ANDROID: Raise targetsdk to 29 but make use of requestLegacyExternalStorage
Also some fixes for deprecated warnings
This commit is contained in:
parent
1bef1b984b
commit
de9aa236d7
7 changed files with 211 additions and 180 deletions
|
@ -49,6 +49,7 @@ import android.widget.PopupWindow;
|
|||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.res.ResourcesCompat;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
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 int NOT_A_KEY = -1;
|
||||
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 int mCurrentKeyIndex = NOT_A_KEY;
|
||||
|
@ -339,40 +340,30 @@ public class CustomKeyboardView extends View implements View.OnClickListener {
|
|||
for (int i = 0; i < n; i++) {
|
||||
int attr = a.getIndex(i);
|
||||
|
||||
switch (attr) {
|
||||
case R.styleable.CustomKeyboardView_keyBackground:
|
||||
// resolve: "resource IDs will be non-final in Android Gradle Plugin version 5.0, avoid using them in switch case statements"
|
||||
// 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);
|
||||
break;
|
||||
case R.styleable.CustomKeyboardView_verticalCorrection:
|
||||
} else if (attr == R.styleable.CustomKeyboardView_verticalCorrection) {
|
||||
mVerticalCorrection = a.getDimensionPixelOffset(attr, 0);
|
||||
break;
|
||||
case R.styleable.CustomKeyboardView_keyPreviewLayout:
|
||||
} else if (attr == R.styleable.CustomKeyboardView_keyPreviewLayout) {
|
||||
previewLayout = a.getResourceId(attr, 0);
|
||||
break;
|
||||
case R.styleable.CustomKeyboardView_keyPreviewOffset:
|
||||
} else if (attr == R.styleable.CustomKeyboardView_keyPreviewOffset) {
|
||||
mPreviewOffset = a.getDimensionPixelOffset(attr, 0);
|
||||
break;
|
||||
case R.styleable.CustomKeyboardView_keyPreviewHeight:
|
||||
} else if (attr == R.styleable.CustomKeyboardView_keyPreviewHeight) {
|
||||
mPreviewHeight = a.getDimensionPixelSize(attr, 80);
|
||||
break;
|
||||
case R.styleable.CustomKeyboardView_keyTextSize:
|
||||
} else if (attr == R.styleable.CustomKeyboardView_keyTextSize) {
|
||||
mKeyTextSize = a.getDimensionPixelSize(attr, 18);
|
||||
break;
|
||||
case R.styleable.CustomKeyboardView_keyTextColor:
|
||||
} else if (attr == R.styleable.CustomKeyboardView_keyTextColor) {
|
||||
mKeyTextColor = a.getColor(attr, 0xFF000000);
|
||||
break;
|
||||
case R.styleable.CustomKeyboardView_labelTextSize:
|
||||
} else if (attr == R.styleable.CustomKeyboardView_labelTextSize) {
|
||||
mLabelTextSize = a.getDimensionPixelSize(attr, 14);
|
||||
break;
|
||||
case R.styleable.CustomKeyboardView_popupLayout:
|
||||
} else if (attr == R.styleable.CustomKeyboardView_popupLayout) {
|
||||
mPopupLayout = a.getResourceId(attr, 0);
|
||||
break;
|
||||
case R.styleable.CustomKeyboardView_shadowColor:
|
||||
} else if (attr == R.styleable.CustomKeyboardView_shadowColor) {
|
||||
mShadowColor = a.getColor(attr, 0);
|
||||
break;
|
||||
case R.styleable.CustomKeyboardView_shadowRadius:
|
||||
} else if (attr == R.styleable.CustomKeyboardView_shadowRadius) {
|
||||
mShadowRadius = a.getFloat(attr, 0f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -407,7 +398,6 @@ public class CustomKeyboardView extends View implements View.OnClickListener {
|
|||
}
|
||||
|
||||
mPreviewPopup.setTouchable(false);
|
||||
|
||||
mPopupKeyboard = new PopupWindow(context);
|
||||
mPopupKeyboard.setBackgroundDrawable(null);
|
||||
//mPopupKeyboard.setClippingEnabled(false);
|
||||
|
@ -425,11 +415,12 @@ public class CustomKeyboardView extends View implements View.OnClickListener {
|
|||
mMiniKeyboardCache = new HashMap<>();
|
||||
|
||||
if (mKeyBackground == null) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
mKeyBackground = context.getResources().getDrawable(R.drawable.btn_keyboard_key, context.getTheme());
|
||||
} else {
|
||||
mKeyBackground = context.getResources().getDrawable(R.drawable.btn_keyboard_key);
|
||||
}
|
||||
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
// mKeyBackground = context.getResources().getDrawable(R.drawable.btn_keyboard_key, context.getTheme());
|
||||
// } else {
|
||||
// mKeyBackground = context.getResources().getDrawable(R.drawable.btn_keyboard_key);
|
||||
// }
|
||||
mKeyBackground = ResourcesCompat.getDrawable(context.getResources(), R.drawable.btn_keyboard_key, context.getTheme());
|
||||
}
|
||||
|
||||
mKeyBackground.getPadding(mPadding);
|
||||
|
@ -612,9 +603,8 @@ public class CustomKeyboardView extends View implements View.OnClickListener {
|
|||
return mShowPreview;
|
||||
}
|
||||
|
||||
public void setVerticalCorrection(int verticalOffset) {
|
||||
public void setVerticalCorrection(int verticalOffset) { }
|
||||
|
||||
}
|
||||
public void setPopupParent(View v) {
|
||||
mPopupParent = v;
|
||||
}
|
||||
|
@ -1130,11 +1120,17 @@ public class CustomKeyboardView extends View implements View.OnClickListener {
|
|||
}
|
||||
final CustomKeyboard.CustomKey key = mKeys[keyIndex];
|
||||
mInvalidatedKey = key;
|
||||
mDirtyRect.union(key.x + getPaddingLeft(), key.y + getPaddingTop(),
|
||||
key.x + key.width + getPaddingLeft(), key.y + key.height + getPaddingTop());
|
||||
mDirtyRect.union(key.x + getPaddingLeft(),
|
||||
key.y + getPaddingTop(),
|
||||
key.x + key.width + getPaddingLeft(),
|
||||
key.y + key.height + getPaddingTop());
|
||||
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
|
||||
|
@ -1173,7 +1169,7 @@ public class CustomKeyboardView extends View implements View.OnClickListener {
|
|||
Context.LAYOUT_INFLATER_SERVICE);
|
||||
mMiniKeyboardContainer = inflater.inflate(mPopupLayout, null);
|
||||
mMiniKeyboard = (CustomKeyboardView) mMiniKeyboardContainer.findViewById(
|
||||
android.R.id.keyboardView);
|
||||
R.id.ScummVMKeyboardView);
|
||||
View closeButton = mMiniKeyboardContainer.findViewById(
|
||||
android.R.id.closeButton);
|
||||
if (closeButton != null) closeButton.setOnClickListener(this);
|
||||
|
@ -1216,7 +1212,7 @@ public class CustomKeyboardView extends View implements View.OnClickListener {
|
|||
mMiniKeyboardCache.put(popupKey, mMiniKeyboardContainer);
|
||||
} else {
|
||||
mMiniKeyboard = (CustomKeyboardView) mMiniKeyboardContainer.findViewById(
|
||||
android.R.id.keyboardView);
|
||||
R.id.ScummVMKeyboardView);
|
||||
}
|
||||
getLocationInWindow(mCoordinates);
|
||||
mPopupX = popupKey.x + getPaddingLeft();
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package org.scummvm.scummvm;
|
||||
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.content.Context;
|
||||
|
@ -270,7 +271,18 @@ public class ScummVMEventsBase implements
|
|||
}
|
||||
}
|
||||
|
||||
// The KeyEvent.ACTION_MULTIPLE constant was deprecated in API level 29 (Q).
|
||||
// No longer used by the input system.
|
||||
// getAction() value: multiple duplicate key events have occurred in a row, or a complex string is being delivered.
|
||||
// If the key code is not KEYCODE_UNKNOWN then the getRepeatCount() method returns the number of times the given key code should be executed.
|
||||
// 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());
|
||||
|
@ -289,9 +301,9 @@ public class ScummVMEventsBase implements
|
|||
s.getRepeatCount(),
|
||||
0);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
int type;
|
||||
switch (keyCode) {
|
||||
|
|
|
@ -36,7 +36,8 @@
|
|||
android:icon="@mipmap/scummvm"
|
||||
android:isGame="true"
|
||||
android:label="@string/app_name"
|
||||
android:resizeableActivity="false">
|
||||
android:resizeableActivity="false"
|
||||
android:requestLegacyExternalStorage="true">
|
||||
<activity
|
||||
android:name=".SplashActivity"
|
||||
android:banner="@drawable/leanback_icon"
|
||||
|
|
|
@ -15,10 +15,10 @@ dependencies {
|
|||
}
|
||||
}
|
||||
|
||||
// Enable to see use of depracted API
|
||||
// tasks.withType(JavaCompile) {
|
||||
// options.compilerArgs << "-Xlint:deprecation"
|
||||
// }
|
||||
// Enable to see use of deprecated API
|
||||
tasks.withType(JavaCompile) {
|
||||
options.compilerArgs << "-Xlint:deprecation"
|
||||
}
|
||||
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
|
@ -33,7 +33,7 @@ android {
|
|||
setProperty("archivesBaseName", "ScummVM")
|
||||
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 28
|
||||
targetSdkVersion 29
|
||||
|
||||
versionName "2.2.1d"
|
||||
versionCode 61
|
||||
|
@ -81,4 +81,5 @@ android {
|
|||
dependencies {
|
||||
implementation "androidx.annotation:annotation:1.1.0"
|
||||
implementation "androidx.documentfile:documentfile:1.0.1"
|
||||
implementation "androidx.appcompat:appcompat:1.2.0"
|
||||
}
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
limitations under the License.
|
||||
-->
|
||||
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_long_pressable="true"
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android" xmlns:scummvm="http://schemas.android.com/apk/res-auto" >
|
||||
<item scummvm:state_long_pressable="true"
|
||||
android:drawable="@drawable/keyboard_key_feedback_more_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" -->
|
||||
<!-- Removed attribute due to invalid for LinearLayout android:layout_alignParentBottom="true" -->
|
||||
<org.scummvm.scummvm.CustomKeyboardView
|
||||
android:id="@android:id/keyboardView"
|
||||
android:id="@id/ScummVMKeyboardView"
|
||||
android:background="@android:color/transparent"
|
||||
android:layout_width="match_parent"
|
||||
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…
Add table
Add a link
Reference in a new issue