summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/calllog/ui
diff options
context:
space:
mode:
authorEric Erfanian <erfanian@google.com>2017-05-03 10:27:13 -0700
committerEric Erfanian <erfanian@google.com>2017-05-03 12:01:21 -0700
commit8369df095a73a77b3715f8ae7ba06089cebca4ce (patch)
tree1a45d60921e293c6088efeaf4d9c408456f3e0e2 /java/com/android/dialer/calllog/ui
parentafa29d4a8659eeffc8d92a6216b154f594eeb895 (diff)
This change reflects the Dialer V10 RC00 branch.
RC00 is based on: branch: dialer-android_release_branch/153304843.1 synced to: 153304843 following the instructions at go/dialer-aosp-release. In this release: * Removes final apache sources. * Uses native lite compilation. More drops will follow with subsequent release candidates until we reach our final v10 release, in cadence with our prebuilt drops. Test: TreeHugger, on device Change-Id: Ic9684057230f9b579c777820c746cd21bf45ec0f
Diffstat (limited to 'java/com/android/dialer/calllog/ui')
-rw-r--r--java/com/android/dialer/calllog/ui/AndroidManifest.xml16
-rw-r--r--java/com/android/dialer/calllog/ui/AnnotatedCallLogCursorLoader.java48
-rw-r--r--java/com/android/dialer/calllog/ui/NewCallLogFragment.java138
-rw-r--r--java/com/android/dialer/calllog/ui/res/layout/new_call_log_entry.xml33
-rw-r--r--java/com/android/dialer/calllog/ui/res/layout/new_call_log_fragment.xml22
5 files changed, 257 insertions, 0 deletions
diff --git a/java/com/android/dialer/calllog/ui/AndroidManifest.xml b/java/com/android/dialer/calllog/ui/AndroidManifest.xml
new file mode 100644
index 000000000..228167749
--- /dev/null
+++ b/java/com/android/dialer/calllog/ui/AndroidManifest.xml
@@ -0,0 +1,16 @@
+<!--
+ ~ Copyright (C) 2017 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License
+ -->
+<manifest package="com.android.dialer.calllog"/>
diff --git a/java/com/android/dialer/calllog/ui/AnnotatedCallLogCursorLoader.java b/java/com/android/dialer/calllog/ui/AnnotatedCallLogCursorLoader.java
new file mode 100644
index 000000000..cd8622e80
--- /dev/null
+++ b/java/com/android/dialer/calllog/ui/AnnotatedCallLogCursorLoader.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package com.android.dialer.calllog.ui;
+
+import android.annotation.TargetApi;
+import android.content.Context;
+import android.content.CursorLoader;
+import android.database.Cursor;
+import android.database.sqlite.SQLiteDatabase;
+import android.os.Build;
+import com.android.dialer.calllog.database.AnnotatedCallLog;
+import com.android.dialer.calllog.database.AnnotatedCallLog.Columns;
+
+/** CursorLoader which reads the annotated call log. */
+class AnnotatedCallLogCursorLoader extends CursorLoader {
+
+ AnnotatedCallLogCursorLoader(Context context) {
+ super(context);
+ }
+
+ @TargetApi(Build.VERSION_CODES.M) // Uses try-with-resources
+ @Override
+ public Cursor loadInBackground() {
+ try (SQLiteDatabase readableDatabase = AnnotatedCallLog.getReadableDatabase(getContext())) {
+ return readableDatabase.rawQuery(
+ "SELECT * FROM "
+ + AnnotatedCallLog.TABLE_NAME
+ + " ORDER BY "
+ + Columns.TIMESTAMP
+ + " DESC",
+ null /* selectionArgs */);
+ }
+ }
+}
diff --git a/java/com/android/dialer/calllog/ui/NewCallLogFragment.java b/java/com/android/dialer/calllog/ui/NewCallLogFragment.java
new file mode 100644
index 000000000..b8f2b1326
--- /dev/null
+++ b/java/com/android/dialer/calllog/ui/NewCallLogFragment.java
@@ -0,0 +1,138 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+package com.android.dialer.calllog.ui;
+
+import android.app.Fragment;
+import android.app.LoaderManager.LoaderCallbacks;
+import android.content.Context;
+import android.content.Loader;
+import android.database.Cursor;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.CursorAdapter;
+import android.widget.ListView;
+import android.widget.SimpleCursorAdapter;
+import android.widget.TextView;
+import com.android.dialer.calllog.CallLogComponent;
+import com.android.dialer.calllog.CallLogFramework;
+import com.android.dialer.calllog.CallLogFramework.CallLogUi;
+import com.android.dialer.calllog.database.AnnotatedCallLog.Columns;
+import com.android.dialer.common.LogUtil;
+import java.text.SimpleDateFormat;
+import java.util.Locale;
+
+/** The "new" call log fragment implementation, which is built on top of the annotated call log. */
+public final class NewCallLogFragment extends Fragment
+ implements CallLogUi, LoaderCallbacks<Cursor> {
+
+ private CursorAdapter cursorAdapter;
+
+ public NewCallLogFragment() {
+ LogUtil.enterBlock("NewCallLogFragment.NewCallLogFragment");
+ }
+
+ @Override
+ public void onCreate(Bundle state) {
+ super.onCreate(state);
+
+ LogUtil.enterBlock("NewCallLogFragment.onCreate");
+
+ CallLogFramework callLogFramework = CallLogComponent.get(getContext()).callLogFramework();
+ callLogFramework.attachUi(this);
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+
+ LogUtil.enterBlock("NewCallLogFragment.onResume");
+
+ CallLogFramework callLogFramework = CallLogComponent.get(getContext()).callLogFramework();
+ callLogFramework.attachUi(this);
+ }
+
+ @Override
+ public void onPause() {
+ super.onPause();
+
+ LogUtil.enterBlock("NewCallLogFragment.onPause");
+
+ CallLogFramework callLogFramework = CallLogComponent.get(getContext()).callLogFramework();
+ callLogFramework.detachUi();
+ }
+
+ @Override
+ public View onCreateView(
+ LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+ LogUtil.enterBlock("NewCallLogFragment.onCreateView");
+
+ View view = inflater.inflate(R.layout.new_call_log_fragment, container, false);
+ ListView listView = (ListView) view.findViewById(R.id.list);
+
+ this.cursorAdapter =
+ new MyCursorAdapter(
+ getContext(),
+ R.layout.new_call_log_entry,
+ null /* cursor */,
+ new String[] {Columns.TIMESTAMP, Columns.CONTACT_NAME},
+ new int[] {R.id.timestamp, R.id.contact_name},
+ 0);
+ listView.setAdapter(cursorAdapter);
+
+ getLoaderManager().initLoader(0, null, this);
+
+ return view;
+ }
+
+ @Override
+ public void invalidateUi() {
+ LogUtil.enterBlock("NewCallLogFragment.invalidateUi");
+ // TODO: Implementation.
+ }
+
+ @Override
+ public Loader<Cursor> onCreateLoader(int id, Bundle args) {
+ // TODO: This is sort of weird, do we need to implement a content provider?
+ return new AnnotatedCallLogCursorLoader(getContext());
+ }
+
+ @Override
+ public void onLoadFinished(Loader<Cursor> loader, Cursor newCursor) {
+ cursorAdapter.swapCursor(newCursor);
+ }
+
+ @Override
+ public void onLoaderReset(Loader<Cursor> loader) {
+ cursorAdapter.swapCursor(null);
+ }
+
+ private static class MyCursorAdapter extends SimpleCursorAdapter {
+
+ MyCursorAdapter(Context context, int layout, Cursor c, String[] from, int[] to, int flags) {
+ super(context, layout, c, from, to, flags);
+ }
+
+ @Override
+ public void setViewText(TextView view, String text) {
+ if (view.getId() == R.id.timestamp) {
+ text = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.US).format(Long.valueOf(text));
+ }
+ view.setText(text);
+ }
+ }
+}
diff --git a/java/com/android/dialer/calllog/ui/res/layout/new_call_log_entry.xml b/java/com/android/dialer/calllog/ui/res/layout/new_call_log_entry.xml
new file mode 100644
index 000000000..ee3efd002
--- /dev/null
+++ b/java/com/android/dialer/calllog/ui/res/layout/new_call_log_entry.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2017 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License
+ -->
+
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="horizontal">
+
+ <TextView
+ android:id="@+id/timestamp"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"/>
+
+ <TextView
+ android:id="@+id/contact_name"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"/>
+</LinearLayout> \ No newline at end of file
diff --git a/java/com/android/dialer/calllog/ui/res/layout/new_call_log_fragment.xml b/java/com/android/dialer/calllog/ui/res/layout/new_call_log_fragment.xml
new file mode 100644
index 000000000..433dbdd0f
--- /dev/null
+++ b/java/com/android/dialer/calllog/ui/res/layout/new_call_log_fragment.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2017 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License
+ -->
+
+<ListView
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/list"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"/>