From 30ccc4f3aa6da94f0bb8a01a880a6353b883b263 Mon Sep 17 00:00:00 2001 From: Eric Erfanian Date: Mon, 20 Mar 2017 20:40:36 +0000 Subject: Revert "Update AOSP Dialer source from internal google3 repository at cl/150622237" This reverts commit 06b6b56e9eaa91ebf757ea641e38a9c885fa40bd. Change-Id: Ida8c5ee67669524dc63b9adc60a6dd392cb9b9a6 --- .../res/drawable-hdpi/ic_person_add_24dp.png | Bin 0 -> 289 bytes .../res/drawable-mdpi/ic_person_add_24dp.png | Bin 0 -> 204 bytes .../res/drawable-xhdpi/ic_person_add_24dp.png | Bin 0 -> 329 bytes .../res/drawable-xxhdpi/ic_person_add_24dp.png | Bin 0 -> 464 bytes .../res/drawable-xxxhdpi/ic_person_add_24dp.png | Bin 0 -> 610 bytes .../res/drawable/ic_person_add_tinted_24dp.xml | 2 +- .../common/res/drawable/ic_search_add_contact.xml | 2 +- .../contacts/common/res/values-ky/strings.xml | 2 +- java/com/android/contacts/common/util/FabUtil.java | 71 ++++++++++++++++++ .../widget/FloatingActionButtonController.java | 79 ++++++++++++++------- 10 files changed, 128 insertions(+), 28 deletions(-) create mode 100644 java/com/android/contacts/common/res/drawable-hdpi/ic_person_add_24dp.png create mode 100644 java/com/android/contacts/common/res/drawable-mdpi/ic_person_add_24dp.png create mode 100644 java/com/android/contacts/common/res/drawable-xhdpi/ic_person_add_24dp.png create mode 100644 java/com/android/contacts/common/res/drawable-xxhdpi/ic_person_add_24dp.png create mode 100644 java/com/android/contacts/common/res/drawable-xxxhdpi/ic_person_add_24dp.png create mode 100644 java/com/android/contacts/common/util/FabUtil.java (limited to 'java/com/android/contacts/common') diff --git a/java/com/android/contacts/common/res/drawable-hdpi/ic_person_add_24dp.png b/java/com/android/contacts/common/res/drawable-hdpi/ic_person_add_24dp.png new file mode 100644 index 000000000..10ae5a70c Binary files /dev/null and b/java/com/android/contacts/common/res/drawable-hdpi/ic_person_add_24dp.png differ diff --git a/java/com/android/contacts/common/res/drawable-mdpi/ic_person_add_24dp.png b/java/com/android/contacts/common/res/drawable-mdpi/ic_person_add_24dp.png new file mode 100644 index 000000000..38e0a2882 Binary files /dev/null and b/java/com/android/contacts/common/res/drawable-mdpi/ic_person_add_24dp.png differ diff --git a/java/com/android/contacts/common/res/drawable-xhdpi/ic_person_add_24dp.png b/java/com/android/contacts/common/res/drawable-xhdpi/ic_person_add_24dp.png new file mode 100644 index 000000000..7e7c289d4 Binary files /dev/null and b/java/com/android/contacts/common/res/drawable-xhdpi/ic_person_add_24dp.png differ diff --git a/java/com/android/contacts/common/res/drawable-xxhdpi/ic_person_add_24dp.png b/java/com/android/contacts/common/res/drawable-xxhdpi/ic_person_add_24dp.png new file mode 100644 index 000000000..8f744f039 Binary files /dev/null and b/java/com/android/contacts/common/res/drawable-xxhdpi/ic_person_add_24dp.png differ diff --git a/java/com/android/contacts/common/res/drawable-xxxhdpi/ic_person_add_24dp.png b/java/com/android/contacts/common/res/drawable-xxxhdpi/ic_person_add_24dp.png new file mode 100644 index 000000000..2fa2cca80 Binary files /dev/null and b/java/com/android/contacts/common/res/drawable-xxxhdpi/ic_person_add_24dp.png differ diff --git a/java/com/android/contacts/common/res/drawable/ic_person_add_tinted_24dp.xml b/java/com/android/contacts/common/res/drawable/ic_person_add_tinted_24dp.xml index c2538cfd1..0af90edb3 100644 --- a/java/com/android/contacts/common/res/drawable/ic_person_add_tinted_24dp.xml +++ b/java/com/android/contacts/common/res/drawable/ic_person_add_tinted_24dp.xml @@ -16,5 +16,5 @@ --> diff --git a/java/com/android/contacts/common/res/drawable/ic_search_add_contact.xml b/java/com/android/contacts/common/res/drawable/ic_search_add_contact.xml index 476212d24..801806044 100644 --- a/java/com/android/contacts/common/res/drawable/ic_search_add_contact.xml +++ b/java/com/android/contacts/common/res/drawable/ic_search_add_contact.xml @@ -17,4 +17,4 @@ + android:src="@drawable/ic_person_add_24dp"/> diff --git a/java/com/android/contacts/common/res/values-ky/strings.xml b/java/com/android/contacts/common/res/values-ky/strings.xml index ed081ec60..55a210a0b 100644 --- a/java/com/android/contacts/common/res/values-ky/strings.xml +++ b/java/com/android/contacts/common/res/values-ky/strings.xml @@ -122,7 +122,7 @@ "Мобилге эмейлдөө" "Жумушка эмейлдөө" "Электрондук кат жазуу" - "Кат жазуу (%s)" + "%s эмейл жөнөтүү" "Электрондук кат жазуу" "Көчөсү" "Абонент кутусу" diff --git a/java/com/android/contacts/common/util/FabUtil.java b/java/com/android/contacts/common/util/FabUtil.java new file mode 100644 index 000000000..b1bb2e653 --- /dev/null +++ b/java/com/android/contacts/common/util/FabUtil.java @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.contacts.common.util; + +import android.content.res.Resources; +import android.graphics.Outline; +import android.view.View; +import android.view.ViewOutlineProvider; +import android.widget.ListView; +import com.android.contacts.common.R; +import com.android.dialer.compat.CompatUtils; + +/** Provides static functions to work with views */ +public class FabUtil { + + private static final ViewOutlineProvider OVAL_OUTLINE_PROVIDER = + new ViewOutlineProvider() { + @Override + public void getOutline(View view, Outline outline) { + outline.setOval(0, 0, view.getWidth(), view.getHeight()); + } + }; + + private FabUtil() {} + + /** + * Configures the floating action button, clipping it to a circle and setting its translation z + * + * @param fabView the float action button's view + * @param res the resources file + */ + public static void setupFloatingActionButton(View fabView, Resources res) { + if (CompatUtils.isLollipopCompatible()) { + fabView.setOutlineProvider(OVAL_OUTLINE_PROVIDER); + fabView.setTranslationZ( + res.getDimensionPixelSize(R.dimen.floating_action_button_translation_z)); + } + } + + /** + * Adds padding to the bottom of the given {@link ListView} so that the floating action button + * does not obscure any content. + * + * @param listView to add the padding to + * @param res valid resources object + */ + public static void addBottomPaddingToListViewForFab(ListView listView, Resources res) { + final int fabPadding = + res.getDimensionPixelSize(R.dimen.floating_action_button_list_bottom_padding); + listView.setPaddingRelative( + listView.getPaddingStart(), + listView.getPaddingTop(), + listView.getPaddingEnd(), + listView.getPaddingBottom() + fabPadding); + listView.setClipToPadding(false); + } +} diff --git a/java/com/android/contacts/common/widget/FloatingActionButtonController.java b/java/com/android/contacts/common/widget/FloatingActionButtonController.java index 368d09207..f03129779 100644 --- a/java/com/android/contacts/common/widget/FloatingActionButtonController.java +++ b/java/com/android/contacts/common/widget/FloatingActionButtonController.java @@ -19,13 +19,13 @@ package com.android.contacts.common.widget; import android.app.Activity; import android.content.res.Resources; import android.graphics.drawable.Drawable; -import android.support.design.widget.FloatingActionButton; import android.view.View; import android.view.animation.AnimationUtils; import android.view.animation.Interpolator; +import android.widget.ImageButton; import com.android.contacts.common.R; +import com.android.contacts.common.util.FabUtil; import com.android.dialer.animation.AnimUtils; -import com.android.dialer.common.Assert; /** Controls the movement and appearance of the FAB (Floating Action Button). */ public class FloatingActionButtonController { @@ -41,11 +41,12 @@ public class FloatingActionButtonController { private final int mAnimationDuration; private final int mFloatingActionButtonWidth; private final int mFloatingActionButtonMarginRight; - private final FloatingActionButton mFab; + private final View mFloatingActionButtonContainer; + private final ImageButton mFloatingActionButton; private final Interpolator mFabInterpolator; private int mScreenWidth; - public FloatingActionButtonController(Activity activity, FloatingActionButton fab) { + public FloatingActionButtonController(Activity activity, View container, ImageButton button) { Resources resources = activity.getResources(); mFabInterpolator = AnimationUtils.loadInterpolator(activity, android.R.interpolator.fast_out_slow_in); @@ -54,7 +55,9 @@ public class FloatingActionButtonController { mFloatingActionButtonMarginRight = resources.getDimensionPixelOffset(R.dimen.floating_action_button_margin_right); mAnimationDuration = resources.getInteger(R.integer.floating_action_button_animation_duration); - mFab = fab; + mFloatingActionButtonContainer = container; + mFloatingActionButton = button; + FabUtil.setupFloatingActionButton(mFloatingActionButtonContainer, resources); } /** @@ -68,7 +71,7 @@ public class FloatingActionButtonController { } public boolean isVisible() { - return mFab.getVisibility() == View.VISIBLE; + return mFloatingActionButtonContainer.getVisibility() == View.VISIBLE; } /** @@ -77,13 +80,14 @@ public class FloatingActionButtonController { * @param visible Whether or not to make the container visible. */ public void setVisible(boolean visible) { - mFab.setVisibility(visible ? View.VISIBLE : View.GONE); + mFloatingActionButtonContainer.setVisibility(visible ? View.VISIBLE : View.GONE); } public void changeIcon(Drawable icon, String description) { - if (mFab.getDrawable() != icon || !mFab.getContentDescription().equals(description)) { - mFab.setImageDrawable(icon); - mFab.setContentDescription(description); + if (mFloatingActionButton.getDrawable() != icon + || !mFloatingActionButton.getContentDescription().equals(description)) { + mFloatingActionButton.setImageDrawable(icon); + mFloatingActionButton.setContentDescription(description); } } @@ -95,7 +99,8 @@ public class FloatingActionButtonController { public void onPageScrolled(float positionOffset) { // As the page is scrolling, if we're on the first tab, update the FAB position so it // moves along with it. - mFab.setTranslationX(positionOffset * getTranslationXForAlignment(ALIGN_END)); + mFloatingActionButtonContainer.setTranslationX( + (int) (positionOffset * getTranslationXForAlignment(ALIGN_END))); } /** @@ -116,7 +121,7 @@ public class FloatingActionButtonController { * @param offsetY Additional offsetY to translate by. * @param animate Whether or not to animate the transition. */ - private void align(int align, int offsetX, int offsetY, boolean animate) { + public void align(int align, int offsetX, int offsetY, boolean animate) { if (mScreenWidth == 0) { return; } @@ -124,16 +129,33 @@ public class FloatingActionButtonController { int translationX = getTranslationXForAlignment(align); // Skip animation if container is not shown; animation causes container to show again. - if (animate && mFab.isShown()) { - mFab.animate() + if (animate && mFloatingActionButtonContainer.isShown()) { + mFloatingActionButtonContainer + .animate() .translationX(translationX + offsetX) .translationY(offsetY) .setInterpolator(mFabInterpolator) .setDuration(mAnimationDuration) .start(); } else { - mFab.setTranslationX(translationX + offsetX); - mFab.setTranslationY(offsetY); + mFloatingActionButtonContainer.setTranslationX(translationX + offsetX); + mFloatingActionButtonContainer.setTranslationY(offsetY); + } + } + + /** + * Resizes width and height of the floating action bar container. + * + * @param dimension The new dimensions for the width and height. + * @param animate Whether to animate this change. + */ + public void resize(int dimension, boolean animate) { + if (animate) { + AnimUtils.changeDimensions(mFloatingActionButtonContainer, dimension, dimension); + } else { + mFloatingActionButtonContainer.getLayoutParams().width = dimension; + mFloatingActionButtonContainer.getLayoutParams().height = dimension; + mFloatingActionButtonContainer.requestLayout(); } } @@ -145,8 +167,17 @@ public class FloatingActionButtonController { */ public void scaleIn(int delayMs) { setVisible(true); - AnimUtils.scaleIn(mFab, FAB_SCALE_IN_DURATION, delayMs); - AnimUtils.fadeIn(mFab, FAB_SCALE_IN_DURATION, delayMs + FAB_SCALE_IN_FADE_IN_DELAY, null); + AnimUtils.scaleIn(mFloatingActionButtonContainer, FAB_SCALE_IN_DURATION, delayMs); + AnimUtils.fadeIn( + mFloatingActionButton, FAB_SCALE_IN_DURATION, delayMs + FAB_SCALE_IN_FADE_IN_DELAY, null); + } + + /** Immediately remove the affects of the last call to {@link #scaleOut}. */ + public void resetIn() { + mFloatingActionButton.setAlpha(1f); + mFloatingActionButton.setVisibility(View.VISIBLE); + mFloatingActionButtonContainer.setScaleX(1); + mFloatingActionButtonContainer.setScaleY(1); } /** @@ -154,10 +185,10 @@ public class FloatingActionButtonController { * animation for hiding the floating action button. */ public void scaleOut() { - AnimUtils.scaleOut(mFab, mAnimationDuration); + AnimUtils.scaleOut(mFloatingActionButtonContainer, mAnimationDuration); // Fade out the icon faster than the scale out animation, so that the icon scaling is less // obvious. We don't want it to scale, but the resizing the container is not as performant. - AnimUtils.fadeOut(mFab, FAB_ICON_FADE_OUT_DURATION, null); + AnimUtils.fadeOut(mFloatingActionButton, FAB_ICON_FADE_OUT_DURATION, null); } /** @@ -167,8 +198,8 @@ public class FloatingActionButtonController { * @param align One of ALIGN_MIDDLE, ALIGN_QUARTER_RIGHT, or ALIGN_RIGHT. * @return The translationX for the given alignment. */ - private int getTranslationXForAlignment(int align) { - int result; + public int getTranslationXForAlignment(int align) { + int result = 0; switch (align) { case ALIGN_MIDDLE: // Moves the FAB to exactly center screen. @@ -182,8 +213,6 @@ public class FloatingActionButtonController { result = mScreenWidth / 2 - mFloatingActionButtonWidth / 2 - mFloatingActionButtonMarginRight; break; - default: - throw Assert.createIllegalStateFailException("Invalid alignment value: " + align); } if (isLayoutRtl()) { result *= -1; @@ -192,6 +221,6 @@ public class FloatingActionButtonController { } private boolean isLayoutRtl() { - return mFab.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL; + return mFloatingActionButtonContainer.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL; } } -- cgit v1.2.3