Fix caption shown under the navbar in ViewRedditGalleryImageOrGifFragment.

This commit is contained in:
Docile-Alligator 2022-08-13 12:25:04 +10:00
parent a12e65aa0e
commit e3f9d31a34
4 changed files with 37 additions and 23 deletions

View File

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

View File

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

View File

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

View File

@ -45,8 +45,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:backgroundTint="#80000000"
android:visibility="gone">
app:paddingBottomSystemWindowInsets="false"
android:backgroundTint="#80000000">
<LinearLayout
android:layout_width="match_parent"
@ -93,7 +93,8 @@
<LinearLayout
android:id="@+id/bottom_app_bar_menu_view_reddit_gallery_image_or_gif_fragment"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:visibility="gone">
<TextView
android:id="@+id/title_text_view_view_reddit_gallery_image_or_gif_fragment"