Add setBackgroundColor() in VideoPreference

- Add setBackgroundColor() to allow changed background
  color of VideoPreference.
- Add test case.

Bug: 149974597
Test: make -j42 RunSettingsRoboTests
Change-Id: I14f849d54657dc0ccbd599c393de6f430e9352d4
This commit is contained in:
hughchen
2020-02-27 14:16:11 +08:00
parent 4d59bce21b
commit 507218b577
2 changed files with 30 additions and 0 deletions

View File

@@ -39,12 +39,18 @@ import com.android.settings.R;
public class VideoPreference extends Preference {
private static final String TAG = "VideoPreference";
private static final int DEFAULT_BACKGROUND_RESOURCE_ID = -1;
private final Context mContext;
@VisibleForTesting
AnimationController mAnimationController;
@VisibleForTesting
boolean mAnimationAvailable;
@VisibleForTesting
LinearLayout mAnimationView;
@VisibleForTesting
int mBackgroundResId = DEFAULT_BACKGROUND_RESOURCE_ID;
private float mAspectRatio = 1.0f;
private int mPreviewId;
private int mAnimationId;
@@ -114,6 +120,7 @@ public class VideoPreference extends Preference {
mVideo = (TextureView) holder.findViewById(R.id.video_texture_view);
mPreviewImage = (ImageView) holder.findViewById(R.id.video_preview_image);
mPlayButton = (ImageView) holder.findViewById(R.id.video_play_button);
mAnimationView = (LinearLayout) holder.itemView;
final AspectRatioFrameLayout layout = (AspectRatioFrameLayout) holder.findViewById(
R.id.video_container);
@@ -123,6 +130,9 @@ public class VideoPreference extends Preference {
layout.setLayoutParams(new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT, mHeight));
}
if (mBackgroundResId != DEFAULT_BACKGROUND_RESOURCE_ID) {
mAnimationView.setBackgroundResource(mBackgroundResId);
}
if (mAnimationController != null) {
mAnimationController.attachView(mVideo, mPreviewImage, mPlayButton);
}
@@ -202,6 +212,14 @@ public class VideoPreference extends Preference {
/ (float) mAnimationController.getVideoHeight();
}
/**
* Set the background color of the video preference
* @param resId resource id of color
*/
public void setBackgroundColor(int resId) {
mBackgroundResId = resId;
}
/**
* Handle animation operations.
*/