Add battery illustration
Also update the VideoPreference to handle the full screen illustration by adding attr isFullWidth and aspectRadio. Change-Id: If2ccba4ce792801c6fd79b7c60af4e3826c091cc Fixes: 74409022 Test: Screenshot | RunSettingsRoboTests
This commit is contained in:
@@ -22,6 +22,7 @@ import android.content.res.TypedArray;
|
||||
import android.graphics.SurfaceTexture;
|
||||
import android.media.MediaPlayer;
|
||||
import android.net.Uri;
|
||||
import android.support.annotation.VisibleForTesting;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceViewHolder;
|
||||
import android.util.AttributeSet;
|
||||
@@ -42,10 +43,13 @@ public class VideoPreference extends Preference {
|
||||
private final Context mContext;
|
||||
|
||||
private Uri mVideoPath;
|
||||
private MediaPlayer mMediaPlayer;
|
||||
private boolean mAnimationAvailable;
|
||||
@VisibleForTesting
|
||||
MediaPlayer mMediaPlayer;
|
||||
@VisibleForTesting
|
||||
boolean mAnimationAvailable;
|
||||
private boolean mVideoReady;
|
||||
private boolean mVideoPaused;
|
||||
private float mAspectRadio = 1.0f;
|
||||
private int mPreviewResource;
|
||||
|
||||
public VideoPreference(Context context, AttributeSet attrs) {
|
||||
@@ -73,6 +77,7 @@ public class VideoPreference extends Preference {
|
||||
|
||||
mMediaPlayer.setOnPreparedListener(mediaPlayer -> mediaPlayer.setLooping(true));
|
||||
mAnimationAvailable = true;
|
||||
updateAspectRatio();
|
||||
} else {
|
||||
setVisible(false);
|
||||
}
|
||||
@@ -94,7 +99,11 @@ public class VideoPreference extends Preference {
|
||||
final TextureView video = (TextureView) holder.findViewById(R.id.video_texture_view);
|
||||
final ImageView imageView = (ImageView) holder.findViewById(R.id.video_preview_image);
|
||||
final ImageView playButton = (ImageView) holder.findViewById(R.id.video_play_button);
|
||||
final AspectRatioFrameLayout layout = (AspectRatioFrameLayout) holder.findViewById(
|
||||
R.id.video_container);
|
||||
|
||||
imageView.setImageResource(mPreviewResource);
|
||||
layout.setAspectRatio(mAspectRadio);
|
||||
|
||||
video.setOnClickListener(v -> {
|
||||
if (mMediaPlayer != null) {
|
||||
@@ -178,4 +187,9 @@ public class VideoPreference extends Preference {
|
||||
return mVideoPaused;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void updateAspectRatio() {
|
||||
mAspectRadio = mMediaPlayer.getVideoWidth() / (float)mMediaPlayer.getVideoHeight();
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user