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 mIsResumed = false;
|
||||||
|
|
||||||
|
private boolean mIsFinished = false;
|
||||||
|
|
||||||
private OnResumeRunnable mOnResumeRunnable;
|
private OnResumeRunnable mOnResumeRunnable;
|
||||||
|
|
||||||
public AbstractSetupData(Context context) {
|
public AbstractSetupData(Context context) {
|
||||||
@ -186,6 +188,7 @@ public abstract class AbstractSetupData extends BroadcastReceiver implements Set
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void finishPages() {
|
public void finishPages() {
|
||||||
|
mIsFinished = true;
|
||||||
for (Page page : mPageList.values()) {
|
for (Page page : mPageList.values()) {
|
||||||
page.onFinishSetup();
|
page.onFinishSetup();
|
||||||
}
|
}
|
||||||
@ -198,6 +201,10 @@ public abstract class AbstractSetupData extends BroadcastReceiver implements Set
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isFinished() {
|
||||||
|
return mIsFinished;
|
||||||
|
}
|
||||||
|
|
||||||
public Bundle save() {
|
public Bundle save() {
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
for (Page page : mPageList.values()) {
|
for (Page page : mPageList.values()) {
|
||||||
|
@ -93,6 +93,10 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks,
|
|||||||
}
|
}
|
||||||
mNextButton = (Button) findViewById(R.id.next_button);
|
mNextButton = (Button) findViewById(R.id.next_button);
|
||||||
mPrevButton = (Button) findViewById(R.id.prev_button);
|
mPrevButton = (Button) findViewById(R.id.prev_button);
|
||||||
|
if (mSetupData.isFinished()) {
|
||||||
|
mNextButton.setVisibility(View.INVISIBLE);
|
||||||
|
mPrevButton.setVisibility(View.INVISIBLE);
|
||||||
|
}
|
||||||
mSetupData.registerListener(this);
|
mSetupData.registerListener(this);
|
||||||
mNextButton.setOnClickListener(new View.OnClickListener() {
|
mNextButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
@ -133,10 +137,19 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks,
|
|||||||
| View.SYSTEM_UI_FLAG_IMMERSIVE
|
| View.SYSTEM_UI_FLAG_IMMERSIVE
|
||||||
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
|
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
if (mSetupData.isFinished()) {
|
||||||
|
mHandler.postDelayed(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
finishSetup();
|
||||||
|
}
|
||||||
|
}, 500);
|
||||||
|
} else {
|
||||||
mSetupData.onResume();
|
mSetupData.onResume();
|
||||||
onPageTreeChanged();
|
onPageTreeChanged();
|
||||||
enableButtonBar(true);
|
enableButtonBar(true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
@ -276,18 +289,19 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks,
|
|||||||
final ThemeManager tm = (ThemeManager) getSystemService(Context.THEME_SERVICE);
|
final ThemeManager tm = (ThemeManager) getSystemService(Context.THEME_SERVICE);
|
||||||
tm.addClient(this);
|
tm.addClient(this);
|
||||||
mSetupData.finishPages();
|
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
|
@Override
|
||||||
public void onFinish(boolean isSuccess) {
|
public void onFinish(boolean isSuccess) {
|
||||||
|
if (isResumed()) {
|
||||||
|
mHandler.post(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
finishSetup();
|
finishSetup();
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onProgress(int progress) {
|
public void onProgress(int progress) {
|
||||||
@ -300,6 +314,13 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks,
|
|||||||
@Override
|
@Override
|
||||||
public void finishSetup() {
|
public void finishSetup() {
|
||||||
if (!mIsFinishing) {
|
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;
|
mIsFinishing = true;
|
||||||
setupRevealImage();
|
setupRevealImage();
|
||||||
}
|
}
|
||||||
@ -394,10 +415,10 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks,
|
|||||||
wallpaperManager.forgetLoadedWallpaper();
|
wallpaperManager.forgetLoadedWallpaper();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
finish();
|
|
||||||
for (Runnable runnable : mFinishRunnables) {
|
for (Runnable runnable : mFinishRunnables) {
|
||||||
runnable.run();
|
runnable.run();
|
||||||
}
|
}
|
||||||
|
finish();
|
||||||
SetupWizardUtils.disableSetupWizard(SetupWizardActivity.this);
|
SetupWizardUtils.disableSetupWizard(SetupWizardActivity.this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user