diff options
author | Yorke Lee <yorkelee@google.com> | 2014-04-22 17:20:00 -0700 |
---|---|---|
committer | Yorke Lee <yorkelee@google.com> | 2014-04-23 17:21:38 -0700 |
commit | a5d5cdf2ed131289943033cfd775dd34ffd7ff45 (patch) | |
tree | efe9512afa45b5e1f802eadd511a73af555c88e3 /src/com/android/dialer/dialpad/DialpadFragment.java | |
parent | d999b71452baebec789f6f58f1955d30e834826d (diff) |
Add floating dialpad action button
* Replace fake action bar at the bottom of the screen with a floating
action button which casts a shadow.
* Remove the now unused mDialpadOverflowMenu button in DialtactsActivity
* Modify dialpad layout to add a bottom row of buttons which provide
access to the add contact button and overflow menu
* Fix dialpad layout so the heights applied in XML are actually
respected - previously they were being ignored and each dialpad key
was being assigned the height of MATCH_PARENT
Bug: 13932988
Change-Id: I6e48c00c5ceeeffed142c3dd259e630d6daf8111
Diffstat (limited to 'src/com/android/dialer/dialpad/DialpadFragment.java')
-rw-r--r-- | src/com/android/dialer/dialpad/DialpadFragment.java | 43 |
1 files changed, 24 insertions, 19 deletions
diff --git a/src/com/android/dialer/dialpad/DialpadFragment.java b/src/com/android/dialer/dialpad/DialpadFragment.java index 703c27730..72abaa085 100644 --- a/src/com/android/dialer/dialpad/DialpadFragment.java +++ b/src/com/android/dialer/dialpad/DialpadFragment.java @@ -76,9 +76,11 @@ import com.android.dialer.NeededForReflection; import com.android.dialer.DialtactsActivity; import com.android.dialer.R; import com.android.dialer.SpecialCharSequenceMgr; +import com.android.dialer.util.DialerUtils; import com.android.internal.telephony.ITelephony; import com.android.phone.common.CallLogAsync; import com.android.phone.common.HapticFeedback; + import com.google.common.annotations.VisibleForTesting; import java.util.HashSet; @@ -199,6 +201,8 @@ public class DialpadFragment extends Fragment /** Remembers if we need to clear digits field when the screen is completely gone. */ private boolean mClearDigitsOnStop; + private View mAddContactButton; + private View mOverflowMenuButton; private View mDelete; private ToneGenerator mToneGenerator; private final Object mToneGeneratorLock = new Object(); @@ -333,6 +337,9 @@ public class DialpadFragment extends Fragment if (isDigitsEmpty()) { mDigitsFilledByIntent = false; mDigits.setCursorVisible(false); + mAddContactButton.setVisibility(View.INVISIBLE); + } else { + mAddContactButton.setVisibility(View.VISIBLE); } if (mDialpadQueryListener != null) { @@ -612,8 +619,6 @@ public class DialpadFragment extends Fragment for (int i = 0; i < buttonIds.length; i++) { dialpadKey = (DialpadKeyButton) fragmentView.findViewById(buttonIds[i]); - dialpadKey.setLayoutParams(new TableRow.LayoutParams( - TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.MATCH_PARENT)); dialpadKey.setOnPressedListener(this); numberView = (TextView) dialpadKey.findViewById(R.id.dialpad_key_number); lettersView = (TextView) dialpadKey.findViewById(R.id.dialpad_key_letters); @@ -637,6 +642,13 @@ public class DialpadFragment extends Fragment zero.setLongHoverContentDescription( resources.getText(R.string.description_image_button_plus)); + mAddContactButton = fragmentView.findViewById(R.id.dialpad_add_contact); + mAddContactButton.setOnClickListener(this); + + mOverflowMenuButton = fragmentView.findViewById(R.id.dialpad_overflow); + mOverflowMenuButton.setOnClickListener(this); + final PopupMenu overflowMenu = buildOptionsMenu(mOverflowMenuButton); + mOverflowMenuButton.setOnTouchListener(overflowMenu.getDragToOpenListener()); } @Override @@ -768,22 +780,6 @@ public class DialpadFragment extends Fragment outState.putBoolean(PREF_DIGITS_FILLED_BY_INTENT, mDigitsFilledByIntent); } - private void setupMenuItems(Menu menu) { - final MenuItem addToContactMenuItem = menu.findItem(R.id.menu_add_contacts); - - // We show "add to contacts" menu only when the user is - // seeing usual dialpad and has typed at least one digit. - // We never show a menu if the "choose dialpad" UI is up. - if (dialpadChooserVisible() || isDigitsEmpty()) { - addToContactMenuItem.setVisible(false); - } else { - final CharSequence digits = mDigits.getText(); - // Put the current digits string into an intent - addToContactMenuItem.setIntent(DialtactsActivity.getAddNumberToContactIntent(digits)); - addToContactMenuItem.setVisible(true); - } - } - private void keyPressed(int keyCode) { if (getView().getTranslationY() != 0) { return; @@ -937,7 +933,6 @@ public class DialpadFragment extends Fragment final PopupMenu popupMenu = new PopupMenu(getActivity(), invoker); popupMenu.inflate(R.menu.dialpad_options); popupMenu.setOnMenuItemClickListener(this); - setupMenuItems(popupMenu.getMenu()); return popupMenu; } @@ -963,6 +958,16 @@ public class DialpadFragment extends Fragment } return; } + case R.id.dialpad_add_contact: { + final CharSequence digits = mDigits.getText(); + DialerUtils.startActivityWithErrorToast(getActivity(), + DialtactsActivity.getAddNumberToContactIntent(digits)); + return; + } + case R.id.dialpad_overflow: { + buildOptionsMenu(view).show(); + break; + } default: { Log.wtf(TAG, "Unexpected onClick() event from: " + view); return; |