Skip to content

Commit

Permalink
Closes #232; make back presses clear the follower pool when back is p…
Browse files Browse the repository at this point in the history
…ressed, not when a link is
  • Loading branch information
Adamantcheese committed Jul 26, 2019
1 parent d17add9 commit 2beade2
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
})
Expand Down Expand Up @@ -539,6 +533,13 @@ public void openArchive(Pair<String, String> 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;
}
Expand Down
10 changes: 7 additions & 3 deletions Kuroba/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -467,9 +467,13 @@ Note that for country code filtering, troll country codes should be prepended wi
<string name="setting_post_filename">Show filename on posts</string>

<!-- Appearance gallery group -->
<string name="settings_group_gallery">Gallery</string>
<string name="setting_gallery_immersive_mode_title">Use immersive mode for image gallery</string>
<string name="setting_gallery_immersive_mode_description">This will make image gallery view be fullscreen with statusbar/navbar hidden</string>
<string name="settings_group_images">Images</string>
<string name="setting_images_pad_thumbs">Pad thumbnails</string>
<string name="setting_images_pad_thumbs_description">Add extra space around thumbnails to move them away from the edges of the cell</string>
<string name="setting_images_high_res">High resolution cells</string>
<string name="setting_images_high_res_description">Make the album view and card catalog images higher resolution by pre-rescaling full size images</string>
<string name="setting_images_immersive_mode_title">Use immersive mode for image gallery</string>
<string name="setting_images_immersive_mode_description">This will make image gallery view be fullscreen with statusbar/navbar hidden</string>

<!-- Behavior -->
<string name="settings_screen_behavior">Behavior</string>
Expand Down

0 comments on commit 2beade2

Please sign in to comment.