From 1eb1562dfd018fc46947558d925bb3f30efcc805 Mon Sep 17 00:00:00 2001 From: scria1000 <91804886+scria1000@users.noreply.github.com> Date: Sun, 28 Nov 2021 19:15:47 +0300 Subject: Adjust caption layout Set caption max length Set link ellipsis --- .../adapters/PostDetailRecyclerViewAdapter.java | 44 ++++++++++++---------- .../ViewRedditGalleryImageOrGifFragment.java | 40 +++++++++++++------- 2 files changed, 52 insertions(+), 32 deletions(-) (limited to 'app/src/main/java') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java index 5ab227a1..17bd2e8a 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java @@ -768,26 +768,9 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter previews) { Post.Preview preview; 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 97330c13..df3d88ae 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRedditGalleryImageOrGifFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRedditGalleryImageOrGifFragment.java @@ -201,20 +201,12 @@ public class ViewRedditGalleryImageOrGifFragment extends Fragment { bottomAppBar.setVisibility(View.VISIBLE); } } else { - 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); - isActionBarHidden = true; - if (activity.isUseBottomAppBar() || isUseBottomCaption) { - bottomAppBar.setVisibility(View.GONE); - } + hideAppBar(); } }); + captionLayout.setOnClickListener(view -> hideAppBar()); + errorLinearLayout.setOnClickListener(view -> { progressBar.setVisibility(View.VISIBLE); errorLinearLayout.setVisibility(View.GONE); @@ -268,6 +260,7 @@ public class ViewRedditGalleryImageOrGifFragment extends Fragment { if (!captionIsEmpty) { captionTextView.setVisibility(View.VISIBLE); captionTextView.setText(caption); + captionTextView.setOnClickListener(view -> hideAppBar()); captionTextView.setOnLongClickListener(view -> { if (activity != null && !activity.isDestroyed() @@ -284,12 +277,19 @@ public class ViewRedditGalleryImageOrGifFragment extends Fragment { }); } if (!captionUrlIsEmpty) { - captionUrlTextView.setText(captionUrl); + String scheme = Uri.parse(captionUrl).getScheme(); + String urlWithoutScheme = ""; + if(!TextUtils.isEmpty(scheme)){ + urlWithoutScheme = captionUrl.substring(scheme.length() + 3); + } + + captionUrlTextView.setText(TextUtils.isEmpty(urlWithoutScheme) ? captionUrl : urlWithoutScheme); + BetterLinkMovementMethod.linkify(Linkify.WEB_URLS, captionUrlTextView).setOnLinkLongClickListener((textView, url) -> { if (activity != null && !activity.isDestroyed() && !activity.isFinishing()) { UrlMenuBottomSheetFragment urlMenuBottomSheetFragment = new UrlMenuBottomSheetFragment(); Bundle bundle = new Bundle(); - bundle.putString(UrlMenuBottomSheetFragment.EXTRA_URL, url); + bundle.putString(UrlMenuBottomSheetFragment.EXTRA_URL, captionUrl); urlMenuBottomSheetFragment.setArguments(bundle); urlMenuBottomSheetFragment.show(activity.getSupportFragmentManager(), urlMenuBottomSheetFragment.getTag()); } @@ -302,6 +302,20 @@ public class ViewRedditGalleryImageOrGifFragment extends Fragment { return rootView; } + private void hideAppBar() { + 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); + isActionBarHidden = true; + if (activity.isUseBottomAppBar() || isUseBottomCaption) { + bottomAppBar.setVisibility(View.GONE); + } + } + private void loadImage() { imageView.showImage(Uri.parse(media.url)); } -- cgit v1.2.3