diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2018-02-24 12:05:27 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2018-02-24 12:05:27 +0000 |
commit | a39e732c6326f6265a213024bbb6899aea04f10a (patch) | |
tree | 1f33e4d0d1dc86364554138b23edb06d1bc7a9b0 /java/com/android/dialer/main/impl | |
parent | 3002ad660a95b79a07837d283d1162df727b3221 (diff) | |
parent | ebc59e20e21e78e479fd3fb42993851c10d63b75 (diff) |
Merge "Fixed a few bugs in NUI Main Activity."
Diffstat (limited to 'java/com/android/dialer/main/impl')
6 files changed, 62 insertions, 12 deletions
diff --git a/java/com/android/dialer/main/impl/MainSearchController.java b/java/com/android/dialer/main/impl/MainSearchController.java index ccd7a4b49..0c2374c96 100644 --- a/java/com/android/dialer/main/impl/MainSearchController.java +++ b/java/com/android/dialer/main/impl/MainSearchController.java @@ -48,6 +48,7 @@ import com.android.dialer.main.impl.toolbar.MainToolbar; import com.android.dialer.main.impl.toolbar.SearchBarListener; import com.android.dialer.searchfragment.list.NewSearchFragment; import com.android.dialer.searchfragment.list.NewSearchFragment.SearchFragmentListener; +import com.android.dialer.smartdial.util.SmartDialNameMatcher; import com.google.common.base.Optional; import java.util.ArrayList; @@ -372,10 +373,12 @@ public class MainSearchController implements SearchBarListener { /** @see OnDialpadQueryChangedListener#onDialpadQueryChanged(java.lang.String) */ public void onDialpadQueryChanged(String query) { + query = SmartDialNameMatcher.normalizeNumber(/* context = */ mainActivity, query); NewSearchFragment fragment = getSearchFragment(); if (fragment != null) { fragment.setQuery(query, CallInitiationType.Type.DIALPAD); } + getDialpadFragment().process_quote_emergency_unquote(query); } @Override diff --git a/java/com/android/dialer/main/impl/OldMainActivityPeer.java b/java/com/android/dialer/main/impl/OldMainActivityPeer.java index 8762f5889..cdbab5cc1 100644 --- a/java/com/android/dialer/main/impl/OldMainActivityPeer.java +++ b/java/com/android/dialer/main/impl/OldMainActivityPeer.java @@ -196,6 +196,7 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen }); MainToolbar toolbar = mainActivity.findViewById(R.id.toolbar); + toolbar.maybeShowSimulator(mainActivity); mainActivity.setSupportActionBar(mainActivity.findViewById(R.id.toolbar)); bottomNav = mainActivity.findViewById(R.id.bottom_nav_bar); @@ -231,7 +232,8 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen bottomNav, mainActivity.findViewById(R.id.contact_tile_drag_shadow_overlay), mainActivity.findViewById(R.id.remove_view), - mainActivity.findViewById(R.id.search_view_container)); + mainActivity.findViewById(R.id.search_view_container), + toolbar); lastTabController = new LastTabController(mainActivity, bottomNav, showVoicemailTab); @@ -901,6 +903,7 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen private final ImageView dragShadowOverlay; private final RemoveView removeView; private final View searchViewContainer; + private final MainToolbar toolbar; // TODO(calderwoodra): Use this for drag and drop @SuppressWarnings("unused") @@ -910,11 +913,13 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen BottomNavBar bottomNavBar, ImageView dragShadowOverlay, RemoveView removeView, - View searchViewContainer) { + View searchViewContainer, + MainToolbar toolbar) { this.bottomNavBar = bottomNavBar; this.dragShadowOverlay = dragShadowOverlay; this.removeView = removeView; this.searchViewContainer = searchViewContainer; + this.toolbar = toolbar; } @Override @@ -933,6 +938,11 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen } @Override + public void setHasFrequents(boolean hasFrequents) { + toolbar.showClearFrequents(hasFrequents); + } + + @Override public void onDragStarted(int x, int y, PhoneFavoriteSquareTileView view) { showRemoveView(true); } diff --git a/java/com/android/dialer/main/impl/toolbar/MainToolbar.java b/java/com/android/dialer/main/impl/toolbar/MainToolbar.java index a129fca8b..fc4bd0312 100644 --- a/java/com/android/dialer/main/impl/toolbar/MainToolbar.java +++ b/java/com/android/dialer/main/impl/toolbar/MainToolbar.java @@ -20,19 +20,20 @@ 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.app.AppCompatActivity; 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.PopupMenu; import android.widget.RelativeLayout; import com.android.dialer.common.Assert; import com.android.dialer.util.ViewUtil; import com.google.common.base.Optional; /** Toolbar for {@link com.android.dialer.main.impl.MainActivity}. */ -public final class MainToolbar extends Toolbar implements OnMenuItemClickListener { +public final class MainToolbar extends Toolbar implements PopupMenu.OnMenuItemClickListener { private static final int SLIDE_DURATION = 300; private static final AccelerateDecelerateInterpolator SLIDE_INTERPOLATOR = @@ -155,4 +156,12 @@ public final class MainToolbar extends Toolbar implements OnMenuItemClickListene public void setHint(@StringRes int hint) { searchBar.setHint(hint); } + + public void showClearFrequents(boolean show) { + overflowMenu.showClearFrequents(show); + } + + public void maybeShowSimulator(AppCompatActivity appCompatActivity) { + overflowMenu.maybeShowSimulator(appCompatActivity); + } } diff --git a/java/com/android/dialer/main/impl/toolbar/MainToolbarMenu.java b/java/com/android/dialer/main/impl/toolbar/MainToolbarMenu.java index 3c6e3611d..16aa7c580 100644 --- a/java/com/android/dialer/main/impl/toolbar/MainToolbarMenu.java +++ b/java/com/android/dialer/main/impl/toolbar/MainToolbarMenu.java @@ -17,9 +17,13 @@ package com.android.dialer.main.impl.toolbar; import android.content.Context; -import android.support.v7.widget.PopupMenu; +import android.support.v7.app.AppCompatActivity; import android.view.Gravity; +import android.view.MenuItem; import android.view.View; +import android.widget.PopupMenu; +import com.android.dialer.simulator.Simulator; +import com.android.dialer.simulator.SimulatorComponent; /** Popup menu accessible from the search bar */ public final class MainToolbarMenu extends PopupMenu { @@ -28,9 +32,18 @@ public final class MainToolbarMenu extends PopupMenu { super(context, anchor, Gravity.NO_GRAVITY, R.attr.actionOverflowMenuStyle, 0); } - @Override - public void show() { - super.show(); - // TODO(calderwoodra): show simulator buttons + public void showClearFrequents(boolean show) { + getMenu().findItem(R.id.clear_frequents).setVisible(show); + } + + public void maybeShowSimulator(AppCompatActivity activity) { + MenuItem simulatorMenuItem = getMenu().findItem(R.id.menu_simulator_submenu); + Simulator simulator = SimulatorComponent.get(activity).getSimulator(); + if (simulator.shouldShow()) { + simulatorMenuItem.setVisible(true); + simulatorMenuItem.setActionProvider(simulator.getActionProvider(activity)); + } else { + simulatorMenuItem.setVisible(false); + } } } diff --git a/java/com/android/dialer/main/impl/toolbar/res/menu/main_menu.xml b/java/com/android/dialer/main/impl/toolbar/res/menu/main_menu.xml index 01309ddc4..e2ff57f28 100644 --- a/java/com/android/dialer/main/impl/toolbar/res/menu/main_menu.xml +++ b/java/com/android/dialer/main/impl/toolbar/res/menu/main_menu.xml @@ -16,13 +16,23 @@ --> <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> + + <item + android:id="@+id/clear_frequents" + android:title="@string/main_menu_clear_frequents" + app:showAsAction="collapseActionView" + android:visible="false"/> + + <!-- TODO(calderwoodra): add clear call log --> + <item android:id="@+id/settings" android:title="@string/settings" app:showAsAction="collapseActionView"/> <item - android:id="@+id/clear_frequents" - android:title="@string/main_menu_clear_frequents" - app:showAsAction="collapseActionView"/> + android:id="@+id/menu_simulator_submenu" + android:title="@string/nui_simulator_submenu_label" + app:showAsAction="collapseActionView" + android:visible="false"/> </menu>
\ No newline at end of file diff --git a/java/com/android/dialer/main/impl/toolbar/res/values/strings.xml b/java/com/android/dialer/main/impl/toolbar/res/values/strings.xml index 66ccfb452..96f0cc0f9 100644 --- a/java/com/android/dialer/main/impl/toolbar/res/values/strings.xml +++ b/java/com/android/dialer/main/impl/toolbar/res/values/strings.xml @@ -37,9 +37,14 @@ <!-- Show users their settings [CHAR LIMIT=20] --> <string name="settings">Settings</string> + <!-- The menu item to clear frequents [CHAR LIMIT=30] --> <string name="main_menu_clear_frequents">Clear frequents</string> <!-- Remove button that shows up when contact is long-pressed. [CHAR LIMIT=NONE] --> <string name="main_remove_contact">Remove</string> + + <!-- Label for the simulator submenu. This is used to show actions that are useful for development + and testing. [CHAR LIMIT=30]--> + <string translatable="false" name="nui_simulator_submenu_label">Simulator</string> </resources>
\ No newline at end of file |