[Scummvm-git-logs] scummvm branch-2-2 -> 5e3dda78bc6d0f6aa9e1de3360173da8a4b16a1f

antoniou79 a.antoniou79 at gmail.com
Sat Oct 10 12:21:00 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:
5e3dda78bc ANDROID: Replace deprecated methods and fix some Code analyze warnings


Commit: 5e3dda78bc6d0f6aa9e1de3360173da8a4b16a1f
    https://github.com/scummvm/scummvm/commit/5e3dda78bc6d0f6aa9e1de3360173da8a4b16a1f
Author: antoniou (a.antoniou79 at gmail.com)
Date: 2020-10-10T15:20:49+03:00

Commit Message:
ANDROID: Replace deprecated methods and fix some Code analyze warnings

Changed paths:
  A backends/platform/android/org/scummvm/scummvm/ScummVMEventsBase.java
  A backends/platform/android/org/scummvm/scummvm/ScummVMEventsModern.java
  R backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java
  R backends/platform/android/org/scummvm/scummvm/ScummVMEventsHoneycomb.java
    backends/platform/android/org/scummvm/scummvm/EditableAccommodatingLatinIMETypeNullIssues.java
    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/ScummVM.java
    backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
    backends/platform/android/org/scummvm/scummvm/Version.java


diff --git a/backends/platform/android/org/scummvm/scummvm/EditableAccommodatingLatinIMETypeNullIssues.java b/backends/platform/android/org/scummvm/scummvm/EditableAccommodatingLatinIMETypeNullIssues.java
index 54938aa9c3..43e04f8f72 100644
--- a/backends/platform/android/org/scummvm/scummvm/EditableAccommodatingLatinIMETypeNullIssues.java
+++ b/backends/platform/android/org/scummvm/scummvm/EditableAccommodatingLatinIMETypeNullIssues.java
@@ -8,7 +8,7 @@ public class EditableAccommodatingLatinIMETypeNullIssues extends SpannableString
 	  }
 
 	//This character must be ignored by your onKey() code.
