mirror of
https://github.com/Julow/Unexpected-Keyboard.git
synced 2024-11-28 02:03:27 +01:00
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'.
This commit is contained in:
parent
332413ed3c
commit
d5676d683f
@ -1,5 +1,6 @@
|
|||||||
package juloo.keyboard2;
|
package juloo.keyboard2;
|
||||||
|
|
||||||
|
import android.annotation.TargetApi;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Build.VERSION;
|
import android.os.Build.VERSION;
|
||||||
@ -7,6 +8,7 @@ import android.preference.PreferenceManager;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
@TargetApi(24)
|
||||||
public final class DirectBootAwarePreferences
|
public final class DirectBootAwarePreferences
|
||||||
{
|
{
|
||||||
/* On API >= 24, preferences are read from the device protected storage. This
|
/* On API >= 24, preferences are read from the device protected storage. This
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package juloo.keyboard2;
|
package juloo.keyboard2;
|
||||||
|
|
||||||
|
import android.annotation.TargetApi;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
@ -118,6 +119,7 @@ public class Keyboard2 extends InputMethodService
|
|||||||
return Arrays.asList();
|
return Arrays.asList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TargetApi(12)
|
||||||
private ExtraKeys extra_keys_of_subtype(InputMethodSubtype subtype)
|
private ExtraKeys extra_keys_of_subtype(InputMethodSubtype subtype)
|
||||||
{
|
{
|
||||||
String extra_keys = subtype.getExtraValueOf("extra_keys");
|
String extra_keys = subtype.getExtraValueOf("extra_keys");
|
||||||
@ -127,6 +129,7 @@ public class Keyboard2 extends InputMethodService
|
|||||||
return ExtraKeys.EMPTY;
|
return ExtraKeys.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TargetApi(12)
|
||||||
private void refreshAccentsOption(InputMethodManager imm, InputMethodSubtype subtype)
|
private void refreshAccentsOption(InputMethodManager imm, InputMethodSubtype subtype)
|
||||||
{
|
{
|
||||||
List<InputMethodSubtype> enabled_subtypes = getEnabledSubtypes(imm);
|
List<InputMethodSubtype> enabled_subtypes = getEnabledSubtypes(imm);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package juloo.keyboard2;
|
package juloo.keyboard2;
|
||||||
|
|
||||||
|
import android.annotation.TargetApi;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.media.AudioManager;
|
import android.media.AudioManager;
|
||||||
@ -31,7 +32,7 @@ public class LauncherActivity extends Activity
|
|||||||
_intro_video = (VideoView)findViewById(R.id.launcher_intro_video);
|
_intro_video = (VideoView)findViewById(R.id.launcher_intro_video);
|
||||||
_tryhere_text = (TextView)findViewById(R.id.launcher_tryhere_text);
|
_tryhere_text = (TextView)findViewById(R.id.launcher_tryhere_text);
|
||||||
_tryhere_area = (EditText)findViewById(R.id.launcher_tryhere_area);
|
_tryhere_area = (EditText)findViewById(R.id.launcher_tryhere_area);
|
||||||
if (VERSION.SDK_INT > 28)
|
if (VERSION.SDK_INT >= 28)
|
||||||
_tryhere_area.addOnUnhandledKeyEventListener(
|
_tryhere_area.addOnUnhandledKeyEventListener(
|
||||||
this.new Tryhere_OnUnhandledKeyEventListener());
|
this.new Tryhere_OnUnhandledKeyEventListener());
|
||||||
setup_intro_video(_intro_video);
|
setup_intro_video(_intro_video);
|
||||||
@ -76,6 +77,7 @@ public class LauncherActivity extends Activity
|
|||||||
v.start();
|
v.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TargetApi(28)
|
||||||
final class Tryhere_OnUnhandledKeyEventListener implements View.OnUnhandledKeyEventListener
|
final class Tryhere_OnUnhandledKeyEventListener implements View.OnUnhandledKeyEventListener
|
||||||
{
|
{
|
||||||
public boolean onUnhandledKeyEvent(View v, KeyEvent ev)
|
public boolean onUnhandledKeyEvent(View v, KeyEvent ev)
|
||||||
|
@ -51,7 +51,7 @@ public class CustomExtraKeysPreference extends ListGroupPreference<String>
|
|||||||
void select(final SelectionCallback<String> callback)
|
void select(final SelectionCallback<String> callback)
|
||||||
{
|
{
|
||||||
new AlertDialog.Builder(getContext())
|
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(){
|
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener(){
|
||||||
public void onClick(DialogInterface dialog, int which)
|
public void onClick(DialogInterface dialog, int which)
|
||||||
{
|
{
|
||||||
|
@ -7,6 +7,7 @@ import android.content.SharedPreferences;
|
|||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
import android.view.View;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
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);
|
ArrayAdapter layouts = new ArrayAdapter(getContext(), android.R.layout.simple_list_item_1, _layout_display_names);
|
||||||
new AlertDialog.Builder(getContext())
|
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(){
|
.setAdapter(layouts, new DialogInterface.OnClickListener(){
|
||||||
public void onClick(DialogInterface _dialog, int which)
|
public void onClick(DialogInterface _dialog, int which)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user