diff options
author | zachh <zachh@google.com> | 2017-08-25 16:11:00 -0700 |
---|---|---|
committer | Eric Erfanian <erfanian@google.com> | 2017-08-30 23:27:58 +0000 |
commit | 196e3fe631a3c7a0073273b41e76387d01ed3baf (patch) | |
tree | a93deda491a7cf62949d44a0aaa1cad535c673d5 /java/com/android/dialer | |
parent | 51f2b28ae6a45f57f94e5c9a66081a10aebc8349 (diff) |
Moved new call log fragment to NUI.
I have removed the flag for rolling out the feature and now just rely on the mechanism which enables NUI.
The annotated call log is built when a user views the new call log for the first time using the NUI activity. However, new call log content observers may now be registered before that if the user has a bugfood/debug build. (Previously observers were enabled based on the presence of a phenotype flag which has now been deleted.)
Moving it to NUI involved converting it to a support fragment.
Finally, I temporarily modified the espresso test to target the old call log; it can't work in the NUI until we implement dialing, clearing call history, deleting entries, etc. I considered keeping the new fragment in Dialtacts activity but that wouldn't work because it requires app.Fragments. I'll port the espresso test as soon as is feasible and for now we at least have better coverage for the old call log.
Bug: 34672501
Test: none
PiperOrigin-RevId: 166538972
Change-Id: I7782b93aaf6ad0719f5b9f763fa4752cf5d8ce68
Diffstat (limited to 'java/com/android/dialer')
7 files changed, 32 insertions, 39 deletions
diff --git a/java/com/android/dialer/app/list/DialtactsPagerAdapter.java b/java/com/android/dialer/app/list/DialtactsPagerAdapter.java index d9cb0c1f6..1fbf0f01a 100644 --- a/java/com/android/dialer/app/list/DialtactsPagerAdapter.java +++ b/java/com/android/dialer/app/list/DialtactsPagerAdapter.java @@ -24,9 +24,6 @@ import android.support.v13.app.FragmentPagerAdapter; import android.view.ViewGroup; import com.android.dialer.app.calllog.CallLogFragment; import com.android.dialer.app.calllog.VisualVoicemailCallLogFragment; -import com.android.dialer.calllog.CallLogComponent; -import com.android.dialer.calllog.CallLogFramework; -import com.android.dialer.calllog.ui.NewCallLogFragment; import com.android.dialer.common.Assert; import com.android.dialer.common.LogUtil; import com.android.dialer.configprovider.ConfigProviderBindings; @@ -60,12 +57,10 @@ public class DialtactsPagerAdapter extends FragmentPagerAdapter { private final List<Fragment> fragments = new ArrayList<>(); private final String[] tabTitles; private final boolean useNewSpeedDialTab; - private final boolean useNewCallLogTab; private final boolean useNewContactsTab; private OldSpeedDialFragment oldSpeedDialFragment; private SpeedDialFragment speedDialFragment; private CallLogFragment callLogFragment; - private NewCallLogFragment newCallLogFragment; private AllContactsFragment oldContactsFragment; private ContactsFragment contactsFragment; private CallLogFragment voicemailFragment; @@ -77,8 +72,6 @@ public class DialtactsPagerAdapter extends FragmentPagerAdapter { super(fm); useNewSpeedDialTab = ConfigProviderBindings.get(context).getBoolean("enable_new_favorites_tab", false); - CallLogFramework callLogFramework = CallLogComponent.get(context).callLogFramework(); - useNewCallLogTab = callLogFramework.isNewCallLogEnabled(context); useNewContactsTab = ConfigProviderBindings.get(context).getBoolean("enable_new_contacts_tab", true); this.tabTitles = tabTitles; @@ -108,17 +101,10 @@ public class DialtactsPagerAdapter extends FragmentPagerAdapter { return oldSpeedDialFragment; } case TAB_INDEX_HISTORY: - if (useNewCallLogTab) { - if (newCallLogFragment == null) { - newCallLogFragment = new NewCallLogFragment(); - } - return newCallLogFragment; - } else { - if (callLogFragment == null) { - callLogFragment = new CallLogFragment(CallLogQueryHandler.CALL_TYPE_ALL); - } - return callLogFragment; + if (callLogFragment == null) { + callLogFragment = new CallLogFragment(CallLogQueryHandler.CALL_TYPE_ALL); } + return callLogFragment; case TAB_INDEX_ALL_CONTACTS: if (useNewContactsTab) { if (contactsFragment == null) { @@ -159,8 +145,6 @@ public class DialtactsPagerAdapter extends FragmentPagerAdapter { speedDialFragment = (SpeedDialFragment) fragment; } else if (fragment instanceof CallLogFragment && position == TAB_INDEX_HISTORY) { callLogFragment = (CallLogFragment) fragment; - } else if (fragment instanceof NewCallLogFragment) { - newCallLogFragment = (NewCallLogFragment) fragment; } else if (fragment instanceof ContactsFragment) { contactsFragment = (ContactsFragment) fragment; } else if (fragment instanceof AllContactsFragment) { diff --git a/java/com/android/dialer/calllog/CallLogFramework.java b/java/com/android/dialer/calllog/CallLogFramework.java index d3a2c638e..788e56b93 100644 --- a/java/com/android/dialer/calllog/CallLogFramework.java +++ b/java/com/android/dialer/calllog/CallLogFramework.java @@ -21,11 +21,11 @@ import android.content.SharedPreferences; import android.preference.PreferenceManager; import android.support.annotation.MainThread; import android.support.annotation.Nullable; +import com.android.dialer.buildtype.BuildType; import com.android.dialer.calllog.datasources.CallLogDataSource; import com.android.dialer.calllog.datasources.DataSources; import com.android.dialer.common.Assert; import com.android.dialer.common.LogUtil; -import com.android.dialer.configprovider.ConfigProviderBindings; import javax.inject.Inject; import javax.inject.Singleton; @@ -49,21 +49,20 @@ public final class CallLogFramework implements CallLogDataSource.ContentObserver this.dataSources = dataSources; } - public boolean isNewCallLogEnabled(Context context) { - return ConfigProviderBindings.get(context).getBoolean("enable_new_call_log_tab", false); - } - /** Registers the content observers for all data sources. */ public void registerContentObservers(Context appContext) { LogUtil.enterBlock("CallLogFramework.registerContentObservers"); - if (!isNewCallLogEnabled(appContext)) { - LogUtil.i("CallLogFramework.registerContentObservers", "new call log not enabled"); - return; - } - - for (CallLogDataSource dataSource : dataSources.getDataSourcesIncludingSystemCallLog()) { - dataSource.registerContentObservers(appContext, this); + // This is the same condition used in MainImpl#isNewUiEnabled. It means that bugfood/debug + // users will have "new call log" content observers firing. These observers usually do simple + // things like writing shared preferences. + // TODO(zachh): Find a way to access Main#isNewUiEnabled without creating a circular dependency. + if (BuildType.get() == BuildType.BUGFOOD || LogUtil.isDebugEnabled()) { + for (CallLogDataSource dataSource : dataSources.getDataSourcesIncludingSystemCallLog()) { + dataSource.registerContentObservers(appContext, this); + } + } else { + LogUtil.i("CallLogFramework.registerContentObservers", "not registering content observers"); } } diff --git a/java/com/android/dialer/calllog/ui/CoalescedAnnotatedCallLogCursorLoader.java b/java/com/android/dialer/calllog/ui/CoalescedAnnotatedCallLogCursorLoader.java index 654591688..f45ac27b9 100644 --- a/java/com/android/dialer/calllog/ui/CoalescedAnnotatedCallLogCursorLoader.java +++ b/java/com/android/dialer/calllog/ui/CoalescedAnnotatedCallLogCursorLoader.java @@ -17,8 +17,8 @@ package com.android.dialer.calllog.ui; import android.content.Context; -import android.content.CursorLoader; import android.database.Cursor; +import android.support.v4.content.CursorLoader; import com.android.dialer.CallTypes; import com.android.dialer.calllog.database.contract.AnnotatedCallLogContract.CoalescedAnnotatedCallLog; import com.google.protobuf.InvalidProtocolBufferException; diff --git a/java/com/android/dialer/calllog/ui/NewCallLogFragment.java b/java/com/android/dialer/calllog/ui/NewCallLogFragment.java index 92276786e..ab7381347 100644 --- a/java/com/android/dialer/calllog/ui/NewCallLogFragment.java +++ b/java/com/android/dialer/calllog/ui/NewCallLogFragment.java @@ -15,11 +15,11 @@ */ package com.android.dialer.calllog.ui; -import android.app.Fragment; -import android.app.LoaderManager.LoaderCallbacks; -import android.content.Loader; import android.database.Cursor; import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.support.v4.app.LoaderManager.LoaderCallbacks; +import android.support.v4.content.Loader; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; @@ -65,6 +65,7 @@ public final class NewCallLogFragment extends Fragment DialerExecutorFactory dialerExecutorFactory = DialerExecutorComponent.get(getContext()).dialerExecutorFactory(); + // TODO(zachh): Use support fragment manager and add support for them in executors library. refreshAnnotatedCallLogTask = dialerExecutorFactory .createUiTaskBuilder( @@ -138,6 +139,12 @@ public final class NewCallLogFragment extends Fragment public void onLoadFinished(Loader<Cursor> loader, Cursor newCursor) { LogUtil.enterBlock("NewCallLogFragment.onLoadFinished"); + if (newCursor == null) { + // This might be possible when the annotated call log hasn't been created but we're trying + // to show the call log. + LogUtil.w("NewCallLogFragment.onLoadFinished", "null cursor"); + return; + } // TODO(zachh): Handle empty cursor by showing empty view. recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); recyclerView.setAdapter(new NewCallLogAdapter(newCursor, System::currentTimeMillis)); diff --git a/java/com/android/dialer/main/impl/MainImpl.java b/java/com/android/dialer/main/impl/MainImpl.java index d29e8c0a5..675533c04 100644 --- a/java/com/android/dialer/main/impl/MainImpl.java +++ b/java/com/android/dialer/main/impl/MainImpl.java @@ -21,11 +21,11 @@ import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; +import android.os.Build; import android.os.Build.VERSION_CODES; import android.support.v4.content.pm.ShortcutInfoCompat; import android.support.v4.content.pm.ShortcutManagerCompat; import android.support.v4.graphics.drawable.IconCompat; -import android.support.v4.os.BuildCompat; import com.android.dialer.buildtype.BuildType; import com.android.dialer.common.LogUtil; import com.android.dialer.main.Main; @@ -36,7 +36,7 @@ final class MainImpl implements Main { private static final String SHORTCUT_KEY = "nui_launcher_shortcut"; @Inject - public MainImpl() {} + MainImpl() {} @Override public boolean isNewUiEnabled(Context context) { @@ -46,7 +46,7 @@ final class MainImpl implements Main { @Override public void createNewUiLauncherShortcut(Context context) { enableComponent(context); - if (BuildCompat.isAtLeastO()) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { createLauncherShortcutO(context); } else { createLauncherShortcutPreO(context); diff --git a/java/com/android/dialer/main/impl/MainPagerAdapter.java b/java/com/android/dialer/main/impl/MainPagerAdapter.java index 33d85ca41..10256a128 100644 --- a/java/com/android/dialer/main/impl/MainPagerAdapter.java +++ b/java/com/android/dialer/main/impl/MainPagerAdapter.java @@ -21,6 +21,7 @@ import android.support.annotation.IntDef; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentStatePagerAdapter; +import com.android.dialer.calllog.ui.NewCallLogFragment; import com.android.dialer.common.Assert; import com.android.dialer.voicemail.listui.VoicemailFragment; import java.lang.annotation.Retention; @@ -60,6 +61,8 @@ final class MainPagerAdapter extends FragmentStatePagerAdapter { switch (position) { case TabIndex.VOICEMAIL: return new VoicemailFragment(); + case TabIndex.HISTORY: + return new NewCallLogFragment(); default: return new StubFragment(); } diff --git a/java/com/android/dialer/simulator/impl/SimulatorActionProvider.java b/java/com/android/dialer/simulator/impl/SimulatorActionProvider.java index 96591135b..f095a5993 100644 --- a/java/com/android/dialer/simulator/impl/SimulatorActionProvider.java +++ b/java/com/android/dialer/simulator/impl/SimulatorActionProvider.java @@ -99,7 +99,7 @@ final class SimulatorActionProvider extends ActionProvider { subMenu .add("Clean database") .setOnMenuItemClickListener( - (itme) -> { + (item) -> { cleanDatabase(); return true; }); |