From 4705c0fa7ca9527f6a3d7cb47542de734a56337d Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Thu, 9 May 2013 13:14:18 +0900 Subject: [PATCH] Fix screen flash when launching settings activity Bug: 8336068 Change-Id: I90a0f259129a3f3319b158b060154cc43960c234 --- java/res/layout/setup_wizard.xml | 1 + .../latin/setup/SetupWizardActivity.java | 26 ++++++++++++------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/java/res/layout/setup_wizard.xml b/java/res/layout/setup_wizard.xml index 176f83630..87db4d012 100644 --- a/java/res/layout/setup_wizard.xml +++ b/java/res/layout/setup_wizard.xml @@ -19,6 +19,7 @@ --> { @@ -104,10 +105,11 @@ public final class SetupWizardActivity extends Activity implements View.OnClickL @Override protected void onCreate(final Bundle savedInstanceState) { - setTheme(android.R.style.Theme_DeviceDefault_Light_NoActionBar); + setTheme(android.R.style.Theme_Translucent_NoTitleBar); super.onCreate(savedInstanceState); setContentView(R.layout.setup_wizard); + mSetupWizard = findViewById(R.id.setup_wizard); RichInputMethodManager.init(this); @@ -179,27 +181,28 @@ public final class SetupWizardActivity extends Activity implements View.OnClickL .authority(getPackageName()) .path(Integer.toString(R.raw.setup_welcome_video)) .build(); - mWelcomeVideoView = (VideoView)findViewById(R.id.setup_welcome_video); - mWelcomeVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { + final VideoView welcomeVideoView = (VideoView)findViewById(R.id.setup_welcome_video); + welcomeVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { @Override public void onPrepared(final MediaPlayer mp) { // Now VideoView has been laid-out and ready to play, remove background of it to // reveal the video. - mWelcomeVideoView.setBackgroundResource(0); + welcomeVideoView.setBackgroundResource(0); mp.setLooping(true); } }); final ImageView welcomeImageView = (ImageView)findViewById(R.id.setup_welcome_image); - mWelcomeVideoView.setOnErrorListener(new MediaPlayer.OnErrorListener() { + welcomeVideoView.setOnErrorListener(new MediaPlayer.OnErrorListener() { @Override public boolean onError(final MediaPlayer mp, final int what, final int extra) { Log.e(TAG, "Playing welcome video causes error: what=" + what + " extra=" + extra); - mWelcomeVideoView.setVisibility(View.GONE); + welcomeVideoView.setVisibility(View.GONE); welcomeImageView.setImageResource(R.raw.setup_welcome_image); welcomeImageView.setVisibility(View.VISIBLE); return true; } }); + mWelcomeVideoView = welcomeVideoView; mActionStart = findViewById(R.id.setup_start_label); mActionStart.setOnClickListener(this); @@ -234,7 +237,7 @@ public final class SetupWizardActivity extends Activity implements View.OnClickL } } - private void invokeSetupWizardOfThisIme() { + void invokeSetupWizardOfThisIme() { final Intent intent = new Intent(); intent.setClass(this, SetupWizardActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED @@ -251,14 +254,14 @@ public final class SetupWizardActivity extends Activity implements View.OnClickL startActivity(intent); } - private void invokeLanguageAndInputSettings() { + void invokeLanguageAndInputSettings() { final Intent intent = new Intent(); intent.setAction(Settings.ACTION_INPUT_METHOD_SETTINGS); intent.addCategory(Intent.CATEGORY_DEFAULT); startActivity(intent); } - private void invokeSubtypeEnablerOfThisIme() { + void invokeSubtypeEnablerOfThisIme() { final InputMethodInfo imi = RichInputMethodManager.getInstance().getInputMethodInfoOfThisIme(); final Intent intent = new Intent(); @@ -318,6 +321,8 @@ public final class SetupWizardActivity extends Activity implements View.OnClickL protected void onResume() { super.onResume(); if (mStepNumber == STEP_LAUNCHING_IME_SETTINGS) { + // Prevent white screen flashing while launching settings activity. + mSetupWizard.setVisibility(View.INVISIBLE); invokeSettingsOfThisIme(); mStepNumber = STEP_BACK_FROM_IME_SETTINGS; return; @@ -360,6 +365,7 @@ public final class SetupWizardActivity extends Activity implements View.OnClickL } private void updateSetupStepView() { + mSetupWizard.setVisibility(View.VISIBLE); final boolean welcomeScreen = (mStepNumber == STEP_WELCOME); mWelcomeScreen.setVisibility(welcomeScreen ? View.VISIBLE : View.GONE); mSetupScreen.setVisibility(welcomeScreen ? View.GONE : View.VISIBLE);