diff options
Diffstat (limited to 'app/src/main')
39 files changed, 612 insertions, 307 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountSavedThingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountSavedThingActivity.java index 52a3d489..42e89abc 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountSavedThingActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountSavedThingActivity.java @@ -22,6 +22,7 @@ import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.appbar.CollapsingToolbarLayout; import com.google.android.material.tabs.TabLayout; import com.r0adkll.slidr.Slidr; +import com.r0adkll.slidr.model.SlidrInterface; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; @@ -76,6 +77,7 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT @Inject CustomThemeWrapper mCustomThemeWrapper; private SectionsPagerAdapter sectionsPagerAdapter; + private SlidrInterface mSlidrInterface; private Menu mMenu; private AppBarLayout.LayoutParams params; private boolean mNullAccessToken = false; @@ -98,7 +100,7 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT applyCustomTheme(); if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK_FROM_POST_DETAIL, true)) { - Slidr.attach(this); + mSlidrInterface = Slidr.attach(this); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { @@ -179,12 +181,7 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT viewPager.setOffscreenPageLimit(2); tabLayout.setupWithViewPager(viewPager); - viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { - @Override - public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { - - } - + viewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { if (isInLazyMode) { @@ -194,11 +191,12 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT sectionsPagerAdapter.pauseLazyMode(); } } - } - - @Override - public void onPageScrollStateChanged(int state) { + if (position == 0) { + unlockSwipeRightToGoBack(); + } else { + lockSwipeRightToGoBack(); + } } }); } @@ -290,6 +288,18 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT } } + private void lockSwipeRightToGoBack() { + if (mSlidrInterface != null) { + mSlidrInterface.lock(); + } + } + + private void unlockSwipeRightToGoBack() { + if (mSlidrInterface != null) { + mSlidrInterface.unlock(); + } + } + private class SectionsPagerAdapter extends FragmentPagerAdapter { private PostFragment postFragment; private CommentsListingFragment commentsListingFragment; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java index 69b52cfb..d1e9af09 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java @@ -64,6 +64,10 @@ import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask import ml.docilealligator.infinityforreddit.AsyncTask.InsertSubscribedThingsAsyncTask; import ml.docilealligator.infinityforreddit.AsyncTask.SwitchAccountAsyncTask; import ml.docilealligator.infinityforreddit.AsyncTask.SwitchToAnonymousAccountAsyncTask; +import ml.docilealligator.infinityforreddit.BottomSheetFragment.PostLayoutBottomSheetFragment; +import ml.docilealligator.infinityforreddit.BottomSheetFragment.PostTypeBottomSheetFragment; +import ml.docilealligator.infinityforreddit.BottomSheetFragment.SortTimeBottomSheetFragment; +import ml.docilealligator.infinityforreddit.BottomSheetFragment.SortTypeBottomSheetFragment; import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.Event.ChangeConfirmToExitEvent; import ml.docilealligator.infinityforreddit.Event.ChangeLockBottomAppBarEvent; @@ -73,10 +77,6 @@ import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent; import ml.docilealligator.infinityforreddit.FetchMyInfo; import ml.docilealligator.infinityforreddit.FetchSubscribedThing; import ml.docilealligator.infinityforreddit.Fragment.PostFragment; -import ml.docilealligator.infinityforreddit.BottomSheetFragment.PostLayoutBottomSheetFragment; -import ml.docilealligator.infinityforreddit.BottomSheetFragment.PostTypeBottomSheetFragment; -import ml.docilealligator.infinityforreddit.BottomSheetFragment.SortTimeBottomSheetFragment; -import ml.docilealligator.infinityforreddit.BottomSheetFragment.SortTypeBottomSheetFragment; import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.ParseAndSaveAccountInfo; import ml.docilealligator.infinityforreddit.Post.PostDataSource; @@ -321,7 +321,8 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb private void getCurrentAccountAndBindView() { new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> { boolean enableNotification = mSharedPreferences.getBoolean(SharedPreferencesUtils.ENABLE_NOTIFICATION_KEY, true); - String notificationInterval = mSharedPreferences.getString(SharedPreferencesUtils.NOTIFICATION_INTERVAL_KEY, "1"); + long notificationInterval = Long.parseLong(mSharedPreferences.getString(SharedPreferencesUtils.NOTIFICATION_INTERVAL_KEY, "1")); + TimeUnit timeUnit = notificationInterval == 15 || notificationInterval == 30 ? TimeUnit.MINUTES : TimeUnit.HOURS; WorkManager workManager = WorkManager.getInstance(this); @@ -349,7 +350,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb PeriodicWorkRequest pullNotificationRequest = new PeriodicWorkRequest.Builder(PullNotificationWorker.class, - Long.parseLong(notificationInterval), TimeUnit.HOURS) + notificationInterval, timeUnit) .setConstraints(constraints) .build(); @@ -375,7 +376,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb PeriodicWorkRequest pullNotificationRequest = new PeriodicWorkRequest.Builder(PullNotificationWorker.class, - Long.parseLong(notificationInterval), TimeUnit.HOURS) + notificationInterval, timeUnit) .setConstraints(constraints) .build(); @@ -405,7 +406,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb PeriodicWorkRequest pullNotificationRequest = new PeriodicWorkRequest.Builder(PullNotificationWorker.class, - Long.parseLong(notificationInterval), TimeUnit.HOURS) + notificationInterval, timeUnit) .setConstraints(constraints) .build(); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubscribedThingListingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubscribedThingListingActivity.java index 4546ac10..994d19e7 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubscribedThingListingActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubscribedThingListingActivity.java @@ -21,6 +21,7 @@ import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.dialog.MaterialAlertDialogBuilder; import com.google.android.material.tabs.TabLayout; import com.r0adkll.slidr.Slidr; +import com.r0adkll.slidr.model.SlidrInterface; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; @@ -86,6 +87,7 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti SharedPreferences mSharedPreferences; @Inject CustomThemeWrapper mCustomThemeWrapper; + private SlidrInterface mSlidrInterface; private boolean mNullAccessToken = false; private String mAccessToken; private String mAccountName; @@ -109,7 +111,7 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti applyCustomTheme(); if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK_FROM_POST_DETAIL, true)) { - Slidr.attach(this); + mSlidrInterface = Slidr.attach(this); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { @@ -179,6 +181,16 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); viewPager.setAdapter(sectionsPagerAdapter); viewPager.setOffscreenPageLimit(3); + viewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { + @Override + public void onPageSelected(int position) { + if (position == 0) { + unlockSwipeRightToGoBack(); + } else { + lockSwipeRightToGoBack(); + } + } + }); tabLayout.setupWithViewPager(viewPager); if (showMultiReddits) { @@ -316,6 +328,18 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti } } + private void lockSwipeRightToGoBack() { + if (mSlidrInterface != null) { + mSlidrInterface.lock(); + } + } + + private void unlockSwipeRightToGoBack() { + if (mSlidrInterface != null) { + mSlidrInterface.unlock(); + } + } + private class SectionsPagerAdapter extends FragmentPagerAdapter { private SubscribedSubredditsListingFragment subscribedSubredditsListingFragment; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewVideoActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewVideoActivity.java index 601920d4..3db53108 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewVideoActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewVideoActivity.java @@ -24,6 +24,7 @@ import android.widget.Toast; import androidx.annotation.NonNull; import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AppCompatActivity; +import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.core.app.ActivityCompat; import androidx.core.content.ContextCompat; @@ -44,6 +45,7 @@ import com.google.android.exoplayer2.upstream.DataSource; import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory; import com.google.android.exoplayer2.upstream.DefaultHttpDataSourceFactory; import com.google.android.exoplayer2.util.Util; +import com.google.android.material.snackbar.Snackbar; import com.thefuntasty.hauler.DragDirection; import com.thefuntasty.hauler.HaulerView; @@ -52,7 +54,7 @@ import javax.inject.Named; import butterknife.BindView; import butterknife.ButterKnife; -import ml.docilealligator.infinityforreddit.FetchGfycatVideoLinks; +import ml.docilealligator.infinityforreddit.FetchGfycatOrRedgifsVideoLinks; import ml.docilealligator.infinityforreddit.Font.ContentFontFamily; import ml.docilealligator.infinityforreddit.Font.FontFamily; import ml.docilealligator.infinityforreddit.Font.TitleFontFamily; @@ -83,6 +85,8 @@ public class ViewVideoActivity extends AppCompatActivity { private static final String VIDEO_URI_STATE = "VUS"; @BindView(R.id.hauler_view_view_video_activity) HaulerView haulerView; + @BindView(R.id.coordinator_layout_view_video_activity) + CoordinatorLayout coordinatorLayout; @BindView(R.id.progress_bar_view_video_activity) ProgressBar progressBar; @BindView(R.id.player_view_view_video_activity) @@ -214,42 +218,17 @@ public class ViewVideoActivity extends AppCompatActivity { } if (mVideoUri == null) { - progressBar.setVisibility(View.VISIBLE); String gfycatId = intent.getStringExtra(EXTRA_GFYCAT_ID); if (gfycatId != null && gfycatId.contains("-")) { gfycatId = gfycatId.substring(0, gfycatId.indexOf('-')); } - Retrofit retrofit; if (videoType == VIDEO_TYPE_GFYCAT) { - retrofit = gfycatRetrofit; videoFileName = "Gfycat-" + gfycatId + ".mp4"; + loadGfycatOrRedgifsVideo(gfycatRetrofit, gfycatId, savedInstanceState, true); } else { - retrofit = redgifsRetrofit; videoFileName = "Redgifs-" + gfycatId + ".mp4"; + loadGfycatOrRedgifsVideo(redgifsRetrofit, gfycatId, savedInstanceState, false); } - FetchGfycatVideoLinks.fetchGfycatVideoLinks(retrofit, gfycatId, - new FetchGfycatVideoLinks.FetchGfycatVideoLinksListener() { - @Override - public void success(String webm, String mp4) { - progressBar.setVisibility(View.GONE); - mVideoUri = Uri.parse(webm); - videoDownloadUrl = mp4; - dataSourceFactory = new DefaultDataSourceFactory(ViewVideoActivity.this, - Util.getUserAgent(ViewVideoActivity.this, "Infinity")); - player.prepare(new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(mVideoUri)); - preparePlayer(savedInstanceState); - } - - @Override - public void failed() { - progressBar.setVisibility(View.GONE); - if (videoType == VIDEO_TYPE_GFYCAT) { - Toast.makeText(ViewVideoActivity.this, R.string.fetch_gfycat_video_failed, Toast.LENGTH_SHORT).show(); - } else { - Toast.makeText(ViewVideoActivity.this, R.string.fetch_redgifs_video_failed, Toast.LENGTH_SHORT).show(); - } - } - }); } else { dataSourceFactory = new DefaultDataSourceFactory(ViewVideoActivity.this, Util.getUserAgent(ViewVideoActivity.this, "Infinity")); @@ -333,6 +312,42 @@ public class ViewVideoActivity extends AppCompatActivity { }); } + private void loadGfycatOrRedgifsVideo(Retrofit retrofit, String gfycatId, Bundle savedInstanceState, boolean needErrorHandling) { + progressBar.setVisibility(View.VISIBLE); + FetchGfycatOrRedgifsVideoLinks.fetchGfycatOrRedgifsVideoLinks(retrofit, gfycatId, + new FetchGfycatOrRedgifsVideoLinks.FetchGfycatOrRedgifsVideoLinksListener() { + @Override + public void success(String webm, String mp4) { + progressBar.setVisibility(View.GONE); + mVideoUri = Uri.parse(webm); + videoDownloadUrl = mp4; + dataSourceFactory = new DefaultDataSourceFactory(ViewVideoActivity.this, + Util.getUserAgent(ViewVideoActivity.this, "Infinity")); + player.prepare(new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(mVideoUri)); + preparePlayer(savedInstanceState); + } + + @Override + public void failed(int errorCode) { + progressBar.setVisibility(View.GONE); + if (videoType == VIDEO_TYPE_GFYCAT) { + if (errorCode == 404 && needErrorHandling) { + if (mSharedPreferences.getBoolean(SharedPreferencesUtils.AUTOMATICALLY_TRY_REDGIFS, true)) { + loadGfycatOrRedgifsVideo(redgifsRetrofit, gfycatId, savedInstanceState, false); + } else { + Snackbar.make(coordinatorLayout, R.string.load_video_in_redgifs, Snackbar.LENGTH_INDEFINITE).setAction(R.string.yes, + view -> loadGfycatOrRedgifsVideo(redgifsRetrofit, gfycatId, savedInstanceState, false)).show(); + } + } else { + Toast.makeText(ViewVideoActivity.this, R.string.fetch_gfycat_video_failed, Toast.LENGTH_SHORT).show(); + } + } else { + Toast.makeText(ViewVideoActivity.this, R.string.fetch_redgifs_video_failed, Toast.LENGTH_SHORT).show(); + } + } + }); + } + @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.view_video, menu); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java index 41acea18..3689f9a8 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java @@ -36,6 +36,7 @@ import androidx.recyclerview.widget.RecyclerView; import com.bumptech.glide.RequestBuilder; import com.bumptech.glide.RequestManager; import com.bumptech.glide.load.DataSource; +import com.bumptech.glide.load.DecodeFormat; import com.bumptech.glide.load.engine.GlideException; import com.bumptech.glide.request.RequestListener; import com.bumptech.glide.request.RequestOptions; @@ -154,6 +155,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy private boolean mShowAbsoluteNumberOfVotes; private boolean mAutoplay = false; private boolean mAutoplayNsfwVideos; + private boolean mMuteAutoplayingVideos; private CommentRecyclerViewAdapterCallback mCommentRecyclerViewAdapterCallback; private boolean isInitiallyLoading; private boolean isInitiallyLoadingFailed; @@ -318,6 +320,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy mAutoplay = Utils.isConnectedToWifi(activity); } mAutoplayNsfwVideos = mSharedPreferences.getBoolean(SharedPreferencesUtils.AUTOPLAY_NSFW_VIDEOS, true); + mMuteAutoplayingVideos = mSharedPreferences.getBoolean(SharedPreferencesUtils.MUTE_AUTOPLAYING_VIDEOS, true); mCommentRecyclerViewAdapterCallback = commentRecyclerViewAdapterCallback; isInitiallyLoading = true; @@ -1139,9 +1142,9 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy if ((mPost.isNSFW() && mNeedBlurNsfw) || (mPost.isSpoiler() && mNeedBlurSpoiler)) { imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10))) - .override(Target.SIZE_ORIGINAL).into(((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView); + .into(((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView); } else { - imageRequestBuilder.override(Target.SIZE_ORIGINAL).into(((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView); + imageRequestBuilder.apply(RequestOptions.noTransformation()).into(((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView); } } else if (holder instanceof PostDetailVideoAndGifPreviewHolder) { RequestBuilder<Drawable> imageRequestBuilder = mGlide.load(mPost.getPreviewUrl()) @@ -1167,9 +1170,9 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy if ((mPost.isNSFW() && mNeedBlurNsfw) || (mPost.isSpoiler() && mNeedBlurSpoiler)) { imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10))) - .override(Target.SIZE_ORIGINAL).into(((PostDetailVideoAndGifPreviewHolder) holder).mImageView); + .into(((PostDetailVideoAndGifPreviewHolder) holder).mImageView); } else { - imageRequestBuilder.override(Target.SIZE_ORIGINAL).into(((PostDetailVideoAndGifPreviewHolder) holder).mImageView); + imageRequestBuilder.apply(RequestOptions.noTransformation()).into(((PostDetailVideoAndGifPreviewHolder) holder).mImageView); } } else if (holder instanceof PostDetailLinkViewHolder) { RequestBuilder<Drawable> imageRequestBuilder = mGlide.load(mPost.getPreviewUrl()) @@ -1195,9 +1198,9 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy if ((mPost.isNSFW() && mNeedBlurNsfw) || (mPost.isSpoiler() && mNeedBlurSpoiler)) { imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10))) - .override(Target.SIZE_ORIGINAL).into(((PostDetailLinkViewHolder) holder).mImageView); + .into(((PostDetailLinkViewHolder) holder).mImageView); } else { - imageRequestBuilder.override(Target.SIZE_ORIGINAL).into(((PostDetailLinkViewHolder) holder).mImageView); + imageRequestBuilder.apply(RequestOptions.noTransformation()).into(((PostDetailLinkViewHolder) holder).mImageView); } } } @@ -2018,7 +2021,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy @Nullable ExoPlayerViewHelper helper; private Uri mediaUri; - private float volume = 0f; + private float volume; public PostDetailVideoAutoplayViewHolder(@NonNull View itemView) { super(itemView); @@ -2047,6 +2050,8 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy aspectRatioFrameLayout.setOnClickListener(null); + volume = mMuteAutoplayingVideos ? 0f : 1f; + muteButton.setOnClickListener(view -> { if (helper != null) { if (helper.getVolume() != 0) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/NavigationDrawerRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/NavigationDrawerRecyclerViewAdapter.java index 0491c1ed..7d038fa0 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/NavigationDrawerRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/NavigationDrawerRecyclerViewAdapter.java @@ -42,7 +42,7 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re private static final int VIEW_TYPE_DIVIDER = 3; private static final int VIEW_TYPE_SUBSCRIBED_SUBREDDIT = 4; private static final int VIEW_TYPE_ACCOUNT = 5; - private static final int CURRENT_MENU_ITEMS = 16; + private static final int CURRENT_MENU_ITEMS = 17; private Context context; private Resources resources; @@ -90,9 +90,9 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re return VIEW_TYPE_SUBSCRIBED_SUBREDDIT; } else if (position == 0) { return VIEW_TYPE_NAV_HEADER; - } else if (position == 1 || position == 6) { + } else if (position == 1 || position == 6 || position == 12) { return VIEW_TYPE_MENU_GROUP_TITLE; - } else if (position == 12) { + } else if (position == 16) { return VIEW_TYPE_DIVIDER; } else { return VIEW_TYPE_MENU_ITEM; @@ -214,6 +214,8 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re ((MenuGroupTitleViewHolder) holder).titleTextView.setText(R.string.label_account); } else if (position == 6) { ((MenuGroupTitleViewHolder) holder).titleTextView.setText(R.string.label_post); + } else if (position == 12) { + ((MenuGroupTitleViewHolder) holder).titleTextView.setText(R.string.label_preferences); } } else if (holder instanceof MenuItemViewHolder) { int stringId = 0; @@ -401,7 +403,7 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re if (subscribedSubreddits != null) { return CURRENT_MENU_ITEMS + subscribedSubreddits.size(); } - return CURRENT_MENU_ITEMS; + return CURRENT_MENU_ITEMS - 1; } else { return 4; } @@ -448,7 +450,7 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re this.isNSFWEnabled = isNSFWEnabled; if (isInMainPage) { if (isLoggedIn) { - notifyItemChanged(CURRENT_MENU_ITEMS - 2); + notifyItemChanged(CURRENT_MENU_ITEMS - 3); } else { notifyItemChanged(2); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java index a7af4e11..86101979 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java @@ -34,6 +34,7 @@ import com.bumptech.glide.Glide; import com.bumptech.glide.RequestBuilder; import com.bumptech.glide.RequestManager; import com.bumptech.glide.load.DataSource; +import com.bumptech.glide.load.DecodeFormat; import com.bumptech.glide.load.engine.GlideException; import com.bumptech.glide.request.RequestListener; import com.bumptech.glide.request.RequestOptions; @@ -164,6 +165,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView private boolean mShowAbsoluteNumberOfVotes; private boolean mAutoplay = false; private boolean mAutoplayNsfwVideos; + private boolean mMuteAutoplayingVideos; private boolean mShowThumbnailOnTheRightInCompactLayout; private Drawable mCommentIcon; private NetworkState networkState; @@ -198,6 +200,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView mAutoplay = Utils.isConnectedToWifi(activity); } mAutoplayNsfwVideos = sharedPreferences.getBoolean(SharedPreferencesUtils.AUTOPLAY_NSFW_VIDEOS, true); + mMuteAutoplayingVideos = sharedPreferences.getBoolean(SharedPreferencesUtils.MUTE_AUTOPLAYING_VIDEOS, true); mShowThumbnailOnTheRightInCompactLayout = sharedPreferences.getBoolean( SharedPreferencesUtils.SHOW_THUMBNAIL_ON_THE_RIGHT_IN_COMPACT_LAYOUT, false); mPostLayout = postLayout; @@ -1144,9 +1147,9 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView if ((post.isNSFW() && mNeedBlurNSFW) || post.isSpoiler() && mNeedBlurSpoiler) { imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10))) - .override(Target.SIZE_ORIGINAL).into(((PostImageAndGifAutoplayViewHolder) holder).imageView); + .into(((PostImageAndGifAutoplayViewHolder) holder).imageView); } else { - imageRequestBuilder.override(Target.SIZE_ORIGINAL).into(((PostImageAndGifAutoplayViewHolder) holder).imageView); + imageRequestBuilder.apply(RequestOptions.noTransformation()).into(((PostImageAndGifAutoplayViewHolder) holder).imageView); } } else if (holder instanceof PostVideoAndGifPreviewViewHolder) { RequestBuilder<Drawable> imageRequestBuilder = mGlide.load(post.getPreviewUrl()).listener(new RequestListener<Drawable>() { @@ -1172,9 +1175,9 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView if ((post.isNSFW() && mNeedBlurNSFW) || post.isSpoiler() && mNeedBlurSpoiler) { imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10))) - .override(Target.SIZE_ORIGINAL).into(((PostVideoAndGifPreviewViewHolder) holder).imageView); + .into(((PostVideoAndGifPreviewViewHolder) holder).imageView); } else { - imageRequestBuilder.override(Target.SIZE_ORIGINAL).into(((PostVideoAndGifPreviewViewHolder) holder).imageView); + imageRequestBuilder.apply(RequestOptions.noTransformation()).into(((PostVideoAndGifPreviewViewHolder) holder).imageView); } } else if (holder instanceof PostLinkTypeViewHolder) { RequestBuilder<Drawable> imageRequestBuilder = mGlide.load(post.getPreviewUrl()).listener(new RequestListener<Drawable>() { @@ -1200,9 +1203,9 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView if ((post.isNSFW() && mNeedBlurNSFW) || post.isSpoiler() && mNeedBlurSpoiler) { imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10))) - .override(Target.SIZE_ORIGINAL).into(((PostLinkTypeViewHolder) holder).imageView); + .into(((PostLinkTypeViewHolder) holder).imageView); } else { - imageRequestBuilder.override(Target.SIZE_ORIGINAL).into(((PostLinkTypeViewHolder) holder).imageView); + imageRequestBuilder.apply(RequestOptions.noTransformation()).into(((PostLinkTypeViewHolder) holder).imageView); } } else if (holder instanceof PostCompactViewHolder) { String previewUrl = post.getThumbnailPreviewUrl().equals("") ? post.getPreviewUrl() : post.getThumbnailPreviewUrl(); @@ -1222,10 +1225,9 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView }); if ((post.isNSFW() && mNeedBlurNSFW) || post.isSpoiler() && mNeedBlurSpoiler) { imageRequestBuilder - .transform(new BlurTransformation(50, 2)) - .override(Target.SIZE_ORIGINAL).into(((PostCompactViewHolder) holder).imageView); + .transform(new BlurTransformation(50, 2)).into(((PostCompactViewHolder) holder).imageView); } else { - imageRequestBuilder.override(Target.SIZE_ORIGINAL).into(((PostCompactViewHolder) holder).imageView); + imageRequestBuilder.into(((PostCompactViewHolder) holder).imageView); } } } @@ -1327,6 +1329,10 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView mAutoplayNsfwVideos = autoplayNsfwVideos; } + public void setMuteAutoplayingVideos(boolean muteAutoplayingVideos) { + mMuteAutoplayingVideos = muteAutoplayingVideos; + } + public void setShowThumbnailOnTheRightInCompactLayout(boolean showThumbnailOnTheRightInCompactLayout) { mShowThumbnailOnTheRightInCompactLayout = showThumbnailOnTheRightInCompactLayout; } @@ -1895,7 +1901,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView @Nullable ExoPlayerViewHelper helper; private Uri mediaUri; - private float volume = 0f; + private float volume; PostVideoAutoplayViewHolder(View itemView) { super(itemView); @@ -1925,6 +1931,8 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView aspectRatioFrameLayout.setOnClickListener(null); + volume = mMuteAutoplayingVideos ? 0f : 1f; + muteButton.setOnClickListener(view -> { if (helper != null) { if (helper.getVolume() != 0) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Event/ChangeMuteAutoplayingVideosEvent.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Event/ChangeMuteAutoplayingVideosEvent.java new file mode 100644 index 00000000..421be2a1 --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Event/ChangeMuteAutoplayingVideosEvent.java @@ -0,0 +1,9 @@ +package ml.docilealligator.infinityforreddit.Event; + +public class ChangeMuteAutoplayingVideosEvent { + public boolean muteAutoplayingVideos; + + public ChangeMuteAutoplayingVideosEvent(boolean muteAutoplayingVideos) { + this.muteAutoplayingVideos = muteAutoplayingVideos; + } +} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchGfycatVideoLinks.java b/app/src/main/java/ml/docilealligator/infinityforreddit/FetchGfycatOrRedgifsVideoLinks.java index b9799484..9d51cb1e 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchGfycatVideoLinks.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/FetchGfycatOrRedgifsVideoLinks.java @@ -14,27 +14,27 @@ import retrofit2.Callback; import retrofit2.Response; import retrofit2.Retrofit; -public class FetchGfycatVideoLinks { - public interface FetchGfycatVideoLinksListener { +public class FetchGfycatOrRedgifsVideoLinks { + public interface FetchGfycatOrRedgifsVideoLinksListener { void success(String webm, String mp4); - void failed(); + void failed(int errorCode); } - public static void fetchGfycatVideoLinks(Retrofit gfycatRetrofit, String gfycatId, - FetchGfycatVideoLinksListener fetchGfycatVideoLinksListener) { + public static void fetchGfycatOrRedgifsVideoLinks(Retrofit gfycatRetrofit, String gfycatId, + FetchGfycatOrRedgifsVideoLinksListener fetchGfycatOrRedgifsVideoLinksListener) { gfycatRetrofit.create(GfycatAPI.class).getGfycatData(gfycatId).enqueue(new Callback<String>() { @Override public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) { if (response.isSuccessful()) { - new ParseGfycatVideoLinksAsyncTask(response.body(), fetchGfycatVideoLinksListener).execute(); + new ParseGfycatVideoLinksAsyncTask(response.body(), fetchGfycatOrRedgifsVideoLinksListener).execute(); } else { - fetchGfycatVideoLinksListener.failed(); + fetchGfycatOrRedgifsVideoLinksListener.failed(response.code()); } } @Override public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) { - fetchGfycatVideoLinksListener.failed(); + fetchGfycatOrRedgifsVideoLinksListener.failed(-1); } }); } @@ -45,11 +45,11 @@ public class FetchGfycatVideoLinks { private String webm; private String mp4; private boolean parseFailed = false; - private FetchGfycatVideoLinksListener fetchGfycatVideoLinksListener; + private FetchGfycatOrRedgifsVideoLinksListener fetchGfycatOrRedgifsVideoLinksListener; - ParseGfycatVideoLinksAsyncTask(String response, FetchGfycatVideoLinksListener fetchGfycatVideoLinksListener) { + ParseGfycatVideoLinksAsyncTask(String response, FetchGfycatOrRedgifsVideoLinksListener fetchGfycatOrRedgifsVideoLinksListener) { this.response = response; - this.fetchGfycatVideoLinksListener = fetchGfycatVideoLinksListener; + this.fetchGfycatOrRedgifsVideoLinksListener = fetchGfycatOrRedgifsVideoLinksListener; } @Override @@ -70,9 +70,9 @@ public class FetchGfycatVideoLinks { protected void onPostExecute(Void aVoid) { super.onPostExecute(aVoid); if (parseFailed) { - fetchGfycatVideoLinksListener.failed(); + fetchGfycatOrRedgifsVideoLinksListener.failed(-1); } else { - fetchGfycatVideoLinksListener.success(webm, mp4); + fetchGfycatOrRedgifsVideoLinksListener.success(webm, mp4); } } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchRemovedComment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/FetchRemovedComment.java index 6e18e927..d012342e 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchRemovedComment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/FetchRemovedComment.java @@ -37,19 +37,19 @@ public class FetchRemovedComment { }); } - private static CommentData parseRemovedComment(JSONObject comment, CommentData commentData) throws JSONException { - String id = comment.getString(JSONUtils.ID_KEY); - if (id.equals(commentData.getId())) { - String author = comment.getString(JSONUtils.AUTHOR_KEY); - String commentMarkdown = ""; - if (!comment.isNull(JSONUtils.BODY_KEY)) { - commentMarkdown = Utils.modifyMarkdown(comment.getString(JSONUtils.BODY_KEY).trim()); - } - - commentData.setAuthor(author); - commentData.setCommentMarkdown(commentMarkdown); - commentData.setCommentRawText(commentMarkdown); - return commentData; + private static CommentData parseRemovedComment(JSONObject result, CommentData comment) throws JSONException { + String id = result.getString(JSONUtils.ID_KEY); + String author = result.getString(JSONUtils.AUTHOR_KEY); + String body = Utils.modifyMarkdown(result.optString(JSONUtils.BODY_KEY).trim()); + + if ( id.equals(comment.getId()) && + (!author.equals(comment.getAuthor()) || + !body.equals(comment.getCommentRawText())) + ) { + comment.setAuthor(author); + comment.setCommentMarkdown(body); + comment.setCommentRawText(body); + return comment; } else { return null; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchRemovedPost.java b/app/src/main/java/ml/docilealligator/infinityforreddit/FetchRemovedPost.java index 2a8076a9..646dfe19 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchRemovedPost.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/FetchRemovedPost.java @@ -40,26 +40,29 @@ public class FetchRemovedPost { }); } - private static Post parseRemovedPost(JSONObject postJson, Post post) throws JSONException { - String id = postJson.getString(JSONUtils.ID_KEY); - if (id.equals(post.getId())) { - String author = postJson.getString(JSONUtils.AUTHOR_KEY); - String title = postJson.getString(JSONUtils.TITLE_KEY); - String postContent = Utils.modifyMarkdown(postJson.getString(JSONUtils.SELFTEXT_KEY).trim()); - + private static Post parseRemovedPost(JSONObject result, Post post) throws JSONException { + String id = result.getString(JSONUtils.ID_KEY); + String author = result.getString(JSONUtils.AUTHOR_KEY); + String title = result.getString(JSONUtils.TITLE_KEY); + String body = Utils.modifyMarkdown(result.getString(JSONUtils.SELFTEXT_KEY).trim()); + + if ( id.equals(post.getId()) && + (!author.equals(post.getAuthor()) || + foundSelfText(post.getSelfText(), body)) + ) { post.setAuthor(author); post.setTitle(title); - post.setSelfText(postContent); + post.setSelfText(body); post.setSelfTextPlain(""); post.setSelfTextPlainTrimmed(""); - String url = postJson.optString(JSONUtils.URL_KEY); + String url = result.optString(JSONUtils.URL_KEY); if (url.endsWith("gif") || url.endsWith("mp4")) { post.setVideoUrl(url); post.setVideoDownloadUrl(url); } else if (post.getPostType() == Post.VIDEO_TYPE || post.getPostType() == Post.GIF_TYPE) { - JSONObject redditVideoObject = postJson.getJSONObject("secure_media").getJSONObject(JSONUtils.REDDIT_VIDEO_KEY); + JSONObject redditVideoObject = result.getJSONObject("secure_media").getJSONObject(JSONUtils.REDDIT_VIDEO_KEY); String videoUrl = Html.fromHtml(redditVideoObject.getString(JSONUtils.HLS_URL_KEY)).toString(); String videoDownloadUrl = redditVideoObject.getString(JSONUtils.FALLBACK_URL_KEY); @@ -81,8 +84,8 @@ public class FetchRemovedPost { } } - if (!postJson.isNull("thumbnail")) { - post.setThumbnailPreviewUrl(postJson.getString("thumbnail")); + if (!result.isNull("thumbnail")) { + post.setThumbnailPreviewUrl(result.getString("thumbnail")); } return post; @@ -91,6 +94,11 @@ public class FetchRemovedPost { } } + private static boolean foundSelfText(String oldText, String newText) { + return !(newText.equals("[deleted]") || newText.equals("[removed]")) && + !newText.equals(oldText); + } + public interface FetchRemovedPostListener { void fetchSuccess(Post post); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java index 48972914..3aa0f16c 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java @@ -59,6 +59,7 @@ import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.CustomView.CustomToroContainer; import ml.docilealligator.infinityforreddit.Event.ChangeAutoplayNsfwVideosEvent; import ml.docilealligator.infinityforreddit.Event.ChangeDefaultPostLayoutEvent; +import ml.docilealligator.infinityforreddit.Event.ChangeMuteAutoplayingVideosEvent; import ml.docilealligator.infinityforreddit.Event.ChangeNSFWBlurEvent; import ml.docilealligator.infinityforreddit.Event.ChangePostLayoutEvent; import ml.docilealligator.infinityforreddit.Event.ChangeShowAbsoluteNumberOfVotesEvent; @@ -891,7 +892,15 @@ public class PostFragment extends Fragment implements FragmentCommunicator { public void onChangeAutoplayNsfwVideosEvent(ChangeAutoplayNsfwVideosEvent changeAutoplayNsfwVideosEvent) { if (mAdapter != null) { mAdapter.setAutoplayNsfwVideos(changeAutoplayNsfwVideosEvent.autoplayNsfwVideos); - refresh(); + refreshAdapter(); + } + } + + @Subscribe + public void onChangeMuteAutoplayingVideosEvent(ChangeMuteAutoplayingVideosEvent changeMuteAutoplayingVideosEvent) { + if (mAdapter != null) { + mAdapter.setMuteAutoplayingVideos(changeMuteAutoplayingVideosEvent.muteAutoplayingVideos); + refreshAdapter(); } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/AboutPreferenceFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/AboutPreferenceFragment.java index 3d81bb30..71e9dbc6 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/AboutPreferenceFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/AboutPreferenceFragment.java @@ -13,6 +13,7 @@ import androidx.preference.Preference; import androidx.preference.PreferenceFragmentCompat; import ml.docilealligator.infinityforreddit.Activity.LinkResolverActivity; +import ml.docilealligator.infinityforreddit.BuildConfig; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; @@ -34,6 +35,7 @@ public class AboutPreferenceFragment extends PreferenceFragmentCompat { Preference redditAccountPreference = findPreference(SharedPreferencesUtils.REDDIT_ACCOUNT_KEY); Preference subredditPreference = findPreference(SharedPreferencesUtils.SUBREDDIT_KEY); Preference sharePreference = findPreference(SharedPreferencesUtils.SHARE_KEY); + Preference versionPreference = findPreference(SharedPreferencesUtils.VERSION_KEY); if (openSourcePreference != null) { openSourcePreference.setOnPreferenceClickListener(preference -> { @@ -112,6 +114,24 @@ public class AboutPreferenceFragment extends PreferenceFragmentCompat { return true; }); } + + if (versionPreference != null) { + versionPreference.setSummary(getString(R.string.settings_version_summary, BuildConfig.VERSION_NAME)); + + versionPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { + int clickedTimes = 0; + + @Override + public boolean onPreferenceClick(Preference preference) { + clickedTimes++; + if (clickedTimes > 6) { + Toast.makeText(activity, R.string.no_developer_easter_egg, Toast.LENGTH_SHORT).show(); + clickedTimes = 0; + } + return true; + } + }); + } } @Override diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/CreditsPreferenceFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/CreditsPreferenceFragment.java index 8607b486..3bb14843 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/CreditsPreferenceFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/CreditsPreferenceFragment.java @@ -32,6 +32,7 @@ public class CreditsPreferenceFragment extends PreferenceFragmentCompat { Preference gildedIconPreference = findPreference(SharedPreferencesUtils.GILDED_ICON_KEY); Preference crosspostIconPreference = findPreference(SharedPreferencesUtils.CROSSPOST_ICON_KEY); Preference thumbtackIconPreference = findPreference(SharedPreferencesUtils.THUMBTACK_ICON_KEY); + Preference bestRocketIconPreference = findPreference(SharedPreferencesUtils.BEST_ROCKET_ICON_KEY); Preference materialIconsPreference = findPreference(SharedPreferencesUtils.MATERIAL_ICONS_KEY); if (iconForegroundPreference != null) { @@ -88,6 +89,15 @@ public class CreditsPreferenceFragment extends PreferenceFragmentCompat { }); } + if (bestRocketIconPreference != null) { + bestRocketIconPreference.setOnPreferenceClickListener(preference -> { + Intent intent = new Intent(activity, LinkResolverActivity.class); + intent.setData(Uri.parse("https://www.flaticon.com/free-icon/spring-swing-rocket_2929322?term=space%20ship&page=1&position=18")); + startActivity(intent); + return true; + }); + } + if (materialIconsPreference != null) { materialIconsPreference.setOnPreferenceClickListener(preference -> { Intent intent = new Intent(activity, LinkResolverActivity.class); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/AutoplayPreferenceFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/VideoPreferenceFragment.java index 91bd52d7..e7cd2432 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/AutoplayPreferenceFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/VideoPreferenceFragment.java @@ -9,17 +9,19 @@ import androidx.preference.SwitchPreference; import org.greenrobot.eventbus.EventBus; import ml.docilealligator.infinityforreddit.Event.ChangeAutoplayNsfwVideosEvent; +import ml.docilealligator.infinityforreddit.Event.ChangeMuteAutoplayingVideosEvent; import ml.docilealligator.infinityforreddit.Event.ChangeVideoAutoplayEvent; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; -public class AutoplayPreferenceFragment extends PreferenceFragmentCompat { +public class VideoPreferenceFragment extends PreferenceFragmentCompat { @Override public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { - setPreferencesFromResource(R.xml.autoplay_preferences, rootKey); + setPreferencesFromResource(R.xml.video_preferences, rootKey); ListPreference videoAutoplayListPreference = findPreference(SharedPreferencesUtils.VIDEO_AUTOPLAY); + SwitchPreference muteAutoplayingVideosSwitchPreference = findPreference(SharedPreferencesUtils.MUTE_AUTOPLAYING_VIDEOS); SwitchPreference autoplayNsfwVideosSwitchPreference = findPreference(SharedPreferencesUtils.AUTOPLAY_NSFW_VIDEOS); if (videoAutoplayListPreference != null && autoplayNsfwVideosSwitchPreference != null) { @@ -33,5 +35,12 @@ public class AutoplayPreferenceFragment extends PreferenceFragmentCompat { return true; }); } + + if (muteAutoplayingVideosSwitchPreference != null) { + muteAutoplayingVideosSwitchPreference.setOnPreferenceChangeListener((preference, newValue) -> { + EventBus.getDefault().post(new ChangeMuteAutoplayingVideosEvent((Boolean) newValue)); + return true; + }); + } } }
\ No newline at end of file diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/APIUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/APIUtils.java index 7f49deee..029b4197 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/APIUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/APIUtils.java @@ -24,14 +24,14 @@ public class APIUtils { public static final String PUSHSHIFT_API_BASE_URI = "https://api.pushshift.io/"; public static final String CLIENT_ID_KEY = "client_id"; - public static final String CLIENT_ID = ""; - public static final String IMGUR_CLIENT_ID = ""; + public static final String CLIENT_ID = "NOe2iKrPPzwscA"; + public static final String IMGUR_CLIENT_ID = "Client-ID cc671794e0ab397"; public static final String RESPONSE_TYPE_KEY = "response_type"; public static final String RESPONSE_TYPE = "code"; public static final String STATE_KEY = "state"; - public static final String STATE = ""; + public static final String STATE = "23ro8xlxvzp4asqd"; public static final String REDIRECT_URI_KEY = "redirect_uri"; - public static final String REDIRECT_URI = ""; + public static final String REDIRECT_URI = "infinity://localhost"; public static final String DURATION_KEY = "duration"; public static final String DURATION = "permanent"; public static final String SCOPE_KEY = "scope"; @@ -41,7 +41,7 @@ public class APIUtils { public static final String AUTHORIZATION_KEY = "Authorization"; public static final String AUTHORIZATION_BASE = "bearer "; public static final String USER_AGENT_KEY = "User-Agent"; - public static final String USER_AGENT = ""; + public static final String USER_AGENT = "android:ml.docilealligator.infinityforreddit:v3.2.0 (by /u/Hostilenemy)"; public static final String GRANT_TYPE_KEY = "grant_type"; public static final String GRANT_TYPE_REFRESH_TOKEN = "refresh_token"; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java index a26571a9..ee25195d 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java @@ -18,6 +18,7 @@ public class SharedPreferencesUtils { public static final String GILDED_ICON_KEY = "gilded_icon"; public static final String CROSSPOST_ICON_KEY = "crosspost_icon"; public static final String THUMBTACK_ICON_KEY = "thumbtack_icon"; + public static final String BEST_ROCKET_ICON_KEY = "best_rocket_icon"; public static final String MATERIAL_ICONS_KEY = "material_icons"; public static final String OPEN_SOURCE_KEY = "open_source"; public static final String RATE_KEY = "rate"; @@ -26,6 +27,7 @@ public class SharedPreferencesUtils { public static final String REDDIT_ACCOUNT_KEY = "reddit_account"; public static final String SUBREDDIT_KEY = "subreddit"; public static final String SHARE_KEY = "share"; + public static final String VERSION_KEY = "version"; public static final String FONT_SIZE_KEY = "font_size"; public static final String TITLE_FONT_SIZE_KEY = "title_font_size"; public static final String CONTENT_FONT_SIZE_KEY = "content_font_size"; @@ -84,7 +86,9 @@ public class SharedPreferencesUtils { public static final String VIDEO_AUTOPLAY_VALUE_ALWAYS_ON = "2"; public static final String VIDEO_AUTOPLAY_VALUE_ON_WIFI = "1"; public static final String VIDEO_AUTOPLAY_VALUE_NEVER = "0"; + public static final String MUTE_AUTOPLAYING_VIDEOS = "mute_autoplaying_videos"; public static final String AUTOPLAY_NSFW_VIDEOS = "autoplay_nsfw_videos"; + public static final String AUTOMATICALLY_TRY_REDGIFS = "automatically_try_redgifs"; public static final String LOCK_JUMP_TO_NEXT_TOP_LEVEL_COMMENT_BUTTON = "lock_jump_to_next_top_level_comment_button"; public static final String SWAP_TAP_AND_LONG_COMMENTS = "swap_tap_and_long_in_comments"; public static final String SWIPE_UP_TO_HIDE_JUMP_TO_NEXT_TOP_LEVEL_COMMENT_BUTTON = "swipe_up_to_hide_jump_to_next_top_level_comments_button"; diff --git a/app/src/main/res/drawable-night/ic_preview_24dp.xml b/app/src/main/res/drawable-night/ic_preview_24dp.xml new file mode 100644 index 00000000..e54e3a9f --- /dev/null +++ b/app/src/main/res/drawable-night/ic_preview_24dp.xml @@ -0,0 +1,9 @@ +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + <path + android:pathData="M12,6.5c3.79,0 7.17,2.13 8.82,5.5 -1.65,3.37 -5.02,5.5 -8.82,5.5S4.83,15.37 3.18,12C4.83,8.63 8.21,6.5 12,6.5m0,-2C7,4.5 2.73,7.61 1,12c1.73,4.39 6,7.5 11,7.5s9.27,-3.11 11,-7.5c-1.73,-4.39 -6,-7.5 -11,-7.5zM12,9.5c1.38,0 2.5,1.12 2.5,2.5s-1.12,2.5 -2.5,2.5 -2.5,-1.12 -2.5,-2.5 1.12,-2.5 2.5,-2.5m0,-2c-2.48,0 -4.5,2.02 -4.5,4.5s2.02,4.5 4.5,4.5 4.5,-2.02 4.5,-4.5 -2.02,-4.5 -4.5,-4.5z" + android:fillColor="#FFFFFF"/> +</vector> diff --git a/app/src/main/res/drawable/ic_best_24.xml b/app/src/main/res/drawable/ic_best_24.xml new file mode 100644 index 00000000..6a592ecc --- /dev/null +++ b/app/src/main/res/drawable/ic_best_24.xml @@ -0,0 +1,17 @@ +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + <group + android:pivotX="12" + android:pivotY="12" + android:rotation="30"> + <path + android:fillColor="@android:color/white" + android:pathData="M11.3,22.66h1.4L12.7,24h-1.4zM11.3,22.66M12.07,0.06L12,0l-0.07,0.06a15.15,15.15 0,0 0,-3.47 4.89h7.08A15.1,15.1 0,0 0,12.07 0.06zM12.07,0.06M4.04,13.69v6.2l3.67,-1.15a16.43,16.43 0,0 1,-1.85 -6.21zM4.04,13.69M13.28,10.8a1.28,1.28 0,1 0,-2.56 0,1.28 1.28,0 0,0 2.56,0zM13.28,10.8" /> + <path + android:fillColor="@android:color/white" + android:pathData="M14.44,19.13a15,15 0,0 0,1.64 -12.77L7.92,6.36a15,15 0,0 0,1.64 12.77h1.74v2.06h1.4v-2.07zM9.32,10.8a2.68,2.68 0,1 1,5.37 0,2.68 2.68,0 0,1 -5.37,0zM9.32,10.8M8.83,20.53h1.4v1.9h-1.4zM8.83,20.53M18.14,12.53c-0.2,2.17 -0.83,4.28 -1.85,6.2l3.67,1.16v-6.2zM18.14,12.53M13.77,20.53h1.4v1.9h-1.4zM13.77,20.53" /> + </group> +</vector> diff --git a/app/src/main/res/drawable/ic_controversial_24.xml b/app/src/main/res/drawable/ic_controversial_24.xml new file mode 100644 index 00000000..8084cc1d --- /dev/null +++ b/app/src/main/res/drawable/ic_controversial_24.xml @@ -0,0 +1,9 @@ +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + <path + android:fillColor="@android:color/white" + android:pathData="M9,3L5,6.99h3L8,14h2L10,6.99h3L9,3zM16,17.01L16,10h-2v7.01h-3L15,21l4,-3.99h-3z" /> +</vector> diff --git a/app/src/main/res/drawable/ic_hot_24.xml b/app/src/main/res/drawable/ic_hot_24.xml new file mode 100644 index 00000000..c163a23d --- /dev/null +++ b/app/src/main/res/drawable/ic_hot_24.xml @@ -0,0 +1,9 @@ +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + <path + android:fillColor="@android:color/white" + android:pathData="M13.5,0.67s0.74,2.65 0.74,4.8c0,2.06 -1.35,3.73 -3.41,3.73 -2.07,0 -3.63,-1.67 -3.63,-3.73l0.03,-0.36C5.21,7.51 4,10.62 4,14c0,4.42 3.58,8 8,8s8,-3.58 8,-8C20,8.61 17.41,3.8 13.5,0.67zM11.71,19c-1.78,0 -3.22,-1.4 -3.22,-3.14 0,-1.62 1.05,-2.76 2.81,-3.12 1.77,-0.36 3.6,-1.21 4.62,-2.58 0.39,1.29 0.59,2.65 0.59,4.04 0,2.65 -2.15,4.8 -4.8,4.8z" /> +</vector> diff --git a/app/src/main/res/drawable/ic_new_24.xml b/app/src/main/res/drawable/ic_new_24.xml new file mode 100644 index 00000000..5ed64d37 --- /dev/null +++ b/app/src/main/res/drawable/ic_new_24.xml @@ -0,0 +1,9 @@ +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + <path + android:fillColor="@android:color/white" + android:pathData="M23,12l-2.44,-2.78 0.34,-3.68 -3.61,-0.82 -1.89,-3.18L12,3 8.6,1.54 6.71,4.72l-3.61,0.81 0.34,3.68L1,12l2.44,2.78 -0.34,3.69 3.61,0.82 1.89,3.18L12,21l3.4,1.46 1.89,-3.18 3.61,-0.82 -0.34,-3.68L23,12z" /> +</vector> diff --git a/app/src/main/res/drawable/ic_random_24.xml b/app/src/main/res/drawable/ic_random_24.xml new file mode 100644 index 00000000..002ff2d7 --- /dev/null +++ b/app/src/main/res/drawable/ic_random_24.xml @@ -0,0 +1,9 @@ +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + <path + android:fillColor="@android:color/white" + android:pathData="M19,3L5,3c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2L21,5c0,-1.1 -0.9,-2 -2,-2zM7.5,18c-0.83,0 -1.5,-0.67 -1.5,-1.5S6.67,15 7.5,15s1.5,0.67 1.5,1.5S8.33,18 7.5,18zM7.5,9C6.67,9 6,8.33 6,7.5S6.67,6 7.5,6 9,6.67 9,7.5 8.33,9 7.5,9zM12,13.5c-0.83,0 -1.5,-0.67 -1.5,-1.5s0.67,-1.5 1.5,-1.5 1.5,0.67 1.5,1.5 -0.67,1.5 -1.5,1.5zM16.5,18c-0.83,0 -1.5,-0.67 -1.5,-1.5s0.67,-1.5 1.5,-1.5 1.5,0.67 1.5,1.5 -0.67,1.5 -1.5,1.5zM16.5,9c-0.83,0 -1.5,-0.67 -1.5,-1.5S15.67,6 16.5,6s1.5,0.67 1.5,1.5S17.33,9 16.5,9z" /> +</vector> diff --git a/app/src/main/res/drawable/ic_rising_24.xml b/app/src/main/res/drawable/ic_rising_24.xml new file mode 100644 index 00000000..75754f74 --- /dev/null +++ b/app/src/main/res/drawable/ic_rising_24.xml @@ -0,0 +1,9 @@ +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + <path + android:fillColor="@android:color/white" + android:pathData="M16,6l2.29,2.29 -4.88,4.88 -4,-4L2,16.59 3.41,18l6,-6 4,4 6.3,-6.29L22,12V6z" /> +</vector> diff --git a/app/src/main/res/drawable/ic_top_24.xml b/app/src/main/res/drawable/ic_top_24.xml new file mode 100644 index 00000000..ed64f733 --- /dev/null +++ b/app/src/main/res/drawable/ic_top_24.xml @@ -0,0 +1,9 @@ +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + <path + android:fillColor="@android:color/white" + android:pathData="M10,20h4L14,6h-4v16zM4,20h4v-8L4,12v8zM16,9v11h4L20,9h-4zM7,6l5,-5 5,5z" /> +</vector> diff --git a/app/src/main/res/layout/activity_comment.xml b/app/src/main/res/layout/activity_comment.xml index 100db899..1fe93f50 100644 --- a/app/src/main/res/layout/activity_comment.xml +++ b/app/src/main/res/layout/activity_comment.xml @@ -45,9 +45,9 @@ android:id="@+id/content_markdown_view_comment_activity" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginStart="16dp" - android:layout_marginEnd="16dp" - android:layout_marginBottom="16dp" + android:layout_marginStart="8dp" + android:layout_marginEnd="8dp" + android:layout_marginBottom="8dp" android:visibility="gone" /> <View diff --git a/app/src/main/res/layout/activity_view_video.xml b/app/src/main/res/layout/activity_view_video.xml index 2907fd4d..1d18f2ab 100644 --- a/app/src/main/res/layout/activity_view_video.xml +++ b/app/src/main/res/layout/activity_view_video.xml @@ -15,7 +15,8 @@ android:layout_height="match_parent" android:fillViewport="true"> - <RelativeLayout + <androidx.coordinatorlayout.widget.CoordinatorLayout + android:id="@+id/coordinator_layout_view_video_activity" android:layout_width="match_parent" android:layout_height="match_parent"> @@ -29,10 +30,10 @@ android:id="@+id/progress_bar_view_video_activity" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_centerInParent="true" + android:layout_gravity="center" android:visibility="gone" /> - </RelativeLayout> + </androidx.coordinatorlayout.widget.CoordinatorLayout> </androidx.core.widget.NestedScrollView> diff --git a/app/src/main/res/layout/fragment_search_post_sort_type_bottom_sheet.xml b/app/src/main/res/layout/fragment_search_post_sort_type_bottom_sheet.xml index f7511131..8b1c86b6 100644 --- a/app/src/main/res/layout/fragment_search_post_sort_type_bottom_sheet.xml +++ b/app/src/main/res/layout/fragment_search_post_sort_type_bottom_sheet.xml @@ -1,95 +1,111 @@ <?xml version="1.0" encoding="utf-8"?> <androidx.core.widget.NestedScrollView 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="wrap_content" - android:paddingBottom="8dp" - android:overScrollMode="never"> + android:overScrollMode="never" + android:paddingBottom="8dp"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> - <TextView + <androidx.appcompat.widget.AppCompatTextView android:id="@+id/relevance_type_text_view_search_sort_type_bottom_sheet_fragment" android:layout_width="match_parent" android:layout_height="wrap_content" - android:text="@string/sort_relevance" - android:textColor="?attr/primaryTextColor" - android:textSize="?attr/font_default" + android:background="?attr/selectableItemBackground" + android:clickable="true" + android:drawableStart="@drawable/ic_best_24" + android:drawablePadding="48dp" + android:focusable="true" android:fontFamily="?attr/font_family" - android:paddingTop="16dp" - android:paddingBottom="16dp" android:paddingStart="32dp" + android:paddingTop="16dp" android:paddingEnd="32dp" - android:clickable="true" - android:focusable="true" - android:background="?attr/selectableItemBackground" /> + android:paddingBottom="16dp" + android:text="@string/sort_relevance" + android:textColor="?attr/primaryTextColor" + android:textSize="?attr/font_default" + app:drawableTint="?attr/primaryTextColor" /> - <TextView + <androidx.appcompat.widget.AppCompatTextView android:id="@+id/hot_type_text_view_search_sort_type_bottom_sheet_fragment" android:layout_width="match_parent" android:layout_height="wrap_content" - android:text="@string/sort_hot" - android:textColor="?attr/primaryTextColor" - android:textSize="?attr/font_default" + android:background="?attr/selectableItemBackground" + android:clickable="true" + android:drawableStart="@drawable/ic_hot_24" + android:drawablePadding="48dp" + android:focusable="true" android:fontFamily="?attr/font_family" - android:paddingTop="16dp" - android:paddingBottom="16dp" android:paddingStart="32dp" + android:paddingTop="16dp" android:paddingEnd="32dp" - android:clickable="true" - android:focusable="true" - android:background="?attr/selectableItemBackground" /> + android:paddingBottom="16dp" + android:text="@string/sort_hot" + android:textColor="?attr/primaryTextColor" + android:textSize="?attr/font_default" + app:drawableTint="?attr/primaryTextColor" /> - <TextView + <androidx.appcompat.widget.AppCompatTextView android:id="@+id/top_type_text_view_search_sort_type_bottom_sheet_fragment" android:layout_width="match_parent" android:layout_height="wrap_content" - android:text="@string/sort_top" - android:textColor="?attr/primaryTextColor" - android:textSize="?attr/font_default" + android:background="?attr/selectableItemBackground" + android:clickable="true" + android:drawableStart="@drawable/ic_top_24" + android:drawablePadding="48dp" + android:focusable="true" android:fontFamily="?attr/font_family" - android:paddingTop="16dp" - android:paddingBottom="16dp" android:paddingStart="32dp" + android:paddingTop="16dp" android:paddingEnd="32dp" - android:clickable="true" - android:focusable="true" - android:background="?attr/selectableItemBackground" /> + android:paddingBottom="16dp" + android:text="@string/sort_top" + android:textColor="?attr/primaryTextColor" + android:textSize="?attr/font_default" + app:drawableTint="?attr/primaryTextColor" /> - <TextView + <androidx.appcompat.widget.AppCompatTextView android:id="@+id/new_type_text_view_search_sort_type_bottom_sheet_fragment" android:layout_width="match_parent" android:layout_height="wrap_content" - android:text="@string/sort_new" - android:textColor="?attr/primaryTextColor" - android:textSize="?attr/font_default" + android:background="?attr/selectableItemBackground" + android:clickable="true" + android:drawableStart="@drawable/ic_new_24" + android:drawablePadding="48dp" + android:focusable="true" android:fontFamily="?attr/font_family" - android:paddingTop="16dp" - android:paddingBottom="16dp" android:paddingStart="32dp" + android:paddingTop="16dp" android:paddingEnd="32dp" - android:clickable="true" - android:focusable="true" - android:background="?attr/selectableItemBackground" /> + android:paddingBottom="16dp" + android:text="@string/sort_new" + android:textColor="?attr/primaryTextColor" + android:textSize="?attr/font_default" + app:drawableTint="?attr/primaryTextColor" /> - <TextView + <androidx.appcompat.widget.AppCompatTextView android:id="@+id/comments_type_text_view_search_sort_type_bottom_sheet_fragment" android:layout_width="match_parent" android:layout_height="wrap_content" - android:text="@string/sort_comments" - android:textColor="?attr/primaryTextColor" - android:textSize="?attr/font_default" + android:background="?attr/selectableItemBackground" + android:clickable="true" + android:drawableStart="@drawable/ic_comment_toolbar_24dp" + android:drawablePadding="48dp" + android:focusable="true" android:fontFamily="?attr/font_family" - android:paddingTop="16dp" - android:paddingBottom="16dp" android:paddingStart="32dp" + android:paddingTop="16dp" android:paddingEnd="32dp" - android:clickable="true" - android:focusable="true" - android:background="?attr/selectableItemBackground" /> + android:paddingBottom="16dp" + android:text="@string/sort_comments" + android:textColor="?attr/primaryTextColor" + android:textSize="?attr/font_default" + app:drawableTint="?attr/primaryTextColor" /> </LinearLayout> -</androidx.core.widget.NestedScrollView>
\ No newline at end of file +</androidx.core.widget.NestedScrollView> diff --git a/app/src/main/res/layout/fragment_sort_type_bottom_sheet.xml b/app/src/main/res/layout/fragment_sort_type_bottom_sheet.xml index d8a62445..d5c9e34d 100644 --- a/app/src/main/res/layout/fragment_sort_type_bottom_sheet.xml +++ b/app/src/main/res/layout/fragment_sort_type_bottom_sheet.xml @@ -1,127 +1,149 @@ <?xml version="1.0" encoding="utf-8"?> <androidx.core.widget.NestedScrollView 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="wrap_content" - android:paddingBottom="8dp" - android:overScrollMode="never"> + android:overScrollMode="never" + android:paddingBottom="8dp"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> - <TextView + <androidx.appcompat.widget.AppCompatTextView android:id="@+id/best_type_text_view_sort_type_bottom_sheet_fragment" android:layout_width="match_parent" android:layout_height="wrap_content" - android:text="@string/sort_best" - android:textColor="?attr/primaryTextColor" - android:textSize="?attr/font_default" + android:background="?attr/selectableItemBackground" + android:clickable="true" + android:drawableStart="@drawable/ic_best_24" + android:drawablePadding="48dp" + android:focusable="true" android:fontFamily="?attr/font_family" - android:paddingTop="16dp" - android:paddingBottom="16dp" android:paddingStart="32dp" + android:paddingTop="16dp" android:paddingEnd="32dp" - android:clickable="true" - android:focusable="true" - android:background="?attr/selectableItemBackground" /> + android:paddingBottom="16dp" + android:text="@string/sort_best" + android:textColor="?attr/primaryTextColor" + android:textSize="?attr/font_default" + app:drawableTint="?attr/primaryTextColor" /> - <TextView + <androidx.appcompat.widget.AppCompatTextView android:id="@+id/hot_type_text_view_sort_type_bottom_sheet_fragment" android:layout_width="match_parent" android:layout_height="wrap_content" - android:text="@string/sort_hot" - android:textColor="?attr/primaryTextColor" - android:textSize="?attr/font_default" + android:background="?attr/selectableItemBackground" + android:clickable="true" + android:drawableStart="@drawable/ic_hot_24" + android:drawablePadding="48dp" + android:focusable="true" android:fontFamily="?attr/font_family" - android:paddingTop="16dp" - android:paddingBottom="16dp" android:paddingStart="32dp" + android:paddingTop="16dp" android:paddingEnd="32dp" - android:clickable="true" - android:focusable="true" - android:background="?attr/selectableItemBackground" /> + android:paddingBottom="16dp" + android:text="@string/sort_hot" + android:textColor="?attr/primaryTextColor" + android:textSize="?attr/font_default" + app:drawableTint="?attr/primaryTextColor" /> - <TextView + <androidx.appcompat.widget.AppCompatTextView android:id="@+id/new_type_text_view_sort_type_bottom_sheet_fragment" android:layout_width="match_parent" android:layout_height="wrap_content" - android:text="@string/sort_new" - android:textColor="?attr/primaryTextColor" - android:textSize="?attr/font_default" + android:background="?attr/selectableItemBackground" + android:clickable="true" + android:drawableStart="@drawable/ic_new_24" + android:drawablePadding="48dp" + android:focusable="true" android:fontFamily="?attr/font_family" - android:paddingTop="16dp" - android:paddingBottom="16dp" android:paddingStart="32dp" + android:paddingTop="16dp" android:paddingEnd="32dp" - android:clickable="true" - android:focusable="true" - android:background="?attr/selectableItemBackground" /> + android:paddingBottom="16dp" + android:text="@string/sort_new" + android:textColor="?attr/primaryTextColor" + android:textSize="?attr/font_default" + app:drawableTint="?attr/primaryTextColor" /> - <TextView + <androidx.appcompat.widget.AppCompatTextView android:id="@+id/random_type_text_view_sort_type_bottom_sheet_fragment" android:layout_width="match_parent" android:layout_height="wrap_content" - android:text="@string/sort_random" - android:textColor="?attr/primaryTextColor" - android:textSize="?attr/font_default" + android:background="?attr/selectableItemBackground" + android:clickable="true" + android:drawableStart="@drawable/ic_random_24" + android:drawablePadding="48dp" + android:focusable="true" android:fontFamily="?attr/font_family" - android:paddingTop="16dp" - android:paddingBottom="16dp" android:paddingStart="32dp" + android:paddingTop="16dp" android:paddingEnd="32dp" - android:clickable="true" - android:focusable="true" - android:background="?attr/selectableItemBackground" /> + android:paddingBottom="16dp" + android:text="@string/sort_random" + android:textColor="?attr/primaryTextColor" + android:textSize="?attr/font_default" + app:drawableTint="?attr/primaryTextColor" /> - <TextView + <androidx.appcompat.widget.AppCompatTextView android:id="@+id/rising_type_text_view_sort_type_bottom_sheet_fragment" android:layout_width="match_parent" android:layout_height="wrap_content" - android:text="@string/sort_rising" - android:textColor="?attr/primaryTextColor" - android:textSize="?attr/font_default" + android:background="?attr/selectableItemBackground" + android:clickable="true" + android:drawableStart="@drawable/ic_rising_24" + android:drawablePadding="48dp" + android:focusable="true" android:fontFamily="?attr/font_family" - android:paddingTop="16dp" - android:paddingBottom="16dp" android:paddingStart="32dp" + android:paddingTop="16dp" android:paddingEnd="32dp" - android:clickable="true" - android:focusable="true" - android:background="?attr/selectableItemBackground" /> + android:paddingBottom="16dp" + android:text="@string/sort_rising" + android:textColor="?attr/primaryTextColor" + android:textSize="?attr/font_default" + app:drawableTint="?attr/primaryTextColor" /> - <TextView + <androidx.appcompat.widget.AppCompatTextView android:id="@+id/top_type_text_view_sort_type_bottom_sheet_fragment" android:layout_width="match_parent" android:layout_height="wrap_content" - android:text="@string/sort_top" - android:textColor="?attr/primaryTextColor" - android:textSize="?attr/font_default" + android:background="?attr/selectableItemBackground" + android:clickable="true" + android:drawableStart="@drawable/ic_top_24" + android:drawablePadding="48dp" + android:focusable="true" android:fontFamily="?attr/font_family" - android:paddingTop="16dp" - android:paddingBottom="16dp" android:paddingStart="32dp" + android:paddingTop="16dp" android:paddingEnd="32dp" - android:clickable="true" - android:focusable="true" - android:background="?attr/selectableItemBackground" /> + android:paddingBottom="16dp" + android:text="@string/sort_top" + android:textColor="?attr/primaryTextColor" + android:textSize="?attr/font_default" + app:drawableTint="?attr/primaryTextColor" /> - <TextView + <androidx.appcompat.widget.AppCompatTextView android:id="@+id/controversial_type_text_view_sort_type_bottom_sheet_fragment" android:layout_width="match_parent" android:layout_height="wrap_content" - android:text="@string/sort_controversial" - android:textColor="?attr/primaryTextColor" - android:textSize="?attr/font_default" + android:background="?attr/selectableItemBackground" + android:clickable="true" + android:drawableStart="@drawable/ic_controversial_24" + android:drawablePadding="48dp" + android:focusable="true" android:fontFamily="?attr/font_family" - android:paddingTop="16dp" - android:paddingBottom="16dp" android:paddingStart="32dp" + android:paddingTop="16dp" android:paddingEnd="32dp" - android:clickable="true" - android:focusable="true" - android:background="?attr/selectableItemBackground" /> + android:paddingBottom="16dp" + android:text="@string/sort_controversial" + android:textColor="?attr/primaryTextColor" + android:textSize="?attr/font_default" + app:drawableTint="?attr/primaryTextColor" /> </LinearLayout> -</androidx.core.widget.NestedScrollView>
\ No newline at end of file +</androidx.core.widget.NestedScrollView> diff --git a/app/src/main/res/layout/fragment_user_thing_sort_type_bottom_sheet.xml b/app/src/main/res/layout/fragment_user_thing_sort_type_bottom_sheet.xml index 8abaf5ff..17056053 100644 --- a/app/src/main/res/layout/fragment_user_thing_sort_type_bottom_sheet.xml +++ b/app/src/main/res/layout/fragment_user_thing_sort_type_bottom_sheet.xml @@ -1,71 +1,85 @@ <?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" + xmlns:app="http://schemas.android.com/apk/res-auto" + android:layout_width="match_parent" android:layout_height="match_parent" + android:orientation="vertical" android:paddingBottom="8dp"> - <TextView + <androidx.appcompat.widget.AppCompatTextView android:id="@+id/new_type_text_view_user_thing_sort_type_bottom_sheet_fragment" android:layout_width="match_parent" android:layout_height="wrap_content" - android:text="@string/sort_new" - android:textColor="?attr/primaryTextColor" - android:textSize="?attr/font_default" + android:background="?attr/selectableItemBackground" + android:clickable="true" + android:drawableStart="@drawable/ic_new_24" + android:drawablePadding="48dp" + android:focusable="true" android:fontFamily="?attr/font_family" - android:paddingTop="16dp" - android:paddingBottom="16dp" android:paddingStart="32dp" + android:paddingTop="16dp" android:paddingEnd="32dp" - android:clickable="true" - android:focusable="true" - android:background="?attr/selectableItemBackground" /> + android:paddingBottom="16dp" + android:text="@string/sort_new" + android:textColor="?attr/primaryTextColor" + android:textSize="?attr/font_default" + app:drawableTint="?attr/primaryTextColor" /> - <TextView + <androidx.appcompat.widget.AppCompatTextView android:id="@+id/hot_type_text_view_user_thing_sort_type_bottom_sheet_fragment" android:layout_width="match_parent" android:layout_height="wrap_content" - android:text="@string/sort_hot" - android:textColor="?attr/primaryTextColor" - android:textSize="?attr/font_default" + android:background="?attr/selectableItemBackground" + android:clickable="true" + android:drawableStart="@drawable/ic_hot_24" + android:drawablePadding="48dp" + android:focusable="true" android:fontFamily="?attr/font_family" - android:paddingTop="16dp" - android:paddingBottom="16dp" android:paddingStart="32dp" + android:paddingTop="16dp" android:paddingEnd="32dp" - android:clickable="true" - android:focusable="true" - android:background="?attr/selectableItemBackground" /> + android:paddingBottom="16dp" + android:text="@string/sort_hot" + android:textColor="?attr/primaryTextColor" + android:textSize="?attr/font_default" + app:drawableTint="?attr/primaryTextColor" /> - <TextView + <androidx.appcompat.widget.AppCompatTextView android:id="@+id/top_type_text_view_user_thing_sort_type_bottom_sheet_fragment" android:layout_width="match_parent" android:layout_height="wrap_content" - android:text="@string/sort_top" - android:textColor="?attr/primaryTextColor" - android:textSize="?attr/font_default" + android:background="?attr/selectableItemBackground" + android:clickable="true" + android:drawableStart="@drawable/ic_top_24" + android:drawablePadding="48dp" + android:focusable="true" android:fontFamily="?attr/font_family" - android:paddingTop="16dp" - android:paddingBottom="16dp" android:paddingStart="32dp" + android:paddingTop="16dp" android:paddingEnd="32dp" - android:clickable="true" - android:focusable="true" - android:background="?attr/selectableItemBackground" /> + android:paddingBottom="16dp" + android:text="@string/sort_top" + android:textColor="?attr/primaryTextColor" + android:textSize="?attr/font_default" + app:drawableTint="?attr/primaryTextColor" /> - <TextView + <androidx.appcompat.widget.AppCompatTextView android:id="@+id/controversial_type_text_view_user_thing_sort_type_bottom_sheet_fragment" android:layout_width="match_parent" android:layout_height="wrap_content" - android:text="@string/sort_controversial" - android:textColor="?attr/primaryTextColor" - android:textSize="?attr/font_default" + android:background="?attr/selectableItemBackground" + android:clickable="true" + android:drawableStart="@drawable/ic_controversial_24" + android:drawablePadding="48dp" + android:focusable="true" android:fontFamily="?attr/font_family" - android:paddingTop="16dp" - android:paddingBottom="16dp" android:paddingStart="32dp" + android:paddingTop="16dp" android:paddingEnd="32dp" - android:clickable="true" - android:focusable="true" - android:background="?attr/selectableItemBackground" /> + android:paddingBottom="16dp" + android:text="@string/sort_controversial" + android:textColor="?attr/primaryTextColor" + android:textSize="?attr/font_default" + app:drawableTint="?attr/primaryTextColor" /> -</LinearLayout>
\ No newline at end of file +</LinearLayout> diff --git a/app/src/main/res/layout/item_post_detail_no_preview_link.xml b/app/src/main/res/layout/item_post_detail_no_preview_link.xml index 7b1f1eb7..f294801a 100644 --- a/app/src/main/res/layout/item_post_detail_no_preview_link.xml +++ b/app/src/main/res/layout/item_post_detail_no_preview_link.xml @@ -108,7 +108,7 @@ android:id="@+id/content_markdown_view_item_post_detail_no_preview_link" android:layout_width="match_parent" android:layout_height="match_parent" - android:layout_marginTop="16dp" + android:layout_marginTop="8dp" android:layout_marginStart="8dp" android:layout_marginEnd="8dp" android:visibility="gone" /> diff --git a/app/src/main/res/layout/item_post_detail_text.xml b/app/src/main/res/layout/item_post_detail_text.xml index de939064..7828687d 100644 --- a/app/src/main/res/layout/item_post_detail_text.xml +++ b/app/src/main/res/layout/item_post_detail_text.xml @@ -108,7 +108,7 @@ android:id="@+id/content_markdown_view_item_post_detail_text" android:layout_width="match_parent" android:layout_height="match_parent" - android:layout_marginTop="16dp" + android:layout_marginTop="8dp" android:layout_marginStart="8dp" android:layout_marginEnd="8dp" android:visibility="gone" /> diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index 878bf61b..3efd7c75 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -1,5 +1,7 @@ <resources> <string-array name="settings_notification_interval"> + <item>15 minutes</item> + <item>30 minutes</item> <item>1 hour</item> <item>2 hours</item> <item>3 hours</item> @@ -10,6 +12,8 @@ </string-array> <string-array name="settings_notification_interval_values"> + <item>15</item> + <item>30</item> <item>1</item> <item>2</item> <item>3</item> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 53f28bc9..1eecbe16 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -313,6 +313,7 @@ <string name="label_account">Account</string> <string name="label_post">Post</string> + <string name="label_preferences">Preferences</string> <string name="account_switched">Account Switched. So all other pages are gone.</string> @@ -328,7 +329,9 @@ <string name="settings_interface_title">Interface</string> <string name="settings_gestures_and_buttons_title">Gestures & Buttons</string> <string name="settings_open_link_in_app_title">Open Link In App</string> + <string name="settigns_video_title">Video</string> <string name="settings_video_autoplay_title">Video Autoplay</string> + <string name="settings_mute_autoplaying_videos_title">Mute Autoplaying Videos</string> <string name="settings_autoplay_nsfw_videos_title">Autoplay NSFW Videos</string> <string name="settings_immersive_interface_title">Immersive Interface</string> <string name="settings_immersive_interface_ignore_nav_bar_title">Ignore Navigation Bar in Immersive Interface</string> @@ -341,6 +344,7 @@ <string name="settings_volume_keys_navigate_comments_title">Use Volume Keys to Navigate Comments in Posts</string> <string name="settings_volume_keys_navigate_posts_title">Use Volume Keys to Navigate Posts</string> <string name="settings_mute_video_title">Mute Video</string> + <string name="settings_automatically_try_redgifs_title">Automatically Try Accessing Redgifs if Videos on Gfycat are Removed.</string> <string name="settings_confirm_to_exit">Confirm to Exit</string> <string name="settings_show_top_level_comments_first_title">Show Top-level Comments First</string> <string name="settings_show_comment_divider_title">Show Comment Divider</string> @@ -387,10 +391,12 @@ <string name="settings_credits_crosspost_icon_summary">Icon made by Freepik from www.flaticon.com</string> <string name="settings_credits_thumbtack_icon_title">Thumbtack Icon</string> <string name="settings_credits_thumbtack_icon_summary">Icon made by Freepik from www.flaticon.com</string> + <string name="settings_credits_best_rocket_icon_title">Rocket Icon</string> + <string name="settings_credits_best_rocket_icon_summary">Icon made by Freepik from www.flaticon.com</string> <string name="settings_credits_material_icons_title">Material Icons</string> <string name="settings_open_source_title">Open Source</string> <string name="settings_open_source_summary">Star it on Github if you like this app</string> - <string name="settings_rate_title">Rate in Google Play</string> + <string name="settings_rate_title">Rate on Google Play</string> <string name="settings_rate_summary">Give me a 5-star rating and I will be really happy</string> <string name="settings_f_droid_title">F-Droid</string> <string name="settings_f_droid_summary">It\'s available in IzzyOnDroid, an F-Droid Repository</string> @@ -402,6 +408,8 @@ <string name="settings_subreddit_summary">r/Infinity_For_Reddit</string> <string name="settings_share_title">Share</string> <string name="settings_share_summary">Share this app to other people if you enjoy it</string> + <string name="settings_version_title">Infinity For Reddit</string> + <string name="settings_version_summary">Version %s</string> <string name="settings_category_customization_title">Customization</string> <string name="settings_customize_light_theme_title">Light Theme</string> <string name="settings_customize_dark_theme_title">Dark Theme</string> @@ -425,6 +433,7 @@ <string name="settings_tab_subreddit_name">Subreddit Name (Without r/ prefix)</string> <string name="settings_tab_multi_reddit_name">MultiReddit Name (/user/yourusername/m/yourmultiredditname)</string> <string name="settings_tab_username">Username (Without u/ prefix)</string> + <string name="no_developer_easter_egg">There\'s no developer options here</string> <string name="no_link_available">Cannot get the link</string> @@ -780,7 +789,7 @@ <string name="set_to_both">Set to Both</string> <string name="default_font_font_preview">Default</string> - <!-- TODO: Remove or change this placeholder text --> - <string name="hello_blank_fragment">Hello blank fragment</string> + + <string name="load_video_in_redgifs">Try loading the video on Redgifs</string> </resources> diff --git a/app/src/main/res/xml/about_preferences.xml b/app/src/main/res/xml/about_preferences.xml index 2772f2ed..a73f9aaa 100644 --- a/app/src/main/res/xml/about_preferences.xml +++ b/app/src/main/res/xml/about_preferences.xml @@ -45,4 +45,9 @@ app:title="@string/settings_share_title" app:summary="@string/settings_share_summary" /> -</PreferenceScreen>
\ No newline at end of file + <Preference + android:key="version" + app:title="@string/settings_version_title" + app:summary="@string/settings_version_summary" /> + +</PreferenceScreen> diff --git a/app/src/main/res/xml/autoplay_preferences.xml b/app/src/main/res/xml/autoplay_preferences.xml deleted file mode 100644 index 6cb07dd9..00000000 --- a/app/src/main/res/xml/autoplay_preferences.xml +++ /dev/null @@ -1,18 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:app="http://schemas.android.com/apk/res-auto"> - - <ListPreference - app:defaultValue="0" - android:entries="@array/settings_video_autoplay" - app:entryValues="@array/settings_video_autoplay_values" - app:key="video_autoplay" - app:title="@string/settings_video_autoplay_title" - app:useSimpleSummaryProvider="true" /> - - <SwitchPreference - app:defaultValue="true" - app:key="autoplay_nsfw_videos" - app:title="@string/settings_autoplay_nsfw_videos_title" /> - -</PreferenceScreen>
\ No newline at end of file diff --git a/app/src/main/res/xml/credits_preferences.xml b/app/src/main/res/xml/credits_preferences.xml index e630422b..8e622332 100644 --- a/app/src/main/res/xml/credits_preferences.xml +++ b/app/src/main/res/xml/credits_preferences.xml @@ -33,7 +33,12 @@ android:summary="@string/settings_credits_thumbtack_icon_summary" /> <Preference + android:key="best_rocket_icon" + app:title="@string/settings_credits_best_rocket_icon_title" + android:summary="@string/settings_credits_best_rocket_icon_summary" /> + + <Preference android:key="material_icons" app:title="@string/settings_credits_material_icons_title"/> -</PreferenceScreen>
\ No newline at end of file +</PreferenceScreen> diff --git a/app/src/main/res/xml/main_preferences.xml b/app/src/main/res/xml/main_preferences.xml index f332a49c..c15bfee4 100644 --- a/app/src/main/res/xml/main_preferences.xml +++ b/app/src/main/res/xml/main_preferences.xml @@ -29,14 +29,9 @@ app:title="@string/settings_open_link_in_app_title" /> <Preference - app:title="@string/settings_video_autoplay_title" - app:fragment="ml.docilealligator.infinityforreddit.Settings.AutoplayPreferenceFragment" /> - - <SwitchPreference - app:defaultValue="false" - app:key="mute_video" - app:icon="@drawable/ic_mute_preferences_24dp" - app:title="@string/settings_mute_video_title" /> + app:title="@string/settigns_video_title" + android:icon="@drawable/ic_outline_video_24dp" + app:fragment="ml.docilealligator.infinityforreddit.Settings.VideoPreferenceFragment" /> <SwitchPreference app:defaultValue="false" diff --git a/app/src/main/res/xml/video_preferences.xml b/app/src/main/res/xml/video_preferences.xml new file mode 100644 index 00000000..bb690347 --- /dev/null +++ b/app/src/main/res/xml/video_preferences.xml @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="utf-8"?> +<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto"> + + <SwitchPreference + app:defaultValue="false" + app:key="mute_video" + app:icon="@drawable/ic_mute_preferences_24dp" + app:title="@string/settings_mute_video_title" /> + + <SwitchPreference + app:defaultValue="true" + app:key="automatically_try_redgifs" + app:title="@string/settings_automatically_try_redgifs_title" /> + + <PreferenceCategory + app:title="@string/settings_video_autoplay_title" /> + + <ListPreference + app:defaultValue="0" + android:entries="@array/settings_video_autoplay" + app:entryValues="@array/settings_video_autoplay_values" + app:key="video_autoplay" + app:title="@string/settings_video_autoplay_title" + app:useSimpleSummaryProvider="true" /> + + <SwitchPreference + app:defaultValue="true" + app:key="mute_autoplaying_videos" + app:icon="@drawable/ic_mute_preferences_24dp" + app:title="@string/settings_mute_autoplaying_videos_title" /> + + <SwitchPreference + app:defaultValue="true" + app:key="autoplay_nsfw_videos" + app:title="@string/settings_autoplay_nsfw_videos_title" /> + +</PreferenceScreen>
\ No newline at end of file |