From 2beade20af220e373837464abe7031aad87ed8b7 Mon Sep 17 00:00:00 2001 From: Adamantcheese Date: Thu, 25 Jul 2019 17:31:25 -0700 Subject: [PATCH] Closes #232; make back presses clear the follower pool when back is pressed, not when a link is --- .../chan/core/settings/ChanSettings.java | 2 ++ .../adamantcheese/chan/ui/cell/PostCell.java | 8 ++++++- .../AppearanceSettingsController.java | 23 +++++++++++-------- .../ui/controller/ViewThreadController.java | 13 ++++++----- Kuroba/app/src/main/res/values/strings.xml | 10 +++++--- 5 files changed, 37 insertions(+), 19 deletions(-) diff --git a/Kuroba/app/src/main/java/com/github/adamantcheese/chan/core/settings/ChanSettings.java b/Kuroba/app/src/main/java/com/github/adamantcheese/chan/core/settings/ChanSettings.java index d01870a06a..bc543df9e0 100644 --- a/Kuroba/app/src/main/java/com/github/adamantcheese/chan/core/settings/ChanSettings.java +++ b/Kuroba/app/src/main/java/com/github/adamantcheese/chan/core/settings/ChanSettings.java @@ -175,6 +175,7 @@ public String getKey() { public static final BooleanSetting shiftPostFormat; public static final BooleanSetting enableEmoji; public static final BooleanSetting highResCells; + public static final BooleanSetting padThumbs; public static final BooleanSetting incrementalThreadDownloadingEnabled; @@ -272,6 +273,7 @@ public String getKey() { shiftPostFormat = new BooleanSetting(p, "shift_post_format", true); enableEmoji = new BooleanSetting(p, "enable_emoji", false); highResCells = new BooleanSetting(p, "high_res_cells", false); + padThumbs = new BooleanSetting(p, "pad_thumbnails", true); incrementalThreadDownloadingEnabled = new BooleanSetting(p, "incremental_thread_downloading", false); } diff --git a/Kuroba/app/src/main/java/com/github/adamantcheese/chan/ui/cell/PostCell.java b/Kuroba/app/src/main/java/com/github/adamantcheese/chan/ui/cell/PostCell.java index b638629a53..897dbb7934 100644 --- a/Kuroba/app/src/main/java/com/github/adamantcheese/chan/ui/cell/PostCell.java +++ b/Kuroba/app/src/main/java/com/github/adamantcheese/chan/ui/cell/PostCell.java @@ -586,7 +586,8 @@ private void buildThumbnails() { int lastId = 0; int generatedId = 1; boolean first = true; - for (PostImage image : post.images) { + for (int i = 0; i < post.images.size(); i++) { + PostImage image = post.images.get(i); PostImageThumbnailView v = new PostImageThumbnailView(getContext()); // Set the correct id. @@ -607,6 +608,11 @@ private void buildThumbnails() { v.setClickable(true); v.setOnClickListener(v2 -> callback.onThumbnailClicked(image, v)); v.setRounding(dp(2)); + //pad top and left if setting is on, no right pad, pad bottom if last image to avoid clashing with divider + v.setPadding(ChanSettings.padThumbs.get() ? dp(4) : 0, + ChanSettings.padThumbs.get() && first ? dp(4) : 0, + 0, + i + 1 == post.images.size() ? dp(1) : 0); relativeLayoutContainer.addView(v, p); thumbnailViews.add(v); diff --git a/Kuroba/app/src/main/java/com/github/adamantcheese/chan/ui/controller/AppearanceSettingsController.java b/Kuroba/app/src/main/java/com/github/adamantcheese/chan/ui/controller/AppearanceSettingsController.java index 6b52ee1ffc..c1fc5ed32b 100644 --- a/Kuroba/app/src/main/java/com/github/adamantcheese/chan/ui/controller/AppearanceSettingsController.java +++ b/Kuroba/app/src/main/java/com/github/adamantcheese/chan/ui/controller/AppearanceSettingsController.java @@ -122,21 +122,26 @@ private void populatePreferences() { groups.add(post); } - //Gallery group + //Image group { - SettingsGroup gallery = new SettingsGroup(R.string.settings_group_gallery); + SettingsGroup images = new SettingsGroup(R.string.settings_group_images); - requiresUiRefresh.add(gallery.add(new BooleanSettingView(this, + requiresUiRefresh.add(images.add(new BooleanSettingView(this, + ChanSettings.padThumbs, + context.getString(R.string.setting_images_pad_thumbs), + context.getString(R.string.setting_images_pad_thumbs_description)))); + + requiresUiRefresh.add(images.add(new BooleanSettingView(this, ChanSettings.highResCells, - "High resolution cells", - "Make the album view and card catalog images higher resolution by pre-rescaling full size images"))); + context.getString(R.string.setting_images_high_res), + context.getString(R.string.setting_images_high_res_description)))); - requiresUiRefresh.add(gallery.add(new BooleanSettingView(this, + requiresUiRefresh.add(images.add(new BooleanSettingView(this, ChanSettings.useImmersiveModeForGallery, - R.string.setting_gallery_immersive_mode_title, - R.string.setting_gallery_immersive_mode_description))); + R.string.setting_images_immersive_mode_title, + R.string.setting_images_immersive_mode_description))); - groups.add(gallery); + groups.add(images); } } diff --git a/Kuroba/app/src/main/java/com/github/adamantcheese/chan/ui/controller/ViewThreadController.java b/Kuroba/app/src/main/java/com/github/adamantcheese/chan/ui/controller/ViewThreadController.java index b9bfb40903..57598d684a 100644 --- a/Kuroba/app/src/main/java/com/github/adamantcheese/chan/ui/controller/ViewThreadController.java +++ b/Kuroba/app/src/main/java/com/github/adamantcheese/chan/ui/controller/ViewThreadController.java @@ -289,12 +289,6 @@ public void showThread(final Loadable threadLoadable) { new AlertDialog.Builder(context) .setNegativeButton(R.string.cancel, null) .setPositiveButton(R.string.ok, (dialog, which) -> { - //clear the pool if the current thread isn't a part of this crosspost chain - //ie a new thread is loaded and a new chain is started; this will never throw null pointer exceptions - //noinspection ConstantConditions - if (!threadFollowerpool.isEmpty() && threadFollowerpool.peekFirst().second != loadable.hashCode()) { - threadFollowerpool.clear(); - } threadFollowerpool.addFirst(new Pair<>(loadable, threadLoadable.hashCode())); loadThread(threadLoadable); }) @@ -539,6 +533,13 @@ public void openArchive(Pair domainNamePair) { @Override public boolean threadBackPressed() { + //clear the pool if the current thread isn't a part of this crosspost chain + //ie a new thread is loaded and a new chain is started; this will never throw null pointer exceptions + //noinspection ConstantConditions + if (!threadFollowerpool.isEmpty() && threadFollowerpool.peekFirst().second != loadable.hashCode()) { + threadFollowerpool.clear(); + } + //if the thread is new, it'll be empty here, so we'll get back-to-catalog functionality if (threadFollowerpool.isEmpty()) { return false; } diff --git a/Kuroba/app/src/main/res/values/strings.xml b/Kuroba/app/src/main/res/values/strings.xml index 933406cc73..a095b15fbe 100644 --- a/Kuroba/app/src/main/res/values/strings.xml +++ b/Kuroba/app/src/main/res/values/strings.xml @@ -467,9 +467,13 @@ Note that for country code filtering, troll country codes should be prepended wi Show filename on posts - Gallery - Use immersive mode for image gallery - This will make image gallery view be fullscreen with statusbar/navbar hidden + Images + Pad thumbnails + Add extra space around thumbnails to move them away from the edges of the cell + High resolution cells + Make the album view and card catalog images higher resolution by pre-rescaling full size images + Use immersive mode for image gallery + This will make image gallery view be fullscreen with statusbar/navbar hidden Behavior