Android: fix few deprecation and wrong code usage warnings
* Some more leftover unused imports. * Deprecated API, especially reflection warnings. * Some unused method parameters warnings. Task-number: QTBUG-118077 Change-Id: Ic9b7d5b69ef64aaf640bc9f53a13428f1c49278c Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
This commit is contained in:
parent
64fe6d836c
commit
41765ef3e2
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
package org.qtproject.qt.android;
|
package org.qtproject.qt.android;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
@ -16,10 +17,11 @@ import android.widget.ImageView;
|
|||||||
import android.widget.PopupWindow;
|
import android.widget.PopupWindow;
|
||||||
|
|
||||||
/* This view represents one of the handle (selection or cursor handle) */
|
/* This view represents one of the handle (selection or cursor handle) */
|
||||||
|
@SuppressLint("ViewConstructor")
|
||||||
class CursorView extends ImageView
|
class CursorView extends ImageView
|
||||||
{
|
{
|
||||||
private final CursorHandle mHandle;
|
private final CursorHandle mHandle;
|
||||||
// The coordinare which where clicked
|
// The coordinate which where clicked
|
||||||
private float m_offsetX;
|
private float m_offsetX;
|
||||||
private float m_offsetY;
|
private float m_offsetY;
|
||||||
private boolean m_pressed = false;
|
private boolean m_pressed = false;
|
||||||
@ -60,7 +62,6 @@ class CursorView extends ImageView
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper class that manages a cursor or selection handle
|
// Helper class that manages a cursor or selection handle
|
||||||
@ -92,8 +93,9 @@ public class CursorHandle implements ViewTreeObserver.OnPreDrawListener
|
|||||||
m_rtl = rtl;
|
m_rtl = rtl;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean initOverlay(){
|
private void initOverlay(){
|
||||||
if (m_popup == null){
|
if (m_popup != null)
|
||||||
|
return;
|
||||||
|
|
||||||
Context context = m_layout.getContext();
|
Context context = m_layout.getContext();
|
||||||
int[] attrs = {m_attr};
|
int[] attrs = {m_attr};
|
||||||
@ -112,8 +114,6 @@ public class CursorHandle implements ViewTreeObserver.OnPreDrawListener
|
|||||||
|
|
||||||
m_layout.getViewTreeObserver().addOnPreDrawListener(this);
|
m_layout.getViewTreeObserver().addOnPreDrawListener(this);
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Show the handle at a given position (or move it if it is already shown)
|
// Show the handle at a given position (or move it if it is already shown)
|
||||||
public void setPosition(final int x, final int y){
|
public void setPosition(final int x, final int y){
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
package org.qtproject.qt.android;
|
package org.qtproject.qt.android;
|
||||||
|
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Point;
|
import android.graphics.Point;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
@ -12,16 +13,16 @@ import android.view.View;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.R;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
@SuppressLint("ViewConstructor")
|
||||||
public class EditContextView extends LinearLayout implements View.OnClickListener
|
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 COPY_BUTTON = 1 << 1;
|
||||||
public static final int PASTE_BUTTON = 1 << 2;
|
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<Integer, ContextButton> m_buttons = new HashMap<>(4);
|
HashMap<Integer, ContextButton> m_buttons = new HashMap<>(4);
|
||||||
OnClickListener m_onClickListener;
|
OnClickListener m_onClickListener;
|
||||||
@ -41,8 +42,10 @@ public class EditContextView extends LinearLayout implements View.OnClickListene
|
|||||||
setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
|
setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||||
ViewGroup.LayoutParams.WRAP_CONTENT, 1));
|
ViewGroup.LayoutParams.WRAP_CONTENT, 1));
|
||||||
setGravity(Gravity.CENTER);
|
setGravity(Gravity.CENTER);
|
||||||
setTextColor(getResources().getColor(R.color.widget_edittext_dark));
|
setTextColor(getResources().getColor(
|
||||||
EditContextView.this.setBackground(getResources().getDrawable(R.drawable.editbox_background_normal));
|
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;
|
float scale = getResources().getDisplayMetrics().density;
|
||||||
int hPadding = (int)(16 * scale + 0.5f);
|
int hPadding = (int)(16 * scale + 0.5f);
|
||||||
int vPadding = (int)(8 * 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)
|
public void updateButtons(int buttonsLayout)
|
||||||
{
|
{
|
||||||
m_buttons.get(R.string.cut).setVisibility((buttonsLayout & CUT_BUTTON) != 0 ? View.VISIBLE : View.GONE);
|
ContextButton button = m_buttons.get(android.R.string.cut);
|
||||||
m_buttons.get(R.string.copy).setVisibility((buttonsLayout & COPY_BUTTON) != 0 ? View.VISIBLE : View.GONE);
|
if (button != null)
|
||||||
m_buttons.get(R.string.paste).setVisibility((buttonsLayout & PASTE_BUTTON) != 0 ? View.VISIBLE : View.GONE);
|
button.setVisibility((buttonsLayout & CUT_BUTTON) != 0 ? View.VISIBLE : View.GONE);
|
||||||
m_buttons.get(R.string.selectAll).setVisibility((buttonsLayout & SALL_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()
|
public Point getCalculatedSize()
|
||||||
@ -97,9 +111,9 @@ public class EditContextView extends LinearLayout implements View.OnClickListene
|
|||||||
m_onClickListener = onClickListener;
|
m_onClickListener = onClickListener;
|
||||||
setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
|
setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
|
||||||
|
|
||||||
addButton(R.string.cut);
|
addButton(android.R.string.cut);
|
||||||
addButton(R.string.copy);
|
addButton(android.R.string.copy);
|
||||||
addButton(R.string.paste);
|
addButton(android.R.string.paste);
|
||||||
addButton(R.string.selectAll);
|
addButton(android.R.string.selectAll);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,6 +52,7 @@ public class QtActivityBase extends Activity
|
|||||||
|
|
||||||
// Append any parameters to your application,
|
// Append any parameters to your application,
|
||||||
// the parameters must be "\t" separated.
|
// the parameters must be "\t" separated.
|
||||||
|
/** @noinspection unused*/
|
||||||
public void appendApplicationParameters(String params)
|
public void appendApplicationParameters(String params)
|
||||||
{
|
{
|
||||||
m_applicationParams += params;
|
m_applicationParams += params;
|
||||||
|
@ -20,13 +20,11 @@ import android.view.animation.AccelerateInterpolator;
|
|||||||
import android.view.animation.AlphaAnimation;
|
import android.view.animation.AlphaAnimation;
|
||||||
import android.view.animation.Animation;
|
import android.view.animation.Animation;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewConfiguration;
|
import android.view.ViewConfiguration;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
import android.view.WindowInsetsController;
|
import android.view.WindowInsetsController;
|
||||||
import android.view.ViewTreeObserver;
|
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.PopupMenu;
|
import android.widget.PopupMenu;
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@ import android.annotation.SuppressLint;
|
|||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
|
@ -59,7 +59,7 @@ public class QtClipboardManager
|
|||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||||
m_clipboardManager.clearPrimaryClip();
|
m_clipboardManager.clearPrimaryClip();
|
||||||
} else {
|
} else {
|
||||||
String[] mimeTypes = { ClipDescription.MIMETYPE_UNKNOWN };
|
String[] mimeTypes = { "application/octet-stream" };
|
||||||
ClipData data = new ClipData("", mimeTypes, new ClipData.Item(new Intent()));
|
ClipData data = new ClipData("", mimeTypes, new ClipData.Item(new Intent()));
|
||||||
m_clipboardManager.setPrimaryClip(data);
|
m_clipboardManager.setPrimaryClip(data);
|
||||||
}
|
}
|
||||||
|
@ -125,8 +125,10 @@ public class QtDisplayManager {
|
|||||||
case SYSTEM_UI_VISIBILITY_NORMAL:
|
case SYSTEM_UI_VISIBILITY_NORMAL:
|
||||||
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
|
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
|
||||||
activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||||
setDisplayCutoutLayout(activity,
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||||
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER);
|
activity.getWindow().getAttributes().layoutInDisplayCutoutMode =
|
||||||
|
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case SYSTEM_UI_VISIBILITY_FULLSCREEN:
|
case SYSTEM_UI_VISIBILITY_FULLSCREEN:
|
||||||
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||||
@ -138,16 +140,20 @@ public class QtDisplayManager {
|
|||||||
| View.SYSTEM_UI_FLAG_FULLSCREEN
|
| View.SYSTEM_UI_FLAG_FULLSCREEN
|
||||||
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
|
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
|
||||||
| View.INVISIBLE;
|
| View.INVISIBLE;
|
||||||
setDisplayCutoutLayout(activity,
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||||
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT);
|
activity.getWindow().getAttributes().layoutInDisplayCutoutMode =
|
||||||
|
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case SYSTEM_UI_VISIBILITY_TRANSLUCENT:
|
case SYSTEM_UI_VISIBILITY_TRANSLUCENT:
|
||||||
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN
|
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN
|
||||||
| WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION
|
| WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION
|
||||||
| WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
|
| WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
|
||||||
activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||||
setDisplayCutoutLayout(activity,
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||||
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS);
|
activity.getWindow().getAttributes().layoutInDisplayCutoutMode =
|
||||||
|
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
activity.getWindow().getDecorView().setSystemUiVisibility(systemUiVisibilityFlags);
|
activity.getWindow().getDecorView().setSystemUiVisibility(systemUiVisibilityFlags);
|
||||||
@ -158,12 +164,6 @@ public class QtDisplayManager {
|
|||||||
return m_systemUiVisibility;
|
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)
|
public void updateFullScreen(Activity activity)
|
||||||
{
|
{
|
||||||
if (m_systemUiVisibility == SYSTEM_UI_VISIBILITY_FULLSCREEN) {
|
if (m_systemUiVisibility == SYSTEM_UI_VISIBILITY_FULLSCREEN) {
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
package org.qtproject.qt.android;
|
package org.qtproject.qt.android;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.graphics.Canvas;
|
||||||
import android.text.InputType;
|
import android.text.InputType;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.inputmethod.EditorInfo;
|
import android.view.inputmethod.EditorInfo;
|
||||||
@ -68,10 +69,10 @@ public class QtEditText extends View
|
|||||||
return new QtInputConnection(this, m_qtInputConnectionListener);
|
return new QtInputConnection(this, m_qtInputConnectionListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
// // DEBUG CODE
|
@Override
|
||||||
// @Override
|
protected void onDraw(Canvas canvas) {
|
||||||
// protected void onDraw(Canvas canvas) {
|
// DEBUG CODE
|
||||||
// canvas.drawARGB(127, 255, 0, 255);
|
// canvas.drawARGB(127, 255, 0, 255);
|
||||||
// super.onDraw(canvas);
|
super.onDraw(canvas);
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@ import android.view.inputmethod.InputMethodManager;
|
|||||||
|
|
||||||
import org.qtproject.qt.android.QtInputConnection.QtInputConnectionListener;
|
import org.qtproject.qt.android.QtInputConnection.QtInputConnectionListener;
|
||||||
|
|
||||||
|
/** @noinspection FieldCanBeLocal*/
|
||||||
public class QtInputDelegate {
|
public class QtInputDelegate {
|
||||||
|
|
||||||
// keyboard methods
|
// keyboard methods
|
||||||
|
@ -280,7 +280,8 @@ public abstract class QtLoader {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the application level metadata.
|
* Returns the application level metadata.
|
||||||
**/
|
*
|
||||||
|
* @noinspection SameParameterValue*/
|
||||||
private String getApplicationMetaData(String key) {
|
private String getApplicationMetaData(String key) {
|
||||||
if (m_contextInfo == null)
|
if (m_contextInfo == null)
|
||||||
return "";
|
return "";
|
||||||
|
@ -7,7 +7,6 @@ package org.qtproject.qt.android;
|
|||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
@ -80,36 +79,18 @@ public class QtMessageDialogHelper
|
|||||||
switch (m_standardIcon)
|
switch (m_standardIcon)
|
||||||
{
|
{
|
||||||
case 1: // Information
|
case 1: // Information
|
||||||
try {
|
|
||||||
return m_activity.getResources().getDrawable(android.R.drawable.ic_dialog_info,
|
return m_activity.getResources().getDrawable(android.R.drawable.ic_dialog_info,
|
||||||
m_activity.getTheme());
|
m_activity.getTheme());
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 2: // Warning
|
case 2: // Warning
|
||||||
// try {
|
return m_activity.getResources().getDrawable(android.R.drawable.stat_sys_warning,
|
||||||
// return Class.forName("android.R$drawable").getDeclaredField("stat_sys_warning").getInt(null);
|
m_activity.getTheme());
|
||||||
// } catch (Exception e) {
|
|
||||||
// e.printStackTrace();
|
|
||||||
// }
|
|
||||||
// break;
|
// break;
|
||||||
case 3: // Critical
|
case 3: // Critical
|
||||||
try {
|
|
||||||
return m_activity.getResources().getDrawable(android.R.drawable.ic_dialog_alert,
|
return m_activity.getResources().getDrawable(android.R.drawable.ic_dialog_alert,
|
||||||
m_activity.getTheme());
|
m_activity.getTheme());
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 4: // Question
|
case 4: // Question
|
||||||
try {
|
|
||||||
return m_activity.getResources().getDrawable(android.R.drawable.ic_menu_help,
|
return m_activity.getResources().getDrawable(android.R.drawable.ic_menu_help,
|
||||||
m_activity.getTheme());
|
m_activity.getTheme());
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -146,9 +127,9 @@ public class QtMessageDialogHelper
|
|||||||
m_buttonsList.add(new ButtonStruct(this, id, text));
|
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);
|
final TypedArray a = m_theme.obtainStyledAttributes(attrs);
|
||||||
Drawable d = a.getDrawable(0);
|
Drawable d = a.getDrawable(0);
|
||||||
a.recycle();
|
a.recycle();
|
||||||
@ -192,9 +173,11 @@ public class QtMessageDialogHelper
|
|||||||
view.setLongClickable(true);
|
view.setLongClickable(true);
|
||||||
|
|
||||||
view.setText(m_text);
|
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.setMargins(16, 8, 16, 8);
|
||||||
layout.addRule(RelativeLayout.ALIGN_PARENT_TOP);
|
layout.addRule(RelativeLayout.ALIGN_PARENT_TOP);
|
||||||
dialogLayout.addView(view, layout);
|
dialogLayout.addView(view, layout);
|
||||||
@ -209,9 +192,11 @@ public class QtMessageDialogHelper
|
|||||||
view.setLongClickable(true);
|
view.setLongClickable(true);
|
||||||
|
|
||||||
view.setText(m_informativeText);
|
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);
|
layout.setMargins(16, 8, 16, 8);
|
||||||
if (lastView != null)
|
if (lastView != null)
|
||||||
layout.addRule(RelativeLayout.BELOW, lastView.getId());
|
layout.addRule(RelativeLayout.BELOW, lastView.getId());
|
||||||
@ -229,9 +214,11 @@ public class QtMessageDialogHelper
|
|||||||
view.setLongClickable(true);
|
view.setLongClickable(true);
|
||||||
|
|
||||||
view.setText(m_detailedText);
|
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);
|
layout.setMargins(16, 8, 16, 8);
|
||||||
if (lastView != null)
|
if (lastView != null)
|
||||||
layout.addRule(RelativeLayout.BELOW, lastView.getId());
|
layout.addRule(RelativeLayout.BELOW, lastView.getId());
|
||||||
@ -251,7 +238,7 @@ public class QtMessageDialogHelper
|
|||||||
{
|
{
|
||||||
Button bv;
|
Button bv;
|
||||||
try {
|
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) {
|
} catch (Exception e) {
|
||||||
bv = new Button(m_activity);
|
bv = new Button(m_activity);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -265,7 +252,7 @@ public class QtMessageDialogHelper
|
|||||||
try {
|
try {
|
||||||
LinearLayout.LayoutParams layout = new LinearLayout.LayoutParams(1,
|
LinearLayout.LayoutParams layout = new LinearLayout.LayoutParams(1,
|
||||||
RelativeLayout.LayoutParams.MATCH_PARENT);
|
RelativeLayout.LayoutParams.MATCH_PARENT);
|
||||||
spacer.setBackgroundDrawable(getStyledDrawable("dividerVertical"));
|
spacer.setBackground(getStyledDrawable(android.R.attr.dividerVertical));
|
||||||
buttonsLayout.addView(spacer, layout);
|
buttonsLayout.addView(spacer, layout);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -279,22 +266,26 @@ public class QtMessageDialogHelper
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
View horizontalDevider = new View(m_activity);
|
View horizontalDivider = new View(m_activity);
|
||||||
horizontalDevider.setId(id++);
|
horizontalDivider.setId(id);
|
||||||
horizontalDevider.setBackgroundDrawable(getStyledDrawable("dividerHorizontal"));
|
horizontalDivider.setBackground(getStyledDrawable(
|
||||||
RelativeLayout.LayoutParams relativeParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, 1);
|
android.R.attr.dividerHorizontal));
|
||||||
|
RelativeLayout.LayoutParams relativeParams = new RelativeLayout.LayoutParams(
|
||||||
|
RelativeLayout.LayoutParams.MATCH_PARENT, 1);
|
||||||
relativeParams.setMargins(0, 10, 0, 0);
|
relativeParams.setMargins(0, 10, 0, 0);
|
||||||
if (lastView != null) {
|
if (lastView != null) {
|
||||||
relativeParams.addRule(RelativeLayout.BELOW, lastView.getId());
|
relativeParams.addRule(RelativeLayout.BELOW, lastView.getId());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
relativeParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
|
relativeParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
|
||||||
dialogLayout.addView(horizontalDevider, relativeParams);
|
dialogLayout.addView(horizontalDivider, relativeParams);
|
||||||
lastView = horizontalDevider;
|
lastView = horizontalDivider;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
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) {
|
if (lastView != null) {
|
||||||
relativeParams.addRule(RelativeLayout.BELOW, lastView.getId());
|
relativeParams.addRule(RelativeLayout.BELOW, lastView.getId());
|
||||||
}
|
}
|
||||||
|
@ -122,6 +122,7 @@ public class QtNative
|
|||||||
return new Exception().getStackTrace()[1].getMethodName() + ": ";
|
return new Exception().getStackTrace()[1].getMethodName() + ": ";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @noinspection SameParameterValue*/
|
||||||
private static Uri getUriWithValidPermission(Context context, String uri, String openMode)
|
private static Uri getUriWithValidPermission(Context context, String uri, String openMode)
|
||||||
{
|
{
|
||||||
Uri parsedUri;
|
Uri parsedUri;
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
package org.qtproject.qt.android;
|
package org.qtproject.qt.android;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.PixelFormat;
|
import android.graphics.PixelFormat;
|
||||||
import android.view.GestureDetector;
|
import android.view.GestureDetector;
|
||||||
@ -11,6 +12,7 @@ import android.view.MotionEvent;
|
|||||||
import android.view.SurfaceHolder;
|
import android.view.SurfaceHolder;
|
||||||
import android.view.SurfaceView;
|
import android.view.SurfaceView;
|
||||||
|
|
||||||
|
@SuppressLint("ViewConstructor")
|
||||||
public class QtSurface extends SurfaceView implements SurfaceHolder.Callback
|
public class QtSurface extends SurfaceView implements SurfaceHolder.Callback
|
||||||
{
|
{
|
||||||
private final GestureDetector m_gestureDetector;
|
private final GestureDetector m_gestureDetector;
|
||||||
|
@ -29,7 +29,7 @@ public class QtAccessibilityDelegate extends View.AccessibilityDelegate
|
|||||||
{
|
{
|
||||||
private static final String TAG = "Qt A11Y";
|
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.
|
// all low positive ints should be fine.
|
||||||
public static final int INVALID_ID = 333; // half evil
|
public static final int INVALID_ID = 333; // half evil
|
||||||
|
|
||||||
@ -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
|
// ### Keep this for debugging for a while. It allows us to visually see that our View
|
||||||
// ### is on top of the surface(s)
|
// ### is on top of the surface(s)
|
||||||
|
//noinspection CommentedOutCode
|
||||||
|
{
|
||||||
// ColorDrawable color = new ColorDrawable(0x80ff8080); //0xAARRGGBB
|
// ColorDrawable color = new ColorDrawable(0x80ff8080); //0xAARRGGBB
|
||||||
// view.setBackground(color);
|
// view.setBackground(color);
|
||||||
|
}
|
||||||
view.setAccessibilityDelegate(QtAccessibilityDelegate.this);
|
view.setAccessibilityDelegate(QtAccessibilityDelegate.this);
|
||||||
|
|
||||||
// if all is fine, add it to the layout
|
// if all is fine, add it to the layout
|
||||||
@ -149,8 +152,6 @@ public class QtAccessibilityDelegate extends View.AccessibilityDelegate
|
|||||||
switch (event.getAction()) {
|
switch (event.getAction()) {
|
||||||
case MotionEvent.ACTION_HOVER_ENTER:
|
case MotionEvent.ACTION_HOVER_ENTER:
|
||||||
case MotionEvent.ACTION_HOVER_MOVE:
|
case MotionEvent.ACTION_HOVER_MOVE:
|
||||||
setHoveredVirtualViewId(virtualViewId);
|
|
||||||
break;
|
|
||||||
case MotionEvent.ACTION_HOVER_EXIT:
|
case MotionEvent.ACTION_HOVER_EXIT:
|
||||||
setHoveredVirtualViewId(virtualViewId);
|
setHoveredVirtualViewId(virtualViewId);
|
||||||
break;
|
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);
|
final AccessibilityEvent event = getEventForVirtualViewId(virtualViewId, eventType);
|
||||||
return sendAccessibilityEvent(event);
|
sendAccessibilityEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean sendAccessibilityEvent(AccessibilityEvent event)
|
public void sendAccessibilityEvent(AccessibilityEvent event)
|
||||||
{
|
{
|
||||||
if (event == null)
|
if (event == null)
|
||||||
return false;
|
return;
|
||||||
|
|
||||||
final ViewGroup group = (ViewGroup) m_view.getParent();
|
final ViewGroup group = (ViewGroup) m_view.getParent();
|
||||||
if (group == null) {
|
if (group == null) {
|
||||||
Log.w(TAG, "Could not send AccessibilityEvent because group was null. This should really not happen.");
|
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)
|
public void invalidateVirtualViewId(int virtualViewId)
|
||||||
@ -416,10 +417,10 @@ public class QtAccessibilityDelegate extends View.AccessibilityDelegate
|
|||||||
// Manage internal accessibility focus state.
|
// Manage internal accessibility focus state.
|
||||||
if (m_focusedVirtualViewId == virtualViewId) {
|
if (m_focusedVirtualViewId == virtualViewId) {
|
||||||
node.setAccessibilityFocused(true);
|
node.setAccessibilityFocused(true);
|
||||||
node.addAction(AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS);
|
node.performAction(AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS);
|
||||||
} else {
|
} else {
|
||||||
node.setAccessibilityFocused(false);
|
node.setAccessibilityFocused(false);
|
||||||
node.addAction(AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS);
|
node.performAction(AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS);
|
||||||
}
|
}
|
||||||
|
|
||||||
int[] ids = QtNativeAccessibility.childIdListForAccessibleObject(virtualViewId);
|
int[] ids = QtNativeAccessibility.childIdListForAccessibleObject(virtualViewId);
|
||||||
@ -483,16 +484,19 @@ public class QtAccessibilityDelegate extends View.AccessibilityDelegate
|
|||||||
return m_view.performAccessibilityAction(action, arguments);
|
return m_view.performAccessibilityAction(action, arguments);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
handled |= performActionForVirtualViewId(virtualViewId, action, arguments);
|
handled |= performActionForVirtualViewId(virtualViewId, action);
|
||||||
|
|
||||||
return handled;
|
return handled;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
protected boolean performActionForVirtualViewId(int virtualViewId, int action, Bundle arguments)
|
protected boolean performActionForVirtualViewId(int virtualViewId, int action)
|
||||||
|
{
|
||||||
|
//noinspection CommentedOutCode
|
||||||
{
|
{
|
||||||
// Log.i(TAG, "ACTION " + action + " on " + virtualViewId);
|
// Log.i(TAG, "ACTION " + action + " on " + virtualViewId);
|
||||||
// dumpNodes(virtualViewId);
|
// dumpNodes(virtualViewId);
|
||||||
|
}
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case AccessibilityNodeInfo.ACTION_CLICK:
|
case AccessibilityNodeInfo.ACTION_CLICK:
|
||||||
|
@ -19,5 +19,4 @@ class QtNativeAccessibility
|
|||||||
static native boolean scrollBackward(int objectId);
|
static native boolean scrollBackward(int objectId);
|
||||||
|
|
||||||
static native boolean populateNode(int objectId, AccessibilityNodeInfo node);
|
static native boolean populateNode(int objectId, AccessibilityNodeInfo node);
|
||||||
static native String valueForAccessibleObject(int objectId);
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user