mirror of
https://gitlab.futo.org/keyboard/latinime.git
synced 2024-09-28 14:54:30 +01:00
AOSP change for showing the app icon.
This change deletes a bunch of code that was used to conditionally show/hide the keyboard app icon given system states and user preferences. Bug 19001197. Change-Id: I69a57aa21872a571af87a193b3e52b7f985e5168
This commit is contained in:
parent
4e395e119f
commit
d913617e0c
@ -18,5 +18,4 @@
|
||||
*/
|
||||
-->
|
||||
<resources>
|
||||
<bool name="config_setup_wizard_available">false</bool>
|
||||
</resources>
|
||||
|
@ -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>
|
||||
|
@ -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"
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -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.
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user