From 5fb4db37bf653bf6a61cc629fb0d9c9d3f0a9787 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ilma=20Lu=C5=A1ija?= Date: Mon, 9 May 2022 21:34:00 +0200 Subject: [PATCH] CATROID-810 Fix some linting errors --- catroid/config/lint-baseline.xml | 1018 ++--------------- .../catroid/io/StorageOperations.java | 35 +- .../catroid/stage/SpeechRecognitionHolder.kt | 5 +- .../main/res/layout/dialog_new_project.xml | 3 + .../main/res/layout/dialog_select_cast.xml | 1 + .../layout/fragment_accesibility_profiles.xml | 2 + .../layout/icon_brick_category_legonxt.xml | 5 +- .../res/layout/icon_brick_category_look.xml | 5 +- .../res/layout/icon_brick_category_motion.xml | 5 +- .../res/layout/icon_brick_category_pen.xml | 5 +- .../res/layout/icon_brick_category_phiro.xml | 5 +- .../icon_brick_category_raspberrypi.xml | 5 +- .../icon_brick_category_recently_used.xml | 5 +- .../res/layout/icon_brick_category_sound.xml | 5 +- .../layout/icon_brick_category_userbrick.xml | 5 +- .../main/res/layout/single_seek_bar_view.xml | 1 + .../src/main/res/layout/view_holder_file.xml | 4 +- .../src/main/res/layout/view_holder_list.xml | 6 +- .../layout/view_holder_sprite_group_item.xml | 5 +- .../main/res/layout/view_holder_variable.xml | 6 +- .../res/layout/view_holder_with_checkbox.xml | 6 +- .../main/res/layout/view_script_finder.xml | 1 + .../res/mipmap-xxxhdpi/ic_launcher_round.png | Bin 16904 -> 0 bytes catroid/src/main/res/values-v25/styles.xml | 13 +- catroid/src/main/res/values/strings.xml | 1 + catroid/src/main/res/values/styles.xml | 12 +- 26 files changed, 152 insertions(+), 1012 deletions(-) delete mode 100644 catroid/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png diff --git a/catroid/config/lint-baseline.xml b/catroid/config/lint-baseline.xml index 99ba72c3278..84273ba4a42 100644 --- a/catroid/config/lint-baseline.xml +++ b/catroid/config/lint-baseline.xml @@ -1,26 +1,4 @@ - - - - - @@ -129,10 +96,21 @@ errorLine2=" ~~~~~~~~~~~~~~~~"> + + + + @@ -151,52 +129,74 @@ errorLine2=" ~~~~~~~~~~~~~~~~"> + message="Missing permissions required by BluetoothDevice.getName: android.permission.BLUETOOTH_CONNECT" + errorLine1=" String deviceInfoBLE = "BLE" + (device.getName() != null ? " - " + device.getName() : "");" + errorLine2=" ~~~~~~~~~~~~~~~~"> + line="163" + column="39"/> + errorLine1=" String deviceInfoBLE = "BLE" + (device.getName() != null ? " - " + device.getName() : "");" + errorLine2=" ~~~~~~~~~~~~~~~~"> + line="163" + column="74"/> + message="Missing permissions required by intent BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE: android.permission.BLUETOOTH_ADVERTISE" + errorLine1=" startActivity(intent);" + errorLine2=" ~~~~~~~~~~~~~~~~~~~~"> + line="401" + column="4"/> + message="Missing permissions required by BluetoothAdapter.getBondedDevices: android.permission.BLUETOOTH_CONNECT" + errorLine1=" Set<android.bluetooth.BluetoothDevice> pairedDevices = btManager.getBluetoothAdapter().getBondedDevices();" + errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> + line="413" + column="58"/> + + + + + + + + @@ -217,19 +217,19 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> + message="Missing permissions required by BluetoothAdapter.listenUsingRfcommWithServiceRecord: android.permission.BLUETOOTH_CONNECT" + errorLine1=" serverSocket = BluetoothAdapter.getDefaultAdapter()" + errorLine2=" ^"> + line="523" + column="20"/> - - - - - - - - - - - - @@ -327,7 +294,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~"> @@ -408,28 +375,6 @@ column="16"/> - - - - - - - - @@ -452,57 +397,6 @@ file="src\main\res\drawable-xhdpi\brick_control_1h.9.png"/> - - - - - - - - - - - - - - - - - - - @@ -517,17 +411,6 @@ file="src\main\res\drawable-xxhdpi"/> - - - - @@ -601,7 +484,7 @@ errorLine2=" ~~~~~~~"> @@ -623,7 +506,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -634,767 +517,8 @@ errorLine2=" ~~~~~~~"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/catroid/src/main/java/org/catrobat/catroid/io/StorageOperations.java b/catroid/src/main/java/org/catrobat/catroid/io/StorageOperations.java index 5143f49e8a5..8ba924609ca 100644 --- a/catroid/src/main/java/org/catrobat/catroid/io/StorageOperations.java +++ b/catroid/src/main/java/org/catrobat/catroid/io/StorageOperations.java @@ -1,6 +1,6 @@ /* * Catroid: An on-device visual programming system for Android devices - * Copyright (C) 2010-2021 The Catrobat Team + * Copyright (C) 2010-2022 The Catrobat Team * () * * This program is free software: you can redistribute it and/or modify @@ -41,6 +41,7 @@ import java.io.OutputStream; import java.nio.channels.FileChannel; import java.nio.file.InvalidPathException; +import java.util.Objects; import static org.catrobat.catroid.common.Constants.BUFFER_8K; import static org.catrobat.catroid.common.Constants.IMAGE_DIRECTORY_NAME; @@ -105,7 +106,10 @@ public static String resolveFileName(ContentResolver contentResolver, Uri uri) { try { try (Cursor cursor = contentResolver.query(uri, null, null, null, null)) { if (cursor != null && cursor.moveToFirst()) { - result = cursor.getString(cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME)); + int index = cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME); + if (index >= 0) { + result = cursor.getString(index); + } } } } catch (Exception e) { @@ -262,11 +266,14 @@ public static File copyDir(File sourceDir, File destinationDir) throws IOExcepti throw new IOException("Cannot create directory: " + destinationDir.getAbsolutePath()); } - for (File file : sourceDir.listFiles()) { - if (file.isDirectory()) { - copyDir(file, new File(destinationDir, file.getName())); - } else { - copyFileToDir(file, destinationDir); + File[] files = sourceDir.listFiles(); + if (files != null) { + for (File file : files) { + if (file.isDirectory()) { + copyDir(file, new File(destinationDir, file.getName())); + } else { + copyFileToDir(file, destinationDir); + } } } @@ -328,14 +335,16 @@ public static void deleteDir(File dir) throws IOException { throw new FileNotFoundException(dir.getAbsolutePath() + " is not a directory."); } - for (File file : dir.listFiles()) { - if (file.isDirectory()) { - deleteDir(file); - } else { - deleteFile(file); + File[] files = dir.listFiles(); + if (files != null) { + for (File file : files) { + if (file.isDirectory()) { + deleteDir(file); + } else { + deleteFile(file); + } } } - if (!dir.delete()) { throw new IOException("Cannot delete directory: " + dir.getAbsolutePath()); } diff --git a/catroid/src/main/java/org/catrobat/catroid/stage/SpeechRecognitionHolder.kt b/catroid/src/main/java/org/catrobat/catroid/stage/SpeechRecognitionHolder.kt index bfd20026241..cb93b502461 100644 --- a/catroid/src/main/java/org/catrobat/catroid/stage/SpeechRecognitionHolder.kt +++ b/catroid/src/main/java/org/catrobat/catroid/stage/SpeechRecognitionHolder.kt @@ -1,6 +1,6 @@ /* * Catroid: An on-device visual programming system for Android devices - * Copyright (C) 2010-2021 The Catrobat Team + * Copyright (C) 2010-2022 The Catrobat Team * () * * This program is free software: you can redistribute it and/or modify @@ -108,6 +108,9 @@ class SpeechRecognitionHolder : SpeechRecognitionHolderInterface { // in case the chosen language is not downloaded or outdated showDialog(stageActivity, stageResourceHolder) } + else -> { + // every other case + } } Log.d(TAG, "SpeechRecognizer restarted!") } diff --git a/catroid/src/main/res/layout/dialog_new_project.xml b/catroid/src/main/res/layout/dialog_new_project.xml index 684be3319ed..08d45675d19 100644 --- a/catroid/src/main/res/layout/dialog_new_project.xml +++ b/catroid/src/main/res/layout/dialog_new_project.xml @@ -64,6 +64,7 @@ android:layout_height="match_parent" android:layout_weight="0.33" android:drawableStart="@drawable/ic_smartphone_dialog_orientation_portrait" + android:paddingEnd="@dimen/material_design_spacing_large" android:paddingStart="@dimen/material_design_spacing_large"/> diff --git a/catroid/src/main/res/layout/dialog_select_cast.xml b/catroid/src/main/res/layout/dialog_select_cast.xml index 91cecb1ab7a..09cb77781ee 100644 --- a/catroid/src/main/res/layout/dialog_select_cast.xml +++ b/catroid/src/main/res/layout/dialog_select_cast.xml @@ -32,6 +32,7 @@ android:layout_height="80dp" android:id="@+id/empty_view_item" android:gravity="center_vertical" + android:paddingEnd="5dp" android:paddingStart="5dp">