Restore switch for showing app icon.

Bug: 20307420
Change-Id: I95969de40936d2ea992669324d0c4df7e8de2bd9
main
Chieu Nguyen 2015-04-22 14:41:45 -07:00
parent fece743fee
commit a2376cd2b4
5 changed files with 34 additions and 3 deletions

View File

@ -433,6 +433,10 @@ mobile devices. [CHAR LIMIT=25] -->
<string name="setup_step3_action">Configure additional languages</string> <string name="setup_step3_action">Configure additional languages</string>
<!-- The label of the button that finishes the setup wizard. [CHAR_LIMIT=64] --> <!-- The label of the button that finishes the setup wizard. [CHAR_LIMIT=64] -->
<string name="setup_finish_action">Finished</string> <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. --> <!-- The dictionary provider application name. Visible in Settings/Applications/Manage applications. -->
<string name="app_name">Dictionary Provider</string> <string name="app_name">Dictionary Provider</string>

View File

@ -43,6 +43,11 @@
android:summary="@string/prefs_enable_emoji_alt_physical_key_summary" android:summary="@string/prefs_enable_emoji_alt_physical_key_summary"
android:defaultValue="true" android:defaultValue="true"
android:persistent="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 <PreferenceScreen
android:fragment="com.android.inputmethod.latin.settings.DebugSettingsFragment" android:fragment="com.android.inputmethod.latin.settings.DebugSettingsFragment"
android:key="screen_debug" android:key="screen_debug"

View File

@ -20,9 +20,11 @@ import android.content.BroadcastReceiver;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo; import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.os.Process; import android.os.Process;
import android.preference.PreferenceManager;
import android.util.Log; import android.util.Log;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
import android.view.inputmethod.InputMethodSubtype; 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.CommonPreferences;
import com.android.inputmethod.dictionarypack.DictionaryPackConstants; import com.android.inputmethod.dictionarypack.DictionaryPackConstants;
import com.android.inputmethod.keyboard.KeyboardLayoutSet; 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.setup.SetupActivity;
import com.android.inputmethod.latin.utils.UncachedInputMethodManagerUtils; import com.android.inputmethod.latin.utils.UncachedInputMethodManagerUtils;
@ -112,11 +115,12 @@ public final class SystemBroadcastReceiver extends BroadcastReceiver {
if (Log.isLoggable(TAG, Log.INFO)) { if (Log.isLoggable(TAG, Log.INFO)) {
Log.i(TAG, "toggleAppIcon() : FLAG_SYSTEM = " + isSystemApp); Log.i(TAG, "toggleAppIcon() : FLAG_SYSTEM = " + isSystemApp);
} }
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
context.getPackageManager().setComponentEnabledSetting( context.getPackageManager().setComponentEnabledSetting(
new ComponentName(context, SetupActivity.class), new ComponentName(context, SetupActivity.class),
isSystemApp Settings.readShowSetupWizardIcon(prefs, context)
? PackageManager.COMPONENT_ENABLED_STATE_DISABLED ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED
: PackageManager.COMPONENT_ENABLED_STATE_ENABLED, : PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
PackageManager.DONT_KILL_APP); PackageManager.DONT_KILL_APP);
} }
} }

View File

@ -18,6 +18,7 @@ package com.android.inputmethod.latin.settings;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.content.res.Resources; import android.content.res.Resources;
import android.os.Build; 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_PREVIEW_TRAIL = "pref_gesture_preview_trail";
public static final String PREF_GESTURE_FLOATING_PREVIEW_TEXT = public static final String PREF_GESTURE_FLOATING_PREVIEW_TEXT =
"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"; 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); 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) { public static boolean readHasHardwareKeyboard(final Configuration conf) {
// The standard way of finding out whether we have a hardware keyboard. This code is taken // The standard way of finding out whether we have a hardware keyboard. This code is taken
// from InputMethodService#onEvaluateInputShown, which canonically determines this. // from InputMethodService#onEvaluateInputShown, which canonically determines this.

View File

@ -81,6 +81,8 @@ public class SettingsValues {
public final boolean mSlidingKeyInputPreviewEnabled; public final boolean mSlidingKeyInputPreviewEnabled;
public final int mKeyLongpressTimeout; public final int mKeyLongpressTimeout;
public final boolean mEnableEmojiAltPhysicalKey; public final boolean mEnableEmojiAltPhysicalKey;
public final boolean mShowAppIcon;
public final boolean mIsShowAppIconSettingInPreferences;
public final boolean mCloudSyncEnabled; public final boolean mCloudSyncEnabled;
public final boolean mEnableMetricsLogging; public final boolean mEnableMetricsLogging;
public final boolean mShouldShowLxxSuggestionUi; public final boolean mShouldShowLxxSuggestionUi;
@ -168,6 +170,8 @@ public class SettingsValues {
mKeyPreviewPopupDismissDelay = Settings.readKeyPreviewPopupDismissDelay(prefs, res); mKeyPreviewPopupDismissDelay = Settings.readKeyPreviewPopupDismissDelay(prefs, res);
mEnableEmojiAltPhysicalKey = prefs.getBoolean( mEnableEmojiAltPhysicalKey = prefs.getBoolean(
Settings.PREF_ENABLE_EMOJI_ALT_PHYSICAL_KEY, true); 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, mAutoCorrectionThreshold = readAutoCorrectionThreshold(res,
autoCorrectionThresholdRawValue); autoCorrectionThresholdRawValue);
mPlausibilityThreshold = Settings.readPlausibilityThreshold(res); mPlausibilityThreshold = Settings.readPlausibilityThreshold(res);