diff --git a/src/android/jar/src/org/qtproject/qt/android/CursorHandle.java b/src/android/jar/src/org/qtproject/qt/android/CursorHandle.java index a5c36b9df8..c8349992bb 100644 --- a/src/android/jar/src/org/qtproject/qt/android/CursorHandle.java +++ b/src/android/jar/src/org/qtproject/qt/android/CursorHandle.java @@ -3,6 +3,7 @@ package org.qtproject.qt.android; +import android.annotation.SuppressLint; import android.app.Activity; import android.content.Context; import android.content.res.TypedArray; @@ -16,10 +17,11 @@ import android.widget.ImageView; import android.widget.PopupWindow; /* This view represents one of the handle (selection or cursor handle) */ +@SuppressLint("ViewConstructor") class CursorView extends ImageView { private final CursorHandle mHandle; - // The coordinare which where clicked + // The coordinate which where clicked private float m_offsetX; private float m_offsetY; private boolean m_pressed = false; @@ -49,7 +51,7 @@ class CursorView extends ImageView if (!m_pressed) return false; mHandle.updatePosition(Math.round(ev.getRawX() - m_offsetX), - Math.round(ev.getRawY() - m_offsetY)); + Math.round(ev.getRawY() - m_offsetY)); break; } @@ -60,7 +62,6 @@ class CursorView extends ImageView } return true; } - } // Helper class that manages a cursor or selection handle @@ -92,27 +93,26 @@ public class CursorHandle implements ViewTreeObserver.OnPreDrawListener m_rtl = rtl; } - private boolean initOverlay(){ - if (m_popup == null){ + private void initOverlay(){ + if (m_popup != null) + return; - Context context = m_layout.getContext(); - int[] attrs = {m_attr}; - TypedArray a = context.getTheme().obtainStyledAttributes(attrs); - Drawable drawable = a.getDrawable(0); + Context context = m_layout.getContext(); + int[] attrs = {m_attr}; + TypedArray a = context.getTheme().obtainStyledAttributes(attrs); + Drawable drawable = a.getDrawable(0); - m_cursorView = new CursorView(context, this); - m_cursorView.setImageDrawable(drawable); + m_cursorView = new CursorView(context, this); + m_cursorView.setImageDrawable(drawable); - m_popup = new PopupWindow(context, null, android.R.attr.textSelectHandleWindowStyle); - m_popup.setSplitTouchEnabled(true); - m_popup.setClippingEnabled(false); - m_popup.setContentView(m_cursorView); - m_popup.setWidth(drawable.getIntrinsicWidth()); - m_popup.setHeight(drawable.getIntrinsicHeight()); + m_popup = new PopupWindow(context, null, android.R.attr.textSelectHandleWindowStyle); + m_popup.setSplitTouchEnabled(true); + m_popup.setClippingEnabled(false); + m_popup.setContentView(m_cursorView); + m_popup.setWidth(drawable.getIntrinsicWidth()); + m_popup.setHeight(drawable.getIntrinsicHeight()); - m_layout.getViewTreeObserver().addOnPreDrawListener(this); - } - return true; + m_layout.getViewTreeObserver().addOnPreDrawListener(this); } // Show the handle at a given position (or move it if it is already shown) diff --git a/src/android/jar/src/org/qtproject/qt/android/EditContextView.java b/src/android/jar/src/org/qtproject/qt/android/EditContextView.java index f5cd6c2a86..a7925f1c6f 100644 --- a/src/android/jar/src/org/qtproject/qt/android/EditContextView.java +++ b/src/android/jar/src/org/qtproject/qt/android/EditContextView.java @@ -4,6 +4,7 @@ package org.qtproject.qt.android; +import android.annotation.SuppressLint; import android.content.Context; import android.graphics.Point; import android.text.TextUtils; @@ -12,16 +13,16 @@ import android.view.View; import android.view.ViewGroup; import android.widget.LinearLayout; import android.widget.TextView; -import android.R; import java.util.HashMap; +@SuppressLint("ViewConstructor") public class EditContextView extends LinearLayout implements View.OnClickListener { - public static final int CUT_BUTTON = 1 << 0; + public static final int CUT_BUTTON = 1; public static final int COPY_BUTTON = 1 << 1; public static final int PASTE_BUTTON = 1 << 2; - public static final int SALL_BUTTON = 1 << 3; + public static final int SELECT_ALL_BUTTON = 1 << 3; HashMap m_buttons = new HashMap<>(4); OnClickListener m_onClickListener; @@ -41,8 +42,10 @@ public class EditContextView extends LinearLayout implements View.OnClickListene setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, 1)); setGravity(Gravity.CENTER); - setTextColor(getResources().getColor(R.color.widget_edittext_dark)); - EditContextView.this.setBackground(getResources().getDrawable(R.drawable.editbox_background_normal)); + setTextColor(getResources().getColor( + android.R.color.widget_edittext_dark, context.getTheme())); + EditContextView.this.setBackground(getResources().getDrawable( + android.R.drawable.editbox_background_normal, context.getTheme())); float scale = getResources().getDisplayMetrics().density; int hPadding = (int)(16 * scale + 0.5f); int vPadding = (int)(8 * scale + 0.5f); @@ -69,10 +72,21 @@ public class EditContextView extends LinearLayout implements View.OnClickListene public void updateButtons(int buttonsLayout) { - m_buttons.get(R.string.cut).setVisibility((buttonsLayout & CUT_BUTTON) != 0 ? View.VISIBLE : View.GONE); - m_buttons.get(R.string.copy).setVisibility((buttonsLayout & COPY_BUTTON) != 0 ? View.VISIBLE : View.GONE); - m_buttons.get(R.string.paste).setVisibility((buttonsLayout & PASTE_BUTTON) != 0 ? View.VISIBLE : View.GONE); - m_buttons.get(R.string.selectAll).setVisibility((buttonsLayout & SALL_BUTTON) != 0 ? View.VISIBLE : View.GONE); + ContextButton button = m_buttons.get(android.R.string.cut); + if (button != null) + button.setVisibility((buttonsLayout & CUT_BUTTON) != 0 ? View.VISIBLE : View.GONE); + + button = m_buttons.get(android.R.string.copy); + if (button != null) + button.setVisibility((buttonsLayout & COPY_BUTTON) != 0 ? View.VISIBLE : View.GONE); + + button = m_buttons.get(android.R.string.paste); + if (button != null) + button.setVisibility((buttonsLayout & PASTE_BUTTON) != 0 ? View.VISIBLE : View.GONE); + + button = m_buttons.get(android.R.string.selectAll); + if (button != null) + button.setVisibility((buttonsLayout & SELECT_ALL_BUTTON) != 0 ? View.VISIBLE : View.GONE); } public Point getCalculatedSize() @@ -97,9 +111,9 @@ public class EditContextView extends LinearLayout implements View.OnClickListene m_onClickListener = onClickListener; setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); - addButton(R.string.cut); - addButton(R.string.copy); - addButton(R.string.paste); - addButton(R.string.selectAll); + addButton(android.R.string.cut); + addButton(android.R.string.copy); + addButton(android.R.string.paste); + addButton(android.R.string.selectAll); } } diff --git a/src/android/jar/src/org/qtproject/qt/android/QtActivityBase.java b/src/android/jar/src/org/qtproject/qt/android/QtActivityBase.java index 764f1344e3..415c8f3a1a 100644 --- a/src/android/jar/src/org/qtproject/qt/android/QtActivityBase.java +++ b/src/android/jar/src/org/qtproject/qt/android/QtActivityBase.java @@ -52,6 +52,7 @@ public class QtActivityBase extends Activity // Append any parameters to your application, // the parameters must be "\t" separated. + /** @noinspection unused*/ public void appendApplicationParameters(String params) { m_applicationParams += params; diff --git a/src/android/jar/src/org/qtproject/qt/android/QtActivityDelegate.java b/src/android/jar/src/org/qtproject/qt/android/QtActivityDelegate.java index d8e6000a46..79d00fac15 100644 --- a/src/android/jar/src/org/qtproject/qt/android/QtActivityDelegate.java +++ b/src/android/jar/src/org/qtproject/qt/android/QtActivityDelegate.java @@ -20,13 +20,11 @@ import android.view.animation.AccelerateInterpolator; import android.view.animation.AlphaAnimation; import android.view.animation.Animation; import android.view.Menu; -import android.view.MenuItem; import android.view.View; import android.view.ViewConfiguration; import android.view.ViewGroup; import android.view.Window; import android.view.WindowInsetsController; -import android.view.ViewTreeObserver; import android.widget.ImageView; import android.widget.PopupMenu; diff --git a/src/android/jar/src/org/qtproject/qt/android/QtActivityLoader.java b/src/android/jar/src/org/qtproject/qt/android/QtActivityLoader.java index 359afd9b65..1b997a9401 100644 --- a/src/android/jar/src/org/qtproject/qt/android/QtActivityLoader.java +++ b/src/android/jar/src/org/qtproject/qt/android/QtActivityLoader.java @@ -8,7 +8,6 @@ import android.annotation.SuppressLint; import android.app.Activity; import android.app.AlertDialog; import android.app.Dialog; -import android.content.DialogInterface; import android.content.Intent; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; diff --git a/src/android/jar/src/org/qtproject/qt/android/QtClipboardManager.java b/src/android/jar/src/org/qtproject/qt/android/QtClipboardManager.java index 8fe8476eb3..992ceb44c8 100644 --- a/src/android/jar/src/org/qtproject/qt/android/QtClipboardManager.java +++ b/src/android/jar/src/org/qtproject/qt/android/QtClipboardManager.java @@ -59,7 +59,7 @@ public class QtClipboardManager if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { m_clipboardManager.clearPrimaryClip(); } else { - String[] mimeTypes = { ClipDescription.MIMETYPE_UNKNOWN }; + String[] mimeTypes = { "application/octet-stream" }; ClipData data = new ClipData("", mimeTypes, new ClipData.Item(new Intent())); m_clipboardManager.setPrimaryClip(data); } diff --git a/src/android/jar/src/org/qtproject/qt/android/QtDisplayManager.java b/src/android/jar/src/org/qtproject/qt/android/QtDisplayManager.java index cbbb2a1256..6364fa53a1 100644 --- a/src/android/jar/src/org/qtproject/qt/android/QtDisplayManager.java +++ b/src/android/jar/src/org/qtproject/qt/android/QtDisplayManager.java @@ -125,8 +125,10 @@ public class QtDisplayManager { case SYSTEM_UI_VISIBILITY_NORMAL: activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); - setDisplayCutoutLayout(activity, - WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { + activity.getWindow().getAttributes().layoutInDisplayCutoutMode = + WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER; + } break; case SYSTEM_UI_VISIBILITY_FULLSCREEN: activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); @@ -138,16 +140,20 @@ public class QtDisplayManager { | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | View.INVISIBLE; - setDisplayCutoutLayout(activity, - WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { + activity.getWindow().getAttributes().layoutInDisplayCutoutMode = + WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT; + } break; case SYSTEM_UI_VISIBILITY_TRANSLUCENT: activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION | WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); - setDisplayCutoutLayout(activity, - WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { + activity.getWindow().getAttributes().layoutInDisplayCutoutMode = + WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS; + } break; } activity.getWindow().getDecorView().setSystemUiVisibility(systemUiVisibilityFlags); @@ -158,12 +164,6 @@ public class QtDisplayManager { return m_systemUiVisibility; } - private void setDisplayCutoutLayout(Activity activity, int cutoutLayout) - { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) - activity.getWindow().getAttributes().layoutInDisplayCutoutMode = cutoutLayout; - } - public void updateFullScreen(Activity activity) { if (m_systemUiVisibility == SYSTEM_UI_VISIBILITY_FULLSCREEN) { diff --git a/src/android/jar/src/org/qtproject/qt/android/QtEditText.java b/src/android/jar/src/org/qtproject/qt/android/QtEditText.java index a802abb2d4..af77825295 100644 --- a/src/android/jar/src/org/qtproject/qt/android/QtEditText.java +++ b/src/android/jar/src/org/qtproject/qt/android/QtEditText.java @@ -5,6 +5,7 @@ package org.qtproject.qt.android; import android.content.Context; +import android.graphics.Canvas; import android.text.InputType; import android.view.View; import android.view.inputmethod.EditorInfo; @@ -68,10 +69,10 @@ public class QtEditText extends View return new QtInputConnection(this, m_qtInputConnectionListener); } -// // DEBUG CODE -// @Override -// protected void onDraw(Canvas canvas) { -// canvas.drawARGB(127, 255, 0, 255); -// super.onDraw(canvas); -// } + @Override + protected void onDraw(Canvas canvas) { + // DEBUG CODE + // canvas.drawARGB(127, 255, 0, 255); + super.onDraw(canvas); + } } diff --git a/src/android/jar/src/org/qtproject/qt/android/QtInputDelegate.java b/src/android/jar/src/org/qtproject/qt/android/QtInputDelegate.java index 1cef7c503c..70b1aaf959 100644 --- a/src/android/jar/src/org/qtproject/qt/android/QtInputDelegate.java +++ b/src/android/jar/src/org/qtproject/qt/android/QtInputDelegate.java @@ -20,6 +20,7 @@ import android.view.inputmethod.InputMethodManager; import org.qtproject.qt.android.QtInputConnection.QtInputConnectionListener; +/** @noinspection FieldCanBeLocal*/ public class QtInputDelegate { // keyboard methods diff --git a/src/android/jar/src/org/qtproject/qt/android/QtLoader.java b/src/android/jar/src/org/qtproject/qt/android/QtLoader.java index 8ca4732246..c76d54bfd0 100644 --- a/src/android/jar/src/org/qtproject/qt/android/QtLoader.java +++ b/src/android/jar/src/org/qtproject/qt/android/QtLoader.java @@ -280,7 +280,8 @@ public abstract class QtLoader { /** * Returns the application level metadata. - **/ + * + * @noinspection SameParameterValue*/ private String getApplicationMetaData(String key) { if (m_contextInfo == null) return ""; diff --git a/src/android/jar/src/org/qtproject/qt/android/QtMessageDialogHelper.java b/src/android/jar/src/org/qtproject/qt/android/QtMessageDialogHelper.java index 811d4b3393..84f327d44a 100644 --- a/src/android/jar/src/org/qtproject/qt/android/QtMessageDialogHelper.java +++ b/src/android/jar/src/org/qtproject/qt/android/QtMessageDialogHelper.java @@ -7,7 +7,6 @@ package org.qtproject.qt.android; import android.app.Activity; import android.app.AlertDialog; import android.content.Context; -import android.content.DialogInterface; import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.drawable.Drawable; @@ -80,36 +79,18 @@ public class QtMessageDialogHelper switch (m_standardIcon) { case 1: // Information - try { - return m_activity.getResources().getDrawable(android.R.drawable.ic_dialog_info, - m_activity.getTheme()); - } catch (Exception e) { - e.printStackTrace(); - } - break; + return m_activity.getResources().getDrawable(android.R.drawable.ic_dialog_info, + m_activity.getTheme()); case 2: // Warning -// try { -// return Class.forName("android.R$drawable").getDeclaredField("stat_sys_warning").getInt(null); -// } catch (Exception e) { -// e.printStackTrace(); -// } + return m_activity.getResources().getDrawable(android.R.drawable.stat_sys_warning, + m_activity.getTheme()); // break; case 3: // Critical - try { - return m_activity.getResources().getDrawable(android.R.drawable.ic_dialog_alert, - m_activity.getTheme()); - } catch (Exception e) { - e.printStackTrace(); - } - break; + return m_activity.getResources().getDrawable(android.R.drawable.ic_dialog_alert, + m_activity.getTheme()); case 4: // Question - try { - return m_activity.getResources().getDrawable(android.R.drawable.ic_menu_help, - m_activity.getTheme()); - } catch (Exception e) { - e.printStackTrace(); - } - break; + return m_activity.getResources().getDrawable(android.R.drawable.ic_menu_help, + m_activity.getTheme()); } return null; } @@ -146,9 +127,9 @@ public class QtMessageDialogHelper m_buttonsList.add(new ButtonStruct(this, id, text)); } - private Drawable getStyledDrawable(String drawable) throws ClassNotFoundException, NoSuchFieldException, IllegalAccessException + private Drawable getStyledDrawable(int id) { - int[] attrs = {Class.forName("android.R$attr").getDeclaredField(drawable).getInt(null)}; + int[] attrs = { id }; final TypedArray a = m_theme.obtainStyledAttributes(attrs); Drawable d = a.getDrawable(0); a.recycle(); @@ -192,9 +173,11 @@ public class QtMessageDialogHelper view.setLongClickable(true); view.setText(m_text); - view.setTextAppearance(m_activity, android.R.style.TextAppearance_Medium); + view.setTextAppearance(android.R.style.TextAppearance_Medium); - RelativeLayout.LayoutParams layout = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT); + RelativeLayout.LayoutParams layout = new RelativeLayout.LayoutParams( + RelativeLayout.LayoutParams.MATCH_PARENT, + RelativeLayout.LayoutParams.WRAP_CONTENT); layout.setMargins(16, 8, 16, 8); layout.addRule(RelativeLayout.ALIGN_PARENT_TOP); dialogLayout.addView(view, layout); @@ -209,9 +192,11 @@ public class QtMessageDialogHelper view.setLongClickable(true); view.setText(m_informativeText); - view.setTextAppearance(m_activity, android.R.style.TextAppearance_Medium); + view.setTextAppearance(android.R.style.TextAppearance_Medium); - RelativeLayout.LayoutParams layout = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT); + RelativeLayout.LayoutParams layout = new RelativeLayout.LayoutParams( + RelativeLayout.LayoutParams.MATCH_PARENT, + RelativeLayout.LayoutParams.WRAP_CONTENT); layout.setMargins(16, 8, 16, 8); if (lastView != null) layout.addRule(RelativeLayout.BELOW, lastView.getId()); @@ -229,9 +214,11 @@ public class QtMessageDialogHelper view.setLongClickable(true); view.setText(m_detailedText); - view.setTextAppearance(m_activity, android.R.style.TextAppearance_Small); + view.setTextAppearance(android.R.style.TextAppearance_Small); - RelativeLayout.LayoutParams layout = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT); + RelativeLayout.LayoutParams layout = new RelativeLayout.LayoutParams( + RelativeLayout.LayoutParams.MATCH_PARENT, + RelativeLayout.LayoutParams.WRAP_CONTENT); layout.setMargins(16, 8, 16, 8); if (lastView != null) layout.addRule(RelativeLayout.BELOW, lastView.getId()); @@ -251,7 +238,7 @@ public class QtMessageDialogHelper { Button bv; try { - bv = new Button(m_activity, null, Class.forName("android.R$attr").getDeclaredField("borderlessButtonStyle").getInt(null)); + bv = new Button(m_activity, null, android.R.attr.borderlessButtonStyle); } catch (Exception e) { bv = new Button(m_activity); e.printStackTrace(); @@ -265,7 +252,7 @@ public class QtMessageDialogHelper try { LinearLayout.LayoutParams layout = new LinearLayout.LayoutParams(1, RelativeLayout.LayoutParams.MATCH_PARENT); - spacer.setBackgroundDrawable(getStyledDrawable("dividerVertical")); + spacer.setBackground(getStyledDrawable(android.R.attr.dividerVertical)); buttonsLayout.addView(spacer, layout); } catch (Exception e) { e.printStackTrace(); @@ -279,22 +266,26 @@ public class QtMessageDialogHelper } try { - View horizontalDevider = new View(m_activity); - horizontalDevider.setId(id++); - horizontalDevider.setBackgroundDrawable(getStyledDrawable("dividerHorizontal")); - RelativeLayout.LayoutParams relativeParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, 1); + View horizontalDivider = new View(m_activity); + horizontalDivider.setId(id); + horizontalDivider.setBackground(getStyledDrawable( + android.R.attr.dividerHorizontal)); + RelativeLayout.LayoutParams relativeParams = new RelativeLayout.LayoutParams( + RelativeLayout.LayoutParams.MATCH_PARENT, 1); relativeParams.setMargins(0, 10, 0, 0); if (lastView != null) { relativeParams.addRule(RelativeLayout.BELOW, lastView.getId()); } else relativeParams.addRule(RelativeLayout.ALIGN_PARENT_TOP); - dialogLayout.addView(horizontalDevider, relativeParams); - lastView = horizontalDevider; + dialogLayout.addView(horizontalDivider, relativeParams); + lastView = horizontalDivider; } catch (Exception e) { e.printStackTrace(); } - RelativeLayout.LayoutParams relativeParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT); + RelativeLayout.LayoutParams relativeParams = new RelativeLayout.LayoutParams( + RelativeLayout.LayoutParams.MATCH_PARENT, + RelativeLayout.LayoutParams.WRAP_CONTENT); if (lastView != null) { relativeParams.addRule(RelativeLayout.BELOW, lastView.getId()); } diff --git a/src/android/jar/src/org/qtproject/qt/android/QtNative.java b/src/android/jar/src/org/qtproject/qt/android/QtNative.java index 23a4000bc3..88eefc45d2 100644 --- a/src/android/jar/src/org/qtproject/qt/android/QtNative.java +++ b/src/android/jar/src/org/qtproject/qt/android/QtNative.java @@ -122,6 +122,7 @@ public class QtNative return new Exception().getStackTrace()[1].getMethodName() + ": "; } + /** @noinspection SameParameterValue*/ private static Uri getUriWithValidPermission(Context context, String uri, String openMode) { Uri parsedUri; diff --git a/src/android/jar/src/org/qtproject/qt/android/QtSurface.java b/src/android/jar/src/org/qtproject/qt/android/QtSurface.java index 32bd07bd7a..17e4aeb20f 100644 --- a/src/android/jar/src/org/qtproject/qt/android/QtSurface.java +++ b/src/android/jar/src/org/qtproject/qt/android/QtSurface.java @@ -4,6 +4,7 @@ package org.qtproject.qt.android; +import android.annotation.SuppressLint; import android.content.Context; import android.graphics.PixelFormat; import android.view.GestureDetector; @@ -11,6 +12,7 @@ import android.view.MotionEvent; import android.view.SurfaceHolder; import android.view.SurfaceView; +@SuppressLint("ViewConstructor") public class QtSurface extends SurfaceView implements SurfaceHolder.Callback { private final GestureDetector m_gestureDetector; diff --git a/src/android/jar/src/org/qtproject/qt/android/accessibility/QtAccessibilityDelegate.java b/src/android/jar/src/org/qtproject/qt/android/accessibility/QtAccessibilityDelegate.java index 40998fbfa9..6f757fd580 100644 --- a/src/android/jar/src/org/qtproject/qt/android/accessibility/QtAccessibilityDelegate.java +++ b/src/android/jar/src/org/qtproject/qt/android/accessibility/QtAccessibilityDelegate.java @@ -29,7 +29,7 @@ public class QtAccessibilityDelegate extends View.AccessibilityDelegate { private static final String TAG = "Qt A11Y"; - // Qt uses the upper half of the unsiged integers + // Qt uses the upper half of the unsigned integers // all low positive ints should be fine. public static final int INVALID_ID = 333; // half evil @@ -89,7 +89,7 @@ public class QtAccessibilityDelegate extends View.AccessibilityDelegate if (Os.getenv("QT_ANDROID_DISABLE_ACCESSIBILITY") != null) return; if (enabled) { - try { + try { View view = m_view; if (view == null) { view = new View(m_activity); @@ -98,8 +98,11 @@ public class QtAccessibilityDelegate extends View.AccessibilityDelegate // ### Keep this for debugging for a while. It allows us to visually see that our View // ### is on top of the surface(s) - // ColorDrawable color = new ColorDrawable(0x80ff8080); //0xAARRGGBB - // view.setBackground(color); + //noinspection CommentedOutCode + { + // ColorDrawable color = new ColorDrawable(0x80ff8080); //0xAARRGGBB + // view.setBackground(color); + } view.setAccessibilityDelegate(QtAccessibilityDelegate.this); // if all is fine, add it to the layout @@ -149,8 +152,6 @@ public class QtAccessibilityDelegate extends View.AccessibilityDelegate switch (event.getAction()) { case MotionEvent.ACTION_HOVER_ENTER: case MotionEvent.ACTION_HOVER_MOVE: - setHoveredVirtualViewId(virtualViewId); - break; case MotionEvent.ACTION_HOVER_EXIT: setHoveredVirtualViewId(virtualViewId); break; @@ -241,24 +242,24 @@ public class QtAccessibilityDelegate extends View.AccessibilityDelegate }); } - public boolean sendEventForVirtualViewId(int virtualViewId, int eventType) + public void sendEventForVirtualViewId(int virtualViewId, int eventType) { final AccessibilityEvent event = getEventForVirtualViewId(virtualViewId, eventType); - return sendAccessibilityEvent(event); + sendAccessibilityEvent(event); } - public boolean sendAccessibilityEvent(AccessibilityEvent event) + public void sendAccessibilityEvent(AccessibilityEvent event) { if (event == null) - return false; + return; final ViewGroup group = (ViewGroup) m_view.getParent(); if (group == null) { Log.w(TAG, "Could not send AccessibilityEvent because group was null. This should really not happen."); - return false; + return; } - return group.requestSendAccessibilityEvent(m_view, event); + group.requestSendAccessibilityEvent(m_view, event); } public void invalidateVirtualViewId(int virtualViewId) @@ -416,10 +417,10 @@ public class QtAccessibilityDelegate extends View.AccessibilityDelegate // Manage internal accessibility focus state. if (m_focusedVirtualViewId == virtualViewId) { node.setAccessibilityFocused(true); - node.addAction(AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS); + node.performAction(AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS); } else { node.setAccessibilityFocused(false); - node.addAction(AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS); + node.performAction(AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS); } int[] ids = QtNativeAccessibility.childIdListForAccessibleObject(virtualViewId); @@ -483,16 +484,19 @@ public class QtAccessibilityDelegate extends View.AccessibilityDelegate return m_view.performAccessibilityAction(action, arguments); } } - handled |= performActionForVirtualViewId(virtualViewId, action, arguments); + handled |= performActionForVirtualViewId(virtualViewId, action); return handled; } }; - protected boolean performActionForVirtualViewId(int virtualViewId, int action, Bundle arguments) + protected boolean performActionForVirtualViewId(int virtualViewId, int action) { -// Log.i(TAG, "ACTION " + action + " on " + virtualViewId); -// dumpNodes(virtualViewId); + //noinspection CommentedOutCode + { + // Log.i(TAG, "ACTION " + action + " on " + virtualViewId); + // dumpNodes(virtualViewId); + } boolean success = false; switch (action) { case AccessibilityNodeInfo.ACTION_CLICK: diff --git a/src/android/jar/src/org/qtproject/qt/android/accessibility/QtNativeAccessibility.java b/src/android/jar/src/org/qtproject/qt/android/accessibility/QtNativeAccessibility.java index d4cce935ba..9fd5394877 100644 --- a/src/android/jar/src/org/qtproject/qt/android/accessibility/QtNativeAccessibility.java +++ b/src/android/jar/src/org/qtproject/qt/android/accessibility/QtNativeAccessibility.java @@ -19,5 +19,4 @@ class QtNativeAccessibility static native boolean scrollBackward(int objectId); static native boolean populateNode(int objectId, AccessibilityNodeInfo node); - static native String valueForAccessibleObject(int objectId); }