From 2e1b55f7969c67d7467aa8bdc1e0a82a856cbc88 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Tue, 5 Mar 2013 12:54:13 +0900 Subject: [PATCH] Add show setup wizard icon preference settings Bug: 8239067 Change-Id: If6106a3632d3abad3e22ce29f1351525a5152ec7 --- java/res/values/strings.xml | 2 + java/res/xml/prefs.xml | 7 ++- .../android/inputmethod/latin/Settings.java | 14 +++++ .../inputmethod/latin/SettingsFragment.java | 7 +++ .../setup/LauncherIconVisibilityManager.java | 59 +++++++++---------- 5 files changed, 57 insertions(+), 32 deletions(-) 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; } }