[Scummvm-git-logs] scummvm branch-2-2 -> 3f177b5d0df351ac9ae1edab595995c4cd75fdd6
antoniou79
a.antoniou79 at gmail.com
Fri Oct 2 16:53:22 UTC 2020
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
3f177b5d0d ANDROID: Reduce more Lint warnings
Commit: 3f177b5d0df351ac9ae1edab595995c4cd75fdd6
https://github.com/scummvm/scummvm/commit/3f177b5d0df351ac9ae1edab595995c4cd75fdd6
Author: antoniou (a.antoniou79 at gmail.com)
Date: 2020-10-02T19:53:06+03:00
Commit Message:
ANDROID: Reduce more Lint warnings
Unused resources, mem leak for event handler, overried View's performClick for accessibility
Changed paths:
R dists/android/res/drawable-xhdpi/ouya_icon.png
R dists/android/res/drawable/scummvm.png
R dists/android/res/mipmap-hdpi/scummvm.png
R dists/android/res/mipmap-mdpi/scummvm.png
R dists/android/res/mipmap-xhdpi/scummvm.png
R dists/android/res/mipmap-xxhdpi/scummvm.png
R dists/android/res/mipmap-xxxhdpi/scummvm.png
backends/platform/android/org/scummvm/scummvm/EditableSurfaceView.java
backends/platform/android/org/scummvm/scummvm/ExternalStorage.java
backends/platform/android/org/scummvm/scummvm/MouseHelper.java
backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java
dists/android/res/drawable/ic_scummvm_background.xml
dists/android/res/values-television/margins.xml
dists/android/res/values/colors.xml
dists/android/res/values/margins.xml
dists/android/res/values/strings.xml
diff --git a/backends/platform/android/org/scummvm/scummvm/EditableSurfaceView.java b/backends/platform/android/org/scummvm/scummvm/EditableSurfaceView.java
index 05c8085763..2c1e29582b 100644
--- a/backends/platform/android/org/scummvm/scummvm/EditableSurfaceView.java
+++ b/backends/platform/android/org/scummvm/scummvm/EditableSurfaceView.java
@@ -35,6 +35,13 @@ public class EditableSurfaceView extends SurfaceView {
_context = context;
}
+ // Deal with LINT warning: Custom view `SurfaceView` has setOnTouchListener called on it but does not override performClick (in ScummVMActivity.java)
+ @Override
+ public boolean performClick() {
+ super.performClick();
+ return true;
+ }
+
@Override
public boolean onCheckIsTextEditor() {
return false;
diff --git a/backends/platform/android/org/scummvm/scummvm/ExternalStorage.java b/backends/platform/android/org/scummvm/scummvm/ExternalStorage.java
index ea1b1844c5..5e8895a704 100644
--- a/backends/platform/android/org/scummvm/scummvm/ExternalStorage.java
+++ b/backends/platform/android/org/scummvm/scummvm/ExternalStorage.java
@@ -73,7 +73,7 @@ public class ExternalStorage {
// These are roughly in order such that the earlier ones, if they exist, are more sure
// to be removable storage than the later ones.
"/mnt/Removable/MicroSD",
- "/storage/removable/sdcard1", // !< Sony Xperia Z1
+ "/storage/removable/" + SD_CARD + "1", // !< Sony Xperia Z1
"/Removable/MicroSD", // Asus ZenPad C
"/removable/microsd",
"/external_sd", // Samsung
@@ -81,25 +81,25 @@ public class ExternalStorage {
"/storage/extSdCard", // later Samsung
"/storage/extsdcard", // Main filesystem is case-sensitive; FAT isn't.
"/mnt/extsd", // some Chinese tablets, e.g. Zeki
- "/storage/sdcard1", // If this exists it's more likely than sdcard0 to be removable.
+ "/storage/" + SD_CARD + "1", // If this exists it's more likely than sdcard0 to be removable.
"/mnt/extSdCard",
- "/mnt/sdcard/external_sd",
+ "/mnt/" + SD_CARD + "/external_sd",
"/mnt/external_sd",
"/storage/external_SD",
"/storage/ext_sd", // HTC One Max
- "/mnt/sdcard/_ExternalSD",
- "/mnt/sdcard-ext",
-
- "/sdcard2", // HTC One M8s
- "/sdcard1", // Sony Xperia Z
- "/mnt/media_rw/sdcard1", // 4.4.2 on CyanogenMod S3
- "/mnt/sdcard", // This can be built-in storage (non-removable).
- "/sdcard",
- "/storage/sdcard0",
+ "/mnt/" + SD_CARD + "/_ExternalSD",
+ "/mnt/" + SD_CARD + "-ext",
+
+ "/" + SD_CARD + "2", // HTC One M8s
+ "/" + SD_CARD + "1", // Sony Xperia Z
+ "/mnt/media_rw/" + SD_CARD + "1", // 4.4.2 on CyanogenMod S3
+ "/mnt/" + SD_CARD, // This can be built-in storage (non-removable).
+ "/" + SD_CARD,
+ "/storage/" + SD_CARD +"0",
"/emmc",
"/mnt/emmc",
- "/sdcard/sd",
- "/mnt/sdcard/bpemmctest",
+ "/" + SD_CARD + "/sd",
+ "/mnt/" + SD_CARD + "/bpemmctest",
"/mnt/external1",
"/data/sdext4",
"/data/sdext3",
diff --git a/backends/platform/android/org/scummvm/scummvm/MouseHelper.java b/backends/platform/android/org/scummvm/scummvm/MouseHelper.java
index 190ed137d7..077ac2f3ad 100644
--- a/backends/platform/android/org/scummvm/scummvm/MouseHelper.java
+++ b/backends/platform/android/org/scummvm/scummvm/MouseHelper.java
@@ -1,5 +1,6 @@
package org.scummvm.scummvm;
+import android.annotation.SuppressLint;
import android.view.InputDevice;
import android.view.KeyEvent;
import android.view.MotionEvent;
@@ -20,10 +21,10 @@ public class MouseHelper {
private boolean _srmbPressed;
private boolean _smmbPressed;
- /**
- * Class initialization fails when this throws an exception.
- * Checking hover availability is done on static class initialization for Android 1.6 compatibility.
- */
+ //
+ // Class initialization fails when this throws an exception.
+ // Checking hover availability is done on static class initialization for Android 1.6 compatibility.
+ //
static {
try {
Class.forName("android.view.View$OnHoverListener");
@@ -100,6 +101,7 @@ public class MouseHelper {
}
}
+ @SuppressLint("InlinedApi")
public boolean onMouseEvent(MotionEvent e, boolean hover) {
_scummvm.pushEvent(ScummVMEvents.JE_MOUSE_MOVE, (int)e.getX(), (int)e.getY(), 0, 0, 0, 0);
@@ -132,6 +134,12 @@ public class MouseHelper {
_mmbPressed = handleButton(e, _mmbPressed, MotionEvent.BUTTON_TERTIARY, ScummVMEvents.JE_MMB_DOWN, ScummVMEvents.JE_MMB_UP);
_bmbPressed = handleButton(e, _bmbPressed, MotionEvent.BUTTON_BACK, ScummVMEvents.JE_BMB_DOWN, ScummVMEvents.JE_BMB_UP);
_fmbPressed = handleButton(e, _fmbPressed, MotionEvent.BUTTON_FORWARD, ScummVMEvents.JE_FMB_DOWN, ScummVMEvents.JE_FMB_UP);
+ // Lint warning for BUTTON_STYLUS... "
+ // Field requires API level 23 (current min is 16): android.view.MotionEvent#BUTTON_STYLUS_PRIMARY"
+ // Field requires API level 23 (current min is 16): android.view.MotionEvent#BUTTON_STYLUS_SECONDARY"
+ // We suppress it:
+ //
+ // https://stackoverflow.com/a/48588149
_srmbPressed = handleButton(e, _srmbPressed, MotionEvent.BUTTON_STYLUS_PRIMARY, ScummVMEvents.JE_RMB_DOWN, ScummVMEvents.JE_RMB_UP);
_smmbPressed = handleButton(e, _smmbPressed, MotionEvent.BUTTON_STYLUS_SECONDARY, ScummVMEvents.JE_MMB_DOWN, ScummVMEvents.JE_MMB_UP);
diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
index 1c6edbd163..96c14a4dde 100644
--- a/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
+++ b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
@@ -248,7 +248,7 @@ public class ScummVMActivity extends Activity implements OnKeyboardVisibilityLis
setContentView(R.layout.main);
takeKeyEvents(true);
- SurfaceView main_surface = findViewById(R.id.main_surface);
+ EditableSurfaceView main_surface = findViewById(R.id.main_surface);
main_surface.requestFocus();
diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java b/backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java
index 105c5e5176..cfb47e7488 100644
--- a/backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java
+++ b/backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java
@@ -1,6 +1,5 @@
package org.scummvm.scummvm;
-//import androidx.annotation.NonNull;
import android.os.Handler;
import android.os.Message;
import android.content.Context;
@@ -14,7 +13,9 @@ import android.view.GestureDetector;
import android.view.InputDevice;
import android.view.inputmethod.InputMethodManager;
-//import java.lang.ref.WeakReference;
+import androidx.annotation.NonNull;
+
+import java.lang.ref.WeakReference;
public class ScummVMEvents implements
android.view.View.OnKeyListener,
@@ -52,29 +53,40 @@ public class ScummVMEvents implements
final protected int _longPress;
final protected MouseHelper _mouseHelper;
- // Reverted code back to using the native Handler function instead of a static custom,
- // since that had issues detecting the long-presses for some reason
- // So for now we shall ignore the Android Studio warning for "This Handler class should be static or leaks might occur (anonymous android.os.Handler)"
- //
- // TODO investigate further why our static custom Handler based on https://stackoverflow.com/a/57926736 was not receiving messages *especially* on a recent enough Android 9 device (Huawei MediaPad M5 CMR-W09)
- //
- final private Handler _keyHandler = new Handler() {
+ // 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
+ public static class ScummVMEventHandler extends Handler {
+
+ private final WeakReference<ScummVMEvents> mListenerReference;
+
+ public ScummVMEventHandler(ScummVMEvents listener) {
+ mListenerReference = new WeakReference<>(listener);
+ }
+
@Override
- public void handleMessage(Message msg) {
- if (msg.what == MSG_SMENU_LONG_PRESS) {
- // this displays the android keyboard (see showVirtualKeyboard() in ScummVMActivity.java)
- // when menu key is long-pressed
- InputMethodManager imm = (InputMethodManager)
- _context.getSystemService(Context.INPUT_METHOD_SERVICE);
-
- if (imm != null)
- imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
- } else if (msg.what == MSG_SBACK_LONG_PRESS) {
- _scummvm.pushEvent(JE_SYS_KEY, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MENU, 0, 0, 0, 0);
- _scummvm.pushEvent(JE_SYS_KEY, KeyEvent.ACTION_UP, KeyEvent.KEYCODE_MENU, 0, 0, 0, 0);
+ public synchronized void handleMessage(@NonNull Message msg) {
+ ScummVMEvents listener = mListenerReference.get();
+ if(listener != null) {
+ listener.handleEVHMessage(msg);
}
}
- };
+
+ public void clear() {
+ this.removeCallbacksAndMessages(null);
+ }
+ }
+
+ final private ScummVMEventHandler _skeyHandler = new ScummVMEventHandler(this);
+
+// /**
+// * An example getter to provide it to some external class
+// * or just use 'new MyHandler(this)' if you are using it internally.
+// * If you only use it internally you might even want it as final member:
+// * private final MyHandler mHandler = new MyHandler(this);
+// */
+// public Handler ScummVMEventHandler() {
+// return new ScummVMEventHandler(this);
+// }
public ScummVMEvents(Context context, ScummVM scummvm, MouseHelper mouseHelper) {
_context = context;
@@ -86,9 +98,27 @@ public class ScummVMEvents implements
_gd.setIsLongpressEnabled(false);
_longPress = ViewConfiguration.getLongPressTimeout();
+
+ }
+
+ private void handleEVHMessage(final Message msg) {
+ if (msg.what == MSG_SMENU_LONG_PRESS) {
+ // this displays the android keyboard (see showVirtualKeyboard() in ScummVMActivity.java)
+ // when menu key is long-pressed
+ InputMethodManager imm = (InputMethodManager)
+ _context.getSystemService(Context.INPUT_METHOD_SERVICE);
+
+ if (imm != null)
+ imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
+ } else if (msg.what == MSG_SBACK_LONG_PRESS) {
+ _scummvm.pushEvent(JE_SYS_KEY, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MENU, 0, 0, 0, 0);
+ _scummvm.pushEvent(JE_SYS_KEY, KeyEvent.ACTION_UP, KeyEvent.KEYCODE_MENU, 0, 0, 0, 0);
+ }
}
- public void clearEventHandler() { }
+ public void clearEventHandler() {
+ _skeyHandler.clear();
+ }
final public void sendQuitEvent() {
_scummvm.pushEvent(JE_QUIT, 0, 0, 0, 0, 0, 0);
@@ -162,12 +192,12 @@ public class ScummVMEvents implements
typeOfLongPressMessage = MSG_SBACK_LONG_PRESS;
}
- final boolean fired = !_keyHandler.hasMessages(typeOfLongPressMessage);
+ final boolean fired = !_skeyHandler.hasMessages(typeOfLongPressMessage);
- _keyHandler.removeMessages(typeOfLongPressMessage);
+ _skeyHandler.removeMessages(typeOfLongPressMessage);
if (action == KeyEvent.ACTION_DOWN) {
- _keyHandler.sendMessageDelayed(_keyHandler.obtainMessage(typeOfLongPressMessage), _longPress);
+ _skeyHandler.sendMessageDelayed(_skeyHandler.obtainMessage(typeOfLongPressMessage), _longPress);
return true;
} else if (action != KeyEvent.ACTION_UP) {
return true;
@@ -257,6 +287,7 @@ public class ScummVMEvents implements
// OnTouchListener
@Override
final public boolean onTouch(View v, MotionEvent e) {
+
if (_mouseHelper != null) {
boolean isMouse = MouseHelper.isMouse(e);
if (isMouse) {
@@ -267,6 +298,16 @@ public class ScummVMEvents implements
final int action = e.getAction();
+ // Deal with LINT warning "ScummVMEvents#onTouch should call View#performClick when a click is detected"
+ switch (e.getAction()) {
+ case MotionEvent.ACTION_UP:
+ v.performClick();
+ break;
+ case MotionEvent.ACTION_DOWN:
+ // fall through
+ default:
+ break;
+ }
// constants from APIv5:
// (action & ACTION_POINTER_INDEX_MASK) >> ACTION_POINTER_INDEX_SHIFT
final int pointer = (action & 0xff00) >> 8;
diff --git a/dists/android/res/drawable-xhdpi/ouya_icon.png b/dists/android/res/drawable-xhdpi/ouya_icon.png
deleted file mode 100644
index d7d0f01806..0000000000
Binary files a/dists/android/res/drawable-xhdpi/ouya_icon.png and /dev/null differ
diff --git a/dists/android/res/drawable/ic_scummvm_background.xml b/dists/android/res/drawable/ic_scummvm_background.xml
index d95f9f1a56..8a83ff24c3 100644
--- a/dists/android/res/drawable/ic_scummvm_background.xml
+++ b/dists/android/res/drawable/ic_scummvm_background.xml
@@ -3,9 +3,12 @@
android:viewportWidth="108"
android:viewportHeight="108"
xmlns:android="http://schemas.android.com/apk/res/android">
- <group>
+ <group>
+ <!-- According to LINT: "Resource references will not work correctly in images generated for this vector icon for API < 21;
+ check generated icon to make sure it looks acceptable"
+ So we don't reference @color/colorPrimary here in fillColor. Instead we use the explicit raw hex value -->
<path
- android:fillColor="@color/colorPrimary"
+ android:fillColor="#FFCC6600"
android:pathData="M0,0h108v108h-108z" />
</group>
</vector>
diff --git a/dists/android/res/drawable/scummvm.png b/dists/android/res/drawable/scummvm.png
deleted file mode 100644
index 077844c8c6..0000000000
Binary files a/dists/android/res/drawable/scummvm.png and /dev/null differ
diff --git a/dists/android/res/mipmap-hdpi/scummvm.png b/dists/android/res/mipmap-hdpi/scummvm.png
deleted file mode 100644
index 22d9630905..0000000000
Binary files a/dists/android/res/mipmap-hdpi/scummvm.png and /dev/null differ
diff --git a/dists/android/res/mipmap-mdpi/scummvm.png b/dists/android/res/mipmap-mdpi/scummvm.png
deleted file mode 100644
index 413faf4a16..0000000000
Binary files a/dists/android/res/mipmap-mdpi/scummvm.png and /dev/null differ
diff --git a/dists/android/res/mipmap-xhdpi/scummvm.png b/dists/android/res/mipmap-xhdpi/scummvm.png
deleted file mode 100644
index 410755be38..0000000000
Binary files a/dists/android/res/mipmap-xhdpi/scummvm.png and /dev/null differ
diff --git a/dists/android/res/mipmap-xxhdpi/scummvm.png b/dists/android/res/mipmap-xxhdpi/scummvm.png
deleted file mode 100644
index ffd1039162..0000000000
Binary files a/dists/android/res/mipmap-xxhdpi/scummvm.png and /dev/null differ
diff --git a/dists/android/res/mipmap-xxxhdpi/scummvm.png b/dists/android/res/mipmap-xxxhdpi/scummvm.png
deleted file mode 100644
index f47022bf40..0000000000
Binary files a/dists/android/res/mipmap-xxxhdpi/scummvm.png and /dev/null differ
diff --git a/dists/android/res/values-television/margins.xml b/dists/android/res/values-television/margins.xml
index 98e3c0049e..5718db76b0 100644
--- a/dists/android/res/values-television/margins.xml
+++ b/dists/android/res/values-television/margins.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
- <dimen name="verticalMargin">45dp</dimen>
- <dimen name="horizontalMargin">80dp</dimen>
+<!-- <dimen name="verticalMargin">45dp</dimen>-->
+<!-- <dimen name="horizontalMargin">80dp</dimen>-->
</resources>
diff --git a/dists/android/res/values/colors.xml b/dists/android/res/values/colors.xml
index 4bbfb35813..825f026ce5 100644
--- a/dists/android/res/values/colors.xml
+++ b/dists/android/res/values/colors.xml
@@ -5,10 +5,10 @@
<!-- a darker variant of the primary color, used for
the status bar (on Android 5.0+) and contextual app bars -->
- <color name="colorPrimaryDark">#FFCC4400</color>
+ <!-- <color name="colorPrimaryDark">#FFCC4400</color> -->
<!-- a secondary color for controls like checkboxes and text fields -->
- <color name="colorAccent">#FFCC5500</color>
+ <!-- <color name="colorAccent">#FFCC5500</color> -->
<color name="colorBackground">#FFCC6600</color>
</resources>
diff --git a/dists/android/res/values/margins.xml b/dists/android/res/values/margins.xml
index 6c574b2b8d..873a06b613 100644
--- a/dists/android/res/values/margins.xml
+++ b/dists/android/res/values/margins.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
- <dimen name="verticalMargin">0dp</dimen>
- <dimen name="horizontalMargin">0dp</dimen>
+<!-- <dimen name="verticalMargin">0dp</dimen>-->
+<!-- <dimen name="horizontalMargin">0dp</dimen>-->
</resources>
diff --git a/dists/android/res/values/strings.xml b/dists/android/res/values/strings.xml
index 26bc8acb34..a619c210b6 100644
--- a/dists/android/res/values/strings.xml
+++ b/dists/android/res/values/strings.xml
@@ -4,36 +4,34 @@
<string name="app_desc">Graphic adventure game engine</string>
<string name="ok">OK</string>
<string name="quit">Quit</string>
- <string name="scummvm_perm_plugin_label">ScummVM plugin</string>
- <string name="scummvm_perm_plugin_desc">Allows the application to
+ <!-- <string name="scummvm_perm_plugin_label">ScummVM plugin</string> -->
+ <!-- <string name="scummvm_perm_plugin_desc">Allows the application to
provide a ScummVM loadable plugin: code that will be executed in the
ScummVM application. Malicious plugins may do anything ScummVM
itself could do: write to your SD card, delete your savegames,
change the ScummVM background to puce, replace menu labels with rude
- words, etc.</string>
- <string name="no_sdcard_title">No SD card?</string>
- <string name="no_sdcard">Unable to read your SD card. This usually means
+ words, etc.</string> -->
+ <!-- <string name="no_sdcard_title">No SD card?</string> -->
+ <!-- <string name="no_sdcard">Unable to read your SD card. This usually means
you still have it mounted on your PC. Unmount, reinsert,
- whatever and then try again.</string>
- <string name="no_external_files_dir_access_title">External storage error</string>
- <string name="no_external_files_dir_access">Unable to access external storage
+ whatever and then try again.</string> -->
+ <!-- <string name="no_external_files_dir_access_title">External storage error</string> -->
+ <!-- <string name="no_external_files_dir_access">Unable to access external storage
to retrieve ScummVM config info! Please grant storage access permissions to
- the ScummVM app, in order to function properly!</string>
- <string name="no_log_file_title">Log File Error</string>
- <string name="no_log_file">Unable to read ScummVM log file or create a new one!</string>
+ the ScummVM app, in order to function properly!</string> -->
+ <!-- <string name="no_log_file_title">Log File Error</string> -->
+ <!-- <string name="no_log_file">Unable to read ScummVM log file or create a new one!</string> -->
<string name="no_config_file_title">Config File Error</string>
<string name="no_config_file">Unable to read ScummVM config file or create a new one!</string>
<string name="no_save_path_title">Save Path Error</string>
<string name="no_save_path_configured">Unable to create or access default save path!</string>
<string name="bad_explicit_save_path_configured">Unable to access the globally set save path! Please revert to default from ScummVM Options</string>
- <string name="no_plugins_title">No plugins found</string>
- <string name="no_plugins_found">ScummVM requires at least one <i>game
+ <!-- <string name="no_plugins_title">No plugins found</string> -->
+ <!-- <string name="no_plugins_found">ScummVM requires at least one <i>game
engine</i> to be useful. Engines are available as separate plugin
- packages, from wherever you found ScummVM.</string>
- <string name="to_market">To Market</string>
+ packages, from wherever you found ScummVM.</string> -->
+ <!-- <string name="to_market">To Market</string> -->
<string name="keyboard_toggle_btn_desc">Toggle virtual keyboard</string>
- <string name="title_activity_splash">ScummVM Logo Activity</string>
- <string name="title_activity_main">ScummVM Main Activity</string>
- <string name="dummy_button">Dummy Button</string>
- <string name="dummy_content">DUMMY\nCONTENT</string>
+ <!-- <string name="title_activity_splash">ScummVM Logo Activity</string> -->
+ <!-- <string name="title_activity_main">ScummVM Main Activity</string> -->
</resources>
More information about the Scummvm-git-logs
mailing list