[Scummvm-git-logs] scummvm master -> 940b87000d80a8c1f115da987f39fd9e8e7ef088
antoniou79
a.antoniou79 at gmail.com
Fri Oct 16 17:11:41 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:
940b87000d ANDROID: Merge ontouch from EditSurfaceView into ScummVMEventsBase
Commit: 940b87000d80a8c1f115da987f39fd9e8e7ef088
https://github.com/scummvm/scummvm/commit/940b87000d80a8c1f115da987f39fd9e8e7ef088
Author: antoniou (a.antoniou79 at gmail.com)
Date: 2020-10-16T20:08:52+03:00
Commit Message:
ANDROID: Merge ontouch from EditSurfaceView into ScummVMEventsBase
Also fix a bug with back button not removing the keyboard if it is shown without clicking on a text input field
Changed paths:
backends/platform/android/org/scummvm/scummvm/EditableSurfaceView.java
backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
backends/platform/android/org/scummvm/scummvm/ScummVMEventsBase.java
diff --git a/backends/platform/android/org/scummvm/scummvm/EditableSurfaceView.java b/backends/platform/android/org/scummvm/scummvm/EditableSurfaceView.java
index 4eaf84cd20..52dc0c5113 100644
--- a/backends/platform/android/org/scummvm/scummvm/EditableSurfaceView.java
+++ b/backends/platform/android/org/scummvm/scummvm/EditableSurfaceView.java
@@ -39,9 +39,9 @@ public class EditableSurfaceView extends SurfaceView {
@Override
public boolean onKeyDown(int keyCode, final KeyEvent event) {
Log.d(ScummVM.LOG_TAG, "onKeyDown - EditableSurface!!!"); // Called
- if( keyCode == KeyEvent.KEYCODE_BACK ) {
+ if (keyCode == KeyEvent.KEYCODE_BACK ) {
- if( ScummVMActivity.keyboardWithoutTextInputShown ) {
+ if (ScummVMActivity.keyboardWithoutTextInputShown ) {
return true;
}
}
@@ -61,10 +61,11 @@ public class EditableSurfaceView extends SurfaceView {
@Override
public boolean onKeyUp(int keyCode, final KeyEvent event) {
Log.d(ScummVM.LOG_TAG, "onKeyUp - EditableSurface!!!");
- if( keyCode == KeyEvent.KEYCODE_BACK ) {
+ if (keyCode == KeyEvent.KEYCODE_BACK ) {
- if( ScummVMActivity.keyboardWithoutTextInputShown ) {
- ((ScummVMActivity) _context).showScreenKeyboardWithoutTextInputField(0); // Hide keyboard
+ if (ScummVMActivity.keyboardWithoutTextInputShown ) {
+ // Hide keyboard (the argument here (0) does not matter)
+ ((ScummVMActivity) _context).showScreenKeyboardWithoutTextInputField(0);
return true;
}
}
@@ -81,51 +82,6 @@ public class EditableSurfaceView extends SurfaceView {
//return super.onKeyUp(keyCode, event);
}
- @Override
- public boolean onTouchEvent(final MotionEvent event) {
- if( ScummVMActivity.keyboardWithoutTextInputShown && ((ScummVMActivity) _context)._screenKeyboard != null &&
- ((ScummVMActivity) _context)._screenKeyboard.getY() <= event.getY() ) {
- event.offsetLocation(-((ScummVMActivity) _context)._screenKeyboard.getX(), -((ScummVMActivity) _context)._screenKeyboard.getY());
- ((ScummVMActivity) _context)._screenKeyboard.onTouchEvent(event);
- return true;
- }
-
- if( android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH ) {
- if (getX() != 0) {
- event.offsetLocation(-getX(), -getY());
- }
- }
-
- // TODO what is this for?
- //DifferentTouchInput.touchInput.process(event);
-
-// // Despite the LINT warning "ScummVMEvents#onTouch should call View#performClick when a click is detected"
-// // we deal with this in our touch event handler (in ScummVMEventsBase class
-// switch (event.getAction()) {
-// case MotionEvent.ACTION_UP:
-// performClick();
-// break;
-// case MotionEvent.ACTION_DOWN:
-// // fall through
-// default:
-// break;
-// }
-
-// super.onTouchEvent(event);
- return true;
- // This causes a crash if we dispatch to super
- // Let our event manager handle it (ScummVMEvents class)
-// return super.dispatchTouchEvent(event);
- }
-
-
- // 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/ScummVMActivity.java b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
index f37cbfd5e2..7d0b2da125 100644
--- a/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
+++ b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
@@ -203,7 +203,7 @@ public class ScummVMActivity extends Activity implements OnKeyboardVisibilityLis
key -= 100000;
_main_surface.onKeyDown(KeyEvent.KEYCODE_SHIFT_LEFT, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_SHIFT_LEFT));
}
- _main_surface.onKeyDown(key, new KeyEvent(KeyEvent.ACTION_DOWN, key)); // calls onKeyDown - EditableSurface!!!
+ _main_surface.onKeyDown(key, new KeyEvent(KeyEvent.ACTION_DOWN, key));
}
public void onRelease(int key) {
@@ -288,7 +288,6 @@ public class ScummVMActivity extends Activity implements OnKeyboardVisibilityLis
_videoLayout.addView(_screenKeyboard, sKeyboardLayout);
_videoLayout.bringChildToFront(_screenKeyboard);
- Log.d(ScummVM.LOG_TAG, "SHOW KEYBOARD - 005" );
}
}
});
@@ -356,11 +355,14 @@ public class ScummVMActivity extends Activity implements OnKeyboardVisibilityLis
}
}
- public boolean isScreenKeyboardShown()
- {
+ public boolean isScreenKeyboardShown() {
return _screenKeyboard != null;
}
+ public View getScreenKeyboard () {
+ return _screenKeyboard;
+ }
+
//
// END OF new screenKeyboardCode
// ---------------------------------------------------------------------------------------------------------------------------
diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVMEventsBase.java b/backends/platform/android/org/scummvm/scummvm/ScummVMEventsBase.java
index 3ac933c31d..ba4a7df62d 100644
--- a/backends/platform/android/org/scummvm/scummvm/ScummVMEventsBase.java
+++ b/backends/platform/android/org/scummvm/scummvm/ScummVMEventsBase.java
@@ -165,6 +165,16 @@ public class ScummVMEventsBase implements
return true;
}
}
+
+ if (ScummVMActivity.keyboardWithoutTextInputShown ) {
+ if (action == KeyEvent.ACTION_DOWN) {
+ return true;
+ } else if (action == KeyEvent.ACTION_UP) {
+ // Hide keyboard (the argument here (0) does not matter)
+ ((ScummVMActivity) _context).showScreenKeyboardWithoutTextInputField(0);
+ return true;
+ }
+ }
}
if (e.isSystem()) {
@@ -289,21 +299,31 @@ public class ScummVMEventsBase implements
// OnTouchListener
@Override
- final public boolean onTouch(View v, MotionEvent e) {
+ final public boolean onTouch(View v, final MotionEvent event) {
//Log.d(ScummVM.LOG_TAG, "SCUMMV-EVENTS-BASE - onTOUCH");
+ if (ScummVMActivity.keyboardWithoutTextInputShown
+ && ((ScummVMActivity) _context).isScreenKeyboardShown()
+ && ((ScummVMActivity) _context).getScreenKeyboard().getY() <= event.getY() ) {
+ event.offsetLocation(-((ScummVMActivity) _context).getScreenKeyboard().getX(), -((ScummVMActivity) _context).getScreenKeyboard().getY());
+ // TODO maybe call the onTouchEvent of something else here?
+ ((ScummVMActivity) _context).getScreenKeyboard().onTouchEvent(event);
+ // correct the offset for continuing handling the event
+ event.offsetLocation(((ScummVMActivity) _context).getScreenKeyboard().getX(), ((ScummVMActivity) _context).getScreenKeyboard().getY());
+ }
+
if (_mouseHelper != null) {
- boolean isMouse = MouseHelper.isMouse(e);
+ boolean isMouse = MouseHelper.isMouse(event);
if (isMouse) {
// mouse button is pressed
- return _mouseHelper.onMouseEvent(e, false);
+ return _mouseHelper.onMouseEvent(event, false);
}
}
- final int action = e.getAction();
+ final int action = event.getAction();
// Deal with LINT warning "ScummVMEvents#onTouch should call View#performClick when a click is detected"
- switch (e.getAction()) {
+ switch (event.getAction()) {
case MotionEvent.ACTION_UP:
v.performClick();
break;
@@ -318,11 +338,11 @@ public class ScummVMEventsBase implements
if (pointer > 0) {
_scummvm.pushEvent(JE_MULTI, pointer, action & 0xff, // ACTION_MASK
- (int)e.getX(), (int)e.getY(), 0, 0);
+ (int)event.getX(), (int)event.getY(), 0, 0);
return true;
}
- return _gd.onTouchEvent(e);
+ return _gd.onTouchEvent(event);
}
// OnGestureListener
More information about the Scummvm-git-logs
mailing list