diff --git a/java/res/values/strings.xml b/java/res/values/strings.xml
index 2a47d7afa..68fa8fd37 100644
--- a/java/res/values/strings.xml
+++ b/java/res/values/strings.xml
@@ -434,4 +434,6 @@
Language & input
Choose input method
+
+ Show setup wizard icon
diff --git a/java/res/xml/prefs.xml b/java/res/xml/prefs.xml
index 276395bad..e5fef8834 100644
--- a/java/res/xml/prefs.xml
+++ b/java/res/xml/prefs.xml
@@ -145,7 +145,7 @@
android:fragment="com.android.inputmethod.latin.AdditionalSubtypeSettings"
android:key="custom_input_styles"
android:title="@string/custom_input_styles_title" />
-
+
+
+
activityClass) {
- final ComponentName activityComponent = new ComponentName(context, activityClass);
- final PackageManager pm = context.getPackageManager();
- final int activityComponentState = pm.getComponentEnabledSetting(activityComponent);
- if (activityComponentState == PackageManager.COMPONENT_ENABLED_STATE_DISABLED) {
- // This activity is already disabled.
- Log.i(TAG, "Activity has already been disabled: " + activityComponent);
- return;
+ public static void updateSetupWizardIconVisibility(final Context context) {
+ final ComponentName setupWizardActivity = new ComponentName(context, SetupActivity.class);
+ final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
+ final boolean stateHasSet;
+ if (Settings.readShowSetupWizardIcon(prefs, context)) {
+ stateHasSet = setActivityState(context, setupWizardActivity,
+ PackageManager.COMPONENT_ENABLED_STATE_ENABLED);
+ Log.i(TAG, (stateHasSet ? "Enable activity: " : "Activity has already been enabled: ")
+ + setupWizardActivity);
+ } else {
+ stateHasSet = setActivityState(context, setupWizardActivity,
+ PackageManager.COMPONENT_ENABLED_STATE_DISABLED);
+ Log.i(TAG, (stateHasSet ? "Disable activity: " : "Activity has already been disabled: ")
+ + setupWizardActivity);
}
- // Disabling an activity will also hide its icon from the launcher.
- pm.setComponentEnabledSetting(activityComponent,
- PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
- PackageManager.DONT_KILL_APP);
- Log.i(TAG, "Disable activity: " + activityComponent);
}
- private static boolean isInSystemImage(final Context context) {
- final ApplicationInfo appInfo = context.getApplicationInfo();
- return (appInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0;
+ private static boolean setActivityState(final Context context,
+ final ComponentName activityComponent, final int activityState) {
+ final PackageManager pm = context.getPackageManager();
+ final int activityComponentState = pm.getComponentEnabledSetting(activityComponent);
+ if (activityComponentState == activityState) {
+ return false;
+ }
+ pm.setComponentEnabledSetting(
+ activityComponent, activityState, PackageManager.DONT_KILL_APP);
+ return true;
}
}