From 8074af74464a162e01296cc2b0b707f1c9d12bb7 Mon Sep 17 00:00:00 2001 From: calderwoodra Date: Fri, 16 Feb 2018 13:20:56 -0800 Subject: Fix a few UI issues based around multiselect in new nav. - No longer crashes when entering mw-mode while in multiselect - Configuration changes now properly restore bottom nav visibility - toolbar shadow is now only visible in search Bug: 72525324 Test: MainActivityOldPeerSearchIntegrationTest PiperOrigin-RevId: 186037379 Change-Id: I5fc00c8091e85fc67482b2131944fb776626d06f --- .../dialer/main/impl/MainSearchController.java | 16 +++++++++------- .../android/dialer/main/impl/OldMainActivityPeer.java | 19 +++++++++++++++---- .../dialer/main/impl/res/layout/main_activity.xml | 4 +++- 3 files changed, 27 insertions(+), 12 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 9b734f40c..8d9e784a7 100644 --- a/java/com/android/dialer/main/impl/MainSearchController.java +++ b/java/com/android/dialer/main/impl/MainSearchController.java @@ -68,8 +68,7 @@ import java.util.ArrayList; public class MainSearchController implements SearchBarListener { private static final String KEY_IS_FAB_HIDDEN = "is_fab_hidden"; - private static final String KEY_CURRENT_TAB = "current_tab"; - private static final String KEY_BOTTOM_NAV_VISIBILITY = "bottom_nav_visibility"; + private static final String KEY_TOOLBAR_SHADOW_VISIBILITY = "toolbar_shadow_visibility"; private static final String KEY_IS_TOOLBAR_EXPANDED = "is_toolbar_expanded"; private static final String KEY_IS_TOOLBAR_SLIDE_UP = "is_toolbar_slide_up"; @@ -80,16 +79,19 @@ public class MainSearchController implements SearchBarListener { private final BottomNavBar bottomNav; private final FloatingActionButton fab; private final MainToolbar toolbar; + private final View toolbarShadow; public MainSearchController( MainActivity mainActivity, BottomNavBar bottomNav, FloatingActionButton fab, - MainToolbar toolbar) { + MainToolbar toolbar, + View toolbarShadow) { this.mainActivity = mainActivity; this.bottomNav = bottomNav; this.fab = fab; this.toolbar = toolbar; + this.toolbarShadow = toolbarShadow; } /** Should be called if we're showing the dialpad because of a new ACTION_DIAL intent. */ @@ -266,6 +268,7 @@ public class MainSearchController implements SearchBarListener { } showBottomNav(); toolbar.collapse(animate); + toolbarShadow.setVisibility(View.GONE); mainActivity.getFragmentManager().beginTransaction().remove(getSearchFragment()).commit(); // Clear the dialpad so the phone number isn't persisted between search sessions. @@ -319,6 +322,7 @@ public class MainSearchController implements SearchBarListener { fab.hide(); toolbar.expand(/* animate=*/ true, query); toolbar.showKeyboard(); + toolbarShadow.setVisibility(View.VISIBLE); hideBottomNav(); FragmentTransaction transaction = mainActivity.getFragmentManager().beginTransaction(); @@ -396,15 +400,13 @@ public class MainSearchController implements SearchBarListener { public void onSaveInstanceState(Bundle bundle) { bundle.putBoolean(KEY_IS_FAB_HIDDEN, !fab.isShown()); - bundle.putInt(KEY_CURRENT_TAB, bottomNav.getSelectedTab()); - bundle.putInt(KEY_BOTTOM_NAV_VISIBILITY, bottomNav.getVisibility()); + bundle.putInt(KEY_TOOLBAR_SHADOW_VISIBILITY, toolbarShadow.getVisibility()); bundle.putBoolean(KEY_IS_TOOLBAR_EXPANDED, toolbar.isExpanded()); bundle.putBoolean(KEY_IS_TOOLBAR_SLIDE_UP, toolbar.isSlideUp()); } public void onRestoreInstanceState(Bundle savedInstanceState) { - bottomNav.selectTab(savedInstanceState.getInt(KEY_CURRENT_TAB)); - bottomNav.setVisibility(savedInstanceState.getInt(KEY_BOTTOM_NAV_VISIBILITY)); + toolbarShadow.setVisibility(savedInstanceState.getInt(KEY_TOOLBAR_SHADOW_VISIBILITY)); if (savedInstanceState.getBoolean(KEY_IS_FAB_HIDDEN, false)) { fab.hide(); } diff --git a/java/com/android/dialer/main/impl/OldMainActivityPeer.java b/java/com/android/dialer/main/impl/OldMainActivityPeer.java index 07c7185ae..7d9216c3f 100644 --- a/java/com/android/dialer/main/impl/OldMainActivityPeer.java +++ b/java/com/android/dialer/main/impl/OldMainActivityPeer.java @@ -196,7 +196,9 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen mainActivity, mainActivity.getContentResolver(), bottomNav, toolbar); bottomNav.addOnTabSelectedListener(callLogFragmentListener); - searchController = getNewMainSearchController(bottomNav, fab, toolbar); + searchController = + getNewMainSearchController( + bottomNav, fab, toolbar, mainActivity.findViewById(R.id.toolbar_shadow)); toolbar.setSearchBarListener(searchController); onDialpadQueryChangedListener = getNewOnDialpadQueryChangedListener(searchController); @@ -284,6 +286,13 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen .getDatabaseHelper(mainActivity) .startSmartDialUpdateThread(forceUpdate); showPostCallPrompt(); + + if (searchController.isInSearch() + || callLogAdapterOnActionModeStateChangedListener.isActionModeStateEnabled()) { + bottomNav.setVisibility(View.GONE); + } else { + bottomNav.setVisibility(View.VISIBLE); + } } @Override @@ -375,8 +384,11 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen } public MainSearchController getNewMainSearchController( - BottomNavBar bottomNavBar, FloatingActionButton fab, MainToolbar mainToolbar) { - return new MainSearchController(mainActivity, bottomNavBar, fab, mainToolbar); + BottomNavBar bottomNavBar, + FloatingActionButton fab, + MainToolbar mainToolbar, + View toolbarShadow) { + return new MainSearchController(mainActivity, bottomNavBar, fab, mainToolbar, toolbarShadow); } public MainOnDialpadQueryChangedListener getNewOnDialpadQueryChangedListener( @@ -482,7 +494,6 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen } /** @see CallLogAdapter.OnActionModeStateChangedListener */ - // TODO(calderwoodra): What is the purpose of this listener? private static final class MainCallLogAdapterOnActionModeStateChangedListener implements CallLogAdapter.OnActionModeStateChangedListener { diff --git a/java/com/android/dialer/main/impl/res/layout/main_activity.xml b/java/com/android/dialer/main/impl/res/layout/main_activity.xml index d8b13a6c2..4f0284126 100644 --- a/java/com/android/dialer/main/impl/res/layout/main_activity.xml +++ b/java/com/android/dialer/main/impl/res/layout/main_activity.xml @@ -68,11 +68,13 @@ layout="@layout/toolbar_layout"/> + android:layout_below="@+id/toolbar" + android:visibility="gone"/> -- cgit v1.2.3 From 6bc46129b93069868d2425fb9d9c50e1dabe6502 Mon Sep 17 00:00:00 2001 From: calderwoodra Date: Tue, 20 Feb 2018 16:14:22 -0800 Subject: Fixed some issues in NUI search bar. - search bar is now the correct height - search bar hint now updates for Google Dialer - search bar now properly slides up when in dialpad search Bug: 72525324 Test: GoogleMainActivityOldPeerIntegrationTest PiperOrigin-RevId: 186379302 Change-Id: If5ad570c89c6a784fa17df422d88e68c30356712 --- .../dialer/main/impl/toolbar/MainToolbar.java | 46 +++++++++++++++++----- .../dialer/main/impl/toolbar/SearchBarView.java | 16 ++++++-- .../toolbar/res/layout/expanded_search_bar.xml | 2 +- .../impl/toolbar/res/layout/toolbar_layout.xml | 9 +++-- .../dialer/main/impl/toolbar/res/values/dimens.xml | 4 +- 5 files changed, 58 insertions(+), 19 deletions(-) (limited to 'java/com/android/dialer/main') diff --git a/java/com/android/dialer/main/impl/toolbar/MainToolbar.java b/java/com/android/dialer/main/impl/toolbar/MainToolbar.java index 604422978..a129fca8b 100644 --- a/java/com/android/dialer/main/impl/toolbar/MainToolbar.java +++ b/java/com/android/dialer/main/impl/toolbar/MainToolbar.java @@ -16,13 +16,17 @@ package com.android.dialer.main.impl.toolbar; +import android.animation.ValueAnimator; +import android.animation.ValueAnimator.AnimatorUpdateListener; import android.content.Context; +import android.support.annotation.StringRes; import android.support.v7.widget.PopupMenu.OnMenuItemClickListener; import android.support.v7.widget.Toolbar; import android.util.AttributeSet; import android.view.MenuItem; import android.view.animation.AccelerateDecelerateInterpolator; import android.widget.ImageButton; +import android.widget.RelativeLayout; import com.android.dialer.common.Assert; import com.android.dialer.util.ViewUtil; import com.google.common.base.Optional; @@ -74,22 +78,40 @@ public final class MainToolbar extends Toolbar implements OnMenuItemClickListene return; } isSlideUp = true; - animate() - .translationY(-getHeight()) - .setDuration(animate ? SLIDE_DURATION : 0) - .setInterpolator(SLIDE_INTERPOLATOR) - .start(); + ValueAnimator animator = ValueAnimator.ofFloat(0, -getHeight()); + animator.setDuration(animate ? SLIDE_DURATION : 0); + animator.setInterpolator(SLIDE_INTERPOLATOR); + animator.addUpdateListener( + new AnimatorUpdateListener() { + @Override + public void onAnimationUpdate(ValueAnimator animation) { + int val = ((Float) animation.getAnimatedValue()).intValue(); + RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) getLayoutParams(); + params.topMargin = val; + requestLayout(); + } + }); + animator.start(); } /** Slides the toolbar down and back onto the screen. */ public void slideDown(boolean animate) { Assert.checkArgument(isSlideUp); isSlideUp = false; - animate() - .translationY(0) - .setDuration(animate ? SLIDE_DURATION : 0) - .setInterpolator(SLIDE_INTERPOLATOR) - .start(); + ValueAnimator animator = ValueAnimator.ofFloat(-getHeight(), 0); + animator.setDuration(animate ? SLIDE_DURATION : 0); + animator.setInterpolator(SLIDE_INTERPOLATOR); + animator.addUpdateListener( + new AnimatorUpdateListener() { + @Override + public void onAnimationUpdate(ValueAnimator animation) { + int val = ((Float) animation.getAnimatedValue()).intValue(); + RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) getLayoutParams(); + params.topMargin = val; + requestLayout(); + } + }); + animator.start(); } /** @see SearchBarView#collapse(boolean) */ @@ -129,4 +151,8 @@ public final class MainToolbar extends Toolbar implements OnMenuItemClickListene public MainToolbarMenu getOverflowMenu() { return overflowMenu; } + + public void setHint(@StringRes int hint) { + searchBar.setHint(hint); + } } diff --git a/java/com/android/dialer/main/impl/toolbar/SearchBarView.java b/java/com/android/dialer/main/impl/toolbar/SearchBarView.java index 95929383b..37ffb9778 100644 --- a/java/com/android/dialer/main/impl/toolbar/SearchBarView.java +++ b/java/com/android/dialer/main/impl/toolbar/SearchBarView.java @@ -22,6 +22,7 @@ import android.animation.ValueAnimator; import android.content.Context; import android.support.annotation.NonNull; import android.support.annotation.Nullable; +import android.support.annotation.StringRes; import android.text.Editable; import android.text.TextUtils; import android.text.TextWatcher; @@ -29,6 +30,7 @@ import android.util.AttributeSet; import android.view.View; import android.widget.EditText; import android.widget.FrameLayout; +import android.widget.TextView; import com.android.dialer.animation.AnimUtils; import com.android.dialer.common.UiUtil; import com.android.dialer.util.DialerUtils; @@ -42,14 +44,15 @@ final class SearchBarView extends FrameLayout { private final float margin; private final float animationEndHeight; + private final float animationStartHeight; private SearchBarListener listener; private EditText searchBox; + private TextView searchBoxTextView; // This useful for when the query didn't actually change. We want to avoid making excessive calls // where we can since IPCs can take a long time on slow networks. private boolean skipLatestTextChange; - private int initialHeight; private boolean isExpanded; private View searchBoxCollapsed; private View searchBoxExpanded; @@ -60,6 +63,8 @@ final class SearchBarView extends FrameLayout { margin = getContext().getResources().getDimension(R.dimen.search_bar_margin); animationEndHeight = getContext().getResources().getDimension(R.dimen.expanded_search_bar_height); + animationStartHeight = + getContext().getResources().getDimension(R.dimen.collapsed_search_bar_height); } @Override @@ -67,6 +72,7 @@ final class SearchBarView extends FrameLayout { super.onFinishInflate(); clearButton = findViewById(R.id.search_clear_button); searchBox = findViewById(R.id.search_view); + searchBoxTextView = findViewById(R.id.search_box_start_search); searchBoxCollapsed = findViewById(R.id.search_box_collapsed); searchBoxExpanded = findViewById(R.id.search_box_expanded); @@ -104,7 +110,6 @@ final class SearchBarView extends FrameLayout { if (isExpanded) { return; } - initialHeight = getHeight(); int duration = animate ? ANIMATION_DURATION : 0; searchBoxExpanded.setVisibility(VISIBLE); @@ -177,7 +182,7 @@ final class SearchBarView extends FrameLayout { params.leftMargin = margin; params.rightMargin = margin; searchBoxExpanded.getLayoutParams().height = - (int) (animationEndHeight - (animationEndHeight - initialHeight) * fraction); + (int) (animationEndHeight - (animationEndHeight - animationStartHeight) * fraction); requestLayout(); } @@ -207,6 +212,11 @@ final class SearchBarView extends FrameLayout { UiUtil.openKeyboardFrom(getContext(), searchBox); } + public void setHint(@StringRes int hint) { + searchBox.setHint(hint); + searchBoxTextView.setText(hint); + } + /** Handles logic for text changes in the search box. */ private class SearchBoxTextWatcher implements TextWatcher { diff --git a/java/com/android/dialer/main/impl/toolbar/res/layout/expanded_search_bar.xml b/java/com/android/dialer/main/impl/toolbar/res/layout/expanded_search_bar.xml index 4e49accae..3bd71b63a 100644 --- a/java/com/android/dialer/main/impl/toolbar/res/layout/expanded_search_bar.xml +++ b/java/com/android/dialer/main/impl/toolbar/res/layout/expanded_search_bar.xml @@ -17,7 +17,7 @@ xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/search_box_expanded" android:layout_width="match_parent" - android:layout_height="wrap_content" + android:layout_height="@dimen/expanded_search_bar_height" android:visibility="invisible"> @@ -27,6 +27,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="@dimen/search_bar_margin" + android:minHeight="@dimen/collapsed_search_bar_height" android:background="@drawable/rounded_corner" android:elevation="4dp"> @@ -58,8 +59,8 @@ android:layout_marginStart="8dp" android:layout_centerVertical="true" android:fontFamily="sans-serif" - android:hint="@string/dialer_hint_find_contact" - android:textColorHint="@color/dialer_secondary_text_color" + android:text="@string/dialer_hint_find_contact" + android:textColor="@color/dialer_secondary_text_color" android:textSize="16dp"/> - \ No newline at end of file + diff --git a/java/com/android/dialer/main/impl/toolbar/res/values/dimens.xml b/java/com/android/dialer/main/impl/toolbar/res/values/dimens.xml index f54f053da..ed6f197fa 100644 --- a/java/com/android/dialer/main/impl/toolbar/res/values/dimens.xml +++ b/java/com/android/dialer/main/impl/toolbar/res/values/dimens.xml @@ -16,5 +16,7 @@ --> 8dp - 60dp + 48dp + + 64dp \ No newline at end of file -- cgit v1.2.3 From 8d26b821c9754a9a81915ccb1b431efbb8550670 Mon Sep 17 00:00:00 2001 From: calderwoodra Date: Tue, 20 Feb 2018 17:44:07 -0800 Subject: Fixed some bugs in NUI search. - Nearby places promo now displays properly - Dialpad now properly handles dial intents - placing calls from search now closes search - placing calls from search now closes the keyboard - toolbar shadow is now visible when search is started from the dialpad. Bug: 72525324 Test: MainActivityOldPeerSearchIntegrationTest PiperOrigin-RevId: 186390952 Change-Id: I7e10ef0499c787da2d1820cae915f2d42645303b --- java/com/android/dialer/main/MainActivityPeer.java | 2 + .../com/android/dialer/main/impl/MainActivity.java | 7 ++++ .../dialer/main/impl/MainSearchController.java | 49 ++++++++++++++++++---- .../dialer/main/impl/NewMainActivityPeer.java | 3 ++ .../dialer/main/impl/OldMainActivityPeer.java | 34 +++++++++------ .../main/impl/toolbar/SearchBarListener.java | 7 ++++ 6 files changed, 80 insertions(+), 22 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 c1a328a65..9c5627be8 100644 --- a/java/com/android/dialer/main/MainActivityPeer.java +++ b/java/com/android/dialer/main/MainActivityPeer.java @@ -26,6 +26,8 @@ public interface MainActivityPeer { void onActivityResume(); + void onUserLeaveHint(); + void onActivityStop(); void onActivityDestroyed(); diff --git a/java/com/android/dialer/main/impl/MainActivity.java b/java/com/android/dialer/main/impl/MainActivity.java index ac2cb389e..1646becf4 100644 --- a/java/com/android/dialer/main/impl/MainActivity.java +++ b/java/com/android/dialer/main/impl/MainActivity.java @@ -82,6 +82,7 @@ public class MainActivity extends TransactionSafeActivity @Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); + setIntent(intent); activePeer.onNewIntent(intent); } @@ -91,6 +92,12 @@ public class MainActivity extends TransactionSafeActivity activePeer.onActivityResume(); } + @Override + protected void onUserLeaveHint() { + super.onUserLeaveHint(); + activePeer.onUserLeaveHint(); + } + @Override protected void onStop() { super.onStop(); diff --git a/java/com/android/dialer/main/impl/MainSearchController.java b/java/com/android/dialer/main/impl/MainSearchController.java index 8d9e784a7..ccd7a4b49 100644 --- a/java/com/android/dialer/main/impl/MainSearchController.java +++ b/java/com/android/dialer/main/impl/MainSearchController.java @@ -95,12 +95,14 @@ public class MainSearchController implements SearchBarListener { } /** Should be called if we're showing the dialpad because of a new ACTION_DIAL intent. */ - public void showDialpadFromNewIntent(boolean animate) { - showDialpad(animate, true); + public void showDialpadFromNewIntent() { + LogUtil.enterBlock("MainSearchController.showDialpadFromNewIntent"); + showDialpad(/* animate=*/ false, /* fromNewIntent=*/ true); } /** Shows the dialpad, hides the FAB and slides the toolbar off screen. */ public void showDialpad(boolean animate) { + LogUtil.enterBlock("MainSearchController.showDialpad"); showDialpad(animate, false); } @@ -110,17 +112,22 @@ public class MainSearchController implements SearchBarListener { fab.hide(); toolbar.slideUp(animate); toolbar.expand(animate, Optional.absent()); + toolbarShadow.setVisibility(View.VISIBLE); mainActivity.setTitle(R.string.dialpad_activity_title); FragmentTransaction transaction = mainActivity.getFragmentManager().beginTransaction(); + NewSearchFragment searchFragment = getSearchFragment(); // Show Search - if (getSearchFragment() == null) { - NewSearchFragment searchFragment = NewSearchFragment.newInstance(false); + if (searchFragment == null) { + // TODO(a bug): zero suggest results aren't actually shown but this enabled the nearby + // places promo to be shown. + searchFragment = NewSearchFragment.newInstance(/* showZeroSuggest=*/ true); transaction.add(R.id.fragment_container, searchFragment, SEARCH_FRAGMENT_TAG); } else if (!isSearchVisible()) { - transaction.show(getSearchFragment()); + transaction.show(searchFragment); } + searchFragment.setQuery("", CallInitiationType.Type.DIALPAD); // Show Dialpad if (getDialpadFragment() == null) { @@ -145,6 +152,7 @@ public class MainSearchController implements SearchBarListener { * @see {@link #closeSearch(boolean)} to "remove" the dialpad. */ private void hideDialpad(boolean animate, boolean bottomNavVisible) { + LogUtil.enterBlock("MainSearchController.hideDialpad"); Assert.checkArgument(isDialpadVisible()); fab.show(); @@ -190,6 +198,7 @@ public class MainSearchController implements SearchBarListener { /** Should be called when {@link DialpadListener#onDialpadShown()} is called. */ public void onDialpadShown() { + LogUtil.enterBlock("MainSearchController.onDialpadShown"); getDialpadFragment().slideUp(true); hideBottomNav(); } @@ -205,6 +214,7 @@ public class MainSearchController implements SearchBarListener { * */ public void onSearchListTouch() { + LogUtil.enterBlock("MainSearchController.onSearchListTouched"); if (isDialpadVisible()) { if (TextUtils.isEmpty(getDialpadFragment().getQuery())) { Logger.get(mainActivity) @@ -236,13 +246,13 @@ public class MainSearchController implements SearchBarListener { */ public boolean onBackPressed() { if (isDialpadVisible() && !TextUtils.isEmpty(getDialpadFragment().getQuery())) { - LogUtil.i("MainSearchController#onBackPressed", "Dialpad visible with query"); + 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"); + LogUtil.i("MainSearchController.onBackPressed", "Search is visible"); Logger.get(mainActivity) .logImpression( isDialpadVisible() @@ -260,6 +270,7 @@ public class MainSearchController implements SearchBarListener { * dialpad. */ private void closeSearch(boolean animate) { + LogUtil.enterBlock("MainSearchController.closeSearch"); Assert.checkArgument(isSearchVisible()); if (isDialpadVisible()) { hideDialpad(animate, /* bottomNavVisible=*/ true); @@ -314,11 +325,13 @@ public class MainSearchController implements SearchBarListener { */ @Override public void onSearchBarClicked() { + LogUtil.enterBlock("MainSearchController.onSearchBarClicked"); Logger.get(mainActivity).logImpression(DialerImpression.Type.NUI_CLICK_SEARCH_BAR); openSearch(Optional.absent()); } private void openSearch(Optional query) { + LogUtil.enterBlock("MainSearchController.openSearch"); fab.hide(); toolbar.expand(/* animate=*/ true, query); toolbar.showKeyboard(); @@ -326,20 +339,26 @@ public class MainSearchController implements SearchBarListener { hideBottomNav(); FragmentTransaction transaction = mainActivity.getFragmentManager().beginTransaction(); + NewSearchFragment searchFragment = getSearchFragment(); // Show Search - if (getSearchFragment() == null) { - NewSearchFragment searchFragment = NewSearchFragment.newInstance(false); + if (searchFragment == null) { + // TODO(a bug): zero suggest results aren't actually shown but this enabled the nearby + // places promo to be shown. + searchFragment = NewSearchFragment.newInstance(true); transaction.add(R.id.fragment_container, searchFragment, SEARCH_FRAGMENT_TAG); } else if (!isSearchVisible()) { transaction.show(getSearchFragment()); } + searchFragment.setQuery( + query.isPresent() ? query.get() : "", CallInitiationType.Type.REGULAR_SEARCH); transaction.commit(); } @Override public void onSearchBackButtonClicked() { + LogUtil.enterBlock("MainSearchController.onSearchBackButtonClicked"); closeSearch(true); } @@ -384,6 +403,18 @@ public class MainSearchController implements SearchBarListener { return false; } + @Override + public void onUserLeaveHint() { + if (isInSearch()) { + closeSearch(false); + } + } + + @Override + public void onCallPlacedFromSearch() { + closeSearch(false); + } + public void onVoiceResults(int resultCode, Intent data) { if (resultCode == AppCompatActivity.RESULT_OK) { ArrayList matches = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS); diff --git a/java/com/android/dialer/main/impl/NewMainActivityPeer.java b/java/com/android/dialer/main/impl/NewMainActivityPeer.java index ed67df936..6f5c18623 100644 --- a/java/com/android/dialer/main/impl/NewMainActivityPeer.java +++ b/java/com/android/dialer/main/impl/NewMainActivityPeer.java @@ -56,6 +56,9 @@ public class NewMainActivityPeer implements MainActivityPeer { @Override public void onActivityResume() {} + @Override + public void onUserLeaveHint() {} + @Override public void onActivityStop() {} diff --git a/java/com/android/dialer/main/impl/OldMainActivityPeer.java b/java/com/android/dialer/main/impl/OldMainActivityPeer.java index 7d9216c3f..69d8032f2 100644 --- a/java/com/android/dialer/main/impl/OldMainActivityPeer.java +++ b/java/com/android/dialer/main/impl/OldMainActivityPeer.java @@ -226,34 +226,34 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen searchController.onRestoreInstanceState(savedInstanceState); bottomNav.selectTab(savedInstanceState.getInt(KEY_CURRENT_TAB)); } else { - showTabOnIntent(mainActivity.getIntent()); + onHandleIntent(mainActivity.getIntent()); } } @Override public void onNewIntent(Intent intent) { LogUtil.enterBlock("OldMainActivityPeer.onNewIntent"); - showTabOnIntent(intent); + onHandleIntent(intent); } - private void showTabOnIntent(Intent intent) { + private void onHandleIntent(Intent intent) { + // Two important implementation notes: + // 1) If the intent contains extra data to open to a specific screen (e.g. DIAL intent), when + // the user leaves that screen, they will return here and add see a blank screen unless we + // select a tab here. + // 2) Don't return early here in case the intent does contain extra data. if (isShowTabIntent(intent)) { bottomNav.selectTab(getTabFromIntent(intent)); - return; + } else if (lastTabController.isEnabled) { + lastTabController.selectLastTab(); + } else { + bottomNav.selectTab(TabIndex.SPEED_DIAL); } if (isDialIntent(intent)) { - searchController.showDialpadFromNewIntent(false); // Dialpad will grab the intent and populate the number - return; - } - - if (lastTabController.isEnabled) { - lastTabController.selectLastTab(); - return; + searchController.showDialpadFromNewIntent(); } - - bottomNav.selectTab(TabIndex.SPEED_DIAL); } /** Returns true if the given intent contains a phone number to populate the dialer with */ @@ -295,6 +295,11 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen } } + @Override + public void onUserLeaveHint() { + searchController.onUserLeaveHint(); + } + @Override public void onActivityStop() { lastTabController.onActivityStop(); @@ -344,6 +349,7 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen @Override public boolean onBackPressed() { + LogUtil.enterBlock("OldMainActivityPeer.onBackPressed"); if (searchController.onBackPressed()) { return true; } @@ -460,6 +466,7 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen @Override public void onCallPlacedFromDialpad() { // TODO(calderwoodra): logging + searchController.onCallPlacedFromSearch(); } } @@ -480,6 +487,7 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen @Override public void onCallPlacedFromSearch() { // TODO(calderwoodra): logging + searchController.onCallPlacedFromSearch(); } } diff --git a/java/com/android/dialer/main/impl/toolbar/SearchBarListener.java b/java/com/android/dialer/main/impl/toolbar/SearchBarListener.java index a074b5131..857c4b9c9 100644 --- a/java/com/android/dialer/main/impl/toolbar/SearchBarListener.java +++ b/java/com/android/dialer/main/impl/toolbar/SearchBarListener.java @@ -16,6 +16,7 @@ package com.android.dialer.main.impl.toolbar; +import android.support.v7.app.AppCompatActivity; import android.view.MenuItem; /** Useful callback for {@link SearchBarView} listeners. */ @@ -36,6 +37,12 @@ public interface SearchBarListener { /** Called when a toolbar menu item is clicked. */ boolean onMenuItemClicked(MenuItem menuItem); + /** Called when {@link AppCompatActivity#onUserLeaveHint()} is called. */ + void onUserLeaveHint(); + + /** Called when the user places a call from search (regular or dialpad). */ + void onCallPlacedFromSearch(); + /** Interface for returning voice results to the search bar. */ interface VoiceSearchResultCallback { -- cgit v1.2.3 From d40d4f09e32ecfc6b95f57bc6d3e3d1703592cd4 Mon Sep 17 00:00:00 2001 From: uabdullah Date: Wed, 21 Feb 2018 02:40:20 -0800 Subject: When there is no VM support hide the tab in the Old Main Activity In the case where the user is not able to dial into the voicemail tab, or there exists another voicemail app, or VVM is not supported, we do not want to show the VM tab. This CL does not update the activity when a sim is inserted/removed. Bug: 73123614 Test: Unit tests PiperOrigin-RevId: 186433072 Change-Id: I0396b1e15c9a4740eee721af89dbfdf95696cace --- .../dialer/main/impl/OldMainActivityPeer.java | 79 +++++++++++++++++++++- .../dialer/main/impl/bottomnav/BottomNavBar.java | 4 ++ 2 files changed, 81 insertions(+), 2 deletions(-) (limited to 'java/com/android/dialer/main') diff --git a/java/com/android/dialer/main/impl/OldMainActivityPeer.java b/java/com/android/dialer/main/impl/OldMainActivityPeer.java index 69d8032f2..99e49557c 100644 --- a/java/com/android/dialer/main/impl/OldMainActivityPeer.java +++ b/java/com/android/dialer/main/impl/OldMainActivityPeer.java @@ -32,6 +32,9 @@ import android.support.annotation.Nullable; import android.support.design.widget.FloatingActionButton; import android.support.v7.widget.Toolbar; import android.telecom.PhoneAccount; +import android.telecom.PhoneAccountHandle; +import android.telephony.TelephonyManager; +import android.text.TextUtils; import android.view.View; import android.widget.ImageView; import com.android.contacts.common.list.OnPhoneNumberPickerActionListener; @@ -81,6 +84,7 @@ import com.android.dialer.storage.StorageComponent; import com.android.dialer.telecom.TelecomUtil; import com.android.dialer.util.DialerUtils; import com.android.dialer.util.TransactionSafeActivity; +import com.android.voicemail.VoicemailComponent; import com.google.common.util.concurrent.ListenableFuture; import java.util.concurrent.TimeUnit; @@ -190,6 +194,9 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen MainBottomNavBarBottomNavTabListener bottomNavTabListener = new MainBottomNavBarBottomNavTabListener(mainActivity, mainActivity.getFragmentManager()); bottomNav.addOnTabSelectedListener(bottomNavTabListener); + // TODO(uabdullah): Handle case of when a sim is inserted/removed while the activity is open. + boolean showVoicemailTab = canVoicemailTabBeShown(mainActivity); + bottomNav.showVoicemail(showVoicemailTab); callLogFragmentListener = new MainCallLogFragmentListener( @@ -218,7 +225,7 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen mainActivity.findViewById(R.id.remove_view), mainActivity.findViewById(R.id.search_view_container)); - lastTabController = new LastTabController(mainActivity, bottomNav); + lastTabController = new LastTabController(mainActivity, bottomNav, showVoicemailTab); // Restore our view state if needed, else initialize as if the app opened for the first time if (savedInstanceState != null) { @@ -230,6 +237,66 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen } } + /** + * Check and return whether the voicemail tab should be shown or not. This includes the following + * criteria under which we show the voicemail tab: + *
  • The voicemail number exists (e.g we are able to dial into listen to voicemail or press and + * hold 1) + *
  • Visual voicemail is enabled from the settings tab + *
  • Visual voicemail carrier is supported by dialer + *
  • There is no voicemail carrier app installed. + * + * @param context + * @return return if voicemail tab should be shown or not depending on what the voicemail state is + * for the carrier. + */ + private static boolean canVoicemailTabBeShown(Context context) { + PhoneAccountHandle defaultUserSelectedAccount = + TelecomUtil.getDefaultOutgoingPhoneAccount(context, PhoneAccount.SCHEME_VOICEMAIL); + + if (isVoicemailAvailable(context, defaultUserSelectedAccount)) { + return true; + } + if (VoicemailComponent.get(context) + .getVoicemailClient() + .isVoicemailEnabled(context, defaultUserSelectedAccount)) { + return true; + } + return false; + } + + /** + * Check if voicemail is enabled/accessible. + * + * @return true if voicemail is enabled and accessible. Note that this can be false "temporarily" + * after the app boot e.g if the sim isn't fully recognized. TODO(uabdullah): Possibly add a + * listener of some kind to detect when a sim is recognized. TODO(uabdullah): Move this to a + * utility class or wrap it all in a static inner class. + */ + private static boolean isVoicemailAvailable( + Context context, PhoneAccountHandle defaultUserSelectedAccount) { + + if (!TelecomUtil.hasReadPhoneStatePermission(context)) { + LogUtil.i( + "OldMainActivityPeer.isVoicemailAvailable", + "No read phone permisison or not the default dialer."); + return false; + } + + if (defaultUserSelectedAccount == null) { + // In a single-SIM phone, there is no default outgoing phone account selected by + // the user, so just call TelephonyManager#getVoicemailNumber directly. + return !TextUtils.isEmpty(getTelephonyManager(context).getVoiceMailNumber()); + } else { + return !TextUtils.isEmpty( + TelecomUtil.getVoicemailNumber(context, defaultUserSelectedAccount)); + } + } + + private static TelephonyManager getTelephonyManager(Context context) { + return context.getSystemService(TelephonyManager.class); + } + @Override public void onNewIntent(Intent intent) { LogUtil.enterBlock("OldMainActivityPeer.onNewIntent"); @@ -947,11 +1014,13 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen private final Context context; private final BottomNavBar bottomNavBar; private final boolean isEnabled; + private final boolean canShowVoicemailTab; - LastTabController(Context context, BottomNavBar bottomNavBar) { + LastTabController(Context context, BottomNavBar bottomNavBar, boolean canShowVoicemailTab) { this.context = context; this.bottomNavBar = bottomNavBar; isEnabled = ConfigProviderBindings.get(context).getBoolean("last_tab_enabled", false); + this.canShowVoicemailTab = canShowVoicemailTab; } /** Sets the last tab if the feature is enabled, otherwise defaults to speed dial. */ @@ -963,6 +1032,12 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen .unencryptedSharedPrefs() .getInt(KEY_LAST_TAB, TabIndex.SPEED_DIAL); } + + // If the voicemail tab cannot be shown, default to showing speed dial + if (tabIndex == TabIndex.VOICEMAIL && !canShowVoicemailTab) { + tabIndex = TabIndex.SPEED_DIAL; + } + bottomNavBar.selectTab(tabIndex); } diff --git a/java/com/android/dialer/main/impl/bottomnav/BottomNavBar.java b/java/com/android/dialer/main/impl/bottomnav/BottomNavBar.java index 2945e39a9..d9a446f84 100644 --- a/java/com/android/dialer/main/impl/bottomnav/BottomNavBar.java +++ b/java/com/android/dialer/main/impl/bottomnav/BottomNavBar.java @@ -123,6 +123,10 @@ public final class BottomNavBar extends LinearLayout { } } + public void showVoicemail(boolean showTab) { + voicemail.setVisibility(showTab ? View.VISIBLE : View.GONE); + } + public void setNotificationCount(@TabIndex int tab, int count) { if (tab == TabIndex.SPEED_DIAL) { speedDial.setNotificationCount(count); -- cgit v1.2.3 From 99606aa5368e1eea30730a899aacdfdd7a5fd61a Mon Sep 17 00:00:00 2001 From: calderwoodra Date: Wed, 21 Feb 2018 10:40:41 -0800 Subject: Fixed some Dialer theming bugs in NUI. - URL links are now blue - Raised buttons are now blue w/ white text - android nav bar is white - call log actions/icons are the correct colors - search bar hint text is the correct color Bug: 72525324 Test: screenshot PiperOrigin-RevId: 186484088 Change-Id: I1863a28e1ea9bf16863f42299afca319a6bdcc97 --- .../android/dialer/main/impl/AndroidManifest.xml | 2 +- .../dialer/main/impl/res/values-v27/styles.xml | 26 ++++++++++++++++++++++ .../android/dialer/main/impl/res/values/styles.xml | 23 ++++++++++++++++++- 3 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 java/com/android/dialer/main/impl/res/values-v27/styles.xml (limited to 'java/com/android/dialer/main') diff --git a/java/com/android/dialer/main/impl/AndroidManifest.xml b/java/com/android/dialer/main/impl/AndroidManifest.xml index 6b7475f97..972c9d929 100644 --- a/java/com/android/dialer/main/impl/AndroidManifest.xml +++ b/java/com/android/dialer/main/impl/AndroidManifest.xml @@ -29,7 +29,7 @@ android:launchMode="singleTask" android:name="com.android.dialer.main.impl.MainActivity" android:resizeableActivity="true" - android:theme="@style/NuiMainActivityTheme" + android:theme="@style/NuiActivityTheme" android:windowSoftInputMode="stateAlwaysHidden|adjustNothing"> diff --git a/java/com/android/dialer/main/impl/res/values-v27/styles.xml b/java/com/android/dialer/main/impl/res/values-v27/styles.xml new file mode 100644 index 000000000..c91cba245 --- /dev/null +++ b/java/com/android/dialer/main/impl/res/values-v27/styles.xml @@ -0,0 +1,26 @@ + + + + + + + \ No newline at end of file diff --git a/java/com/android/dialer/main/impl/res/values/styles.xml b/java/com/android/dialer/main/impl/res/values/styles.xml index 2865f2587..47fdbac93 100644 --- a/java/com/android/dialer/main/impl/res/values/styles.xml +++ b/java/com/android/dialer/main/impl/res/values/styles.xml @@ -15,14 +15,35 @@ ~ limitations under the License --> -