From 6d8f2280deb87c7ace9af19d04031a9253579f54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20L=C3=A4nge?= Date: Wed, 17 Jan 2024 19:19:03 +0100 Subject: [PATCH] Fix lint errors --- app/build.gradle | 4 +++ app/lint.xml | 10 +++++++ .../activities/GameActivity.java | 28 ++++++++++--------- .../database/DatabaseExporter.java | 2 +- .../main/res/layout-land/activity_main.xml | 4 --- app/src/main/res/layout/activity_main.xml | 18 +++++------- 6 files changed, 37 insertions(+), 29 deletions(-) create mode 100644 app/lint.xml diff --git a/app/build.gradle b/app/build.gradle index 46f6acf..0032737 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -45,6 +45,10 @@ android { enabled = true } namespace 'org.secuso.privacyfriendly2048' + + lint { + lintConfig = file("lint.xml") + } } dependencies { diff --git a/app/lint.xml b/app/lint.xml new file mode 100644 index 0000000..1b66a25 --- /dev/null +++ b/app/lint.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/app/src/main/java/org/secuso/privacyfriendly2048/activities/GameActivity.java b/app/src/main/java/org/secuso/privacyfriendly2048/activities/GameActivity.java index 51d1875..e182150 100644 --- a/app/src/main/java/org/secuso/privacyfriendly2048/activities/GameActivity.java +++ b/app/src/main/java/org/secuso/privacyfriendly2048/activities/GameActivity.java @@ -835,7 +835,7 @@ public void updateHighestNumber() public void check2048() { - if(won2048 == false) + if(won2048 == false) { for(int i = 0; i < elements.length; i++) { for(int j = 0; j < elements[i].length; j++) @@ -866,6 +866,7 @@ public void onClick(DialogInterface dialog, int which) { } } } + } } @@ -1138,18 +1139,19 @@ public void onSaveInstanceState(Bundle savedInstanceState) { public void saveStateToFile(GameState nS) { - if(saveState) - try { - if(filename == null) - filename = "state" + n + ".txt"; - File file = new File(getFilesDir(), filename); - FileOutputStream fileOut = new FileOutputStream(file); - ObjectOutputStream out = new ObjectOutputStream(fileOut); - out.writeObject(nS); - out.close(); - fileOut.close(); - } catch (IOException e) { - e.printStackTrace(); + if(saveState) { + try { + if (filename == null) + filename = "state" + n + ".txt"; + File file = new File(getFilesDir(), filename); + FileOutputStream fileOut = new FileOutputStream(file); + ObjectOutputStream out = new ObjectOutputStream(fileOut); + out.writeObject(nS); + out.close(); + fileOut.close(); + } catch (IOException e) { + e.printStackTrace(); + } } } diff --git a/app/src/main/java/org/secuso/privacyfriendly2048/database/DatabaseExporter.java b/app/src/main/java/org/secuso/privacyfriendly2048/database/DatabaseExporter.java index 1ed1c67..26fbde8 100644 --- a/app/src/main/java/org/secuso/privacyfriendly2048/database/DatabaseExporter.java +++ b/app/src/main/java/org/secuso/privacyfriendly2048/database/DatabaseExporter.java @@ -115,7 +115,7 @@ public ArrayList getTableNames() { if (c.moveToFirst()) { while (!c.isAfterLast()) { - arrTblNames.add(c.getString(c.getColumnIndex("name"))); + arrTblNames.add(c.getString(c.getColumnIndexOrThrow("name"))); c.moveToNext(); } } diff --git a/app/src/main/res/layout-land/activity_main.xml b/app/src/main/res/layout-land/activity_main.xml index c176eef..f1dd0f8 100644 --- a/app/src/main/res/layout-land/activity_main.xml +++ b/app/src/main/res/layout-land/activity_main.xml @@ -48,7 +48,6 @@ android:layout_marginStart="@dimen/activity_horizontal_margin" android:layout_weight="1" android:background="?attr/selectableItemBackgroundBorderless" - android:onClick="onClick" android:padding="@dimen/activity_horizontal_margin" android:src="@drawable/ic_keyboard_arrow_left_black_24dp" /> @@ -75,7 +74,6 @@ android:layout_marginRight="@dimen/activity_horizontal_margin" android:layout_weight="1" android:background="?attr/selectableItemBackgroundBorderless" - android:onClick="onClick" android:padding="10dp" android:src="@drawable/ic_keyboard_arrow_right_black_24dp" /> @@ -121,7 +119,6 @@ android:layout_weight="3" android:background="@color/colorPrimary" android:clickable="false" - android:onClick="onClick" android:text="@string/new_Game_Button" android:textColor="@color/white" android:textStyle="normal" /> @@ -137,7 +134,6 @@ android:layout_weight="3" android:background="@color/colorPrimary" android:clickable="false" - android:onClick="onClick" android:text="@string/continue_Game_Button" android:textColor="@color/white" android:textStyle="normal" /> diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index ac13d54..71853c9 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -53,14 +53,13 @@ android:id="@+id/btn_prev" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_alignParentLeft="true" android:layout_alignParentStart="true" + android:layout_alignParentLeft="true" android:layout_centerVertical="true" - android:layout_marginLeft="@dimen/activity_horizontal_margin" android:layout_marginStart="@dimen/activity_horizontal_margin" + android:layout_marginLeft="@dimen/activity_horizontal_margin" android:layout_weight="1" android:background="?attr/selectableItemBackgroundBorderless" - android:onClick="onClick" android:padding="@dimen/activity_horizontal_margin" android:src="@drawable/ic_keyboard_arrow_left_black_24dp" android:visibility="invisible" /> @@ -76,7 +75,6 @@ android:layout_marginRight="@dimen/activity_horizontal_margin" android:layout_weight="1" android:background="?attr/selectableItemBackgroundBorderless" - android:onClick="onClick" android:padding="10dp" android:src="@drawable/ic_keyboard_arrow_right_black_24dp" /> @@ -90,10 +88,10 @@ android:divider="#000" android:gravity="center_horizontal" android:orientation="vertical" - android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" - android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" + android:paddingRight="@dimen/activity_horizontal_margin" + android:paddingBottom="@dimen/activity_vertical_margin" android:weightSum="5" tools:context=".activities.MainActivity"> @@ -101,8 +99,8 @@ android:id="@+id/layoutDots" android:layout_width="match_parent" android:layout_height="0dp" - android:layout_alignParentBottom="true" android:layout_alignParentStart="true" + android:layout_alignParentBottom="true" android:layout_weight="1" android:gravity="center" android:orientation="horizontal"> @@ -115,12 +113,11 @@ android:layout_height="0dp" android:layout_gravity="center_horizontal" android:layout_marginLeft="20dp" - android:layout_marginRight="20dp" android:layout_marginTop="10dp" + android:layout_marginRight="20dp" android:layout_weight="2" android:background="@drawable/standalone_button" android:clickable="false" - android:onClick="onClick" android:text="@string/new_Game_Button" android:textColor="@color/white" android:textSize="25sp" @@ -132,12 +129,11 @@ android:layout_height="0dp" android:layout_gravity="center_horizontal" android:layout_marginLeft="20dp" - android:layout_marginRight="20dp" android:layout_marginTop="10dp" + android:layout_marginRight="20dp" android:layout_weight="2" android:background="@drawable/standalone_button" android:clickable="false" - android:onClick="onClick" android:text="@string/continue_Game_Button" android:textColor="@color/white" android:textSize="25sp"