diff options
author | Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> | 2022-08-13 02:25:04 +0000 |
---|---|---|
committer | Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> | 2022-08-13 02:25:04 +0000 |
commit | e3f9d31a3404eccee01b6deb53c8d166f1557892 (patch) | |
tree | 0b0f5ab13cb7a1ab7717c451adfb97700ea1ab06 /app/src/main/java | |
parent | a12e65aa0ea130d43b4f899b5cfdbb81dbce6ec1 (diff) | |
download | infinity-for-reddit-e3f9d31a3404eccee01b6deb53c8d166f1557892.tar infinity-for-reddit-e3f9d31a3404eccee01b6deb53c8d166f1557892.tar.gz infinity-for-reddit-e3f9d31a3404eccee01b6deb53c8d166f1557892.tar.bz2 infinity-for-reddit-e3f9d31a3404eccee01b6deb53c8d166f1557892.tar.lz infinity-for-reddit-e3f9d31a3404eccee01b6deb53c8d166f1557892.tar.xz infinity-for-reddit-e3f9d31a3404eccee01b6deb53c8d166f1557892.tar.zst infinity-for-reddit-e3f9d31a3404eccee01b6deb53c8d166f1557892.zip |
Fix caption shown under the navbar in ViewRedditGalleryImageOrGifFragment.
Diffstat (limited to 'app/src/main/java')
3 files changed, 33 insertions, 20 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewRedditGalleryActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewRedditGalleryActivity.java index 67744239..1c52da84 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewRedditGalleryActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewRedditGalleryActivity.java @@ -76,6 +76,7 @@ public class ViewRedditGalleryActivity extends AppCompatActivity implements SetA private String subredditName; private boolean isNsfw; private boolean useBottomAppBar; + private boolean isActionBarHidden = false; @Override protected void onCreate(Bundle savedInstanceState) { @@ -279,6 +280,14 @@ public class ViewRedditGalleryActivity extends AppCompatActivity implements SetA this.typeface = typeface; } + public boolean isActionBarHidden() { + return isActionBarHidden; + } + + public void setActionBarHidden(boolean isActionBarHidden) { + this.isActionBarHidden = isActionBarHidden; + } + private class SectionsPagerAdapter extends FragmentStatePagerAdapter { SectionsPagerAdapter(@NonNull FragmentManager fm) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/customviews/AspectRatioGifImageView.java b/app/src/main/java/ml/docilealligator/infinityforreddit/customviews/AspectRatioGifImageView.java index 6e6c1059..5097849f 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/customviews/AspectRatioGifImageView.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/customviews/AspectRatioGifImageView.java @@ -25,7 +25,7 @@ public class AspectRatioGifImageView extends GifImageView { } public final void setRatio(float var1) { - if (this.ratio != var1) { + if (Math.abs(this.ratio - var1) > 0.0001) { this.ratio = var1; requestLayout(); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRedditGalleryImageOrGifFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRedditGalleryImageOrGifFragment.java index e90c277f..fe9dac8b 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRedditGalleryImageOrGifFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRedditGalleryImageOrGifFragment.java @@ -112,7 +112,6 @@ public class ViewRedditGalleryImageOrGifFragment extends Fragment { private String subredditName; private boolean isNsfw; private boolean isDownloading = false; - private boolean isActionBarHidden = false; private boolean isUseBottomCaption = false; private boolean isFallback = false; @@ -215,20 +214,13 @@ public class ViewRedditGalleryImageOrGifFragment extends Fragment { }); loadImage(); - activity.getWindow().getDecorView().setSystemUiVisibility( - View.SYSTEM_UI_FLAG_LAYOUT_STABLE - | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION - | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); imageView.setOnClickListener(view -> { - if (isActionBarHidden) { - activity.getWindow().getDecorView().setSystemUiVisibility( - View.SYSTEM_UI_FLAG_LAYOUT_STABLE - | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION - | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); - isActionBarHidden = false; - if (activity.isUseBottomAppBar() || isUseBottomCaption) { - bottomAppBar.setVisibility(View.VISIBLE); + if (activity.isActionBarHidden()) { + activity.getWindow().getDecorView().setSystemUiVisibility(0); + activity.setActionBarHidden(false); + if (activity.isUseBottomAppBar()) { + bottomAppBarMenu.setVisibility(View.VISIBLE); } } else { hideAppBar(); @@ -244,7 +236,7 @@ public class ViewRedditGalleryImageOrGifFragment extends Fragment { }); if (activity.isUseBottomAppBar()) { - bottomAppBar.setVisibility(View.VISIBLE); + bottomAppBarMenu.setVisibility(View.VISIBLE); if (media.mediaType == Post.Gallery.TYPE_GIF) { titleTextView.setText(getString(R.string.view_reddit_gallery_activity_gif_label, getArguments().getInt(EXTRA_INDEX) + 1, getArguments().getInt(EXTRA_MEDIA_COUNT))); @@ -279,7 +271,6 @@ public class ViewRedditGalleryImageOrGifFragment extends Fragment { isUseBottomCaption = true; if (!activity.isUseBottomAppBar()) { - bottomAppBar.setVisibility(View.VISIBLE); bottomAppBarMenu.setVisibility(View.GONE); } @@ -339,9 +330,9 @@ public class ViewRedditGalleryImageOrGifFragment extends Fragment { | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE); - isActionBarHidden = true; - if (activity.isUseBottomAppBar() || isUseBottomCaption) { - bottomAppBar.setVisibility(View.GONE); + activity.setActionBarHidden(true); + if (activity.isUseBottomAppBar()) { + bottomAppBarMenu.setVisibility(View.GONE); } } @@ -382,7 +373,8 @@ public class ViewRedditGalleryImageOrGifFragment extends Fragment { } return true; } else if (itemId == R.id.action_set_wallpaper_view_reddit_gallery_image_or_gif_fragment) { - setWallpaper(); + //setWallpaper(); + Toast.makeText(activity, Integer.toString(activity.getWindow().getDecorView().getSystemUiVisibility()), Toast.LENGTH_SHORT).show(); return true; } @@ -542,6 +534,18 @@ public class ViewRedditGalleryImageOrGifFragment extends Fragment { if (ssiv == null || !ssiv.hasImage()) { loadImage(); } + + if (activity.isActionBarHidden()) { + activity.getWindow().getDecorView().setSystemUiVisibility( + View.SYSTEM_UI_FLAG_LAYOUT_STABLE + | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN + | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_FULLSCREEN + | View.SYSTEM_UI_FLAG_IMMERSIVE); + } else { + activity.getWindow().getDecorView().setSystemUiVisibility(0); + } } @Override |