diff options
author | 2015-04-22 14:41:45 -0700 | |
---|---|---|
committer | 2015-04-22 15:46:40 -0700 | |
commit | a2376cd2b4fea6b655fdcdf794cf16b7bbe1a161 (patch) | |
tree | 80858f3efd63d7fcbb6d46f5647320ea40ef1264 | |
parent | fece743fee904e97a8ea89acc6354915c729885f (diff) | |
download | latinime-a2376cd2b4fea6b655fdcdf794cf16b7bbe1a161.tar.gz latinime-a2376cd2b4fea6b655fdcdf794cf16b7bbe1a161.tar.xz latinime-a2376cd2b4fea6b655fdcdf794cf16b7bbe1a161.zip |
Restore switch for showing app icon.
Bug: 20307420
Change-Id: I95969de40936d2ea992669324d0c4df7e8de2bd9
5 files changed, 34 insertions, 3 deletions
diff --git a/java/res/values/strings.xml b/java/res/values/strings.xml index 28dabf682..a64d4480e 100644 --- a/java/res/values/strings.xml +++ b/java/res/values/strings.xml @@ -433,6 +433,10 @@ mobile devices. [CHAR LIMIT=25] --> <string name="setup_step3_action">Configure additional languages</string> <!-- The label of the button that finishes the setup wizard. [CHAR_LIMIT=64] --> <string name="setup_finish_action">Finished</string> + <!-- Option to show setup wizard icon. [CHAR LIMIT=30]--> + <string name="show_setup_wizard_icon">Show app icon</string> + <!-- Description for the option to show setup wizard application icon of this IME in the laucher. [CHAR_LIMIT=65] --> + <string name="show_setup_wizard_icon_summary">Display application icon in the launcher</string> <!-- The dictionary provider application name. Visible in Settings/Applications/Manage applications. --> <string name="app_name">Dictionary Provider</string> diff --git a/java/res/xml/prefs_screen_advanced.xml b/java/res/xml/prefs_screen_advanced.xml index 6038f9947..b27104a2c 100644 --- a/java/res/xml/prefs_screen_advanced.xml +++ b/java/res/xml/prefs_screen_advanced.xml @@ -43,6 +43,11 @@ android:summary="@string/prefs_enable_emoji_alt_physical_key_summary" android:defaultValue="true" android:persistent="true" /> + <CheckBoxPreference + android:key="pref_show_setup_wizard_icon" + android:title="@string/show_setup_wizard_icon" + android:summary="@string/show_setup_wizard_icon_summary" + android:persistent="true" /> <PreferenceScreen android:fragment="com.android.inputmethod.latin.settings.DebugSettingsFragment" android:key="screen_debug" diff --git a/java/src/com/android/inputmethod/latin/SystemBroadcastReceiver.java b/java/src/com/android/inputmethod/latin/SystemBroadcastReceiver.java index 2a69d3650..0d081e0d2 100644 --- a/java/src/com/android/inputmethod/latin/SystemBroadcastReceiver.java +++ b/java/src/com/android/inputmethod/latin/SystemBroadcastReceiver.java @@ -20,9 +20,11 @@ import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.Context; import android.content.Intent; +import android.content.SharedPreferences; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.os.Process; +import android.preference.PreferenceManager; import android.util.Log; import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodSubtype; @@ -30,6 +32,7 @@ import android.view.inputmethod.InputMethodSubtype; import com.android.inputmethod.dictionarypack.CommonPreferences; import com.android.inputmethod.dictionarypack.DictionaryPackConstants; import com.android.inputmethod.keyboard.KeyboardLayoutSet; +import com.android.inputmethod.latin.settings.Settings; import com.android.inputmethod.latin.setup.SetupActivity; import com.android.inputmethod.latin.utils.UncachedInputMethodManagerUtils; @@ -112,11 +115,12 @@ public final class SystemBroadcastReceiver extends BroadcastReceiver { if (Log.isLoggable(TAG, Log.INFO)) { Log.i(TAG, "toggleAppIcon() : FLAG_SYSTEM = " + isSystemApp); } + final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); context.getPackageManager().setComponentEnabledSetting( new ComponentName(context, SetupActivity.class), - isSystemApp - ? PackageManager.COMPONENT_ENABLED_STATE_DISABLED - : PackageManager.COMPONENT_ENABLED_STATE_ENABLED, + Settings.readShowSetupWizardIcon(prefs, context) + ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED + : PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); } } diff --git a/java/src/com/android/inputmethod/latin/settings/Settings.java b/java/src/com/android/inputmethod/latin/settings/Settings.java index e9645eef1..694f43d3f 100644 --- a/java/src/com/android/inputmethod/latin/settings/Settings.java +++ b/java/src/com/android/inputmethod/latin/settings/Settings.java @@ -18,6 +18,7 @@ package com.android.inputmethod.latin.settings; import android.content.Context; import android.content.SharedPreferences; +import android.content.pm.ApplicationInfo; import android.content.res.Configuration; import android.content.res.Resources; import android.os.Build; @@ -93,6 +94,7 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang public static final String PREF_GESTURE_PREVIEW_TRAIL = "pref_gesture_preview_trail"; public static final String PREF_GESTURE_FLOATING_PREVIEW_TEXT = "pref_gesture_floating_preview_text"; + public static final String PREF_SHOW_SETUP_WIZARD_ICON = "pref_show_setup_wizard_icon"; public static final String PREF_KEY_IS_INTERNAL = "pref_key_is_internal"; @@ -350,6 +352,18 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang return res.getBoolean(R.bool.config_use_fullscreen_mode); } + public static boolean readShowSetupWizardIcon(final SharedPreferences prefs, + final Context context) { + if (!prefs.contains(PREF_SHOW_SETUP_WIZARD_ICON)) { + final ApplicationInfo appInfo = context.getApplicationInfo(); + final boolean isApplicationInSystemImage = + (appInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0; + // Default value + return !isApplicationInSystemImage; + } + return prefs.getBoolean(PREF_SHOW_SETUP_WIZARD_ICON, false); + } + public static boolean readHasHardwareKeyboard(final Configuration conf) { // The standard way of finding out whether we have a hardware keyboard. This code is taken // from InputMethodService#onEvaluateInputShown, which canonically determines this. diff --git a/java/src/com/android/inputmethod/latin/settings/SettingsValues.java b/java/src/com/android/inputmethod/latin/settings/SettingsValues.java index 94573a6d5..57018244f 100644 --- a/java/src/com/android/inputmethod/latin/settings/SettingsValues.java +++ b/java/src/com/android/inputmethod/latin/settings/SettingsValues.java @@ -81,6 +81,8 @@ public class SettingsValues { public final boolean mSlidingKeyInputPreviewEnabled; public final int mKeyLongpressTimeout; public final boolean mEnableEmojiAltPhysicalKey; + public final boolean mShowAppIcon; + public final boolean mIsShowAppIconSettingInPreferences; public final boolean mCloudSyncEnabled; public final boolean mEnableMetricsLogging; public final boolean mShouldShowLxxSuggestionUi; @@ -168,6 +170,8 @@ public class SettingsValues { mKeyPreviewPopupDismissDelay = Settings.readKeyPreviewPopupDismissDelay(prefs, res); mEnableEmojiAltPhysicalKey = prefs.getBoolean( Settings.PREF_ENABLE_EMOJI_ALT_PHYSICAL_KEY, true); + mShowAppIcon = Settings.readShowSetupWizardIcon(prefs, context); + mIsShowAppIconSettingInPreferences = prefs.contains(Settings.PREF_SHOW_SETUP_WIZARD_ICON); mAutoCorrectionThreshold = readAutoCorrectionThreshold(res, autoCorrectionThresholdRawValue); mPlausibilityThreshold = Settings.readPlausibilityThreshold(res); |