[Scummvm-git-logs] scummvm master -> c1702a0953c0baaf3590ba91ff907cc586172c26

sev- sev at scummvm.org
Sat Jun 19 12:37:38 UTC 2021


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:
c1702a0953 ANDROID: Add an on-screen menu button


Commit: c1702a0953c0baaf3590ba91ff907cc586172c26
    https://github.com/scummvm/scummvm/commit/c1702a0953c0baaf3590ba91ff907cc586172c26
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2021-06-19T14:37:35+02:00

Commit Message:
ANDROID: Add an on-screen menu button

Changed paths:
  A dists/android/res/drawable/ic_action_keyboard.xml
  A dists/android/res/drawable/ic_action_menu.xml
  R dists/android/res/drawable-anydpi-v26/ic_action_keyboard.xml
  R dists/android/res/drawable-hdpi/ic_action_keyboard.png
  R dists/android/res/drawable-ldpi/ic_action_keyboard.png
  R dists/android/res/drawable-mdpi/ic_action_keyboard.png
  R dists/android/res/drawable-xhdpi/ic_action_keyboard.png
  R dists/android/res/drawable-xxhdpi/ic_action_keyboard.png
    backends/platform/android/events.cpp
    backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
    backends/platform/android/org/scummvm/scummvm/ScummVMEventsBase.java


diff --git a/backends/platform/android/events.cpp b/backends/platform/android/events.cpp
index 3527dbd708..a714082f1f 100644
--- a/backends/platform/android/events.cpp
+++ b/backends/platform/android/events.cpp
@@ -77,7 +77,8 @@ enum {
 	JE_BMB_UP = 19,
 	JE_FMB_DOWN = 20,
 	JE_FMB_UP = 21,
-	JE_QUIT = 0x1000
+	JE_QUIT = 0x1000,
+	JE_MENU = 0x1001
 };
 
 // meta modifier
@@ -1221,6 +1222,13 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3,
 
 		return;
 
+	case JE_MENU:
+		e.type = Common::EVENT_MAINMENU;
+
+		pushEvent(e);
+
+		return;
+
 	default:
 		LOGE("unknown jevent type: %d", type);
 
diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
index 426cb3dc98..776e134dc1 100644
--- a/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
+++ b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
@@ -38,6 +38,7 @@ import android.view.WindowManager;
 import android.view.inputmethod.InputMethodManager;
 import android.widget.FrameLayout;
 import android.widget.ImageView;
+import android.widget.LinearLayout;
 import android.widget.Toast;
 
 import androidx.annotation.NonNull;
@@ -115,6 +116,7 @@ public class ScummVMActivity extends Activity implements OnKeyboardVisibilityLis
 
 	private EditableSurfaceView _main_surface = null;
 	private ImageView _toggleKeyboardBtnIcon = null;
+	private ImageView _openMenuBtnIcon = null;
 
 	public View _screenKeyboard = null;
 	static boolean keyboardWithoutTextInputShown = false;
@@ -570,6 +572,18 @@ public class ScummVMActivity extends Activity implements OnKeyboardVisibilityLis
 	};
 
 
+	public final View.OnClickListener menuBtnOnClickListener = new View.OnClickListener() {
+		@Override
+		public void onClick(View v) {
+			runOnUiThread(new Runnable() {
+				public void run() {
+					_scummvm.pushEvent(ScummVMEventsBase.JE_MENU, 0, 0, 0, 0, 0, 0);
+				}
+			});
+		}
+	};
+
+
 	private class MyScummVM extends ScummVM {
 
 		public MyScummVM(SurfaceHolder holder, final MyScummVMDestroyedCallback destroyedCallback) {
@@ -879,14 +893,24 @@ public class ScummVMActivity extends Activity implements OnKeyboardVisibilityLis
 
 		_videoLayout.addView(_main_surface, new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
 
+		LinearLayout buttonLayout = new LinearLayout(this);
+		buttonLayout.setOrientation(LinearLayout.HORIZONTAL);
+		FrameLayout.LayoutParams buttonLayoutParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.TOP | Gravity.END);
+		buttonLayoutParams.setMarginEnd(5);
+		buttonLayoutParams.topMargin = 5;
+		buttonLayoutParams.rightMargin = 5;
+		_videoLayout.addView(buttonLayout, buttonLayoutParams);
+		_videoLayout.bringChildToFront(buttonLayout);
+
 		_toggleKeyboardBtnIcon = new ImageView(this);
 		_toggleKeyboardBtnIcon.setImageResource(R.drawable.ic_action_keyboard);
-		FrameLayout.LayoutParams keybrdBtnlayout = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.TOP | Gravity.END);
-		keybrdBtnlayout.setMarginEnd(15);
-		keybrdBtnlayout.topMargin = 15;
-		keybrdBtnlayout.rightMargin = 15;
-		_videoLayout.addView(_toggleKeyboardBtnIcon, keybrdBtnlayout);
-		_videoLayout.bringChildToFront(_toggleKeyboardBtnIcon);
+		buttonLayout.addView(_toggleKeyboardBtnIcon, new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT));
+		buttonLayout.bringChildToFront(_toggleKeyboardBtnIcon);
+
+		_openMenuBtnIcon = new ImageView(this);
+		_openMenuBtnIcon.setImageResource(R.drawable.ic_action_menu);
+		buttonLayout.addView(_openMenuBtnIcon, new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT));
+		buttonLayout.bringChildToFront(_openMenuBtnIcon);
 
 		_main_surface.setFocusable(true);
 		_main_surface.setFocusableInTouchMode(true);
