Remove the pause icon from IllustrationPreference.
Fix: 189426848 Test: robotest and test the IllustrationPreference manually. Change-Id: I6087adb99e6b23642d952165073e4e3468397dab
This commit is contained in:
@@ -1,24 +0,0 @@
|
||||
<!--
|
||||
Copyright (C) 2021 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.
|
||||
-->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="48.0"
|
||||
android:viewportHeight="48.0">
|
||||
<path android:fillColor="#FFFFFF" android:pathData="M24,24m-19,0a19,19 0,1 1,38 0a19,19 0,1 1,-38 0"/>
|
||||
<path android:fillColor="#1A73E8" android:pathData="M20,33l12,-9l-12,-9z"/>
|
||||
<path android:fillColor="#1A73E8" android:pathData="M24,4C12.96,4 4,12.96 4,24s8.96,20 20,20s20,-8.96 20,-20S35.04,4 24,4zM24,40c-8.82,0 -16,-7.18 -16,-16S15.18,8 24,8s16,7.18 16,16S32.82,40 24,40z"/>
|
||||
</vector>
|
||||
@@ -50,14 +50,5 @@
|
||||
android:background="@android:color/transparent"
|
||||
android:layout_gravity="center"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/video_play_button"
|
||||
android:layout_width="36dp"
|
||||
android:layout_height="36dp"
|
||||
android:layout_gravity="center"
|
||||
android:visibility="gone"
|
||||
android:src="@drawable/ic_gesture_play_button"/>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
|
||||
@@ -18,8 +18,6 @@ package com.android.settingslib.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
@@ -28,7 +26,6 @@ import android.widget.ImageView;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.Preference.OnPreferenceClickListener;
|
||||
import androidx.preference.PreferenceViewHolder;
|
||||
|
||||
import com.airbnb.lottie.LottieAnimationView;
|
||||
@@ -36,14 +33,12 @@ import com.airbnb.lottie.LottieAnimationView;
|
||||
/**
|
||||
* IllustrationPreference is a preference that can play lottie format animation
|
||||
*/
|
||||
public class IllustrationPreference extends Preference implements OnPreferenceClickListener {
|
||||
public class IllustrationPreference extends Preference {
|
||||
|
||||
static final String TAG = "IllustrationPreference";
|
||||
|
||||
private int mAnimationId;
|
||||
private boolean mIsAnimating;
|
||||
private boolean mIsAutoScale;
|
||||
private ImageView mPlayButton;
|
||||
private LottieAnimationView mIllustrationView;
|
||||
private View mMiddleGroundView;
|
||||
private FrameLayout mMiddleGroundLayout;
|
||||
@@ -72,13 +67,11 @@ public class IllustrationPreference extends Preference implements OnPreferenceCl
|
||||
return;
|
||||
}
|
||||
mMiddleGroundLayout = (FrameLayout) holder.findViewById(R.id.middleground_layout);
|
||||
mPlayButton = (ImageView) holder.findViewById(R.id.video_play_button);
|
||||
mIllustrationView = (LottieAnimationView) holder.findViewById(R.id.lottie_view);
|
||||
mIllustrationView.setAnimation(mAnimationId);
|
||||
mIllustrationView.loop(true);
|
||||
ColorUtils.applyDynamicColors(getContext(), mIllustrationView);
|
||||
mIllustrationView.playAnimation();
|
||||
updateAnimationStatus(mIsAnimating);
|
||||
if (mIsAutoScale) {
|
||||
enableAnimationAutoScale(mIsAutoScale);
|
||||
}
|
||||
@@ -87,28 +80,6 @@ public class IllustrationPreference extends Preference implements OnPreferenceCl
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
mIsAnimating = !isAnimating();
|
||||
updateAnimationStatus(mIsAnimating);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Parcelable onSaveInstanceState() {
|
||||
Parcelable superState = super.onSaveInstanceState();
|
||||
SavedState ss = new SavedState(superState);
|
||||
ss.mIsAnimating = mIsAnimating;
|
||||
return ss;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRestoreInstanceState(Parcelable state) {
|
||||
SavedState ss = (SavedState) state;
|
||||
super.onRestoreInstanceState(ss.getSuperState());
|
||||
mIsAnimating = ss.mIsAnimating;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
boolean isAnimating() {
|
||||
return mIllustrationView.isAnimating();
|
||||
@@ -158,7 +129,6 @@ public class IllustrationPreference extends Preference implements OnPreferenceCl
|
||||
private void init(Context context, AttributeSet attrs) {
|
||||
setLayoutResource(R.layout.illustration_preference);
|
||||
|
||||
mIsAnimating = true;
|
||||
mIsAutoScale = false;
|
||||
if (attrs != null) {
|
||||
final TypedArray a = context.obtainStyledAttributes(attrs,
|
||||
@@ -166,56 +136,5 @@ public class IllustrationPreference extends Preference implements OnPreferenceCl
|
||||
mAnimationId = a.getResourceId(R.styleable.LottieAnimationView_lottie_rawRes, 0);
|
||||
a.recycle();
|
||||
}
|
||||
setOnPreferenceClickListener(this);
|
||||
}
|
||||
|
||||
private void updateAnimationStatus(boolean playAnimation) {
|
||||
if (playAnimation) {
|
||||
mIllustrationView.resumeAnimation();
|
||||
mPlayButton.setVisibility(View.INVISIBLE);
|
||||
} else {
|
||||
mIllustrationView.pauseAnimation();
|
||||
mPlayButton.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
static class SavedState extends BaseSavedState {
|
||||
boolean mIsAnimating;
|
||||
|
||||
SavedState(Parcelable superState) {
|
||||
super(superState);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor called from {@link #CREATOR}
|
||||
*/
|
||||
private SavedState(Parcel in) {
|
||||
super(in);
|
||||
mIsAnimating = (Boolean) in.readValue(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel out, int flags) {
|
||||
super.writeToParcel(out, flags);
|
||||
out.writeValue(mIsAnimating);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "IllustrationPreference.SavedState{"
|
||||
+ Integer.toHexString(System.identityHashCode(this))
|
||||
+ " mIsAnimating=" + mIsAnimating + "}";
|
||||
}
|
||||
|
||||
public static final Parcelable.Creator<SavedState> CREATOR =
|
||||
new Parcelable.Creator<SavedState>() {
|
||||
public SavedState createFromParcel(Parcel in) {
|
||||
return new SavedState(in);
|
||||
}
|
||||
|
||||
public SavedState[] newArray(int size) {
|
||||
return new SavedState[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,6 @@ package com.android.settingslib.widget;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
@@ -56,20 +54,6 @@ public class IllustrationPreferenceTest {
|
||||
ReflectionHelpers.setField(mPreference, "mIllustrationView", mAnimationView);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isAnimating_lottieAnimationViewIsNotAnimating_shouldReturnFalse() {
|
||||
when(mAnimationView.isAnimating()).thenReturn(false);
|
||||
|
||||
assertThat(mPreference.isAnimating()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isAnimating_lottieAnimationViewIsAnimating_shouldReturnTrue() {
|
||||
when(mAnimationView.isAnimating()).thenReturn(true);
|
||||
|
||||
assertThat(mPreference.isAnimating()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setMiddleGroundView_middleGroundView_shouldVisible() {
|
||||
final View view = new View(mContext);
|
||||
|
||||
Reference in New Issue
Block a user