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:
cretin45 2015-03-13 16:18:24 -07:00
parent 0ed67f547c
commit bfde63c27c
2 changed files with 39 additions and 11 deletions

View File

@ -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()) {

View File

@ -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,9 +137,18 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks,
| View.SYSTEM_UI_FLAG_IMMERSIVE
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
super.onResume();
mSetupData.onResume();
onPageTreeChanged();
enableButtonBar(true);
if (mSetupData.isFinished()) {
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
finishSetup();
}
}, 500);
} else {
mSetupData.onResume();
onPageTreeChanged();
enableButtonBar(true);
}
}
@Override
@ -276,17 +289,18 @@ 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) {
finishSetup();
if (isResumed()) {
mHandler.post(new Runnable() {
@Override
public void run() {
finishSetup();
}
});
}
}
@Override
@ -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);
}
}