From 1b851897d2b7dba3c6cf54b8f4bd02d2240f98b1 Mon Sep 17 00:00:00 2001 From: Raimondas Rimkus Date: Sun, 22 Dec 2019 12:09:33 +0200 Subject: [PATCH] Don't hide launcher icon (Android 10 policy) --- app/build.gradle | 4 +- app/src/main/AndroidManifest.xml | 13 +---- .../inputmethod/keyboard/SetupActivity.java | 53 ------------------ .../inputmethod/latin/LatinIME.java | 4 +- .../settings/AdvancedSettingsFragment.java | 12 +--- .../inputmethod/latin/settings/Settings.java | 1 - .../latin/settings/SettingsActivity.java | 56 +++++++++++++++---- app/src/main/res/values-de/strings.xml | 1 - app/src/main/res/values-el/strings.xml | 1 - app/src/main/res/values-es/strings.xml | 1 - app/src/main/res/values-eu-rES/strings.xml | 1 - app/src/main/res/values-in/strings.xml | 1 - app/src/main/res/values-lt/strings.xml | 1 - app/src/main/res/values-nb/strings.xml | 1 - app/src/main/res/values-tr/strings.xml | 1 - app/src/main/res/values/strings.xml | 1 - .../main/res/xml/prefs_screen_advanced.xml | 4 -- 17 files changed, 51 insertions(+), 105 deletions(-) delete mode 100644 app/src/main/java/rkr/simplekeyboard/inputmethod/keyboard/SetupActivity.java diff --git a/app/build.gradle b/app/build.gradle index de07e1f32..5922f2e64 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -7,8 +7,8 @@ android { applicationId "rkr.simplekeyboard.inputmethod" minSdkVersion 19 targetSdkVersion 29 - versionCode 66 - versionName "3.16" + versionCode 67 + versionName "3.17" } buildTypes { release { diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index cd1a29687..e72bb817f 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -24,16 +24,6 @@ android:icon="@drawable/ic_launcher_keyboard" android:label="@string/english_ime_name" android:supportsRtl="true"> - - - - - - - + diff --git a/app/src/main/java/rkr/simplekeyboard/inputmethod/keyboard/SetupActivity.java b/app/src/main/java/rkr/simplekeyboard/inputmethod/keyboard/SetupActivity.java deleted file mode 100644 index 25c342b24..000000000 --- a/app/src/main/java/rkr/simplekeyboard/inputmethod/keyboard/SetupActivity.java +++ /dev/null @@ -1,53 +0,0 @@ -package rkr.simplekeyboard.inputmethod.keyboard; - -import android.app.AlertDialog; -import android.content.Context; -import android.content.DialogInterface; -import android.content.Intent; -import android.util.Log; -import android.view.inputmethod.InputMethodManager; - -import rkr.simplekeyboard.inputmethod.R; -import rkr.simplekeyboard.inputmethod.latin.RichInputMethodManager; -import rkr.simplekeyboard.inputmethod.latin.settings.SettingsActivity; - -public class SetupActivity extends SettingsActivity { - private static final String TAG = SetupActivity.class.getSimpleName(); - - @Override - protected void onStart() { - super.onStart(); - - boolean enabled = false; - try { - InputMethodManager immService = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); - RichInputMethodManager.InputMethodInfoCache inputMethodInfoCache = new RichInputMethodManager.InputMethodInfoCache(immService, getPackageName()); - enabled = inputMethodInfoCache.isInputMethodOfThisImeEnabled(); - } - catch (Exception e) { - Log.e(TAG, "Exception in check if input method is enabled", e); - } - - if (!enabled) { - final Context context = this; - AlertDialog.Builder builder = new AlertDialog.Builder(this); - builder.setMessage(R.string.setup_message); - builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int id) { - Intent intent = new Intent(android.provider.Settings.ACTION_INPUT_METHOD_SETTINGS); - intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - context.startActivity(intent); - dialog.dismiss(); - } - }); - builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int id) { - finish(); - } - }); - builder.setCancelable(false); - - builder.create().show(); - } - } -} diff --git a/app/src/main/java/rkr/simplekeyboard/inputmethod/latin/LatinIME.java b/app/src/main/java/rkr/simplekeyboard/inputmethod/latin/LatinIME.java index a6d4fc496..0ac50b8d1 100644 --- a/app/src/main/java/rkr/simplekeyboard/inputmethod/latin/LatinIME.java +++ b/app/src/main/java/rkr/simplekeyboard/inputmethod/latin/LatinIME.java @@ -1082,7 +1082,7 @@ public boolean shouldShowLanguageSwitchKey() { } private void setNavigationBarColor() { - if (Build.VERSION.SDK_INT > Build.VERSION_CODES.O && mSettings.getCurrent().mUseMatchingNavbarColor) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P && mSettings.getCurrent().mUseMatchingNavbarColor) { final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); final int keyboardColor = Settings.readKeyboardColor(prefs, this); final Window window = getWindow().getWindow(); @@ -1103,7 +1103,7 @@ private void setNavigationBarColor() { } private void clearNavigationBarColor() { - if (Build.VERSION.SDK_INT > Build.VERSION_CODES.O && mSettings.getCurrent().mUseMatchingNavbarColor) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P && mSettings.getCurrent().mUseMatchingNavbarColor) { final Window window = getWindow().getWindow(); if (window == null) { return; diff --git a/app/src/main/java/rkr/simplekeyboard/inputmethod/latin/settings/AdvancedSettingsFragment.java b/app/src/main/java/rkr/simplekeyboard/inputmethod/latin/settings/AdvancedSettingsFragment.java index dd8f3b505..32bf3b19c 100644 --- a/app/src/main/java/rkr/simplekeyboard/inputmethod/latin/settings/AdvancedSettingsFragment.java +++ b/app/src/main/java/rkr/simplekeyboard/inputmethod/latin/settings/AdvancedSettingsFragment.java @@ -16,10 +16,8 @@ package rkr.simplekeyboard.inputmethod.latin.settings; -import android.content.ComponentName; import android.content.Context; import android.content.SharedPreferences; -import android.content.pm.PackageManager; import android.content.res.Resources; import android.media.AudioManager; import android.os.Build; @@ -27,7 +25,6 @@ import rkr.simplekeyboard.inputmethod.R; import rkr.simplekeyboard.inputmethod.keyboard.KeyboardLayoutSet; -import rkr.simplekeyboard.inputmethod.keyboard.SetupActivity; import rkr.simplekeyboard.inputmethod.latin.AudioAndHapticFeedbackManager; /** @@ -57,7 +54,7 @@ public void onCreate(final Bundle icicle) { if (!AudioAndHapticFeedbackManager.getInstance().hasVibrator()) { removePreference(Settings.PREF_VIBRATION_DURATION_SETTINGS); } - if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.O) { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) { removePreference(Settings.PREF_MATCHING_NAVBAR_COLOR); } @@ -75,13 +72,6 @@ public void onSharedPreferenceChanged(final SharedPreferences prefs, final Strin key.equals(Settings.PREF_SHOW_NUMBER_ROW)) KeyboardLayoutSet.onKeyboardThemeChanged(); - if (key.equals(Settings.PREF_HIDE_LAUNCHER)) { - int targetState = prefs.getBoolean(Settings.PREF_HIDE_LAUNCHER, false) ? PackageManager.COMPONENT_ENABLED_STATE_DISABLED : PackageManager.COMPONENT_ENABLED_STATE_ENABLED; - PackageManager packageManager = getActivity().getPackageManager(); - ComponentName componentName = new ComponentName(getActivity(), SetupActivity.class); - packageManager.setComponentEnabledSetting(componentName, targetState, PackageManager.DONT_KILL_APP); - } - refreshEnablingsOfKeypressSoundAndVibrationSettings(); } diff --git a/app/src/main/java/rkr/simplekeyboard/inputmethod/latin/settings/Settings.java b/app/src/main/java/rkr/simplekeyboard/inputmethod/latin/settings/Settings.java index 8b51b33d7..d8ddcbfcb 100644 --- a/app/src/main/java/rkr/simplekeyboard/inputmethod/latin/settings/Settings.java +++ b/app/src/main/java/rkr/simplekeyboard/inputmethod/latin/settings/Settings.java @@ -60,7 +60,6 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang public static final String PREF_SPACE_SWIPE = "pref_space_swipe"; public static final String PREF_DELETE_SWIPE = "pref_delete_swipe"; public static final String PREF_MATCHING_NAVBAR_COLOR = "pref_matching_navbar_color"; - public static final String PREF_HIDE_LAUNCHER = "pref_hide_launcher"; private static final float UNDEFINED_PREFERENCE_VALUE_FLOAT = -1.0f; private static final int UNDEFINED_PREFERENCE_VALUE_INT = -1; diff --git a/app/src/main/java/rkr/simplekeyboard/inputmethod/latin/settings/SettingsActivity.java b/app/src/main/java/rkr/simplekeyboard/inputmethod/latin/settings/SettingsActivity.java index 3c8958f5d..547b7ea6f 100644 --- a/app/src/main/java/rkr/simplekeyboard/inputmethod/latin/settings/SettingsActivity.java +++ b/app/src/main/java/rkr/simplekeyboard/inputmethod/latin/settings/SettingsActivity.java @@ -17,20 +17,59 @@ package rkr.simplekeyboard.inputmethod.latin.settings; import android.app.ActionBar; -import android.content.ComponentName; +import android.app.AlertDialog; +import android.content.Context; +import android.content.DialogInterface; import android.content.Intent; -import android.content.SharedPreferences; -import android.content.pm.PackageManager; import android.os.Bundle; import android.preference.PreferenceActivity; -import android.preference.PreferenceManager; +import android.util.Log; import android.view.MenuItem; +import android.view.inputmethod.InputMethodManager; -import rkr.simplekeyboard.inputmethod.keyboard.SetupActivity; +import rkr.simplekeyboard.inputmethod.R; +import rkr.simplekeyboard.inputmethod.latin.RichInputMethodManager; import rkr.simplekeyboard.inputmethod.latin.utils.FragmentUtils; public class SettingsActivity extends PreferenceActivity { private static final String DEFAULT_FRAGMENT = SettingsFragment.class.getName(); + private static final String TAG = SettingsActivity.class.getSimpleName(); + + @Override + protected void onStart() { + super.onStart(); + + boolean enabled = false; + try { + InputMethodManager immService = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); + RichInputMethodManager.InputMethodInfoCache inputMethodInfoCache = new RichInputMethodManager.InputMethodInfoCache(immService, getPackageName()); + enabled = inputMethodInfoCache.isInputMethodOfThisImeEnabled(); + } catch (Exception e) { + Log.e(TAG, "Exception in check if input method is enabled", e); + } + + if (!enabled) { + final Context context = this; + AlertDialog.Builder builder = new AlertDialog.Builder(this); + builder.setMessage(R.string.setup_message); + builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + Intent intent = new Intent(android.provider.Settings.ACTION_INPUT_METHOD_SETTINGS); + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + context.startActivity(intent); + dialog.dismiss(); + } + }); + builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + finish(); + } + }); + builder.setCancelable(false); + + builder.create().show(); + } + } @Override protected void onCreate(final Bundle savedState) { @@ -40,13 +79,6 @@ protected void onCreate(final Bundle savedState) { actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setHomeButtonEnabled(true); } - - PackageManager packageManager = getPackageManager(); - ComponentName componentName = new ComponentName(this, SetupActivity.class); - boolean hideLauncher = packageManager.getComponentEnabledSetting(componentName) == PackageManager.COMPONENT_ENABLED_STATE_DISABLED; - SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); - if (prefs.getBoolean(Settings.PREF_HIDE_LAUNCHER, false) != hideLauncher) - prefs.edit().putBoolean(Settings.PREF_HIDE_LAUNCHER, hideLauncher).apply(); } @Override diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 77aa542b4..340669b07 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -65,5 +65,4 @@ Durch Wischen löschen Passende Farbe der Navigationsleiste verwenden Simple Keyboard ist nicht aktiviert. Klicken Sie auf OK, um die Sprache & Eingabe Einstellungen zu öffnen. Sie müssen Simple Keyboard in Ihrer aktuellen Tastatur auswählen, um sie zu verwenden. - App-Icon ausblenden diff --git a/app/src/main/res/values-el/strings.xml b/app/src/main/res/values-el/strings.xml index 21c2145c5..2934f5105 100644 --- a/app/src/main/res/values-el/strings.xml +++ b/app/src/main/res/values-el/strings.xml @@ -65,5 +65,4 @@ Αφαίρεση της ολίσθησης Χρήση αντίστοιχου χρώματος γραμμής πλοήγησης Το Simple Keyboard δεν είναι ενεργοποιημένο. Πατήστε OK για να ανοίξετε τις ρυθμίσεις Γλώσσας & Εισαγωγής. Θα πρέπει να επιλέξετε το Simple Keyboard ως τρέχον πληκτρολόγιο ώστε να μπορείτε να το χρησιμοποιήσετε. - Απόκρυψη εικονιδίου εκκινητή diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 37230de48..af4738f18 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -65,5 +65,4 @@ Eliminar deslizar Usar el color correspondiente de la barra de navegación Simple Keyboard no está habilitado. Haga clic en OK para abrir Idiomas & Ajustes de entrada. Necesitará seleccionar Simple Keyboard en su teclado actual para usarlo. - Ocultar icono diff --git a/app/src/main/res/values-eu-rES/strings.xml b/app/src/main/res/values-eu-rES/strings.xml index 6b130ac35..afe5bc1a2 100644 --- a/app/src/main/res/values-eu-rES/strings.xml +++ b/app/src/main/res/values-eu-rES/strings.xml @@ -65,5 +65,4 @@ Ezabatzeko keinua Erabili bat datorren nabigazio-barraren kolorea Simple Keyboard gaitu gabe dago. Sakatu Ados Hizkuntzak eta idazketa ezarpenak irekitzeko. Simple Keyboard aukeratu behar duzu uneko teklatu gisa hau erabili ahal izateko. - Ezkutatu abiarazlearen ikonoa diff --git a/app/src/main/res/values-in/strings.xml b/app/src/main/res/values-in/strings.xml index b13557b2d..f56c87799 100644 --- a/app/src/main/res/values-in/strings.xml +++ b/app/src/main/res/values-in/strings.xml @@ -65,5 +65,4 @@ Hapus dengan menggeser Samakan dengan warna bilah navigasi Simple Keyboard belum diaktifkan. Klik OKE untuk membuka setelan Bahasa & Masukan. Anda perlu memilih Simple Keyboard di dalam setelan keyboard untuk menggunakannya. - Sembunyikan ikon peluncur diff --git a/app/src/main/res/values-lt/strings.xml b/app/src/main/res/values-lt/strings.xml index e1304a4dc..e9a423506 100644 --- a/app/src/main/res/values-lt/strings.xml +++ b/app/src/main/res/values-lt/strings.xml @@ -65,5 +65,4 @@ Trynimo klavišo braukimas Atitinkama navigacijos juostos spalva Simple Keyboard yra neįgalinta. Spauskite OK kad atidaryti Kalbos ir įvestis nustatymus. Simple Keyboard galėsite pasirinkti dabartinėje klaviatūroje. - Slėpti darbastalio ikoną diff --git a/app/src/main/res/values-nb/strings.xml b/app/src/main/res/values-nb/strings.xml index 03d694e2f..7c6b9a386 100644 --- a/app/src/main/res/values-nb/strings.xml +++ b/app/src/main/res/values-nb/strings.xml @@ -65,5 +65,4 @@ Slette-sveip Bruk matchende navigasjonslinjefarge Simple Keyboard er ikke aktivert. Trykk OK for å åpne innstillinger for Språk og inndata. Du må velge Simple Keyboard som standardtastatur for å bruke det. - Skjul app-ikon diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml index 285208349..d8d2a2654 100644 --- a/app/src/main/res/values-tr/strings.xml +++ b/app/src/main/res/values-tr/strings.xml @@ -65,5 +65,4 @@ Sil tuşu kaydırması Eşleşen gezinti çubuğu rengini kullan Simple Keyboard etkin değil. Diller & Giriş ayarlarını açmak için Tamam\'ı tıklayın. Kullanmak için geçerli klavyenizde Simple Keyboard\'u seçmeniz gerekmektedir. - Başlatıcı simgesini gizle diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d128f6260..7f9b5c930 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -224,7 +224,6 @@ mobile devices. [CHAR LIMIT=25] --> Delete swipe Use matching navigation bar color Simple Keyboard is not enabled. Click OK to open Languages & Input settings. You will need to select Simple Keyboard in your current keyboard to use it. - Hide launcher icon diff --git a/app/src/main/res/xml/prefs_screen_advanced.xml b/app/src/main/res/xml/prefs_screen_advanced.xml index 21ef9b8c8..59a6538f5 100644 --- a/app/src/main/res/xml/prefs_screen_advanced.xml +++ b/app/src/main/res/xml/prefs_screen_advanced.xml @@ -42,10 +42,6 @@ -