From 410451fcec2e9d6c6e7d2371a401981d4d73faad Mon Sep 17 00:00:00 2001 From: calderwoodra Date: Thu, 15 Feb 2018 11:11:12 -0800 Subject: Implemented hangouts connection into GoogleMainActivity. Bug: 72525950 Test: disabled GoogleDialtactsActivity and was able to place a call over wifi. PiperOrigin-RevId: 185867741 Change-Id: Id24b2318a8557a1b3262ff99b62303f4555728ed --- java/com/android/dialer/main/MainActivityPeer.java | 2 ++ .../com/android/dialer/main/impl/MainSearchController.java | 2 +- java/com/android/dialer/main/impl/NewMainActivityPeer.java | 3 +++ java/com/android/dialer/main/impl/OldMainActivityPeer.java | 14 +++++++++++--- 4 files changed, 17 insertions(+), 4 deletions(-) (limited to 'java/com/android/dialer/main') diff --git a/java/com/android/dialer/main/MainActivityPeer.java b/java/com/android/dialer/main/MainActivityPeer.java index 6457b607b..c1a328a65 100644 --- a/java/com/android/dialer/main/MainActivityPeer.java +++ b/java/com/android/dialer/main/MainActivityPeer.java @@ -28,6 +28,8 @@ public interface MainActivityPeer { void onActivityStop(); + void onActivityDestroyed(); + void onNewIntent(Intent intent); void onActivityResult(int requestCode, int resultCode, Intent data); diff --git a/java/com/android/dialer/main/impl/MainSearchController.java b/java/com/android/dialer/main/impl/MainSearchController.java index 7098f8844..d0e593c80 100644 --- a/java/com/android/dialer/main/impl/MainSearchController.java +++ b/java/com/android/dialer/main/impl/MainSearchController.java @@ -261,7 +261,7 @@ public class MainSearchController implements SearchBarListener { *

Unless this method is being called for the first time in {@link #openSearch(Optional)} or * {@link #showDialpad(boolean)}, it should never return null. */ - private DialpadFragment getDialpadFragment() { + protected DialpadFragment getDialpadFragment() { return (DialpadFragment) mainActivity.getFragmentManager().findFragmentByTag(DIALPAD_FRAGMENT_TAG); } diff --git a/java/com/android/dialer/main/impl/NewMainActivityPeer.java b/java/com/android/dialer/main/impl/NewMainActivityPeer.java index 0a85667a1..ed67df936 100644 --- a/java/com/android/dialer/main/impl/NewMainActivityPeer.java +++ b/java/com/android/dialer/main/impl/NewMainActivityPeer.java @@ -59,6 +59,9 @@ public class NewMainActivityPeer implements MainActivityPeer { @Override public void onActivityStop() {} + @Override + public void onActivityDestroyed() {} + @Override public void onNewIntent(Intent intent) {} diff --git a/java/com/android/dialer/main/impl/OldMainActivityPeer.java b/java/com/android/dialer/main/impl/OldMainActivityPeer.java index c46e61bd0..b63970103 100644 --- a/java/com/android/dialer/main/impl/OldMainActivityPeer.java +++ b/java/com/android/dialer/main/impl/OldMainActivityPeer.java @@ -191,7 +191,7 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen searchController = getNewMainSearchController(bottomNav, fab, toolbar); toolbar.setSearchBarListener(searchController); - onDialpadQueryChangedListener = new MainOnDialpadQueryChangedListener(searchController); + onDialpadQueryChangedListener = getNewOnDialpadQueryChangedListener(searchController); dialpadListener = new MainDialpadListener(mainActivity, searchController, getLastOutgoingCallListener); searchFragmentListener = new MainSearchFragmentListener(searchController); @@ -285,6 +285,9 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen mainActivity.getSystemService(KeyguardManager.class).isKeyguardLocked()); } + @Override + public void onActivityDestroyed() {} + private void showPostCallPrompt() { if (TelecomUtil.isInManagedCall(mainActivity)) { // No prompt to show if the user is in a call @@ -360,6 +363,11 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen return new MainSearchController(mainActivity, bottomNavBar, fab, mainToolbar); } + public MainOnDialpadQueryChangedListener getNewOnDialpadQueryChangedListener( + MainSearchController mainSearchController) { + return new MainOnDialpadQueryChangedListener(mainSearchController); + } + /** @see OnContactSelectedListener */ private static final class MainOnContactSelectedListener implements OnContactSelectedListener { @@ -378,12 +386,12 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen } /** @see OnDialpadQueryChangedListener */ - private static final class MainOnDialpadQueryChangedListener + protected static class MainOnDialpadQueryChangedListener implements OnDialpadQueryChangedListener { private final MainSearchController searchController; - MainOnDialpadQueryChangedListener(MainSearchController searchController) { + protected MainOnDialpadQueryChangedListener(MainSearchController searchController) { this.searchController = searchController; } -- cgit v1.2.3 From a4377191c9a8201d983f66979b56b26b6221967b Mon Sep 17 00:00:00 2001 From: yueg Date: Thu, 15 Feb 2018 11:53:09 -0800 Subject: Add logging to NUI. Including: - switching tabs - touch search list - press back button - click search bar and voice button - click FAB Test: MainActivityOldPeerTest, MainSearchControllerTest PiperOrigin-RevId: 185875596 Change-Id: Ie7824ce2f7a2570327abdb35cef1538cad786e73 --- .../dialer/main/impl/MainSearchController.java | 19 ++++++++++ .../dialer/main/impl/OldMainActivityPeer.java | 43 ++++++++++++++++++++-- 2 files changed, 58 insertions(+), 4 deletions(-) (limited to 'java/com/android/dialer/main') diff --git a/java/com/android/dialer/main/impl/MainSearchController.java b/java/com/android/dialer/main/impl/MainSearchController.java index d0e593c80..e0d42abe6 100644 --- a/java/com/android/dialer/main/impl/MainSearchController.java +++ b/java/com/android/dialer/main/impl/MainSearchController.java @@ -40,6 +40,7 @@ import com.android.dialer.constants.ActivityRequestCodes; import com.android.dialer.dialpadview.DialpadFragment; import com.android.dialer.dialpadview.DialpadFragment.DialpadListener; import com.android.dialer.dialpadview.DialpadFragment.OnDialpadQueryChangedListener; +import com.android.dialer.logging.DialerImpression; import com.android.dialer.logging.Logger; import com.android.dialer.logging.ScreenEvent; import com.android.dialer.main.impl.bottomnav.BottomNavBar; @@ -204,14 +205,23 @@ public class MainSearchController implements SearchBarListener { public void onSearchListTouch() { if (isDialpadVisible()) { if (TextUtils.isEmpty(getDialpadFragment().getQuery())) { + Logger.get(mainActivity) + .logImpression( + DialerImpression.Type.NUI_TOUCH_DIALPAD_SEARCH_LIST_TO_CLOSE_SEARCH_AND_DIALPAD); closeSearch(true); } else { + Logger.get(mainActivity) + .logImpression(DialerImpression.Type.NUI_TOUCH_DIALPAD_SEARCH_LIST_TO_HIDE_DIALPAD); hideDialpad(/* animate=*/ true, /* bottomNavVisible=*/ false); } } else if (isSearchVisible()) { if (TextUtils.isEmpty(toolbar.getQuery())) { + Logger.get(mainActivity) + .logImpression(DialerImpression.Type.NUI_TOUCH_SEARCH_LIST_TO_CLOSE_SEARCH); closeSearch(true); } else { + Logger.get(mainActivity) + .logImpression(DialerImpression.Type.NUI_TOUCH_SEARCH_LIST_TO_HIDE_KEYBOARD); toolbar.hideKeyboard(); } } @@ -225,10 +235,17 @@ public class MainSearchController implements SearchBarListener { public boolean onBackPressed() { if (isDialpadVisible() && !TextUtils.isEmpty(getDialpadFragment().getQuery())) { LogUtil.i("MainSearchController#onBackPressed", "Dialpad visible with query"); + Logger.get(mainActivity) + .logImpression(DialerImpression.Type.NUI_PRESS_BACK_BUTTON_TO_HIDE_DIALPAD); hideDialpad(/* animate=*/ true, /* bottomNavVisible=*/ false); return true; } else if (isSearchVisible()) { LogUtil.i("MainSearchController#onBackPressed", "Search is visible"); + Logger.get(mainActivity) + .logImpression( + isDialpadVisible() + ? DialerImpression.Type.NUI_PRESS_BACK_BUTTON_TO_CLOSE_SEARCH_AND_DIALPAD + : DialerImpression.Type.NUI_PRESS_BACK_BUTTON_TO_CLOSE_SEARCH); closeSearch(true); return true; } else { @@ -297,6 +314,7 @@ public class MainSearchController implements SearchBarListener { */ @Override public void onSearchBarClicked() { + Logger.get(mainActivity).logImpression(DialerImpression.Type.NUI_CLICK_SEARCH_BAR); openSearch(Optional.absent()); } @@ -350,6 +368,7 @@ public class MainSearchController implements SearchBarListener { @Override public void onVoiceButtonClicked(VoiceSearchResultCallback voiceSearchResultCallback) { + Logger.get(mainActivity).logImpression(DialerImpression.Type.NUI_CLICK_SEARCH_BAR_VOICE_BUTTON); try { Intent voiceIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); mainActivity.startActivityForResult(voiceIntent, ActivityRequestCodes.DIALTACTS_VOICE_SEARCH); diff --git a/java/com/android/dialer/main/impl/OldMainActivityPeer.java b/java/com/android/dialer/main/impl/OldMainActivityPeer.java index b63970103..07c7185ae 100644 --- a/java/com/android/dialer/main/impl/OldMainActivityPeer.java +++ b/java/com/android/dialer/main/impl/OldMainActivityPeer.java @@ -66,6 +66,8 @@ import com.android.dialer.dialpadview.DialpadFragment.DialpadListener; import com.android.dialer.dialpadview.DialpadFragment.LastOutgoingCallCallback; import com.android.dialer.dialpadview.DialpadFragment.OnDialpadQueryChangedListener; import com.android.dialer.interactions.PhoneNumberInteraction; +import com.android.dialer.logging.DialerImpression; +import com.android.dialer.logging.Logger; import com.android.dialer.main.MainActivityPeer; import com.android.dialer.main.impl.bottomnav.BottomNavBar; import com.android.dialer.main.impl.bottomnav.BottomNavBar.OnBottomNavTabSelectedListener; @@ -154,6 +156,7 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen @Override public void onActivityCreate(Bundle savedInstanceState) { + LogUtil.enterBlock("OldMainActivityPeer.onActivityCreate"); mainActivity.setContentView(R.layout.main_activity); initUiListeners(); initLayout(savedInstanceState); @@ -173,14 +176,19 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen snackbarContainer = mainActivity.findViewById(R.id.coordinator_layout); FloatingActionButton fab = mainActivity.findViewById(R.id.fab); - fab.setOnClickListener(v -> searchController.showDialpad(true)); + fab.setOnClickListener( + v -> { + Logger.get(mainActivity) + .logImpression(DialerImpression.Type.NUI_CLICK_FAB_TO_OPEN_DIALPAD); + searchController.showDialpad(true); + }); MainToolbar toolbar = mainActivity.findViewById(R.id.toolbar); mainActivity.setSupportActionBar(mainActivity.findViewById(R.id.toolbar)); bottomNav = mainActivity.findViewById(R.id.bottom_nav_bar); MainBottomNavBarBottomNavTabListener bottomNavTabListener = - new MainBottomNavBarBottomNavTabListener(mainActivity.getFragmentManager()); + new MainBottomNavBarBottomNavTabListener(mainActivity, mainActivity.getFragmentManager()); bottomNav.addOnTabSelectedListener(bottomNavTabListener); callLogFragmentListener = @@ -222,6 +230,7 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen @Override public void onNewIntent(Intent intent) { + LogUtil.enterBlock("OldMainActivityPeer.onNewIntent"); showTabOnIntent(intent); } @@ -312,10 +321,15 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { + LogUtil.i( + "OldMainActivityPeer.onActivityResult", + "requestCode:%d, resultCode:%d", + requestCode, + resultCode); if (requestCode == ActivityRequestCodes.DIALTACTS_VOICE_SEARCH) { searchController.onVoiceResults(resultCode, data); } else { - LogUtil.e("MainActivity.onActivityResult", "Unknown request code: " + requestCode); + LogUtil.e("OldMainActivityPeer.onActivityResult", "Unknown request code: " + requestCode); } } @@ -353,6 +367,8 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen return (T) onPhoneNumberPickerActionListener; } else if (callbackInterface.isInstance(oldSpeedDialFragmentHost)) { return (T) oldSpeedDialFragmentHost; + } else if (callbackInterface.isInstance(searchController)) { + return (T) searchController; } else { return null; } @@ -802,13 +818,20 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen private static final String VOICEMAIL_TAG = "voicemail"; private final FragmentManager fragmentManager; + private final Context context; + @TabIndex private int selectedTab = -1; - private MainBottomNavBarBottomNavTabListener(FragmentManager fragmentManager) { + private MainBottomNavBarBottomNavTabListener(Context context, FragmentManager fragmentManager) { this.fragmentManager = fragmentManager; + this.context = context; } @Override public void onSpeedDialSelected() { + if (selectedTab != TabIndex.SPEED_DIAL) { + Logger.get(context).logImpression(DialerImpression.Type.NUI_SWITCH_TAB_TO_FAVORITE); + selectedTab = TabIndex.SPEED_DIAL; + } hideAllFragments(); Fragment fragment = fragmentManager.findFragmentByTag(SPEED_DIAL_TAG); if (fragment == null) { @@ -823,6 +846,10 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen @Override public void onCallLogSelected() { + if (selectedTab != TabIndex.CALL_LOG) { + Logger.get(context).logImpression(DialerImpression.Type.NUI_SWITCH_TAB_TO_CALL_LOG); + selectedTab = TabIndex.CALL_LOG; + } hideAllFragments(); CallLogFragment fragment = (CallLogFragment) fragmentManager.findFragmentByTag(CALL_LOG_TAG); if (fragment == null) { @@ -837,6 +864,10 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen @Override public void onContactsSelected() { + if (selectedTab != TabIndex.CONTACTS) { + Logger.get(context).logImpression(DialerImpression.Type.NUI_SWITCH_TAB_TO_CONTACTS); + selectedTab = TabIndex.CONTACTS; + } hideAllFragments(); ContactsFragment fragment = (ContactsFragment) fragmentManager.findFragmentByTag(CONTACTS_TAG); @@ -855,6 +886,10 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen @Override public void onVoicemailSelected() { + if (selectedTab != TabIndex.VOICEMAIL) { + Logger.get(context).logImpression(DialerImpression.Type.NUI_SWITCH_TAB_TO_VOICEMAIL); + selectedTab = TabIndex.VOICEMAIL; + } hideAllFragments(); VisualVoicemailCallLogFragment fragment = (VisualVoicemailCallLogFragment) fragmentManager.findFragmentByTag(VOICEMAIL_TAG); -- cgit v1.2.3 From a9776efc28f13671fe01c7a2ca5513d462e00b3c Mon Sep 17 00:00:00 2001 From: calderwoodra Date: Thu, 15 Feb 2018 12:47:04 -0800 Subject: Do no preload dialpad fragment when opening search through search bar. If the dialpad is preloaded it steals focus from the search bar. Aside from this, I believe this change also caused other regressions and makes the code harder to understand. Test: tap PiperOrigin-RevId: 185883795 Change-Id: Idbaca1df50ed02a698eb454cbb9de26a11e35f05 --- .../dialer/main/impl/MainSearchController.java | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) (limited to 'java/com/android/dialer/main') diff --git a/java/com/android/dialer/main/impl/MainSearchController.java b/java/com/android/dialer/main/impl/MainSearchController.java index e0d42abe6..9b734f40c 100644 --- a/java/com/android/dialer/main/impl/MainSearchController.java +++ b/java/com/android/dialer/main/impl/MainSearchController.java @@ -269,15 +269,12 @@ public class MainSearchController implements SearchBarListener { mainActivity.getFragmentManager().beginTransaction().remove(getSearchFragment()).commit(); // Clear the dialpad so the phone number isn't persisted between search sessions. - getDialpadFragment().clearDialpad(); + if (getDialpadFragment() != null) { + getDialpadFragment().clearDialpad(); + } } - /** - * Returns {@link DialpadFragment}. - * - *

Unless this method is being called for the first time in {@link #openSearch(Optional)} or - * {@link #showDialpad(boolean)}, it should never return null. - */ + @Nullable protected DialpadFragment getDialpadFragment() { return (DialpadFragment) mainActivity.getFragmentManager().findFragmentByTag(DIALPAD_FRAGMENT_TAG); @@ -334,14 +331,6 @@ public class MainSearchController implements SearchBarListener { transaction.show(getSearchFragment()); } - // Add the dialpad fragment but keep it hidden - if (getDialpadFragment() == null) { - DialpadFragment dialpadFragment = new DialpadFragment(); - transaction - .add(R.id.dialpad_fragment_container, dialpadFragment, DIALPAD_FRAGMENT_TAG) - .hide(dialpadFragment); - } - transaction.commit(); } -- cgit v1.2.3