summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2019-05-07 21:49:05 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2019-05-07 21:49:05 +0000
commit873b8bd87cdd8bf43f01e06639937362436d41e1 (patch)
treee5335b9a7a289d09ccdea3780cc8d6e2414c9ae0
parenta4e4cb9bf3759b5b99bee579497a5ec8e9820b59 (diff)
parent1d64a3d08fa77af4c065bbe4135403c17275e607 (diff)
downloadsetupwizard-873b8bd87cdd8bf43f01e06639937362436d41e1.tar.gz
Snap for 5450365 from 1d64a3d08fa77af4c065bbe4135403c17275e607 to pi-platform-releasepie-platform-release
Change-Id: I1fb7dcaa3e5603f2d32dda3ca944cd2a7bbdc3d4
-rw-r--r--library/main/res/values-en-rXC/strings.xml6
-rw-r--r--library/main/res/values-hi/strings.xml2
-rw-r--r--library/main/res/values-mr/strings.xml2
-rw-r--r--library/main/src/com/android/setupwizardlib/view/IllustrationVideoView.java55
-rw-r--r--library/test/robotest/src/com/android/setupwizardlib/view/IllustrationVideoViewTest.java28
-rw-r--r--navigationbar/res/values-en-rXC/strings.xml4
-rw-r--r--navigationbar/res/values-fi/strings.xml2
7 files changed, 87 insertions, 12 deletions
diff --git a/library/main/res/values-en-rXC/strings.xml b/library/main/res/values-en-rXC/strings.xml
index 693af6b..7a7836b 100644
--- a/library/main/res/values-en-rXC/strings.xml
+++ b/library/main/res/values-en-rXC/strings.xml
@@ -17,7 +17,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="suw_next_button_label" msgid="7269625133873553978">"‎‏‎‎‎‎‎‏‎‏‏‏‎‎‎‎‎‏‎‎‏‎‎‎‏‏‏‏‏‏‏‏‏‏‎‎‏‎‎‏‏‏‎‎‎‏‎‏‏‏‎‎‏‎‏‏‎‎‎‏‎‏‏‎‎‎‎‏‎‏‎‏‏‎‎‏‎‎‎‏‏‏‎‎‎‏‎‎‎‏‏‏‎‏‎‎Next‎‏‎‎‏‎"</string>
- <string name="suw_back_button_label" msgid="1460929053642711025">"‎‏‎‎‎‎‎‏‎‏‏‏‎‎‎‎‎‏‎‎‏‎‎‎‏‏‏‏‏‏‎‏‏‎‏‎‎‎‏‎‎‎‏‏‎‎‏‎‎‎‎‏‏‎‎‏‏‏‎‏‏‏‏‏‎‎‏‎‎‎‏‏‎‏‎‏‏‏‏‎‏‏‏‏‏‏‏‏‏‎‎‎‏‎Back‎‏‎‎‏‎"</string>
- <string name="suw_more_button_label" msgid="7769076059705546563">"‎‏‎‎‎‎‎‏‎‏‏‏‎‎‎‎‎‏‎‎‏‎‎‎‏‏‏‏‏‏‏‏‏‏‎‏‎‏‏‏‏‎‏‎‎‎‏‎‏‎‎‏‏‎‏‏‎‎‎‎‎‏‏‏‎‎‏‎‎‏‏‏‎‏‏‏‏‎‏‏‎‎‏‎‏‏‏‎‏‎‎‎‎‏‏‎More‎‏‎‎‏‎"</string>
+ <string name="suw_next_button_label" msgid="7269625133873553978">"‎‏‎‎‎‎‎‏‎‏‏‏‎‎‎‎‎‎‏‎‎‏‎‎‎‏‏‏‏‏‏‏‏‏‏‎‎‏‎‎‏‏‏‎‎‎‏‎‏‏‏‎‎‏‎‏‏‎‎‎‏‎‏‏‎‎‎‎‏‎‏‎‏‏‎‎‏‎‎‎‏‏‏‎‎‎‏‎‎‎‏‏‏‎‏‎‎Next‎‏‎‎‏‎"</string>
+ <string name="suw_back_button_label" msgid="1460929053642711025">"‎‏‎‎‎‎‎‏‎‏‏‏‎‎‎‎‎‎‏‎‎‏‎‎‎‏‏‏‏‏‏‎‏‏‎‏‎‎‎‏‎‎‎‏‏‎‎‏‎‎‎‎‏‏‎‎‏‏‏‎‏‏‏‏‏‎‎‏‎‎‎‏‏‎‏‎‏‏‏‏‎‏‏‏‏‏‏‏‏‏‎‎‎‏‎Back‎‏‎‎‏‎"</string>
+ <string name="suw_more_button_label" msgid="7769076059705546563">"‎‏‎‎‎‎‎‏‎‏‏‏‎‎‎‎‎‎‏‎‎‏‎‎‎‏‏‏‏‏‏‏‏‏‏‎‏‎‏‏‏‏‎‏‎‎‎‏‎‏‎‎‏‏‎‏‏‎‎‎‎‎‏‏‏‎‎‏‎‎‏‏‏‎‏‏‏‏‎‏‏‎‎‏‎‏‏‏‎‏‎‎‎‎‏‏‎More‎‏‎‎‏‎"</string>
</resources>
diff --git a/library/main/res/values-hi/strings.xml b/library/main/res/values-hi/strings.xml
index 3fb41d3..ec2cd77 100644
--- a/library/main/res/values-hi/strings.xml
+++ b/library/main/res/values-hi/strings.xml
@@ -19,5 +19,5 @@
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="suw_next_button_label" msgid="7269625133873553978">"आगे बढ़ें"</string>
<string name="suw_back_button_label" msgid="1460929053642711025">"पीछे"</string>
- <string name="suw_more_button_label" msgid="7769076059705546563">"अधिक"</string>
+ <string name="suw_more_button_label" msgid="7769076059705546563">"ज़्यादा"</string>
</resources>
diff --git a/library/main/res/values-mr/strings.xml b/library/main/res/values-mr/strings.xml
index a529655..5c5b6c2 100644
--- a/library/main/res/values-mr/strings.xml
+++ b/library/main/res/values-mr/strings.xml
@@ -17,7 +17,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="suw_next_button_label" msgid="7269625133873553978">"पुढील"</string>
+ <string name="suw_next_button_label" msgid="7269625133873553978">"पुढे जा"</string>
<string name="suw_back_button_label" msgid="1460929053642711025">"मागे"</string>
<string name="suw_more_button_label" msgid="7769076059705546563">"अधिक"</string>
</resources>
diff --git a/library/main/src/com/android/setupwizardlib/view/IllustrationVideoView.java b/library/main/src/com/android/setupwizardlib/view/IllustrationVideoView.java
index e5c2fb1..fd1e176 100644
--- a/library/main/src/com/android/setupwizardlib/view/IllustrationVideoView.java
+++ b/library/main/src/com/android/setupwizardlib/view/IllustrationVideoView.java
@@ -64,6 +64,8 @@ public class IllustrationVideoView extends TextureView implements Animatable,
@VisibleForTesting Surface mSurface;
+ protected int mWindowVisibility;
+
public IllustrationVideoView(Context context, AttributeSet attrs) {
super(context, attrs);
final TypedArray a = context.obtainStyledAttributes(attrs,
@@ -124,7 +126,7 @@ public class IllustrationVideoView extends TextureView implements Animatable,
* Creates a media player for the current URI. The media player will be started immediately if
* the view's window is visible. If there is an existing media player, it will be released.
*/
- private void createMediaPlayer() {
+ protected void createMediaPlayer() {
if (mMediaPlayer != null) {
mMediaPlayer.release();
}
@@ -149,11 +151,35 @@ public class IllustrationVideoView extends TextureView implements Animatable,
} else {
Log.wtf(TAG, "Unable to initialize media player for video view");
}
- if (getWindowVisibility() == View.VISIBLE) {
+ if (mWindowVisibility == View.VISIBLE) {
start();
}
}
+ protected void createSurface() {
+ if (mSurface != null) {
+ mSurface.release();
+ mSurface = null;
+ }
+ // Reattach only if it has been previously released
+ SurfaceTexture surfaceTexture = getSurfaceTexture();
+ if (surfaceTexture != null) {
+ setVisibility(View.INVISIBLE);
+ mSurface = new Surface(surfaceTexture);
+ }
+ }
+
+ @Override
+ protected void onWindowVisibilityChanged(int visibility) {
+ super.onWindowVisibilityChanged(visibility);
+ mWindowVisibility = visibility;
+ if (visibility == View.VISIBLE) {
+ reattach();
+ } else {
+ release();
+ }
+ }
+
/**
* Whether the media player should play the video in a continuous loop. The default value is
* true.
@@ -178,14 +204,34 @@ public class IllustrationVideoView extends TextureView implements Animatable,
}
}
+ private void reattach() {
+ if (mSurface == null) {
+ initVideo();
+ }
+ }
+
+ private void initVideo() {
+ if (mWindowVisibility != View.VISIBLE) {
+ return;
+ }
+ createSurface();
+ if (mSurface != null) {
+ createMediaPlayer();
+ } else {
+ Log.w("IllustrationVideoView", "Surface creation failed");
+ }
+ }
+
+ protected void onRenderingStart() {
+ }
+
/* SurfaceTextureListener methods */
@Override
public void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture, int width, int height) {
// Keep the view hidden until video starts
setVisibility(View.INVISIBLE);
- mSurface = new Surface(surfaceTexture);
- createMediaPlayer();
+ initVideo();
}
@Override
@@ -230,6 +276,7 @@ public class IllustrationVideoView extends TextureView implements Animatable,
if (what == MediaPlayer.MEDIA_INFO_VIDEO_RENDERING_START) {
// Video available, show view now
setVisibility(View.VISIBLE);
+ onRenderingStart();
}
return false;
}
diff --git a/library/test/robotest/src/com/android/setupwizardlib/view/IllustrationVideoViewTest.java b/library/test/robotest/src/com/android/setupwizardlib/view/IllustrationVideoViewTest.java
index 21822a4..a501506 100644
--- a/library/test/robotest/src/com/android/setupwizardlib/view/IllustrationVideoViewTest.java
+++ b/library/test/robotest/src/com/android/setupwizardlib/view/IllustrationVideoViewTest.java
@@ -16,6 +16,8 @@
package com.android.setupwizardlib.view;
+import static com.google.common.truth.Truth.assertThat;
+
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
@@ -31,6 +33,7 @@ import android.media.MediaPlayer;
import android.os.Build.VERSION_CODES;
import android.support.annotation.RawRes;
import android.view.Surface;
+import android.view.View;
import com.android.setupwizardlib.R;
import com.android.setupwizardlib.robolectric.SuwLibRobolectricTestRunner;
@@ -91,6 +94,30 @@ public class IllustrationVideoViewTest {
}
@Test
+ public void onVisibilityChanged_notVisible_shouldRelease() {
+ createDefaultView();
+ mView.onWindowVisibilityChanged(View.GONE);
+
+ verify(ShadowMockMediaPlayer.sMediaPlayer).release();
+ assertThat(mView.mSurface).isNull();
+ assertThat(mView.mMediaPlayer).isNull();
+ }
+
+ @Test
+ public void onVisibilityChanged_visible_shouldPlay() {
+ createDefaultView();
+
+ mView.onWindowVisibilityChanged(View.GONE);
+ assertThat(mView.mSurface).isNull();
+ assertThat(mView.mMediaPlayer).isNull();
+
+ mView.onWindowVisibilityChanged(View.VISIBLE);
+
+ assertThat(mView.mSurface).isNotNull();
+ assertThat(mView.mMediaPlayer).isNotNull();
+ }
+
+ @Test
public void testPausedWhenWindowFocusLost() {
createDefaultView();
mView.start();
@@ -148,6 +175,7 @@ public class IllustrationVideoViewTest {
// Any resource attribute should work, since the media player is mocked
.addAttribute(R.attr.suwVideo, "@android:color/white")
.build());
+ mView.setSurfaceTexture(mock(SurfaceTexture.class));
mView.onSurfaceTextureAvailable(mSurfaceTexture, 500, 500);
}
diff --git a/navigationbar/res/values-en-rXC/strings.xml b/navigationbar/res/values-en-rXC/strings.xml
index 5c7c658..8107182 100644
--- a/navigationbar/res/values-en-rXC/strings.xml
+++ b/navigationbar/res/values-en-rXC/strings.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="setup_wizard_next_button_label" msgid="6681282266022780599">"‎‏‎‎‎‎‎‏‎‏‏‏‎‎‎‎‎‏‎‎‏‎‎‎‏‏‏‏‏‏‏‏‏‎‏‏‏‎‎‏‎‏‏‏‎‎‎‏‎‏‎‏‏‏‎‏‏‎‏‎‎‏‎‎‏‏‎‏‏‏‎‎‏‏‎‎‏‏‏‏‎‎‏‏‏‏‎‏‎‏‏‎‏‏‏‎Next‎‏‎‎‏‎"</string>
- <string name="setup_wizard_back_button_label" msgid="2863826823307023546">"‎‏‎‎‎‎‎‏‎‏‏‏‎‎‎‎‎‏‎‎‏‎‎‎‏‏‏‏‏‏‏‎‏‎‎‏‏‏‏‎‏‏‏‏‏‎‎‏‎‏‏‎‏‏‎‏‎‏‎‎‏‎‏‎‎‏‎‏‎‏‎‏‏‏‎‎‏‏‎‏‎‏‎‏‎‎‏‎‏‏‏‎‏‎‎Back‎‏‎‎‏‎"</string>
+ <string name="setup_wizard_next_button_label" msgid="6681282266022780599">"‎‏‎‎‎‎‎‏‎‏‏‏‎‎‎‎‎‎‏‎‎‏‎‎‎‏‏‏‏‏‏‏‏‏‎‏‏‏‎‎‏‎‏‏‏‎‎‎‏‎‏‎‏‏‏‎‏‏‎‏‎‎‏‎‎‏‏‎‏‏‏‎‎‏‏‎‎‏‏‏‏‎‎‏‏‏‏‎‏‎‏‏‎‏‏‏‎Next‎‏‎‎‏‎"</string>
+ <string name="setup_wizard_back_button_label" msgid="2863826823307023546">"‎‏‎‎‎‎‎‏‎‏‏‏‎‎‎‎‎‎‏‎‎‏‎‎‎‏‏‏‏‏‏‏‎‏‎‎‏‏‏‏‎‏‏‏‏‏‎‎‏‎‏‏‎‏‏‎‏‎‏‎‎‏‎‏‎‎‏‎‏‎‏‎‏‏‏‎‎‏‏‎‏‎‏‎‏‎‎‏‎‏‏‏‎‏‎‎Back‎‏‎‎‏‎"</string>
</resources>
diff --git a/navigationbar/res/values-fi/strings.xml b/navigationbar/res/values-fi/strings.xml
index 1bf32f2..c0718e3 100644
--- a/navigationbar/res/values-fi/strings.xml
+++ b/navigationbar/res/values-fi/strings.xml
@@ -2,5 +2,5 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="setup_wizard_next_button_label" msgid="6681282266022780599">"Seuraava"</string>
- <string name="setup_wizard_back_button_label" msgid="2863826823307023546">"Edellinen"</string>
+ <string name="setup_wizard_back_button_label" msgid="2863826823307023546">"Takaisin"</string>
</resources>