From 9e56a8649204b3d201be4e27fa89599240210311 Mon Sep 17 00:00:00 2001 From: Javi Rueda Date: Tue, 8 Dec 2020 11:03:19 +0100 Subject: [PATCH] Some fixes for lint --- .../java/io/lbry/browser/MainActivity.java | 36 ++++++++----------- .../ui/findcontent/FileViewFragment.java | 1 - .../main/res/layout/activity_verification.xml | 2 +- app/src/main/res/layout/app_bar_main.xml | 4 +-- .../res/layout/container_comment_form.xml | 3 +- app/src/main/res/layout/content_main.xml | 4 +-- .../main/res/layout/dialog_content_from.xml | 21 +++++------ .../main/res/layout/dialog_content_scope.xml | 9 ++--- .../main/res/layout/dialog_content_sort.xml | 19 +++++----- .../res/layout/exo_playback_control_view.xml | 8 ++--- .../main/res/layout/fragment_all_content.xml | 6 ++-- app/src/main/res/layout/fragment_channel.xml | 12 +++---- .../res/layout/fragment_channel_content.xml | 4 +-- .../main/res/layout/fragment_channel_form.xml | 4 +-- .../main/res/layout/fragment_file_view.xml | 16 ++++----- .../main/res/layout/fragment_following.xml | 4 +-- app/src/main/res/layout/fragment_gallery.xml | 3 +- app/src/main/res/layout/fragment_home.xml | 3 +- app/src/main/res/layout/fragment_publish.xml | 12 +++---- .../main/res/layout/fragment_publish_form.xml | 3 +- app/src/main/res/layout/fragment_shuffle.xml | 4 +-- app/src/main/res/layout/list_item_channel.xml | 3 +- .../list_item_featured_search_result.xml | 3 +- .../res/layout/list_item_notification.xml | 3 +- app/src/main/res/layout/list_item_reward.xml | 5 +-- .../res/layout/list_item_startupstage.xml | 5 +-- app/src/main/res/layout/list_item_stream.xml | 3 +- app/src/main/res/layout/list_item_tag.xml | 3 +- 28 files changed, 103 insertions(+), 100 deletions(-) diff --git a/app/src/main/java/io/lbry/browser/MainActivity.java b/app/src/main/java/io/lbry/browser/MainActivity.java index 39ec4a90..991ce942 100644 --- a/app/src/main/java/io/lbry/browser/MainActivity.java +++ b/app/src/main/java/io/lbry/browser/MainActivity.java @@ -107,6 +107,7 @@ import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; import org.java_websocket.client.WebSocketClient; import org.java_websocket.handshake.ServerHandshake; +import org.jetbrains.annotations.NotNull; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; @@ -221,6 +222,8 @@ import lombok.Setter; import lombok.SneakyThrows; import okhttp3.OkHttpClient; +import static android.os.Build.VERSION_CODES.M; + public class MainActivity extends AppCompatActivity implements SdkStatusListener, SharedPreferences.OnSharedPreferenceChangeListener, ActionMode.Callback, SelectionModeListener { @@ -434,7 +437,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener initKeyStore(); loadAuthToken(); - if (!isDarkMode()) { + if (Build.VERSION.SDK_INT >= M && !isDarkMode()) { getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); } initSpecialRouteMap(); @@ -1315,7 +1318,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener private void toggleUrlSuggestions(boolean visible) { View container = findViewById(R.id.url_suggestions_container); View closeIcon = findViewById(R.id.wunderbar_close); - EditText wunderbar = findViewById(R.id.wunderbar); + //EditText wunderbar = findViewById(R.id.wunderbar); //wunderbar.setPadding(0, 0, visible ? getScaledValue(36) : 0, 0); container.setVisibility(visible ? View.VISIBLE : View.GONE); @@ -1863,17 +1866,13 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener new DecimalFormat(Helper.LBC_CURRENCY_FORMAT_PATTERN).format(amountClaimed)); } Snackbar.make(findViewById(R.id.content_main), message, Snackbar.LENGTH_LONG).show(); - if (sp != null) { - sp.edit().putBoolean(PREFERENCE_KEY_INTERNAL_NEW_ANDROID_REWARD_CLAIMED, true).apply(); - } + sp.edit().putBoolean(PREFERENCE_KEY_INTERNAL_NEW_ANDROID_REWARD_CLAIMED, true).apply(); } @Override public void onError(Exception error) { // pass. fail silently - if (sp != null) { - sp.edit().putBoolean(PREFERENCE_KEY_INTERNAL_NEW_ANDROID_REWARD_CLAIMED, true).apply(); - } + sp.edit().putBoolean(PREFERENCE_KEY_INTERNAL_NEW_ANDROID_REWARD_CLAIMED, true).apply(); } }); task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); @@ -1958,7 +1957,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener notificationListAdapter.setInSelectionMode(false); notificationListAdapter.notifyDataSetChanged(); } - if (isDarkMode()) { + if (Build.VERSION.SDK_INT >= M && isDarkMode()) { getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); } this.actionMode = null; @@ -2022,8 +2021,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener if (nowPlayingClaimUrl != null) { Intent launchIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(nowPlayingClaimUrl)); launchIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); - PendingIntent intent = PendingIntent.getActivity(MainActivity.this, 0, launchIntent, 0); - return intent; + return PendingIntent.getActivity(MainActivity.this, 0, launchIntent, 0); } return null; } @@ -2236,8 +2234,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener @Override public void onSyncSetSuccess(String hash) { Lbryio.lastRemoteHash = hash; - WalletSync walletSync = new WalletSync(hash, data); - Lbryio.lastWalletSync = walletSync; + Lbryio.lastWalletSync = new WalletSync(hash, data); if (pendingSyncSetQueue.size() > 0) { fullSyncInProgress = true; @@ -2417,8 +2414,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener pendingFollowingReload = true; } private void handleOpenChannelUrl(Intent intent) { - String url = intent.getStringExtra("url"); - pendingChannelUrl = url; + pendingChannelUrl = intent.getStringExtra("url"); } }; registerReceiver(requestsReceiver, intentFilter); @@ -2578,7 +2574,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener } @Override - public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) { + public void onRequestPermissionsResult(int requestCode, @NotNull String[] permissions, @NotNull int[] grantResults) { switch (requestCode) { case REQUEST_STORAGE_PERMISSION: if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { @@ -2613,7 +2609,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener super.onActivityResult(requestCode, resultCode, data); if (requestCode == REQUEST_FILE_PICKER) { startingFilePickerActivity = false; - if (resultCode == RESULT_OK) { + if (resultCode == RESULT_OK && data != null) { Uri fileUri = data.getData(); String filePath = Helper.getRealPathFromURI_API19(this, fileUri); for (FilePickerListener listener : filePickerListeners) { @@ -2724,8 +2720,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener int backCount = getSupportFragmentManager().getBackStackEntryCount(); if (backCount > 0) { try { - Fragment fragment = getSupportFragmentManager().getFragments().get(backCount - 1); - return fragment; + return getSupportFragmentManager().getFragments().get(backCount - 1); } catch (IndexOutOfBoundsException ex) { return null; } @@ -2849,8 +2844,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener // resolve subscriptions if (subUrls.size() > 0 && Lbryio.cacheResolvedSubscriptions.size() != Lbryio.subscriptions.size()) { - List resolvedSubs = Lbry.resolve(subUrls, Lbry.LBRY_TV_CONNECTION_STRING); - Lbryio.cacheResolvedSubscriptions = resolvedSubs; + Lbryio.cacheResolvedSubscriptions = Lbry.resolve(subUrls, Lbry.LBRY_TV_CONNECTION_STRING); } // if no exceptions occurred here, subscriptions have been loaded and resolved startupStages.set(STARTUP_STAGE_SUBSCRIPTIONS_RESOLVED - 1, new StartupStage(STARTUP_STAGE_SUBSCRIPTIONS_RESOLVED, true)); diff --git a/app/src/main/java/io/lbry/browser/ui/findcontent/FileViewFragment.java b/app/src/main/java/io/lbry/browser/ui/findcontent/FileViewFragment.java index 71547ae9..805c21f1 100644 --- a/app/src/main/java/io/lbry/browser/ui/findcontent/FileViewFragment.java +++ b/app/src/main/java/io/lbry/browser/ui/findcontent/FileViewFragment.java @@ -2168,7 +2168,6 @@ public class FileViewFragment extends BaseFragment implements } private void openClaimExternally(Claim claim, String mediaType) { - File file = new File(claim.getFile().getDownloadPath()); Uri fileUri = Uri.parse(claim.getFile().getDownloadPath()); Intent intent = new Intent(); diff --git a/app/src/main/res/layout/activity_verification.xml b/app/src/main/res/layout/activity_verification.xml index 23ec89f3..c5017c9e 100644 --- a/app/src/main/res/layout/activity_verification.xml +++ b/app/src/main/res/layout/activity_verification.xml @@ -31,7 +31,7 @@ android:layout_width="24dp" android:layout_height="24dp" android:src="@drawable/ic_close" - android:tint="@color/white" /> + app:tint="@color/white" /> + app:tint="@color/actionBarForeground" /> + app:tint="@color/actionBarForeground" /> + app:tint="@color/foreground" /> diff --git a/app/src/main/res/layout/content_main.xml b/app/src/main/res/layout/content_main.xml index 0edffd26..06bfa62f 100644 --- a/app/src/main/res/layout/content_main.xml +++ b/app/src/main/res/layout/content_main.xml @@ -174,9 +174,9 @@ + android:layout_centerInParent="true" + app:tint="@color/foreground" /> diff --git a/app/src/main/res/layout/dialog_content_from.xml b/app/src/main/res/layout/dialog_content_from.xml index 41729cb7..7bdc4161 100644 --- a/app/src/main/res/layout/dialog_content_from.xml +++ b/app/src/main/res/layout/dialog_content_from.xml @@ -1,5 +1,6 @@ @@ -44,8 +45,8 @@ android:layout_alignParentEnd="true" android:layout_centerVertical="true" android:src="@drawable/ic_check" - android:tint="@color/lbryGreen" - android:visibility="gone" /> + android:visibility="gone" + app:tint="@color/lbryGreen" /> + android:visibility="gone" + app:tint="@color/lbryGreen" /> + android:visibility="gone" + app:tint="@color/lbryGreen" /> + android:visibility="gone" + app:tint="@color/lbryGreen" /> + android:visibility="gone" + app:tint="@color/lbryGreen" /> \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_content_scope.xml b/app/src/main/res/layout/dialog_content_scope.xml index 7bef7653..b8b9211d 100644 --- a/app/src/main/res/layout/dialog_content_scope.xml +++ b/app/src/main/res/layout/dialog_content_scope.xml @@ -1,5 +1,6 @@ @@ -53,8 +54,8 @@ android:layout_alignParentEnd="true" android:layout_centerVertical="true" android:src="@drawable/ic_check" - android:tint="@color/lbryGreen" - android:visibility="gone" /> + android:visibility="gone" + app:tint="@color/lbryGreen" /> + android:visibility="gone" + app:tint="@color/lbryGreen" /> \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_content_sort.xml b/app/src/main/res/layout/dialog_content_sort.xml index 194f476b..82e012d5 100644 --- a/app/src/main/res/layout/dialog_content_sort.xml +++ b/app/src/main/res/layout/dialog_content_sort.xml @@ -1,5 +1,6 @@ @@ -35,7 +36,7 @@ android:layout_height="18dp" android:layout_centerVertical="true" android:src="@drawable/ic_trending" - android:tint="@color/foreground" /> + app:tint="@color/foreground" /> + android:visibility="gone" + app:tint="@color/lbryGreen" /> + app:tint="@color/foreground" /> + android:visibility="gone" + app:tint="@color/lbryGreen" /> + app:tint="@color/foreground" /> + android:visibility="gone" + app:tint="@color/lbryGreen" /> \ No newline at end of file diff --git a/app/src/main/res/layout/exo_playback_control_view.xml b/app/src/main/res/layout/exo_playback_control_view.xml index e5385779..19d8310c 100644 --- a/app/src/main/res/layout/exo_playback_control_view.xml +++ b/app/src/main/res/layout/exo_playback_control_view.xml @@ -22,7 +22,7 @@ android:layout_alignParentBottom="true" android:layout_marginBottom="16dp" android:src="@drawable/ic_replay_10" - android:tint="@color/white" /> + app:tint="@color/white" /> + app:tint="@color/white" /> + app:tint="@color/white" /> + app:tint="@color/white" /> + app:tint="@color/foreground" /> + app:tint="@color/foreground" /> + app:tint="@color/foreground" /> diff --git a/app/src/main/res/layout/fragment_channel.xml b/app/src/main/res/layout/fragment_channel.xml index fa688fa6..058dcbfe 100644 --- a/app/src/main/res/layout/fragment_channel.xml +++ b/app/src/main/res/layout/fragment_channel.xml @@ -157,8 +157,8 @@ android:layout_centerInParent="true" android:layout_width="24dp" android:layout_height="24dp" - android:tint="@color/foreground" - android:src="@drawable/ic_edit" /> + android:src="@drawable/ic_edit" + app:tint="@color/foreground" /> + android:src="@drawable/ic_delete" + app:tint="@color/foreground" /> + android:src="@drawable/ic_share" + app:tint="@color/foreground" /> + app:tint="@color/foreground" /> + app:tint="@color/foreground" /> diff --git a/app/src/main/res/layout/fragment_channel_form.xml b/app/src/main/res/layout/fragment_channel_form.xml index 5549368d..bdce4273 100644 --- a/app/src/main/res/layout/fragment_channel_form.xml +++ b/app/src/main/res/layout/fragment_channel_form.xml @@ -38,7 +38,7 @@ android:layout_height="16dp" android:layout_centerInParent="true" android:src="@drawable/ic_edit" - android:tint="@color/white" /> + app:tint="@color/white" /> @@ -112,7 +112,7 @@ android:layout_height="16dp" android:layout_centerInParent="true" android:src="@drawable/ic_edit" - android:tint="@color/white" /> + app:tint="@color/white" /> diff --git a/app/src/main/res/layout/fragment_file_view.xml b/app/src/main/res/layout/fragment_file_view.xml index 974a527c..3b0930bc 100644 --- a/app/src/main/res/layout/fragment_file_view.xml +++ b/app/src/main/res/layout/fragment_file_view.xml @@ -261,7 +261,7 @@ android:layout_centerVertical="true" android:layout_toStartOf="@+id/file_view_title_layout" android:src="@drawable/ic_arrow_dropdown" - android:tint="@color/foreground" /> + app:tint="@color/foreground" /> + app:tint="@color/foreground" /> + app:tint="@color/foreground" /> + app:tint="@color/foreground" /> + app:tint="@color/foreground" /> + app:tint="@color/foreground" /> + app:tint="@color/foreground" /> - \ No newline at end of file + diff --git a/app/src/main/res/layout/fragment_following.xml b/app/src/main/res/layout/fragment_following.xml index dc0f2b54..d636c1b6 100644 --- a/app/src/main/res/layout/fragment_following.xml +++ b/app/src/main/res/layout/fragment_following.xml @@ -82,7 +82,7 @@ android:layout_marginStart="2dp" android:layout_gravity="center_vertical" android:src="@drawable/ic_arrow_dropdown" - android:tint="@color/foreground" /> + app:tint="@color/foreground" /> + app:tint="@color/foreground" /> + android:layout_height="match_parent"> + android:layout_height="match_parent"> + android:src="@drawable/ic_record" + app:tint="@color/white" /> + android:src="@drawable/ic_photo" + app:tint="@color/white" /> + android:src="@drawable/ic_upload" + app:tint="@color/white" /> @@ -67,7 +68,7 @@ android:layout_height="16dp" android:layout_centerInParent="true" android:src="@drawable/ic_edit" - android:tint="@color/white" /> + app:tint="@color/white" /> diff --git a/app/src/main/res/layout/fragment_shuffle.xml b/app/src/main/res/layout/fragment_shuffle.xml index 2edce022..7025333a 100644 --- a/app/src/main/res/layout/fragment_shuffle.xml +++ b/app/src/main/res/layout/fragment_shuffle.xml @@ -80,8 +80,8 @@ android:layout_width="24dp" android:layout_height="24dp" android:layout_centerInParent="true" - android:tint="@color/white" - android:src="@drawable/ic_share" /> + android:src="@drawable/ic_share" + app:tint="@color/white" /> \ No newline at end of file diff --git a/app/src/main/res/layout/list_item_channel.xml b/app/src/main/res/layout/list_item_channel.xml index 81a9c997..bcb32887 100644 --- a/app/src/main/res/layout/list_item_channel.xml +++ b/app/src/main/res/layout/list_item_channel.xml @@ -1,5 +1,6 @@ + app:tint="@color/nextLbryGreen" /> diff --git a/app/src/main/res/layout/list_item_featured_search_result.xml b/app/src/main/res/layout/list_item_featured_search_result.xml index afb084b6..a6cffcee 100644 --- a/app/src/main/res/layout/list_item_featured_search_result.xml +++ b/app/src/main/res/layout/list_item_featured_search_result.xml @@ -1,5 +1,6 @@ + app:tint="@color/nextLbryGreen" /> diff --git a/app/src/main/res/layout/list_item_notification.xml b/app/src/main/res/layout/list_item_notification.xml index ed5fbd00..3c478664 100644 --- a/app/src/main/res/layout/list_item_notification.xml +++ b/app/src/main/res/layout/list_item_notification.xml @@ -1,6 +1,7 @@ + app:tint="@color/nextLbryGreen" /> + android:visibility="invisible" + app:tint="@color/lbryGreen" /> @@ -8,8 +9,8 @@ android:layout_width="16dp" android:layout_height="16dp" android:layout_gravity="center_vertical" - android:tint="@color/white" - android:src="@drawable/ic_check" /> + android:src="@drawable/ic_check" + app:tint="@color/white" /> + app:tint="@color/nextLbryGreen" /> + app:tint="@color/darkForeground" />