diff options
author | Alex Ning <chineseperson5@gmail.com> | 2020-07-15 02:42:46 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2020-07-15 02:42:46 +0000 |
commit | a9ba807cf42632b1744b5af5b9e1081575fecae5 (patch) | |
tree | 4093f8fe5e0442d6431c9ee3946ad779b0b17d9a /app/src/main/java/ml | |
parent | c97120528bd158c7ff430846ac04acfa74f78058 (diff) | |
download | infinity-for-reddit-a9ba807cf42632b1744b5af5b9e1081575fecae5.tar infinity-for-reddit-a9ba807cf42632b1744b5af5b9e1081575fecae5.tar.gz infinity-for-reddit-a9ba807cf42632b1744b5af5b9e1081575fecae5.tar.bz2 infinity-for-reddit-a9ba807cf42632b1744b5af5b9e1081575fecae5.tar.lz infinity-for-reddit-a9ba807cf42632b1744b5af5b9e1081575fecae5.tar.xz infinity-for-reddit-a9ba807cf42632b1744b5af5b9e1081575fecae5.tar.zst infinity-for-reddit-a9ba807cf42632b1744b5af5b9e1081575fecae5.zip |
Fix gif too small in ViewImageOrGifActivity. Hide immersive interface entry if the device has Android version lower than 8.0.
Diffstat (limited to 'app/src/main/java/ml')
6 files changed, 22 insertions, 73 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImageOrGifActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImageOrGifActivity.java index dd2b0d1c..ad5e4fcc 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImageOrGifActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImageOrGifActivity.java @@ -77,8 +77,6 @@ public class ViewImageOrGifActivity extends AppCompatActivity implements SetAsWa public static final String FILE_NAME_KEY = "FNK"; public static final String POST_TITLE_KEY = "PTK"; private static final int PERMISSION_REQUEST_WRITE_EXTERNAL_STORAGE = 0; - /*@BindView(R.id.hauler_view_view_image_or_gif_activity) - HaulerView mHaulerView;*/ @BindView(R.id.progress_bar_view_image_or_gif_activity) ProgressBar mProgressBar; @BindView(R.id.image_view_view_image_or_gif_activity) @@ -259,61 +257,11 @@ public class ViewImageOrGifActivity extends AppCompatActivity implements SetAsWa } }); - /*if (isGif) { - gestureLayout.setVisibility(View.VISIBLE); - gestureLayout.getController().getSettings().setMaxZoom(10f).setDoubleTapZoom(2f).setPanEnabled(true); - mGifView.setOnClickListener(imageViewOnClickListener); - } else { - mImageView.setVisibility(View.VISIBLE); - mImageView.setOnClickListener(imageViewOnClickListener); - }*/ - loadImage(); } private void loadImage() { mImageView.showImage(Uri.parse(mImageUrl)); - /*if (isGif) { - glide.load(mImageUrl).listener(new RequestListener<Drawable>() { - @Override - public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) { - mProgressBar.setVisibility(View.GONE); - mLoadErrorLinearLayout.setVisibility(View.VISIBLE); - return false; - } - - @Override - public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) { - mProgressBar.setVisibility(View.GONE); - return false; - } - }).override(Target.SIZE_ORIGINAL).into(mGifView); - } else { - glide.asBitmap().load(mImageUrl).listener(new RequestListener<Bitmap>() { - @Override - public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Bitmap> target, boolean isFirstResource) { - mProgressBar.setVisibility(View.GONE); - mLoadErrorLinearLayout.setVisibility(View.VISIBLE); - return false; - } - - @Override - public boolean onResourceReady(Bitmap resource, Object model, Target<Bitmap> target, DataSource dataSource, boolean isFirstResource) { - mProgressBar.setVisibility(View.GONE); - return false; - } - }).override(Target.SIZE_ORIGINAL).into(new CustomTarget<Bitmap>() { - @Override - public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) { - mImageView.setImage(ImageSource.bitmap(resource)); - } - - @Override - public void onLoadCleared(@Nullable Drawable placeholder) { - - } - }); - }*/ } @Override 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 a7975e47..bbf36110 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java @@ -1248,7 +1248,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy if ((mPost.isNSFW() && mNeedBlurNsfw && !(mPost.getPostType() == Post.GIF_TYPE && mAutoplayNsfwVideos)) || (mPost.isSpoiler() && mNeedBlurSpoiler)) { imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10))).into(((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView); } else { - if (mImageViewWidth > mPost.getPreviewWidth() && mPost.getPostType() == Post.IMAGE_TYPE) { + if (mImageViewWidth > mPost.getPreviewWidth()) { imageRequestBuilder.override(Target.SIZE_ORIGINAL).into(((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView); } else { imageRequestBuilder.into(((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView); 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 d630f12a..835d8af1 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java @@ -875,7 +875,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10))) .into(((PostImageAndGifAutoplayViewHolder) holder).imageView); } else { - if (mImageViewWidth > post.getPreviewWidth() && post.getPostType() == Post.IMAGE_TYPE) { + if (mImageViewWidth > post.getPreviewWidth()) { imageRequestBuilder.override(Target.SIZE_ORIGINAL).into(((PostImageAndGifAutoplayViewHolder) holder).imageView); } else { imageRequestBuilder.into(((PostImageAndGifAutoplayViewHolder) holder).imageView); 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 c9f95e98..019f3593 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/ImmersiveInterfacePreferenceFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/ImmersiveInterfacePreferenceFragment.java @@ -1,6 +1,5 @@ package ml.docilealligator.infinityforreddit.Settings; -import android.os.Build; import android.os.Bundle; import androidx.preference.PreferenceFragmentCompat; @@ -22,32 +21,26 @@ public class ImmersiveInterfacePreferenceFragment extends PreferenceFragmentComp SwitchPreference immersiveInterfaceIgnoreNavBarSwitch = findPreference(SharedPreferencesUtils.IMMERSIVE_INTERFACE_IGNORE_NAV_BAR_KEY); if (immersiveInterfaceSwitch != null && immersiveInterfaceIgnoreNavBarSwitch != null) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - immersiveInterfaceSwitch.setVisible(true); - immersiveInterfaceSwitch.setOnPreferenceChangeListener((preference, newValue) -> { - if ((Boolean) newValue) { - immersiveInterfaceIgnoreNavBarSwitch.setVisible(true); - } else { - immersiveInterfaceIgnoreNavBarSwitch.setVisible(false); - } - EventBus.getDefault().post(new RecreateActivityEvent()); - return true; - }); - - if (immersiveInterfaceSwitch.isChecked()) { + immersiveInterfaceSwitch.setOnPreferenceChangeListener((preference, newValue) -> { + if ((Boolean) newValue) { immersiveInterfaceIgnoreNavBarSwitch.setVisible(true); } else { immersiveInterfaceIgnoreNavBarSwitch.setVisible(false); } + EventBus.getDefault().post(new RecreateActivityEvent()); + return true; + }); - immersiveInterfaceIgnoreNavBarSwitch.setOnPreferenceChangeListener((preference, newValue) -> { - EventBus.getDefault().post(new RecreateActivityEvent()); - return true; - }); + if (immersiveInterfaceSwitch.isChecked()) { + immersiveInterfaceIgnoreNavBarSwitch.setVisible(true); } else { - immersiveInterfaceSwitch.setVisible(false); immersiveInterfaceIgnoreNavBarSwitch.setVisible(false); } + + immersiveInterfaceIgnoreNavBarSwitch.setOnPreferenceChangeListener((preference, newValue) -> { + EventBus.getDefault().post(new RecreateActivityEvent()); + return true; + }); } } }
\ No newline at end of file diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/InterfacePreferenceFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/InterfacePreferenceFragment.java index c665478a..bec9cad8 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/InterfacePreferenceFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/InterfacePreferenceFragment.java @@ -1,9 +1,11 @@ package ml.docilealligator.infinityforreddit.Settings; +import android.os.Build; import android.os.Bundle; import androidx.preference.ListPreference; +import androidx.preference.Preference; import androidx.preference.PreferenceFragmentCompat; import androidx.preference.SwitchPreference; @@ -24,6 +26,7 @@ public class InterfacePreferenceFragment extends PreferenceFragmentCompat { public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { setPreferencesFromResource(R.xml.interface_preference, rootKey); + Preference immersiveInterfaceEntryPreference = findPreference(SharedPreferencesUtils.IMMERSIVE_INTERFACE_ENTRY_KEY); SwitchPreference bottomAppBarSwitch = findPreference(SharedPreferencesUtils.BOTTOM_APP_BAR_KEY); SwitchPreference voteButtonsOnTheRightSwitch = findPreference(SharedPreferencesUtils.VOTE_BUTTONS_ON_THE_RIGHT_KEY); ListPreference defaultPostLayoutSwitch = findPreference(SharedPreferencesUtils.DEFAULT_POST_LAYOUT_KEY); @@ -31,6 +34,10 @@ public class InterfacePreferenceFragment extends PreferenceFragmentCompat { SwitchPreference showThumbnailOnTheRightInCompactLayout = findPreference(SharedPreferencesUtils.SHOW_THUMBNAIL_ON_THE_LEFT_IN_COMPACT_LAYOUT); SwitchPreference showAbsoluteNumberOfVotes = findPreference(SharedPreferencesUtils.SHOW_ABSOLUTE_NUMBER_OF_VOTES); + if (immersiveInterfaceEntryPreference != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + immersiveInterfaceEntryPreference.setVisible(true); + } + if (bottomAppBarSwitch != null) { bottomAppBarSwitch.setOnPreferenceChangeListener((preference, newValue) -> { EventBus.getDefault().post(new RecreateActivityEvent()); 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 c4eba6f8..b473bc34 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java @@ -35,6 +35,7 @@ public class SharedPreferencesUtils { public static final String TITLE_FONT_FAMILY_KEY = "title_font_family"; public static final String CONTENT_FONT_FAMILY_KEY = "content_font_family"; public static final String AMOLED_DARK_KEY = "amoled_dark"; + public static final String IMMERSIVE_INTERFACE_ENTRY_KEY = "immersive_interface_entry"; public static final String IMMERSIVE_INTERFACE_KEY = "immersive_interface"; public static final String IMMERSIVE_INTERFACE_IGNORE_NAV_BAR_KEY = "immersive_interface_ignore_nav_bar"; public static final String BOTTOM_APP_BAR_KEY = "bottom_app_bar"; |