Merge "Add a cancel string for ToggleSubscriptionDialog to handle Tamil translation" into sc-dev
diff --git a/res/layout/fingerprint_enroll_introduction.xml b/res/layout/fingerprint_enroll_introduction.xml
index 65c1497..5f82879 100644
--- a/res/layout/fingerprint_enroll_introduction.xml
+++ b/res/layout/fingerprint_enroll_introduction.xml
@@ -98,7 +98,7 @@
android:paddingTop="24dp">
<ImageView
- android:id="@+id/icon_fingerprint"
+ android:id="@+id/icon_device_locked"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@null"
@@ -133,7 +133,7 @@
android:paddingTop="24dp">
<ImageView
- android:id="@+id/icon_fingerprint"
+ android:id="@+id/icon_trash_can"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@null"
diff --git a/res/layout/preference_animated_image.xml b/res/layout/preference_animated_image.xml
deleted file mode 100644
index 64cfc98..0000000
--- a/res/layout/preference_animated_image.xml
+++ /dev/null
@@ -1,45 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2019 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.
- -->
-
-<LinearLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="@dimen/settingslib_illustration_height"
- android:gravity="center"
- android:padding="@dimen/settingslib_illustration_padding"
- android:orientation="vertical"
- android:importantForAccessibility="noHideDescendants">
-
- <ImageView
- android:id="@+id/animated_img"
- android:maxWidth="@dimen/settingslib_illustration_width"
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:background="@drawable/protection_background"
- android:scaleType="fitCenter"
- android:adjustViewBounds="true"/>
-
- <com.airbnb.lottie.LottieAnimationView
- android:id="@+id/lottie_view"
- android:maxWidth="@dimen/settingslib_illustration_width"
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:background="@drawable/protection_background"
- android:scaleType="fitCenter"
- android:adjustViewBounds="true"
- android:clipToOutline="true"/>
-</LinearLayout>
\ No newline at end of file
diff --git a/res/raw/lottie_swipe_for_notifications.json b/res/raw/lottie_swipe_for_notifications.json
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/res/raw/lottie_swipe_for_notifications.json
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 0f98a5a..26fbd79 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -926,16 +926,8 @@
<string name="security_settings_fingerprint_enroll_introduction_cancel">Cancel</string>
<!-- Button text to cancel enrollment [CHAR LIMIT=30] -->
<string name="security_settings_fingerprint_enroll_introduction_no_thanks">No thanks</string>
- <!-- Button text to skip enrollment [CHAR LIMIT=30] -->
- <string name="security_settings_fingerprint_enroll_introduction_skip">No thanks</string>
- <!-- Button text to continue to the next screen from the introduction [CHAR LIMIT=22] -->
- <string name="security_settings_fingerprint_enroll_introduction_continue">Continue</string>
<!-- Button text to agree the consent and continue to the next screen from the introduction [CHAR LIMIT=22] -->
<string name="security_settings_fingerprint_enroll_introduction_agree">I agree</string>
- <!-- Button text to cancel enrollment from the introduction (this string variant is used while in setup wizard) [CHAR LIMIT=22] -->
- <string name="security_settings_fingerprint_enroll_introduction_cancel_setup">Skip</string>
- <!-- Button text to continue to the next screen from the introduction (this string variant is used while in setup wizard) [CHAR LIMIT=22] -->
- <string name="security_settings_fingerprint_enroll_introduction_continue_setup">Next</string>
<!-- Title of dialog shown when the user tries to skip setting up fingerprint after adding lock screen during initial setup. [CHAR LIMIT=30] -->
<string name="setup_fingerprint_enroll_skip_title">Skip fingerprint?</string>
<!-- Body text of dialog shown when the user tries to skip setting up fingerprint after adding lock screen during initial setup [CHAR LIMIT=NONE] -->
@@ -13391,7 +13383,7 @@
<string name="mobile_data_no_connection">No connection</string>
<!-- Provider Model:
Summary indicating that a SIM has no mobile data connection [CHAR LIMIT=50] -->
- <string name="mobile_data_off_summary">Internet won\u0027t auto\u2011connect</string>
+ <string name="mobile_data_off_summary">Mobile data won\u0027t auto\u2011connect</string>
<!-- Provider Model: Summary indicating that no other networks available [CHAR LIMIT=50] -->
<string name="non_carrier_network_unavailable">No other networks available</string>
<!-- Provider Model: Summary indicating that no networks available [CHAR LIMIT=50] -->
diff --git a/res/xml/accounts_dashboard_settings.xml b/res/xml/accounts_dashboard_settings.xml
index c8627e7..71bfc18 100644
--- a/res/xml/accounts_dashboard_settings.xml
+++ b/res/xml/accounts_dashboard_settings.xml
@@ -37,7 +37,6 @@
<com.android.settings.widget.GearPreference
android:fragment="com.android.settings.applications.defaultapps.DefaultAutofillPicker"
android:key="default_autofill_main"
- android:title="@string/autofill_app"
settings:keywords="@string/autofill_keywords">
<extra
android:name="for_work"
diff --git a/res/xml/accounts_personal_dashboard_settings.xml b/res/xml/accounts_personal_dashboard_settings.xml
index e0ba71b..b01c235 100644
--- a/res/xml/accounts_personal_dashboard_settings.xml
+++ b/res/xml/accounts_personal_dashboard_settings.xml
@@ -38,7 +38,6 @@
<com.android.settings.widget.GearPreference
android:fragment="com.android.settings.applications.defaultapps.DefaultAutofillPicker"
android:key="default_autofill_main"
- android:title="@string/autofill_app"
settings:keywords="@string/autofill_keywords">
<extra
android:name="for_work"
diff --git a/res/xml/accounts_work_dashboard_settings.xml b/res/xml/accounts_work_dashboard_settings.xml
index 1c4c6aa..c24ea6f 100644
--- a/res/xml/accounts_work_dashboard_settings.xml
+++ b/res/xml/accounts_work_dashboard_settings.xml
@@ -38,7 +38,6 @@
<com.android.settings.widget.GearPreference
android:fragment="com.android.settings.applications.defaultapps.DefaultAutofillPicker"
android:key="default_autofill_work"
- android:title="@string/autofill_app"
settings:searchable="false">
<extra
android:name="for_work"
diff --git a/src/com/android/settings/accessibility/AnimatedImagePreference.java b/src/com/android/settings/accessibility/AnimatedImagePreference.java
deleted file mode 100644
index c707e5c..0000000
--- a/src/com/android/settings/accessibility/AnimatedImagePreference.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- * Copyright (C) 2019 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.settings.accessibility;
-
-import android.content.Context;
-import android.graphics.drawable.Animatable;
-import android.graphics.drawable.Animatable2;
-import android.graphics.drawable.AnimationDrawable;
-import android.graphics.drawable.Drawable;
-import android.net.Uri;
-import android.util.Log;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ImageView;
-
-import androidx.preference.Preference;
-import androidx.preference.PreferenceViewHolder;
-
-import com.android.settings.R;
-
-import com.airbnb.lottie.LottieAnimationView;
-import com.airbnb.lottie.LottieDrawable;
-
-import java.io.FileNotFoundException;
-import java.io.InputStream;
-import java.util.Objects;
-
-/**
- * A custom {@link ImageView} preference for showing animated or static image, such as <a
- * href="https://developers.google.com/speed/webp/">animated webp</a> and static png.
- */
-public class AnimatedImagePreference extends Preference {
-
- private static final String TAG = "AnimatedImagePreference";
- private Uri mImageUri;
- private int mMaxHeight = -1;
-
- private final Animatable2.AnimationCallback mAnimationCallback =
- new Animatable2.AnimationCallback() {
- @Override
- public void onAnimationEnd(Drawable drawable) {
- ((Animatable2) drawable).start();
- }
- };
-
- AnimatedImagePreference(Context context) {
- super(context);
- setLayoutResource(R.layout.preference_animated_image);
- }
-
- @Override
- public void onBindViewHolder(PreferenceViewHolder holder) {
- super.onBindViewHolder(holder);
-
- final ImageView imageView = holder.itemView.findViewById(R.id.animated_img);
- final LottieAnimationView lottieView = holder.itemView.findViewById(R.id.lottie_view);
- if (imageView == null || lottieView == null) {
- return;
- }
-
- if (mImageUri != null) {
- resetAnimations(imageView, lottieView);
- hideAllChildViews(holder.itemView);
-
- imageView.setImageURI(mImageUri);
- if (imageView.getDrawable() != null) {
- startAnimationWith(imageView);
- } else {
- // The lottie image from the raw folder also returns null.
- startLottieAnimationWith(lottieView);
- }
- }
-
- if (mMaxHeight > -1) {
- imageView.setMaxHeight(mMaxHeight);
- lottieView.setMaxHeight(mMaxHeight);
- }
- }
-
- /**
- * Sets image uri to display image in {@link ImageView}
- *
- * @param imageUri the Uri of an image
- */
- public void setImageUri(Uri imageUri) {
- if (imageUri != null && !imageUri.equals(mImageUri)) {
- mImageUri = imageUri;
- notifyChanged();
- }
- }
-
- /**
- * Sets the maximum height of the view.
- *
- * @param maxHeight the maximum height of ImageView in terms of pixels.
- */
- public void setMaxHeight(int maxHeight) {
- if (maxHeight != mMaxHeight) {
- mMaxHeight = maxHeight;
- notifyChanged();
- }
- }
-
- private void startAnimationWith(ImageView imageView) {
- startAnimation(imageView.getDrawable());
-
- imageView.setVisibility(View.VISIBLE);
- }
-
- private void startLottieAnimationWith(LottieAnimationView lottieView) {
- final InputStream inputStream = getInputStreamFromUri(mImageUri);
- Objects.requireNonNull(inputStream, "Invalid resource.");
- lottieView.setAnimation(inputStream, /* cacheKey= */ null);
- lottieView.setRepeatCount(LottieDrawable.INFINITE);
- lottieView.playAnimation();
-
- lottieView.setVisibility(View.VISIBLE);
- }
-
- private void startAnimation(Drawable drawable) {
- if (!(drawable instanceof Animatable)) {
- return;
- }
-
- if (drawable instanceof Animatable2) {
- ((Animatable2) drawable).registerAnimationCallback(mAnimationCallback);
- } else if (drawable instanceof AnimationDrawable) {
- ((AnimationDrawable) drawable).setOneShot(false);
- }
-
- ((Animatable) drawable).start();
- }
-
- private void resetAnimations(ImageView imageView, LottieAnimationView lottieView) {
- resetAnimation(imageView.getDrawable());
-
- lottieView.cancelAnimation();
- }
-
- private void resetAnimation(Drawable drawable) {
- if (!(drawable instanceof Animatable)) {
- return;
- }
-
- if (drawable instanceof Animatable2) {
- ((Animatable2) drawable).clearAnimationCallbacks();
- }
-
- ((Animatable) drawable).stop();
- }
-
- private InputStream getInputStreamFromUri(Uri uri) {
- try {
- return getContext().getContentResolver().openInputStream(uri);
- } catch (FileNotFoundException e) {
- Log.w(TAG, "Cannot find content uri: " + uri, e);
- return null;
- }
- }
-
- private void hideAllChildViews(View itemView) {
- final ViewGroup viewGroup = (ViewGroup) itemView;
- for (int i = 0; i < viewGroup.getChildCount(); i++) {
- viewGroup.getChildAt(i).setVisibility(View.GONE);
- }
- }
-}
diff --git a/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java b/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java
index 640ae53..510f8d3 100644
--- a/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java
@@ -59,6 +59,7 @@
import com.android.settings.widget.SettingsMainSwitchPreference;
import com.android.settingslib.HelpUtils;
import com.android.settingslib.accessibility.AccessibilityUtils;
+import com.android.settingslib.widget.IllustrationPreference;
import com.android.settingslib.widget.OnMainSwitchChangeListener;
import com.google.android.setupcompat.util.WizardManagerHelper;
@@ -398,15 +399,13 @@
return;
}
- final int screenHalfHeight = AccessibilityUtil.getScreenHeightPixels(getPrefContext()) / 2;
- final AnimatedImagePreference animatedImagePreference =
- new AnimatedImagePreference(getPrefContext());
- animatedImagePreference.setImageUri(mImageUri);
- animatedImagePreference.setSelectable(false);
- animatedImagePreference.setMaxHeight(screenHalfHeight);
- animatedImagePreference.setKey(KEY_ANIMATED_IMAGE);
+ final IllustrationPreference illustrationPreference =
+ new IllustrationPreference(getPrefContext());
+ illustrationPreference.setImageUri(mImageUri);
+ illustrationPreference.setSelectable(false);
+ illustrationPreference.setKey(KEY_ANIMATED_IMAGE);
- getPreferenceScreen().addPreference(animatedImagePreference);
+ getPreferenceScreen().addPreference(illustrationPreference);
}
private void initToggleServiceSwitchPreference() {
diff --git a/src/com/android/settings/applications/defaultapps/DefaultAppPreferenceController.java b/src/com/android/settings/applications/defaultapps/DefaultAppPreferenceController.java
index fd6f4c2..d962692 100644
--- a/src/com/android/settings/applications/defaultapps/DefaultAppPreferenceController.java
+++ b/src/com/android/settings/applications/defaultapps/DefaultAppPreferenceController.java
@@ -65,11 +65,19 @@
((TwoTargetPreference) preference).setIconSize(ICON_SIZE_MEDIUM);
}
if (!TextUtils.isEmpty(defaultAppLabel)) {
- preference.setSummary(defaultAppLabel);
+ if (showLabelAsTitle()) {
+ preference.setTitle(defaultAppLabel);
+ } else {
+ preference.setSummary(defaultAppLabel);
+ }
preference.setIcon(Utils.getSafeIcon(getDefaultAppIcon()));
} else {
Log.d(TAG, "No default app");
- preference.setSummary(R.string.app_list_preference_none);
+ if (showLabelAsTitle()) {
+ preference.setTitle(R.string.app_list_preference_none);
+ } else {
+ preference.setSummary(R.string.app_list_preference_none);
+ }
preference.setIcon(null);
}
mayUpdateGearIcon(app, preference);
@@ -102,6 +110,13 @@
return null;
}
+ /**
+ * Whether to show the default app label as the title, instead of as the summary.
+ */
+ protected boolean showLabelAsTitle() {
+ return false;
+ }
+
public Drawable getDefaultAppIcon() {
if (!isAvailable()) {
return null;
diff --git a/src/com/android/settings/applications/defaultapps/DefaultAutofillPreferenceController.java b/src/com/android/settings/applications/defaultapps/DefaultAutofillPreferenceController.java
index d32322b..1493e30 100644
--- a/src/com/android/settings/applications/defaultapps/DefaultAutofillPreferenceController.java
+++ b/src/com/android/settings/applications/defaultapps/DefaultAutofillPreferenceController.java
@@ -69,4 +69,9 @@
}
return null;
}
+
+ @Override
+ protected boolean showLabelAsTitle() {
+ return true;
+ }
}
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollIntroduction.java b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollIntroduction.java
index 8c3b1ce..a75fb0f 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollIntroduction.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollIntroduction.java
@@ -64,9 +64,13 @@
super.onCreate(savedInstanceState);
final ImageView iconFingerprint = findViewById(R.id.icon_fingerprint);
+ final ImageView iconDeviceLocked = findViewById(R.id.icon_device_locked);
+ final ImageView iconTrashCan = findViewById(R.id.icon_trash_can);
final ImageView iconInfo = findViewById(R.id.icon_info);
final ImageView iconLink = findViewById(R.id.icon_link);
iconFingerprint.getDrawable().setColorFilter(getIconColorFilter());
+ iconDeviceLocked.getDrawable().setColorFilter(getIconColorFilter());
+ iconTrashCan.getDrawable().setColorFilter(getIconColorFilter());
iconInfo.getDrawable().setColorFilter(getIconColorFilter());
iconLink.getDrawable().setColorFilter(getIconColorFilter());
@@ -87,7 +91,7 @@
@StringRes
int getNegativeButtonTextId() {
- return R.string.security_settings_fingerprint_enroll_introduction_skip;
+ return R.string.security_settings_fingerprint_enroll_introduction_no_thanks;
}
@StringRes
diff --git a/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollIntroduction.java b/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollIntroduction.java
index e105911..4bd8afd 100644
--- a/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollIntroduction.java
+++ b/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollIntroduction.java
@@ -26,7 +26,6 @@
import android.view.View;
import com.android.internal.widget.LockPatternUtils;
-import com.android.settings.R;
import com.android.settings.SetupWizardUtils;
import com.android.settings.Utils;
import com.android.settings.biometrics.BiometricUtils;
@@ -34,8 +33,6 @@
import com.android.settings.password.SetupChooseLockGeneric;
import com.android.settings.password.SetupSkipDialog;
-import com.google.android.setupcompat.template.FooterButton;
-
public class SetupFingerprintEnrollIntroduction extends FingerprintEnrollIntroduction {
/**
* Returns the number of fingerprint enrolled.
@@ -57,11 +54,6 @@
}
@Override
- int getNegativeButtonTextId() {
- return R.string.security_settings_face_enroll_introduction_cancel;
- }
-
- @Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putBoolean(KEY_LOCK_SCREEN_PRESENT, mAlreadyHadLockScreenSetup);
@@ -79,19 +71,6 @@
}
@Override
- protected void initViews() {
- super.initViews();
-
- FooterButton nextButton = getNextButton();
- nextButton.setText(
- this, R.string.security_settings_fingerprint_enroll_introduction_continue_setup);
-
- final FooterButton cancelButton = getCancelButton();
- cancelButton.setText(
- this, R.string.security_settings_fingerprint_enroll_introduction_cancel_setup);
- }
-
- @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// if lock was already present, do not return intent data since it must have been
// reported in previous attempts
diff --git a/src/com/android/settings/enterprise/ActionDisabledByAdminDialogHelper.java b/src/com/android/settings/enterprise/ActionDisabledByAdminDialogHelper.java
index ccc7436..f898ab2 100644
--- a/src/com/android/settings/enterprise/ActionDisabledByAdminDialogHelper.java
+++ b/src/com/android/settings/enterprise/ActionDisabledByAdminDialogHelper.java
@@ -65,7 +65,8 @@
R.layout.admin_support_details_dialog, null);
mActionDisabledByAdminController = ActionDisabledByAdminControllerFactory
.createInstance(mActivity, restriction,
- new DeviceAdminStringProviderImpl(mActivity));
+ new DeviceAdminStringProviderImpl(mActivity),
+ UserHandle.SYSTEM);
}
private @UserIdInt int getEnforcementAdminUserId(@NonNull EnforcedAdmin admin) {
diff --git a/src/com/android/settings/gestures/OneHandedSettings.java b/src/com/android/settings/gestures/OneHandedSettings.java
index 6d1cbfd..51c6b66 100644
--- a/src/com/android/settings/gestures/OneHandedSettings.java
+++ b/src/com/android/settings/gestures/OneHandedSettings.java
@@ -16,19 +16,18 @@
package com.android.settings.gestures;
+import android.app.Activity;
import android.app.settings.SettingsEnums;
import android.content.ComponentName;
import android.content.Context;
import android.os.Bundle;
import android.os.UserHandle;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
import com.android.internal.accessibility.AccessibilityShortcutController;
import com.android.settings.R;
import com.android.settings.accessibility.AccessibilityShortcutPreferenceFragment;
import com.android.settings.search.BaseSearchIndexProvider;
+import com.android.settingslib.widget.IllustrationPreference;
/**
* Fragment for One-handed mode settings
@@ -37,13 +36,27 @@
* providing basic accessibility shortcut service setup.
*/
public class OneHandedSettings extends AccessibilityShortcutPreferenceFragment {
+
private static final String ONE_HANDED_SHORTCUT_KEY = "one_handed_shortcuts_preference";
+ private static final String ONE_HANDED_ILLUSTRATION_KEY = "one_handed_header";
private String mFeatureName;
+ private OneHandedSettingsUtils mUtils;
@Override
protected void updatePreferenceStates() {
OneHandedSettingsUtils.setUserId(UserHandle.myUserId());
super.updatePreferenceStates();
+
+ final IllustrationPreference preference =
+ (IllustrationPreference) getPreferenceScreen().findPreference(
+ ONE_HANDED_ILLUSTRATION_KEY);
+ if (preference != null) {
+ final boolean isSwipeDownNotification =
+ OneHandedSettingsUtils.isSwipeDownNotificationEnabled(getContext());
+ preference.setLottieAnimationResId(
+ isSwipeDownNotification ? R.raw.lottie_swipe_for_notifications
+ : R.raw.lottie_one_hand_mode);
+ }
}
@Override
@@ -69,9 +82,21 @@
}
@Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- return super.onCreateView(inflater, container, savedInstanceState);
+ public void onStart() {
+ super.onStart();
+ mUtils = new OneHandedSettingsUtils(this.getContext());
+ mUtils.registerToggleAwareObserver(uri -> {
+ Activity activity = getActivity();
+ if (activity != null) {
+ activity.runOnUiThread(() -> updatePreferenceStates());
+ }
+ });
+ }
+
+ @Override
+ public void onStop() {
+ super.onStop();
+ mUtils.unregisterToggleAwareObserver();
}
@Override
diff --git a/tests/robotests/src/com/android/settings/accessibility/AnimatedImagePreferenceTest.java b/tests/robotests/src/com/android/settings/accessibility/AnimatedImagePreferenceTest.java
deleted file mode 100644
index c7e5b13..0000000
--- a/tests/robotests/src/com/android/settings/accessibility/AnimatedImagePreferenceTest.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Copyright (C) 2020 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.settings.accessibility;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.verify;
-
-import android.content.ContentResolver;
-import android.content.Context;
-import android.graphics.drawable.AnimatedImageDrawable;
-import android.graphics.drawable.AnimatedVectorDrawable;
-import android.graphics.drawable.AnimationDrawable;
-import android.net.Uri;
-import android.view.ViewGroup;
-import android.widget.ImageView;
-
-import androidx.preference.PreferenceViewHolder;
-
-import com.android.settings.R;
-
-import com.airbnb.lottie.LottieAnimationView;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.mockito.Spy;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
-
-import java.io.InputStream;
-
-/** Tests for {@link AnimatedImagePreference}. */
-@RunWith(RobolectricTestRunner.class)
-public class AnimatedImagePreferenceTest {
- private final Context mContext = RuntimeEnvironment.application;
- private Uri mImageUri;
- private PreferenceViewHolder mViewHolder;
- private AnimatedImagePreference mAnimatedImagePreference;
-
- @Mock
- private ViewGroup mRootView;
-
- @Spy
- private ImageView mImageView;
-
- @Before
- public void init() {
- MockitoAnnotations.initMocks(this);
-
- mViewHolder = spy(PreferenceViewHolder.createInstanceForTests(mRootView));
- doReturn(new LottieAnimationView(mContext)).when(mRootView).findViewById(R.id.lottie_view);
- mImageView = spy(new ImageView(mContext));
-
- mAnimatedImagePreference = new AnimatedImagePreference(mContext);
- mImageUri = new Uri.Builder().build();
- }
-
- @Test
- public void playAnimation_animatedImageDrawable_success() {
- final AnimatedImageDrawable drawable = mock(AnimatedImageDrawable.class);
- doReturn(mImageView).when(mRootView).findViewById(R.id.animated_img);
- doReturn(drawable).when(mImageView).getDrawable();
-
- mAnimatedImagePreference.setImageUri(mImageUri);
- mAnimatedImagePreference.onBindViewHolder(mViewHolder);
-
- verify(drawable).start();
- }
-
- @Test
- public void playAnimation_animatedVectorDrawable_success() {
- final AnimatedVectorDrawable drawable = mock(AnimatedVectorDrawable.class);
- doReturn(mImageView).when(mRootView).findViewById(R.id.animated_img);
- doReturn(drawable).when(mImageView).getDrawable();
-
- mAnimatedImagePreference.setImageUri(mImageUri);
- mAnimatedImagePreference.onBindViewHolder(mViewHolder);
-
- verify(drawable).start();
- }
-
- @Test
- public void playAnimation_animationDrawable_success() {
- final AnimationDrawable drawable = mock(AnimationDrawable.class);
- doReturn(mImageView).when(mRootView).findViewById(R.id.animated_img);
- doReturn(drawable).when(mImageView).getDrawable();
-
- mAnimatedImagePreference.setImageUri(mImageUri);
- mAnimatedImagePreference.onBindViewHolder(mViewHolder);
-
- verify(drawable).start();
- }
-
- @Test
- public void setImageUri_viewNotExist_setFail() {
- doReturn(null).when(mRootView).findViewById(R.id.animated_img);
-
- mAnimatedImagePreference.setImageUri(mImageUri);
- mAnimatedImagePreference.onBindViewHolder(mViewHolder);
-
- verify(mImageView, never()).setImageURI(mImageUri);
- }
-
- @Test
- public void setMaxHeight_success() {
- final int maxHeight = 100;
- doReturn(mImageView).when(mRootView).findViewById(R.id.animated_img);
-
- mAnimatedImagePreference.setMaxHeight(maxHeight);
- mAnimatedImagePreference.onBindViewHolder(mViewHolder);
-
- assertThat(mImageView.getMaxHeight()).isEqualTo(maxHeight);
- }
-
- @Test
- public void setImageUriAndRebindViewHolder_lottieImageFromRawFolder_setAnimation() {
- final int fakeLottieResId = 111111;
- final Uri lottieImageUri =
- new Uri.Builder().scheme(ContentResolver.SCHEME_ANDROID_RESOURCE)
- .authority(mContext.getPackageName())
- .appendPath(String.valueOf(fakeLottieResId))
- .build();
- final LottieAnimationView lottieView = spy(new LottieAnimationView(mContext));
- doReturn(mImageView).when(mRootView).findViewById(R.id.animated_img);
- doReturn(lottieView).when(mRootView).findViewById(R.id.lottie_view);
-
- mAnimatedImagePreference.setImageUri(lottieImageUri);
- mAnimatedImagePreference.onBindViewHolder(mViewHolder);
-
- verify(lottieView).setAnimation(any(InputStream.class), eq(null));
- }
-}
diff --git a/tests/unit/src/com/android/settings/enterprise/ActionDisabledLearnMoreButtonLauncherImplTest.java b/tests/unit/src/com/android/settings/enterprise/ActionDisabledLearnMoreButtonLauncherImplTest.java
index 4f7ecc8..0b0b8e5 100644
--- a/tests/unit/src/com/android/settings/enterprise/ActionDisabledLearnMoreButtonLauncherImplTest.java
+++ b/tests/unit/src/com/android/settings/enterprise/ActionDisabledLearnMoreButtonLauncherImplTest.java
@@ -111,7 +111,7 @@
@Test
public void showHelpPage_works() {
- mImpl.showHelpPage(mActivity, URL);
+ mImpl.showHelpPage(mActivity, URL, CONTEXT_USER);
verify(mActivity).startActivityAsUser(mIntentCaptor.capture(), eq(CONTEXT_USER));
assertActionViewIntent(mIntentCaptor.getValue());