Skip to content
This repository has been archived by the owner on Sep 25, 2021. It is now read-only.

Super patch #739

Merged
merged 42 commits into from
Aug 1, 2020
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
1789886
Improve post info dialogue
Oct 5, 2018
621d41a
Fix spelling error
Oct 5, 2018
05e4e2f
Tidy post date implementation
Oct 5, 2018
ded8037
Revert empty-setup emoji change
Oct 6, 2018
9e2b644
Revert post-date info "implementation"
Oct 6, 2018
2c8e1d6
Merge pull request #1 from alex-eyre/dev-loopswitch
alexeyre Oct 12, 2018
384d9ab
Update gitignore to be more general
Adamantcheese Aug 3, 2019
02cdac7
Fixes #700
Adamantcheese Aug 3, 2019
e72d49c
Fixes #681
Adamantcheese Aug 3, 2019
eace807
Fixes #685, Fixes #617?
Adamantcheese Aug 3, 2019
5917d4d
From PR #695, make the error dialog only appear if the image in the c…
Adamantcheese Aug 3, 2019
ed69295
Fixes #500
Adamantcheese Aug 3, 2019
bfba09e
Resolves #600
Adamantcheese Aug 3, 2019
32cded6
Resolves #286
Adamantcheese Aug 3, 2019
0b0a322
Fixes #484, possibly #450?
Adamantcheese Aug 3, 2019
6aa568a
Resolves #543
Adamantcheese Aug 3, 2019
cfb8a19
Resolves #526 more (even though the 1 minute was already added)
Adamantcheese Aug 3, 2019
153a151
Merge remote-tracking branch 'alex-eyre/dev' into super-patch
Adamantcheese Aug 3, 2019
31873ce
Resolves #437, along with @alex-eyre's previous PR
Adamantcheese Aug 3, 2019
0bdddef
Resolves #683
Adamantcheese Aug 3, 2019
f399c18
checkstyle fixes
Adamantcheese Aug 3, 2019
5800cbf
apparently static member names are treated differently or something d…
Adamantcheese Aug 3, 2019
7832802
Copy a fix from Kuroba to Clover
Adamantcheese Aug 4, 2019
f36764b
Fixes an issue where external links opened in the app would not corre…
Adamantcheese Aug 14, 2019
c6308ff
Fixes an issue where some OP post links couldn't be tapped, due to th…
Adamantcheese Aug 22, 2019
bd106c4
Fixes the board menu search to use startsWith instead of equals for b…
Adamantcheese Aug 22, 2019
f5982f1
Shouldn't have removed that line
Adamantcheese Aug 23, 2019
ef85675
Fixes the board menu search to use startsWith instead of equals for b…
Adamantcheese Aug 23, 2019
2f669c5
Merge branch 'super-patch' of https://github.com/Adamantcheese/Clover…
Adamantcheese Aug 23, 2019
e1c7b89
Fixes an issue noted in Kuroba#378 for text-only mode
Adamantcheese Oct 13, 2019
ae3b82f
Implement @andyklimczak 's suggestions
Adamantcheese Oct 19, 2019
2663693
Rename to use proper boolean get method naming convention
Adamantcheese Oct 19, 2019
cbf7818
Concurrency updates per findings on Kuroba
Adamantcheese Feb 23, 2020
aff384f
Fixes a closed file and preview tapped NPE found on Kuroba
Adamantcheese Feb 23, 2020
b16f7ef
Copy of fix for #759
Adamantcheese Feb 23, 2020
e2ced22
Imports cleanup for checkstyle
Adamantcheese Feb 23, 2020
f4132a6
checkstyle is good and all, but fuck give me a code style to actually…
Adamantcheese Feb 23, 2020
993be60
Fixes an issue where when the image viewer is backed out of before th…
Adamantcheese Feb 27, 2020
6b11afd
Fixes an issue with GIF files, when uncompressed, crashing the applic…
Adamantcheese Mar 22, 2020
2ab85d6
Updates to the getReadableFileSize method; get rid of the SI flag as …
Adamantcheese May 7, 2020
2331523
Style fix
Adamantcheese May 9, 2020
475ca7b
Closes #744
Adamantcheese Jun 9, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
gps/
Clover/app/keys.properties
**/keys.properties
**/keystore.jks
Clover/app/version.properties
Clover/captures/
Clover/sentry.properties
Expand Down Expand Up @@ -27,6 +28,8 @@ local.properties
.gradle
build/
*.iml
# Layout captures
**/*.li

## Windows detritus
#############
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,15 @@ public List<Filter> getEnabledFilters() {
return enabledFilters;
}

public List<Filter> getAllFilters() {
try {
return databaseFilterManager.getFilters().call();
} catch (Exception e) {
Logger.wtf(TAG, "Couldn't get all filters for some reason.");
return new ArrayList<>();
}
}

@AnyThread
public boolean matchesBoard(Filter filter, Board board) {
if (filter.allBoards || TextUtils.isEmpty(filter.boards)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,16 @@ public void onChanLoaderError(ChanLoaderException error) {
public void onChanLoaderData(ChanThread thread) {
pin.isError = false;

/*
* Forcibly update watched thread titles
* This solves the issue of when you post a thread and the site doesn't have the thread listed yet,
* resulting in the thread title being something like /test/918324919 instead of a proper title
*
* The thread title will be updated as soon as the site has the thread listed in the thread directory
*
*/
pin.loadable.setTitle(PostHelper.getTitle(thread.op, pin.loadable));

