summaryrefslogtreecommitdiffstats
path: root/java/com/android/contacts/common
diff options
context:
space:
mode:
authorEric Erfanian <erfanian@google.com>2017-03-21 10:11:17 -0700
committerEric Erfanian <erfanian@google.com>2017-03-21 10:11:17 -0700
commitfc37b02f5d3381a7882770941e461b13b679b6ef (patch)
tree23ce96100a89f1cf8847a4967efd35e56b6f8092 /java/com/android/contacts/common
parent30ccc4f3aa6da94f0bb8a01a880a6353b883b263 (diff)
downloadandroid_packages_apps_Dialer-fc37b02f5d3381a7882770941e461b13b679b6ef.tar.gz
android_packages_apps_Dialer-fc37b02f5d3381a7882770941e461b13b679b6ef.tar.bz2
android_packages_apps_Dialer-fc37b02f5d3381a7882770941e461b13b679b6ef.zip
Update AOSP Dialer source from internal google3 repository at
cl/150756069 Test: make, treehugger This CL updates the AOSP Dialer source with all the changes that have gone into the private google3 repository. This includes all the changes from cl/150392808 (3/16/2017) to cl/150756069 (3/21/2017). This goal of these drops is to keep the AOSP source in sync with the internal google3 repository. Currently these sync are done by hand with very minor modifications to the internal source code. See the Android.mk file for list of modifications. Our current goal is to do frequent drops (daily if possible) and eventually switched to an automated process. Change-Id: I0888b5db52efb28eb8194600e0c7804592f975f3
Diffstat (limited to 'java/com/android/contacts/common')
-rw-r--r--java/com/android/contacts/common/ContactPhotoManager.java15
-rw-r--r--java/com/android/contacts/common/dialog/CallSubjectDialog.java69
-rw-r--r--java/com/android/contacts/common/res/drawable-hdpi/ic_person_add_24dp.pngbin289 -> 0 bytes
-rw-r--r--java/com/android/contacts/common/res/drawable-mdpi/ic_person_add_24dp.pngbin204 -> 0 bytes
-rw-r--r--java/com/android/contacts/common/res/drawable-xhdpi/ic_person_add_24dp.pngbin329 -> 0 bytes
-rw-r--r--java/com/android/contacts/common/res/drawable-xxhdpi/ic_person_add_24dp.pngbin464 -> 0 bytes
-rw-r--r--java/com/android/contacts/common/res/drawable-xxxhdpi/ic_person_add_24dp.pngbin610 -> 0 bytes
-rw-r--r--java/com/android/contacts/common/res/drawable/ic_person_add_tinted_24dp.xml2
-rw-r--r--java/com/android/contacts/common/res/drawable/ic_search_add_contact.xml2
-rw-r--r--java/com/android/contacts/common/res/values-ky/strings.xml2
-rw-r--r--java/com/android/contacts/common/util/FabUtil.java71
-rw-r--r--java/com/android/contacts/common/widget/FloatingActionButtonController.java79
12 files changed, 52 insertions, 188 deletions
diff --git a/java/com/android/contacts/common/ContactPhotoManager.java b/java/com/android/contacts/common/ContactPhotoManager.java
index 0f65a6c56..9e627ae1f 100644
--- a/java/com/android/contacts/common/ContactPhotoManager.java
+++ b/java/com/android/contacts/common/ContactPhotoManager.java
@@ -27,7 +27,9 @@ import android.support.annotation.VisibleForTesting;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
+import android.widget.QuickContactBadge;
import com.android.contacts.common.lettertiles.LetterTileDrawable;
+import com.android.contacts.common.util.UriUtils;
import com.android.dialer.common.LogUtil;
import com.android.dialer.util.PermissionsUtil;
@@ -233,6 +235,19 @@ public abstract class ContactPhotoManager implements ComponentCallbacks2 {
loadThumbnail(view, photoId, darkTheme, isCircular, defaultImageRequest, DEFAULT_AVATAR);
}
+ public final void loadDialerThumbnail(
+ QuickContactBadge badge, Uri contactUri, long photoId, String displayName, int contactType) {
+ badge.assignContactUri(contactUri);
+ badge.setOverlay(null);
+
+ String lookupKey = contactUri == null ? null : UriUtils.getLookupKeyFromUri(contactUri);
+ ContactPhotoManager.DefaultImageRequest request =
+ new ContactPhotoManager.DefaultImageRequest(
+ displayName, lookupKey, contactType, true /* isCircular */);
+ loadThumbnail(
+ badge, photoId, false /* darkTheme */, true /* isCircular */, request, DEFAULT_AVATAR);
+ }
+
/**
* Load photo into the supplied image view. If the photo is already cached, it is displayed
* immediately. Otherwise a request is sent to load the photo from the location specified by the
diff --git a/java/com/android/contacts/common/dialog/CallSubjectDialog.java b/java/com/android/contacts/common/dialog/CallSubjectDialog.java
index d2e3a2357..5e0d6b58a 100644
--- a/java/com/android/contacts/common/dialog/CallSubjectDialog.java
+++ b/java/com/android/contacts/common/dialog/CallSubjectDialog.java
@@ -46,12 +46,10 @@ import android.widget.TextView;
import com.android.contacts.common.ContactPhotoManager;
import com.android.contacts.common.R;
import com.android.contacts.common.compat.telecom.TelecomManagerCompat;
-import com.android.contacts.common.util.UriUtils;
import com.android.dialer.animation.AnimUtils;
import com.android.dialer.callintent.CallIntentBuilder;
import com.android.dialer.callintent.nano.CallInitiationType;
import com.android.dialer.common.LogUtil;
-import com.android.dialer.compat.CompatUtils;
import com.android.dialer.util.ViewUtil;
import java.nio.charset.Charset;
import java.util.ArrayList;
@@ -68,14 +66,13 @@ public class CallSubjectDialog extends Activity {
/** Activity intent argument bundle keys: */
public static final String ARG_PHOTO_ID = "PHOTO_ID";
- public static final String ARG_PHOTO_URI = "PHOTO_URI";
public static final String ARG_CONTACT_URI = "CONTACT_URI";
public static final String ARG_NAME_OR_NUMBER = "NAME_OR_NUMBER";
- public static final String ARG_IS_BUSINESS = "IS_BUSINESS";
public static final String ARG_NUMBER = "NUMBER";
public static final String ARG_DISPLAY_NUMBER = "DISPLAY_NUMBER";
public static final String ARG_NUMBER_LABEL = "NUMBER_LABEL";
public static final String ARG_PHONE_ACCOUNT_HANDLE = "PHONE_ACCOUNT_HANDLE";
+ public static final String ARG_CONTACT_TYPE = "CONTACT_TYPE";
private static final int CALL_SUBJECT_LIMIT = 16;
private static final int CALL_SUBJECT_HISTORY_SIZE = 5;
private int mAnimationDuration;
@@ -111,7 +108,6 @@ public class CallSubjectDialog extends Activity {
}
};
- private int mPhotoSize;
private SharedPreferences mPrefs;
private List<String> mSubjectHistory;
/** Handles displaying the list of past call subjects. */
@@ -138,13 +134,12 @@ public class CallSubjectDialog extends Activity {
};
private long mPhotoID;
- private Uri mPhotoUri;
private Uri mContactUri;
private String mNameOrNumber;
- private boolean mIsBusiness;
private String mNumber;
private String mDisplayNumber;
private String mNumberLabel;
+ private int mContactType;
private PhoneAccountHandle mPhoneAccountHandle;
/** Handles starting a call with a call subject specified. */
private final View.OnClickListener mSendAndCallOnClickListener =
@@ -200,13 +195,12 @@ public class CallSubjectDialog extends Activity {
start(
activity,
-1 /* photoId */,
- null /* photoUri */,
null /* contactUri */,
number /* nameOrNumber */,
- false /* isBusiness */,
number /* number */,
null /* displayNumber */,
null /* numberLabel */,
+ ContactPhotoManager.TYPE_DEFAULT,
null /* phoneAccountHandle */);
}
@@ -215,35 +209,32 @@ public class CallSubjectDialog extends Activity {
*
* @param activity The current activity.
* @param photoId The photo ID (used to populate contact photo).
- * @param photoUri The photo Uri (used to populate contact photo).
* @param contactUri The Contact URI (used so quick contact can be invoked from contact photo).
* @param nameOrNumber The name or number of the callee.
- * @param isBusiness {@code true} if a business is being called (used for contact photo).
* @param number The raw number to dial.
* @param displayNumber The number to dial, formatted for display.
* @param numberLabel The label for the number (if from a contact).
+ * @param contactType The contact type according to {@link ContactPhotoManager}.
* @param phoneAccountHandle The phone account handle.
*/
public static void start(
Activity activity,
long photoId,
- Uri photoUri,
Uri contactUri,
String nameOrNumber,
- boolean isBusiness,
String number,
String displayNumber,
String numberLabel,
+ int contactType,
PhoneAccountHandle phoneAccountHandle) {
Bundle arguments = new Bundle();
arguments.putLong(ARG_PHOTO_ID, photoId);
- arguments.putParcelable(ARG_PHOTO_URI, photoUri);
arguments.putParcelable(ARG_CONTACT_URI, contactUri);
arguments.putString(ARG_NAME_OR_NUMBER, nameOrNumber);
- arguments.putBoolean(ARG_IS_BUSINESS, isBusiness);
arguments.putString(ARG_NUMBER, number);
arguments.putString(ARG_DISPLAY_NUMBER, displayNumber);
arguments.putString(ARG_NUMBER_LABEL, numberLabel);
+ arguments.putInt(ARG_CONTACT_TYPE, contactType);
arguments.putParcelable(ARG_PHONE_ACCOUNT_HANDLE, phoneAccountHandle);
start(activity, arguments);
}
@@ -293,8 +284,6 @@ public class CallSubjectDialog extends Activity {
super.onCreate(savedInstanceState);
mAnimationDuration = getResources().getInteger(R.integer.call_subject_animation_duration);
mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
- mPhotoSize =
- getResources().getDimensionPixelSize(R.dimen.call_subject_dialog_contact_photo_size);
readArguments();
loadConfiguration();
mSubjectHistory = loadSubjectHistory(mPrefs);
@@ -330,7 +319,8 @@ public class CallSubjectDialog extends Activity {
/** Populates the contact info fields based on the current contact information. */
private void updateContactInfo() {
if (mContactUri != null) {
- setPhoto(mPhotoID, mPhotoUri, mContactUri, mNameOrNumber, mIsBusiness);
+ ContactPhotoManager.getInstance(this)
+ .loadDialerThumbnail(mContactPhoto, mContactUri, mPhotoID, mNameOrNumber, mContactType);
} else {
mContactPhoto.setVisibility(View.GONE);
}
@@ -353,13 +343,12 @@ public class CallSubjectDialog extends Activity {
return;
}
mPhotoID = arguments.getLong(ARG_PHOTO_ID);
- mPhotoUri = arguments.getParcelable(ARG_PHOTO_URI);
mContactUri = arguments.getParcelable(ARG_CONTACT_URI);
mNameOrNumber = arguments.getString(ARG_NAME_OR_NUMBER);
- mIsBusiness = arguments.getBoolean(ARG_IS_BUSINESS);
mNumber = arguments.getString(ARG_NUMBER);
mDisplayNumber = arguments.getString(ARG_DISPLAY_NUMBER);
mNumberLabel = arguments.getString(ARG_NUMBER_LABEL);
+ mContactType = arguments.getInt(ARG_CONTACT_TYPE, ContactPhotoManager.TYPE_DEFAULT);
mPhoneAccountHandle = arguments.getParcelable(ARG_PHONE_ACCOUNT_HANDLE);
}
@@ -389,46 +378,6 @@ public class CallSubjectDialog extends Activity {
}
}
- /** Sets the photo on the quick contact photo. */
- private void setPhoto(
- long photoId, Uri photoUri, Uri contactUri, String displayName, boolean isBusiness) {
- mContactPhoto.assignContactUri(contactUri);
- if (CompatUtils.isLollipopCompatible()) {
- mContactPhoto.setOverlay(null);
- }
-
- int contactType;
- if (isBusiness) {
- contactType = ContactPhotoManager.TYPE_BUSINESS;
- } else {
- contactType = ContactPhotoManager.TYPE_DEFAULT;
- }
-
- String lookupKey = null;
- if (contactUri != null) {
- lookupKey = UriUtils.getLookupKeyFromUri(contactUri);
- }
-
- ContactPhotoManager.DefaultImageRequest request =
- new ContactPhotoManager.DefaultImageRequest(
- displayName, lookupKey, contactType, true /* isCircular */);
-
- if (photoId == 0 && photoUri != null) {
- ContactPhotoManager.getInstance(this)
- .loadPhoto(
- mContactPhoto,
- photoUri,
- mPhotoSize,
- false /* darkTheme */,
- true /* isCircular */,
- request);
- } else {
- ContactPhotoManager.getInstance(this)
- .loadThumbnail(
- mContactPhoto, photoId, false /* darkTheme */, true /* isCircular */, request);
- }
- }
-
/**
* Saves the subject history list to shared prefs, removing older items so that there are only
* {@link #CALL_SUBJECT_HISTORY_SIZE} items at most.
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
deleted file mode 100644
index 10ae5a70c..000000000
--- a/java/com/android/contacts/common/res/drawable-hdpi/ic_person_add_24dp.png
+++ /dev/null
Binary files 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
deleted file mode 100644
index 38e0a2882..000000000
--- a/java/com/android/contacts/common/res/drawable-mdpi/ic_person_add_24dp.png
+++ /dev/null
Binary files 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
deleted file mode 100644
index 7e7c289d4..000000000
--- a/java/com/android/contacts/common/res/drawable-xhdpi/ic_person_add_24dp.png
+++ /dev/null
Binary files 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
deleted file mode 100644
index 8f744f039..000000000
--- a/java/com/android/contacts/common/res/drawable-xxhdpi/ic_person_add_24dp.png
+++ /dev/null
Binary files 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
deleted file mode 100644
index 2fa2cca80..000000000
--- a/java/com/android/contacts/common/res/drawable-xxxhdpi/ic_person_add_24dp.png
+++ /dev/null
Binary files 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 0af90edb3..c2538cfd1 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 @@
-->
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:autoMirrored="true"
- android:src="@drawable/ic_person_add_24dp"
+ android:src="@drawable/quantum_ic_person_add_white_24"
android:tint="@color/actionbar_icon_color"/>
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 801806044..476212d24 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 @@
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:autoMirrored="true"
- android:src="@drawable/ic_person_add_24dp"/>
+ android:src="@drawable/quantum_ic_person_add_white_24"/>
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 55a210a0b..ed081ec60 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 @@
<string name="email_mobile" msgid="4487686436743741150">"Мобилге эмейлдөө"</string>
<string name="email_work" msgid="4223487303344613528">"Жумушка эмейлдөө"</string>
<string name="email_other" msgid="4246411900126012062">"Электрондук кат жазуу"</string>
- <string name="email_custom" msgid="7246580894327511013">"<xliff:g id="CUSTOM">%s</xliff:g> эмейл жөнөтүү"</string>
+ <string name="email_custom" msgid="7246580894327511013">"Кат жазуу (<xliff:g id="CUSTOM">%s</xliff:g>)"</string>
<string name="email" msgid="2807318537887091606">"Электрондук кат жазуу"</string>
<string name="postal_street" msgid="6918171741240802474">"Көчөсү"</string>
<string name="postal_pobox" msgid="2962203483168878561">"Абонент кутусу"</string>
diff --git a/java/com/android/contacts/common/util/FabUtil.java b/java/com/android/contacts/common/util/FabUtil.java
deleted file mode 100644
index b1bb2e653..000000000
--- a/java/com/android/contacts/common/util/FabUtil.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * 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 f03129779..368d09207 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,12 +41,11 @@ public class FloatingActionButtonController {
private final int mAnimationDuration;
private final int mFloatingActionButtonWidth;
private final int mFloatingActionButtonMarginRight;
- private final View mFloatingActionButtonContainer;
- private final ImageButton mFloatingActionButton;
+ private final FloatingActionButton mFab;
private final Interpolator mFabInterpolator;
private int mScreenWidth;
- public FloatingActionButtonController(Activity activity, View container, ImageButton button) {
+ public FloatingActionButtonController(Activity activity, FloatingActionButton fab) {
Resources resources = activity.getResources();
mFabInterpolator =
AnimationUtils.loadInterpolator(activity, android.R.interpolator.fast_out_slow_in);
@@ -55,9 +54,7 @@ public class FloatingActionButtonController {
mFloatingActionButtonMarginRight =
resources.getDimensionPixelOffset(R.dimen.floating_action_button_margin_right);
mAnimationDuration = resources.getInteger(R.integer.floating_action_button_animation_duration);
- mFloatingActionButtonContainer = container;
- mFloatingActionButton = button;
- FabUtil.setupFloatingActionButton(mFloatingActionButtonContainer, resources);
+ mFab = fab;
}
/**
@@ -71,7 +68,7 @@ public class FloatingActionButtonController {
}
public boolean isVisible() {
- return mFloatingActionButtonContainer.getVisibility() == View.VISIBLE;
+ return mFab.getVisibility() == View.VISIBLE;
}
/**
@@ -80,14 +77,13 @@ public class FloatingActionButtonController {
* @param visible Whether or not to make the container visible.
*/
public void setVisible(boolean visible) {
- mFloatingActionButtonContainer.setVisibility(visible ? View.VISIBLE : View.GONE);
+ mFab.setVisibility(visible ? View.VISIBLE : View.GONE);
}
public void changeIcon(Drawable icon, String description) {
- if (mFloatingActionButton.getDrawable() != icon
- || !mFloatingActionButton.getContentDescription().equals(description)) {
- mFloatingActionButton.setImageDrawable(icon);
- mFloatingActionButton.setContentDescription(description);
+ if (mFab.getDrawable() != icon || !mFab.getContentDescription().equals(description)) {
+ mFab.setImageDrawable(icon);
+ mFab.setContentDescription(description);
}
}
@@ -99,8 +95,7 @@ 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.
- mFloatingActionButtonContainer.setTranslationX(
- (int) (positionOffset * getTranslationXForAlignment(ALIGN_END)));
+ mFab.setTranslationX(positionOffset * getTranslationXForAlignment(ALIGN_END));
}
/**
@@ -121,7 +116,7 @@ public class FloatingActionButtonController {
* @param offsetY Additional offsetY to translate by.
* @param animate Whether or not to animate the transition.
*/
- public void align(int align, int offsetX, int offsetY, boolean animate) {
+ private void align(int align, int offsetX, int offsetY, boolean animate) {
if (mScreenWidth == 0) {
return;
}
@@ -129,33 +124,16 @@ public class FloatingActionButtonController {
int translationX = getTranslationXForAlignment(align);
// Skip animation if container is not shown; animation causes container to show again.
- if (animate && mFloatingActionButtonContainer.isShown()) {
- mFloatingActionButtonContainer
- .animate()
+ if (animate && mFab.isShown()) {
+ mFab.animate()
.translationX(translationX + offsetX)
.translationY(offsetY)
.setInterpolator(mFabInterpolator)
.setDuration(mAnimationDuration)
.start();
} else {
- 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();
+ mFab.setTranslationX(translationX + offsetX);
+ mFab.setTranslationY(offsetY);
}
}
@@ -167,17 +145,8 @@ public class FloatingActionButtonController {
*/
public void scaleIn(int delayMs) {
setVisible(true);
- 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);
+ AnimUtils.scaleIn(mFab, FAB_SCALE_IN_DURATION, delayMs);
+ AnimUtils.fadeIn(mFab, FAB_SCALE_IN_DURATION, delayMs + FAB_SCALE_IN_FADE_IN_DELAY, null);
}
/**
@@ -185,10 +154,10 @@ public class FloatingActionButtonController {
* animation for hiding the floating action button.
*/
public void scaleOut() {
- AnimUtils.scaleOut(mFloatingActionButtonContainer, mAnimationDuration);
+ AnimUtils.scaleOut(mFab, 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(mFloatingActionButton, FAB_ICON_FADE_OUT_DURATION, null);
+ AnimUtils.fadeOut(mFab, FAB_ICON_FADE_OUT_DURATION, null);
}
/**
@@ -198,8 +167,8 @@ public class FloatingActionButtonController {
* @param align One of ALIGN_MIDDLE, ALIGN_QUARTER_RIGHT, or ALIGN_RIGHT.
* @return The translationX for the given alignment.
*/
- public int getTranslationXForAlignment(int align) {
- int result = 0;
+ private int getTranslationXForAlignment(int align) {
+ int result;
switch (align) {
case ALIGN_MIDDLE:
// Moves the FAB to exactly center screen.
@@ -213,6 +182,8 @@ public class FloatingActionButtonController {
result =
mScreenWidth / 2 - mFloatingActionButtonWidth / 2 - mFloatingActionButtonMarginRight;
break;
+ default:
+ throw Assert.createIllegalStateFailException("Invalid alignment value: " + align);
}
if (isLayoutRtl()) {
result *= -1;
@@ -221,6 +192,6 @@ public class FloatingActionButtonController {
}
private boolean isLayoutRtl() {
- return mFloatingActionButtonContainer.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
+ return mFab.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
}
}