Fix gif too small in ViewImageOrGifActivity. Hide immersive interface entry if the device has Android version lower than 8.0.

This commit is contained in:
Alex Ning 2020-07-15 10:42:46 +08:00
parent c97120528b
commit a9ba807cf4
10 changed files with 30 additions and 80 deletions

View File

@ -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

View File

@ -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);

View File

@ -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);

View File

@ -1,6 +1,5 @@
package ml.docilealligator.infinityforreddit.Settings;
import android.os.Build;
import android.os.Bundle;
import androidx.preference.PreferenceFragmentCompat;
@ -22,8 +21,6 @@ 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);
@ -44,10 +41,6 @@ public class ImmersiveInterfacePreferenceFragment extends PreferenceFragmentComp
EventBus.getDefault().post(new RecreateActivityEvent());
return true;
});
} else {
immersiveInterfaceSwitch.setVisible(false);
immersiveInterfaceIgnoreNavBarSwitch.setVisible(false);
}
}
}
}

View File

@ -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());

View File

@ -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";

View File

@ -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"

View File

@ -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>

View File

@ -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>

View File

@ -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"