aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/ActivityToolbarInterface.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/AppModule.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/PullNotificationWorker.java4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/RedditDataRoomDatabase.java30
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/LinkResolverActivity.java3
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java11
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostGalleryActivity.java21
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/SubredditMultiselectionRecyclerViewAdapter.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/apis/RedditAPI.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java3
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/services/DownloadMediaService.java4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/settings/GesturesAndButtonsPreferenceFragment.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/settings/ImmersiveInterfacePreferenceFragment.java12
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/utils/JSONUtils.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/utils/MaterialYouUtils.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/utils/Utils.java3
16 files changed, 30 insertions, 83 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ActivityToolbarInterface.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ActivityToolbarInterface.java
index 04f0bcb5..65280f92 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/ActivityToolbarInterface.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ActivityToolbarInterface.java
@@ -2,5 +2,5 @@ package ml.docilealligator.infinityforreddit;
public interface ActivityToolbarInterface {
void onLongPress();
- default void displaySortType() {};
+ default void displaySortType() {}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/AppModule.java b/app/src/main/java/ml/docilealligator/infinityforreddit/AppModule.java
index d38f04a1..d4399607 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/AppModule.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/AppModule.java
@@ -234,7 +234,7 @@ class AppModule {
@Provides
@Singleton
RedditDataRoomDatabase provideRedditDataRoomDatabase() {
- return RedditDataRoomDatabase.getDatabase(mApplication);
+ return RedditDataRoomDatabase.create(mApplication);
}
@Provides
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PullNotificationWorker.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PullNotificationWorker.java
index 67caf295..9a36071d 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/PullNotificationWorker.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PullNotificationWorker.java
@@ -230,10 +230,8 @@ public class PullNotificationWorker extends Worker {
return fetchMessages(account, retryCount - 1);
}
- return null;
- } else {
- return null;
}
+ return null;
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/RedditDataRoomDatabase.java b/app/src/main/java/ml/docilealligator/infinityforreddit/RedditDataRoomDatabase.java
index 29964dac..959330f7 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/RedditDataRoomDatabase.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/RedditDataRoomDatabase.java
@@ -40,25 +40,17 @@ import ml.docilealligator.infinityforreddit.user.UserData;
SubscribedUserData.class, MultiReddit.class, CustomTheme.class, RecentSearchQuery.class,
ReadPost.class, PostFilter.class, PostFilterUsage.class, AnonymousMultiredditSubreddit.class}, version = 23)
public abstract class RedditDataRoomDatabase extends RoomDatabase {
- private static RedditDataRoomDatabase INSTANCE;
-
- public static RedditDataRoomDatabase getDatabase(final Context context) {
- if (INSTANCE == null) {
- synchronized (RedditDataRoomDatabase.class) {
- if (INSTANCE == null) {
- INSTANCE = Room.databaseBuilder(context.getApplicationContext(),
- RedditDataRoomDatabase.class, "reddit_data")
- .addMigrations(MIGRATION_1_2, MIGRATION_2_3, MIGRATION_3_4, MIGRATION_4_5,
- MIGRATION_5_6, MIGRATION_6_7, MIGRATION_7_8, MIGRATION_8_9,
- MIGRATION_9_10, MIGRATION_10_11, MIGRATION_11_12, MIGRATION_12_13,
- MIGRATION_13_14, MIGRATION_14_15, MIGRATION_15_16, MIGRATION_16_17,
- MIGRATION_17_18, MIGRATION_18_19, MIGRATION_19_20, MIGRATION_20_21,
- MIGRATION_21_22, MIGRATION_22_23)
- .build();
- }
- }
- }
- return INSTANCE;
+
+ public static RedditDataRoomDatabase create(final Context context) {
+ return Room.databaseBuilder(context.getApplicationContext(),
+ RedditDataRoomDatabase.class, "reddit_data")
+ .addMigrations(MIGRATION_1_2, MIGRATION_2_3, MIGRATION_3_4, MIGRATION_4_5,
+ MIGRATION_5_6, MIGRATION_6_7, MIGRATION_7_8, MIGRATION_8_9,
+ MIGRATION_9_10, MIGRATION_10_11, MIGRATION_11_12, MIGRATION_12_13,
+ MIGRATION_13_14, MIGRATION_14_15, MIGRATION_15_16, MIGRATION_16_17,
+ MIGRATION_17_18, MIGRATION_18_19, MIGRATION_19_20, MIGRATION_20_21,
+ MIGRATION_21_22, MIGRATION_22_23)
+ .build();
}
public abstract AccountDao accountDao();
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LinkResolverActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LinkResolverActivity.java
index 58a0312b..748d7b53 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LinkResolverActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LinkResolverActivity.java
@@ -106,7 +106,6 @@ public class LinkResolverActivity extends AppCompatActivity {
private void handleUri(Uri uri) {
if (uri == null) {
Toast.makeText(this, R.string.no_link_available, Toast.LENGTH_SHORT).show();
- finish();
} else {
String path = uri.getPath();
if (path == null) {
@@ -339,8 +338,8 @@ public class LinkResolverActivity extends AppCompatActivity {
}
}
- finish();
}
+ finish();
}
private void deepLinkError(Uri uri) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java
index c9cbcd45..ef3f6858 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java
@@ -322,12 +322,11 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
mMessageFullname = savedInstanceState.getString(MESSAGE_FULLNAME_STATE);
mNewAccountName = savedInstanceState.getString(NEW_ACCOUNT_NAME_STATE);
inboxCount = savedInstanceState.getInt(INBOX_COUNT_STATE);
- initializeNotificationAndBindView();
} else {
mMessageFullname = getIntent().getStringExtra(EXTRA_MESSSAGE_FULLNAME);
mNewAccountName = getIntent().getStringExtra(EXTRA_NEW_ACCOUNT_NAME);
- initializeNotificationAndBindView();
}
+ initializeNotificationAndBindView();
}
@Override
@@ -754,11 +753,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
intent = new Intent(MainActivity.this, ViewUserDetailActivity.class);
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, mAccountName);
} else if (stringId == R.string.subscriptions) {
- if (mAccessToken != null) {
- intent = new Intent(MainActivity.this, SubscribedThingListingActivity.class);
- } else {
- intent = new Intent(MainActivity.this, SubscribedThingListingActivity.class);
- }
+ intent = new Intent(MainActivity.this, SubscribedThingListingActivity.class);
} else if (stringId == R.string.multi_reddit) {
intent = new Intent(MainActivity.this, SubscribedThingListingActivity.class);
intent.putExtra(SubscribedThingListingActivity.EXTRA_SHOW_MULTIREDDITS, true);
@@ -1101,7 +1096,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
}
@Override
- public void onBackPressed() {;
+ public void onBackPressed() {
if (drawer.isOpen()) {
drawer.close();
} else {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostGalleryActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostGalleryActivity.java
index fe42c979..c18ba059 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostGalleryActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostGalleryActivity.java
@@ -236,28 +236,9 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee
imagesRecyclerView.addItemDecoration(new RecyclerView.ItemDecoration() {
@Override
public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
- GridLayoutManager.LayoutParams layoutParams = (GridLayoutManager.LayoutParams) view.getLayoutParams();
-
- int spanIndex = layoutParams.getSpanIndex();
-
int offset = (int) (Utils.convertDpToPixel(16, PostGalleryActivity.this));
int halfOffset = offset / 2;
-
- if (nColumns == 2) {
- if (spanIndex == 0) {
- outRect.set(halfOffset, 0, halfOffset, offset);
- } else {
- outRect.set(halfOffset, 0, halfOffset, offset);
- }
- } else if (nColumns == 3) {
- if (spanIndex == 0) {
- outRect.set(halfOffset, 0, halfOffset, offset);
- } else if (spanIndex == 1) {
- outRect.set(halfOffset, 0, halfOffset, offset);
- } else {
- outRect.set(halfOffset, 0, halfOffset, offset);
- }
- }
+ outRect.set(halfOffset, 0, halfOffset, offset);
}
});
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/SubredditMultiselectionRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/SubredditMultiselectionRecyclerViewAdapter.java
index 8ed3739f..a5532c42 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/SubredditMultiselectionRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/SubredditMultiselectionRecyclerViewAdapter.java
@@ -58,11 +58,7 @@ public class SubredditMultiselectionRecyclerViewAdapter extends RecyclerView.Ada
.error(glide.load(R.drawable.subreddit_default_icon)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
.into(((SubscribedSubredditViewHolder) holder).iconImageView);
- if (subscribedSubreddits.get(position).isSelected()) {
- ((SubscribedSubredditViewHolder) holder).checkBox.setChecked(true);
- } else {
- ((SubscribedSubredditViewHolder) holder).checkBox.setChecked(false);
- }
+ ((SubscribedSubredditViewHolder) holder).checkBox.setChecked(subscribedSubreddits.get(position).isSelected());
((SubscribedSubredditViewHolder) holder).checkBox.setOnClickListener(view -> {
if (subscribedSubreddits.get(position).isSelected()) {
((SubscribedSubredditViewHolder) holder).checkBox.setChecked(false);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/apis/RedditAPI.java b/app/src/main/java/ml/docilealligator/infinityforreddit/apis/RedditAPI.java
index caada0cb..c3d9f394 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/apis/RedditAPI.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/apis/RedditAPI.java
@@ -277,7 +277,7 @@ public interface RedditAPI {
default Call<String> getWiki(@Path("subredditName") String subredditName) {
return getWikiPage(subredditName, "index");
- };
+ }
@GET("/r/{subredditName}/wiki/{wikiPage}.json?raw_json=1")
Call<String> getWikiPage(@Path("subredditName") String subredditName, @Path("wikiPage") String wikiPage);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java
index 1f1e2b6f..fff5d62f 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java
@@ -876,7 +876,6 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
}
}
- return;
} else {
for (int i = currentSearchIndex - 1; i >= 0; i--) {
if (visibleComments.get(i).getCommentRawText() != null &&
@@ -894,8 +893,8 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
}
}
- return;
}
+ return;
}
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/services/DownloadMediaService.java b/app/src/main/java/ml/docilealligator/infinityforreddit/services/DownloadMediaService.java
index 61fe0bea..d247ad4c 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/services/DownloadMediaService.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/services/DownloadMediaService.java
@@ -269,7 +269,7 @@ public class DownloadMediaService extends Service {
contentValues.put(MediaStore.MediaColumns.DISPLAY_NAME, destinationFileName);
contentValues.put(MediaStore.MediaColumns.MIME_TYPE, mediaType == EXTRA_MEDIA_TYPE_VIDEO ? "video/*" : "image/*");
contentValues.put(MediaStore.MediaColumns.RELATIVE_PATH, destinationFileUriString);
- contentValues.put(mediaType == EXTRA_MEDIA_TYPE_VIDEO ? MediaStore.Video.Media.IS_PENDING : MediaStore.Images.Media.IS_PENDING, 1);
+ contentValues.put(MediaStore.MediaColumns.IS_PENDING, 1);
final Uri contentUri = mediaType == EXTRA_MEDIA_TYPE_VIDEO ? MediaStore.Video.Media.getContentUri(MediaStore.VOLUME_EXTERNAL_PRIMARY) : MediaStore.Images.Media.getContentUri(MediaStore.VOLUME_EXTERNAL_PRIMARY);
Uri uri = contentResolver.insert(contentUri, contentValues);
@@ -291,7 +291,7 @@ public class DownloadMediaService extends Service {
stream.write(buf, 0, len);
}
contentValues.clear();
- contentValues.put(mediaType == EXTRA_MEDIA_TYPE_VIDEO ? MediaStore.Video.Media.IS_PENDING : MediaStore.Images.Media.IS_PENDING, 0);
+ contentValues.put(MediaStore.MediaColumns.IS_PENDING, 0);
contentResolver.update(uri, contentValues, null, null);
destinationFileUriString = uri.toString();
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/GesturesAndButtonsPreferenceFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/GesturesAndButtonsPreferenceFragment.java
index ddb45bf9..da02aae8 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/GesturesAndButtonsPreferenceFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/GesturesAndButtonsPreferenceFragment.java
@@ -44,11 +44,7 @@ public class GesturesAndButtonsPreferenceFragment extends CustomFontPreferenceFr
if (lockJumpToNextTopLevelCommentButtonSwitch != null && lockBottomAppBarSwitch != null &&
swipeUpToHideJumpToNextTopLevelCommentButtonSwitch != null) {
lockJumpToNextTopLevelCommentButtonSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
- if ((Boolean) newValue) {
- swipeUpToHideJumpToNextTopLevelCommentButtonSwitch.setVisible(false);
- } else {
- swipeUpToHideJumpToNextTopLevelCommentButtonSwitch.setVisible(true);
- }
+ swipeUpToHideJumpToNextTopLevelCommentButtonSwitch.setVisible(!((Boolean) newValue));
return true;
});
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/ImmersiveInterfacePreferenceFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/ImmersiveInterfacePreferenceFragment.java
index df3d41fc..0584095f 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/ImmersiveInterfacePreferenceFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/ImmersiveInterfacePreferenceFragment.java
@@ -24,20 +24,12 @@ public class ImmersiveInterfacePreferenceFragment extends CustomFontPreferenceFr
if (immersiveInterfaceSwitch != null && immersiveInterfaceIgnoreNavBarSwitch != null
&& disableImmersiveInterfaceInLandscapeModeSwitch != null) {
immersiveInterfaceSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
- if ((Boolean) newValue) {
- immersiveInterfaceIgnoreNavBarSwitch.setVisible(true);
- } else {
- immersiveInterfaceIgnoreNavBarSwitch.setVisible(false);
- }
+ immersiveInterfaceIgnoreNavBarSwitch.setVisible((Boolean) newValue);
EventBus.getDefault().post(new RecreateActivityEvent());
return true;
});
- if (immersiveInterfaceSwitch.isChecked()) {
- immersiveInterfaceIgnoreNavBarSwitch.setVisible(true);
- } else {
- immersiveInterfaceIgnoreNavBarSwitch.setVisible(false);
- }
+ immersiveInterfaceIgnoreNavBarSwitch.setVisible(immersiveInterfaceSwitch.isChecked());
immersiveInterfaceIgnoreNavBarSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
EventBus.getDefault().post(new RecreateActivityEvent());
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/JSONUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/JSONUtils.java
index 828f2dd1..968dcbae 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/JSONUtils.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/JSONUtils.java
@@ -132,7 +132,7 @@ public class JSONUtils {
public static final String TOTAL_KARMA_KEY = "total_karma";
public static final String AWARDER_KARMA_KEY = "awarder_karma";
public static final String AWARDEE_KARMA_KEY = "awardee_karma";
- public static final String CONTENT_URLS_KEY = "content_urls";;
+ public static final String CONTENT_URLS_KEY = "content_urls";
public static final String WEBM_KEY = "webm";
public static final String WEBM_URL_KEY = "webmUrl";
public static final String UPVOTE_RATIO_KEY = "upvote_ratio";
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/MaterialYouUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/MaterialYouUtils.java
index 7268cb2b..f50cc10d 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/MaterialYouUtils.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/MaterialYouUtils.java
@@ -129,7 +129,7 @@ public class MaterialYouUtils {
darkTheme.navBarColor = darkTheme.colorPrimary;
darkTheme.primaryTextColor = context.getColor(android.R.color.system_neutral1_10);
darkTheme.secondaryTextColor = context.getColor(android.R.color.system_neutral1_10);
- darkTheme.bottomAppBarIconColor = context.getColor(android.R.color.system_accent1_100);;
+ darkTheme.bottomAppBarIconColor = context.getColor(android.R.color.system_accent1_100);
darkTheme.primaryIconColor = context.getColor(android.R.color.system_accent1_100);
darkTheme.fabIconColor = context.getColor(android.R.color.system_neutral1_900);
darkTheme.toolbarPrimaryTextAndIconColor = context.getColor(android.R.color.system_accent2_100);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/Utils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/Utils.java
index 39aadc17..08e759a8 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/Utils.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/Utils.java
@@ -252,7 +252,6 @@ public final class Utils {
}
} catch (SecurityException ignore) {
}
- return NETWORK_TYPE_OTHER;
} else {
boolean isWifi = false;
boolean isCellular = false;
@@ -274,8 +273,8 @@ public final class Utils {
return NETWORK_TYPE_CELLULAR;
}
- return NETWORK_TYPE_OTHER;
}
+ return NETWORK_TYPE_OTHER;
}
return NETWORK_TYPE_OTHER;