Skip to content

Commit

Permalink
Don't hide launcher icon (Android 10 policy)
Browse files Browse the repository at this point in the history
  • Loading branch information
rkkr committed Dec 22, 2019
1 parent bf61443 commit 1b85189
Show file tree
Hide file tree
Showing 17 changed files with 51 additions and 105 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
13 changes: 2 additions & 11 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,6 @@
android:icon="@drawable/ic_launcher_keyboard"
android:label="@string/english_ime_name"
android:supportsRtl="true">
<activity
android:name=".keyboard.SetupActivity"
android:label="@string/english_ime_name"
android:theme="@style/platformSettingsTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- Services -->
<service
android:name=".latin.LatinIME"
Expand All @@ -50,10 +40,11 @@

<activity
android:name=".latin.settings.SettingsActivity"
android:label="@string/english_ime_settings"
android:label="@string/english_ime_name"
android:theme="@style/platformSettingsTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity> <!-- Broadcast receivers -->
<receiver android:name=".latin.SystemBroadcastReceiver">
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,15 @@

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;
import android.os.Bundle;

import rkr.simplekeyboard.inputmethod.R;
import rkr.simplekeyboard.inputmethod.keyboard.KeyboardLayoutSet;
import rkr.simplekeyboard.inputmethod.keyboard.SetupActivity;
import rkr.simplekeyboard.inputmethod.latin.AudioAndHapticFeedbackManager;

/**
Expand Down Expand Up @@ -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);
}

Expand All @@ -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();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,4 @@
<string name="delete_swipe">Durch Wischen löschen</string>
<string name="matching_navbar_color">Passende Farbe der Navigationsleiste verwenden</string>
<string name="setup_message">Simple Keyboard ist nicht aktiviert. Klicken Sie auf OK, um die Sprache &amp; Eingabe Einstellungen zu öffnen. Sie müssen Simple Keyboard in Ihrer aktuellen Tastatur auswählen, um sie zu verwenden.</string>
<string name="hide_launcher">App-Icon ausblenden</string>
</resources>
1 change: 0 additions & 1 deletion app/src/main/res/values-el/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,4 @@
<string name="delete_swipe">Αφαίρεση της ολίσθησης</string>
<string name="matching_navbar_color">Χρήση αντίστοιχου χρώματος γραμμής πλοήγησης</string>
<string name="setup_message">Το Simple Keyboard δεν είναι ενεργοποιημένο. Πατήστε OK για να ανοίξετε τις ρυθμίσεις Γλώσσας &amp; Εισαγωγής. Θα πρέπει να επιλέξετε το Simple Keyboard ως τρέχον πληκτρολόγιο ώστε να μπορείτε να το χρησιμοποιήσετε.</string>
<string name="hide_launcher">Απόκρυψη εικονιδίου εκκινητή</string>
</resources>
1 change: 0 additions & 1 deletion app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,4 @@
<string name="delete_swipe">Eliminar deslizar</string>
<string name="matching_navbar_color">Usar el color correspondiente de la barra de navegación</string>
<string name="setup_message">Simple Keyboard no está habilitado. Haga clic en OK para abrir Idiomas &amp; Ajustes de entrada. Necesitará seleccionar Simple Keyboard en su teclado actual para usarlo.</string>
<string name="hide_launcher">Ocultar icono</string>
</resources>
1 change: 0 additions & 1 deletion app/src/main/res/values-eu-rES/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,4 @@
<string name="delete_swipe">Ezabatzeko keinua</string>
<string name="matching_navbar_color">Erabili bat datorren nabigazio-barraren kolorea</string>
<string name="setup_message">Simple Keyboard gaitu gabe dago. Sakatu Ados Hizkuntzak eta idazketa ezarpenak irekitzeko. Simple Keyboard aukeratu behar duzu uneko teklatu gisa hau erabili ahal izateko.</string>
<string name="hide_launcher">Ezkutatu abiarazlearen ikonoa</string>
</resources>
1 change: 0 additions & 1 deletion app/src/main/res/values-in/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,4 @@
<string name="delete_swipe">Hapus dengan menggeser</string>
<string name="matching_navbar_color">Samakan dengan warna bilah navigasi</string>
<string name="setup_message">Simple Keyboard belum diaktifkan. Klik OKE untuk membuka setelan Bahasa &amp; Masukan. Anda perlu memilih Simple Keyboard di dalam setelan keyboard untuk menggunakannya.</string>
<string name="hide_launcher">Sembunyikan ikon peluncur</string>
</resources>
1 change: 0 additions & 1 deletion app/src/main/res/values-lt/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,4 @@
<string name="delete_swipe">Trynimo klavišo braukimas</string>
<string name="matching_navbar_color">Atitinkama navigacijos juostos spalva</string>
<string name="setup_message">Simple Keyboard yra neįgalinta. Spauskite OK kad atidaryti Kalbos ir įvestis nustatymus. Simple Keyboard galėsite pasirinkti dabartinėje klaviatūroje.</string>
<string name="hide_launcher">Slėpti darbastalio ikoną</string>
</resources>
1 change: 0 additions & 1 deletion app/src/main/res/values-nb/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,4 @@
<string name="delete_swipe">Slette-sveip</string>
<string name="matching_navbar_color">Bruk matchende navigasjonslinjefarge</string>
<string name="setup_message">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.</string>
<string name="hide_launcher">Skjul app-ikon</string>
</resources>
1 change: 0 additions & 1 deletion app/src/main/res/values-tr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,4 @@
<string name="delete_swipe">Sil tuşu kaydırması</string>
<string name="matching_navbar_color">Eşleşen gezinti çubuğu rengini kullan</string>
<string name="setup_message">Simple Keyboard etkin değil. Diller &amp; Giriş ayarlarını açmak için Tamam\'ı tıklayın. Kullanmak için geçerli klavyenizde Simple Keyboard\'u seçmeniz gerekmektedir.</string>
<string name="hide_launcher">Başlatıcı simgesini gizle</string>
</resources>
1 change: 0 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ mobile devices. [CHAR LIMIT=25] -->
<string name="delete_swipe">Delete swipe</string>
<string name="matching_navbar_color">Use matching navigation bar color</string>
<string name="setup_message">Simple Keyboard is not enabled. Click OK to open Languages &amp; Input settings. You will need to select Simple Keyboard in your current keyboard to use it.</string>
<string name="hide_launcher">Hide launcher icon</string>

<!-- Standard message to dismiss a dialog box -->
<!-- Title of the button in a dialog box. The button takes the user to the keyboard settings. [CHAR LIMIT=15] -->
Expand Down
4 changes: 0 additions & 4 deletions app/src/main/res/xml/prefs_screen_advanced.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@
<rkr.simplekeyboard.inputmethod.latin.settings.ColorDialogPreference
android:key="pref_keyboard_color"
android:title="@string/keyboard_color" />
<CheckBoxPreference
android:key="pref_hide_launcher"
android:title="@string/hide_launcher"
android:defaultValue="false" />
<CheckBoxPreference
android:key="pref_matching_navbar_color"
android:title="@string/matching_navbar_color"
Expand Down

0 comments on commit 1b85189

Please sign in to comment.