if (pin.thumbnailUrl == null && thread.op != null && thread.op.image() != null) {
pin.thumbnailUrl = thread.op.image().getThumbnailUrl().toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ public void updateDrawState(@NonNull TextPaint ds) {
}
}

public boolean getSpoilerState() {
Adamantcheese marked this conversation as resolved.
Show resolved Hide resolved
return spoilerVisible;
}

public static class ThreadLink {
public String board;
public int threadId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void showImages(List<PostImage> images, int position, Loadable loadable)

// Do this before the view is measured, to avoid it to always loading the first two pages
callback.setPagerItems(images, selectedPosition);
callback.setImageMode(images.get(selectedPosition), MultiImageView.Mode.LOWRES);
callback.setImageMode(images.get(selectedPosition), MultiImageView.Mode.LOWRES, true);
}

public void onViewMeasured() {
Expand All @@ -106,7 +106,7 @@ public void onExit() {
PostImage postImage = images.get(selectedPosition);
if (postImage.type == PostImage.Type.MOVIE) {
// VideoView doesn't work with invisible visibility
callback.setImageMode(postImage, MultiImageView.Mode.LOWRES);
callback.setImageMode(postImage, MultiImageView.Mode.LOWRES, true);
}

callback.setPagerVisiblity(false);
Expand Down Expand Up @@ -172,8 +172,8 @@ public void onModeLoaded(MultiImageView multiImageView, MultiImageView.Mode mode
changeViewsOnInTransitionEnd = true;
}
// Transition ended or not, request loading the other side views to lowres
for (PostImage other : getOther(selectedPosition, false)) {
callback.setImageMode(other, MultiImageView.Mode.LOWRES);
for (PostImage other : getOther(selectedPosition)) {
callback.setImageMode(other, MultiImageView.Mode.LOWRES, false);
}
onLowResInCenter();
} else {
Expand All @@ -197,8 +197,8 @@ private void onPageSwipedTo(int position) {
setTitle(postImage, position);
callback.scrollToImage(postImage);

for (PostImage other : getOther(position, false)) {
callback.setImageMode(other, MultiImageView.Mode.LOWRES);
for (PostImage other : getOther(position)) {
callback.setImageMode(other, MultiImageView.Mode.LOWRES, false);
}

// Already in LOWRES mode
Expand All @@ -218,11 +218,11 @@ private void onLowResInCenter() {

if (imageAutoLoad(postImage) && !postImage.spoiler) {
if (postImage.type == PostImage.Type.STATIC) {
callback.setImageMode(postImage, MultiImageView.Mode.BIGIMAGE);
callback.setImageMode(postImage, MultiImageView.Mode.BIGIMAGE, true);
} else if (postImage.type == PostImage.Type.GIF) {
callback.setImageMode(postImage, MultiImageView.Mode.GIF);
callback.setImageMode(postImage, MultiImageView.Mode.GIF, true);
} else if (postImage.type == PostImage.Type.MOVIE && videoAutoLoad(postImage)) {
callback.setImageMode(postImage, MultiImageView.Mode.MOVIE);
callback.setImageMode(postImage, MultiImageView.Mode.MOVIE, true);
}
}

Expand Down Expand Up @@ -282,18 +282,18 @@ public void onTap(MultiImageView multiImageView) {
PostImage postImage = images.get(selectedPosition);
if (imageAutoLoad(postImage) && !postImage.spoiler) {
if (postImage.type == PostImage.Type.MOVIE) {
callback.setImageMode(postImage, MultiImageView.Mode.MOVIE);
callback.setImageMode(postImage, MultiImageView.Mode.MOVIE, true);
} else {
onExit();
}
} else {
MultiImageView.Mode currentMode = callback.getImageMode(postImage);
if (postImage.type == PostImage.Type.STATIC && currentMode != MultiImageView.Mode.BIGIMAGE) {
callback.setImageMode(postImage, MultiImageView.Mode.BIGIMAGE);
callback.setImageMode(postImage, MultiImageView.Mode.BIGIMAGE, true);
} else if (postImage.type == PostImage.Type.GIF && currentMode != MultiImageView.Mode.GIF) {
callback.setImageMode(postImage, MultiImageView.Mode.GIF);
callback.setImageMode(postImage, MultiImageView.Mode.GIF, true);
} else if (postImage.type == PostImage.Type.MOVIE && currentMode != MultiImageView.Mode.MOVIE) {
callback.setImageMode(postImage, MultiImageView.Mode.MOVIE);
callback.setImageMode(postImage, MultiImageView.Mode.MOVIE, true);
} else {
onExit();
}
Expand Down Expand Up @@ -377,14 +377,11 @@ private void setTitle(PostImage postImage, int position) {
postImage.spoiler && callback.getImageMode(postImage) == MultiImageView.Mode.LOWRES);
}

private List<PostImage> getOther(int position, boolean all) {
List<PostImage> other = new ArrayList<>(3);
private List<PostImage> getOther(int position) {
List<PostImage> other = new ArrayList<>(2);
if (position - 1 >= 0) {
other.add(images.get(position - 1));
}
if (all) {
other.add(images.get(position));
}
if (position + 1 < images.size()) {
other.add(images.get(position + 1));
}
Expand All @@ -402,7 +399,7 @@ public interface Callback {

void setPagerItems(List<PostImage> images, int initialIndex);

void setImageMode(PostImage postImage, MultiImageView.Mode mode);
void setImageMode(PostImage postImage, MultiImageView.Mode mode, boolean center);

void setVolume(PostImage postImage, boolean muted);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,8 @@ private void handleQuote(Post post, String textQuote) {
callback.loadViewsIntoDraft(draft);

String extraNewline = "";
if (draft.selection - 1 >= 0 && draft.selection - 1 < draft.comment.length() &&
draft.comment.charAt(draft.selection - 1) != '\n') {
if (draft.selectionStart - 1 >= 0 && draft.selectionStart - 1 < draft.comment.length() &&
draft.comment.charAt(draft.selectionStart - 1) != '\n') {
extraNewline = "\n";
}

Expand Down Expand Up @@ -360,8 +360,14 @@ private void commentInsert(String insertBefore) {

private void commentInsert(String insertBefore, String insertAfter) {
draft.comment = new StringBuilder(draft.comment)
.insert(draft.selection, insertBefore + insertAfter).toString();
draft.selection += insertBefore.length();
.insert(draft.selectionStart, insertBefore)
.insert(draft.selectionEnd + insertBefore.length(), insertAfter)
.toString();
/* Since this method is only used for quote insertion and spoilers,
both of which should set the cursor to right after the selected text for more typing,
set the selection start to the new end */
draft.selectionEnd += insertBefore.length();
draft.selectionStart = draft.selectionEnd;
callback.loadDraftIntoViews(draft);
}

Expand Down Expand Up @@ -438,10 +444,10 @@ public void switchPage(Page page, boolean animate, boolean useV2NoJsCaptcha) {
private void highlightQuotes() {
Matcher matcher = QUOTE_PATTERN.matcher(draft.comment);

// Find all occurrences of >>\d+ with start and end between selection
// Find all occurrences of >>\d+ with start and end between selectionStart
int no = -1;
while (matcher.find()) {
if (matcher.start() <= draft.selection && matcher.end() >= draft.selection - 1) {
if (matcher.start() <= draft.selectionStart && matcher.end() >= draft.selectionStart - 1) {
String quote = matcher.group().substring(2);
try {
no = Integer.parseInt(quote);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.floens.chan.core.manager.WatchManager;
import org.floens.chan.core.model.ChanThread;
import org.floens.chan.core.model.Post;
import org.floens.chan.core.model.PostHttpIcon;
import org.floens.chan.core.model.PostImage;
import org.floens.chan.core.model.PostLinkable;
import org.floens.chan.core.model.orm.Board;
Expand Down Expand Up @@ -485,9 +486,16 @@ public Object onPopulatePostOptions(Post post, List<FloatingMenuItem> menu,
menu.add(new FloatingMenuItem(POST_OPTION_DELETE, R.string.post_delete));
}

if (ChanSettings.accessibleInfo.get()) {
//Accessible info enabled
menu.add(new FloatingMenuItem(POST_OPTION_INFO, R.string.post_info));
} else {
extraMenu.add(new FloatingMenuItem(POST_OPTION_INFO, R.string.post_info));
}

menu.add(new FloatingMenuItem(POST_OPTION_EXTRA, R.string.post_more));

extraMenu.add(new FloatingMenuItem(POST_OPTION_INFO, R.string.post_info));

extraMenu.add(new FloatingMenuItem(POST_OPTION_LINKS, R.string.post_show_links));
extraMenu.add(new FloatingMenuItem(POST_OPTION_OPEN_BROWSER, R.string.action_open_browser));
extraMenu.add(new FloatingMenuItem(POST_OPTION_SHARE, R.string.post_share));
Expand Down Expand Up @@ -702,8 +710,7 @@ private void showPostInfo(Post post) {
text.append("\n");
}

// TODO(multi-site) get this from the timestamp
// text += "Date: " + post.date;
text.append("Posted: ").append(PostHelper.getLocalDate(post));

if (!TextUtils.isEmpty(post.id)) {
text.append("\nId: ").append(post.id);
Expand All @@ -713,9 +720,17 @@ private void showPostInfo(Post post) {
text.append("\nTripcode: ").append(post.tripcode);
}

/*if (!TextUtils.isEmpty(post.countryName)) {
text += "\nCountry: " + post.country + ", " + post.countryName;
}*/
if (post.httpIcons != null && !post.httpIcons.isEmpty()) {
for (PostHttpIcon icon : post.httpIcons) {
if (icon.url.toString().contains("troll")) {
text.append("\nTroll Country: ").append(icon.name);
} else if (icon.url.toString().contains("country")) {
text.append("\nCountry: ").append(icon.name);
} else if (icon.url.toString().contains("minileaf")) {
text.append("\n4chan Pass Year: ").append(icon.name);
}
}
}

if (!TextUtils.isEmpty(post.capcode)) {
text.append("\nCapcode: ").append(post.capcode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ public String getKey() {
public static final BooleanSetting saveOriginalFilename;
public static final BooleanSetting shareUrl;
public static final BooleanSetting enableReplyFab;
public static final BooleanSetting accessibleInfo;
public static final BooleanSetting anonymize;
public static final BooleanSetting anonymizeIds;
public static final BooleanSetting showAnonymousName;
Expand All @@ -133,6 +134,7 @@ public String getKey() {
public static final BooleanSetting neverHideToolbar;
public static final BooleanSetting controllerSwipeable;
public static final BooleanSetting saveBoardFolder;
public static final BooleanSetting saveThreadFolder;
public static final BooleanSetting videoDefaultMuted;
public static final BooleanSetting videoAutoLoop;

Expand Down Expand Up @@ -199,6 +201,7 @@ public String getKey() {
EventBus.getDefault().post(new SettingChanged<>(saveLocation)));
saveOriginalFilename = new BooleanSetting(p, "preference_image_save_original", false);
shareUrl = new BooleanSetting(p, "preference_image_share_url", false);
accessibleInfo = new BooleanSetting(p, "preference_enable_accessible_info", false);
enableReplyFab = new BooleanSetting(p, "preference_enable_reply_fab", true);
anonymize = new BooleanSetting(p, "preference_anonymize", false);
anonymizeIds = new BooleanSetting(p, "preference_anonymize_ids", false);
Expand All @@ -215,6 +218,7 @@ public String getKey() {
neverHideToolbar = new BooleanSetting(p, "preference_never_hide_toolbar", false);
controllerSwipeable = new BooleanSetting(p, "preference_controller_swipeable", true);
saveBoardFolder = new BooleanSetting(p, "preference_save_subboard", false);
saveThreadFolder = new BooleanSetting(p, "preference_save_subthread", false);
videoDefaultMuted = new BooleanSetting(p, "preference_video_default_muted", true);
videoAutoLoop = new BooleanSetting(p, "preference_video_loop", true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ public LoadableResult resolveLoadableForUrl(String url) {
Loadable resolved = loadableProvider.get(resolvedLoadable);

if (resolved != null) {
resolved.markedNo = resolvedLoadable.markedNo;
return new LoadableResult(resolved);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,14 @@ public void readPostObject(JsonReader reader, ChanReaderProcessingQueue queue) t

private PostImage readPostImage(JsonReader reader, Post.Builder builder,
SiteEndpoints endpoints) throws IOException {
reader.beginObject();
try {
reader.beginObject();
} catch (Exception e) {
//workaround for weird 8chan error where extra_files has a random empty array in it
reader.beginArray();
reader.endArray();
reader.beginObject();
}

String fileId = null;
long fileSize = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ public class Reply {
public String options = "";
public String subject = "";
public String comment = "";
public int selection;
public int selectionStart;
public int selectionEnd;
public boolean spoilerImage = false;
public String password = "";
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,18 @@ public void finishUpdate(ViewGroup container) {
if (view == null) {
Logger.w(TAG, "finishUpdate setMode view still not found");
} else {
view.setMode(change.mode);
view.setMode(change.mode, change.center);
}
}
pendingModeChanges.clear();
}

public void setMode(final PostImage postImage, MultiImageView.Mode mode) {
public void setMode(final PostImage postImage, MultiImageView.Mode mode, boolean center) {
MultiImageView view = find(postImage);
if (view == null) {
pendingModeChanges.add(new ModeChange(mode, postImage));
pendingModeChanges.add(new ModeChange(mode, postImage, center));
} else {
view.setMode(mode);
view.setMode(mode, center);
}
}

Expand Down Expand Up @@ -116,13 +116,20 @@ public MultiImageView find(PostImage postImage) {
return null;
}

public void toggleTransparency(PostImage postImage) {
MultiImageView view = find(postImage);
view.toggleTransparency();
}

private static class ModeChange {
public MultiImageView.Mode mode;
public PostImage postImage;
public boolean center;

private ModeChange(MultiImageView.Mode mode, PostImage postImage) {
private ModeChange(MultiImageView.Mode mode, PostImage postImage, boolean center) {
this.mode = mode;
this.postImage = postImage;
this.center = center;
}
}
}
Loading