diff options
Diffstat (limited to 'java/com/android/dialer/main/impl/toolbar')
4 files changed, 47 insertions, 10 deletions
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 |