Merge pull request #4293 from ByteHamster/lint-app

Added CI Lint checks for app module
This commit is contained in:
H. Lehmann 2020-07-16 12:18:33 +02:00 committed by GitHub
commit 1ee5281e7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 28 additions and 105 deletions

View File

@ -80,3 +80,13 @@ workflows:
echo "Comparing to $branchBaseCommit"
curl -s -L https://github.com/yangziwen/diff-checkstyle/releases/download/0.0.4/diff-checkstyle.jar > diff-checkstyle.jar
java -Dconfig_loc=config/checkstyle -jar diff-checkstyle.jar -c config/checkstyle/checkstyle-new-code.xml --git-dir . --base-rev $branchBaseCommit
- build:
name: Lint app
build-steps:
- run:
name: Lint app
command: ./gradlew app:lintPlayRelease
- store_artifacts:
name: Uploading lint reports
path: app/build/reports/lint-results-playRelease.html
destination: lint-results.html

View File

@ -98,7 +98,14 @@ android {
}
lintOptions {
abortOnError false
disable 'ObsoleteLintCustomCheck', 'CheckResult', 'UnusedAttribute', 'BatteryLife', 'InflateParams',
'GradleDependency', 'RestrictedApi', 'TrustAllX509TrustManager', 'ExportedReceiver', 'AllowBackup',
'StaticFieldLeak', 'UseCompoundDrawables', 'NestedWeights', 'Overdraw', 'UselessParent', 'TextFields',
'AlwaysShowAction', 'Autofill', 'ClickableViewAccessibility', 'ContentDescription',
'KeyboardInaccessibleWidget', 'LabelFor', 'SetTextI18n', 'HardcodedText', 'RelativeOverlap',
'RtlCompat', 'RtlHardcoded', 'MissingMediaBrowserServiceIntentFilter'
warningsAsErrors true
abortOnError true
}
compileOptions {

View File

@ -23,6 +23,7 @@ import java.net.Proxy;
import java.net.SocketAddress;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.concurrent.TimeUnit;
import de.danoeh.antennapod.R;
@ -63,6 +64,8 @@ public class ProxyDialog {
public Dialog show() {
View content = View.inflate(context, R.layout.proxy_settings, null);
spType = content.findViewById(R.id.spType);
dialog = new AlertDialog.Builder(context)
.setTitle(R.string.pref_proxy_title)
.setView(content)
@ -76,7 +79,7 @@ public class ProxyDialog {
test();
return;
}
String type = (String) ((Spinner) content.findViewById(R.id.spType)).getSelectedItem();
String type = (String) spType.getSelectedItem();
ProxyConfig proxy;
if (Proxy.Type.valueOf(type) == Proxy.Type.DIRECT) {
proxy = ProxyConfig.direct();
@ -106,7 +109,6 @@ public class ProxyDialog {
dialog.dismiss();
});
spType = content.findViewById(R.id.spType);
List<String> types = new ArrayList<>();
types.add(Proxy.Type.DIRECT.name());
types.add(Proxy.Type.HTTP.name());
@ -260,7 +262,7 @@ public class ProxyDialog {
portValue = Integer.parseInt(port);
}
SocketAddress address = InetSocketAddress.createUnresolved(host, portValue);
Proxy.Type proxyType = Proxy.Type.valueOf(type.toUpperCase());
Proxy.Type proxyType = Proxy.Type.valueOf(type.toUpperCase(Locale.US));
Proxy proxy = new Proxy(proxyType, address);
OkHttpClient.Builder builder = AntennapodHttpClient.newBuilder()
.connectTimeout(10, TimeUnit.SECONDS)

View File

@ -45,7 +45,6 @@ public class ChaptersFragment extends Fragment {
RecyclerView recyclerView = root.findViewById(R.id.recyclerView);
layoutManager = new LinearLayoutManager(getActivity());
recyclerView.setLayoutManager(layoutManager);
recyclerView.setHasFixedSize(true);
recyclerView.addItemDecoration(new HorizontalDividerItemDecoration.Builder(getActivity()).build());
adapter = new ChaptersListAdapter(getActivity(), pos -> {

View File

@ -124,7 +124,6 @@ public class SearchFragment extends Fragment {
LinearLayoutManager layoutManagerFeeds = new LinearLayoutManager(getActivity());
layoutManagerFeeds.setOrientation(RecyclerView.HORIZONTAL);
recyclerViewFeeds.setLayoutManager(layoutManagerFeeds);
recyclerViewFeeds.setHasFixedSize(true);
adapterFeeds = new FeedSearchResultAdapter((MainActivity) getActivity());
recyclerViewFeeds.setAdapter(adapterFeeds);

View File

@ -1,5 +1,6 @@
package de.danoeh.antennapod.fragment.preferences;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.res.Resources;
@ -85,6 +86,7 @@ public class AutoDownloadPreferencesFragment extends PreferenceFragmentCompat {
return val == null ? "" : val;
}
@SuppressLint("MissingPermission") // getConfiguredNetworks needs location permission starting with API 29
private void buildAutodownloadSelectedNetworksPreference() {
if (Build.VERSION.SDK_INT >= 29) {
return;

View File

@ -38,6 +38,7 @@ import java.io.FileOutputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Locale;
public class ImportExportPreferencesFragment extends PreferenceFragmentCompat {
private static final String TAG = "ImportExPrefFragment";
@ -86,9 +87,7 @@ public class ImportExportPreferencesFragment extends PreferenceFragmentCompat {
}
private String dateStampFilename(String fname) {
return String.format(fname,
new SimpleDateFormat("yyyy-MM-dd")
.format(new Date()));
return String.format(fname, new SimpleDateFormat("yyyy-MM-dd", Locale.US).format(new Date()));
}
private void setupStorageScreen() {

View File

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+id/listview"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>

View File

@ -1,55 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:background="@android:color/darker_gray"
android:paddingTop="@dimen/listitem_threeline_verticalpadding"
android:paddingBottom="@dimen/listitem_threeline_verticalpadding">
<ImageView
android:id="@+id/imgvFeedimage"
android:layout_width="@dimen/thumbnail_length_itemlist"
android:layout_height="@dimen/thumbnail_length_itemlist"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/listitem_threeline_horizontalpadding"
android:layout_marginStart="@dimen/listitem_threeline_horizontalpadding"
android:importantForAccessibility="no"
android:scaleType="centerCrop"
tools:src="@drawable/ic_antenna"
tools:background="@android:color/holo_green_dark"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/listitem_iconwithtext_textleftpadding"
android:layout_marginStart="@dimen/listitem_iconwithtext_textleftpadding"
android:layout_marginRight="@dimen/listitem_threeline_verticalpadding"
android:layout_marginEnd="@dimen/listitem_threeline_verticalpadding"
android:layout_toRightOf="@id/imgvFeedimage"
android:layout_toEndOf="@id/imgvFeedimage"
android:orientation="vertical"
tools:background="@android:color/holo_red_dark">
<TextView
android:id="@+id/txtvTitle"
style="@style/AntennaPod.TextView.ListItemPrimaryTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
tools:text="Search item title"
tools:background="@android:color/holo_green_dark" />
<TextView
android:id="@+id/txtvSubtitle"
style="@style/AntennaPod.TextView.ListItemSecondaryTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:lines="1"
tools:text="Search item subtitle"
tools:background="@android:color/holo_blue_light"/>
</LinearLayout>
</RelativeLayout>

View File

@ -1,24 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.google.android.material.tabs.TabLayout
android:id="@+id/sliding_tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/windowBackground"
app:tabBackground="?attr/selectableItemBackground"
app:tabGravity="fill"
app:tabMode="fixed" />
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="1" />
</LinearLayout>

View File

@ -4,5 +4,5 @@
(300dp ~ 1.875 inch, devices with 3.5-inch screens have a width of ~ 1.9in
so the setup is applicable for most phones)
-->
<dimen name="sd_label_max_width" tools:ignore="MissingDefaultResource">240dp</dimen>
<dimen name="sd_label_max_width" tools:ignore="MissingDefaultResource, UnusedResources">240dp</dimen>
</resources>

View File

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
android:hint="@string/search_label"
android:label="@string/app_name"/>