Android: remove redundant assignement and type specifiers

that kind of code gives Android Java warnings.

Task-number: QTBUG-118077
Change-Id: I395c650aba209a84ff1b7548821444f3d1e461e3
Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
This commit is contained in:
Assam Boudjelthia 2023-11-11 03:01:57 +02:00
parent c8bf35f4e4
commit 869e9b927a
9 changed files with 18 additions and 22 deletions

View File

@ -23,7 +23,7 @@ public class EditContextView extends LinearLayout implements View.OnClickListene
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 SALL_BUTTON = 1 << 3;
HashMap<Integer, ContextButton> m_buttons = new HashMap<Integer, ContextButton>(4); HashMap<Integer, ContextButton> m_buttons = new HashMap<>(4);
OnClickListener m_onClickListener; OnClickListener m_onClickListener;
public interface OnClickListener public interface OnClickListener

View File

@ -37,7 +37,7 @@ import org.qtproject.qt.android.accessibility.QtAccessibilityDelegate;
public class QtActivityDelegate public class QtActivityDelegate
{ {
private Activity m_activity = null; private Activity m_activity;
private boolean m_started = false; private boolean m_started = false;
private boolean m_quitApp = true; private boolean m_quitApp = true;
@ -218,8 +218,8 @@ public class QtActivityDelegate
e.printStackTrace(); e.printStackTrace();
} }
m_surfaces = new HashMap<Integer, QtSurface>(); m_surfaces = new HashMap<>();
m_nativeViews = new HashMap<Integer, View>(); m_nativeViews = new HashMap<>();
m_activity.registerForContextMenu(m_layout); m_activity.registerForContextMenu(m_layout);
m_activity.setContentView(m_layout, m_activity.setContentView(m_layout,
new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,

View File

@ -6,8 +6,6 @@ package org.qtproject.qt.android;
import android.app.Application; import android.app.Application;
public class QtApplicationBase extends Application { public class QtApplicationBase extends Application {
public final static String QtTAG = "Qt";
@Override @Override
public void onTerminate() { public void onTerminate() {
QtNative.terminateQt(); QtNative.terminateQt();

View File

@ -71,7 +71,7 @@ public class QtInputConnection extends BaseInputConnection
Rect r = new Rect(); Rect r = new Rect();
activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(r); activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(r);
int screenHeight = 0; int screenHeight;
if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.R) { if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {
DisplayMetrics metrics = new DisplayMetrics(); DisplayMetrics metrics = new DisplayMetrics();
activity.getWindowManager().getDefaultDisplay().getMetrics(metrics); activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);

View File

@ -163,8 +163,7 @@ public class QtLayout extends ViewGroup
/** /**
* Per-child layout information associated with AbsoluteLayout. * Per-child layout information associated with AbsoluteLayout.
* See * See {android.R.styleable#AbsoluteLayout_Layout Absolute Layout Attributes}
* {@link android.R.styleable#AbsoluteLayout_Layout Absolute Layout Attributes}
* for a list of all child view attributes that this class supports. * for a list of all child view attributes that this class supports.
*/ */
public static class LayoutParams extends ViewGroup.LayoutParams public static class LayoutParams extends ViewGroup.LayoutParams
@ -221,7 +220,7 @@ public class QtLayout extends ViewGroup
/** /**
* set the layout params on a child view. * set the layout params on a child view.
* * <p>
* Note: This function adds the child view if it's not in the * Note: This function adds the child view if it's not in the
* layout already. * layout already.
*/ */

View File

@ -142,7 +142,7 @@ public class QtMessageDialogHelper
public void addButton(int id, String text) public void addButton(int id, String text)
{ {
if (m_buttonsList == null) if (m_buttonsList == null)
m_buttonsList = new ArrayList<ButtonStruct>(); m_buttonsList = new ArrayList<>();
m_buttonsList.add(new ButtonStruct(this, id, text)); m_buttonsList.add(new ButtonStruct(this, id, text));
} }
@ -271,18 +271,19 @@ public class QtMessageDialogHelper
bv.setOnClickListener(button); bv.setOnClickListener(button);
if (!firstButton) // first button if (!firstButton) // first button
{ {
LinearLayout.LayoutParams layout = null;
View spacer = new View(m_activity); View spacer = new View(m_activity);
try { try {
layout = new LinearLayout.LayoutParams(1, RelativeLayout.LayoutParams.MATCH_PARENT); LinearLayout.LayoutParams layout = new LinearLayout.LayoutParams(1,
RelativeLayout.LayoutParams.MATCH_PARENT);
spacer.setBackgroundDrawable(getStyledDrawable("dividerVertical")); spacer.setBackgroundDrawable(getStyledDrawable("dividerVertical"));
buttonsLayout.addView(spacer, layout); buttonsLayout.addView(spacer, layout);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
LinearLayout.LayoutParams layout = null; LinearLayout.LayoutParams layout = new LinearLayout.LayoutParams(
layout = new LinearLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT, 1.0f); RelativeLayout.LayoutParams.MATCH_PARENT,
RelativeLayout.LayoutParams.WRAP_CONTENT, 1.0f);
buttonsLayout.addView(bv, layout); buttonsLayout.addView(bv, layout);
firstButton = false; firstButton = false;
} }

View File

@ -14,7 +14,6 @@ import android.view.SurfaceView;
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;
private Object m_accessibilityDelegate = null;
public QtSurface(Context context, int id, boolean onTop, int imageDepth) public QtSurface(Context context, int id, boolean onTop, int imageDepth)
{ {

View File

@ -7,7 +7,7 @@ import java.util.ArrayList;
import java.util.concurrent.Semaphore; import java.util.concurrent.Semaphore;
public class QtThread { public class QtThread {
private final ArrayList<Runnable> m_pendingRunnables = new ArrayList<Runnable>(); private final ArrayList<Runnable> m_pendingRunnables = new ArrayList<>();
private boolean m_exit = false; private boolean m_exit = false;
private final Thread m_qtThread = new Thread(new Runnable() { private final Thread m_qtThread = new Thread(new Runnable() {
@Override @Override
@ -18,7 +18,7 @@ public class QtThread {
synchronized (m_qtThread) { synchronized (m_qtThread) {
if (m_pendingRunnables.size() == 0) if (m_pendingRunnables.size() == 0)
m_qtThread.wait(); m_qtThread.wait();
pendingRunnables = new ArrayList<Runnable>(m_pendingRunnables); pendingRunnables = new ArrayList<>(m_pendingRunnables);
m_pendingRunnables.clear(); m_pendingRunnables.clear();
} }
for (Runnable runnable : pendingRunnables) for (Runnable runnable : pendingRunnables)

View File

@ -113,7 +113,7 @@ public class QtAccessibilityDelegate extends View.AccessibilityDelegate
m_view.setOnHoverListener(new HoverEventListener()); m_view.setOnHoverListener(new HoverEventListener());
} catch (Exception e) { } catch (Exception e) {
// Unknown exception means something went wrong. // Unknown exception means something went wrong.
Log.w("Qt A11y", "Unknown exception: " + e.toString()); Log.w("Qt A11y", "Unknown exception: " + e);
} }
} else { } else {
if (m_view != null) { if (m_view != null) {
@ -425,10 +425,9 @@ public class QtAccessibilityDelegate extends View.AccessibilityDelegate
screenRect.offset(offsetX, offsetY); screenRect.offset(offsetX, offsetY);
node.setBoundsInScreen(screenRect); node.setBoundsInScreen(screenRect);
Rect rectInParent = screenRect;
Rect parentScreenRect = QtNativeAccessibility.screenRect(parentId); Rect parentScreenRect = QtNativeAccessibility.screenRect(parentId);
rectInParent.offset(-parentScreenRect.left, -parentScreenRect.top); screenRect.offset(-parentScreenRect.left, -parentScreenRect.top);
node.setBoundsInParent(rectInParent); node.setBoundsInParent(screenRect);
// Manage internal accessibility focus state. // Manage internal accessibility focus state.
if (m_focusedVirtualViewId == virtualViewId) { if (m_focusedVirtualViewId == virtualViewId) {