diff --git a/leankeykeyboard/src/main/AndroidManifest.xml b/leankeykeyboard/src/main/AndroidManifest.xml
index 5d7a107..a119a5e 100644
--- a/leankeykeyboard/src/main/AndroidManifest.xml
+++ b/leankeykeyboard/src/main/AndroidManifest.xml
@@ -33,7 +33,7 @@
android:theme="@style/Theme.Leanback">
@@ -43,6 +43,10 @@
+
+
diff --git a/leankeykeyboard/src/main/java/com/liskovsoft/leankeyboard/activity/settings/KbSettingsActivity2.java b/leankeykeyboard/src/main/java/com/liskovsoft/leankeyboard/activity/settings/KbSettingsActivity2.java
new file mode 100644
index 0000000..afbfa2b
--- /dev/null
+++ b/leankeykeyboard/src/main/java/com/liskovsoft/leankeyboard/activity/settings/KbSettingsActivity2.java
@@ -0,0 +1,4 @@
+package com.liskovsoft.leankeyboard.activity.settings;
+
+public class KbSettingsActivity2 extends KbSettingsActivity {
+}
diff --git a/leankeykeyboard/src/main/java/com/liskovsoft/leankeyboard/fragments/settings/MiscFragment.java b/leankeykeyboard/src/main/java/com/liskovsoft/leankeyboard/fragments/settings/MiscFragment.java
index 7722e6c..92a0fdf 100644
--- a/leankeykeyboard/src/main/java/com/liskovsoft/leankeyboard/fragments/settings/MiscFragment.java
+++ b/leankeykeyboard/src/main/java/com/liskovsoft/leankeyboard/fragments/settings/MiscFragment.java
@@ -1,24 +1,33 @@
package com.liskovsoft.leankeyboard.fragments.settings;
+import android.app.Activity;
+import android.content.ComponentName;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;
import androidx.leanback.widget.GuidanceStylist.Guidance;
+import com.liskovsoft.leankeyboard.activity.settings.KbSettingsActivity;
+import com.liskovsoft.leankeyboard.activity.settings.KbSettingsActivity2;
+import com.liskovsoft.leankeyboard.helpers.Helpers;
import com.liskovsoft.leankeyboard.utils.LeanKeySettings;
import com.liskovsoft.leankeykeyboard.R;
public class MiscFragment extends BaseSettingsFragment {
private LeanKeySettings mPrefs;
+ private Context mContext;
@Override
public void onAttach(Context context) {
super.onAttach(context);
+ mContext = context;
mPrefs = LeanKeySettings.instance(getActivity());
addCheckedAction(R.string.keep_on_screen, R.string.keep_on_screen_desc, mPrefs::getForceShowKeyboard, mPrefs::setForceShowKeyboard);
addCheckedAction(R.string.increase_kbd_size, R.string.increase_kbd_size_desc, mPrefs::getEnlargeKeyboard, mPrefs::setEnlargeKeyboard);
+ addCheckedAction(R.string.enable_suggestions, R.string.enable_suggestions_desc, mPrefs::getSuggestionsEnabled, mPrefs::setSuggestionsEnabled);
+ addCheckedAction(R.string.show_launcher_icon, R.string.show_launcher_icon_desc, this::getLauncherIconShown, this::setLauncherIconShown);
}
@NonNull
@@ -35,4 +44,12 @@ public class MiscFragment extends BaseSettingsFragment {
icon
);
}
+
+ private void setLauncherIconShown(boolean shown) {
+ Helpers.setLauncherIconShown(mContext, KbSettingsActivity2.class, shown);
+ }
+
+ private boolean getLauncherIconShown() {
+ return Helpers.getLauncherIconShown(mContext, KbSettingsActivity2.class);
+ }
}
diff --git a/leankeykeyboard/src/main/java/com/liskovsoft/leankeyboard/helpers/Helpers.java b/leankeykeyboard/src/main/java/com/liskovsoft/leankeyboard/helpers/Helpers.java
index e00c285..a2f69b2 100644
--- a/leankeykeyboard/src/main/java/com/liskovsoft/leankeyboard/helpers/Helpers.java
+++ b/leankeykeyboard/src/main/java/com/liskovsoft/leankeyboard/helpers/Helpers.java
@@ -1,5 +1,6 @@
package com.liskovsoft.leankeyboard.helpers;
+import android.app.Activity;
import android.app.ActivityManager;
import android.content.ActivityNotFoundException;
import android.content.ComponentName;
@@ -11,6 +12,7 @@ import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
+import com.liskovsoft.leankeyboard.activity.settings.KbSettingsActivity;
import com.liskovsoft.leankeyboard.utils.LocaleUtility;
import java.io.ByteArrayInputStream;
@@ -224,4 +226,20 @@ public class Helpers {
return deviceName.contains("(vbox86p)");
}
+
+ public static void setLauncherIconShown(Context context, Class> activityClass, boolean shown) {
+ PackageManager pm = context.getPackageManager();
+ ComponentName component = new ComponentName(context, activityClass);
+ pm.setComponentEnabledSetting(
+ component,
+ shown ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED : PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
+ PackageManager.DONT_KILL_APP
+ );
+ }
+
+ public static boolean getLauncherIconShown(Context context, Class> activityClass) {
+ PackageManager pm = context.getPackageManager();
+ ComponentName component = new ComponentName(context, activityClass);
+ return pm.getComponentEnabledSetting(component) != PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
+ }
}
diff --git a/leankeykeyboard/src/main/java/com/liskovsoft/leankeyboard/ime/LeanbackImeService.java b/leankeykeyboard/src/main/java/com/liskovsoft/leankeyboard/ime/LeanbackImeService.java
index d40a5de..7f3951b 100644
--- a/leankeykeyboard/src/main/java/com/liskovsoft/leankeyboard/ime/LeanbackImeService.java
+++ b/leankeykeyboard/src/main/java/com/liskovsoft/leankeyboard/ime/LeanbackImeService.java
@@ -81,7 +81,12 @@ public class LeanbackImeService extends InputMethodService {
}
private void initSettings() {
- mForceShowKbd = LeanKeySettings.instance(this).getForceShowKeyboard();
+ LeanKeySettings prefs = LeanKeySettings.instance(this);
+ mForceShowKbd = prefs.getForceShowKeyboard();
+
+ if (mKeyboardController != null) {
+ mKeyboardController.setSuggestionsEnabled(prefs.getSuggestionsEnabled());
+ }
}
private void clearSuggestionsDelayed() {
diff --git a/leankeykeyboard/src/main/java/com/liskovsoft/leankeyboard/ime/LeanbackKeyboardContainer.java b/leankeykeyboard/src/main/java/com/liskovsoft/leankeyboard/ime/LeanbackKeyboardContainer.java
index b89e378..812a02f 100644
--- a/leankeykeyboard/src/main/java/com/liskovsoft/leankeyboard/ime/LeanbackKeyboardContainer.java
+++ b/leankeykeyboard/src/main/java/com/liskovsoft/leankeyboard/ime/LeanbackKeyboardContainer.java
@@ -113,6 +113,7 @@ public class LeanbackKeyboardContainer {
private View mSuggestionsBg;
private HorizontalScrollView mSuggestionsContainer;
private boolean mSuggestionsEnabled;
+ private boolean mForceDisableSuggestions;
private Keyboard mSymKeyboard;
private KeyFocus mTempKeyInfo = new KeyFocus();
private PointF mTempPoint = new PointF();
@@ -404,6 +405,10 @@ public class LeanbackKeyboardContainer {
// mCapCharacters = true;
//}
+ if (mForceDisableSuggestions) {
+ mSuggestionsEnabled = false;
+ }
+
if (info.privateImeOptions != null) {
if (info.privateImeOptions.contains(IME_PRIVATE_OPTIONS_ESCAPE_NORTH)) {
mEscapeNorthEnabled = true;
@@ -559,6 +564,11 @@ public class LeanbackKeyboardContainer {
return mSuggestionsEnabled;
}
+ public void setSuggestionsEnabled(boolean enabled) {
+ mSuggestionsEnabled = enabled;
+ mForceDisableSuggestions = !enabled;
+ }
+
public void cancelVoiceRecording() {
mVoiceAnimator.startExitAnimation();
}
diff --git a/leankeykeyboard/src/main/java/com/liskovsoft/leankeyboard/ime/LeanbackKeyboardController.java b/leankeykeyboard/src/main/java/com/liskovsoft/leankeyboard/ime/LeanbackKeyboardController.java
index 382dc4e..efc6462 100644
--- a/leankeykeyboard/src/main/java/com/liskovsoft/leankeyboard/ime/LeanbackKeyboardController.java
+++ b/leankeykeyboard/src/main/java/com/liskovsoft/leankeyboard/ime/LeanbackKeyboardController.java
@@ -621,6 +621,12 @@ public class LeanbackKeyboardController implements LeanbackKeyboardContainer.Voi
return mContainer != null && mContainer.areSuggestionsEnabled();
}
+ public void setSuggestionsEnabled(boolean enabled) {
+ if (mContainer != null) {
+ mContainer.setSuggestionsEnabled(enabled);
+ }
+ }
+
public boolean enableAutoEnterSpace() {
return mContainer != null && mContainer.enableAutoEnterSpace();
}
diff --git a/leankeykeyboard/src/main/java/com/liskovsoft/leankeyboard/utils/LeanKeySettings.java b/leankeykeyboard/src/main/java/com/liskovsoft/leankeyboard/utils/LeanKeySettings.java
index 67ef450..a189291 100644
--- a/leankeykeyboard/src/main/java/com/liskovsoft/leankeyboard/utils/LeanKeySettings.java
+++ b/leankeykeyboard/src/main/java/com/liskovsoft/leankeyboard/utils/LeanKeySettings.java
@@ -13,6 +13,7 @@ public final class LeanKeySettings {
private static final String KEYBOARD_THEME = "keyboardTheme";
public static final String DEFAULT_THEME_ID = "Default";
public static final String DARK_THEME_ID = "Dark";
+ private static final String SUGGESTIONS_ENABLED = "suggestionsEnabled";
private static LeanKeySettings sInstance;
private final Context mContext;
private SharedPreferences mPrefs;
@@ -87,4 +88,14 @@ public final class LeanKeySettings {
public String getCurrentTheme() {
return mPrefs.getString(KEYBOARD_THEME, DEFAULT_THEME_ID);
}
+
+ public void setSuggestionsEnabled(boolean enabled) {
+ mPrefs.edit()
+ .putBoolean(SUGGESTIONS_ENABLED, enabled)
+ .apply();
+ }
+
+ public boolean getSuggestionsEnabled() {
+ return mPrefs.getBoolean(SUGGESTIONS_ENABLED, true);
+ }
}
diff --git a/leankeykeyboard/src/main/res/values-ru/strings.xml b/leankeykeyboard/src/main/res/values-ru/strings.xml
index 8875470..485d540 100644
--- a/leankeykeyboard/src/main/res/values-ru/strings.xml
+++ b/leankeykeyboard/src/main/res/values-ru/strings.xml
@@ -44,4 +44,8 @@
Тема
Тема клавиатуры
Выбрать тему
+ Отображать подсказки
+ Отображать ряд с подсказками при вводе
+ Отображать иконку
+ Отображать иконку лаунчера
diff --git a/leankeykeyboard/src/main/res/values/strings.xml b/leankeykeyboard/src/main/res/values/strings.xml
index 2aef660..30f458e 100644
--- a/leankeykeyboard/src/main/res/values/strings.xml
+++ b/leankeykeyboard/src/main/res/values/strings.xml
@@ -55,4 +55,8 @@
Theme
Keyboard Theme
Change Theme
+ Enable suggestions
+ Enable suggestions row
+ Show icon
+ Show launcher icon