@@ -976,6 +1000,7 @@ public class ScummVMActivity extends Activity implements OnKeyboardVisibilityLis
 			// On screen button listener
 			//findViewById(R.id.show_keyboard).setOnClickListener(keyboardBtnOnClickListener);
 			_toggleKeyboardBtnIcon.setOnClickListener(keyboardBtnOnClickListener);
+			_openMenuBtnIcon.setOnClickListener(menuBtnOnClickListener);
 
 			// Keyboard visibility listener - mainly to hide system UI if keyboard is shown and we return from Suspend to the Activity
 			setKeyboardVisibilityListener(this);
@@ -1223,7 +1248,7 @@ public class ScummVMActivity extends Activity implements OnKeyboardVisibilityLis
 //		}
 //	}
 
-	// Show or hide the semi-transparent keyboard btn (which is used to explicitly bring up the android keyboard).
+	// Show or hide the semi-transparent onscreen controls
 	// Called by the override of showKeyboardControl()
 	private void showToggleKeyboardBtnIcon(boolean show) {
 		//ImageView keyboardBtn = findViewById(R.id.show_keyboard);
@@ -1234,6 +1259,14 @@ public class ScummVMActivity extends Activity implements OnKeyboardVisibilityLis
 				_toggleKeyboardBtnIcon.setVisibility(View.GONE);
 			}
 		}
+
+		if (_openMenuBtnIcon != null ) {
+			if (show) {
+				_openMenuBtnIcon.setVisibility(View.VISIBLE);
+			} else {
+				_openMenuBtnIcon.setVisibility(View.GONE);
+			}
+		}
 	}
 
 	// Listener to check for keyboard visibility changes
diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVMEventsBase.java b/backends/platform/android/org/scummvm/scummvm/ScummVMEventsBase.java
index 220016d6d7..455580a87a 100644
--- a/backends/platform/android/org/scummvm/scummvm/ScummVMEventsBase.java
+++ b/backends/platform/android/org/scummvm/scummvm/ScummVMEventsBase.java
@@ -48,6 +48,7 @@ public class ScummVMEventsBase implements
 	public static final int JE_FMB_DOWN = 20;
 	public static final int JE_FMB_UP = 21;
 	public static final int JE_QUIT = 0x1000;
+	public static final int JE_MENU = 0x1001;
 
 	final protected Context _context;
 	final protected ScummVM _scummvm;
