diff options
author | Andrew Lee <anwlee@google.com> | 2014-05-16 21:36:57 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-05-16 21:36:58 +0000 |
commit | 7a67eab3a6e5e323934f12819eba9a72a604916f (patch) | |
tree | 2b50380391324e097244f09c40728c2937bc04f6 | |
parent | 6c02922d6b3c4a2872d25f8377309339df8001f6 (diff) | |
parent | e74a10eab5d8a43918a540bc42f0c159bdf5ab7c (diff) |
Merge "Move actionbar menu into menu button in search edit text."
-rw-r--r-- | res/layout/search_edittext.xml | 8 | ||||
-rw-r--r-- | res/values/colors.xml | 1 | ||||
-rw-r--r-- | src/com/android/dialer/DialtactsActivity.java | 41 | ||||
-rw-r--r-- | src/com/android/dialer/list/ListsFragment.java | 4 |
4 files changed, 38 insertions, 16 deletions
diff --git a/res/layout/search_edittext.xml b/res/layout/search_edittext.xml index f44cc0b6d..a20935f30 100644 --- a/res/layout/search_edittext.xml +++ b/res/layout/search_edittext.xml @@ -45,4 +45,12 @@ android:clickable="true" android:contentDescription="@string/description_start_voice_search" android:background="?android:attr/selectableItemBackground" /> + <ImageButton + android:id="@+id/dialtacts_options_menu_button" + android:layout_width="@dimen/search_box_icon_size" + android:layout_height="@dimen/search_box_icon_size" + android:padding="@dimen/search_box_icon_padding" + android:background="?android:attr/selectableItemBackground" + android:src="@drawable/ic_overflow_menu" + android:tint="@color/searchbox_options_menu_color" /> </view>
\ No newline at end of file diff --git a/res/values/colors.xml b/res/values/colors.xml index 28b78963c..301d4162f 100644 --- a/res/values/colors.xml +++ b/res/values/colors.xml @@ -59,6 +59,7 @@ <color name="searchbox_text_color">#000000</color> <!-- Text color of the search box hint text --> <color name="searchbox_hint_text_color">#d3d3d3</color> + <color name="searchbox_options_menu_color">#d5d5d5</color> <!-- Color of the contact name in favorite tiles --> <color name="contact_tile_name_color">#ffffff</color> diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java index 8fa4ae66c..d888de6fe 100644 --- a/src/com/android/dialer/DialtactsActivity.java +++ b/src/com/android/dialer/DialtactsActivity.java @@ -44,7 +44,6 @@ import android.util.Log; import android.view.DragEvent; import android.view.KeyEvent; import android.view.Menu; -import android.view.MenuInflater; import android.view.MenuItem; import android.view.MotionEvent; import android.view.View; @@ -103,6 +102,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O SpeedDialFragment.HostInterface, OnDragDropListener, OnPhoneNumberPickerActionListener, + PopupMenu.OnMenuItemClickListener, ViewPager.OnPageChangeListener { private static final String TAG = "DialtactsActivity"; @@ -193,6 +193,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O private EditText mSearchView; private View mSearchViewCloseButton; private View mVoiceSearchButton; + /** * View that contains the "Remove" dialog that shows up when the user long presses a contact. * If the user releases a contact when hovering on top of this, the contact is unfavorited and @@ -207,8 +208,8 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O private DialerDatabaseHelper mDialerDatabaseHelper; private DragDropController mDragDropController; - private class OverflowPopupMenu extends PopupMenu { - public OverflowPopupMenu(Context context, View anchor) { + private class OptionsPopupMenu extends PopupMenu { + public OptionsPopupMenu(Context context, View anchor) { super(context, anchor); } @@ -216,8 +217,9 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O public void show() { final Menu menu = getMenu(); final MenuItem clearFrequents = menu.findItem(R.id.menu_clear_frequents); - // TODO: Check mSpeedDialFragment.hasFrequents() - clearFrequents.setVisible(true); + clearFrequents.setVisible(mListsFragment != null && + mListsFragment.getSpeedDialFragment() != null && + mListsFragment.getSpeedDialFragment().hasFrequents()); super.show(); } } @@ -335,10 +337,15 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O mSearchView.addTextChangedListener(mPhoneSearchQueryTextListener); mSearchView.setOnTouchListener(mSearchViewOnTouchListener); - mSearchViewCloseButton = actionBarView.findViewById(R.id.search_close_button); mSearchViewCloseButton.setOnClickListener(this); + ImageButton optionsMenuButton = + (ImageButton) actionBarView.findViewById(R.id.dialtacts_options_menu_button); + optionsMenuButton.setOnClickListener(this); + final OptionsPopupMenu optionsMenu = buildOptionsMenu(optionsMenuButton); + optionsMenuButton.setOnTouchListener(optionsMenu.getDragToOpenListener()); + final TypedArray styledAttributes = getTheme().obtainStyledAttributes( new int[] { android.R.attr.actionBarSize }); mActionBarHeight = (int) styledAttributes.getDimension(0, 0); @@ -462,6 +469,9 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O Toast.LENGTH_SHORT).show(); } break; + case R.id.dialtacts_options_menu_button: + buildOptionsMenu(view).show(); + break; default: { Log.wtf(TAG, "Unexpected onClick event from " + view); break; @@ -470,7 +480,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O } @Override - public boolean onOptionsItemSelected(MenuItem item) { + public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.menu_history: showCallHistory(); @@ -494,8 +504,6 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O DialtactsActivity.class); return true; case R.id.menu_clear_frequents: - // TODO: This should be enabled/disabled based on - // SpeedDialFragment.hasFrequents ClearFrequentsDialog.show(getFragmentManager()); return true; case R.id.menu_call_settings: @@ -653,19 +661,20 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O } } + private OptionsPopupMenu buildOptionsMenu(View invoker) { + final OptionsPopupMenu popupMenu = new OptionsPopupMenu(this, invoker); + popupMenu.inflate(R.menu.dialtacts_options); + popupMenu.setOnMenuItemClickListener(this); + return popupMenu; + } + @Override public boolean onCreateOptionsMenu(Menu menu) { - if (DEBUG) { - Log.d(TAG, "onCreateOptionsMenu"); - } - MenuInflater inflater = getMenuInflater(); - inflater.inflate(R.menu.dialtacts_options, menu); - if (mPendingSearchViewQuery != null) { mSearchView.setText(mPendingSearchViewQuery); mPendingSearchViewQuery = null; } - return super.onCreateOptionsMenu(menu); + return false; } /** diff --git a/src/com/android/dialer/list/ListsFragment.java b/src/com/android/dialer/list/ListsFragment.java index 250706561..b4497e4b0 100644 --- a/src/com/android/dialer/list/ListsFragment.java +++ b/src/com/android/dialer/list/ListsFragment.java @@ -364,4 +364,8 @@ public class ListsFragment extends Fragment implements CallLogQueryHandler.Liste // height changes. transition.enableTransitionType(LayoutTransition.CHANGING); } + + public SpeedDialFragment getSpeedDialFragment() { + return mSpeedDialFragment; + } } |