Skip to content

Commit

Permalink
CATROID-810 Fix some linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
l-ilma committed Jul 12, 2022
1 parent e8cfbf8 commit 5fb4db3
Show file tree
Hide file tree
Showing 26 changed files with 152 additions and 1,012 deletions.
1,018 changes: 71 additions & 947 deletions catroid/config/lint-baseline.xml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -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
* (<http://developer.catrobat.org/credits>)
*
* This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}
}
}

Expand Down Expand Up @@ -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());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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
* (<http://developer.catrobat.org/credits>)
*
* This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -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!")
}
Expand Down
3 changes: 3 additions & 0 deletions catroid/src/main/res/layout/dialog_new_project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"/>

<RadioButton
Expand All @@ -72,6 +73,7 @@
android:layout_height="match_parent"
android:layout_weight="0.33"
android:drawableStart="@drawable/ic_smartphone_dialog_orientation_landscape"
android:paddingEnd="@dimen/material_design_spacing_large"
android:paddingStart="@dimen/material_design_spacing_large"/>

<RadioButton
Expand All @@ -81,6 +83,7 @@
android:layout_weight="0.33"
android:drawableStart="@drawable/ic_dialog_tv"
android:visibility="gone"
android:paddingEnd="@dimen/material_design_spacing_large"
android:paddingStart="@dimen/material_design_spacing_large"/>

</RadioGroup>
Expand Down
1 change: 1 addition & 0 deletions catroid/src/main/res/layout/dialog_select_cast.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
android:layout_height="80dp"
android:id="@+id/empty_view_item"
android:gravity="center_vertical"
android:paddingEnd="5dp"
android:paddingStart="5dp">

