SetupWizard: Add callback for actions to run post finish
Change-Id: Ifa62c94f61afbe33a97a66dc0acb72e303023579
This commit is contained in:
parent
4e192fd22b
commit
c9c13f20c9
@ -191,6 +191,13 @@ public abstract class AbstractSetupData extends BroadcastReceiver implements Set
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addFinishRunnable(Runnable runnable) {
|
||||
for (int i = 0; i < mListeners.size(); i++) {
|
||||
mListeners.get(i).addFinishRunnable(runnable);
|
||||
}
|
||||
}
|
||||
|
||||
public Bundle save() {
|
||||
Bundle bundle = new Bundle();
|
||||
for (Page page : mPageList.values()) {
|
||||
|
@ -123,9 +123,14 @@ public class CyanogenSettingsPage extends SetupPage {
|
||||
|
||||
@Override
|
||||
public void onFinishSetup() {
|
||||
if (getData().containsKey(KEY_ENABLE_NAV_KEYS)) {
|
||||
writeDisableNavkeysOption(mContext, getData().getBoolean(KEY_ENABLE_NAV_KEYS));
|
||||
}
|
||||
getCallbacks().addFinishRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (getData().containsKey(KEY_ENABLE_NAV_KEYS)) {
|
||||
writeDisableNavkeysOption(mContext, getData().getBoolean(KEY_ENABLE_NAV_KEYS));
|
||||
}
|
||||
}
|
||||
});
|
||||
handleWhisperPushRegistration();
|
||||
handleEnableMetrics();
|
||||
handleDefaultThemeSetup();
|
||||
|
@ -26,4 +26,5 @@ public interface SetupDataCallbacks {
|
||||
boolean isCurrentPage(Page page);
|
||||
Page getPage(String key);
|
||||
Page getPage(int key);
|
||||
void addFinishRunnable(Runnable runnable);
|
||||
}
|
||||
|
@ -47,6 +47,8 @@ import com.cyanogenmod.setupwizard.setup.SetupDataCallbacks;
|
||||
import com.cyanogenmod.setupwizard.util.EnableAccessibilityController;
|
||||
import com.cyanogenmod.setupwizard.util.SetupWizardUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
||||
public class SetupWizardActivity extends Activity implements SetupDataCallbacks {
|
||||
|
||||
@ -69,6 +71,8 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks
|
||||
|
||||
private volatile boolean mIsFinishing = false;
|
||||
|
||||
private final ArrayList<Runnable> mFinishRunnables = new ArrayList<Runnable>();
|
||||
|
||||
private ThemeManager.ThemeChangeListener mThemeChangeListener = new ThemeManager.ThemeChangeListener() {
|
||||
@Override
|
||||
public void onProgress(int progress) {
|
||||
@ -273,6 +277,11 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks
|
||||
return mSetupData.isCurrentPage(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addFinishRunnable(Runnable runnable) {
|
||||
mFinishRunnables.add(runnable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinish() {
|
||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR);
|
||||
@ -313,6 +322,9 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks
|
||||
@Override
|
||||
public void finish() {
|
||||
super.finish();
|
||||
for (Runnable runnable : mFinishRunnables) {
|
||||
runnable.run();
|
||||
}
|
||||
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
|
||||
}
|
||||
|
||||
@ -390,21 +402,28 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks
|
||||
}
|
||||
|
||||
private void finalizeSetup() {
|
||||
Settings.Global.putInt(getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 1);
|
||||
Settings.Secure.putInt(getContentResolver(), Settings.Secure.USER_SETUP_COMPLETE, 1);
|
||||
mFinishRunnables.add(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Settings.Global.putInt(getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 1);
|
||||
Settings.Secure.putInt(getContentResolver(),
|
||||
Settings.Secure.USER_SETUP_COMPLETE, 1);
|
||||
if (mEnableAccessibilityController != null) {
|
||||
mEnableAccessibilityController.onDestroy();
|
||||
}
|
||||
SetupWizardUtils.disableGMSSetupWizard(SetupWizardActivity.this);
|
||||
SetupWizardUtils.disableSetupWizard(SetupWizardActivity.this);
|
||||
final ThemeManager tm =
|
||||
(ThemeManager) SetupWizardActivity.this.getSystemService(THEME_SERVICE);
|
||||
tm.removeClient(mThemeChangeListener);
|
||||
Intent intent = new Intent(Intent.ACTION_MAIN);
|
||||
intent.addCategory(Intent.CATEGORY_HOME);
|
||||
startActivity(intent);
|
||||
final WallpaperManager wallpaperManager =
|
||||
WallpaperManager.getInstance(SetupWizardActivity.this);
|
||||
wallpaperManager.forgetLoadedWallpaper();
|
||||
}
|
||||
});
|
||||
finish();
|
||||
if (mEnableAccessibilityController != null) {
|
||||
mEnableAccessibilityController.onDestroy();
|
||||
}
|
||||
SetupWizardUtils.disableGMSSetupWizard(this);
|
||||
SetupWizardUtils.disableSetupWizard(this);
|
||||
final ThemeManager tm = (ThemeManager) this.getSystemService(THEME_SERVICE);
|
||||
tm.removeClient(mThemeChangeListener);
|
||||
Intent intent = new Intent(Intent.ACTION_MAIN);
|
||||
intent.addCategory(Intent.CATEGORY_HOME);
|
||||
startActivity(intent);
|
||||
final WallpaperManager wallpaperManager =
|
||||
WallpaperManager.getInstance(SetupWizardActivity.this);
|
||||
wallpaperManager.forgetLoadedWallpaper();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user