mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-02 17:03:13 +00:00
ANDROID: Raise targetsdk to 29 but make use of requestLegacyExternalStorage
Also some fixes for deprecated warnings
This commit is contained in:
parent
6000a0b472
commit
0de952a59c
@ -49,6 +49,7 @@ import android.widget.PopupWindow;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.core.content.res.ResourcesCompat;
|
||||||
|
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@ -127,7 +128,7 @@ public class CustomKeyboardView extends View implements View.OnClickListener {
|
|||||||
private static final boolean DEBUG = false;
|
private static final boolean DEBUG = false;
|
||||||
private static final int NOT_A_KEY = -1;
|
private static final int NOT_A_KEY = -1;
|
||||||
private static final int[] KEY_DELETE = { CustomKeyboard.KEYCODE_DELETE };
|
private static final int[] KEY_DELETE = { CustomKeyboard.KEYCODE_DELETE };
|
||||||
private static final int[] LONG_PRESSABLE_STATE_SET = { android.R.attr.state_long_pressable };
|
private static final int[] LONG_PRESSABLE_STATE_SET = { R.attr.state_long_pressable };
|
||||||
|
|
||||||
private CustomKeyboard mKeyboard;
|
private CustomKeyboard mKeyboard;
|
||||||
private int mCurrentKeyIndex = NOT_A_KEY;
|
private int mCurrentKeyIndex = NOT_A_KEY;
|
||||||
@ -220,15 +221,15 @@ public class CustomKeyboardView extends View implements View.OnClickListener {
|
|||||||
private float mOldPointerX;
|
private float mOldPointerX;
|
||||||
private float mOldPointerY;
|
private float mOldPointerY;
|
||||||
|
|
||||||
// @UnsupportedAppUsage
|
// @UnsupportedAppUsage
|
||||||
// https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/annotation/UnsupportedAppUsage.java
|
// https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/annotation/UnsupportedAppUsage.java
|
||||||
// Indicates that a class member, that is not part of the SDK, is used by apps.
|
// Indicates that a class member, that is not part of the SDK, is used by apps.
|
||||||
// Since the member is not part of the SDK, such use is not supported.
|
// Since the member is not part of the SDK, such use is not supported.
|
||||||
//
|
//
|
||||||
// This annotation acts as a heads up that changing a given method or field
|
// This annotation acts as a heads up that changing a given method or field
|
||||||
// may affect apps, potentially breaking them when the next Android version is
|
// may affect apps, potentially breaking them when the next Android version is
|
||||||
// released. In some cases, for members that are heavily used, this annotation
|
// released. In some cases, for members that are heavily used, this annotation
|
||||||
// may imply restrictions on changes to the member.
|
// may imply restrictions on changes to the member.
|
||||||
private Drawable mKeyBackground;
|
private Drawable mKeyBackground;
|
||||||
|
|
||||||
private static final int REPEAT_INTERVAL = 50; // ~20 keys per second
|
private static final int REPEAT_INTERVAL = 50; // ~20 keys per second
|
||||||
@ -263,52 +264,52 @@ public class CustomKeyboardView extends View implements View.OnClickListener {
|
|||||||
/** Whether the requirement of a headset to hear passwords if accessibility is enabled is announced. */
|
/** Whether the requirement of a headset to hear passwords if accessibility is enabled is announced. */
|
||||||
private boolean mHeadsetRequiredToHearPasswordsAnnounced;
|
private boolean mHeadsetRequiredToHearPasswordsAnnounced;
|
||||||
|
|
||||||
// Custom handler code (to avoid mem leaks, see warning "This Handler Class Should Be Static Or Leaks Might Occur”) based on:
|
// Custom handler code (to avoid mem leaks, see warning "This Handler Class Should Be Static Or Leaks Might Occur”) based on:
|
||||||
// https://stackoverflow.com/a/27826094
|
// https://stackoverflow.com/a/27826094
|
||||||
public static class CustomKeyboardViewHandler extends Handler {
|
public static class CustomKeyboardViewHandler extends Handler {
|
||||||
|
|
||||||
private final WeakReference<CustomKeyboardView> mListenerReference;
|
private final WeakReference<CustomKeyboardView> mListenerReference;
|
||||||
|
|
||||||
public CustomKeyboardViewHandler(CustomKeyboardView listener) {
|
public CustomKeyboardViewHandler(CustomKeyboardView listener) {
|
||||||
mListenerReference = new WeakReference<>(listener);
|
mListenerReference = new WeakReference<>(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void handleMessage(@NonNull Message msg) {
|
public synchronized void handleMessage(@NonNull Message msg) {
|
||||||
CustomKeyboardView listener = mListenerReference.get();
|
CustomKeyboardView listener = mListenerReference.get();
|
||||||
if(listener != null) {
|
if(listener != null) {
|
||||||
switch (msg.what) {
|
switch (msg.what) {
|
||||||
case MSG_SHOW_PREVIEW:
|
case MSG_SHOW_PREVIEW:
|
||||||
listener.showKey(msg.arg1);
|
listener.showKey(msg.arg1);
|
||||||
break;
|
break;
|
||||||
case MSG_REMOVE_PREVIEW:
|
case MSG_REMOVE_PREVIEW:
|
||||||
listener.mPreviewText.setVisibility(INVISIBLE);
|
listener.mPreviewText.setVisibility(INVISIBLE);
|
||||||
break;
|
break;
|
||||||
case MSG_REPEAT:
|
case MSG_REPEAT:
|
||||||
if (listener.repeatKey()) {
|
if (listener.repeatKey()) {
|
||||||
Message repeat = Message.obtain(this, MSG_REPEAT);
|
Message repeat = Message.obtain(this, MSG_REPEAT);
|
||||||
sendMessageDelayed(repeat, REPEAT_INTERVAL);
|
sendMessageDelayed(repeat, REPEAT_INTERVAL);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MSG_LONGPRESS:
|
case MSG_LONGPRESS:
|
||||||
listener.openPopupIfRequired((MotionEvent) msg.obj);
|
listener.openPopupIfRequired((MotionEvent) msg.obj);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clear() {
|
public void clear() {
|
||||||
this.removeCallbacksAndMessages(null);
|
this.removeCallbacksAndMessages(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handler mHandler;
|
// Handler mHandler;
|
||||||
// final private CustomKeyboardViewHandler mHandler = new CustomKeyboardViewHandler(this);
|
// final private CustomKeyboardViewHandler mHandler = new CustomKeyboardViewHandler(this);
|
||||||
private CustomKeyboardViewHandler mHandler = new CustomKeyboardViewHandler(this);
|
private CustomKeyboardViewHandler mHandler = new CustomKeyboardViewHandler(this);
|
||||||
|
|
||||||
public void clearEventHandler() {
|
public void clearEventHandler() {
|
||||||
mHandler.clear();
|
mHandler.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public CustomKeyboardView(Context context, AttributeSet attrs) {
|
public CustomKeyboardView(Context context, AttributeSet attrs) {
|
||||||
this(context, attrs, R.attr.keyboardViewStyle);
|
this(context, attrs, R.attr.keyboardViewStyle);
|
||||||
@ -318,11 +319,11 @@ public class CustomKeyboardView extends View implements View.OnClickListener {
|
|||||||
this(context, attrs, defStyleAttr, 0);
|
this(context, attrs, defStyleAttr, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CustomKeyboardView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
public CustomKeyboardView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||||
// super(context, attrs, defStyleAttr, defStyleRes); // this call requires API 21. Skip it for now
|
// super(context, attrs, defStyleAttr, defStyleRes); // this call requires API 21. Skip it for now
|
||||||
super(context, attrs, defStyleAttr);
|
super(context, attrs, defStyleAttr);
|
||||||
|
|
||||||
mContext = context;
|
mContext = context;
|
||||||
|
|
||||||
TypedArray a = context.obtainStyledAttributes(
|
TypedArray a = context.obtainStyledAttributes(
|
||||||
attrs, R.styleable.CustomKeyboardView, defStyleAttr, defStyleRes);
|
attrs, R.styleable.CustomKeyboardView, defStyleAttr, defStyleRes);
|
||||||
@ -339,62 +340,52 @@ public class CustomKeyboardView extends View implements View.OnClickListener {
|
|||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
int attr = a.getIndex(i);
|
int attr = a.getIndex(i);
|
||||||
|
|
||||||
switch (attr) {
|
// resolve: "resource IDs will be non-final in Android Gradle Plugin version 5.0, avoid using them in switch case statements"
|
||||||
case R.styleable.CustomKeyboardView_keyBackground:
|
// We converted the switch statement to if/else as suggested here: http://tools.android.com/tips/non-constant-fields
|
||||||
|
if (attr == R.styleable.CustomKeyboardView_keyBackground) {
|
||||||
mKeyBackground = a.getDrawable(attr);
|
mKeyBackground = a.getDrawable(attr);
|
||||||
break;
|
} else if (attr == R.styleable.CustomKeyboardView_verticalCorrection) {
|
||||||
case R.styleable.CustomKeyboardView_verticalCorrection:
|
|
||||||
mVerticalCorrection = a.getDimensionPixelOffset(attr, 0);
|
mVerticalCorrection = a.getDimensionPixelOffset(attr, 0);
|
||||||
break;
|
} else if (attr == R.styleable.CustomKeyboardView_keyPreviewLayout) {
|
||||||
case R.styleable.CustomKeyboardView_keyPreviewLayout:
|
|
||||||
previewLayout = a.getResourceId(attr, 0);
|
previewLayout = a.getResourceId(attr, 0);
|
||||||
break;
|
} else if (attr == R.styleable.CustomKeyboardView_keyPreviewOffset) {
|
||||||
case R.styleable.CustomKeyboardView_keyPreviewOffset:
|
|
||||||
mPreviewOffset = a.getDimensionPixelOffset(attr, 0);
|
mPreviewOffset = a.getDimensionPixelOffset(attr, 0);
|
||||||
break;
|
} else if (attr == R.styleable.CustomKeyboardView_keyPreviewHeight) {
|
||||||
case R.styleable.CustomKeyboardView_keyPreviewHeight:
|
|
||||||
mPreviewHeight = a.getDimensionPixelSize(attr, 80);
|
mPreviewHeight = a.getDimensionPixelSize(attr, 80);
|
||||||
break;
|
} else if (attr == R.styleable.CustomKeyboardView_keyTextSize) {
|
||||||
case R.styleable.CustomKeyboardView_keyTextSize:
|
|
||||||
mKeyTextSize = a.getDimensionPixelSize(attr, 18);
|
mKeyTextSize = a.getDimensionPixelSize(attr, 18);
|
||||||
break;
|
} else if (attr == R.styleable.CustomKeyboardView_keyTextColor) {
|
||||||
case R.styleable.CustomKeyboardView_keyTextColor:
|
|
||||||
mKeyTextColor = a.getColor(attr, 0xFF000000);
|
mKeyTextColor = a.getColor(attr, 0xFF000000);
|
||||||
break;
|
} else if (attr == R.styleable.CustomKeyboardView_labelTextSize) {
|
||||||
case R.styleable.CustomKeyboardView_labelTextSize:
|
|
||||||
mLabelTextSize = a.getDimensionPixelSize(attr, 14);
|
mLabelTextSize = a.getDimensionPixelSize(attr, 14);
|
||||||
break;
|
} else if (attr == R.styleable.CustomKeyboardView_popupLayout) {
|
||||||
case R.styleable.CustomKeyboardView_popupLayout:
|
|
||||||
mPopupLayout = a.getResourceId(attr, 0);
|
mPopupLayout = a.getResourceId(attr, 0);
|
||||||
break;
|
} else if (attr == R.styleable.CustomKeyboardView_shadowColor) {
|
||||||
case R.styleable.CustomKeyboardView_shadowColor:
|
|
||||||
mShadowColor = a.getColor(attr, 0);
|
mShadowColor = a.getColor(attr, 0);
|
||||||
break;
|
} else if (attr == R.styleable.CustomKeyboardView_shadowRadius) {
|
||||||
case R.styleable.CustomKeyboardView_shadowRadius:
|
|
||||||
mShadowRadius = a.getFloat(attr, 0f);
|
mShadowRadius = a.getFloat(attr, 0f);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// // TODO put default values as constants somewhere
|
// // TODO put default values as constants somewhere
|
||||||
// if (mLabelTextSize == 0) {
|
// if (mLabelTextSize == 0) {
|
||||||
// mLabelTextSize = 14;
|
// mLabelTextSize = 14;
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// if (mKeyTextSize == 0) {
|
// if (mKeyTextSize == 0) {
|
||||||
// mKeyTextSize = 18;
|
// mKeyTextSize = 18;
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// if (mKeyTextColor == 0) {
|
// if (mKeyTextColor == 0) {
|
||||||
// mKeyTextColor = 0xFF000000;
|
// mKeyTextColor = 0xFF000000;
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// if (mPreviewHeight == 0) {
|
// if (mPreviewHeight == 0) {
|
||||||
// mPreviewHeight = 80;
|
// mPreviewHeight = 80;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
mBackgroundDimAmount = a.getFloat(R.styleable.CustomKeyboardView_backgroundDimAmount, 0.5f);
|
mBackgroundDimAmount = a.getFloat(R.styleable.CustomKeyboardView_backgroundDimAmount, 0.5f);
|
||||||
a.recycle();
|
a.recycle();
|
||||||
|
|
||||||
mPreviewPopup = new PopupWindow(context);
|
mPreviewPopup = new PopupWindow(context);
|
||||||
if (previewLayout != 0) {
|
if (previewLayout != 0) {
|
||||||
@ -407,7 +398,6 @@ public class CustomKeyboardView extends View implements View.OnClickListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mPreviewPopup.setTouchable(false);
|
mPreviewPopup.setTouchable(false);
|
||||||
|
|
||||||
mPopupKeyboard = new PopupWindow(context);
|
mPopupKeyboard = new PopupWindow(context);
|
||||||
mPopupKeyboard.setBackgroundDrawable(null);
|
mPopupKeyboard.setBackgroundDrawable(null);
|
||||||
//mPopupKeyboard.setClippingEnabled(false);
|
//mPopupKeyboard.setClippingEnabled(false);
|
||||||
@ -425,34 +415,35 @@ public class CustomKeyboardView extends View implements View.OnClickListener {
|
|||||||
mMiniKeyboardCache = new HashMap<>();
|
mMiniKeyboardCache = new HashMap<>();
|
||||||
|
|
||||||
if (mKeyBackground == null) {
|
if (mKeyBackground == null) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
mKeyBackground = context.getResources().getDrawable(R.drawable.btn_keyboard_key, context.getTheme());
|
// mKeyBackground = context.getResources().getDrawable(R.drawable.btn_keyboard_key, context.getTheme());
|
||||||
} else {
|
// } else {
|
||||||
mKeyBackground = context.getResources().getDrawable(R.drawable.btn_keyboard_key);
|
// mKeyBackground = context.getResources().getDrawable(R.drawable.btn_keyboard_key);
|
||||||
}
|
// }
|
||||||
}
|
mKeyBackground = ResourcesCompat.getDrawable(context.getResources(), R.drawable.btn_keyboard_key, context.getTheme());
|
||||||
|
}
|
||||||
|
|
||||||
mKeyBackground.getPadding(mPadding);
|
mKeyBackground.getPadding(mPadding);
|
||||||
|
|
||||||
mSwipeThreshold = (int) (500 * getResources().getDisplayMetrics().density);
|
mSwipeThreshold = (int) (500 * getResources().getDisplayMetrics().density);
|
||||||
mDisambiguateSwipe = getResources().getBoolean(
|
mDisambiguateSwipe = getResources().getBoolean(
|
||||||
R.bool.config_swipeDisambiguation);
|
R.bool.config_swipeDisambiguation);
|
||||||
|
|
||||||
//mAccessibilityManager = AccessibilityManager.getInstance(context);
|
//mAccessibilityManager = AccessibilityManager.getInstance(context);
|
||||||
mAccessibilityManager = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);
|
mAccessibilityManager = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);
|
||||||
mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
|
mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
|
||||||
|
|
||||||
resetMultiTap();
|
resetMultiTap();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onAttachedToWindow() {
|
protected void onAttachedToWindow() {
|
||||||
super.onAttachedToWindow();
|
super.onAttachedToWindow();
|
||||||
initGestureDetector();
|
initGestureDetector();
|
||||||
if (mHandler == null) {
|
if (mHandler == null) {
|
||||||
mHandler = new CustomKeyboardViewHandler(this);
|
mHandler = new CustomKeyboardViewHandler(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initGestureDetector() {
|
private void initGestureDetector() {
|
||||||
if (mGestureDetector == null) {
|
if (mGestureDetector == null) {
|
||||||
@ -542,7 +533,7 @@ public class CustomKeyboardView extends View implements View.OnClickListener {
|
|||||||
mKeyboard = keyboard;
|
mKeyboard = keyboard;
|
||||||
List<CustomKeyboard.CustomKey> keys = mKeyboard.getKeys();
|
List<CustomKeyboard.CustomKey> keys = mKeyboard.getKeys();
|
||||||
// mKeys = keys.toArray(new CustomKeyboard.Key[keys.size()]);
|
// mKeys = keys.toArray(new CustomKeyboard.Key[keys.size()]);
|
||||||
mKeys = keys.toArray(new CustomKeyboard.CustomKey[0]);
|
mKeys = keys.toArray(new CustomKeyboard.CustomKey[0]);
|
||||||
requestLayout();
|
requestLayout();
|
||||||
// Hint to reallocate the buffer if the size changed
|
// Hint to reallocate the buffer if the size changed
|
||||||
mKeyboardChanged = true;
|
mKeyboardChanged = true;
|
||||||
@ -612,9 +603,8 @@ public class CustomKeyboardView extends View implements View.OnClickListener {
|
|||||||
return mShowPreview;
|
return mShowPreview;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setVerticalCorrection(int verticalOffset) {
|
public void setVerticalCorrection(int verticalOffset) { }
|
||||||
|
|
||||||
}
|
|
||||||
public void setPopupParent(View v) {
|
public void setPopupParent(View v) {
|
||||||
mPopupParent = v;
|
mPopupParent = v;
|
||||||
}
|
}
|
||||||
@ -686,7 +676,7 @@ public class CustomKeyboardView extends View implements View.OnClickListener {
|
|||||||
int length = keys.length;
|
int length = keys.length;
|
||||||
int dimensionSum = 0;
|
int dimensionSum = 0;
|
||||||
for (int i = 0; i < length; i++) {
|
for (int i = 0; i < length; i++) {
|
||||||
CustomKeyboard.CustomKey key = keys[i];
|
CustomKeyboard.CustomKey key = keys[i];
|
||||||
dimensionSum += Math.min(key.width, key.height) + key.gap;
|
dimensionSum += Math.min(key.width, key.height) + key.gap;
|
||||||
}
|
}
|
||||||
if (dimensionSum < 0 || length == 0) return;
|
if (dimensionSum < 0 || length == 0) return;
|
||||||
@ -763,7 +753,7 @@ public class CustomKeyboardView extends View implements View.OnClickListener {
|
|||||||
int[] drawableState = key.getCurrentDrawableState();
|
int[] drawableState = key.getCurrentDrawableState();
|
||||||
keyBackground.setState(drawableState);
|
keyBackground.setState(drawableState);
|
||||||
|
|
||||||
// Log.d("keyboardView", " key label: " + (key.label == null ? "null" : key.label.toString()));
|
// Log.d("keyboardView", " key label: " + (key.label == null ? "null" : key.label.toString()));
|
||||||
// Switch the character to uppercase if shift is pressed
|
// Switch the character to uppercase if shift is pressed
|
||||||
String label = key.label == null? null : adjustCase(key.label).toString();
|
String label = key.label == null? null : adjustCase(key.label).toString();
|
||||||
|
|
||||||
@ -787,21 +777,21 @@ public class CustomKeyboardView extends View implements View.OnClickListener {
|
|||||||
// Draw a drop shadow for the text
|
// Draw a drop shadow for the text
|
||||||
paint.setShadowLayer(mShadowRadius, 0, 0, mShadowColor);
|
paint.setShadowLayer(mShadowRadius, 0, 0, mShadowColor);
|
||||||
// Draw the text
|
// Draw the text
|
||||||
Log.d("keyboardView", "keyW: " + key.width +
|
Log.d("keyboardView", "keyW: " + key.width +
|
||||||
" keyH: " + key.height +
|
" keyH: " + key.height +
|
||||||
" padL: " + padding.left +
|
" padL: " + padding.left +
|
||||||
" padR: " + padding.right +
|
" padR: " + padding.right +
|
||||||
" padT: " + padding.top +
|
" padT: " + padding.top +
|
||||||
" padB: " + padding.bottom +
|
" padB: " + padding.bottom +
|
||||||
" paintTs: " + paint.getTextSize() +
|
" paintTs: " + paint.getTextSize() +
|
||||||
" paintDesce: " + paint.descent());
|
" paintDesce: " + paint.descent());
|
||||||
|
|
||||||
Log.d("keyboardView", " Draw key: " + label
|
Log.d("keyboardView", " Draw key: " + label
|
||||||
+ " x: " + ( ((key.width - padding.left - padding.right) / 2.0f ) + padding.left)
|
+ " x: " + ( ((key.width - padding.left - padding.right) / 2.0f ) + padding.left)
|
||||||
+ " y: " + ( ((key.height - padding.top - padding.bottom) / 2.0f ) + ((paint.getTextSize() - paint.descent()) / 2.0f) + padding.top));
|
+ " y: " + ( ((key.height - padding.top - padding.bottom) / 2.0f ) + ((paint.getTextSize() - paint.descent()) / 2.0f) + padding.top));
|
||||||
canvas.drawText(label,
|
canvas.drawText(label,
|
||||||
( ((key.width - padding.left - padding.right) / 2.0f ) + padding.left),
|
( ((key.width - padding.left - padding.right) / 2.0f ) + padding.left),
|
||||||
( ((key.height - padding.top - padding.bottom) / 2.0f ) + ((paint.getTextSize() - paint.descent()) / 2.0f) + padding.top),
|
( ((key.height - padding.top - padding.bottom) / 2.0f ) + ((paint.getTextSize() - paint.descent()) / 2.0f) + padding.top),
|
||||||
paint);
|
paint);
|
||||||
// Turn off drop shadow
|
// Turn off drop shadow
|
||||||
paint.setShadowLayer(0, 0, 0, 0);
|
paint.setShadowLayer(0, 0, 0, 0);
|
||||||
@ -949,7 +939,7 @@ public class CustomKeyboardView extends View implements View.OnClickListener {
|
|||||||
final CustomKeyboard.CustomKey[] keys = mKeys;
|
final CustomKeyboard.CustomKey[] keys = mKeys;
|
||||||
if (oldKeyIndex != mCurrentKeyIndex) {
|
if (oldKeyIndex != mCurrentKeyIndex) {
|
||||||
if (oldKeyIndex != NOT_A_KEY && keys.length > oldKeyIndex) {
|
if (oldKeyIndex != NOT_A_KEY && keys.length > oldKeyIndex) {
|
||||||
CustomKeyboard.CustomKey oldKey = keys[oldKeyIndex];
|
CustomKeyboard.CustomKey oldKey = keys[oldKeyIndex];
|
||||||
oldKey.onReleased(mCurrentKeyIndex == NOT_A_KEY);
|
oldKey.onReleased(mCurrentKeyIndex == NOT_A_KEY);
|
||||||
invalidateKey(oldKeyIndex);
|
invalidateKey(oldKeyIndex);
|
||||||
final int keyCode = oldKey.codes[0];
|
final int keyCode = oldKey.codes[0];
|
||||||
@ -960,7 +950,7 @@ public class CustomKeyboardView extends View implements View.OnClickListener {
|
|||||||
AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED, keyCode);
|
AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED, keyCode);
|
||||||
}
|
}
|
||||||
if (mCurrentKeyIndex != NOT_A_KEY && keys.length > mCurrentKeyIndex) {
|
if (mCurrentKeyIndex != NOT_A_KEY && keys.length > mCurrentKeyIndex) {
|
||||||
CustomKeyboard.CustomKey newKey = keys[mCurrentKeyIndex];
|
CustomKeyboard.CustomKey newKey = keys[mCurrentKeyIndex];
|
||||||
newKey.onPressed();
|
newKey.onPressed();
|
||||||
invalidateKey(mCurrentKeyIndex);
|
invalidateKey(mCurrentKeyIndex);
|
||||||
final int keyCode = newKey.codes[0];
|
final int keyCode = newKey.codes[0];
|
||||||
@ -999,7 +989,7 @@ public class CustomKeyboardView extends View implements View.OnClickListener {
|
|||||||
final PopupWindow previewPopup = mPreviewPopup;
|
final PopupWindow previewPopup = mPreviewPopup;
|
||||||
final CustomKeyboard.CustomKey[] keys = mKeys;
|
final CustomKeyboard.CustomKey[] keys = mKeys;
|
||||||
if (keyIndex < 0 || keyIndex >= mKeys.length) return;
|
if (keyIndex < 0 || keyIndex >= mKeys.length) return;
|
||||||
CustomKeyboard.CustomKey key = keys[keyIndex];
|
CustomKeyboard.CustomKey key = keys[keyIndex];
|
||||||
if (key.icon != null) {
|
if (key.icon != null) {
|
||||||
mPreviewText.setCompoundDrawables(null, null, null,
|
mPreviewText.setCompoundDrawables(null, null, null,
|
||||||
key.iconPreview != null ? key.iconPreview : key.icon);
|
key.iconPreview != null ? key.iconPreview : key.icon);
|
||||||
@ -1130,11 +1120,17 @@ public class CustomKeyboardView extends View implements View.OnClickListener {
|
|||||||
}
|
}
|
||||||
final CustomKeyboard.CustomKey key = mKeys[keyIndex];
|
final CustomKeyboard.CustomKey key = mKeys[keyIndex];
|
||||||
mInvalidatedKey = key;
|
mInvalidatedKey = key;
|
||||||
mDirtyRect.union(key.x + getPaddingLeft(), key.y + getPaddingTop(),
|
mDirtyRect.union(key.x + getPaddingLeft(),
|
||||||
key.x + key.width + getPaddingLeft(), key.y + key.height + getPaddingTop());
|
key.y + getPaddingTop(),
|
||||||
|
key.x + key.width + getPaddingLeft(),
|
||||||
|
key.y + key.height + getPaddingTop());
|
||||||
onBufferDraw();
|
onBufferDraw();
|
||||||
invalidate(key.x + getPaddingLeft(), key.y + getPaddingTop(),
|
|
||||||
key.x + key.width + getPaddingLeft(), key.y + key.height + getPaddingTop());
|
// The switch to hardware accelerated rendering in API 14 reduced the importance of the dirty rectangle.
|
||||||
|
// In API 21 the given rectangle is ignored entirely in favor of an internally-calculated area instead.
|
||||||
|
// Because of this, clients are encouraged to just call invalidate().
|
||||||
|
//invalidate(key.x + getPaddingLeft(), key.y + getPaddingTop(),key.x + key.width + getPaddingLeft(), key.y + key.height + getPaddingTop());
|
||||||
|
invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
// @UnsupportedAppUsage
|
// @UnsupportedAppUsage
|
||||||
@ -1147,7 +1143,7 @@ public class CustomKeyboardView extends View implements View.OnClickListener {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CustomKeyboard.CustomKey popupKey = mKeys[mCurrentKey];
|
CustomKeyboard.CustomKey popupKey = mKeys[mCurrentKey];
|
||||||
boolean result = onLongPress(popupKey);
|
boolean result = onLongPress(popupKey);
|
||||||
if (result) {
|
if (result) {
|
||||||
mAbortKey = true;
|
mAbortKey = true;
|
||||||
@ -1173,9 +1169,9 @@ public class CustomKeyboardView extends View implements View.OnClickListener {
|
|||||||
Context.LAYOUT_INFLATER_SERVICE);
|
Context.LAYOUT_INFLATER_SERVICE);
|
||||||
mMiniKeyboardContainer = inflater.inflate(mPopupLayout, null);
|
mMiniKeyboardContainer = inflater.inflate(mPopupLayout, null);
|
||||||
mMiniKeyboard = (CustomKeyboardView) mMiniKeyboardContainer.findViewById(
|
mMiniKeyboard = (CustomKeyboardView) mMiniKeyboardContainer.findViewById(
|
||||||
android.R.id.keyboardView);
|
R.id.ScummVMKeyboardView);
|
||||||
View closeButton = mMiniKeyboardContainer.findViewById(
|
View closeButton = mMiniKeyboardContainer.findViewById(
|
||||||
android.R.id.closeButton);
|
android.R.id.closeButton);
|
||||||
if (closeButton != null) closeButton.setOnClickListener(this);
|
if (closeButton != null) closeButton.setOnClickListener(this);
|
||||||
mMiniKeyboard.setOnKeyboardActionListener(new OnKeyboardActionListener() {
|
mMiniKeyboard.setOnKeyboardActionListener(new OnKeyboardActionListener() {
|
||||||
public void onKey(int primaryCode, int[] keyCodes) {
|
public void onKey(int primaryCode, int[] keyCodes) {
|
||||||
@ -1200,7 +1196,7 @@ public class CustomKeyboardView extends View implements View.OnClickListener {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
//mInputView.setSuggest(mSuggest);
|
//mInputView.setSuggest(mSuggest);
|
||||||
CustomKeyboard keyboard;
|
CustomKeyboard keyboard;
|
||||||
if (popupKey.popupCharacters != null) {
|
if (popupKey.popupCharacters != null) {
|
||||||
keyboard = new CustomKeyboard(getContext(), popupKeyboardId,
|
keyboard = new CustomKeyboard(getContext(), popupKeyboardId,
|
||||||
popupKey.popupCharacters, -1, getPaddingLeft() + getPaddingRight());
|
popupKey.popupCharacters, -1, getPaddingLeft() + getPaddingRight());
|
||||||
@ -1216,7 +1212,7 @@ public class CustomKeyboardView extends View implements View.OnClickListener {
|
|||||||
mMiniKeyboardCache.put(popupKey, mMiniKeyboardContainer);
|
mMiniKeyboardCache.put(popupKey, mMiniKeyboardContainer);
|
||||||
} else {
|
} else {
|
||||||
mMiniKeyboard = (CustomKeyboardView) mMiniKeyboardContainer.findViewById(
|
mMiniKeyboard = (CustomKeyboardView) mMiniKeyboardContainer.findViewById(
|
||||||
android.R.id.keyboardView);
|
R.id.ScummVMKeyboardView);
|
||||||
}
|
}
|
||||||
getLocationInWindow(mCoordinates);
|
getLocationInWindow(mCoordinates);
|
||||||
mPopupX = popupKey.x + getPaddingLeft();
|
mPopupX = popupKey.x + getPaddingLeft();
|
||||||
@ -1277,8 +1273,8 @@ public class CustomKeyboardView extends View implements View.OnClickListener {
|
|||||||
down.recycle();
|
down.recycle();
|
||||||
// If it's an up action, then deliver the up as well.
|
// If it's an up action, then deliver the up as well.
|
||||||
if (action == MotionEvent.ACTION_UP) {
|
if (action == MotionEvent.ACTION_UP) {
|
||||||
//// TODO should we do this performClick here?
|
//// TODO should we do this performClick here?
|
||||||
//performClick();
|
//performClick();
|
||||||
result = onModifiedTouchEvent(me, true);
|
result = onModifiedTouchEvent(me, true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -1286,16 +1282,16 @@ public class CustomKeyboardView extends View implements View.OnClickListener {
|
|||||||
MotionEvent up = MotionEvent.obtain(now, now, MotionEvent.ACTION_UP,
|
MotionEvent up = MotionEvent.obtain(now, now, MotionEvent.ACTION_UP,
|
||||||
mOldPointerX, mOldPointerY, me.getMetaState());
|
mOldPointerX, mOldPointerY, me.getMetaState());
|
||||||
result = onModifiedTouchEvent(up, true);
|
result = onModifiedTouchEvent(up, true);
|
||||||
//// TODO should we do this performClick here?
|
//// TODO should we do this performClick here?
|
||||||
//performClick();
|
//performClick();
|
||||||
up.recycle();
|
up.recycle();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (pointerCount == 1) {
|
if (pointerCount == 1) {
|
||||||
// TODO should we do this performClick here?
|
// TODO should we do this performClick here?
|
||||||
//if (action == MotionEvent.ACTION_UP) {
|
//if (action == MotionEvent.ACTION_UP) {
|
||||||
// performClick();
|
// performClick();
|
||||||
//}
|
//}
|
||||||
result = onModifiedTouchEvent(me, false);
|
result = onModifiedTouchEvent(me, false);
|
||||||
mOldPointerX = me.getX();
|
mOldPointerX = me.getX();
|
||||||
mOldPointerY = me.getY();
|
mOldPointerY = me.getY();
|
||||||
@ -1309,11 +1305,11 @@ public class CustomKeyboardView extends View implements View.OnClickListener {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean performClick() {
|
public boolean performClick() {
|
||||||
super.performClick();
|
super.performClick();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean onModifiedTouchEvent(MotionEvent me, boolean possiblePoly) {
|
private boolean onModifiedTouchEvent(MotionEvent me, boolean possiblePoly) {
|
||||||
int touchX = (int) me.getX() - getPaddingLeft();
|
int touchX = (int) me.getX() - getPaddingLeft();
|
||||||
@ -1405,7 +1401,7 @@ public class CustomKeyboardView extends View implements View.OnClickListener {
|
|||||||
} else {
|
} else {
|
||||||
// if (mRepeatKeyIndex != NOT_A_KEY)
|
// if (mRepeatKeyIndex != NOT_A_KEY)
|
||||||
// New - handle the case where the user holds their finger and moves out of the key button
|
// New - handle the case where the user holds their finger and moves out of the key button
|
||||||
// Unfortunately, we will also get a "release" event on MotionEvent.ACTION_UP but that is safe since it is ignored
|
// Unfortunately, we will also get a "release" event on MotionEvent.ACTION_UP but that is safe since it is ignored
|
||||||
removeMessages();
|
removeMessages();
|
||||||
if (mRepeatKeyIndex >= 0 && !mMiniKeyboardOnScreen && !mAbortKey) {
|
if (mRepeatKeyIndex >= 0 && !mMiniKeyboardOnScreen && !mAbortKey) {
|
||||||
//Log.d(ScummVM.LOG_TAG, "CustomKeyboardView:: onModifiedTouchEvent - MotionEvent.ACTION_MOVE Final Rep");
|
//Log.d(ScummVM.LOG_TAG, "CustomKeyboardView:: onModifiedTouchEvent - MotionEvent.ACTION_MOVE Final Rep");
|
||||||
@ -1476,7 +1472,7 @@ public class CustomKeyboardView extends View implements View.OnClickListener {
|
|||||||
|
|
||||||
// @UnsupportedAppUsage
|
// @UnsupportedAppUsage
|
||||||
private boolean repeatKey() {
|
private boolean repeatKey() {
|
||||||
CustomKeyboard.CustomKey key = mKeys[mRepeatKeyIndex];
|
CustomKeyboard.CustomKey key = mKeys[mRepeatKeyIndex];
|
||||||
//Log.d(ScummVM.LOG_TAG, "CustomKeyboardView:: repeatKey");
|
//Log.d(ScummVM.LOG_TAG, "CustomKeyboardView:: repeatKey");
|
||||||
detectAndSendKey(mCurrentKey, key.x, key.y, mLastTapTime, true, false);
|
detectAndSendKey(mCurrentKey, key.x, key.y, mLastTapTime, true, false);
|
||||||
return true;
|
return true;
|
||||||
@ -1549,7 +1545,7 @@ public class CustomKeyboardView extends View implements View.OnClickListener {
|
|||||||
|
|
||||||
private void checkMultiTap(long eventTime, int keyIndex) {
|
private void checkMultiTap(long eventTime, int keyIndex) {
|
||||||
if (keyIndex == NOT_A_KEY) return;
|
if (keyIndex == NOT_A_KEY) return;
|
||||||
CustomKeyboard.CustomKey key = mKeys[keyIndex];
|
CustomKeyboard.CustomKey key = mKeys[keyIndex];
|
||||||
if (key.codes.length > 1) {
|
if (key.codes.length > 1) {
|
||||||
mInMultiTap = true;
|
mInMultiTap = true;
|
||||||
if (eventTime < mLastTapTime + MULTITAP_INTERVAL
|
if (eventTime < mLastTapTime + MULTITAP_INTERVAL
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package org.scummvm.scummvm;
|
package org.scummvm.scummvm;
|
||||||
|
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@ -270,27 +271,38 @@ public class ScummVMEventsBase implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// sequence of characters
|
// The KeyEvent.ACTION_MULTIPLE constant was deprecated in API level 29 (Q).
|
||||||
if (action == KeyEvent.ACTION_MULTIPLE
|
// No longer used by the input system.
|
||||||
&& keyCode == KeyEvent.KEYCODE_UNKNOWN) {
|
// getAction() value: multiple duplicate key events have occurred in a row, or a complex string is being delivered.
|
||||||
final KeyCharacterMap m = KeyCharacterMap.load(e.getDeviceId());
|
// If the key code is not KEYCODE_UNKNOWN then the getRepeatCount() method returns the number of times the given key code should be executed.
|
||||||
final KeyEvent[] es = m.getEvents(e.getCharacters().toCharArray());
|
// Otherwise, if the key code is KEYCODE_UNKNOWN, then this is a sequence of characters as returned by getCharacters().
|
||||||
|
// sequence of characters
|
||||||
|
// getCharacters() is also deprecated in API level 29
|
||||||
|
// For the special case of a ACTION_MULTIPLE event with key code of KEYCODE_UNKNOWN,
|
||||||
|
// this is a raw string of characters associated with the event. In all other cases it is null.
|
||||||
|
// TODO What is the use case for this?
|
||||||
|
// Does it make sense to keep it with a Build.VERSION.SDK_INT < Build.VERSION_CODES.Q check?
|
||||||
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
|
||||||
|
if (action == KeyEvent.ACTION_MULTIPLE
|
||||||
|
&& keyCode == KeyEvent.KEYCODE_UNKNOWN) {
|
||||||
|
final KeyCharacterMap m = KeyCharacterMap.load(e.getDeviceId());
|
||||||
|
final KeyEvent[] es = m.getEvents(e.getCharacters().toCharArray());
|
||||||
|
|
||||||
if (es == null) {
|
if (es == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (KeyEvent s : es) {
|
||||||
|
_scummvm.pushEvent(JE_KEY,
|
||||||
|
s.getAction(),
|
||||||
|
s.getKeyCode(),
|
||||||
|
eventUnicodeChar & KeyCharacterMap.COMBINING_ACCENT_MASK,
|
||||||
|
s.getMetaState(),
|
||||||
|
s.getRepeatCount(),
|
||||||
|
0);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (KeyEvent s : es) {
|
|
||||||
_scummvm.pushEvent(JE_KEY,
|
|
||||||
s.getAction(),
|
|
||||||
s.getKeyCode(),
|
|
||||||
eventUnicodeChar & KeyCharacterMap.COMBINING_ACCENT_MASK,
|
|
||||||
s.getMetaState(),
|
|
||||||
s.getRepeatCount(),
|
|
||||||
0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int type;
|
int type;
|
||||||
|
@ -36,7 +36,8 @@
|
|||||||
android:icon="@mipmap/scummvm"
|
android:icon="@mipmap/scummvm"
|
||||||
android:isGame="true"
|
android:isGame="true"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:resizeableActivity="false">
|
android:resizeableActivity="false"
|
||||||
|
android:requestLegacyExternalStorage="true">
|
||||||
<activity
|
<activity
|
||||||
android:name=".SplashActivity"
|
android:name=".SplashActivity"
|
||||||
android:banner="@drawable/leanback_icon"
|
android:banner="@drawable/leanback_icon"
|
||||||
|
@ -15,10 +15,10 @@ dependencies {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable to see use of depracted API
|
// Enable to see use of deprecated API
|
||||||
// tasks.withType(JavaCompile) {
|
tasks.withType(JavaCompile) {
|
||||||
// options.compilerArgs << "-Xlint:deprecation"
|
options.compilerArgs << "-Xlint:deprecation"
|
||||||
// }
|
}
|
||||||
|
|
||||||
apply plugin: 'com.android.application'
|
apply plugin: 'com.android.application'
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ android {
|
|||||||
setProperty("archivesBaseName", "ScummVM")
|
setProperty("archivesBaseName", "ScummVM")
|
||||||
|
|
||||||
minSdkVersion 16
|
minSdkVersion 16
|
||||||
targetSdkVersion 28
|
targetSdkVersion 29
|
||||||
|
|
||||||
versionName "2.3.0git"
|
versionName "2.3.0git"
|
||||||
versionCode 65
|
versionCode 65
|
||||||
@ -82,4 +82,5 @@ android {
|
|||||||
dependencies {
|
dependencies {
|
||||||
implementation "androidx.annotation:annotation:1.1.0"
|
implementation "androidx.annotation:annotation:1.1.0"
|
||||||
implementation "androidx.documentfile:documentfile:1.0.1"
|
implementation "androidx.documentfile:documentfile:1.0.1"
|
||||||
|
implementation "androidx.appcompat:appcompat:1.2.0"
|
||||||
}
|
}
|
||||||
|
@ -14,8 +14,8 @@
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
<selector xmlns:android="http://schemas.android.com/apk/res/android" xmlns:scummvm="http://schemas.android.com/apk/res-auto" >
|
||||||
<item android:state_long_pressable="true"
|
<item scummvm:state_long_pressable="true"
|
||||||
android:drawable="@drawable/keyboard_key_feedback_more_background" />
|
android:drawable="@drawable/keyboard_key_feedback_more_background" />
|
||||||
|
|
||||||
<item android:drawable="@drawable/keyboard_key_feedback_background" />
|
<item android:drawable="@drawable/keyboard_key_feedback_background" />
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
<!-- Excluded attribute due to error: (layout should not include itself) android:popupLayout="@layout/keyboard_popup_keyboard" -->
|
<!-- Excluded attribute due to error: (layout should not include itself) android:popupLayout="@layout/keyboard_popup_keyboard" -->
|
||||||
<!-- Removed attribute due to invalid for LinearLayout android:layout_alignParentBottom="true" -->
|
<!-- Removed attribute due to invalid for LinearLayout android:layout_alignParentBottom="true" -->
|
||||||
<org.scummvm.scummvm.CustomKeyboardView
|
<org.scummvm.scummvm.CustomKeyboardView
|
||||||
android:id="@android:id/keyboardView"
|
android:id="@id/ScummVMKeyboardView"
|
||||||
android:background="@android:color/transparent"
|
android:background="@android:color/transparent"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
21
dists/android/res/values/ids_min.xml
Normal file
21
dists/android/res/values/ids_min.xml
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
**
|
||||||
|
** Copyright 2007, The Android Open Source Project
|
||||||
|
**
|
||||||
|
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
** you may not use this file except in compliance with the License.
|
||||||
|
** You may obtain a copy of the License at
|
||||||
|
**
|
||||||
|
** http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
**
|
||||||
|
** Unless required by applicable law or agreed to in writing, software
|
||||||
|
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
** See the License for the specific language governing permissions and
|
||||||
|
** limitations under the License.
|
||||||
|
*/
|
||||||
|
-->
|
||||||
|
<resources>
|
||||||
|
<item type="id" name="ScummVMKeyboardView" />
|
||||||
|
</resources>
|
Loading…
x
Reference in New Issue
Block a user