From 405a6e6822fb19a9d14329da92e03e75e2e72703 Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Wed, 20 Aug 2014 15:02:16 -0700 Subject: 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 --- res/drawable-hdpi/fab_green.png | Bin 0 -> 2798 bytes res/drawable-mdpi/fab_green.png | Bin 0 -> 1845 bytes res/drawable-xhdpi/fab_green.png | Bin 0 -> 4092 bytes res/drawable-xxhdpi/fab_green.png | Bin 0 -> 7004 bytes res/drawable-xxxhdpi/fab_green.png | Bin 0 -> 9900 bytes res/drawable/floating_action_button.xml | 4 +- res/layout-land/dialpad_fragment.xml | 98 +++++++++++++++------ res/layout/dialpad_fragment.xml | 75 +++++++++++----- res/layout/dialtacts_activity.xml | 13 +-- src/com/android/dialer/DialtactsActivity.java | 55 +++--------- .../android/dialer/dialpad/DialpadFragment.java | 66 +++++++------- 11 files changed, 177 insertions(+), 134 deletions(-) create mode 100644 res/drawable-hdpi/fab_green.png create mode 100644 res/drawable-mdpi/fab_green.png create mode 100644 res/drawable-xhdpi/fab_green.png create mode 100644 res/drawable-xxhdpi/fab_green.png create mode 100644 res/drawable-xxxhdpi/fab_green.png diff --git a/res/drawable-hdpi/fab_green.png b/res/drawable-hdpi/fab_green.png new file mode 100644 index 000000000..ff9753c18 Binary files /dev/null and b/res/drawable-hdpi/fab_green.png differ diff --git a/res/drawable-mdpi/fab_green.png b/res/drawable-mdpi/fab_green.png new file mode 100644 index 000000000..947aac142 Binary files /dev/null and b/res/drawable-mdpi/fab_green.png differ diff --git a/res/drawable-xhdpi/fab_green.png b/res/drawable-xhdpi/fab_green.png new file mode 100644 index 000000000..e8bab3fec Binary files /dev/null and b/res/drawable-xhdpi/fab_green.png differ diff --git a/res/drawable-xxhdpi/fab_green.png b/res/drawable-xxhdpi/fab_green.png new file mode 100644 index 000000000..7e4fd3e49 Binary files /dev/null and b/res/drawable-xxhdpi/fab_green.png differ diff --git a/res/drawable-xxxhdpi/fab_green.png b/res/drawable-xxxhdpi/fab_green.png new file mode 100644 index 000000000..aa8849e86 Binary files /dev/null and b/res/drawable-xxxhdpi/fab_green.png differ diff --git a/res/drawable/floating_action_button.xml b/res/drawable/floating_action_button.xml index cbbfb8542..e5ae14a2b 100644 --- a/res/drawable/floating_action_button.xml +++ b/res/drawable/floating_action_button.xml @@ -16,6 +16,4 @@ --> - - + android:color="@color/floating_action_button_touch_tint" /> \ No newline at end of file diff --git a/res/layout-land/dialpad_fragment.xml b/res/layout-land/dialpad_fragment.xml index aac0daf3b..680c2d770 100644 --- a/res/layout-land/dialpad_fragment.xml +++ b/res/layout-land/dialpad_fragment.xml @@ -13,35 +13,75 @@ See the License for the specific language governing permissions and limitations under the License. --> - - - - - - - - + android:layout_height="wrap_content"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/res/layout/dialpad_fragment.xml b/res/layout/dialpad_fragment.xml index 01bbecc00..21cb58654 100644 --- a/res/layout/dialpad_fragment.xml +++ b/res/layout/dialpad_fragment.xml @@ -13,31 +13,64 @@ See the License for the specific language governing permissions and limitations under the License. --> - - - + + - - + + + + + + + + + + + + + - - - + + + + + android:layout_height="match_parent" + android:background="@drawable/floating_action_button" + android:contentDescription="@string/description_dial_button" + android:src="@drawable/fab_ic_call"/> + + + diff --git a/res/layout/dialtacts_activity.xml b/res/layout/dialtacts_activity.xml index aa4ce9409..0f1f2bbdb 100644 --- a/res/layout/dialtacts_activity.xml +++ b/res/layout/dialtacts_activity.xml @@ -22,9 +22,8 @@ android:focusable="true" android:focusableInTouchMode="true" android:clipChildren="false" - android:animateLayoutChanges="true" - android:background="@color/background_dialer_light" - > + android:background="@color/background_dialer_light"> + + + android:layout_gravity="center_horizontal|bottom"> + + 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; @@ -95,35 +98,21 @@ public class DialpadFragment extends AnalyticsFragment DialpadKeyButton.OnPressedListener { 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); } } -- cgit v1.2.3