-	public static CharSequence ONE_UNPROCESSED_CHARACTER = "/";
+	public static final CharSequence ONE_UNPROCESSED_CHARACTER = "/";
 
 	@Override
 	public SpannableStringBuilder replace(final int spannableStringStart, final int spannableStringEnd, CharSequence replacementSequence, int replacementStart, int replacementEnd) {
diff --git a/backends/platform/android/org/scummvm/scummvm/EditableSurfaceView.java b/backends/platform/android/org/scummvm/scummvm/EditableSurfaceView.java
index 2c1e29582b..2f686aea26 100644
--- a/backends/platform/android/org/scummvm/scummvm/EditableSurfaceView.java
+++ b/backends/platform/android/org/scummvm/scummvm/EditableSurfaceView.java
@@ -16,7 +16,7 @@ import android.view.inputmethod.InputConnection;
 import android.annotation.TargetApi;
 
 public class EditableSurfaceView extends SurfaceView {
-	Context _context;
+	final Context _context;
 	public EditableSurfaceView(Context context) {
 
 		super(context);
diff --git a/backends/platform/android/org/scummvm/scummvm/ExternalStorage.java b/backends/platform/android/org/scummvm/scummvm/ExternalStorage.java
index 5e8895a704..3908a5672c 100644
--- a/backends/platform/android/org/scummvm/scummvm/ExternalStorage.java
+++ b/backends/platform/android/org/scummvm/scummvm/ExternalStorage.java
@@ -5,6 +5,7 @@ import android.os.Environment;
 import java.io.File;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Objects;
 import java.util.Scanner;
 
 import android.text.TextUtils;
@@ -53,21 +54,24 @@ public class ExternalStorage {
 		}
 	}
 
-	private static Pattern
-		// Pattern that SD card device should match
-		devicePattern = Pattern.compile("/dev/(block/.*vold.*|fuse)|/mnt/.*"),
-		// Pattern that SD card mount path should match
-		pathPattern = Pattern.compile("/(mnt|storage|external_sd|extsd|_ExternalSD|Removable|.*MicroSD).*", Pattern.CASE_INSENSITIVE),
-		// Pattern that the mount path should not match.
-		//' emulated' indicates an internal storage location, so skip it.
-		// 'asec' is an encrypted package file, decrypted and mounted as a directory.
-		pathAntiPattern = Pattern.compile(".*(/secure|/asec|/emulated).*"),
-		/** These are expected fs types, including vfat. tmpfs is not OK.
-		 * fuse can be removable SD card (as on Moto E or Asus ZenPad), or can be internal (Huawei G610). */
+	// Pattern that SD card device should match
+	private static final Pattern
+		devicePattern = Pattern.compile("/dev/(block/.*vold.*|fuse)|/mnt/.*");
+	// Pattern that SD card mount path should match
+	private static final Pattern
+		pathPattern = Pattern.compile("/(mnt|storage|external_sd|extsd|_ExternalSD|Removable|.*MicroSD).*", Pattern.CASE_INSENSITIVE);
+	// Pattern that the mount path should not match.
+	//' emulated' indicates an internal storage location, so skip it.
+	// 'asec' is an encrypted package file, decrypted and mounted as a directory.
+	private static final Pattern
+		pathAntiPattern = Pattern.compile(".*(/secure|/asec|/emulated).*");
+	// These are expected fs types, including vfat. tmpfs is not OK.
+	// fuse can be removable SD card (as on Moto E or Asus ZenPad), or can be internal (Huawei G610).
+	private static final Pattern
 		fsTypePattern = Pattern.compile(".*(fat|msdos|ntfs|ext[34]|fuse|sdcard|esdfs).*");
 
 	/** Common paths for microSD card. **/
-	private static String[] commonPaths = {
+	private static final String[] commonPaths = {
 		// Some of these taken from
 		// https://stackoverflow.com/questions/13976982/removable-storage-external-sdcard-path-by-manufacturers
 		// These are roughly in order such that the earlier ones, if they exist, are more sure
@@ -204,7 +208,7 @@ public class ExternalStorage {
 		if (!mountedPaths.isEmpty()) {
 			// See https://stackoverflow.com/a/5374346/423105 on why the following is necessary.
 			// Basically, .toArray() needs its parameter to know what type of array to return.
-			File[] mountedPathsArray = mountedPaths.toArray(new File[mountedPaths.size()]);
+			File[] mountedPathsArray = mountedPaths.toArray(new File[0]);
 			addAncestors(mountedPathsArray, candidatePaths);
 		}
 
@@ -237,7 +241,7 @@ public class ExternalStorage {
 		// Note that you can't pass null, or you'll get an NPE.
 		final File publicDirectory = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC);
 		// Take the parent, because we tend to get a path like /pathTo/sdCard/Music.
-		addPath(publicDirectory.getParentFile().getAbsolutePath(), candidatePaths);
+		addPath(Objects.requireNonNull(publicDirectory.getParentFile()).getAbsolutePath(), candidatePaths);
 		// EXTERNAL_STORAGE: may not be removable.
 		val = System.getenv("EXTERNAL_STORAGE");
 		if (!TextUtils.isEmpty(val)) {
@@ -460,7 +464,7 @@ public class ExternalStorage {
 		map.add(DATA_DIRECTORY_INT);
 		map.add(ctx.getFilesDir().getPath());
 		map.add(DATA_DIRECTORY_EXT);
-		map.add(ctx.getExternalFilesDir(null).getPath());
+		map.add(Objects.requireNonNull(ctx.getExternalFilesDir(null)).getPath());
 
 		// Now go through the external storage
 		if (isAvailable()) {  // we can read the External Storage...
@@ -481,7 +485,7 @@ public class ExternalStorage {
 
 				if (files != null) {
 					for (final File file : files) {
-						if (file.isDirectory() && file.canRead() && (file.listFiles().length > 0)) {  // it is a real directory (not a USB drive)...
+						if (file.isDirectory() && file.canRead() && (Objects.requireNonNull(file.listFiles()).length > 0)) {  // it is a real directory (not a USB drive)...
 							String key = file.getAbsolutePath();
 							if (!map.contains(key)) {
 								map.add(key); // Make name as directory
diff --git a/backends/platform/android/org/scummvm/scummvm/MouseHelper.java b/backends/platform/android/org/scummvm/scummvm/MouseHelper.java
index 077ac2f3ad..6ac125d2d2 100644
--- a/backends/platform/android/org/scummvm/scummvm/MouseHelper.java
+++ b/backends/platform/android/org/scummvm/scummvm/MouseHelper.java
@@ -103,7 +103,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);
+		_scummvm.pushEvent(ScummVMEventsBase.JE_MOUSE_MOVE, (int)e.getX(), (int)e.getY(), 0, 0, 0, 0);
 
 		int buttonState = e.getButtonState();
 
@@ -117,31 +117,31 @@ public class MouseHelper {
 		if (lmbDown) {
 			if (!_lmbPressed) {
 				// left mouse button was pressed just now
-				_scummvm.pushEvent(ScummVMEvents.JE_LMB_DOWN, (int)e.getX(), (int)e.getY(), e.getButtonState(), 0, 0, 0);
+				_scummvm.pushEvent(ScummVMEventsBase.JE_LMB_DOWN, (int)e.getX(), (int)e.getY(), e.getButtonState(), 0, 0, 0);
 			}
 
 			_lmbPressed = true;
 		} else {
 			if (_lmbPressed) {
 				// left mouse button was released just now
-				_scummvm.pushEvent(ScummVMEvents.JE_LMB_UP, (int)e.getX(), (int)e.getY(), e.getButtonState(), 0, 0, 0);
+				_scummvm.pushEvent(ScummVMEventsBase.JE_LMB_UP, (int)e.getX(), (int)e.getY(), e.getButtonState(), 0, 0, 0);
 			}
 
 			_lmbPressed = false;
 		}
 
-		_rmbPressed = handleButton(e, _rmbPressed, MotionEvent.BUTTON_SECONDARY, ScummVMEvents.JE_RMB_DOWN, ScummVMEvents.JE_RMB_UP);
-		_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);
+		_rmbPressed = handleButton(e, _rmbPressed, MotionEvent.BUTTON_SECONDARY, ScummVMEventsBase.JE_RMB_DOWN, ScummVMEventsBase.JE_RMB_UP);
+		_mmbPressed = handleButton(e, _mmbPressed, MotionEvent.BUTTON_TERTIARY, ScummVMEventsBase.JE_MMB_DOWN, ScummVMEventsBase.JE_MMB_UP);
+		_bmbPressed = handleButton(e, _bmbPressed, MotionEvent.BUTTON_BACK, ScummVMEventsBase.JE_BMB_DOWN, ScummVMEventsBase.JE_BMB_UP);
+		_fmbPressed = handleButton(e, _fmbPressed, MotionEvent.BUTTON_FORWARD, ScummVMEventsBase.JE_FMB_DOWN, ScummVMEventsBase.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);
+		_srmbPressed = handleButton(e, _srmbPressed, MotionEvent.BUTTON_STYLUS_PRIMARY, ScummVMEventsBase.JE_RMB_DOWN, ScummVMEventsBase.JE_RMB_UP);
+		_smmbPressed = handleButton(e, _smmbPressed, MotionEvent.BUTTON_STYLUS_SECONDARY, ScummVMEventsBase.JE_MMB_DOWN, ScummVMEventsBase.JE_MMB_UP);
 
 		return true;
 	}
diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVM.java b/backends/platform/android/org/scummvm/scummvm/ScummVM.java
index d8095c70d3..1cbe794e4e 100644
--- a/backends/platform/android/org/scummvm/scummvm/ScummVM.java
+++ b/backends/platform/android/org/scummvm/scummvm/ScummVM.java
@@ -1,9 +1,11 @@
 package org.scummvm.scummvm;
 
 import android.content.res.AssetManager;
+import android.media.AudioAttributes;
 import android.media.AudioFormat;
 import android.media.AudioManager;
 import android.media.AudioTrack;
+import android.os.Build;
 import android.util.Log;
 import android.view.SurfaceHolder;
 
@@ -246,7 +248,7 @@ public abstract class ScummVM implements SurfaceHolder.Callback, Runnable {
 		_sample_rate = AudioTrack.getNativeOutputSampleRate(
 									AudioManager.STREAM_MUSIC);
 		_buffer_size = AudioTrack.getMinBufferSize(_sample_rate,
-									AudioFormat.CHANNEL_CONFIGURATION_STEREO,
+									AudioFormat.CHANNEL_OUT_STEREO,
 									AudioFormat.ENCODING_PCM_16BIT);
 
 		// ~50ms
@@ -262,12 +264,28 @@ public abstract class ScummVM implements SurfaceHolder.Callback, Runnable {
 		Log.i(LOG_TAG, String.format(Locale.ROOT, "Using %d bytes buffer for %dHz audio",
 										_buffer_size, _sample_rate));
 
-		_audio_track = new AudioTrack(AudioManager.STREAM_MUSIC,
-									_sample_rate,
-									AudioFormat.CHANNEL_CONFIGURATION_STEREO,
-									AudioFormat.ENCODING_PCM_16BIT,
-									_buffer_size,
-									AudioTrack.MODE_STREAM);
+		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+			_audio_track = new AudioTrack(
+				new AudioAttributes.Builder()
+					.setUsage(AudioAttributes.USAGE_MEDIA)
+					.setContentType(AudioAttributes.CONTENT_TYPE_MUSIC)
+					.build(),
+				new AudioFormat.Builder()
+					.setSampleRate(_sample_rate)
+					.setEncoding(AudioFormat.ENCODING_PCM_16BIT)
+					.setChannelMask(AudioFormat.CHANNEL_OUT_STEREO).build(),
+				_buffer_size,
+				AudioTrack.MODE_STREAM,
+				AudioManager.AUDIO_SESSION_ID_GENERATE);
+		} else {
+			//support for Android KitKat or lower
+			_audio_track = new AudioTrack(AudioManager.STREAM_MUSIC,
+				_sample_rate,
+				AudioFormat.CHANNEL_OUT_STEREO,
+				AudioFormat.ENCODING_PCM_16BIT,
+				_buffer_size,
+				AudioTrack.MODE_STREAM);
+		}
 
 		if (_audio_track.getState() != AudioTrack.STATE_INITIALIZED)
 			throw new Exception(
@@ -444,14 +462,14 @@ public abstract class ScummVM implements SurfaceHolder.Callback, Runnable {
 	}
 
 	static {
-		// For grabbing with gdb...
-		final boolean sleep_for_debugger = false;
-		if (sleep_for_debugger) {
-			try {
-				Thread.sleep(20 * 1000);
-			} catch (InterruptedException ignored) {
-			}
-		}
+//		// For grabbing with gdb...
+//		final boolean sleep_for_debugger = false;
+//		if (sleep_for_debugger) {
+//			try {
+//				Thread.sleep(20 * 1000);
+//			} catch (InterruptedException ignored) {
+//			}
+//		}
 
 		System.loadLibrary("scummvm");
 	}
diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
index e81d766542..2e85b2a5a6 100644
--- a/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
+++ b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
@@ -4,6 +4,7 @@ import android.Manifest;
 import android.annotation.TargetApi;
 import android.app.Activity;
 import android.app.AlertDialog;
+import android.content.ClipboardManager;
 import android.content.Context;
 import android.content.DialogInterface;
 import android.content.Intent;
@@ -17,8 +18,6 @@ import android.net.wifi.WifiManager;
 import android.os.Build;
 import android.os.Bundle;
 import android.os.Environment;
-import android.os.Handler;
-import android.text.ClipboardManager;
 import android.util.DisplayMetrics;
 import android.util.Log;
 import android.util.TypedValue;
@@ -48,13 +47,10 @@ import java.io.Reader;
 import java.io.UnsupportedEncodingException;
 import java.util.HashMap;
 import java.util.LinkedHashMap;
-import java.util.List;
 import java.util.Map;
 import java.util.Objects;
 import java.util.Properties;
 
-import static org.scummvm.scummvm.ExternalStorage.getAllStorageLocations;
-
 //import android.os.Environment;
 //import java.util.List;
 
@@ -63,7 +59,8 @@ public class ScummVMActivity extends Activity implements OnKeyboardVisibilityLis
 	/* Establish whether the hover events are available */
 	private static boolean _hoverAvailable;
 
-	private ClipboardManager _clipboard;
+	private ClipboardManager _clipboardManager;
+
 	private Version _currentScummVMVersion;
 	private File _configScummvmFile;
 	private File _actualScummVMDataDir;
@@ -96,7 +93,7 @@ public class ScummVMActivity extends Activity implements OnKeyboardVisibilityLis
 		}
 	}
 
-	public View.OnClickListener keyboardBtnOnClickListener = new View.OnClickListener() {
+	public final View.OnClickListener keyboardBtnOnClickListener = new View.OnClickListener() {
 		@Override
 		public void onClick(View v) {
 			runOnUiThread(new Runnable() {
@@ -140,21 +137,31 @@ public class ScummVMActivity extends Activity implements OnKeyboardVisibilityLis
 
 		@Override
 		protected boolean hasTextInClipboard() {
-			return _clipboard.hasText();
+			final android.content.ClipData clip = _clipboardManager.getPrimaryClip();
+
+			return (clip != null
+			        && clip.getItemCount() > 0
+			        && clip.getItemAt(0).getText() != null);
 		}
 
 		@Override
 		protected String getTextFromClipboard() {
-			CharSequence text = _clipboard.getText();
-			if (text != null) {
-				return text.toString();
+			// based on: https://stackoverflow.com/q/37196571
+			final android.content.ClipData clip = _clipboardManager.getPrimaryClip();
+
+			if (clip == null
+			    || clip.getItemCount() == 0
+			    || clip.getItemCount() > 0 && clip.getItemAt(0).getText() == null) {
+				return null;
 			}
-			return null;
+
+			return  clip.getItemAt(0).getText().toString();
 		}
 
 		@Override
-		protected boolean setTextInClipboard(String text) {
-			_clipboard.setText(text);
+		protected boolean setTextInClipboard(String textStr) {
+			final android.content.ClipData clip = android.content.ClipData.newPlainText("ScummVM clip", textStr);
+			_clipboardManager.setPrimaryClip(clip);
 			return true;
 		}
 
@@ -237,7 +244,7 @@ public class ScummVMActivity extends Activity implements OnKeyboardVisibilityLis
 	}
 
 	private MyScummVM _scummvm;
-	private ScummVMEvents _events;
+	private ScummVMEventsBase _events;
 	private MouseHelper _mouseHelper;
 	private Thread _scummvm_thread;
 
@@ -256,9 +263,7 @@ public class ScummVMActivity extends Activity implements OnKeyboardVisibilityLis
 		EditableSurfaceView main_surface = findViewById(R.id.main_surface);
 
 		main_surface.requestFocus();
-
-		_clipboard = (ClipboardManager)getSystemService(CLIPBOARD_SERVICE);
-
+		_clipboardManager = (android.content.ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
 		_currentScummVMVersion = new Version(BuildConfig.VERSION_NAME);
 		Log.d(ScummVM.LOG_TAG, "Current ScummVM version running is: " + _currentScummVMVersion.getDescription() + " (" + _currentScummVMVersion.get() + ")");
 
@@ -307,10 +312,10 @@ public class ScummVMActivity extends Activity implements OnKeyboardVisibilityLis
 				_mouseHelper.attach(main_surface);
 			}
 
-			if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB_MR1) {
-				_events = new ScummVMEvents(this, _scummvm, _mouseHelper);
+			if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) {
+				_events = new ScummVMEventsModern(this, _scummvm, _mouseHelper);
 			} else {
-				_events = new ScummVMEventsHoneycomb(this, _scummvm, _mouseHelper);
+				_events = new ScummVMEventsBase(this, _scummvm, _mouseHelper);
 			}
 
 			// On screen button listener
@@ -890,7 +895,7 @@ public class ScummVMActivity extends Activity implements OnKeyboardVisibilityLis
 					if (tmpOldVersionFound.compareTo(maxOldVersionFound) > 0) {
 						maxOldVersionFound = tmpOldVersionFound;
 						existingVersionFoundInScummVMDataDir = tmpOldVersionFound;
-						scummVMConfigHandled = false; // invalidate the handled flag
+						//scummVMConfigHandled = false; // invalidate the handled flag
 					}
 				} else {
 					Log.d(ScummVM.LOG_TAG, "Could not find info on existing ScummVM version. Unsupported or corrupt file?");
@@ -911,7 +916,7 @@ public class ScummVMActivity extends Activity implements OnKeyboardVisibilityLis
 			for (String oldConfigFileDescription : candidateOldLocationsOfScummVMConfigMap.keySet()) {
 				File oldCandidateScummVMConfig = candidateOldLocationsOfScummVMConfigMap.get(oldConfigFileDescription);
 				Log.d(ScummVM.LOG_TAG, "Looking for old config " + oldConfigFileDescription + " ScummVM file...");
-				Log.d(ScummVM.LOG_TAG, "at Path: " + oldCandidateScummVMConfig.getPath() + "...");
+				Log.d(ScummVM.LOG_TAG, "at Path: " + Objects.requireNonNull(oldCandidateScummVMConfig).getPath() + "...");
 				if (oldCandidateScummVMConfig.exists() && oldCandidateScummVMConfig.isFile()) {
 					Log.d(ScummVM.LOG_TAG, "Old config " + oldConfigFileDescription + " ScummVM file was found!");
 					String existingVersionInfo = getVersionInfoFromScummvmConfiguration(oldCandidateScummVMConfig.getPath());
@@ -928,7 +933,7 @@ public class ScummVMActivity extends Activity implements OnKeyboardVisibilityLis
 						//          and old version found is lower than 2.2.1
 						//       Then: replace our current config ini and remove the recovered ini from the aux external storage
 						if ((tmpOldVersionFound.compareTo(maxOldVersionFound) > 0)
-						     || (existingConfigInScummVMDataDirReplacedOnce == false
+						     || (!existingConfigInScummVMDataDirReplacedOnce
 						         && existingVersionFoundInScummVMDataDir.compareTo(version2_2_1_forPatch) == 0
 						         && tmpOldVersionFound.compareTo(version2_2_1_forPatch) < 0
 						         && oldConfigFileDescription.startsWith("A-"))
@@ -1071,10 +1076,10 @@ public class ScummVMActivity extends Activity implements OnKeyboardVisibilityLis
 			//       Then: Scan for previous usable ScummVM folder (it will still only copy the larger one found)
 			boolean scanOnlyInAuxExternalStorage = false;
 			if (defaultSaveDirFiles.length == 0
-			    || (existingConfigInScummVMDataDirReplacedOnce == true
+			    || (existingConfigInScummVMDataDirReplacedOnce
 			        && existingVersionFoundInScummVMDataDir.compareTo(version2_2_1_forPatch) == 0)
 			) {
-				if (existingConfigInScummVMDataDirReplacedOnce == true
+				if (existingConfigInScummVMDataDirReplacedOnce
 					&& existingVersionFoundInScummVMDataDir.compareTo(version2_2_1_forPatch) == 0) {
 					scanOnlyInAuxExternalStorage = true;
 				}
@@ -1157,7 +1162,7 @@ public class ScummVMActivity extends Activity implements OnKeyboardVisibilityLis
 					File iterCandidateScummVMSavesPath = candidateOldLocationsOfScummVMSavesMap.get(oldSavesPathDescription);
 					Log.d(ScummVM.LOG_TAG, "Looking for old saves path " + oldSavesPathDescription + "...");
 					try {
-						Log.d(ScummVM.LOG_TAG, " at Path: " + iterCandidateScummVMSavesPath.getPath());
+						Log.d(ScummVM.LOG_TAG, " at Path: " + Objects.requireNonNull(iterCandidateScummVMSavesPath).getPath());
 						if (iterCandidateScummVMSavesPath.exists() && iterCandidateScummVMSavesPath.isDirectory()) {
 							File[] sgfiles = iterCandidateScummVMSavesPath.listFiles();
 							if (sgfiles != null) {
diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java b/backends/platform/android/org/scummvm/scummvm/ScummVMEventsBase.java
similarity index 97%
rename from backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java
rename to backends/platform/android/org/scummvm/scummvm/ScummVMEventsBase.java
index cfb47e7488..efa9395b1f 100644
--- a/backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java
+++ b/backends/platform/android/org/scummvm/scummvm/ScummVMEventsBase.java
@@ -17,7 +17,7 @@ import androidx.annotation.NonNull;
 
 import java.lang.ref.WeakReference;
 
-public class ScummVMEvents implements
+public class ScummVMEventsBase implements
 		android.view.View.OnKeyListener,
 		android.view.View.OnTouchListener,
 		android.view.GestureDetector.OnGestureListener,
@@ -57,15 +57,15 @@ public class ScummVMEvents implements
 	// https://stackoverflow.com/a/27826094
 	public static class ScummVMEventHandler extends Handler {
 
-		private final WeakReference<ScummVMEvents> mListenerReference;
+		private final WeakReference<ScummVMEventsBase> mListenerReference;
 
-		public ScummVMEventHandler(ScummVMEvents listener) {
+		public ScummVMEventHandler(ScummVMEventsBase listener) {
 			mListenerReference = new WeakReference<>(listener);
 		}
 
 		@Override
 		public synchronized void handleMessage(@NonNull Message msg) {
-			ScummVMEvents listener = mListenerReference.get();
+			ScummVMEventsBase listener = mListenerReference.get();
 			if(listener != null) {
 				listener.handleEVHMessage(msg);
 			}
@@ -88,7 +88,7 @@ public class ScummVMEvents implements
 //		return new ScummVMEventHandler(this);
 //	}
 
-	public ScummVMEvents(Context context, ScummVM scummvm, MouseHelper mouseHelper) {
+	public ScummVMEventsBase(Context context, ScummVM scummvm, MouseHelper mouseHelper) {
 		_context = context;
 		_scummvm = scummvm;
 		_mouseHelper = mouseHelper;
diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVMEventsHoneycomb.java b/backends/platform/android/org/scummvm/scummvm/ScummVMEventsModern.java
similarity index 59%
rename from backends/platform/android/org/scummvm/scummvm/ScummVMEventsHoneycomb.java
rename to backends/platform/android/org/scummvm/scummvm/ScummVMEventsModern.java
index 6061763d02..ccaf7e1167 100644
--- a/backends/platform/android/org/scummvm/scummvm/ScummVMEventsHoneycomb.java
+++ b/backends/platform/android/org/scummvm/scummvm/ScummVMEventsModern.java
@@ -4,15 +4,16 @@ import android.content.Context;
 import android.view.MotionEvent;
 import android.view.InputDevice;
 
-public class ScummVMEventsHoneycomb extends ScummVMEvents {
+// A class that extends the basic ScummVMEventsBase, supporting Android APIs > HONEYCOMB_MR1 (API 12)
+public class ScummVMEventsModern extends ScummVMEventsBase {
 
-	public ScummVMEventsHoneycomb(Context context, ScummVM scummvm, MouseHelper mouseHelper) {
+	public ScummVMEventsModern(Context context, ScummVM scummvm, MouseHelper mouseHelper) {
 		super(context, scummvm, mouseHelper);
 	}
 
 	@Override
 	public boolean onGenericMotionEvent(MotionEvent e) {
-		if((e.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) != 0) {
+		if ((e.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) != 0) {
 			_scummvm.pushEvent(JE_JOYSTICK, e.getAction(),
 					   (int)(e.getAxisValue(MotionEvent.AXIS_X)*100),
 					   (int)(e.getAxisValue(MotionEvent.AXIS_Y)*100),
diff --git a/backends/platform/android/org/scummvm/scummvm/Version.java b/backends/platform/android/org/scummvm/scummvm/Version.java
index 3ae3dd8958..165c845e46 100644
--- a/backends/platform/android/org/scummvm/scummvm/Version.java
+++ b/backends/platform/android/org/scummvm/scummvm/Version.java
@@ -3,8 +3,8 @@ package org.scummvm.scummvm;
 // Based on code from: https://stackoverflow.com/a/11024200
 public class Version implements Comparable<Version> {
 
-	private String versionOnlyDigits;
-	private String versionDescription;
+	private final String versionOnlyDigits;
+	private final String versionDescription;
 
 	public final String getDescription() {
 		return this.versionDescription;




More information about the Scummvm-git-logs mailing list