diff options
7 files changed, 36 insertions, 30 deletions
diff --git a/java/com/android/dialer/main/impl/MainSearchController.java b/java/com/android/dialer/main/impl/MainSearchController.java index 0296ec911..c439767ee 100644 --- a/java/com/android/dialer/main/impl/MainSearchController.java +++ b/java/com/android/dialer/main/impl/MainSearchController.java @@ -25,6 +25,7 @@ import android.support.annotation.Nullable; import android.support.design.widget.FloatingActionButton; import android.support.v7.app.AppCompatActivity; import android.text.TextUtils; +import android.view.MenuItem; import android.view.View; import android.view.animation.Animation; import android.view.animation.Animation.AnimationListener; @@ -58,7 +59,7 @@ import java.util.ArrayList; * * @see #onBackPressed() */ -final class MainSearchController implements SearchBarListener { +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"; @@ -74,7 +75,7 @@ final class MainSearchController implements SearchBarListener { private final FloatingActionButton fab; private final MainToolbar toolbar; - MainSearchController( + public MainSearchController( MainActivity mainActivity, BottomNavBar bottomNav, FloatingActionButton fab, @@ -324,6 +325,16 @@ final class MainSearchController implements SearchBarListener { } } + @Override + public boolean onMenuItemClicked(MenuItem menuItem) { + if (menuItem.getItemId() == R.id.settings) { + // TODO(calderwoodra) + } else if (menuItem.getItemId() == R.id.clear_frequents) { + // TODO(calderwoodra) + } + return false; + } + public void onVoiceResults(int resultCode, Intent data) { if (resultCode == AppCompatActivity.RESULT_OK) { ArrayList<String> matches = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS); @@ -338,12 +349,6 @@ final class MainSearchController implements SearchBarListener { } } - @Override - public void openSettings() {} - - @Override - public void sendFeedback() {} - public void onSaveInstanceState(Bundle bundle) { bundle.putBoolean(KEY_IS_FAB_HIDDEN, !fab.isShown()); bundle.putInt(KEY_CURRENT_TAB, bottomNav.getSelectedTab()); diff --git a/java/com/android/dialer/main/impl/OldMainActivityPeer.java b/java/com/android/dialer/main/impl/OldMainActivityPeer.java index a27bdd23a..c46e61bd0 100644 --- a/java/com/android/dialer/main/impl/OldMainActivityPeer.java +++ b/java/com/android/dialer/main/impl/OldMainActivityPeer.java @@ -188,7 +188,7 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen mainActivity, mainActivity.getContentResolver(), bottomNav, toolbar); bottomNav.addOnTabSelectedListener(callLogFragmentListener); - searchController = new MainSearchController(mainActivity, bottomNav, fab, toolbar); + searchController = getNewMainSearchController(bottomNav, fab, toolbar); toolbar.setSearchBarListener(searchController); onDialpadQueryChangedListener = new MainOnDialpadQueryChangedListener(searchController); @@ -355,6 +355,11 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen } } + public MainSearchController getNewMainSearchController( + BottomNavBar bottomNavBar, FloatingActionButton fab, MainToolbar mainToolbar) { + return new MainSearchController(mainActivity, bottomNavBar, fab, mainToolbar); + } + /** @see OnContactSelectedListener */ private static final class MainOnContactSelectedListener implements OnContactSelectedListener { 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> |