diff options
| author | Jules Aguillon | 2024-02-10 17:33:42 +0100 |
|---|---|---|
| committer | Jules Aguillon | 2024-02-10 17:33:42 +0100 |
| commit | d5676d683f031a2d23f4e01e0ada0afd58dc9b89 (patch) | |
| tree | 983cebb866b28e1c6352b2bf639cf82432221484 /srcs/juloo.keyboard2 | |
| parent | 332413ed3c34b6e4021c3bad97625704edb8b5c6 (diff) | |
| download | unexpected-keyboard-d5676d683f031a2d23f4e01e0ada0afd58dc9b89.tar.gz unexpected-keyboard-d5676d683f031a2d23f4e01e0ada0afd58dc9b89.zip | |
Fix compatibility with Android 3.0
Incompatible APIs were used in the custom layouts and the extra keys
options.
Add @TargetApi annotations to help catch similar issues in the future
with the help of 'gradle lint'.
Diffstat (limited to 'srcs/juloo.keyboard2')
| -rw-r--r-- | srcs/juloo.keyboard2/DirectBootAwarePreferences.java | 2 | ||||
| -rw-r--r-- | srcs/juloo.keyboard2/Keyboard2.java | 3 | ||||
| -rw-r--r-- | srcs/juloo.keyboard2/LauncherActivity.java | 4 | ||||
| -rw-r--r-- | srcs/juloo.keyboard2/prefs/CustomExtraKeysPreference.java | 2 | ||||
| -rw-r--r-- | srcs/juloo.keyboard2/prefs/LayoutsPreference.java | 3 |
5 files changed, 11 insertions, 3 deletions
diff --git a/srcs/juloo.keyboard2/DirectBootAwarePreferences.java b/srcs/juloo.keyboard2/DirectBootAwarePreferences.java index 372e159..fcc67c6 100644 --- a/srcs/juloo.keyboard2/DirectBootAwarePreferences.java +++ b/srcs/juloo.keyboard2/DirectBootAwarePreferences.java @@ -1,5 +1,6 @@ package juloo.keyboard2; +import android.annotation.TargetApi; import android.content.Context; import android.content.SharedPreferences; import android.os.Build.VERSION; @@ -7,6 +8,7 @@ import android.preference.PreferenceManager; import java.util.Map; import java.util.Set; +@TargetApi(24) public final class DirectBootAwarePreferences { /* On API >= 24, preferences are read from the device protected storage. This diff --git a/srcs/juloo.keyboard2/Keyboard2.java b/srcs/juloo.keyboard2/Keyboard2.java index 0f46a13..6440c7d 100644 --- a/srcs/juloo.keyboard2/Keyboard2.java +++ b/srcs/juloo.keyboard2/Keyboard2.java @@ -1,5 +1,6 @@ package juloo.keyboard2; +import android.annotation.TargetApi; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; @@ -118,6 +119,7 @@ public class Keyboard2 extends InputMethodService return Arrays.asList(); } + @TargetApi(12) private ExtraKeys extra_keys_of_subtype(InputMethodSubtype subtype) { String extra_keys = subtype.getExtraValueOf("extra_keys"); @@ -127,6 +129,7 @@ public class Keyboard2 extends InputMethodService return ExtraKeys.EMPTY; } + @TargetApi(12) private void refreshAccentsOption(InputMethodManager imm, InputMethodSubtype subtype) { List<InputMethodSubtype> enabled_subtypes = getEnabledSubtypes(imm); diff --git a/srcs/juloo.keyboard2/LauncherActivity.java b/srcs/juloo.keyboard2/LauncherActivity.java index b8906b5..7b82d21 100644 --- a/srcs/juloo.keyboard2/LauncherActivity.java +++ b/srcs/juloo.keyboard2/LauncherActivity.java @@ -1,5 +1,6 @@ package juloo.keyboard2; +import android.annotation.TargetApi; import android.app.Activity; import android.content.Intent; import android.media.AudioManager; @@ -31,7 +32,7 @@ public class LauncherActivity extends Activity _intro_video = (VideoView)findViewById(R.id.launcher_intro_video); _tryhere_text = (TextView)findViewById(R.id.launcher_tryhere_text); _tryhere_area = (EditText)findViewById(R.id.launcher_tryhere_area); - if (VERSION.SDK_INT > 28) + if (VERSION.SDK_INT >= 28) _tryhere_area.addOnUnhandledKeyEventListener( this.new Tryhere_OnUnhandledKeyEventListener()); setup_intro_video(_intro_video); @@ -76,6 +77,7 @@ public class LauncherActivity extends Activity v.start(); } + @TargetApi(28) final class Tryhere_OnUnhandledKeyEventListener implements View.OnUnhandledKeyEventListener { public boolean onUnhandledKeyEvent(View v, KeyEvent ev) diff --git a/srcs/juloo.keyboard2/prefs/CustomExtraKeysPreference.java b/srcs/juloo.keyboard2/prefs/CustomExtraKeysPreference.java index 9d8395f..cf47d46 100644 --- a/srcs/juloo.keyboard2/prefs/CustomExtraKeysPreference.java +++ b/srcs/juloo.keyboard2/prefs/CustomExtraKeysPreference.java @@ -51,7 +51,7 @@ public class CustomExtraKeysPreference extends ListGroupPreference<String> void select(final SelectionCallback<String> callback) { new AlertDialog.Builder(getContext()) - .setView(R.layout.dialog_edit_text) + .setView(View.inflate(getContext(), R.layout.dialog_edit_text, null)) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener(){ public void onClick(DialogInterface dialog, int which) { diff --git a/srcs/juloo.keyboard2/prefs/LayoutsPreference.java b/srcs/juloo.keyboard2/prefs/LayoutsPreference.java index 842a2f2..c1a863f 100644 --- a/srcs/juloo.keyboard2/prefs/LayoutsPreference.java +++ b/srcs/juloo.keyboard2/prefs/LayoutsPreference.java @@ -7,6 +7,7 @@ import android.content.SharedPreferences; import android.content.res.Resources; import android.content.res.TypedArray; import android.util.AttributeSet; +import android.view.View; import android.widget.ArrayAdapter; import java.util.ArrayList; import java.util.Arrays; @@ -149,7 +150,7 @@ public class LayoutsPreference extends ListGroupPreference<LayoutsPreference.Lay { ArrayAdapter layouts = new ArrayAdapter(getContext(), android.R.layout.simple_list_item_1, _layout_display_names); new AlertDialog.Builder(getContext()) - .setView(R.layout.dialog_edit_text) + .setView(View.inflate(getContext(), R.layout.dialog_edit_text, null)) .setAdapter(layouts, new DialogInterface.OnClickListener(){ public void onClick(DialogInterface _dialog, int which) { |
