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 | |
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.
10 files changed, 30 insertions, 80 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"; diff --git a/app/src/main/res/layout/activity_view_image_or_gif.xml b/app/src/main/res/layout/activity_view_image_or_gif.xml index 21dd1f4b..9d3a0b58 100644 --- a/app/src/main/res/layout/activity_view_image_or_gif.xml +++ b/app/src/main/res/layout/activity_view_image_or_gif.xml @@ -19,8 +19,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" app:optimizeDisplay="true" - app:tapToRetry="false" - app:initScaleType="centerInside" /> + app:tapToRetry="false"/> <LinearLayout android:id="@+id/load_image_error_linear_layout_view_image_or_gif_activity" diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index eb0e5557..24d7639d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -352,6 +352,7 @@ <string name="settings_start_autoplay_visible_area_offset_landscape_title">Autoplay Videos Visible Area Offset (Landscape)</string> <string name="settings_start_autoplay_visible_area_offset_landscape_summary">Start autoplaying videos when %1$d%% of them are visible</string> <string name="settings_immersive_interface_title">Immersive Interface</string> + <string name="settings_immersive_interface_summary">Does Not Apply to All Pages</string> <string name="settings_immersive_interface_ignore_nav_bar_title">Ignore Navigation Bar in Immersive Interface</string> <string name="settings_immersive_interface_ignore_nav_bar_summary">Prevent the Bottom Navigation Bar Having Extra Padding</string> <string name="settings_customize_tabs_in_main_page_title">Customize Tabs in Main Page</string> @@ -378,7 +379,7 @@ <string name="settings_show_thumbnail_on_the_left_in_compact_layout">Show Thumbnail on the Left in Compact Layout</string> <string name="settings_swap_tap_and_long_title">Swap Tap and Long Press in Comments</string> <string name="settings_swipe_to_go_back_title">Swipe Right to Go Back</string> - <string name="settings_swipe_to_go_back_summary">Does not apply to all pages</string> + <string name="settings_swipe_to_go_back_summary">Does Not Apply to All Pages</string> <string name="settings_lock_jump_to_next_top_level_comment_button_title">Lock Jump to Next Top-level Comment Button</string> <string name="settings_lock_bottom_app_bar_title">Lock Bottom Navigation Bar</string> <string name="settings_swipe_up_to_hide_jump_to_next_top_level_comment_button_title">Swipe Up to Hide Jump to Next Top-level Comment Button</string> diff --git a/app/src/main/res/xml/immersive_interface_preferences.xml b/app/src/main/res/xml/immersive_interface_preferences.xml index 962faa10..6cd31d84 100644 --- a/app/src/main/res/xml/immersive_interface_preferences.xml +++ b/app/src/main/res/xml/immersive_interface_preferences.xml @@ -5,13 +5,12 @@ app:defaultValue="true" app:key="immersive_interface" app:title="@string/settings_immersive_interface_title" - app:isPreferenceVisible="false" /> + app:summary="@string/settings_immersive_interface_summary" /> <SwitchPreference app:defaultValue="false" app:key="immersive_interface_ignore_nav_bar" app:title="@string/settings_immersive_interface_ignore_nav_bar_title" - app:summary="@string/settings_immersive_interface_ignore_nav_bar_summary" - app:isPreferenceVisible="false" /> + app:summary="@string/settings_immersive_interface_ignore_nav_bar_summary" /> </PreferenceScreen>
\ No newline at end of file diff --git a/app/src/main/res/xml/interface_preference.xml b/app/src/main/res/xml/interface_preference.xml index e391a21c..8ad53611 100644 --- a/app/src/main/res/xml/interface_preference.xml +++ b/app/src/main/res/xml/interface_preference.xml @@ -8,8 +8,10 @@ app:fragment="ml.docilealligator.infinityforreddit.Settings.FontPreferenceFragment" /> <Preference + app:key="immersive_interface_entry" app:title="@string/settings_immersive_interface_title" - app:fragment="ml.docilealligator.infinityforreddit.Settings.ImmersiveInterfacePreferenceFragment" /> + app:fragment="ml.docilealligator.infinityforreddit.Settings.ImmersiveInterfacePreferenceFragment" + app:isPreferenceVisible="false" /> <Preference app:title="@string/settings_customize_tabs_in_main_page_title" |