diff options
Diffstat (limited to 'java/com/android/dialer/main/impl/toolbar')
5 files changed, 17 insertions, 21 deletions
diff --git a/java/com/android/dialer/main/impl/toolbar/MainToolbar.java b/java/com/android/dialer/main/impl/toolbar/MainToolbar.java index 1d7f7ce20..604422978 100644 --- a/java/com/android/dialer/main/impl/toolbar/MainToolbar.java +++ b/java/com/android/dialer/main/impl/toolbar/MainToolbar.java @@ -36,6 +36,7 @@ public final class MainToolbar extends Toolbar implements OnMenuItemClickListene private SearchBarView searchBar; private SearchBarListener listener; + private MainToolbarMenu overflowMenu; private boolean isSlideUp; public MainToolbar(Context context, AttributeSet attrs) { @@ -46,7 +47,7 @@ public final class MainToolbar extends Toolbar implements OnMenuItemClickListene protected void onFinishInflate() { super.onFinishInflate(); ImageButton optionsMenuButton = findViewById(R.id.main_options_menu_button); - MainToolbarMenu overflowMenu = new MainToolbarMenu(getContext(), optionsMenuButton); + overflowMenu = new MainToolbarMenu(getContext(), optionsMenuButton); overflowMenu.inflate(R.menu.main_menu); overflowMenu.setOnMenuItemClickListener(this); optionsMenuButton.setOnClickListener(v -> overflowMenu.show()); @@ -57,12 +58,7 @@ public final class MainToolbar extends Toolbar implements OnMenuItemClickListene @Override public boolean onMenuItemClick(MenuItem menuItem) { - if (menuItem.getItemId() == R.id.settings) { - listener.openSettings(); - } else if (menuItem.getItemId() == R.id.feedback) { - listener.sendFeedback(); - } - return false; + return listener.onMenuItemClicked(menuItem); } public void setSearchBarListener(SearchBarListener listener) { @@ -129,4 +125,8 @@ public final class MainToolbar extends Toolbar implements OnMenuItemClickListene public void showKeyboard() { searchBar.showKeyboard(); } + + public MainToolbarMenu getOverflowMenu() { + return overflowMenu; + } } diff --git a/java/com/android/dialer/main/impl/toolbar/MainToolbarMenu.java b/java/com/android/dialer/main/impl/toolbar/MainToolbarMenu.java index f4dfeef23..3c6e3611d 100644 --- a/java/com/android/dialer/main/impl/toolbar/MainToolbarMenu.java +++ b/java/com/android/dialer/main/impl/toolbar/MainToolbarMenu.java @@ -22,18 +22,15 @@ import android.view.Gravity; import android.view.View; /** Popup menu accessible from the search bar */ -final class MainToolbarMenu extends PopupMenu { +public final class MainToolbarMenu extends PopupMenu { public MainToolbarMenu(Context context, View anchor) { - super(context, anchor, Gravity.TOP); - // TODO(calderwoodra): menu should open from the top, not the bottom + super(context, anchor, Gravity.NO_GRAVITY, R.attr.actionOverflowMenuStyle, 0); } @Override public void show() { super.show(); - // TODO(calderwoodra): show/hide clear frequents - // TODO(calderwoodra): only show call history item if we have phone permission // TODO(calderwoodra): show simulator buttons } } diff --git a/java/com/android/dialer/main/impl/toolbar/SearchBarListener.java b/java/com/android/dialer/main/impl/toolbar/SearchBarListener.java index 2e31997e6..a074b5131 100644 --- a/java/com/android/dialer/main/impl/toolbar/SearchBarListener.java +++ b/java/com/android/dialer/main/impl/toolbar/SearchBarListener.java @@ -16,6 +16,8 @@ package com.android.dialer.main.impl.toolbar; +import android.view.MenuItem; + /** Useful callback for {@link SearchBarView} listeners. */ public interface SearchBarListener { @@ -31,11 +33,8 @@ public interface SearchBarListener { /** Called when the voice search button is clicked. */ void onVoiceButtonClicked(VoiceSearchResultCallback voiceSearchResultCallback); - /** Called when the settings option is selected from the search menu. */ - void openSettings(); - - /** Called when send feedback is selected from the search menu. */ - void sendFeedback(); + /** Called when a toolbar menu item is clicked. */ + boolean onMenuItemClicked(MenuItem menuItem); /** Interface for returning voice results to the search bar. */ interface VoiceSearchResultCallback { 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 5b09fca8c..01309ddc4 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 @@ -22,7 +22,7 @@ app:showAsAction="collapseActionView"/> <item - android:id="@+id/feedback" - android:title="@string/main_send_feedback" + android:id="@+id/clear_frequents" + android:title="@string/main_menu_clear_frequents" app:showAsAction="collapseActionView"/> </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 6af235b81..66ccfb452 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,8 +37,8 @@ <!-- Show users their settings [CHAR LIMIT=20] --> <string name="settings">Settings</string> - <!-- Send feedback about the app [CHAR LIMIT=20] --> - <string name="main_send_feedback">Send feedback</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> |