diff --git a/java/res/values/setup-wizard.xml b/java/res/values/setup-wizard.xml index 84647090bc7d3d903df8ca9530715d55ff41105f..90c3ecac93a37663a98213469cf7463c4ce40ab7 100644 --- a/java/res/values/setup-wizard.xml +++ b/java/res/values/setup-wizard.xml @@ -18,5 +18,4 @@ */ --> <resources> - <bool name="config_setup_wizard_available">false</bool> </resources> diff --git a/java/res/values/strings.xml b/java/res/values/strings.xml index 5eaac09a3b726fa86e12a6a6e275c22cded62d6d..2e9c8ea1f624d121464f0ce1fa1a1a52b948288b 100644 --- a/java/res/values/strings.xml +++ b/java/res/values/strings.xml @@ -413,10 +413,6 @@ 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 1fa6fd0c4329684f4de0ed3903eb1dac2ec0c8bc..402132e67ed492942a3ceedfce6dd57b9063d839 100644 --- a/java/res/xml/prefs_screen_advanced.xml +++ b/java/res/xml/prefs_screen_advanced.xml @@ -43,12 +43,6 @@ android:summary="@string/prefs_enable_emoji_alt_physical_key_summary" android:defaultValue="true" android:persistent="true" /> - <!-- The settings for showing setup wizard application icon shouldn't be persistent and - the default value is added programmatically. --> - <CheckBoxPreference - android:key="pref_show_setup_wizard_icon" - android:title="@string/show_setup_wizard_icon" - android:summary="@string/show_setup_wizard_icon_summary" /> <!-- title will be set programmatically to embed application name --> <CheckBoxPreference android:key="pref_enable_metrics_logging" diff --git a/java/src/com/android/inputmethod/latin/SystemBroadcastReceiver.java b/java/src/com/android/inputmethod/latin/SystemBroadcastReceiver.java index 982d4c69029ee3b0c80870c88fada6c5764b4198..db5e632aeebfa8404ba7560cbd04eea05ae26548 100644 --- a/java/src/com/android/inputmethod/latin/SystemBroadcastReceiver.java +++ b/java/src/com/android/inputmethod/latin/SystemBroadcastReceiver.java @@ -17,16 +17,17 @@ package com.android.inputmethod.latin; import android.content.BroadcastReceiver; +import android.content.ComponentName; import android.content.Context; import android.content.Intent; +import android.content.pm.PackageManager; import android.os.Process; import android.util.Log; import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodSubtype; -import com.android.inputmethod.compat.IntentCompatUtils; import com.android.inputmethod.keyboard.KeyboardLayoutSet; -import com.android.inputmethod.latin.setup.LauncherIconVisibilityManager; +import com.android.inputmethod.latin.setup.SetupActivity; import com.android.inputmethod.latin.utils.UncachedInputMethodManagerUtils; /** @@ -34,26 +35,6 @@ import com.android.inputmethod.latin.utils.UncachedInputMethodManagerUtils; * package has been replaced by a newer version of the same package. This class also detects * {@link Intent#ACTION_BOOT_COMPLETED} and {@link Intent#ACTION_USER_INITIALIZE} broadcast intent. * - * If this IME has already been installed in the system image and a new version of this IME has - * been installed, {@link Intent#ACTION_MY_PACKAGE_REPLACED} is received by this receiver and it - * will hide the setup wizard's icon. - * - * If this IME has already been installed in the data partition and a new version of this IME has - * been installed, {@link Intent#ACTION_MY_PACKAGE_REPLACED} is received by this receiver but it - * will not hide the setup wizard's icon, and the icon will appear on the launcher. - * - * If this IME hasn't been installed yet and has been newly installed, no - * {@link Intent#ACTION_MY_PACKAGE_REPLACED} will be sent and the setup wizard's icon will appear - * on the launcher. - * - * When the device has been booted, {@link Intent#ACTION_BOOT_COMPLETED} is received by this - * receiver and it checks whether the setup wizard's icon should be appeared or not on the launcher - * depending on which partition this IME is installed. - * - * When a multiuser account has been created, {@link Intent#ACTION_USER_INITIALIZE} is received - * by this receiver and it checks the whether the setup wizard's icon should be appeared or not on - * the launcher depending on which partition this IME is installed. - * * When the system locale has been changed, {@link Intent#ACTION_LOCALE_CHANGED} is received by * this receiver and the {@link KeyboardLayoutSet}'s cache is cleared. */ @@ -71,13 +52,10 @@ public final class SystemBroadcastReceiver extends BroadcastReceiver { final RichInputMethodManager richImm = RichInputMethodManager.getInstance(); final InputMethodSubtype[] additionalSubtypes = richImm.getAdditionalSubtypes(); richImm.setAdditionalInputMethodSubtypes(additionalSubtypes); - LauncherIconVisibilityManager.updateSetupWizardIconVisibility(context); + showAppIcon(context); } else if (Intent.ACTION_BOOT_COMPLETED.equals(intentAction)) { Log.i(TAG, "Boot has been completed"); - LauncherIconVisibilityManager.updateSetupWizardIconVisibility(context); - } else if (IntentCompatUtils.is_ACTION_USER_INITIALIZE(intentAction)) { - Log.i(TAG, "User initialize"); - LauncherIconVisibilityManager.updateSetupWizardIconVisibility(context); + showAppIcon(context); } else if (Intent.ACTION_LOCALE_CHANGED.equals(intentAction)) { Log.i(TAG, "System locale changed"); KeyboardLayoutSet.onSystemLocaleChanged(); @@ -100,4 +78,13 @@ public final class SystemBroadcastReceiver extends BroadcastReceiver { Process.killProcess(myPid); } } + + private static void showAppIcon(final Context context) { + final ComponentName setupWizardActivity = new ComponentName(context, SetupActivity.class); + final PackageManager pm = context.getPackageManager(); + pm.setComponentEnabledSetting( + setupWizardActivity, + PackageManager.COMPONENT_ENABLED_STATE_ENABLED, + PackageManager.DONT_KILL_APP); + } } diff --git a/java/src/com/android/inputmethod/latin/settings/AdvancedSettingsFragment.java b/java/src/com/android/inputmethod/latin/settings/AdvancedSettingsFragment.java index d2c9dbbe97679a7a5609e51d2d020190085a07a5..3dfc743f8e0a2d214f9926d795e7e4106ac46e8c 100644 --- a/java/src/com/android/inputmethod/latin/settings/AdvancedSettingsFragment.java +++ b/java/src/com/android/inputmethod/latin/settings/AdvancedSettingsFragment.java @@ -23,12 +23,10 @@ import android.media.AudioManager; import android.os.Bundle; import android.preference.ListPreference; import android.preference.Preference; -import android.preference.TwoStatePreference; import com.android.inputmethod.latin.AudioAndHapticFeedbackManager; import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.define.ProductionFlags; -import com.android.inputmethod.latin.setup.LauncherIconVisibilityManager; /** * "Advanced" settings sub screen. @@ -89,10 +87,6 @@ public final class AdvancedSettingsFragment extends SubScreenFragment { Settings.readKeyPreviewPopupEnabled(prefs, res)); } - if (!res.getBoolean(R.bool.config_setup_wizard_available)) { - removePreference(Settings.PREF_SHOW_SETUP_WIZARD_ICON); - } - // If metrics logging isn't supported, or account sign in is enabled // don't show the logging preference. // TODO: Eventually when we enable account sign in by default, @@ -121,11 +115,6 @@ public final class AdvancedSettingsFragment extends SubScreenFragment { public void onResume() { super.onResume(); final SharedPreferences prefs = getPreferenceManager().getSharedPreferences(); - final TwoStatePreference showSetupWizardIcon = - (TwoStatePreference)findPreference(Settings.PREF_SHOW_SETUP_WIZARD_ICON); - if (showSetupWizardIcon != null) { - showSetupWizardIcon.setChecked(Settings.readShowSetupWizardIcon(prefs, getActivity())); - } updateListPreferenceSummaryToCurrentValue(Settings.PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY); } @@ -135,8 +124,6 @@ public final class AdvancedSettingsFragment extends SubScreenFragment { if (key.equals(Settings.PREF_POPUP_ON)) { setPreferenceEnabled(Settings.PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY, Settings.readKeyPreviewPopupEnabled(prefs, res)); - } else if (key.equals(Settings.PREF_SHOW_SETUP_WIZARD_ICON)) { - LauncherIconVisibilityManager.updateSetupWizardIconVisibility(getActivity()); } updateListPreferenceSummaryToCurrentValue(Settings.PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY); refreshEnablingsOfKeypressSoundAndVibrationSettings(); diff --git a/java/src/com/android/inputmethod/latin/settings/Settings.java b/java/src/com/android/inputmethod/latin/settings/Settings.java index 0d3dab57c7d291fff9f02d76286a47756c2ddc82..77996405b7b593dc836631bf905b2a9a474960b0 100644 --- a/java/src/com/android/inputmethod/latin/settings/Settings.java +++ b/java/src/com/android/inputmethod/latin/settings/Settings.java @@ -18,7 +18,6 @@ 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; @@ -102,7 +101,6 @@ 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_PHRASE_GESTURE_ENABLED = "pref_gesture_space_aware"; public static final String PREF_INPUT_LANGUAGE = "input_language"; @@ -378,23 +376,6 @@ 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) { - final boolean enableSetupWizardByConfig = context.getResources().getBoolean( - R.bool.config_setup_wizard_available); - if (!enableSetupWizardByConfig) { - return false; - } - 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/setup/LauncherIconVisibilityManager.java b/java/src/com/android/inputmethod/latin/setup/LauncherIconVisibilityManager.java deleted file mode 100644 index 3f0b10225c21ae05b6c0d958ae85f844d0915e62..0000000000000000000000000000000000000000 --- a/java/src/com/android/inputmethod/latin/setup/LauncherIconVisibilityManager.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.inputmethod.latin.setup; - -import android.content.ComponentName; -import android.content.Context; -import android.content.Intent; -import android.content.SharedPreferences; -import android.content.pm.PackageManager; -import android.preference.PreferenceManager; -import android.util.Log; - -import com.android.inputmethod.latin.settings.Settings; - -/** - * This class handles the {@link Intent#ACTION_MY_PACKAGE_REPLACED} broadcast intent when this IME - * package has been replaced by a newer version of the same package. This class also handles - * {@link Intent#ACTION_BOOT_COMPLETED} and {@link Intent#ACTION_USER_INITIALIZE} broadcast intent. - * - * If this IME has already been installed in the system image and a new version of this IME has - * been installed, {@link Intent#ACTION_MY_PACKAGE_REPLACED} is received to this class to hide the - * setup wizard's icon. - * - * If this IME has already been installed in the data partition and a new version of this IME has - * been installed, {@link Intent#ACTION_MY_PACKAGE_REPLACED} is forwarded to this class but it - * will not hide the setup wizard's icon, and the icon will appear on the launcher. - * - * If this IME hasn't been installed yet and has been newly installed, no - * {@link Intent#ACTION_MY_PACKAGE_REPLACED} will be sent and the setup wizard's icon will appear - * on the launcher. - * - * When the device has been booted, {@link Intent#ACTION_BOOT_COMPLETED} is forwarded to this class - * to check whether the setup wizard's icon should be appeared or not on the launcher - * depending on which partition this IME is installed. - * - * When a multiuser account has been created, {@link Intent#ACTION_USER_INITIALIZE} is forwarded to - * this class to check whether the setup wizard's icon should be appeared or not on the launcher - * depending on which partition this IME is installed. - */ -public final class LauncherIconVisibilityManager { - private static final String TAG = LauncherIconVisibilityManager.class.getSimpleName(); - - 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); - } - } - - 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; - } -}