From 8369df095a73a77b3715f8ae7ba06089cebca4ce Mon Sep 17 00:00:00 2001 From: Eric Erfanian Date: Wed, 3 May 2017 10:27:13 -0700 Subject: 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 --- .../android/dialer/calllog/ui/AndroidManifest.xml | 16 +++ .../calllog/ui/AnnotatedCallLogCursorLoader.java | 48 +++++++ .../dialer/calllog/ui/NewCallLogFragment.java | 138 +++++++++++++++++++++ .../calllog/ui/res/layout/new_call_log_entry.xml | 33 +++++ .../ui/res/layout/new_call_log_fragment.xml | 22 ++++ 5 files changed, 257 insertions(+) create mode 100644 java/com/android/dialer/calllog/ui/AndroidManifest.xml create mode 100644 java/com/android/dialer/calllog/ui/AnnotatedCallLogCursorLoader.java create mode 100644 java/com/android/dialer/calllog/ui/NewCallLogFragment.java create mode 100644 java/com/android/dialer/calllog/ui/res/layout/new_call_log_entry.xml create mode 100644 java/com/android/dialer/calllog/ui/res/layout/new_call_log_fragment.xml (limited to 'java/com/android/dialer/calllog/ui') 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 @@ + + 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 { + + 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 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 loader, Cursor newCursor) { + cursorAdapter.swapCursor(newCursor); + } + + @Override + public void onLoaderReset(Loader 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 @@ + + + + + + + + + \ 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 @@ + + + + -- cgit v1.2.3