diff --git a/dists/android/res/drawable-anydpi-v26/ic_action_keyboard.xml b/dists/android/res/drawable-anydpi-v26/ic_action_keyboard.xml
deleted file mode 100644
index 8d0e1fc692..0000000000
--- a/dists/android/res/drawable-anydpi-v26/ic_action_keyboard.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-<vector android:alpha="0.5" android:height="24dp" android:tint="#FFFFFF"
-    android:viewportHeight="24" android:viewportWidth="24"
-    android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
-    <path android:fillColor="@android:color/white" android:pathData="M20,5L4,5c-1.1,0 -1.99,0.9 -1.99,2L2,17c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,7c0,-1.1 -0.9,-2 -2,-2zM11,8h2v2h-2L11,8zM11,11h2v2h-2v-2zM8,8h2v2L8,10L8,8zM8,11h2v2L8,13v-2zM7,13L5,13v-2h2v2zM7,10L5,10L5,8h2v2zM16,17L8,17v-2h8v2zM16,13h-2v-2h2v2zM16,10h-2L14,8h2v2zM19,13h-2v-2h2v2zM19,10h-2L17,8h2v2z"/>
-</vector>
diff --git a/dists/android/res/drawable-hdpi/ic_action_keyboard.png b/dists/android/res/drawable-hdpi/ic_action_keyboard.png
deleted file mode 100644
index ea881771e6..0000000000
Binary files a/dists/android/res/drawable-hdpi/ic_action_keyboard.png and /dev/null differ
diff --git a/dists/android/res/drawable-ldpi/ic_action_keyboard.png b/dists/android/res/drawable-ldpi/ic_action_keyboard.png
deleted file mode 100644
index 11f3b9cc7a..0000000000
Binary files a/dists/android/res/drawable-ldpi/ic_action_keyboard.png and /dev/null differ
diff --git a/dists/android/res/drawable-mdpi/ic_action_keyboard.png b/dists/android/res/drawable-mdpi/ic_action_keyboard.png
deleted file mode 100644
index a7d77c034e..0000000000
Binary files a/dists/android/res/drawable-mdpi/ic_action_keyboard.png and /dev/null differ
diff --git a/dists/android/res/drawable-xhdpi/ic_action_keyboard.png b/dists/android/res/drawable-xhdpi/ic_action_keyboard.png
deleted file mode 100644
index 8694ee4986..0000000000
Binary files a/dists/android/res/drawable-xhdpi/ic_action_keyboard.png and /dev/null differ
diff --git a/dists/android/res/drawable-xxhdpi/ic_action_keyboard.png b/dists/android/res/drawable-xxhdpi/ic_action_keyboard.png
deleted file mode 100644
index ae3957efd0..0000000000
Binary files a/dists/android/res/drawable-xxhdpi/ic_action_keyboard.png and /dev/null differ
diff --git a/dists/android/res/drawable/ic_action_keyboard.xml b/dists/android/res/drawable/ic_action_keyboard.xml
new file mode 100644
index 0000000000..59bc2e92e5
--- /dev/null
+++ b/dists/android/res/drawable/ic_action_keyboard.xml
@@ -0,0 +1,14 @@
+<vector
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:name="vector"
+    android:width="48dp"
+    android:height="48dp"
+    android:viewportWidth="48"
+    android:viewportHeight="48"
+    android:alpha="0.5">
+    <path
+        android:name="path"
+        android:pathData="M 40 10 L 8 10 C 5.79 10 4.02 11.79 4.02 14 L 4 34 C 4 36.21 5.79 38 8 38 L 40 38 C 42.21 38 44 36.21 44 34 L 44 14 C 44 11.79 42.21 10 40 10 Z M 22 16 L 26 16 L 26 20 L 22 20 L 22 16 Z M 22 22 L 26 22 L 26 26 L 22 26 L 22 22 Z M 16 16 L 20 16 L 20 20 L 16 20 L 16 16 Z M 16 22 L 20 22 L 20 26 L 16 26 L 16 22 Z M 14 26 L 10 26 L 10 22 L 14 22 L 14 26 Z M 14 20 L 10 20 L 10 16 L 14 16 L 14 20 Z M 32 34 L 16 34 L 16 30 L 32 30 L 32 34 Z M 32 26 L 28 26 L 28 22 L 32 22 L 32 26 Z M 32 20 L 28 20 L 28 16 L 32 16 L 32 20 Z M 38 26 L 34 26 L 34 22 L 38 22 L 38 26 Z M 38 20 L 34 20 L 34 16 L 38 16 L 38 20 Z"
+        android:fillColor="#ffffff"
+        android:strokeWidth="1"/>
+</vector>
diff --git a/dists/android/res/drawable/ic_action_menu.xml b/dists/android/res/drawable/ic_action_menu.xml
new file mode 100644
index 0000000000..3bedcfbe73
--- /dev/null
+++ b/dists/android/res/drawable/ic_action_menu.xml
@@ -0,0 +1,14 @@
+<vector
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:name="vector"
+    android:width="48dp"
+    android:height="48dp"
+    android:viewportWidth="48"
+    android:viewportHeight="48"
+    android:alpha="0.5">
+    <path
+        android:name="path"
+        android:pathData="M 6 36 L 42 36 L 42 32 L 6 32 L 6 36 Z M 6 26 L 42 26 L 42 22 L 6 22 L 6 26 Z M 6 12 L 6 16 L 42 16 L 42 12 L 6 12 Z"
+        android:fillColor="#ffffff"
+        android:strokeWidth="1"/>
+</vector>




More information about the Scummvm-git-logs mailing list