SetupWizard: #blamethemes
Themes keep breaking the handle themeConfig flag. This provides a workaround for cases the activity gets torn down during the finish process. Change-Id: I6664ded3dfff5b69c1217f89f25106953cb5f92a
This commit is contained in:
parent
0ed67f547c
commit
bfde63c27c
@ -34,6 +34,8 @@ public abstract class AbstractSetupData extends BroadcastReceiver implements Set
|
||||
|
||||
private boolean mIsResumed = false;
|
||||
|
||||
private boolean mIsFinished = false;
|
||||
|
||||
private OnResumeRunnable mOnResumeRunnable;
|
||||
|
||||
public AbstractSetupData(Context context) {
|
||||
@ -186,6 +188,7 @@ public abstract class AbstractSetupData extends BroadcastReceiver implements Set
|
||||
}
|
||||
|
||||
public void finishPages() {
|
||||
mIsFinished = true;
|
||||
for (Page page : mPageList.values()) {
|
||||
page.onFinishSetup();
|
||||
}
|
||||
@ -198,6 +201,10 @@ public abstract class AbstractSetupData extends BroadcastReceiver implements Set
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isFinished() {
|
||||
return mIsFinished;
|
||||
}
|
||||
|
||||
public Bundle save() {
|
||||
Bundle bundle = new Bundle();
|
||||
for (Page page : mPageList.values()) {
|
||||
|
@ -93,6 +93,10 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks,
|
||||
}
|
||||
mNextButton = (Button) findViewById(R.id.next_button);
|
||||
mPrevButton = (Button) findViewById(R.id.prev_button);
|
||||
if (mSetupData.isFinished()) {
|
||||
mNextButton.setVisibility(View.INVISIBLE);
|
||||
mPrevButton.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
mSetupData.registerListener(this);
|
||||
mNextButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
@ -133,10 +137,19 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks,
|
||||
| View.SYSTEM_UI_FLAG_IMMERSIVE
|
||||
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
|
||||
super.onResume();
|
||||
if (mSetupData.isFinished()) {
|
||||
mHandler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
finishSetup();
|
||||
}
|
||||
}, 500);
|
||||
} else {
|
||||
mSetupData.onResume();
|
||||
onPageTreeChanged();
|
||||
enableButtonBar(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
@ -276,18 +289,19 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks,
|
||||
final ThemeManager tm = (ThemeManager) getSystemService(Context.THEME_SERVICE);
|
||||
tm.addClient(this);
|
||||
mSetupData.finishPages();
|
||||
SetupStats.addEvent(SetupStats.Categories.APP_FINISHED, TAG,
|
||||
SetupStats.Label.TOTAL_TIME, String.valueOf(
|
||||
System.nanoTime() - sLaunchTime));
|
||||
setupWizardApp.sendStickyBroadcastAsUser(
|
||||
new Intent(SetupWizardApp.ACTION_FINISHED),
|
||||
UserHandle.getCallingUserHandle());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinish(boolean isSuccess) {
|
||||
if (isResumed()) {
|
||||
mHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
finishSetup();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProgress(int progress) {
|
||||
@ -300,6 +314,13 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks,
|
||||
@Override
|
||||
public void finishSetup() {
|
||||
if (!mIsFinishing) {
|
||||
SetupStats.addEvent(SetupStats.Categories.APP_FINISHED, TAG,
|
||||
SetupStats.Label.TOTAL_TIME, String.valueOf(
|
||||
System.nanoTime() - sLaunchTime));
|
||||
final SetupWizardApp setupWizardApp = (SetupWizardApp)getApplication();
|
||||
setupWizardApp.sendStickyBroadcastAsUser(
|
||||
new Intent(SetupWizardApp.ACTION_FINISHED),
|
||||
UserHandle.getCallingUserHandle());
|
||||
mIsFinishing = true;
|
||||
setupRevealImage();
|
||||
}
|
||||
@ -394,10 +415,10 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks,
|
||||
wallpaperManager.forgetLoadedWallpaper();
|
||||
}
|
||||
});
|
||||
finish();
|
||||
for (Runnable runnable : mFinishRunnables) {
|
||||
runnable.run();
|
||||
}
|
||||
finish();
|
||||
SetupWizardUtils.disableSetupWizard(SetupWizardActivity.this);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user