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 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;
public interface OnClickListener

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -14,7 +14,6 @@ import android.view.SurfaceView;
public class QtSurface extends SurfaceView implements SurfaceHolder.Callback
{
private final GestureDetector m_gestureDetector;
private Object m_accessibilityDelegate = null;
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;
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 final Thread m_qtThread = new Thread(new Runnable() {
@Override
@ -18,7 +18,7 @@ public class QtThread {
synchronized (m_qtThread) {
if (m_pendingRunnables.size() == 0)
m_qtThread.wait();
pendingRunnables = new ArrayList<Runnable>(m_pendingRunnables);
pendingRunnables = new ArrayList<>(m_pendingRunnables);
m_pendingRunnables.clear();
}
for (Runnable runnable : pendingRunnables)

View File

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