<ProgressBar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="@dimen/material_design_spacing_large"
android:paddingEnd="@dimen/material_design_spacing_large"
android:paddingTop="@dimen/material_design_spacing_large"
android:paddingBottom="@dimen/material_design_spacing_small"
android:text="@string/preference_title_accessibility_profile_headline"
Expand All @@ -52,6 +53,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="@dimen/material_design_spacing_large"
android:paddingEnd="@dimen/material_design_spacing_large"
android:paddingTop="@dimen/material_design_spacing_large"
android:paddingBottom="@dimen/material_design_spacing_small"
android:text="@string/preference_title_accessibility_predefined_profile_headline"
Expand Down
5 changes: 3 additions & 2 deletions catroid/src/main/res/layout/icon_brick_category_legonxt.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Catroid: An on-device visual programming system for Android devices
~ Copyright (C) 2010-2018 The Catrobat Team
~ Copyright (C) 2010-2022 The Catrobat Team
~ (<http://developer.catrobat.org/credits>)
~
~ This program is free software: you can redistribute it and/or modify
Expand All @@ -27,6 +27,7 @@
android:layout_height="wrap_content">
<ImageView
android:src="?attr/icon_legonxt"
style="@style/CategoryIconStyle">
style="@style/CategoryIconStyle"
android:contentDescription="@string/category_lego_nxt">
</ImageView >
</LinearLayout>
5 changes: 3 additions & 2 deletions catroid/src/main/res/layout/icon_brick_category_look.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Catroid: An on-device visual programming system for Android devices
~ Copyright (C) 2010-2018 The Catrobat Team
~ Copyright (C) 2010-2022 The Catrobat Team
~ (<http://developer.catrobat.org/credits>)
~
~ This program is free software: you can redistribute it and/or modify
Expand All @@ -27,6 +27,7 @@
android:layout_height="wrap_content">
<ImageView
android:src="?attr/icon_look"
style="@style/CategoryIconStyle">
style="@style/CategoryIconStyle"
android:contentDescription="@string/category_looks">
</ImageView >
</LinearLayout>
5 changes: 3 additions & 2 deletions catroid/src/main/res/layout/icon_brick_category_motion.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Catroid: An on-device visual programming system for Android devices
~ Copyright (C) 2010-2018 The Catrobat Team
~ Copyright (C) 2010-2022 The Catrobat Team
~ (<http://developer.catrobat.org/credits>)
~
~ This program is free software: you can redistribute it and/or modify
Expand All @@ -27,6 +27,7 @@
android:layout_height="wrap_content">
<ImageView
android:src="?attr/icon_motion"
style="@style/CategoryIconStyle">
style="@style/CategoryIconStyle"
android:contentDescription="@string/category_motion">
</ImageView >
</LinearLayout>
5 changes: 3 additions & 2 deletions catroid/src/main/res/layout/icon_brick_category_pen.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Catroid: An on-device visual programming system for Android devices
~ Copyright (C) 2010-2018 The Catrobat Team
~ Copyright (C) 2010-2022 The Catrobat Team
~ (<http://developer.catrobat.org/credits>)
~
~ This program is free software: you can redistribute it and/or modify
Expand All @@ -27,6 +27,7 @@
android:layout_height="wrap_content">
<ImageView
android:src="?attr/icon_pen"
style="@style/CategoryIconStyle">
style="@style/CategoryIconStyle"
android:contentDescription="@string/category_pen">
</ImageView >
</LinearLayout>
5 changes: 3 additions & 2 deletions catroid/src/main/res/layout/icon_brick_category_phiro.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Catroid: An on-device visual programming system for Android devices
~ Copyright (C) 2010-2018 The Catrobat Team
~ Copyright (C) 2010-2022 The Catrobat Team
~ (<http://developer.catrobat.org/credits>)
~
~ This program is free software: you can redistribute it and/or modify
Expand All @@ -27,6 +27,7 @@
android:layout_height="wrap_content">
<ImageView
android:src="?attr/icon_phiro"
style="@style/CategoryIconStyle">
style="@style/CategoryIconStyle"
android:contentDescription="@string/category_phiro">
</ImageView >
</LinearLayout>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Catroid: An on-device visual programming system for Android devices
~ Copyright (C) 2010-2018 The Catrobat Team
~ Copyright (C) 2010-2022 The Catrobat Team
~ (<http://developer.catrobat.org/credits>)
~
~ This program is free software: you can redistribute it and/or modify
Expand All @@ -27,6 +27,7 @@
android:layout_height="wrap_content">
<ImageView
android:src="?attr/icon_raspberrypi"
style="@style/CategoryIconStyle">
style="@style/CategoryIconStyle"
android:contentDescription="@string/category_raspi">
</ImageView >
</LinearLayout>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Catroid: An on-device visual programming system for Android devices
~ Copyright (C) 2010-2021 The Catrobat Team
~ Copyright (C) 2010-2022 The Catrobat Team
~ (<http://developer.catrobat.org/credits>)
~
~ This program is free software: you can redistribute it and/or modify
Expand All @@ -27,6 +27,7 @@
android:layout_height="wrap_content">
<ImageView
android:src="?attr/icon_recently_used"
style="@style/CategoryIconStyle">
style="@style/CategoryIconStyle"
android:contentDescription="@string/category_recently_used">
</ImageView >
</LinearLayout>
5 changes: 3 additions & 2 deletions catroid/src/main/res/layout/icon_brick_category_sound.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Catroid: An on-device visual programming system for Android devices
~ Copyright (C) 2010-2018 The Catrobat Team
~ Copyright (C) 2010-2022 The Catrobat Team
~ (<http://developer.catrobat.org/credits>)
~
~ This program is free software: you can redistribute it and/or modify
Expand All @@ -27,6 +27,7 @@
android:layout_height="wrap_content">
<ImageView
style="@style/CategoryIconStyle"
android:src="?attr/icon_sound">
android:src="?attr/icon_sound"
android:contentDescription="@string/category_sound">
</ImageView >
</LinearLayout>
5 changes: 3 additions & 2 deletions catroid/src/main/res/layout/icon_brick_category_userbrick.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Catroid: An on-device visual programming system for Android devices
~ Copyright (C) 2010-2021 The Catrobat Team
~ Copyright (C) 2010-2022 The Catrobat Team
~ (<http://developer.catrobat.org/credits>)
~
~ This program is free software: you can redistribute it and/or modify
Expand All @@ -28,6 +28,7 @@
<ImageView
android:src="?attr/icon_userbrick"
style="@style/CategoryIconStyle"
android:background="#395cab">
android:background="#395cab"
android:contentDescription="@string/category_user_bricks">
</ImageView >
</LinearLayout>
1 change: 1 addition & 0 deletions catroid/src/main/res/layout/single_seek_bar_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
android:maxWidth="150dp"
android:maxLines="1"
android:ellipsize="end"
android:paddingStart="@dimen/material_design_spacing_small"
android:paddingEnd="@dimen/material_design_spacing_small" />

<TextView
Expand Down
4 changes: 2 additions & 2 deletions catroid/src/main/res/layout/view_holder_file.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Catroid: An on-device visual programming system for Android devices
~ Copyright (C) 2010-2021 The Catrobat Team
~ Copyright (C) 2010-2022 The Catrobat Team
~ (<http://developer.catrobat.org/credits>)
~
~ This program is free software: you can redistribute it and/or modify
Expand All @@ -24,7 +24,7 @@

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:contentDescription="checkbox"
android:contentDescription="@string/checkbox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="?attr/element_spacing"
Expand Down
6 changes: 4 additions & 2 deletions catroid/src/main/res/layout/view_holder_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

<CheckBox
android:id="@+id/checkbox"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_weight="0"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
Expand All @@ -55,6 +55,7 @@
android:layout_weight="1"
android:minWidth="@dimen/data_view_space"
android:paddingEnd="@dimen/details_spacing"
android:paddingStart="@dimen/details_spacing"
android:textColor="@color/view_holder_item_title"
android:textSize="?attr/large"
android:ellipsize="end"
Expand All @@ -75,7 +76,8 @@
android:layout_weight="0"
android:gravity="center_vertical"
android:backgroundTint="@color/accent"
android:background="@drawable/ic_more_vert" />
android:background="@drawable/ic_more_vert"
android:contentDescription="@string/settings"/>

</LinearLayout>
</LinearLayout>
5 changes: 3 additions & 2 deletions catroid/src/main/res/layout/view_holder_sprite_group_item.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Catroid: An on-device visual programming system for Android devices
~ Copyright (C) 2010-2018 The Catrobat Team
~ Copyright (C) 2010-2022 The Catrobat Team
~ (<http://developer.catrobat.org/credits>)
~
~ This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -93,6 +93,7 @@
android:layout_weight="0"
android:gravity="center_vertical"
android:backgroundTint="@color/accent"
android:background="@drawable/ic_more_vert" />
android:background="@drawable/ic_more_vert"
android:contentDescription="@string/settings"/>
</LinearLayout>
</LinearLayout>
6 changes: 4 additions & 2 deletions catroid/src/main/res/layout/view_holder_variable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

<CheckBox
android:id="@+id/checkbox"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0"
android:layout_gravity="center_vertical"
Expand All @@ -54,6 +54,7 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingEnd="@dimen/details_spacing"
android:paddingStart="@dimen/details_spacing"
android:textColor="@color/view_holder_item_title"
android:textSize="?attr/large"
android:minWidth="@dimen/data_view_space"
Expand All @@ -78,7 +79,8 @@
android:layout_weight="0"
android:gravity="center_vertical"
android:backgroundTint="@color/accent"
android:background="@drawable/ic_more_vert" />
android:background="@drawable/ic_more_vert"
android:contentDescription="@string/settings"/>

</LinearLayout>
</LinearLayout>
Loading

0 comments on commit 5fb4db3

Please sign in to comment.