diff options
Diffstat (limited to 'java/com/android/dialer/main/impl')
4 files changed, 43 insertions, 14 deletions
diff --git a/java/com/android/dialer/main/impl/MainSearchController.java b/java/com/android/dialer/main/impl/MainSearchController.java index b04e7b11b..dbeed0d69 100644 --- a/java/com/android/dialer/main/impl/MainSearchController.java +++ b/java/com/android/dialer/main/impl/MainSearchController.java @@ -140,7 +140,7 @@ public class MainSearchController implements SearchBarListener { fab.hide(); toolbar.slideUp(animate, fragmentContainer); - toolbar.expand(animate, Optional.absent()); + toolbar.expand(animate, Optional.absent(), /* requestFocus */ false); toolbarShadow.setVisibility(View.VISIBLE); activity.setTitle(R.string.dialpad_activity_title); @@ -390,7 +390,7 @@ public class MainSearchController implements SearchBarListener { Logger.get(activity).logScreenView(ScreenEvent.Type.MAIN_SEARCH, activity); fab.hide(); - toolbar.expand(/* animate=*/ true, query); + toolbar.expand(/* animate=*/ true, query, /* requestFocus */ true); toolbar.showKeyboard(); toolbarShadow.setVisibility(View.VISIBLE); hideBottomNav(); @@ -528,12 +528,15 @@ public class MainSearchController implements SearchBarListener { if (savedInstanceState.getBoolean(KEY_IS_FAB_HIDDEN, false)) { fab.hide(); } - if (savedInstanceState.getBoolean(KEY_IS_TOOLBAR_EXPANDED, false)) { - toolbar.expand(false, Optional.absent()); - } - if (savedInstanceState.getBoolean(KEY_IS_TOOLBAR_SLIDE_UP, false)) { + boolean isSlideUp = savedInstanceState.getBoolean(KEY_IS_TOOLBAR_SLIDE_UP, false); + if (isSlideUp) { toolbar.slideUp(false, fragmentContainer); } + if (savedInstanceState.getBoolean(KEY_IS_TOOLBAR_EXPANDED, false)) { + // If the toolbar is slide up, that means the dialpad is showing. Thus we don't want to + // request focus or we'll break physical/bluetooth keyboards typing. + toolbar.expand(/* animate */ false, Optional.absent(), /* requestFocus */ !isSlideUp); + } } public void addOnSearchShowListener(OnSearchShowListener listener) { diff --git a/java/com/android/dialer/main/impl/NewMainActivityPeer.java b/java/com/android/dialer/main/impl/NewMainActivityPeer.java index 960787972..0ab69a443 100644 --- a/java/com/android/dialer/main/impl/NewMainActivityPeer.java +++ b/java/com/android/dialer/main/impl/NewMainActivityPeer.java @@ -29,6 +29,7 @@ import com.android.dialer.main.MainActivityPeer; import com.android.dialer.main.impl.bottomnav.BottomNavBar; import com.android.dialer.main.impl.bottomnav.BottomNavBar.OnBottomNavTabSelectedListener; import com.android.dialer.main.impl.bottomnav.BottomNavBar.TabIndex; +import com.android.dialer.speeddial.SpeedDialFragment; import com.android.dialer.voicemail.listui.NewVoicemailFragment; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.MoreExecutors; @@ -89,6 +90,7 @@ public class NewMainActivityPeer implements MainActivityPeer { private static final class MainBottomNavBarBottomNavTabListener implements OnBottomNavTabSelectedListener { + private static final String SPEED_DIAL_TAG = "speed_dial"; private static final String CALL_LOG_TAG = "call_log"; private static final String VOICEMAIL_TAG = "voicemail"; @@ -104,7 +106,16 @@ public class NewMainActivityPeer implements MainActivityPeer { @Override public void onSpeedDialSelected() { hideAllFragments(); - // TODO(calderwoodra): Implement SpeedDialFragment when FragmentUtils#getParent works + SpeedDialFragment fragment = + (SpeedDialFragment) supportFragmentManager.findFragmentByTag(SPEED_DIAL_TAG); + if (fragment == null) { + supportFragmentManager + .beginTransaction() + .add(R.id.fragment_container, SpeedDialFragment.newInstance(), SPEED_DIAL_TAG) + .commit(); + } else { + supportFragmentManager.beginTransaction().show(fragment).commit(); + } } @Override @@ -143,8 +154,14 @@ public class NewMainActivityPeer implements MainActivityPeer { } } + // TODO(calderwoodra): fix overlapping fragments issue private void hideAllFragments() { FragmentTransaction supportTransaction = supportFragmentManager.beginTransaction(); + Fragment speedDialFragment = supportFragmentManager.findFragmentByTag(SPEED_DIAL_TAG); + if (speedDialFragment != null) { + supportTransaction.hide(speedDialFragment); + } + Fragment callLogFragment = supportFragmentManager.findFragmentByTag(CALL_LOG_TAG); if (callLogFragment != null) { if (callLogFragment.isVisible()) { @@ -158,6 +175,7 @@ public class NewMainActivityPeer implements MainActivityPeer { } supportTransaction.hide(callLogFragment); } + if (supportFragmentManager.findFragmentByTag(VOICEMAIL_TAG) != null) { supportTransaction.hide(supportFragmentManager.findFragmentByTag(VOICEMAIL_TAG)); } diff --git a/java/com/android/dialer/main/impl/toolbar/MainToolbar.java b/java/com/android/dialer/main/impl/toolbar/MainToolbar.java index 68876dde5..5e5db2c8c 100644 --- a/java/com/android/dialer/main/impl/toolbar/MainToolbar.java +++ b/java/com/android/dialer/main/impl/toolbar/MainToolbar.java @@ -113,9 +113,9 @@ public final class MainToolbar extends Toolbar implements PopupMenu.OnMenuItemCl searchBar.collapse(animate); } - /** @see SearchBarView#collapse(boolean) */ - public void expand(boolean animate, Optional<String> text) { - searchBar.expand(animate, text); + /** @see SearchBarView#expand(boolean, Optional, boolean) */ + public void expand(boolean animate, Optional<String> text, boolean requestFocus) { + searchBar.expand(animate, text, requestFocus); } public boolean isSlideUp() { diff --git a/java/com/android/dialer/main/impl/toolbar/SearchBarView.java b/java/com/android/dialer/main/impl/toolbar/SearchBarView.java index 0cc76598c..8ea94299e 100644 --- a/java/com/android/dialer/main/impl/toolbar/SearchBarView.java +++ b/java/com/android/dialer/main/impl/toolbar/SearchBarView.java @@ -101,13 +101,17 @@ final class SearchBarView extends FrameLayout { listener.onVoiceButtonClicked( result -> { if (!TextUtils.isEmpty(result)) { - expand(true, Optional.of(result)); + expand(/* animate */ true, Optional.of(result), /* requestFocus */ true); } }); } - /** Expand the search bar and populate it with text if any exists. */ - /* package-private */ void expand(boolean animate, Optional<String> text) { + /** + * Expand the search bar and populate it with text if any exists. + * + * @param requestFocus should be false if showing the dialpad + */ + /* package-private */ void expand(boolean animate, Optional<String> text, boolean requestFocus) { if (isExpanded) { return; } @@ -133,7 +137,11 @@ final class SearchBarView extends FrameLayout { if (text.isPresent()) { searchBox.setText(text.get()); } - searchBox.requestFocus(); + // Don't request focus unless we're actually showing the search box, otherwise + // physical/bluetooth keyboards will type into this box when the dialpad is open. + if (requestFocus) { + searchBox.requestFocus(); + } setBackgroundResource(R.drawable.search_bar_background); } }); |