diff options
author | Andrew Lee <anwlee@google.com> | 2014-08-20 15:02:16 -0700 |
---|---|---|
committer | Andrew Lee <anwlee@google.com> | 2014-09-02 15:15:21 -0700 |
commit | 405a6e6822fb19a9d14329da92e03e75e2e72703 (patch) | |
tree | 71c5c7db40e52be5c4ba89b1addbc24693f19598 /src/com/android/dialer | |
parent | 3186c3723e143be8c0ab9389118f695ea7c183b4 (diff) |
Use different FAB for dialpad, and use new animations.
+ Use scaleIn/scaleOut for FABs in the Dialer application.
+ Add assets for green fab.
+ Update dialpad fragment, both the Java and layouts, to have their
own FAB containers and FABs.
+ Change DialpadSlidingLinearLayout into
DialpadSlidingRelativeLayout.
- Removed or relocated dial some FAB handling, visibility, and
translation functions. Now that the FABs in the dialpad fragment
and DialtactsActivity are distinct, the logic can be scoped more
precisely to a particular fragment/view.
Bug: 16399233
Change-Id: I86f9f0053dc3c50fe0d5046389632af7ddff9f67
Diffstat (limited to 'src/com/android/dialer')
-rw-r--r-- | src/com/android/dialer/DialtactsActivity.java | 55 | ||||
-rw-r--r-- | src/com/android/dialer/dialpad/DialpadFragment.java | 66 |
2 files changed, 45 insertions, 76 deletions
diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java index 6991be6f9..035ec8b38 100644 --- a/src/com/android/dialer/DialtactsActivity.java +++ b/src/com/android/dialer/DialtactsActivity.java @@ -16,9 +16,7 @@ package com.android.dialer; -import android.animation.LayoutTransition; import android.app.ActionBar; -import android.app.Activity; import android.app.Fragment; import android.app.FragmentTransaction; import android.content.ActivityNotFoundException; @@ -30,7 +28,6 @@ import android.content.res.Configuration; import android.content.res.Resources; import android.net.Uri; import android.os.Bundle; -import android.os.RemoteException; import android.provider.ContactsContract.Contacts; import android.provider.ContactsContract.Intents; import android.speech.RecognizerIntent; @@ -53,7 +50,6 @@ import android.view.View.OnTouchListener; import android.view.ViewTreeObserver; import android.view.animation.Animation; import android.view.animation.AnimationUtils; -import android.view.inputmethod.InputMethodManager; import android.widget.AbsListView.OnScrollListener; import android.widget.EditText; import android.widget.FrameLayout; @@ -103,7 +99,6 @@ import java.util.Locale; public class DialtactsActivity extends TransactionSafeActivity implements View.OnClickListener, DialpadFragment.OnDialpadQueryChangedListener, OnListFragmentScrolledListener, - DialpadFragment.HostInterface, ListsFragment.HostInterface, SpeedDialFragment.HostInterface, SearchFragment.HostInterface, @@ -224,9 +219,6 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O private DragDropController mDragDropController; private ActionBarController mActionBarController; - private String mDescriptionDialButtonStr; - private String mActionMenuDialpadButtonStr; - private ImageButton mFloatingActionButton; private FloatingActionButtonController mFloatingActionButtonController; private int mActionBarHeight; @@ -351,8 +343,6 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O final Resources resources = getResources(); mActionBarHeight = resources.getDimensionPixelSize(R.dimen.action_bar_height_large); - mDescriptionDialButtonStr = resources.getString(R.string.description_dial_button); - mActionMenuDialpadButtonStr = resources.getString(R.string.action_menu_dialpad_button); setContentView(R.layout.dialtacts_activity); getWindow().setBackgroundDrawable(null); @@ -389,12 +379,10 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O final View floatingActionButtonContainer = findViewById( R.id.floating_action_button_container); - mFloatingActionButton = (ImageButton) findViewById(R.id.floating_action_button); - int floatingActionButtonWidth = resources.getDimensionPixelSize( - R.dimen.floating_action_button_width); - mFloatingActionButton.setOnClickListener(this); + ImageButton floatingActionButton = (ImageButton) findViewById(R.id.floating_action_button); + floatingActionButton.setOnClickListener(this); mFloatingActionButtonController = new FloatingActionButtonController(this, - floatingActionButtonContainer, mFloatingActionButton); + floatingActionButtonContainer, floatingActionButton); ImageButton optionsMenuButton = (ImageButton) searchEditTextLayout.findViewById(R.id.dialtacts_options_menu_button); @@ -435,14 +423,13 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O mSlideOut.setAnimationListener(mSlideOutListener); parentLayout = (FrameLayout) findViewById(R.id.dialtacts_mainlayout); - parentLayout.getLayoutTransition().enableTransitionType(LayoutTransition.CHANGING); parentLayout.setOnDragListener(new LayoutOnDragListener()); floatingActionButtonContainer.getViewTreeObserver().addOnGlobalLayoutListener( new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { - final ViewTreeObserver observer = floatingActionButtonContainer - .getViewTreeObserver(); + final ViewTreeObserver observer = + floatingActionButtonContainer.getViewTreeObserver(); if (!observer.isAlive()) { return; } @@ -543,9 +530,6 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O if (!mIsDialpadShown) { mInCallDialpadUp = false; showDialpadFragment(true); - } else { - // Dial button was pressed; tell the Dialpad fragment - mDialpadFragment.dialButtonPressed(); } break; case R.id.voice_search_button: @@ -637,6 +621,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O ft.show(mDialpadFragment); ft.commit(); + mFloatingActionButtonController.scaleOut(); mActionBarController.onDialpadUp(); if (!isInSearchUi()) { @@ -648,9 +633,6 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O * Callback from child DialpadFragment when the dialpad is shown. */ public void onDialpadShown() { - mFloatingActionButton.setImageResource(R.drawable.fab_ic_call); - mFloatingActionButton.setContentDescription(mDescriptionDialButtonStr); - updateFloatingActionButtonControllerAlignment(mDialpadFragment.getAnimate()); if (mDialpadFragment.getAnimate()) { mDialpadFragment.getView().startAnimation(mSlideIn); } else { @@ -679,8 +661,6 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O mDialpadFragment.setAnimate(animate); updateSearchFragmentPosition(); - mFloatingActionButton.setImageResource(R.drawable.fab_ic_dial); - mFloatingActionButton.setContentDescription(mActionMenuDialpadButtonStr); updateFloatingActionButtonControllerAlignment(animate); if (animate) { @@ -705,6 +685,8 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O final FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.hide(mDialpadFragment); ft.commit(); + + mFloatingActionButtonController.scaleIn(AnimUtils.NO_DELAY); } private void updateSearchFragmentPosition() { @@ -1008,11 +990,6 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O // interactions with the ListsFragments. } - @Override - public void setFloatingActionButtonVisible(boolean visible) { - mFloatingActionButtonController.setVisible(visible); - } - private boolean phoneIsInUse() { return getTelecommManager().isInCall(); } @@ -1180,19 +1157,9 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O * @param animate Whether or not to animate the transition. */ private void updateFloatingActionButtonControllerAlignment(boolean animate) { - int align; - if (mIsDialpadShown) { - align = mIsLandscape ? FloatingActionButtonController.ALIGN_QUARTER_END - : FloatingActionButtonController.ALIGN_MIDDLE; - } else { - if (!mIsLandscape) { - align = mCurrentTabPosition == ListsFragment.TAB_INDEX_SPEED_DIAL - ? FloatingActionButtonController.ALIGN_MIDDLE - : FloatingActionButtonController.ALIGN_END; - } else { - align = FloatingActionButtonController.ALIGN_END; - } - } + int align = (!mIsLandscape && mCurrentTabPosition == ListsFragment.TAB_INDEX_SPEED_DIAL) ? + FloatingActionButtonController.ALIGN_MIDDLE : + FloatingActionButtonController.ALIGN_END; mFloatingActionButtonController.align(align, 0 /* offsetX */, 0 /* offsetY */, animate); } } diff --git a/src/com/android/dialer/dialpad/DialpadFragment.java b/src/com/android/dialer/dialpad/DialpadFragment.java index 141a45188..748d22a89 100644 --- a/src/com/android/dialer/dialpad/DialpadFragment.java +++ b/src/com/android/dialer/dialpad/DialpadFragment.java @@ -58,16 +58,19 @@ import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.BaseAdapter; import android.widget.EditText; +import android.widget.ImageButton; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ListView; import android.widget.PopupMenu; +import android.widget.RelativeLayout; import android.widget.TextView; import com.android.contacts.common.CallUtil; import com.android.contacts.common.GeoUtil; import com.android.contacts.common.util.PhoneNumberFormatter; import com.android.contacts.common.util.StopWatch; +import com.android.contacts.common.widget.FloatingActionButtonController; import com.android.dialer.DialtactsActivity; import com.android.dialer.NeededForReflection; import com.android.dialer.R; @@ -96,34 +99,20 @@ public class DialpadFragment extends AnalyticsFragment private static final String TAG = DialpadFragment.class.getSimpleName(); /** - * This interface allows the DialpadFragment to tell its hosting Activity when and when not - * to display the "dial" button. While this is logically part of the DialpadFragment, the - * need to have a particular kind of slick animation puts the "dial" button in the parent. - * - * The parent calls dialButtonPressed() and optionsMenuInvoked() on the dialpad fragment - * when appropriate. - * - * TODO: Refactor the app so this interchange is a bit cleaner. - */ - public interface HostInterface { - void setFloatingActionButtonVisible(boolean visible); - } - - /** * LinearLayout with getter and setter methods for the translationY property using floats, * for animation purposes. */ - public static class DialpadSlidingLinearLayout extends LinearLayout { + public static class DialpadSlidingRelativeLayout extends RelativeLayout { - public DialpadSlidingLinearLayout(Context context) { + public DialpadSlidingRelativeLayout(Context context) { super(context); } - public DialpadSlidingLinearLayout(Context context, AttributeSet attrs) { + public DialpadSlidingRelativeLayout(Context context, AttributeSet attrs) { super(context, attrs); } - public DialpadSlidingLinearLayout(Context context, AttributeSet attrs, int defStyle) { + public DialpadSlidingRelativeLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @@ -167,6 +156,7 @@ public class DialpadFragment extends AnalyticsFragment private DialpadView mDialpadView; private EditText mDigits; + private int mDialpadSlideInDuration; /** Remembers if we need to clear digits field when the screen is completely gone. */ private boolean mClearDigitsOnStop; @@ -178,6 +168,8 @@ public class DialpadFragment extends AnalyticsFragment private final Object mToneGeneratorLock = new Object(); private View mSpacer; + private FloatingActionButtonController mFloatingActionButtonController; + /** * Set of dialpad keys that are currently being pressed */ @@ -337,6 +329,8 @@ public class DialpadFragment extends AnalyticsFragment if (state != null) { mDigitsFilledByIntent = state.getBoolean(PREF_DIGITS_FILLED_BY_INTENT); } + + mDialpadSlideInDuration = getResources().getInteger(R.integer.dialpad_slide_in_duration); } @Override @@ -388,6 +382,14 @@ public class DialpadFragment extends AnalyticsFragment mDialpadChooser = (ListView) fragmentView.findViewById(R.id.dialpadChooser); mDialpadChooser.setOnItemClickListener(this); + final View floatingActionButtonContainer = + fragmentView.findViewById(R.id.dialpad_floating_action_button_container); + final View floatingActionButton = + (ImageButton) fragmentView.findViewById(R.id.dialpad_floating_action_button); + floatingActionButton.setOnClickListener(this); + mFloatingActionButtonController = new FloatingActionButtonController(getActivity(), + floatingActionButtonContainer, floatingActionButton); + return fragmentView; } @@ -870,27 +872,22 @@ public class DialpadFragment extends AnalyticsFragment return popupMenu; } - /** - * Called by the containing Activity to tell this Fragment that the dial button has been - * pressed. - */ - public void dialButtonPressed() { - mHaptic.vibrate(); - handleDialButtonPressed(); - } - @Override public void onClick(View view) { switch (view.getId()) { + case R.id.dialpad_floating_action_button: + mHaptic.vibrate(); + handleDialButtonPressed(); + break; case R.id.deleteButton: { keyPressed(KeyEvent.KEYCODE_DEL); - return; + break; } case R.id.digits: { if (!isDigitsEmpty()) { mDigits.setCursorVisible(true); } - return; + break; } case R.id.dialpad_overflow: { mOverflowPopupMenu.show(); @@ -1214,8 +1211,8 @@ public class DialpadFragment extends AnalyticsFragment if (mDialpadView != null) { mDialpadView.setVisibility(View.GONE); } - ((HostInterface) getActivity()).setFloatingActionButtonVisible(false); + mFloatingActionButtonController.setVisible(false); mDialpadChooser.setVisibility(View.VISIBLE); // Instantiate the DialpadChooserAdapter and hook it up to the @@ -1231,7 +1228,8 @@ public class DialpadFragment extends AnalyticsFragment } else { mDigits.setVisibility(View.VISIBLE); } - ((HostInterface) getActivity()).setFloatingActionButtonVisible(true); + + mFloatingActionButtonController.setVisible(true); mDialpadChooser.setVisibility(View.GONE); } } @@ -1605,10 +1603,14 @@ public class DialpadFragment extends AnalyticsFragment if (!hidden) { if (mAnimate) { dialpadView.animateShow(); + mFloatingActionButtonController.scaleIn(mDialpadSlideInDuration); } activity.onDialpadShown(); mDigits.requestFocus(); } + if (hidden && mAnimate) { + mFloatingActionButtonController.scaleOut(); + } } public void setAnimate(boolean value) { @@ -1620,6 +1622,6 @@ public class DialpadFragment extends AnalyticsFragment } public void setYFraction(float yFraction) { - ((DialpadSlidingLinearLayout) getView()).setYFraction(yFraction); + ((DialpadSlidingRelativeLayout) getView()).setYFraction(yFraction); } } |