aboutsummaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
authorDan Zivkovic <zivkovic@google.com>2015-01-16 17:49:36 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-01-16 17:49:37 +0000
commitfc470076741a61a7133590d63fc5241ee1343d2e (patch)
tree9232cf6d98be58c0f706c724141564c6cf8e5e6f /java
parent9fe700ec4fceba1e061733795bc89ca9d0620525 (diff)
parentd913617e0cecc2628c3729933c365d76f45f5504 (diff)
downloadlatinime-fc470076741a61a7133590d63fc5241ee1343d2e.tar.gz
latinime-fc470076741a61a7133590d63fc5241ee1343d2e.tar.xz
latinime-fc470076741a61a7133590d63fc5241ee1343d2e.zip
Merge "AOSP change for showing the app icon."
Diffstat (limited to 'java')
-rw-r--r--java/res/values/setup-wizard.xml1
-rw-r--r--java/res/values/strings.xml4
-rw-r--r--java/res/xml/prefs_screen_advanced.xml6
-rw-r--r--java/src/com/android/inputmethod/latin/SystemBroadcastReceiver.java41
-rw-r--r--java/src/com/android/inputmethod/latin/settings/AdvancedSettingsFragment.java13
-rw-r--r--java/src/com/android/inputmethod/latin/settings/Settings.java19
-rw-r--r--java/src/com/android/inputmethod/latin/setup/LauncherIconVisibilityManager.java85
7 files changed, 14 insertions, 155 deletions
diff --git a/java/res/values/setup-wizard.xml b/java/res/values/setup-wizard.xml
index 84647090b..90c3ecac9 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 5eaac09a3..2e9c8ea1f 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 1fa6fd0c4..402132e67 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 982d4c690..db5e632ae 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 d2c9dbbe9..3dfc743f8 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 0d3dab57c..77996405b 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 3f0b10225..000000000
--- 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;
- }
-}