139 Commits

Author SHA1 Message Date
Bazsalanszky
55bbef25c6 Switch pipeline to java 17 2024-08-29 14:20:42 +02:00
Bazsalanszky
32c75ff87c Fix crash when switching to some sort types on the community search page
Closes #283
2024-08-29 14:12:15 +02:00
Bazsalanszky
468bae4019 Fix crash on video autoplay
This commit fixes the issue where the app crashes if autoplay is enabled and the user clicks on a post with a video.

Closes #281
2024-08-29 13:51:30 +02:00
Bazsalanszky
e8b199a74a Fix crash on theme editing
This commit resolves the issue where saving or previewing a theme crashed the app.

Closes #282
2024-08-29 10:52:20 +02:00
Bazsalanszky
0c8e3e3ea5 Fix comment rendering
There were some issues rendering markdown in comments. Now its fixed.
2024-08-12 13:16:18 +02:00
Bazsalanszky
767e75b798 Better markdown handling
This commit fixes some of the issues with markdown rendering:
- Switch to Textview instead of RecyclerView to render Markdown
- Import Spoiler renderer from Jebora
- Import Script renderer from Jebora
- Clean out markwon plugins that were specific to reddit

Closes #130 #172 #217 and #273
2024-08-09 12:45:15 +02:00
Bazsalanszky
c1c8d99de2 Fix issue where preferences used the Display name instead of the full account name
Closes #275
2024-08-09 10:37:23 +02:00
Bazsalanszky
336223cc36 Bump version 2024-08-09 09:44:32 +02:00
Bazsalanszky
7da428e9b2 Removed unused translations 2024-08-09 09:35:09 +02:00
Bazsalanszky
2a08a26a36 Remove CustomTextView dependency and reimplement it from scratch
The dependency caused some errors. It is old and unmaintained anyway.
2024-08-09 08:52:47 +02:00
Bazsalanszky
c60d88b2fe Add ThreadStackSize to gradle.properties
For real now
2024-08-08 14:43:59 +02:00
Bazsalanszky
b66742dd37 Revert "Add ThreadStackSize to gradle.properties"
This reverts commit b3623e6f7b.
2024-08-08 14:40:41 +02:00
Bazsalanszky
b3623e6f7b Add ThreadStackSize to gradle.properties 2024-08-08 14:38:42 +02:00
Bazsalanszky
2a2e7c0e87 Removed many unused strings
Closes #263
2024-08-08 14:27:31 +02:00
Balazs Toldi
1395eee2df Fix typo in woodpecker pipeline 2024-08-06 08:30:25 +02:00
Balazs Toldi
a0e2bb06a1 Update SDK in woodpecker pipeline 2024-08-06 08:23:29 +02:00
Balazs Toldi
ce08191d01 Bump versionCode in build.gradle 2024-08-06 08:23:29 +02:00
Lefteris T
75f65691fd Translated using Weblate (Greek)
Currently translated at 99.5% (1319 of 1325 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/el/
2024-08-05 16:18:23 +00:00
Balazs Toldi
b70db40a03 Fix crash when trying to Commnet
Previously, if a post did not have any markdown in it, the app would not initialize Glide on the CommentActivity, causing a crash while loading the user icon. Now it will be initialized either way.

Closes #272
2024-08-04 14:31:39 +02:00
30p87
5f345113f1 Translated using Weblate (Bavarian)
Currently translated at 0.9% (12 of 1325 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/bar/
2024-08-03 21:18:23 +00:00
30p87
ba1c320e47 Translated using Weblate (German)
Currently translated at 100.0% (1325 of 1325 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/de/
2024-08-03 21:18:23 +00:00
Fjuro
be6c137e03 Translated using Weblate (Czech)
Currently translated at 100.0% (1325 of 1325 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/cs/
2024-08-03 21:18:23 +00:00
30p87
07a556b76e Added translation using Weblate (Bavarian) 2024-08-03 08:02:33 +00:00
SomeTr
5aba7cd938 Translated using Weblate (Ukrainian)
Currently translated at 100.0% (1325 of 1325 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/uk/
2024-08-02 13:18:23 +00:00
lucasew
40b63522d0 Translated using Weblate (Portuguese)
Currently translated at 94.5% (1253 of 1325 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/pt/
2024-08-02 13:18:23 +00:00
Balazs Toldi
934d0e5c81 Change error image in a few more places 2024-08-01 18:33:58 +02:00
Balazs Toldi
6457a4db2f Proper Admin/Moderator indication
This commit adds proper indicators if a post or comment is made by a moderator or an admin. If a user is both an admin and a moderator, both indicators will be shown.

Closes #267
2024-07-30 09:32:16 +02:00
Balazs Toldi
4ccb1a38bf Fix crash when opening links
This commit fixes the issue where opening links while browsing would trigger an account switch with a null name.
2024-07-29 21:47:54 +02:00
SomeTr
de92e0edd3 Translated using Weblate (Ukrainian)
Currently translated at 100.0% (1325 of 1325 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/uk/
2024-07-29 09:18:23 +00:00
Anonymous
e87426d591 Translated using Weblate (French)
Currently translated at 93.5% (1240 of 1325 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/fr/
2024-07-28 08:27:52 +00:00
Bazsalanszky
3a9638e236 Fix typos 2024-07-28 10:00:46 +02:00
Bazsalanszky
f5b8206959 Fix token checking (again)
Failure to call the API (e.g. network error) with the token caused incorrect relogin requests.
2024-07-28 10:00:45 +02:00
Lefteris T
ae74eeba0f Translated using Weblate (Greek)
Currently translated at 99.5% (1318 of 1324 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/el/
2024-07-27 13:18:23 +00:00
artnay
f6e5942e86 Translated using Weblate (Finnish)
Currently translated at 56.0% (742 of 1324 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/fi/
2024-07-24 17:22:40 +00:00
SomeTr
b67b62f952 Translated using Weblate (Ukrainian)
Currently translated at 100.0% (1324 of 1324 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/uk/
2024-07-23 10:18:23 +00:00
Fjuro
f01e53953b Translated using Weblate (Czech)
Currently translated at 100.0% (1324 of 1324 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/cs/
2024-07-23 10:18:23 +00:00
Bazsalanszky
241f082806 Translated using Weblate (Hungarian)
Currently translated at 82.7% (1094 of 1322 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/hu/
2024-07-22 10:07:25 +00:00
Bazsalanszky
56e05a2e84 Add indication for removed/deleted comments
It is now visible, if a comment is deleted by the creator or if it was removed by a moderator or admin.

Closes #249
2024-07-22 12:07:13 +02:00
Bazsalanszky
2c16a05a95 Bump version code 2024-07-21 20:46:15 +02:00
Bazsalanszky
23c5ac9127 Fix issues with notifications
This commit fixes the issue where the app incorrectly switches accounts when opening a notification (see changes in the InboxActivity). It also fixes the issue where the posts/comments would not show up after clicking on a notification that would require an account switch (see changes in the LinkResolverActivity).
2024-07-21 20:44:39 +02:00
Bazsalanszky
1303106a7b Mark message as read fix
This commit fixes the issue where messages aren't marked as read when you click on them from the InboxActivity.
2024-07-21 13:47:07 +02:00
Bazsalanszky
f9a0e0e70d Fix CRASH on starting a foreground service
Starting from android target 34, we need to set a foreground service type. In my opinion, the dataSync one fits best for us.
2024-07-21 11:49:17 +02:00
Bazsalanszky
3d3285d1ee Fix CRASH on CommentActivity 2024-07-21 11:49:17 +02:00
Lefteris T
c2017dd17c Translated using Weblate (Greek)
Currently translated at 99.5% (1316 of 1322 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/el/
2024-07-20 20:18:24 +00:00
SomeTr
fb6d9ed0bc Translated using Weblate (Ukrainian)
Currently translated at 100.0% (1322 of 1322 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/uk/
2024-07-20 20:18:24 +00:00
Fjuro
257dc4d0a7 Translated using Weblate (Czech)
Currently translated at 100.0% (1322 of 1322 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/cs/
2024-07-20 20:18:24 +00:00
Balazs Toldi
5fdf1208a7 Better image loading in Markdown
This commit potentially solves issues with slow scrolling on posts and some crashes due to too large files
2024-07-19 20:55:08 +02:00
Balazs Toldi
6708b72fd8 Removed commit log file 2024-07-19 19:15:05 +02:00
Balazs Toldi
327b874fd6 Update strings
Removed anonymous_homepage_not_implemented string from every language file
2024-07-19 19:12:46 +02:00
Balazs Toldi
cafd3c6025 Add option to disable automatic post hide
This commit adds two new options:
- Do not hide saved posts automatically: When enabled, read posts will also be visible on the saved posts page
- Do not hide your own posts: When enabled, your own posts will be visible, even if it's read

Closes #219
Closes #125
2024-07-19 17:02:58 +02:00
Balazs Toldi
9ecbaba3d4 Minor change to distinguish moderators/admins 2024-07-19 17:02:58 +02:00
Balazs Toldi
4741198c78 Show new icon as error image as well
Closes #223
2024-07-19 17:02:58 +02:00
Balazs Toldi
577d5b8e6f Removed Anonymous page not implemented error
No longer needed as it's there now.
2024-07-19 17:02:58 +02:00
SomeTr
307036bca0 Translated using Weblate (Ukrainian)
Currently translated at 100.0% (1321 of 1321 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/uk/
2024-07-19 13:18:24 +00:00
Fjuro
ec4c79eb69 Translated using Weblate (Czech)
Currently translated at 100.0% (1321 of 1321 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/cs/
2024-07-19 13:18:24 +00:00
Balazs Toldi
0affa4a90d Update build.gradle
Bump version, version code and target sdk
2024-07-19 13:11:49 +02:00
Balazs Toldi
8ef3867610 Transparent branding images
This works better on light themes
2024-07-19 13:10:58 +02:00
Balazs Toldi
b9e61518a4 Improve video preview loading time
This commit improves the loading time of posts with videos on the feed.

Closes #242
2024-07-18 21:32:53 +02:00
SomeTr
706f51c4f5 Translated using Weblate (Ukrainian)
Currently translated at 100.0% (1316 of 1316 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/uk/
2024-07-18 12:07:58 +00:00
Bazsalanszky
30a2c1a9b9 Instance Blocking
This commit adds the ability to block/unblock instances from the instance view page.

Closes #231
2024-07-18 14:07:34 +02:00
Bazsalanszky
06315c55ad Add option to view instance of users/communities
This Commit adds an option to view the details of a users/communities instance, just like the instance info accessible from the navigation bar. #204
2024-07-18 11:09:22 +02:00
Bazsalanszky
42af7ee315 Fix user icons for the instance info page
The avatars were parsed incorrectly.
2024-07-18 10:46:36 +02:00
Bazsalanszky
f0d6abee5d Search to open link
This commit adds the ability to open posts from a URL by inserting it to the search menu.
2024-07-12 08:28:10 +02:00
Bazsalanszky
21861a5884 Added Comments to search results
This commit adds the ability to search for comments. It adds a new tab to the SearchResultActivity with a CommentsListingFragment. #241

This commit also fixes an issue where you can't upvote comments on when in a listing (e.g. on a profile, or now search)
2024-07-12 08:22:29 +02:00
Bazsalanszky
0fb834fb38 Minor pipeline change 2024-07-09 16:22:25 +02:00
Bazsalanszky
60155c4c6b Fix search sorting
Added all sorting options to the SearchResultActivity
2024-07-09 16:20:33 +02:00
Bazsalanszky
1ab8f31cbd Do not show display name when disabled
There was an issue where the display name of the user was
2024-07-09 15:54:51 +02:00
Bazsalanszky
ae5b3836e7 Fix unread message highlight in inbox
Previously, the mentions where incorrectly highlighted as unread in the Inbox activity (the read/unread messages were inverted). This commit fixes this issue.
2024-07-09 12:13:27 +02:00
Bazsalanszky
1cdd490789 Fix crash when adding a community to multi-communties
This commit fixes the issue where the app previously crashed when adding a community to a multi-community from search.
2024-07-09 12:13:27 +02:00
30p87
e96a89d430 Translated using Weblate (German)
Currently translated at 100.0% (1315 of 1315 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/de/
2024-07-07 14:18:24 +00:00
Bazsalanszky
c606a29e79 Added Lemmy badge to README 2024-07-04 18:18:06 +00:00
trlef19
afd8223eb4 Translated using Weblate (Greek)
Currently translated at 99.5% (1309 of 1315 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/el/
2024-07-03 10:18:29 +00:00
SomeTr
a39ee994ff Translated using Weblate (Ukrainian)
Currently translated at 100.0% (1315 of 1315 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/uk/
2024-07-03 10:18:26 +00:00
SomeTr
e25e258d48 Translated using Weblate (Ukrainian)
Currently translated at 100.0% (1315 of 1315 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/uk/
2024-07-01 10:18:26 +00:00
0ko
1e8a60aeb9 Translated using Weblate (Russian)
Currently translated at 98.4% (1295 of 1315 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/ru/
2024-07-01 10:18:25 +00:00
Fjuro
27f3807a69 Translated using Weblate (Czech)
Currently translated at 100.0% (1315 of 1315 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/cs/
2024-07-01 10:18:25 +00:00
Balazs Toldi
49961c215a Remove FAB from blocked instances page 2024-06-30 20:19:11 +02:00
Balazs Toldi
b0cbecbdc5 Remove score from user pages
This has been removed from lemmy. No longer needed.
2024-06-30 11:32:33 +02:00
Balazs Toldi
1276435494 View blocked instances
This commit adds the instances page to the blocks activity to display the instances blocked by the user.
2024-06-30 10:53:45 +02:00
Balazs Toldi
b68bf50359 Added handling for unauthorized responses when validating an auth token.
Previously, any unsuccessful response would trigger the onValidateAuthTokenFailed callback. Now, if the response is 401 Unauthorized (indicating an invalid token), the onValidateAuthTokenFailed callback will be called. Other errors are still ignored.
2024-06-28 09:21:04 +02:00
Balazs Toldi
ae125feae0 Adjust markPostAsRead to Lemmy 0.19.4 2024-06-23 14:32:18 +02:00
Balazs Toldi
03c1792262 Don't hide read posts on saved page
This commit fixes the issue where if the option to hide read posts from the feed is activated, no posts show up in the saved section.

Fixes #219.
2024-06-23 14:18:17 +02:00
Balazs Toldi
6c3d26fe5a Fix comment loading from inbox
There was an issue where if you load comments from a post, it will not display them initially. They would only appear after a refresh. Now it has been fixed, and comments are loaded immediately.
2024-06-21 22:36:00 +02:00
Balazs Toldi
1373b4cb40 Fix crash 2024-06-21 22:19:57 +02:00
Balazs Toldi
ae389527b6 Removed "Community Recommended Sort type" option
Caused some issues, described in #151. Also, this is not a feature in Lemmy, should have been removed anyway.
2024-06-21 21:19:45 +02:00
C1ff0
1390460438 Translated using Weblate (Italian)
Currently translated at 89.1% (1171 of 1313 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/it/
2024-05-25 13:18:24 +00:00
SomeTr
0674934366 Translated using Weblate (Ukrainian)
Currently translated at 100.0% (1313 of 1313 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/uk/
2024-05-24 09:18:23 +00:00
SomeTr
dbc0effe61 Translated using Weblate (Ukrainian)
Currently translated at 99.9% (1312 of 1313 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/uk/
2024-03-18 17:53:35 +00:00
mochichi
f0cf65a5a4 Translated using Weblate (Japanese)
Currently translated at 75.7% (995 of 1313 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/ja/
2024-03-12 18:53:34 +00:00
v1s7
5696c9e7a8 Translated using Weblate (Russian)
Currently translated at 98.4% (1293 of 1313 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/ru/
2024-03-11 04:46:30 +00:00
Integral
3c871e2678 Translated using Weblate (Chinese (Simplified))
Currently translated at 98.0% (1288 of 1313 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/zh_Hans/
2024-02-27 09:56:33 +00:00
SomeTr
f4d61ee8dc Translated using Weblate (Ukrainian)
Currently translated at 99.9% (1312 of 1313 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/uk/
2024-02-26 08:56:33 +00:00
dogasert01
e7d434458d Translated using Weblate (Turkish)
Currently translated at 85.8% (1127 of 1313 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/tr/
2024-02-26 08:56:33 +00:00
jaahas
00568cfd37 Translated using Weblate (Finnish)
Currently translated at 51.2% (673 of 1313 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/fi/
2024-02-24 14:56:33 +00:00
Application-Maker
237894892d Translated using Weblate (Russian)
Currently translated at 98.4% (1293 of 1313 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/ru/
2024-02-22 12:56:33 +00:00
Dirk
62bf37e9c3 Translated using Weblate (German)
Currently translated at 100.0% (1313 of 1313 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/de/
2024-02-22 12:56:32 +00:00
Integral
4be9a409ec Translated using Weblate (Chinese (Simplified))
Currently translated at 97.7% (1283 of 1313 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/zh_Hans/
2024-02-21 10:56:33 +00:00
Dirk
85d94d91c0 Translated using Weblate (German)
Currently translated at 100.0% (1313 of 1313 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/de/
2024-02-21 10:56:33 +00:00
Integral
af4b0cc65e Translated using Weblate (Chinese (Simplified))
Currently translated at 96.1% (1263 of 1313 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/zh_Hans/
2024-02-20 09:56:33 +00:00
0que
1f8f44af57 Translated using Weblate (Russian)
Currently translated at 98.4% (1292 of 1313 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/ru/
2024-02-03 17:56:34 +00:00
gallegonovato
f3db563550 Translated using Weblate (Spanish)
Currently translated at 87.9% (1155 of 1313 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/es/
2024-01-31 17:56:33 +00:00
Application-Maker
0aeaa8fb93 Translated using Weblate (Russian)
Currently translated at 98.3% (1291 of 1313 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/ru/
2024-01-29 00:56:32 +00:00
coper
213856a1eb Translated using Weblate (Spanish)
Currently translated at 87.8% (1154 of 1313 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/es/
2024-01-29 00:56:32 +00:00
Application-Maker
bc1cd27dd4 Translated using Weblate (Russian)
Currently translated at 98.6% (1295 of 1313 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/ru/
2024-01-26 20:56:33 +00:00
Hiajen
2f9d45bed3 Translated using Weblate (German)
Currently translated at 95.0% (1248 of 1313 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/de/
2024-01-24 20:56:34 +00:00
Application-Maker
bf5937da63 Translated using Weblate (Russian)
Currently translated at 98.6% (1295 of 1313 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/ru/
2024-01-22 08:01:41 +00:00
0que
d04f0c296c Translated using Weblate (Russian)
Currently translated at 98.5% (1294 of 1313 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/ru/
2024-01-20 16:56:33 +00:00
onemorebug
ad2a1f5bf5 Translated using Weblate (German)
Currently translated at 94.8% (1245 of 1313 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/de/
2024-01-17 16:56:33 +00:00
SomeTr
72a8f88738 Translated using Weblate (Ukrainian)
Currently translated at 99.8% (1311 of 1313 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/uk/
2024-01-07 12:49:12 +00:00
Bazsalanszky
3668466ee6 Translated using Weblate (Hungarian)
Currently translated at 82.7% (1087 of 1313 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/hu/
2024-01-07 12:49:12 +00:00
Fjuro
cecb218278 Translated using Weblate (Czech)
Currently translated at 100.0% (1313 of 1313 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/cs/
2024-01-07 12:49:12 +00:00
Balazs Toldi
8cf911685a Merge remote-tracking branch 'origin/master'
# Conflicts:
#	app/src/main/java/eu/toldi/infinityforlemmy/activities/MainActivity.java
2024-01-06 21:53:14 +01:00
Balazs Toldi
07fbb103e7 Fix loading block page
Closes #228
2024-01-06 21:52:13 +01:00
Balazs Toldi
3195f05e56 Only check token for logged in users 2024-01-06 21:42:57 +01:00
SomeTr
67da6b1c53 Translated using Weblate (Ukrainian)
Currently translated at 99.8% (1311 of 1313 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/uk/
2024-01-06 20:18:37 +00:00
tinsukE
0662173045 Allow login with email (#239)
While the call to obtain a JWT (`api/v3/user/login`) works for username or email, the app was then following that with a call to ` api/v3/user`, which only works with username (https://lemmy.readme.io/reference/get_user). This would cause the login attempt to fail with the error reported on #235.

These changes skip the call to `api/v3/user`, and instead retrieves the user information from the call to `api/v3/site`, that was already being performed.

Fixes #235.

Question: should the label of the username field be updated to "Username / Email" or "Username or Email"? (screenshot)

Reviewed-on: https://codeberg.org/Bazsalanszky/Eternity/pulls/239
Reviewed-by: Bazsalanszky <bazsalanszky@noreply.codeberg.org>
Co-authored-by: tinsukE <tinsuke@noreply.codeberg.org>
Co-committed-by: tinsukE <tinsuke@noreply.codeberg.org>
2024-01-06 20:18:32 +00:00
0que
3d5c936fa3 Translated using Weblate (Russian)
Currently translated at 98.5% (1292 of 1311 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/ru/
2024-01-06 10:40:09 +00:00
Balazs Toldi
e7f84b8aed Better realization of a Lemmy upgrade 2024-01-06 11:40:00 +01:00
Balazs Toldi
ba5b533cb9 Added "Most comments" and "new comments" sort type 2024-01-06 11:39:33 +01:00
Balazs Toldi
133dc4a69c Fix "Old" sort type for multi communities 2024-01-06 11:20:30 +01:00
Balazs Toldi
0fd7203fa3 Multi communities (#209)
Reviewed-on: https://codeberg.org/Bazsalanszky/Eternity/pulls/209
Co-authored-by: Balazs Toldi <balazs@toldi.eu>
Co-committed-by: Balazs Toldi <balazs@toldi.eu>
2024-01-06 10:18:16 +00:00
SomeTr
1a1b92bb72 Translated using Weblate (Ukrainian)
Currently translated at 99.9% (1310 of 1311 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/uk/
2024-01-05 10:43:51 +00:00
Bazsalanszky
715f371440 Translated using Weblate (Hungarian)
Currently translated at 82.9% (1087 of 1311 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/hu/
2024-01-05 10:43:51 +00:00
Fjuro
b1164921a0 Translated using Weblate (Czech)
Currently translated at 100.0% (1311 of 1311 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/cs/
2024-01-05 10:43:51 +00:00
Balazs Toldi
b69245aedc Fix shortcut login issues
Fix issues with home screen shortcuts not logging the user in properly
2024-01-04 19:12:18 +01:00
Balazs Toldi
3dc94a05c7 Remove report option from User pages
This was a reddit feature that is unavailable on Lemmy. Closes #211
2024-01-04 15:02:27 +01:00
Balazs Toldi
d0849e9f27 Fix pull down refresh on Post detail pages
The refresh function was incorrectly called, making the loading progress not stopping at all (actually it didn't even start properly)
2024-01-04 14:51:54 +01:00
Balazs Toldi
2ea47cf7fd Changed intent filter from www.hexbear.net to hexbear.net
Fixes #237
2024-01-04 11:06:55 +01:00
Balazs Toldi
6d23f4e13d Merge remote-tracking branch 'origin/master' 2024-01-04 11:04:26 +01:00
Bazsalanszky
02bed2eb3b Merge pull request 'Remove Gfycat support (the service is dead), simplifying the code' (#226) from tinsukE/Eternity:remove_gfycat into master
Reviewed-on: https://codeberg.org/Bazsalanszky/Eternity/pulls/226
Reviewed-by: Bazsalanszky <bazsalanszky@noreply.codeberg.org>
2024-01-03 13:39:39 +00:00
Bazsalanszky
84653d7677 Merge pull request 'Add previews to video (MP4, WEBM) posts' (#225) from tinsukE/Eternity:video-preview into master
Reviewed-on: https://codeberg.org/Bazsalanszky/Eternity/pulls/225
Reviewed-by: Bazsalanszky <bazsalanszky@noreply.codeberg.org>
2024-01-03 13:39:25 +00:00
tinsukE
103ab039b3 Remove Gfycat support (the service is dead), simplifying the code 2024-01-03 09:39:53 +01:00
Sergio Varela
b684542e42 Translated using Weblate (Spanish)
Currently translated at 87.9% (1153 of 1311 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/es/
2023-11-28 16:38:27 +00:00
Sergio Varela
a1d78271fa Translated using Weblate (Spanish)
Currently translated at 85.9% (1127 of 1311 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/es/
2023-11-23 16:13:37 +00:00
tinsukE
1c75710424 Add previews to video (MP4, WEBM) posts 2023-11-22 08:02:21 +00:00
alextecplayz
89583cfe29 Translated using Weblate (Romanian)
Currently translated at 100.0% (1311 of 1311 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/ro/
2023-11-20 11:13:38 +00:00
0que
8e0b599b09 Translated using Weblate (Russian)
Currently translated at 98.6% (1293 of 1311 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/ru/
2023-11-17 16:13:37 +00:00
SomeTr
b8eda72d7b Translated using Weblate (Ukrainian)
Currently translated at 100.0% (1311 of 1311 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/uk/
2023-11-13 17:13:38 +00:00
0que
c0f483e570 Translated using Weblate (Russian)
Currently translated at 97.2% (1275 of 1311 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/ru/
2023-11-13 17:13:37 +00:00
230 changed files with 4863 additions and 4175 deletions

View File

@@ -1,13 +1,13 @@
steps:
build:
image: alvrme/alpine-android:android-33-jdk11
image: alvrme/alpine-android:android-34-jdk17
commands:
- apk add --no-cache python3
- ./gradlew :app:assembleRelease
when:
path: [ app/**, build.gradle ]
sign:
image: alvrme/alpine-android:android-33-jdk11
image: alvrme/alpine-android:android-34-jdk17
commands:
- ./scripts/apk-sign.sh Eternity-signed.apk app/build/outputs/apk/release/app-release-unsigned.apk
secrets: [ APK_KS_PASS, APK_KS, APK_KS_ALIAS ]
@@ -23,7 +23,7 @@ steps:
from_secret: GITEA_ACCESS_TOKEN
target: main
prerelease: true
note: "This is an alpha release. Expect many bugs and unfinished features!"
note: "Pending release notes..."
when:
event: [ tag ]
when:

View File

@@ -6,12 +6,12 @@ clone:
steps:
build:
image: alvrme/alpine-android:android-33-jdk11
image: alvrme/alpine-android:android-34-jdk17
commands:
- apk add --no-cache python3
- ./gradlew :app:assembleNightly
sign:
image: alvrme/alpine-android:android-33-jdk11
image: alvrme/alpine-android:android-34-jdk17
commands:
- ./scripts/apk-sign.sh eu.toldi.infinityforlemmy.nightly.apk app/build/outputs/apk/nightly/eu.toldi.infinityforlemmy.nightly.apk
secrets: [ APK_KS_PASS, APK_KS, APK_KS_ALIAS ]

View File

@@ -14,6 +14,7 @@ A Lemmy client for Android written in Java. It's a fork of the [Infinity for Red
[![status-badge](https://ci.codeberg.org/api/badges/12474/status.svg)](https://ci.codeberg.org/repos/12474)
[![Liberapay patrons](https://img.shields.io/liberapay/patrons/bazsalanszky)](https://liberapay.com/Bazsalanszky)
[![Lemmy Community](https://img.shields.io/lemmy/eternityapp@lemdro.id?style=flat-square&logo=lemmy&label=lemmy)](https://lemdro.id/c/eternityapp)
<a href="https://codeberg.org/Bazsalanszky/Eternity/issues">Report a Bug</a>

View File

@@ -16,13 +16,13 @@ def getCommitVersionCode = { ->
}
android {
compileSdk 33
compileSdk 34
defaultConfig {
applicationId "eu.toldi.infinityforlemmy"
minSdk 21
targetSdk 33
versionCode 131
versionName "0.1.2"
targetSdk 34
versionCode 136
versionName "0.2.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
javaCompileOptions {
annotationProcessorOptions {
@@ -245,6 +245,7 @@ dependencies {
implementation "io.noties.markwon:simple-ext:$markwonVersion"
implementation "io.noties.markwon:inline-parser:$markwonVersion"
implementation "io.noties.markwon:image-glide:$markwonVersion"
implementation "io.noties.markwon:html:$markwonVersion"
implementation 'com.atlassian.commonmark:commonmark-ext-gfm-tables:0.14.0'
implementation 'me.saket:better-link-movement-method:2.2.0'
@@ -254,8 +255,6 @@ dependencies {
// Loading ProgressBar
implementation 'com.lsjwzh:materialloadingprogressbar:0.5.8-RELEASE'
// Customizable TextView
implementation 'com.libRG:customtextview:2.4'
// Dismiss gesturing
implementation 'app.futured.hauler:hauler:5.0.0'

View File

@@ -17,6 +17,7 @@
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="22" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC"/>
<uses-permission-sdk-23
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
@@ -59,10 +60,10 @@
android:parentActivityName=".activities.SettingsActivity"
android:theme="@style/AppTheme.NoActionBar"
android:exported="false" />
<activity
android:name=".activities.HistoryActivity"
android:exported="false"
android:label="@string/history_activity_label"
android:name=".activities.BlockedThingListingActivity"
android:label="@string/blocks"
android:parentActivityName=".activities.MainActivity"
android:theme="@style/AppTheme.Slidable" />
<activity
@@ -135,11 +136,7 @@
android:name=".activities.FetchRandomSubredditOrPostActivity"
android:parentActivityName=".activities.MainActivity"
android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name=".activities.GiveAwardActivity"
android:label="@string/give_award_activity_label"
android:parentActivityName=".activities.MainActivity"
android:theme="@style/AppTheme.Slidable" />
<activity
android:name=".activities.SelectUserFlairActivity"
android:parentActivityName=".activities.MainActivity"
@@ -158,6 +155,7 @@
<service
android:name=".services.DownloadMediaService"
android:enabled="true"
android:foregroundServiceType="dataSync"
android:exported="false" />
<activity
@@ -175,6 +173,7 @@
<service
android:name=".services.DownloadRedditVideoService"
android:enabled="true"
android:foregroundServiceType="dataSync"
android:exported="false" />
<activity
@@ -323,7 +322,7 @@
<data android:host="feddit.de" />
<data android:host="lemmy.fmhy.ml" />
<data android:host="lemmy.ca" />
<data android:host="www.hexbear.net" />
<data android:host="hexbear.net" />
<data android:host="programming.dev" />
<data android:host="lemmy.dbzer0.com" />
<data android:host="lemmy.blahaj.zone" />
@@ -537,10 +536,12 @@
<service
android:name=".services.SubmitPostService"
android:enabled="true"
android:foregroundServiceType="dataSync"
android:exported="false" />
<service
android:name=".services.EditProfileService"
android:enabled="true"
android:foregroundServiceType="dataSync"
android:exported="false" />
<receiver android:name=".broadcastreceivers.DownloadedMediaDeleteActionBroadcastReceiver" />

View File

@@ -74,6 +74,7 @@ import eu.toldi.infinityforlemmy.bottomsheetfragments.AccountChooserBottomSheetF
import eu.toldi.infinityforlemmy.bottomsheetfragments.CommentMoreBottomSheetFragment;
import eu.toldi.infinityforlemmy.bottomsheetfragments.FlairBottomSheetFragment;
import eu.toldi.infinityforlemmy.fragments.BlockedCommunitiesListingFragment;
import eu.toldi.infinityforlemmy.fragments.BlockedInstancesListingFragment;
import eu.toldi.infinityforlemmy.fragments.BlockedUsersListingFragment;
import eu.toldi.infinityforlemmy.fragments.CommentsListingFragment;
import eu.toldi.infinityforlemmy.fragments.FollowedUsersListingFragment;
@@ -318,6 +319,8 @@ public interface AppComponent {
void inject(BlockedUsersListingFragment blockedUsersListingFragment);
void inject(BlockedInstancesListingFragment blockedInstancesListingFragment);
void inject(CommentMoreBottomSheetFragment commentMoreBottomSheetFragment);
void inject(PrivateMessageFragment privateMessageFragment);

View File

@@ -0,0 +1,85 @@
package eu.toldi.infinityforlemmy;
import android.content.Context;
import android.graphics.drawable.GradientDrawable;
import android.util.AttributeSet;
import androidx.appcompat.widget.AppCompatTextView;
import android.content.res.TypedArray;
public class CustomTextView extends AppCompatTextView {
private float radius = 6f;
private boolean roundedView = true;
private int shape = 0;
public CustomTextView(Context context) {
super(context);
init(null);
}
public CustomTextView(Context context, AttributeSet attrs) {
super(context, attrs);
init(attrs);
}
public CustomTextView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init(attrs);
}
private void init(AttributeSet attrs) {
if (attrs != null) {
TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.CustomTextView);
radius = a.getDimension(R.styleable.CustomTextView_lib_setRadius, radius);
roundedView = a.getBoolean(R.styleable.CustomTextView_lib_setRoundedView, roundedView);
shape = a.getInt(R.styleable.CustomTextView_lib_setShape, shape);
a.recycle();
}
updateBackground();
}
private void updateBackground() {
GradientDrawable drawable = new GradientDrawable();
if (shape == 0) { // Rectangle
drawable.setShape(GradientDrawable.RECTANGLE);
} else if (shape == 1) { // Oval
drawable.setShape(GradientDrawable.OVAL);
}
if (roundedView) {
drawable.setCornerRadius(radius);
} else {
drawable.setCornerRadius(0);
}
this.setBackground(drawable);
}
public void setBackgroundColor(int color) {
GradientDrawable background = (GradientDrawable) this.getBackground();
background.setColor(color);
this.setBackground(background);
}
public void setBorderColor(int borderColor, int borderWidthDp) {
GradientDrawable background = (GradientDrawable) this.getBackground();
background.setStroke(dpToPx(borderWidthDp), borderColor);
this.setBackground(background);
}
public void setBorderColor(int borderColor) {
this.setBorderColor(borderColor, 1);
}
private int dpToPx(int dp) {
float density = getContext().getResources().getDisplayMetrics().density;
return Math.round(dp * density);
}
}

View File

@@ -0,0 +1,78 @@
package eu.toldi.infinityforlemmy;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import androidx.annotation.Nullable;
public class DualBadgeDrawable extends Drawable {
private Drawable leftBadge;
private Drawable rightBadge;
public DualBadgeDrawable(Drawable leftBadge, Drawable rightBadge) {
this.leftBadge = leftBadge;
this.rightBadge = rightBadge;
}
@Override
public void draw(Canvas canvas) {
if (leftBadge == null || rightBadge == null) {
return;
}
int width = getBounds().width();
int height = getBounds().height();
// Draw the left badge on the left half of the canvas
Rect leftRect = new Rect(0, 0, width / 2, height);
leftBadge.setBounds(leftRect);
leftBadge.draw(canvas);
// Draw the right badge on the right half of the canvas
Rect rightRect = new Rect(width / 2, 0, width, height);
rightBadge.setBounds(rightRect);
rightBadge.draw(canvas);
}
@Override
public void setAlpha(int alpha) {
if (leftBadge != null) {
leftBadge.setAlpha(alpha);
}
if (rightBadge != null) {
rightBadge.setAlpha(alpha);
}
}
@Override
public void setColorFilter(@Nullable ColorFilter colorFilter) {
if (leftBadge != null) {
leftBadge.setColorFilter(colorFilter);
}
if (rightBadge != null) {
rightBadge.setColorFilter(colorFilter);
}
}
@Override
public int getOpacity() {
return leftBadge != null ? leftBadge.getOpacity() : rightBadge.getOpacity();
}
@Override
public int getIntrinsicWidth() {
int leftWidth = leftBadge != null ? leftBadge.getIntrinsicWidth() : 0;
int rightWidth = rightBadge != null ? rightBadge.getIntrinsicWidth() : 0;
return leftWidth + rightWidth;
}
@Override
public int getIntrinsicHeight() {
int leftHeight = leftBadge != null ? leftBadge.getIntrinsicHeight() : 0;
int rightHeight = rightBadge != null ? rightBadge.getIntrinsicHeight() : 0;
return Math.max(leftHeight, rightHeight);
}
}

View File

@@ -1,129 +0,0 @@
package eu.toldi.infinityforlemmy;
import android.os.Handler;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.IOException;
import java.util.concurrent.Executor;
import eu.toldi.infinityforlemmy.apis.GfycatAPI;
import eu.toldi.infinityforlemmy.apis.RedgifsAPI;
import eu.toldi.infinityforlemmy.utils.JSONUtils;
import retrofit2.Call;
import retrofit2.Response;
import retrofit2.Retrofit;
public class FetchGfycatOrRedgifsVideoLinks {
public interface FetchGfycatOrRedgifsVideoLinksListener {
void success(String webm, String mp4);
void failed(int errorCode);
}
public static void fetchGfycatVideoLinks(Executor executor, Handler handler, Retrofit gfycatRetrofit,
String gfycatId,
FetchGfycatOrRedgifsVideoLinksListener fetchGfycatOrRedgifsVideoLinksListener) {
executor.execute(() -> {
try {
Response<String> response = gfycatRetrofit.create(GfycatAPI.class).getGfycatData(gfycatId).execute();
if (response.isSuccessful()) {
parseGfycatVideoLinks(handler, response.body(), fetchGfycatOrRedgifsVideoLinksListener);
} else {
handler.post(() -> fetchGfycatOrRedgifsVideoLinksListener.failed(response.code()));
}
} catch (IOException e) {
e.printStackTrace();
handler.post(() -> fetchGfycatOrRedgifsVideoLinksListener.failed(-1));
}
});
}
public static void fetchRedgifsVideoLinks(Executor executor, Handler handler, Retrofit redgifsRetrofit,
String gfycatId,
FetchGfycatOrRedgifsVideoLinksListener fetchGfycatOrRedgifsVideoLinksListener) {
executor.execute(() -> {
try {
Response<String> response = redgifsRetrofit.create(RedgifsAPI.class).getRedgifsData(gfycatId).execute();
if (response.isSuccessful()) {
parseRedgifsVideoLinks(handler, response.body(), fetchGfycatOrRedgifsVideoLinksListener);
} else {
handler.post(() -> fetchGfycatOrRedgifsVideoLinksListener.failed(response.code()));
}
} catch (IOException e) {
e.printStackTrace();
handler.post(() -> fetchGfycatOrRedgifsVideoLinksListener.failed(-1));
}
});
}
public static void fetchGfycatOrRedgifsVideoLinksInRecyclerViewAdapter(Executor executor, Handler handler,
Call<String> gfycatCall,
boolean isGfycatVideo,
boolean automaticallyTryRedgifs,
FetchGfycatOrRedgifsVideoLinksListener fetchGfycatOrRedgifsVideoLinksListener) {
executor.execute(() -> {
try {
Response<String> response = gfycatCall.execute();
if (response.isSuccessful()) {
if (isGfycatVideo) {
parseGfycatVideoLinks(handler, response.body(), fetchGfycatOrRedgifsVideoLinksListener);
} else {
parseRedgifsVideoLinks(handler, response.body(), fetchGfycatOrRedgifsVideoLinksListener);
}
} else {
if (response.code() == 404 && isGfycatVideo && automaticallyTryRedgifs) {
fetchGfycatOrRedgifsVideoLinksInRecyclerViewAdapter(executor, handler, gfycatCall.clone(),
false, false, fetchGfycatOrRedgifsVideoLinksListener);
} else {
handler.post(() -> fetchGfycatOrRedgifsVideoLinksListener.failed(response.code()));
}
}
} catch (IOException e) {
e.printStackTrace();
handler.post(() -> fetchGfycatOrRedgifsVideoLinksListener.failed(-1));
}
});
}
private static void parseGfycatVideoLinks(Handler handler, String response,
FetchGfycatOrRedgifsVideoLinksListener fetchGfycatOrRedgifsVideoLinksListener) {
try {
JSONObject jsonObject = new JSONObject(response);
String mp4 = jsonObject.getJSONObject(JSONUtils.GFY_ITEM_KEY).has(JSONUtils.MP4_URL_KEY) ?
jsonObject.getJSONObject(JSONUtils.GFY_ITEM_KEY).getString(JSONUtils.MP4_URL_KEY)
: jsonObject.getJSONObject(JSONUtils.GFY_ITEM_KEY)
.getJSONObject(JSONUtils.CONTENT_URLS_KEY)
.getJSONObject(JSONUtils.MP4_KEY)
.getString(JSONUtils.URL_KEY);
String webm;
if (jsonObject.getJSONObject(JSONUtils.GFY_ITEM_KEY).has(JSONUtils.WEBM_URL_KEY)) {
webm = jsonObject.getJSONObject(JSONUtils.GFY_ITEM_KEY).getString(JSONUtils.WEBM_URL_KEY);
} else if (jsonObject.getJSONObject(JSONUtils.GFY_ITEM_KEY).getJSONObject(JSONUtils.CONTENT_URLS_KEY).has(JSONUtils.WEBM_KEY)) {
webm = jsonObject.getJSONObject(JSONUtils.GFY_ITEM_KEY)
.getJSONObject(JSONUtils.CONTENT_URLS_KEY)
.getJSONObject(JSONUtils.WEBM_KEY)
.getString(JSONUtils.URL_KEY);
} else {
webm = mp4;
}
handler.post(() -> fetchGfycatOrRedgifsVideoLinksListener.success(webm, mp4));
} catch (JSONException e) {
e.printStackTrace();
handler.post(() -> fetchGfycatOrRedgifsVideoLinksListener.failed(-1));
}
}
private static void parseRedgifsVideoLinks(Handler handler, String response,
FetchGfycatOrRedgifsVideoLinksListener fetchGfycatOrRedgifsVideoLinksListener) {
try {
String mp4 = new JSONObject(response).getJSONObject(JSONUtils.GIF_KEY).getJSONObject(JSONUtils.URLS_KEY)
.getString(JSONUtils.HD_KEY);
handler.post(() -> fetchGfycatOrRedgifsVideoLinksListener.success(mp4, mp4));
} catch (JSONException e) {
e.printStackTrace();
handler.post(() -> fetchGfycatOrRedgifsVideoLinksListener.failed(-1));
}
}
}

View File

@@ -1,99 +0,0 @@
package eu.toldi.infinityforlemmy;
import android.os.AsyncTask;
import androidx.annotation.NonNull;
import org.json.JSONException;
import org.json.JSONObject;
import eu.toldi.infinityforlemmy.apis.LemmyAPI;
import eu.toldi.infinityforlemmy.utils.LemmyUtils;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Retrofit;
public class FetchMyInfo {
public static void fetchAccountInfo(final Retrofit retrofit, RedditDataRoomDatabase redditDataRoomDatabase,
String username,String accessToken, final FetchMyInfoListener fetchMyInfoListener) {
LemmyAPI api = retrofit.create(LemmyAPI.class);
Call<String> userInfo = api.userInfo(username,accessToken);
userInfo.enqueue(new Callback<String>() {
@Override
public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) {
if (response.isSuccessful()) {
new ParseAndSaveAccountInfoAsyncTask(response.body(), redditDataRoomDatabase, fetchMyInfoListener).execute();
} else {
fetchMyInfoListener.onFetchMyInfoFailed(false);
}
}
@Override
public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) {
fetchMyInfoListener.onFetchMyInfoFailed(false);
}
});
}
public interface FetchMyInfoListener {
void onFetchMyInfoSuccess(String name, String display_name,String profileImageUrl, String bannerImageUrl);
void onFetchMyInfoFailed(boolean parseFailed);
}
private static class ParseAndSaveAccountInfoAsyncTask extends AsyncTask<Void, Void, Void> {
private JSONObject jsonResponse;
private RedditDataRoomDatabase redditDataRoomDatabase;
private FetchMyInfoListener fetchMyInfoListener;
private boolean parseFailed;
private String name;
private String profileImageUrl;
private String bannerImageUrl;
private String display_name;
ParseAndSaveAccountInfoAsyncTask(String response, RedditDataRoomDatabase redditDataRoomDatabase,
FetchMyInfoListener fetchMyInfoListener) {
try {
jsonResponse = new JSONObject(response);
this.redditDataRoomDatabase = redditDataRoomDatabase;
this.fetchMyInfoListener = fetchMyInfoListener;
parseFailed = false;
} catch (JSONException e) {
fetchMyInfoListener.onFetchMyInfoFailed(true);
}
}
@Override
protected Void doInBackground(Void... voids) {
try {
JSONObject person = jsonResponse.getJSONObject("person_view").getJSONObject("person");
name = LemmyUtils.actorID2FullName(person.getString("actor_id"));
if (!person.isNull("avatar")) {
profileImageUrl = person.getString("avatar");
}
if (!person.isNull("banner")) {
bannerImageUrl = person.getString("banner");
}
display_name = (person.has("display_name")) ? person.getString("display_name") : person.getString("name");
redditDataRoomDatabase.accountDao().updateAccountInfo(name, profileImageUrl, bannerImageUrl);
} catch (JSONException e) {
parseFailed = true;
}
return null;
}
@Override
protected void onPostExecute(Void aVoid) {
if (!parseFailed) {
fetchMyInfoListener.onFetchMyInfoSuccess(name,display_name, profileImageUrl, bannerImageUrl);
} else {
fetchMyInfoListener.onFetchMyInfoFailed(true);
}
}
}
}

View File

@@ -49,7 +49,7 @@ public class FetchPostFilterReadPostsAndConcatenatedSubredditNames {
if (anonymousSubscribedSubreddits != null && !anonymousSubscribedSubreddits.isEmpty()) {
StringBuilder stringBuilder = new StringBuilder();
for (SubscribedSubredditData s : anonymousSubscribedSubreddits) {
stringBuilder.append(s.getName()).append("+");
stringBuilder.append(s.getQualified_name()).append(",");
}
if (stringBuilder.length() > 0) {
stringBuilder.deleteCharAt(stringBuilder.length() - 1);

View File

@@ -0,0 +1,71 @@
package eu.toldi.infinityforlemmy;
import android.os.Handler;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.IOException;
import java.util.concurrent.Executor;
import eu.toldi.infinityforlemmy.apis.RedgifsAPI;
import eu.toldi.infinityforlemmy.utils.JSONUtils;
import retrofit2.Call;
import retrofit2.Response;
import retrofit2.Retrofit;
public class FetchRedgifsVideoLinks {
public interface FetchRedgifsVideoLinksListener {
void success(String webm, String mp4);
void failed(int errorCode);
}
public static void fetchRedgifsVideoLinks(Executor executor, Handler handler, Retrofit redgifsRetrofit,
String redgifsId,
FetchRedgifsVideoLinksListener fetchRedgifsVideoLinksListener) {
executor.execute(() -> {
try {
Response<String> response = redgifsRetrofit.create(RedgifsAPI.class).getRedgifsData(redgifsId).execute();
if (response.isSuccessful()) {
parseRedgifsVideoLinks(handler, response.body(), fetchRedgifsVideoLinksListener);
} else {
handler.post(() -> fetchRedgifsVideoLinksListener.failed(response.code()));
}
} catch (IOException e) {
e.printStackTrace();
handler.post(() -> fetchRedgifsVideoLinksListener.failed(-1));
}
});
}
public static void fetchRedgifsVideoLinksInRecyclerViewAdapter(Executor executor, Handler handler,
Call<String> redgifsCall,
FetchRedgifsVideoLinksListener fetchRedgifsVideoLinksListener) {
executor.execute(() -> {
try {
Response<String> response = redgifsCall.execute();
if (response.isSuccessful()) {
parseRedgifsVideoLinks(handler, response.body(), fetchRedgifsVideoLinksListener);
} else {
handler.post(() -> fetchRedgifsVideoLinksListener.failed(response.code()));
}
} catch (IOException e) {
e.printStackTrace();
handler.post(() -> fetchRedgifsVideoLinksListener.failed(-1));
}
});
}
private static void parseRedgifsVideoLinks(Handler handler, String response,
FetchRedgifsVideoLinksListener fetchRedgifsVideoLinksListener) {
try {
String mp4 = new JSONObject(response).getJSONObject(JSONUtils.GIF_KEY).getJSONObject(JSONUtils.URLS_KEY)
.getString(JSONUtils.HD_KEY);
handler.post(() -> fetchRedgifsVideoLinksListener.success(mp4, mp4));
} catch (JSONException e) {
e.printStackTrace();
handler.post(() -> fetchRedgifsVideoLinksListener.failed(-1));
}
}
}

View File

@@ -143,15 +143,6 @@ abstract class NetworkModule {
.build();
}
@Provides
@Named("gfycat")
@Singleton
static Retrofit provideGfycatRetrofit(@Named("base") RetrofitHolder retrofit) {
return retrofit.getRetrofit().newBuilder()
.baseUrl(APIUtils.GFYCAT_API_BASE_URI)
.build();
}
@Provides
@Named("RedgifsAccessTokenAuthenticator")
static Interceptor redgifsAccessTokenAuthenticator(@Named("current_account") SharedPreferences currentAccountSharedPreferences) {

View File

@@ -10,6 +10,7 @@ import eu.toldi.infinityforlemmy.post.enrich.CompositePostEnricher;
import eu.toldi.infinityforlemmy.post.enrich.PostEnricher;
import eu.toldi.infinityforlemmy.post.enrich.RedGifsPostEnricher;
@Module
abstract class PostEnricherModule {

View File

@@ -15,6 +15,8 @@ import eu.toldi.infinityforlemmy.account.Account;
import eu.toldi.infinityforlemmy.account.AccountDao;
import eu.toldi.infinityforlemmy.blockedcommunity.BlockedCommunityDao;
import eu.toldi.infinityforlemmy.blockedcommunity.BlockedCommunityData;
import eu.toldi.infinityforlemmy.blockedinstances.BlockedInstanceDao;
import eu.toldi.infinityforlemmy.blockedinstances.BlockedInstanceData;
import eu.toldi.infinityforlemmy.blockeduser.BlockedUserDao;
import eu.toldi.infinityforlemmy.blockeduser.BlockedUserData;
import eu.toldi.infinityforlemmy.commentfilter.CommentFilter;
@@ -47,7 +49,7 @@ import eu.toldi.infinityforlemmy.user.UserData;
@Database(entities = {Account.class, SubredditData.class, SubscribedSubredditData.class, UserData.class,
SubscribedUserData.class, MultiReddit.class, CustomTheme.class, RecentSearchQuery.class,
ReadPost.class, PostFilter.class, PostFilterUsage.class, AnonymousMultiredditSubreddit.class,
BlockedUserData.class, BlockedCommunityData.class, CommentFilter.class, CommentFilterUsage.class}, version = 28)
BlockedUserData.class, BlockedCommunityData.class, BlockedInstanceData.class, CommentFilter.class, CommentFilterUsage.class}, version = 30)
public abstract class RedditDataRoomDatabase extends RoomDatabase {
public static RedditDataRoomDatabase create(final Context context) {
@@ -58,7 +60,9 @@ public abstract class RedditDataRoomDatabase extends RoomDatabase {
MIGRATION_9_10, MIGRATION_10_11, MIGRATION_11_12, MIGRATION_12_13,
MIGRATION_13_14, MIGRATION_14_15, MIGRATION_15_16, MIGRATION_16_17,
MIGRATION_17_18, MIGRATION_18_19, MIGRATION_19_20, MIGRATION_20_21,
MIGRATION_21_22, MIGRATION_22_23, MIGRATION_23_24, MIGRATION_24_25, MIGRATION_25_26, MIGRATION_26_27, MIGRATION_27_28)
MIGRATION_21_22, MIGRATION_22_23, MIGRATION_23_24, MIGRATION_24_25,
MIGRATION_25_26, MIGRATION_26_27, MIGRATION_27_28, MIGRATION_28_29,
MIGRATION_29_30)
.build();
}
@@ -72,6 +76,8 @@ public abstract class RedditDataRoomDatabase extends RoomDatabase {
public abstract BlockedCommunityDao blockedCommunityDao();
public abstract BlockedInstanceDao blockedInstanceDao();
public abstract UserDao userDao();
public abstract SubscribedUserDao subscribedUserDao();
@@ -445,4 +451,23 @@ public abstract class RedditDataRoomDatabase extends RoomDatabase {
"name_of_usage TEXT NOT NULL, PRIMARY KEY(name, usage, name_of_usage), FOREIGN KEY(name) REFERENCES comment_filter(name) ON DELETE CASCADE)");
}
};
private static final Migration MIGRATION_28_29 = new Migration(28, 29) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase database) {
database.execSQL("CREATE TABLE blocked_instances" +
"(domain TEXT, id INTEGER NOT NULL, account_name TEXT NOT NULL, PRIMARY KEY( id, account_name))");
}
};
private static final Migration MIGRATION_29_30 = new Migration(29, 30) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase database) {
// Alter table "blocked_instances" to add new columns "instance_name" and "icon"
database.execSQL("ALTER TABLE blocked_instances ADD COLUMN instance_name TEXT");
database.execSQL("ALTER TABLE blocked_instances ADD COLUMN icon TEXT");
}
};
}

View File

@@ -35,8 +35,8 @@ public class SortType {
NEW("New", "New"),
OLD("Old", "Old"),
TOP("Top", "Top"),
MOST_COMMENTS("MostCommentes", "Most Commentes"),
NEW_COMMENTS("NewCommentes", "New Commentes"),
MOST_COMMENTS("MostComments", "Most Comments"),
NEW_COMMENTS("NewComments", "New Comments"),
TOP_HOUR("TopHour", "Top"),
TOP_SIX_HOURS("TopSixHour", "Top"),

View File

@@ -9,6 +9,7 @@ import java.util.List;
import eu.toldi.infinityforlemmy.apis.LemmyAPI;
import eu.toldi.infinityforlemmy.blockedcommunity.BlockedCommunityData;
import eu.toldi.infinityforlemmy.blockedinstances.BlockedInstanceData;
import eu.toldi.infinityforlemmy.blockeduser.BlockedUserData;
import eu.toldi.infinityforlemmy.subreddit.ParseSubredditData;
import eu.toldi.infinityforlemmy.subreddit.SubredditData;
@@ -31,10 +32,13 @@ public class FetchBlockedThings {
if (siteInfo != null) {
List<BlockedUserData> blockedUsers = new ArrayList<>();
List<BlockedCommunityData> blockedCommunities = new ArrayList<>();
List<BlockedInstanceData> blockedInstances = new ArrayList<>();
try {
JSONObject siteInfoJson = new JSONObject(siteInfo).getJSONObject("my_user");
JSONArray blockedUsersJson = (siteInfoJson.has("person_blocks")) ? siteInfoJson.getJSONArray("person_blocks") : null;
JSONArray blockedCommunitiesJson = (siteInfoJson.has("community_blocks")) ? siteInfoJson.getJSONArray("community_blocks") : null;
JSONArray blockedInstancesJson = (siteInfoJson.has("instance_blocks")) ? siteInfoJson.getJSONArray("instance_blocks") : null;
if (blockedUsersJson != null) {
for (int i = 0; i < blockedUsersJson.length(); i++) {
JSONObject blockedUserJson = blockedUsersJson.getJSONObject(i).getJSONObject("target");
@@ -57,7 +61,29 @@ public class FetchBlockedThings {
blockedCommunities.add(new BlockedCommunityData(blockedCommunityData, accountName));
}
}
fetchBlockedThingsListener.onFetchBlockedThingsSuccess(blockedUsers, blockedCommunities);
if (blockedInstancesJson != null) {
for (int i = 0; i < blockedInstancesJson.length(); i++) {
JSONObject blockedInstanceJson = blockedInstancesJson.getJSONObject(i);
// Get the "instance" object if it exists
JSONObject instanceJson = blockedInstanceJson.has("instance") ? blockedInstanceJson.getJSONObject("instance") : null;
if (instanceJson == null) {
continue;
}
int id = instanceJson.getInt("id");
String domain = instanceJson.getString("domain");
JSONObject siteJson = blockedInstanceJson.has("site") ? blockedInstanceJson.getJSONObject("site") : null;
if (siteJson == null) {
blockedInstances.add(new BlockedInstanceData(id, domain, null, null, accountName));
continue;
}
String name = siteJson.getString("name");
String icon = siteJson.optString("icon");
blockedInstances.add(new BlockedInstanceData(id, domain, name, icon, accountName));
}
}
fetchBlockedThingsListener.onFetchBlockedThingsSuccess(blockedUsers, blockedCommunities, blockedInstances);
} catch (JSONException e) {
e.printStackTrace();
fetchBlockedThingsListener.onFetchBlockedThingsFailure();
@@ -78,7 +104,7 @@ public class FetchBlockedThings {
}
public interface FetchBlockedThingsListener {
void onFetchBlockedThingsSuccess(List<BlockedUserData> blockedUsers, List<BlockedCommunityData> blockedCommunities);
void onFetchBlockedThingsSuccess(List<BlockedUserData> blockedUsers, List<BlockedCommunityData> blockedCommunities, List<BlockedInstanceData> blockedInstances);
void onFetchBlockedThingsFailure();
}

View File

@@ -286,7 +286,7 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
bundle.putString(PostFragment.EXTRA_USER_NAME, mAccountQualifiedName);
bundle.putString(PostFragment.EXTRA_USER_WHERE, PostPagingSource.USER_WHERE_SAVED);
bundle.putString(PostFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountName);
bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountQualifiedName);
bundle.putBoolean(PostFragment.EXTRA_DISABLE_READ_POSTS, true);
fragment.setArguments(bundle);
return fragment;

View File

@@ -42,6 +42,7 @@ import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.shape.CornerFamily;
import com.google.android.material.shape.MaterialShapeDrawable;
import com.google.android.material.shape.ShapeAppearanceModel;
import com.google.android.material.snackbar.Snackbar;
import com.google.android.material.tabs.TabLayout;
import java.lang.reflect.Field;
@@ -321,6 +322,12 @@ public abstract class BaseActivity extends AppCompatActivity implements CustomFo
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar, true);
}
protected Snackbar applySnackBarTheme(Snackbar snackbar) {
snackbar.setBackgroundTint(customThemeWrapper.getBackgroundColor());
snackbar.setTextColor(customThemeWrapper.getSecondaryTextColor());
return snackbar;
}
protected void applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(AppBarLayout appBarLayout, @Nullable CollapsingToolbarLayout collapsingToolbarLayout, Toolbar toolbar, boolean setToolbarBackgroundColor) {
appBarLayout.setBackgroundColor(customThemeWrapper.getColorPrimary());
if (collapsingToolbarLayout != null) {

View File

@@ -1,7 +1,6 @@
package eu.toldi.infinityforlemmy.activities;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
@@ -24,7 +23,6 @@ import androidx.core.view.inputmethod.EditorInfoCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
import androidx.viewpager.widget.ViewPager;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.appbar.CollapsingToolbarLayout;
@@ -51,6 +49,7 @@ import eu.toldi.infinityforlemmy.RetrofitHolder;
import eu.toldi.infinityforlemmy.account.FetchBlockedThings;
import eu.toldi.infinityforlemmy.asynctasks.InsertBlockedThings;
import eu.toldi.infinityforlemmy.blockedcommunity.BlockedCommunityData;
import eu.toldi.infinityforlemmy.blockedinstances.BlockedInstanceData;
import eu.toldi.infinityforlemmy.blockeduser.BlockedUserData;
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
import eu.toldi.infinityforlemmy.customviews.ViewPagerBugFixed;
@@ -58,6 +57,7 @@ import eu.toldi.infinityforlemmy.customviews.slidr.Slidr;
import eu.toldi.infinityforlemmy.events.GoBackToMainPageEvent;
import eu.toldi.infinityforlemmy.events.SwitchAccountEvent;
import eu.toldi.infinityforlemmy.fragments.BlockedCommunitiesListingFragment;
import eu.toldi.infinityforlemmy.fragments.BlockedInstancesListingFragment;
import eu.toldi.infinityforlemmy.fragments.BlockedUsersListingFragment;
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
import eu.toldi.infinityforlemmy.utils.Utils;
@@ -110,8 +110,6 @@ public class BlockedThingListingActivity extends BaseActivity implements Activit
private String mAccountQualifiedName;
private boolean mInsertSuccess = false;
private boolean mInsertMultiredditSuccess = false;
private boolean showMultiReddits = false;
private SectionsPagerAdapter sectionsPagerAdapter;
private Menu mMenu;
@@ -167,9 +165,6 @@ public class BlockedThingListingActivity extends BaseActivity implements Activit
if (savedInstanceState != null) {
mInsertSuccess = savedInstanceState.getBoolean(INSERT_SUBSCRIBED_SUBREDDIT_STATE);
mInsertMultiredditSuccess = savedInstanceState.getBoolean(INSERT_MULTIREDDIT_STATE);
} else {
showMultiReddits = getIntent().getBooleanExtra(EXTRA_SHOW_MULTIREDDITS, false);
}
if (mAccessToken == null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
@@ -216,37 +211,12 @@ public class BlockedThingListingActivity extends BaseActivity implements Activit
}
private void initializeViewPagerAndLoadSubscriptions() {
fab.setOnClickListener(view -> {
Intent intent = new Intent(this, CreateMultiRedditActivity.class);
startActivity(intent);
});
fab.hide();
sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
viewPager.setAdapter(sectionsPagerAdapter);
viewPager.setOffscreenPageLimit(2);
if (viewPager.getCurrentItem() != 2) {
fab.hide();
}
viewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position) {
if (position == 0) {
unlockSwipeRightToGoBack();
fab.hide();
} else {
lockSwipeRightToGoBack();
if (position != 2) {
fab.hide();
} else {
fab.show();
}
}
}
});
tabLayout.setupWithViewPager(viewPager);
if (showMultiReddits) {
viewPager.setCurrentItem(2, false);
}
tabLayout.setupWithViewPager(viewPager);
loadBlocks(false);
}
@@ -303,7 +273,6 @@ public class BlockedThingListingActivity extends BaseActivity implements Activit
protected void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
outState.putBoolean(INSERT_SUBSCRIBED_SUBREDDIT_STATE, mInsertSuccess);
outState.putBoolean(INSERT_MULTIREDDIT_STATE, mInsertMultiredditSuccess);
}
@Override
@@ -316,9 +285,9 @@ public class BlockedThingListingActivity extends BaseActivity implements Activit
if (mAccessToken != null && !(!forceLoad && mInsertSuccess)) {
FetchBlockedThings.fetchBlockedThings(mRetrofit.getRetrofit(), mAccessToken, mAccountQualifiedName, new FetchBlockedThings.FetchBlockedThingsListener() {
@Override
public void onFetchBlockedThingsSuccess(List<BlockedUserData> blockedUsers, List<BlockedCommunityData> blockedCommunities) {
public void onFetchBlockedThingsSuccess(List<BlockedUserData> blockedUsers, List<BlockedCommunityData> blockedCommunities, List<BlockedInstanceData> blockedInstances) {
InsertBlockedThings.insertBlockedThings(mExecutor, new Handler(), mRedditDataRoomDatabase, mAccountQualifiedName,
blockedCommunities, blockedUsers, () -> {
blockedCommunities, blockedUsers, blockedInstances, () -> {
mInsertSuccess = true;
sectionsPagerAdapter.stopRefreshProgressbar();
});
@@ -396,12 +365,20 @@ public class BlockedThingListingActivity extends BaseActivity implements Activit
fragment.setArguments(bundle);
return fragment;
}
case 2: {
BlockedInstancesListingFragment fragment = new BlockedInstancesListingFragment();
Bundle bundle = new Bundle();
bundle.putString(BlockedInstancesListingFragment.EXTRA_ACCOUNT_NAME, mAccountQualifiedName);
bundle.putString(BlockedInstancesListingFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
fragment.setArguments(bundle);
return fragment;
}
}
}
@Override
public int getCount() {
return 2;
return 3;
}
@Override
@@ -412,7 +389,7 @@ public class BlockedThingListingActivity extends BaseActivity implements Activit
case 1:
return Utils.getTabTextWithCustomFont(typeface, getString(R.string.users));
case 2:
return Utils.getTabTextWithCustomFont(typeface, getString(R.string.multi_reddits));
return Utils.getTabTextWithCustomFont(typeface, getString(R.string.instances));
}
return null;

View File

@@ -170,6 +170,7 @@ public class CommentActivity extends BaseActivity implements UploadImageEnabledA
String parentBodyMarkdown = intent.getStringExtra(EXTRA_COMMENT_PARENT_BODY_MARKDOWN_KEY);
String parentBody = intent.getStringExtra(EXTRA_COMMENT_PARENT_BODY_KEY);
mGlide = Glide.with(getApplication());
if (parentBodyMarkdown != null && !parentBodyMarkdown.equals("")) {
binding.commentContentMarkdownView.setVisibility(View.VISIBLE);
binding.commentContentMarkdownView.setNestedScrollingEnabled(false);
@@ -204,8 +205,9 @@ public class CommentActivity extends BaseActivity implements UploadImageEnabledA
builder.linkColor(linkColor);
}
};
Markwon postBodyMarkwon = MarkdownUtils.createFullRedditMarkwon(this,
miscPlugin, parentTextColor, parentSpoilerBackgroundColor, null, mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_IMAGE_PREVIEW, false));
miscPlugin, parentTextColor, parentSpoilerBackgroundColor, mGlide, null, mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_IMAGE_PREVIEW, false));
MarkwonAdapter markwonAdapter = MarkdownUtils.createTablesAdapter();
binding.commentContentMarkdownView.setLayoutManager(new LinearLayoutManagerBugFixed(this));
binding.commentContentMarkdownView.setAdapter(markwonAdapter);
@@ -226,8 +228,6 @@ public class CommentActivity extends BaseActivity implements UploadImageEnabledA
setSupportActionBar(binding.commentToolbar);
mGlide = Glide.with(getApplication());
if (savedInstanceState != null) {
selectedAccount = savedInstanceState.getParcelable(SELECTED_ACCOUNT_STATE);
uploadedImages = savedInstanceState.getParcelableArrayList(UPLOADED_IMAGES_STATE);

View File

@@ -34,13 +34,13 @@ import butterknife.ButterKnife;
import eu.toldi.infinityforlemmy.Infinity;
import eu.toldi.infinityforlemmy.R;
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
import eu.toldi.infinityforlemmy.RetrofitHolder;
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
import eu.toldi.infinityforlemmy.customviews.slidr.Slidr;
import eu.toldi.infinityforlemmy.multireddit.CreateMultiReddit;
import eu.toldi.infinityforlemmy.multireddit.MultiRedditJSONModel;
import eu.toldi.infinityforlemmy.subreddit.SubredditWithSelection;
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
import eu.toldi.infinityforlemmy.utils.Utils;
import retrofit2.Retrofit;
public class CreateMultiRedditActivity extends BaseActivity {
@@ -71,8 +71,8 @@ public class CreateMultiRedditActivity extends BaseActivity {
@BindView(R.id.select_subreddit_text_view_create_multi_reddit_activity)
TextView selectSubredditTextView;
@Inject
@Named("oauth")
Retrofit mOauthRetrofit;
@Named("no_oauth")
RetrofitHolder mRetrofit;
@Inject
RedditDataRoomDatabase mRedditDataRoomDatabase;
@Inject
@@ -87,14 +87,14 @@ public class CreateMultiRedditActivity extends BaseActivity {
Executor mExecutor;
private String mAccessToken;
private String mAccountName;
private ArrayList<String> mSubreddits;
private ArrayList<SubredditWithSelection> mSubreddits;
@Override
protected void onCreate(Bundle savedInstanceState) {
((Infinity) getApplication()).getAppComponent().inject(this);
setImmersiveModeNotApplicable();
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_create_multi_reddit);
@@ -114,10 +114,10 @@ public class CreateMultiRedditActivity extends BaseActivity {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, "-");
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_QUALIFIED_NAME, "-");
visibilityLinearLayout.setVisibility(View.GONE);
if (mAccessToken == null) {
visibilityLinearLayout.setVisibility(View.GONE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
nameEditText.setImeOptions(nameEditText.getImeOptions() | EditorInfoCompat.IME_FLAG_NO_PERSONALIZED_LEARNING);
descriptionEditText.setImeOptions(descriptionEditText.getImeOptions() | EditorInfoCompat.IME_FLAG_NO_PERSONALIZED_LEARNING);
@@ -125,7 +125,7 @@ public class CreateMultiRedditActivity extends BaseActivity {
}
if (savedInstanceState != null) {
mSubreddits = savedInstanceState.getStringArrayList(SELECTED_SUBREDDITS_STATE);
mSubreddits = savedInstanceState.getParcelableArrayList(SELECTED_SUBREDDITS_STATE);
} else {
mSubreddits = new ArrayList<>();
}
@@ -135,7 +135,7 @@ public class CreateMultiRedditActivity extends BaseActivity {
private void bindView() {
selectSubredditTextView.setOnClickListener(view -> {
Intent intent = new Intent(CreateMultiRedditActivity.this, SelectedSubredditsAndUsersActivity.class);
intent.putStringArrayListExtra(SelectedSubredditsAndUsersActivity.EXTRA_SELECTED_SUBREDDITS, mSubreddits);
intent.putParcelableArrayListExtra(SelectedSubredditsAndUsersActivity.EXTRA_SELECTED_SUBREDDITS, mSubreddits);
startActivityForResult(intent, SUBREDDIT_SELECTION_REQUEST_CODE);
});
}
@@ -159,42 +159,29 @@ public class CreateMultiRedditActivity extends BaseActivity {
return true;
}
if (mAccessToken != null) {
String jsonModel = new MultiRedditJSONModel(nameEditText.getText().toString(), descriptionEditText.getText().toString(),
visibilitySwitch.isChecked(), mSubreddits).createJSONModel();
CreateMultiReddit.createMultiReddit(mOauthRetrofit, mRedditDataRoomDatabase, mAccessToken,
"/user/" + mAccountName + "/m/" + nameEditText.getText().toString(),
jsonModel, new CreateMultiReddit.CreateMultiRedditListener() {
@Override
public void success() {
finish();
}
@Override
public void failed(int errorCode) {
if (errorCode == 409) {
Snackbar.make(coordinatorLayout, R.string.duplicate_multi_reddit, Snackbar.LENGTH_SHORT).show();
} else {
Snackbar.make(coordinatorLayout, R.string.create_multi_reddit_failed, Snackbar.LENGTH_SHORT).show();
}
}
});
} else {
CreateMultiReddit.anonymousCreateMultiReddit(mExecutor, new Handler(), mRedditDataRoomDatabase,
"/user/-/m/" + nameEditText.getText().toString(),
nameEditText.getText().toString(), descriptionEditText.getText().toString(),
mSubreddits, new CreateMultiReddit.CreateMultiRedditListener() {
@Override
public void success() {
finish();
}
@Override
public void failed(int errorType) {
//Will not be called
}
});
// Create a list of community qualified names seperated by a comma
StringBuilder subredditList = new StringBuilder();
String prefix = "";
for (SubredditWithSelection s : mSubreddits) {
subredditList.append(prefix);
prefix = ",";
subredditList.append(s.getQualifiedName());
}
CreateMultiReddit.anonymousCreateMultiReddit(mExecutor, new Handler(), mRedditDataRoomDatabase,
mAccountName, subredditList.toString(),
nameEditText.getText().toString(), descriptionEditText.getText().toString(),
mSubreddits, new CreateMultiReddit.CreateMultiRedditListener() {
@Override
public void success() {
finish();
}
@Override
public void failed(int errorType) {
//Will not be called
}
});
}
return false;
}
@@ -204,7 +191,7 @@ public class CreateMultiRedditActivity extends BaseActivity {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == SUBREDDIT_SELECTION_REQUEST_CODE && resultCode == RESULT_OK) {
if (data != null) {
mSubreddits = data.getStringArrayListExtra(
mSubreddits = data.getParcelableArrayListExtra(
SubredditMultiselectionActivity.EXTRA_RETURN_SELECTED_SUBREDDITS);
}
}
@@ -213,7 +200,7 @@ public class CreateMultiRedditActivity extends BaseActivity {
@Override
protected void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
outState.putStringArrayList(SELECTED_SUBREDDITS_STATE, mSubreddits);
outState.putParcelableArrayList(SELECTED_SUBREDDITS_STATE, mSubreddits);
}
@Override

View File

@@ -157,14 +157,7 @@ public class CustomizePostFilterActivity extends BaseActivity {
TextInputEditText excludesUsersTextInputEditText;
@BindView(R.id.add_users_image_view_customize_post_filter_activity)
ImageView addUsersImageView;
@BindView(R.id.excludes_flairs_text_input_layout_customize_post_filter_activity)
TextInputLayout excludesFlairsTextInputLayout;
@BindView(R.id.excludes_flairs_text_input_edit_text_customize_post_filter_activity)
TextInputEditText excludesFlairsTextInputEditText;
@BindView(R.id.contains_flairs_text_input_layout_customize_post_filter_activity)
TextInputLayout containsFlairsTextInputLayout;
@BindView(R.id.contains_flairs_text_input_edit_text_customize_post_filter_activity)
TextInputEditText containsFlairsTextInputEditText;
@BindView(R.id.exclude_domains_text_input_layout_customize_post_filter_activity)
TextInputLayout excludeDomainsTextInputLayout;
@BindView(R.id.exclude_domains_text_input_edit_text_customize_post_filter_activity)
@@ -189,14 +182,7 @@ public class CustomizePostFilterActivity extends BaseActivity {
TextInputLayout maxCommentsTextInputLayout;
@BindView(R.id.max_comments_text_input_edit_text_customize_post_filter_activity)
TextInputEditText maxCommentsTextInputEditText;
@BindView(R.id.min_awards_text_input_layout_customize_post_filter_activity)
TextInputLayout minAwardsTextInputLayout;
@BindView(R.id.min_awards_text_input_edit_text_customize_post_filter_activity)
TextInputEditText minAwardsTextInputEditText;
@BindView(R.id.max_awards_text_input_layout_customize_post_filter_activity)
TextInputLayout maxAwardsTextInputLayout;
@BindView(R.id.max_awards_text_input_edit_text_customize_post_filter_activity)
TextInputEditText maxAwardsTextInputEditText;
@Inject
RedditDataRoomDatabase mRedditDataRoomDatabase;
@Inject
@@ -323,16 +309,12 @@ public class CustomizePostFilterActivity extends BaseActivity {
titleContainsRegexTextInputEditText.setText(postFilter.postTitleContainsRegex);
excludesSubredditsTextInputEditText.setText(postFilter.excludeSubreddits);
excludesUsersTextInputEditText.setText(postFilter.excludeUsers);
excludesFlairsTextInputEditText.setText(postFilter.excludeFlairs);
containsFlairsTextInputEditText.setText(postFilter.containFlairs);
excludeDomainsTextInputEditText.setText(postFilter.excludeDomains);
containDomainsTextInputEditText.setText(postFilter.containDomains);
minVoteTextInputEditText.setText(Integer.toString(postFilter.minVote));
maxVoteTextInputEditText.setText(Integer.toString(postFilter.maxVote));
minCommentsTextInputEditText.setText(Integer.toString(postFilter.minComments));
maxCommentsTextInputEditText.setText(Integer.toString(postFilter.maxComments));
minAwardsTextInputEditText.setText(Integer.toString(postFilter.minAwards));
maxAwardsTextInputEditText.setText(Integer.toString(postFilter.maxAwards));
Intent intent = getIntent();
String excludeSubreddit = intent.getStringExtra(EXTRA_EXCLUDE_SUBREDDIT);
@@ -354,18 +336,6 @@ public class CustomizePostFilterActivity extends BaseActivity {
}
excludesUsersTextInputEditText.append(excludeUser);
}
if (excludeFlair != null && !excludeFlair.equals("")) {
if (!excludesFlairsTextInputEditText.getText().toString().equals("")) {
excludesFlairsTextInputEditText.append(",");
}
excludesFlairsTextInputEditText.append(excludeFlair);
}
if (containFlair != null && !containFlair.equals("")) {
if (!containsFlairsTextInputEditText.getText().toString().equals("")) {
containsFlairsTextInputEditText.append(",");
}
containsFlairsTextInputEditText.append(containFlair);
}
if (excludeDomain != null && !excludeDomain.equals("")) {
if (!excludeDomainsTextInputEditText.getText().toString().equals("")) {
excludeDomainsTextInputEditText.append(",");
@@ -428,12 +398,6 @@ public class CustomizePostFilterActivity extends BaseActivity {
excludesUsersTextInputLayout.setDefaultHintTextColor(ColorStateList.valueOf(primaryTextColor));
excludesUsersTextInputEditText.setTextColor(primaryTextColor);
addUsersImageView.setImageDrawable(Utils.getTintedDrawable(this, R.drawable.ic_add_24dp, primaryIconColor));
excludesFlairsTextInputLayout.setBoxStrokeColor(primaryTextColor);
excludesFlairsTextInputLayout.setDefaultHintTextColor(ColorStateList.valueOf(primaryTextColor));
excludesFlairsTextInputEditText.setTextColor(primaryTextColor);
containsFlairsTextInputLayout.setBoxStrokeColor(primaryTextColor);
containsFlairsTextInputLayout.setDefaultHintTextColor(ColorStateList.valueOf(primaryTextColor));
containsFlairsTextInputEditText.setTextColor(primaryTextColor);
excludeDomainsTextInputLayout.setBoxStrokeColor(primaryTextColor);
excludeDomainsTextInputLayout.setDefaultHintTextColor(ColorStateList.valueOf(primaryTextColor));
excludeDomainsTextInputEditText.setTextColor(primaryTextColor);
@@ -452,13 +416,6 @@ public class CustomizePostFilterActivity extends BaseActivity {
maxCommentsTextInputLayout.setBoxStrokeColor(primaryTextColor);
maxCommentsTextInputLayout.setDefaultHintTextColor(ColorStateList.valueOf(primaryTextColor));
maxCommentsTextInputEditText.setTextColor(primaryTextColor);
minAwardsTextInputLayout.setBoxStrokeColor(primaryTextColor);
minAwardsTextInputLayout.setDefaultHintTextColor(ColorStateList.valueOf(primaryTextColor));
minAwardsTextInputEditText.setTextColor(primaryTextColor);
maxAwardsTextInputLayout.setBoxStrokeColor(primaryTextColor);
maxAwardsTextInputLayout.setDefaultHintTextColor(ColorStateList.valueOf(primaryTextColor));
maxAwardsTextInputEditText.setTextColor(primaryTextColor);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
nameTextInputEditText.setTextCursorDrawable(cursorDrawable);
titleExcludesStringsTextInputEditText.setTextCursorDrawable(cursorDrawable);
@@ -467,16 +424,12 @@ public class CustomizePostFilterActivity extends BaseActivity {
titleContainsRegexTextInputEditText.setTextCursorDrawable(cursorDrawable);
excludesSubredditsTextInputEditText.setTextCursorDrawable(cursorDrawable);
excludesUsersTextInputEditText.setTextCursorDrawable(cursorDrawable);
excludesFlairsTextInputEditText.setTextCursorDrawable(cursorDrawable);
containsFlairsTextInputEditText.setTextCursorDrawable(cursorDrawable);
excludeDomainsTextInputEditText.setTextCursorDrawable(cursorDrawable);
containDomainsTextInputEditText.setTextCursorDrawable(cursorDrawable);
minVoteTextInputEditText.setTextCursorDrawable(cursorDrawable);
maxVoteTextInputEditText.setTextCursorDrawable(cursorDrawable);
minCommentsTextInputEditText.setTextCursorDrawable(cursorDrawable);
maxCommentsTextInputEditText.setTextCursorDrawable(cursorDrawable);
minAwardsTextInputEditText.setTextCursorDrawable(cursorDrawable);
maxAwardsTextInputEditText.setTextCursorDrawable(cursorDrawable);
} else {
setCursorDrawableColor(nameTextInputEditText, primaryTextColor);
setCursorDrawableColor(titleExcludesStringsTextInputEditText, primaryTextColor);
@@ -485,16 +438,12 @@ public class CustomizePostFilterActivity extends BaseActivity {
setCursorDrawableColor(titleContainsRegexTextInputEditText, primaryTextColor);
setCursorDrawableColor(excludesSubredditsTextInputEditText, primaryTextColor);
setCursorDrawableColor(excludesUsersTextInputEditText, primaryTextColor);
setCursorDrawableColor(excludesFlairsTextInputEditText, primaryTextColor);
setCursorDrawableColor(containsFlairsTextInputEditText, primaryTextColor);
setCursorDrawableColor(excludeDomainsTextInputEditText, primaryTextColor);
setCursorDrawableColor(containDomainsTextInputEditText, primaryTextColor);
setCursorDrawableColor(minVoteTextInputEditText, primaryTextColor);
setCursorDrawableColor(maxVoteTextInputEditText, primaryTextColor);
setCursorDrawableColor(minCommentsTextInputEditText, primaryTextColor);
setCursorDrawableColor(maxCommentsTextInputEditText, primaryTextColor);
setCursorDrawableColor(minAwardsTextInputEditText, primaryTextColor);
setCursorDrawableColor(maxAwardsTextInputEditText, primaryTextColor);
}
if (typeface != null) {
@@ -639,8 +588,6 @@ public class CustomizePostFilterActivity extends BaseActivity {
postFilter.minVote = minVoteTextInputEditText.getText() == null || minVoteTextInputEditText.getText().toString().equals("") ? -1 : Integer.parseInt(minVoteTextInputEditText.getText().toString());
postFilter.maxComments = maxCommentsTextInputEditText.getText() == null || maxCommentsTextInputEditText.getText().toString().equals("") ? -1 : Integer.parseInt(maxCommentsTextInputEditText.getText().toString());
postFilter.minComments = minCommentsTextInputEditText.getText() == null || minCommentsTextInputEditText.getText().toString().equals("") ? -1 : Integer.parseInt(minCommentsTextInputEditText.getText().toString());
postFilter.maxAwards = maxAwardsTextInputEditText.getText() == null || maxAwardsTextInputEditText.getText().toString().equals("") ? -1 : Integer.parseInt(maxAwardsTextInputEditText.getText().toString());
postFilter.minAwards = minAwardsTextInputEditText.getText() == null || minAwardsTextInputEditText.getText().toString().equals("") ? -1 : Integer.parseInt(minAwardsTextInputEditText.getText().toString());
postFilter.postTitleExcludesRegex = titleExcludesRegexTextInputEditText.getText().toString();
Pattern.compile(postFilter.postTitleExcludesRegex);
postFilter.postTitleContainsRegex = titleContainsRegexTextInputEditText.getText().toString();
@@ -649,8 +596,6 @@ public class CustomizePostFilterActivity extends BaseActivity {
postFilter.postTitleContainsStrings = titleContainsStringsTextInputEditText.getText().toString();
postFilter.excludeSubreddits = excludesSubredditsTextInputEditText.getText().toString();
postFilter.excludeUsers = excludesUsersTextInputEditText.getText().toString();
postFilter.excludeFlairs = excludesFlairsTextInputEditText.getText().toString();
postFilter.containFlairs = containsFlairsTextInputEditText.getText().toString();
postFilter.excludeDomains = excludeDomainsTextInputEditText.getText().toString();
postFilter.containDomains = containDomainsTextInputEditText.getText().toString();
postFilter.containTextType = postTypeTextCheckBox.isChecked();

View File

@@ -12,7 +12,6 @@ import android.view.View;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.Switch;
import android.widget.TextView;
import androidx.annotation.NonNull;
@@ -25,6 +24,7 @@ import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.appbar.CollapsingToolbarLayout;
import com.google.android.material.snackbar.Snackbar;
import java.util.ArrayList;
import java.util.concurrent.Executor;
import javax.inject.Inject;
@@ -40,7 +40,7 @@ import eu.toldi.infinityforlemmy.customviews.slidr.Slidr;
import eu.toldi.infinityforlemmy.multireddit.EditMultiReddit;
import eu.toldi.infinityforlemmy.multireddit.FetchMultiRedditInfo;
import eu.toldi.infinityforlemmy.multireddit.MultiReddit;
import eu.toldi.infinityforlemmy.multireddit.MultiRedditJSONModel;
import eu.toldi.infinityforlemmy.subreddit.SubredditWithSelection;
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
import eu.toldi.infinityforlemmy.utils.Utils;
import retrofit2.Retrofit;
@@ -70,12 +70,6 @@ public class EditMultiRedditActivity extends BaseActivity {
EditText descriptionEditText;
@BindView(R.id.divider_2_edit_multi_reddit_activity)
View divider2;
@BindView(R.id.visibility_wrapper_linear_layout_edit_multi_reddit_activity)
LinearLayout visibilityLinearLayout;
@BindView(R.id.visibility_text_view_edit_multi_reddit_activity)
TextView visibilityTextView;
@BindView(R.id.visibility_switch_edit_multi_reddit_activity)
Switch visibilitySwitch;
@BindView(R.id.select_subreddit_text_view_edit_multi_reddit_activity)
TextView selectSubredditTextView;
@Inject
@@ -123,10 +117,9 @@ public class EditMultiRedditActivity extends BaseActivity {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, "-");
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_QUALIFIED_NAME, "-");
if (mAccessToken == null) {
visibilityLinearLayout.setVisibility(View.GONE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
nameEditText.setImeOptions(nameEditText.getImeOptions() | EditorInfoCompat.IME_FLAG_NO_PERSONALIZED_LEARNING);
descriptionEditText.setImeOptions(descriptionEditText.getImeOptions() | EditorInfoCompat.IME_FLAG_NO_PERSONALIZED_LEARNING);
@@ -145,53 +138,44 @@ public class EditMultiRedditActivity extends BaseActivity {
private void bindView() {
if (multiReddit == null) {
if (mAccessToken == null) {
FetchMultiRedditInfo.anonymousFetchMultiRedditInfo(mExecutor, new Handler(),
mRedditDataRoomDatabase, multipath, new FetchMultiRedditInfo.FetchMultiRedditInfoListener() {
@Override
public void success(MultiReddit multiReddit) {
EditMultiRedditActivity.this.multiReddit = multiReddit;
progressBar.setVisibility(View.GONE);
linearLayout.setVisibility(View.VISIBLE);
nameEditText.setText(multiReddit.getDisplayName());
descriptionEditText.setText(multiReddit.getDescription());
}
@Override
public void failed() {
//Will not be called
}
});
} else {
FetchMultiRedditInfo.fetchMultiRedditInfo(mRetrofit, mAccessToken, multipath, new FetchMultiRedditInfo.FetchMultiRedditInfoListener() {
@Override
public void success(MultiReddit multiReddit) {
EditMultiRedditActivity.this.multiReddit = multiReddit;
progressBar.setVisibility(View.GONE);
linearLayout.setVisibility(View.VISIBLE);
nameEditText.setText(multiReddit.getDisplayName());
descriptionEditText.setText(multiReddit.getDescription());
visibilitySwitch.setChecked(!multiReddit.getVisibility().equals("public"));
}
FetchMultiRedditInfo.anonymousFetchMultiRedditInfo(mExecutor, new Handler(),
mRedditDataRoomDatabase, multipath, mAccountName, new FetchMultiRedditInfo.FetchMultiRedditInfoListener() {
@Override
public void success(MultiReddit multiReddit) {
EditMultiRedditActivity.this.multiReddit = multiReddit;
progressBar.setVisibility(View.GONE);
linearLayout.setVisibility(View.VISIBLE);
nameEditText.setText(multiReddit.getDisplayName());
descriptionEditText.setText(multiReddit.getDescription());
}
@Override
public void failed() {
//Will not be called
}
});
@Override
public void failed() {
Snackbar.make(coordinatorLayout, R.string.cannot_fetch_multireddit, Snackbar.LENGTH_SHORT).show();
}
});
}
} else {
progressBar.setVisibility(View.GONE);
linearLayout.setVisibility(View.VISIBLE);
nameEditText.setText(multiReddit.getDisplayName());
descriptionEditText.setText(multiReddit.getDescription());
visibilitySwitch.setChecked(!multiReddit.getVisibility().equals("public"));
}
selectSubredditTextView.setOnClickListener(view -> {
Intent intent = new Intent(EditMultiRedditActivity.this, SelectedSubredditsAndUsersActivity.class);
if (multiReddit.getSubreddits() != null) {
intent.putStringArrayListExtra(SelectedSubredditsAndUsersActivity.EXTRA_SELECTED_SUBREDDITS, multiReddit.getSubreddits());
if (multiReddit.getSubreddits().isEmpty() && !multiReddit.getPath().equals("")) {
String[] communities = multiReddit.getPath().split(",");
ArrayList<SubredditWithSelection> communitiesList = new ArrayList<>();
for (String community : communities) {
communitiesList.add(new SubredditWithSelection(community.substring(0, community.indexOf('@')), null, community));
}
intent.putParcelableArrayListExtra(SelectedSubredditsAndUsersActivity.EXTRA_SELECTED_SUBREDDITS, communitiesList);
} else {
intent.putParcelableArrayListExtra(SelectedSubredditsAndUsersActivity.EXTRA_SELECTED_SUBREDDITS, multiReddit.getSubreddits());
}
}
startActivityForResult(intent, SUBREDDIT_SELECTION_REQUEST_CODE);
});
@@ -216,39 +200,34 @@ public class EditMultiRedditActivity extends BaseActivity {
return true;
}
if (mAccessToken == null) {
String name = nameEditText.getText().toString();
multiReddit.setDisplayName(name);
multiReddit.setName(name);
multiReddit.setDescription(descriptionEditText.getText().toString());
EditMultiReddit.anonymousEditMultiReddit(mExecutor, new Handler(), mRedditDataRoomDatabase,
multiReddit, new EditMultiReddit.EditMultiRedditListener() {
@Override
public void success() {
finish();
}
@Override
public void failed() {
//Will not be called
}
});
} else {
String jsonModel = new MultiRedditJSONModel(nameEditText.getText().toString(), descriptionEditText.getText().toString(),
visibilitySwitch.isChecked(), multiReddit.getSubreddits()).createJSONModel();
EditMultiReddit.editMultiReddit(mRetrofit, mAccessToken, multiReddit.getPath(),
jsonModel, new EditMultiReddit.EditMultiRedditListener() {
@Override
public void success() {
finish();
}
@Override
public void failed() {
Snackbar.make(coordinatorLayout, R.string.edit_multi_reddit_failed, Snackbar.LENGTH_SHORT).show();
}
});
String name = nameEditText.getText().toString();
multiReddit.setDisplayName(name);
multiReddit.setName(name);
multiReddit.setDescription(descriptionEditText.getText().toString());
StringBuilder pathStringBuilder = new StringBuilder();
String prefix = "";
for (SubredditWithSelection s : multiReddit.getSubreddits()) {
pathStringBuilder.append(prefix);
prefix = ",";
pathStringBuilder.append(s.getQualifiedName());
}
multiReddit.setPath(pathStringBuilder.toString());
EditMultiReddit.anonymousEditMultiReddit(mExecutor, new Handler(), mRedditDataRoomDatabase,
multiReddit, multipath, new EditMultiReddit.EditMultiRedditListener() {
@Override
public void success() {
finish();
}
@Override
public void failed() {
//Will not be called
}
});
return true;
}
return false;
@@ -259,7 +238,7 @@ public class EditMultiRedditActivity extends BaseActivity {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == SUBREDDIT_SELECTION_REQUEST_CODE && resultCode == RESULT_OK) {
if (data != null) {
multiReddit.setSubreddits(data.getStringArrayListExtra(
multiReddit.setSubreddits(data.getParcelableArrayListExtra(
SelectedSubredditsAndUsersActivity.EXTRA_RETURN_SELECTED_SUBREDDITS));
}
}
@@ -296,7 +275,6 @@ public class EditMultiRedditActivity extends BaseActivity {
divider2.setBackgroundColor(dividerColor);
descriptionEditText.setTextColor(primaryTextColor);
descriptionEditText.setHintTextColor(secondaryTextColor);
visibilityTextView.setTextColor(primaryTextColor);
selectSubredditTextView.setTextColor(primaryTextColor);
if (typeface != null) {

View File

@@ -317,7 +317,7 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec
bundle.putInt(PostFragment.EXTRA_POST_TYPE, postType);
bundle.putParcelable(PostFragment.EXTRA_FILTER, postFilter);
bundle.putString(PostFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountName);
bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountQualifiedName);
if (postType == PostPagingSource.TYPE_USER) {
bundle.putString(PostFragment.EXTRA_USER_NAME, name);
bundle.putString(PostFragment.EXTRA_USER_WHERE, userWhere);
@@ -371,20 +371,17 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec
} else if (itemId == R.id.action_sort_filtered_thing_activity) {
switch (postType) {
case PostPagingSource.TYPE_FRONT_PAGE:
SortTypeBottomSheetFragment bestSortTypeBottomSheetFragment = SortTypeBottomSheetFragment.getNewInstance(false, mFragment.getSortType());
case PostPagingSource.TYPE_SUBREDDIT:
case PostPagingSource.TYPE_MULTI_REDDIT:
case PostPagingSource.TYPE_ANONYMOUS_MULTIREDDIT:
case PostPagingSource.TYPE_ANONYMOUS_FRONT_PAGE:
SortTypeBottomSheetFragment bestSortTypeBottomSheetFragment = SortTypeBottomSheetFragment.getNewInstance(postType, mFragment.getSortType());
bestSortTypeBottomSheetFragment.show(getSupportFragmentManager(), bestSortTypeBottomSheetFragment.getTag());
break;
case PostPagingSource.TYPE_SEARCH:
SearchPostSortTypeBottomSheetFragment searchPostSortTypeBottomSheetFragment = SearchPostSortTypeBottomSheetFragment.getNewInstance(mFragment.getSortType());
searchPostSortTypeBottomSheetFragment.show(getSupportFragmentManager(), searchPostSortTypeBottomSheetFragment.getTag());
break;
case PostPagingSource.TYPE_SUBREDDIT:
case PostPagingSource.TYPE_MULTI_REDDIT:
case PostPagingSource.TYPE_ANONYMOUS_MULTIREDDIT:
case PostPagingSource.TYPE_ANONYMOUS_FRONT_PAGE:
SortTypeBottomSheetFragment sortTypeBottomSheetFragment = SortTypeBottomSheetFragment.getNewInstance(true, mFragment.getSortType());
sortTypeBottomSheetFragment.show(getSupportFragmentManager(), sortTypeBottomSheetFragment.getTag());
break;
case PostPagingSource.TYPE_USER:
UserThingSortTypeBottomSheetFragment userThingSortTypeBottomSheetFragment = UserThingSortTypeBottomSheetFragment.getNewInstance(mFragment.getSortType());
userThingSortTypeBottomSheetFragment.show(getSupportFragmentManager(), userThingSortTypeBottomSheetFragment.getTag());

View File

@@ -18,6 +18,7 @@ import androidx.appcompat.widget.Toolbar;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.Glide;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.appbar.CollapsingToolbarLayout;
@@ -139,7 +140,7 @@ public class FullMarkdownActivity extends BaseActivity {
}
};
Markwon markwon = MarkdownUtils.createFullRedditMarkwon(this,
miscPlugin, markdownColor, spoilerBackgroundColor, null, mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_IMAGE_PREVIEW, false));
miscPlugin, markdownColor, spoilerBackgroundColor, Glide.with(getApplication()), null, mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_IMAGE_PREVIEW, false));
MarkwonAdapter markwonAdapter = MarkdownUtils.createTablesAdapter();
LinearLayoutManagerBugFixed linearLayoutManager = new SwipeLockLinearLayoutManager(this, new SwipeLockInterface() {

View File

@@ -117,7 +117,7 @@ public class GiveAwardActivity extends BaseActivity {
View layout = inflater.inflate(R.layout.dialog_give_award, null);
MaterialSwitch materialSwitch = layout.findViewById(R.id.switch_material_give_award_dialog);
new MaterialAlertDialogBuilder(this)
.setTitle(R.string.give_award_dialog_title)
.setTitle("")
.setView(layout)
.setPositiveButton(R.string.yes, (dialogInterface, i) -> {
boolean isAnonymous = materialSwitch.isChecked();
@@ -138,10 +138,10 @@ public class GiveAwardActivity extends BaseActivity {
public void failed(int code, String message) {
View layout = inflater.inflate(R.layout.copy_text_material_dialog, null);
TextView textView = layout.findViewById(R.id.text_view_copy_text_material_dialog);
String text = getString(R.string.give_award_error_message, code, message == null ? "" : message);
String text = "";
textView.setText(text);
new MaterialAlertDialogBuilder(GiveAwardActivity.this, R.style.CopyTextMaterialAlertDialogTheme)
.setTitle(R.string.give_award_failed)
.setTitle("")
.setView(layout)
.setPositiveButton(R.string.copy_all, (dialogInterface, i) -> {
ClipboardManager clipboard = (ClipboardManager) GiveAwardActivity.this.getSystemService(Context.CLIPBOARD_SERVICE);

View File

@@ -156,7 +156,7 @@ public class InboxActivity extends BaseActivity implements ActivityToolbarInterf
fragmentManager = getSupportFragmentManager();
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null);
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_QUALIFIED_NAME, null);
if (savedInstanceState != null) {
mNewAccountName = savedInstanceState.getString(NEW_ACCOUNT_NAME_STATE);

View File

@@ -8,10 +8,12 @@ import android.net.Uri;
import android.os.Bundle;
import android.text.Spanned;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -21,8 +23,10 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.Glide;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.card.MaterialCardView;
import com.google.android.material.snackbar.Snackbar;
import java.util.List;
@@ -32,16 +36,22 @@ import javax.inject.Named;
import eu.toldi.infinityforlemmy.Infinity;
import eu.toldi.infinityforlemmy.R;
import eu.toldi.infinityforlemmy.RetrofitHolder;
import eu.toldi.infinityforlemmy.account.FetchBlockedThings;
import eu.toldi.infinityforlemmy.adapters.AdminRecyclerViewAdapter;
import eu.toldi.infinityforlemmy.blockedcommunity.BlockedCommunityData;
import eu.toldi.infinityforlemmy.blockedinstances.BlockedInstanceData;
import eu.toldi.infinityforlemmy.blockeduser.BlockedUserData;
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
import eu.toldi.infinityforlemmy.customviews.LinearLayoutManagerBugFixed;
import eu.toldi.infinityforlemmy.customviews.slidr.Slidr;
import eu.toldi.infinityforlemmy.databinding.ActivityInstanceInfoBinding;
import eu.toldi.infinityforlemmy.markdown.MarkdownUtils;
import eu.toldi.infinityforlemmy.site.BlockInstance;
import eu.toldi.infinityforlemmy.site.FetchSiteInfo;
import eu.toldi.infinityforlemmy.site.SiteInfo;
import eu.toldi.infinityforlemmy.site.SiteStatistics;
import eu.toldi.infinityforlemmy.user.BasicUserInfo;
import eu.toldi.infinityforlemmy.user.MyUserInfo;
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
import io.noties.markwon.AbstractMarkwonPlugin;
import io.noties.markwon.Markwon;
@@ -49,9 +59,13 @@ import io.noties.markwon.MarkwonConfiguration;
import io.noties.markwon.MarkwonPlugin;
import io.noties.markwon.core.MarkwonTheme;
import io.noties.markwon.recycler.MarkwonAdapter;
import retrofit2.Retrofit;
public class InstanceInfoActivity extends BaseActivity {
public static final String EXTRA_INSTANCE_DOMAIN = "instance_info_domain";
public static final String EXTRA_INSTANCE_ID = "instance_info_id";
@Inject
@Named("default")
SharedPreferences mSharedPreferences;
@@ -63,6 +77,10 @@ public class InstanceInfoActivity extends BaseActivity {
@Named("no_oauth")
RetrofitHolder mRetorifitHolder;
@Inject
@Named("current_account")
SharedPreferences mCurrentAccountSharedPreferences;
ActivityInstanceInfoBinding mInstanceInfoActivityViewBinding;
private CoordinatorLayout coordinatorLayout;
private Toolbar toolbar;
@@ -92,6 +110,11 @@ public class InstanceInfoActivity extends BaseActivity {
private MarkwonAdapter mMarkwonAdapter;
private Markwon mPostDetailMarkwon;
private AdminRecyclerViewAdapter mAdminAdapter;
private Retrofit mRetrofit;
private String mInstanceDomain;
private int mInstanceId;
private String mAccessToken;
private String mAccountName;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
@@ -104,6 +127,25 @@ public class InstanceInfoActivity extends BaseActivity {
setContentView(view);
setSupportActionBar(mInstanceInfoActivityViewBinding.toolbarInstanceInfoActivity);
if (savedInstanceState != null) {
mInstanceDomain = savedInstanceState.getString(EXTRA_INSTANCE_DOMAIN);
mInstanceId = savedInstanceState.getInt(EXTRA_INSTANCE_ID);
} else {
mInstanceDomain = getIntent().getStringExtra(EXTRA_INSTANCE_DOMAIN);
mInstanceId = getIntent().getIntExtra(EXTRA_INSTANCE_ID, -1);
}
if (mInstanceDomain == null) {
mRetrofit = mRetorifitHolder.getRetrofit();
} else {
String originalBaseUrl = mRetorifitHolder.getBaseURL();
mRetorifitHolder.setBaseURL("https://" + mInstanceDomain);
mRetrofit = mRetorifitHolder.getRetrofit();
mRetorifitHolder.setBaseURL(originalBaseUrl);
}
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null);
setUpBindings();
applyCustomTheme();
@@ -149,7 +191,7 @@ public class InstanceInfoActivity extends BaseActivity {
};
mPostDetailMarkwon = MarkdownUtils.createFullRedditMarkwon(this,
miscPlugin, markdownColor, postSpoilerBackgroundColor, null, mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_IMAGE_PREVIEW, false));
miscPlugin, markdownColor, postSpoilerBackgroundColor, Glide.with(getApplication()), null, mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_IMAGE_PREVIEW, false));
mMarkwonAdapter = MarkdownUtils.createTablesAdapter();
mContentMarkdownView.setAdapter(mMarkwonAdapter);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
@@ -168,9 +210,9 @@ public class InstanceInfoActivity extends BaseActivity {
}
private void fetchInstanceInfo() {
FetchSiteInfo.fetchSiteInfo(mRetorifitHolder.getRetrofit(), null, new FetchSiteInfo.FetchSiteInfoListener() {
FetchSiteInfo.fetchSiteInfo(mRetrofit, null, new FetchSiteInfo.FetchSiteInfoListener() {
@Override
public void onFetchSiteInfoSuccess(SiteInfo siteInfo) {
public void onFetchSiteInfoSuccess(SiteInfo siteInfo, MyUserInfo myUserInfo) {
mLoadingConstraintLayout.setVisibility(View.GONE);
toolbar.setTitle(siteInfo.getName());
if (siteInfo.getSidebar() != null) {
@@ -197,7 +239,7 @@ public class InstanceInfoActivity extends BaseActivity {
}
@Override
public void onFetchSiteInfoFailed() {
public void onFetchSiteInfoFailed(boolean parseFailed) {
}
});
@@ -256,11 +298,88 @@ public class InstanceInfoActivity extends BaseActivity {
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
protected void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
outState.putString(EXTRA_INSTANCE_DOMAIN, mInstanceDomain);
outState.putInt(EXTRA_INSTANCE_ID, mInstanceId);
}
@Override
protected void onRestoreInstanceState(@NonNull Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
mInstanceDomain = savedInstanceState.getString(EXTRA_INSTANCE_DOMAIN);
mInstanceId = savedInstanceState.getInt(EXTRA_INSTANCE_ID);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.instance_info_activity, menu);
if (mInstanceDomain == null || mInstanceDomain.equalsIgnoreCase(mRetorifitHolder.getBaseURL().split("/")[2])) {
menu.findItem(R.id.action_block_instance_info).setVisible(false);
menu.findItem(R.id.action_unblock_instance_info).setVisible(false);
return true;
}
if (mAccessToken == null) {
menu.findItem(R.id.action_block_instance_info).setVisible(false);
menu.findItem(R.id.action_unblock_instance_info).setVisible(false);
return true;
}
FetchBlockedThings.fetchBlockedThings(mRetorifitHolder.getRetrofit(), mAccessToken, mAccountName, new FetchBlockedThings.FetchBlockedThingsListener() {
@Override
public void onFetchBlockedThingsSuccess(List<BlockedUserData> blockedUsers, List<BlockedCommunityData> blockedCommunities, List<BlockedInstanceData> blockedInstances) {
for (BlockedInstanceData blockedInstanceData : blockedInstances) {
if (blockedInstanceData.getDomain().equals(mInstanceDomain)) {
menu.findItem(R.id.action_block_instance_info).setVisible(false);
menu.findItem(R.id.action_unblock_instance_info).setVisible(true);
return;
}
}
menu.findItem(R.id.action_block_instance_info).setVisible(true);
menu.findItem(R.id.action_unblock_instance_info).setVisible(false);
}
@Override
public void onFetchBlockedThingsFailure() {
}
});
return true;
}
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
if (item.getItemId() == android.R.id.home) {
finish();
return true;
} else if (item.getItemId() == R.id.action_block_instance_info) {
blockInstance(true);
return true;
} else if (item.getItemId() == R.id.action_unblock_instance_info) {
blockInstance(false);
return true;
}
return false;
return super.onOptionsItemSelected(item);
}
public void blockInstance(boolean blocked) {
BlockInstance.INSTANCE.blockInstance(mRetorifitHolder.getRetrofit(), mInstanceId, blocked, new BlockInstance.BlockInstanceResponse() {
@Override
public void onResponse() {
if (blocked) {
applySnackBarTheme(Snackbar.make(coordinatorLayout, R.string.block_instance_success, Snackbar.LENGTH_SHORT)).show();
} else {
applySnackBarTheme(Snackbar.make(coordinatorLayout, R.string.unblock_instance_success, Snackbar.LENGTH_SHORT)).show();
}
InstanceInfoActivity.this.invalidateOptionsMenu();
}
@Override
public void onFailure() {
Toast.makeText(InstanceInfoActivity.this, R.string.block_instance_failed, Toast.LENGTH_SHORT).show();
}
});
}
}

View File

@@ -17,6 +17,7 @@ import androidx.browser.customtabs.CustomTabsIntent;
import androidx.browser.customtabs.CustomTabsService;
import org.apache.commons.io.FilenameUtils;
import org.greenrobot.eventbus.EventBus;
import java.net.MalformedURLException;
import java.net.URL;
@@ -29,10 +30,13 @@ import javax.inject.Named;
import eu.toldi.infinityforlemmy.Infinity;
import eu.toldi.infinityforlemmy.R;
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
import eu.toldi.infinityforlemmy.RetrofitHolder;
import eu.toldi.infinityforlemmy.asynctasks.SwitchAccount;
import eu.toldi.infinityforlemmy.comment.Comment;
import eu.toldi.infinityforlemmy.comment.FetchComment;
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
import eu.toldi.infinityforlemmy.events.SwitchAccountEvent;
import eu.toldi.infinityforlemmy.post.FetchPost;
import eu.toldi.infinityforlemmy.post.ObjectResolver;
import eu.toldi.infinityforlemmy.post.Post;
@@ -55,7 +59,6 @@ public class LinkResolverActivity extends AppCompatActivity {
private static final String MULTIREDDIT_PATTERN = "/user/[\\w-]+/m/\\w+/?";
private static final String MULTIREDDIT_PATTERN_2 = "/[rR]/(\\w+\\+?)+/?";
private static final String REDD_IT_POST_PATTERN = "/\\w+/?";
private static final String GFYCAT_PATTERN = "(/i?fr)?/[\\w-]+$";
private static final String REDGIFS_PATTERN = "/watch/[\\w-]+$";
private static final String IMGUR_GALLERY_PATTERN = "/gallery/\\w+/?";
private static final String IMGUR_ALBUM_PATTERN = "/(album|a)/\\w+/?";
@@ -70,6 +73,9 @@ public class LinkResolverActivity extends AppCompatActivity {
@Inject
CustomThemeWrapper mCustomThemeWrapper;
@Inject
RedditDataRoomDatabase mRedditDataRoomDatabase;
@Inject
ObjectResolver mObjectResolver;
@@ -88,6 +94,7 @@ public class LinkResolverActivity extends AppCompatActivity {
PostEnricher postEnricher;
private String mAccessToken;
private String mAccountQualifedName;
private Uri getRedditUriByPath(String path) {
if (path.charAt(0) != '/') {
@@ -103,6 +110,7 @@ public class LinkResolverActivity extends AppCompatActivity {
((Infinity) getApplication()).getAppComponent().inject(this);
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
mAccountQualifedName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_QUALIFIED_NAME,null);
if (mAccessToken != null) {
String instance = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_INSTANCE, null);
mRetrofit.setBaseURL(instance);
@@ -216,52 +224,17 @@ public class LinkResolverActivity extends AppCompatActivity {
intent.putExtra(ViewPostDetailActivity.EXTRA_NEW_ACCOUNT_NAME, newAccountName);
startActivity(intent);
} else {
boolean local = false;
try {
URL baseURL = new URL(mRetrofit.getBaseURL());
if (baseURL.getHost().equalsIgnoreCase(uri.getHost())) {
local = true;
FetchPost.fetchPost(mExecutor, new Handler(), mRetrofit.getRetrofit(), segments.get(segments.size() - 1), mAccessToken, postEnricher, new FetchPost.FetchPostListener() {
@Override
public void fetchPostSuccess(Post post) {
Intent intent = new Intent(LinkResolverActivity.this, ViewPostDetailActivity.class);
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_ID, post.getId());
intent.putExtra(ViewPostDetailActivity.EXTRA_MESSAGE_FULLNAME, messageFullname);
intent.putExtra(ViewPostDetailActivity.EXTRA_NEW_ACCOUNT_NAME, newAccountName);
startActivity(intent);
}
@Override
public void fetchPostFailed() {
Toast.makeText(getApplicationContext(), R.string.could_not_resolve_link, Toast.LENGTH_SHORT).show();
finish();
}
});
}
} catch (MalformedURLException e) {
Toast.makeText(getApplicationContext(), R.string.could_not_resolve_link, Toast.LENGTH_SHORT).show();
finish();
if (mAccountQualifedName == null || newAccountName != null && !mAccountQualifedName.equals(newAccountName)) {
SwitchAccount.switchAccount(mRedditDataRoomDatabase, mRetrofit, mCurrentAccountSharedPreferences,
mExecutor, new Handler(), newAccountName, newAccount -> {
EventBus.getDefault().post(new SwitchAccountEvent(getClass().getName()));
Toast.makeText(this, R.string.account_switched, Toast.LENGTH_SHORT).show();
openPost(uri, segments, messageFullname);
});
} else {
openPost(uri, segments, messageFullname);
}
if (!local) {
mObjectResolver.resolvePost(uri.toString(), mAccessToken, new ObjectResolver.ObjectResolverListener() {
@Override
public void onResolveObjectSuccess(Object p) {
Post post = (Post) p;
Intent intent = new Intent(LinkResolverActivity.this, ViewPostDetailActivity.class);
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_ID, post.getId());
intent.putExtra(ViewPostDetailActivity.EXTRA_MESSAGE_FULLNAME, messageFullname);
intent.putExtra(ViewPostDetailActivity.EXTRA_NEW_ACCOUNT_NAME, newAccountName);
startActivity(intent);
}
@Override
public void onResolveObjectFailed() {
Toast.makeText(getApplicationContext(), R.string.could_not_resolve_link, Toast.LENGTH_SHORT).show();
finish();
}
});
}
}
} else if (uri.toString().matches(COMMENT_PATTERN)) {
if (mAccessToken == null) {
@@ -286,56 +259,17 @@ public class LinkResolverActivity extends AppCompatActivity {
}
});
} else {
boolean local = false;
try {
URL baseURL = new URL(mRetrofit.getBaseURL());
if (baseURL.getHost().equalsIgnoreCase(uri.getHost())) {
local = true;
FetchComment.fetchSingleComment(mRetrofit.getRetrofit(), mAccessToken, Integer.parseInt(segments.get(segments.size() - 1)), new FetchComment.FetchCommentListener() {
@Override
public void onFetchCommentSuccess(ArrayList<Comment> comments, Integer parentId, ArrayList<Integer> moreChildrenIds) {
Intent intent = new Intent(LinkResolverActivity.this, ViewPostDetailActivity.class);
Comment comment = comments.get(0);
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_ID, comment.getPostId());
intent.putExtra(ViewPostDetailActivity.EXTRA_MESSAGE_FULLNAME, messageFullname);
intent.putExtra(ViewPostDetailActivity.EXTRA_NEW_ACCOUNT_NAME, newAccountName);
intent.putExtra(ViewPostDetailActivity.EXTRA_SINGLE_COMMENT_ID, comment.getId());
intent.putExtra(ViewPostDetailActivity.EXTRA_SINGLE_COMMENT_PARENT_ID, comment.getParentId());
startActivity(intent);
}
@Override
public void onFetchCommentFailed() {
Toast.makeText(getApplicationContext(), R.string.could_not_resolve_link, Toast.LENGTH_SHORT).show();
finish();
}
});
}
} catch (MalformedURLException e) {
Toast.makeText(getApplicationContext(), R.string.could_not_resolve_link, Toast.LENGTH_SHORT).show();
finish();
if (mAccountQualifedName == null || newAccountName != null && !mAccountQualifedName.equals(newAccountName)) {
SwitchAccount.switchAccount(mRedditDataRoomDatabase, mRetrofit, mCurrentAccountSharedPreferences,
mExecutor, new Handler(), newAccountName, newAccount -> {
EventBus.getDefault().post(new SwitchAccountEvent(getClass().getName()));
Toast.makeText(this, R.string.account_switched, Toast.LENGTH_SHORT).show();
openComment(uri, segments, messageFullname);
});
} else {
openComment(uri, segments, messageFullname);
}
if (!local) {
mObjectResolver.resolveComment(uri.toString(), mAccessToken, new ObjectResolver.ObjectResolverListener() {
@Override
public void onResolveObjectSuccess(Object c) {
Comment comment = (Comment) c;
Intent intent = new Intent(LinkResolverActivity.this, ViewPostDetailActivity.class);
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_ID, comment.getPostId());
intent.putExtra(ViewPostDetailActivity.EXTRA_MESSAGE_FULLNAME, messageFullname);
intent.putExtra(ViewPostDetailActivity.EXTRA_NEW_ACCOUNT_NAME, newAccountName);
intent.putExtra(ViewPostDetailActivity.EXTRA_SINGLE_COMMENT_ID, comment.getId());
intent.putExtra(ViewPostDetailActivity.EXTRA_SINGLE_COMMENT_PARENT_ID, comment.getParentId());
startActivity(intent);
}
@Override
public void onResolveObjectFailed() {
Toast.makeText(getApplicationContext(), R.string.could_not_resolve_link, Toast.LENGTH_SHORT).show();
finish();
}
});
}
}
} else if (authority.equals("v.redd.it")) {
Intent intent = new Intent(this, ViewVideoActivity.class);
@@ -346,20 +280,10 @@ public class LinkResolverActivity extends AppCompatActivity {
if (path.startsWith("/CL0/")) {
handleUri(Uri.parse(path.substring("/CL0/".length())));
}
} else if (authority.contains("gfycat.com")) {
if (path.matches(GFYCAT_PATTERN)) {
Intent intent = new Intent(this, ViewVideoActivity.class);
intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, path.substring(path.lastIndexOf("/") + 1));
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_GFYCAT);
intent.putExtra(ViewVideoActivity.EXTRA_IS_NSFW, getIntent().getBooleanExtra(EXTRA_IS_NSFW, false));
startActivity(intent);
} else {
deepLinkError(uri);
}
} else if (authority.contains("redgifs.com")) {
if (path.matches(REDGIFS_PATTERN)) {
Intent intent = new Intent(this, ViewVideoActivity.class);
intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, path.substring(path.lastIndexOf("/") + 1));
intent.putExtra(ViewVideoActivity.EXTRA_REDGIFS_ID, path.substring(path.lastIndexOf("/") + 1));
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_REDGIFS);
intent.putExtra(ViewVideoActivity.EXTRA_IS_NSFW, true);
startActivity(intent);
@@ -425,6 +349,104 @@ public class LinkResolverActivity extends AppCompatActivity {
finish();
}
private void openComment(Uri uri, List<String> segments, String messageFullname) {
boolean local = false;
try {
URL baseURL = new URL(mRetrofit.getBaseURL());
if (baseURL.getHost().equalsIgnoreCase(uri.getHost())) {
local = true;
FetchComment.fetchSingleComment(mRetrofit.getRetrofit(), mAccessToken, Integer.parseInt(segments.get(segments.size() - 1)), new FetchComment.FetchCommentListener() {
@Override
public void onFetchCommentSuccess(ArrayList<Comment> comments, Integer parentId, ArrayList<Integer> moreChildrenIds) {
Intent intent = new Intent(LinkResolverActivity.this, ViewPostDetailActivity.class);
Comment comment = comments.get(0);
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_ID, comment.getPostId());
intent.putExtra(ViewPostDetailActivity.EXTRA_MESSAGE_FULLNAME, messageFullname);
intent.putExtra(ViewPostDetailActivity.EXTRA_SINGLE_COMMENT_ID, comment.getId());
intent.putExtra(ViewPostDetailActivity.EXTRA_SINGLE_COMMENT_PARENT_ID, comment.getParentId());
startActivity(intent);
}
@Override
public void onFetchCommentFailed() {
Toast.makeText(getApplicationContext(), R.string.could_not_resolve_link, Toast.LENGTH_SHORT).show();
finish();
}
});
}
} catch (MalformedURLException e) {
Toast.makeText(getApplicationContext(), R.string.could_not_resolve_link, Toast.LENGTH_SHORT).show();
finish();
}
if (!local) {
mObjectResolver.resolveComment(uri.toString(), mAccessToken, new ObjectResolver.ObjectResolverListener() {
@Override
public void onResolveObjectSuccess(Object c) {
Comment comment = (Comment) c;
Intent intent = new Intent(LinkResolverActivity.this, ViewPostDetailActivity.class);
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_ID, comment.getPostId());
intent.putExtra(ViewPostDetailActivity.EXTRA_MESSAGE_FULLNAME, messageFullname);
intent.putExtra(ViewPostDetailActivity.EXTRA_SINGLE_COMMENT_ID, comment.getId());
intent.putExtra(ViewPostDetailActivity.EXTRA_SINGLE_COMMENT_PARENT_ID, comment.getParentId());
startActivity(intent);
}
@Override
public void onResolveObjectFailed() {
Toast.makeText(getApplicationContext(), R.string.could_not_resolve_link, Toast.LENGTH_SHORT).show();
finish();
}
});
}
}
private void openPost(Uri uri, List<String> segments, String messageFullname) {
boolean local = false;
try {
URL baseURL = new URL(mRetrofit.getBaseURL());
if (baseURL.getHost().equalsIgnoreCase(uri.getHost())) {
local = true;
FetchPost.fetchPost(mExecutor, new Handler(), mRetrofit.getRetrofit(), segments.get(segments.size() - 1), mAccessToken, postEnricher, new FetchPost.FetchPostListener() {
@Override
public void fetchPostSuccess(Post post) {
Intent intent = new Intent(LinkResolverActivity.this, ViewPostDetailActivity.class);
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_ID, post.getId());
intent.putExtra(ViewPostDetailActivity.EXTRA_MESSAGE_FULLNAME, messageFullname);
startActivity(intent);
}
@Override
public void fetchPostFailed() {
Toast.makeText(getApplicationContext(), R.string.could_not_resolve_link, Toast.LENGTH_SHORT).show();
finish();
}
});
}
} catch (MalformedURLException e) {
Toast.makeText(getApplicationContext(), R.string.could_not_resolve_link, Toast.LENGTH_SHORT).show();
finish();
}
if (!local) {
mObjectResolver.resolvePost(uri.toString(), mAccessToken, new ObjectResolver.ObjectResolverListener() {
@Override
public void onResolveObjectSuccess(Object p) {
Post post = (Post) p;
Intent intent = new Intent(LinkResolverActivity.this, ViewPostDetailActivity.class);
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_ID, post.getId());
intent.putExtra(ViewPostDetailActivity.EXTRA_MESSAGE_FULLNAME, messageFullname);
startActivity(intent);
}
@Override
public void onResolveObjectFailed() {
Toast.makeText(getApplicationContext(), R.string.could_not_resolve_link, Toast.LENGTH_SHORT).show();
finish();
}
});
}
}
private void deepLinkError(Uri uri) {
PackageManager pm = getPackageManager();

View File

@@ -39,7 +39,6 @@ import javax.inject.Named;
import butterknife.BindView;
import butterknife.ButterKnife;
import eu.toldi.infinityforlemmy.FetchMyInfo;
import eu.toldi.infinityforlemmy.Infinity;
import eu.toldi.infinityforlemmy.R;
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
@@ -55,6 +54,7 @@ import eu.toldi.infinityforlemmy.lemmyverse.LemmyInstance;
import eu.toldi.infinityforlemmy.lemmyverse.LemmyVerseFetchInstances;
import eu.toldi.infinityforlemmy.site.FetchSiteInfo;
import eu.toldi.infinityforlemmy.site.SiteInfo;
import eu.toldi.infinityforlemmy.user.MyUserInfo;
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
import eu.toldi.infinityforlemmy.utils.Utils;
import retrofit2.Call;
@@ -217,64 +217,58 @@ public class LoginActivity extends BaseActivity {
try {
JSONObject responseJSON = new JSONObject(accountResponse);
String accessToken = responseJSON.getString("jwt");
mRetrofit.setAccessToken(null);
mRetrofit.setAccessToken(accessToken);
FetchMyInfo.fetchAccountInfo(mRetrofit.getRetrofit(), mRedditDataRoomDatabase, username,
accessToken, new FetchMyInfo.FetchMyInfoListener() {
@Override
public void onFetchMyInfoSuccess(String name, String display_name, String profileImageUrl, String bannerImageUrl) {
FetchSiteInfo.fetchSiteInfo(mRetrofit.getRetrofit(), accessToken, new FetchSiteInfo.FetchSiteInfoListener() {
@Override
public void onFetchSiteInfoSuccess(SiteInfo siteInfo) {
boolean canDownvote = siteInfo.isEnable_downvotes();
ParseAndInsertNewAccount.parseAndInsertNewAccount(mExecutor, new Handler(), name, display_name, accessToken, profileImageUrl, bannerImageUrl, authCode, finalInstance, canDownvote, mRedditDataRoomDatabase.accountDao(),
() -> {
Intent resultIntent = new Intent();
setResult(Activity.RESULT_OK, resultIntent);
finish();
});
mCurrentAccountSharedPreferences.edit().putBoolean(SharedPreferencesUtils.CAN_DOWNVOTE, canDownvote).apply();
String[] version = siteInfo.getVersion().split("\\.");
if (version.length > 0) {
Log.d("SwitchAccount", "Lemmy Version: " + version[0] + "." + version[1]);
int majorVersion = Integer.parseInt(version[0]);
int minorVersion = Integer.parseInt(version[1]);
if (majorVersion > 0 || (majorVersion == 0 && minorVersion >= 19)) {
mRetrofit.setAccessToken(accessToken);
mCurrentAccountSharedPreferences.edit().putBoolean(SharedPreferencesUtils.BEARER_TOKEN_AUTH, true).apply();
}
}
}
FetchSiteInfo.fetchSiteInfo(mRetrofit.getRetrofit(), accessToken, new FetchSiteInfo.FetchSiteInfoListener() {
@Override
public void onFetchSiteInfoSuccess(SiteInfo siteInfo, MyUserInfo myUserInfo) {
if (myUserInfo == null) {
finish();
Toast.makeText(LoginActivity.this, R.string.parse_user_info_error, Toast.LENGTH_SHORT).show();
return;
}
@Override
public void onFetchSiteInfoFailed() {
ParseAndInsertNewAccount.parseAndInsertNewAccount(mExecutor, new Handler(), name,display_name, accessToken, profileImageUrl, bannerImageUrl, authCode, finalInstance,true, mRedditDataRoomDatabase.accountDao(),
() -> {
Intent resultIntent = new Intent();
setResult(Activity.RESULT_OK, resultIntent);
finish();
});
mCurrentAccountSharedPreferences.edit().putBoolean(SharedPreferencesUtils.CAN_DOWNVOTE, true).apply();
}
boolean canDownvote = siteInfo.isEnable_downvotes();
ParseAndInsertNewAccount.parseAndInsertNewAccount(mExecutor, new Handler(), myUserInfo.getQualifiedName(), myUserInfo.getDisplayName(), accessToken, myUserInfo.getProfileImageUrl(), myUserInfo.getBannerImageUrl(), authCode, finalInstance, canDownvote, mRedditDataRoomDatabase.accountDao(),
() -> {
Intent resultIntent = new Intent();
setResult(Activity.RESULT_OK, resultIntent);
finish();
});
mCurrentAccountSharedPreferences.edit().putString(SharedPreferencesUtils.ACCESS_TOKEN, accessToken)
.putString(SharedPreferencesUtils.ACCOUNT_NAME, display_name)
.putString(SharedPreferencesUtils.ACCOUNT_QUALIFIED_NAME, name)
.putString(SharedPreferencesUtils.ACCOUNT_INSTANCE,finalInstance)
.putString(SharedPreferencesUtils.ACCOUNT_IMAGE_URL, profileImageUrl).apply();
mCurrentAccountSharedPreferences.edit()
.putString(SharedPreferencesUtils.ACCESS_TOKEN, accessToken)
.putString(SharedPreferencesUtils.ACCOUNT_NAME, myUserInfo.getDisplayName())
.putString(SharedPreferencesUtils.ACCOUNT_QUALIFIED_NAME, myUserInfo.getQualifiedName())
.putString(SharedPreferencesUtils.ACCOUNT_INSTANCE,finalInstance)
.putString(SharedPreferencesUtils.ACCOUNT_IMAGE_URL, myUserInfo.getProfileImageUrl())
.putBoolean(SharedPreferencesUtils.CAN_DOWNVOTE, canDownvote).apply();
String[] version = siteInfo.getVersion().split("\\.");
if (version.length > 0) {
Log.d("SwitchAccount", "Lemmy Version: " + version[0] + "." + version[1]);
int majorVersion = Integer.parseInt(version[0]);
int minorVersion = Integer.parseInt(version[1]);
if (majorVersion > 0 || (majorVersion == 0 && minorVersion >= 19)) {
mRetrofit.setAccessToken(accessToken);
mCurrentAccountSharedPreferences.edit().putBoolean(SharedPreferencesUtils.BEARER_TOKEN_AUTH, true).apply();
} else {
mRetrofit.setAccessToken(null);
mCurrentAccountSharedPreferences.edit().putBoolean(SharedPreferencesUtils.BEARER_TOKEN_AUTH, false).apply();
}
}
}
@Override
public void onFetchMyInfoFailed(boolean parseFailed) {
if (parseFailed) {
Toast.makeText(LoginActivity.this, R.string.parse_user_info_error, Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(LoginActivity.this, R.string.cannot_fetch_user_info, Toast.LENGTH_SHORT).show();
}
finish();
}
});
@Override
public void onFetchSiteInfoFailed(boolean parseFailed) {
if (parseFailed) {
finish();
Toast.makeText(LoginActivity.this, R.string.parse_user_info_error, Toast.LENGTH_SHORT).show();
} else {
progressBar.setVisibility(ProgressBar.GONE);
loginButton.setEnabled(true);
Toast.makeText(LoginActivity.this, R.string.cannot_fetch_user_info, Toast.LENGTH_SHORT).show();
}
}
});
} catch (JSONException e) {
throw new RuntimeException(e);
}

View File

@@ -14,6 +14,7 @@ import android.os.Bundle;
import android.os.Handler;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.Menu;
@@ -53,6 +54,7 @@ import com.google.android.material.appbar.CollapsingToolbarLayout;
import com.google.android.material.appbar.MaterialToolbar;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.navigation.NavigationView;
import com.google.android.material.snackbar.Snackbar;
import com.google.android.material.tabs.TabLayout;
import com.google.android.material.tabs.TabLayoutMediator;
import com.google.android.material.textfield.TextInputEditText;
@@ -119,12 +121,15 @@ import eu.toldi.infinityforlemmy.post.MarkPostAsRead;
import eu.toldi.infinityforlemmy.post.Post;
import eu.toldi.infinityforlemmy.post.PostPagingSource;
import eu.toldi.infinityforlemmy.readpost.InsertReadPost;
import eu.toldi.infinityforlemmy.site.FetchSiteInfo;
import eu.toldi.infinityforlemmy.site.SiteInfo;
import eu.toldi.infinityforlemmy.subreddit.ParseSubredditData;
import eu.toldi.infinityforlemmy.subreddit.SubredditData;
import eu.toldi.infinityforlemmy.subscribedsubreddit.SubscribedSubredditData;
import eu.toldi.infinityforlemmy.subscribedsubreddit.SubscribedSubredditViewModel;
import eu.toldi.infinityforlemmy.subscribeduser.SubscribedUserData;
import eu.toldi.infinityforlemmy.user.FetchUserData;
import eu.toldi.infinityforlemmy.user.MyUserInfo;
import eu.toldi.infinityforlemmy.user.UserData;
import eu.toldi.infinityforlemmy.utils.APIUtils;
import eu.toldi.infinityforlemmy.utils.CustomThemeSharedPreferencesUtils;
@@ -860,12 +865,12 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
}
} else if (stringId == R.string.enable_nsfw) {
if (sectionsPagerAdapter != null) {
mNsfwAndSpoilerSharedPreferences.edit().putBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, true).apply();
mNsfwAndSpoilerSharedPreferences.edit().putBoolean((mAccountQualifiedName == null ? "" : mAccountQualifiedName) + SharedPreferencesUtils.NSFW_BASE, true).apply();
sectionsPagerAdapter.changeNSFW(true);
}
} else if (stringId == R.string.disable_nsfw) {
if (sectionsPagerAdapter != null) {
mNsfwAndSpoilerSharedPreferences.edit().putBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, false).apply();
mNsfwAndSpoilerSharedPreferences.edit().putBoolean((mAccountQualifiedName == null ? "" : mAccountQualifiedName) + SharedPreferencesUtils.NSFW_BASE, false).apply();
sectionsPagerAdapter.changeNSFW(false);
}
} else if (stringId == R.string.settings) {
@@ -923,17 +928,17 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
navDrawerRecyclerView.setLayoutManager(new LinearLayoutManagerBugFixed(this));
navDrawerRecyclerView.setAdapter(adapter.getConcatAdapter());
int tabCount = mMainActivityTabsSharedPreferences.getInt((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_COUNT, 3);
mShowFavoriteMultiReddits = mMainActivityTabsSharedPreferences.getBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_FAVORITE_MULTIREDDITS, false);
mShowMultiReddits = mMainActivityTabsSharedPreferences.getBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_MULTIREDDITS, false);
mShowFavoriteSubscribedSubreddits = mMainActivityTabsSharedPreferences.getBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_FAVORITE_SUBSCRIBED_SUBREDDITS, false);
mShowSubscribedSubreddits = mMainActivityTabsSharedPreferences.getBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_SUBSCRIBED_SUBREDDITS, false);
int tabCount = mMainActivityTabsSharedPreferences.getInt((mAccountQualifiedName == null ? "" : mAccountQualifiedName) + SharedPreferencesUtils.MAIN_PAGE_TAB_COUNT, 3);
mShowFavoriteMultiReddits = mMainActivityTabsSharedPreferences.getBoolean((mAccountQualifiedName == null ? "" : mAccountQualifiedName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_FAVORITE_MULTIREDDITS, false);
mShowMultiReddits = mMainActivityTabsSharedPreferences.getBoolean((mAccountQualifiedName == null ? "" : mAccountQualifiedName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_MULTIREDDITS, false);
mShowFavoriteSubscribedSubreddits = mMainActivityTabsSharedPreferences.getBoolean((mAccountQualifiedName == null ? "" : mAccountQualifiedName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_FAVORITE_SUBSCRIBED_SUBREDDITS, false);
mShowSubscribedSubreddits = mMainActivityTabsSharedPreferences.getBoolean((mAccountQualifiedName == null ? "" : mAccountQualifiedName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_SUBSCRIBED_SUBREDDITS, false);
sectionsPagerAdapter = new SectionsPagerAdapter(this, tabCount, mShowFavoriteMultiReddits,
mShowMultiReddits, mShowFavoriteSubscribedSubreddits, mShowSubscribedSubreddits);
viewPager2.setAdapter(sectionsPagerAdapter);
viewPager2.setOffscreenPageLimit(ViewPager2.OFFSCREEN_PAGE_LIMIT_DEFAULT);
viewPager2.setUserInputEnabled(!mDisableSwipingBetweenTabs);
if (mMainActivityTabsSharedPreferences.getBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_TAB_NAMES, true)) {
if (mMainActivityTabsSharedPreferences.getBoolean((mAccountQualifiedName == null ? "" : mAccountQualifiedName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_TAB_NAMES, true)) {
if (mShowFavoriteMultiReddits || mShowMultiReddits || mShowFavoriteSubscribedSubreddits || mShowSubscribedSubreddits) {
tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);
} else {
@@ -942,13 +947,13 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
new TabLayoutMediator(tabLayout, viewPager2, (tab, position) -> {
switch (position) {
case 0:
Utils.setTitleWithCustomFontToTab(typeface, tab, mMainActivityTabsSharedPreferences.getString((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_TITLE, getString(R.string.subscribed_feed)));
Utils.setTitleWithCustomFontToTab(typeface, tab, mMainActivityTabsSharedPreferences.getString((mAccountQualifiedName == null ? "" : mAccountQualifiedName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_TITLE, getString(R.string.subscribed_feed)));
break;
case 1:
Utils.setTitleWithCustomFontToTab(typeface, tab, mMainActivityTabsSharedPreferences.getString((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_TITLE, getString(R.string.local)));
Utils.setTitleWithCustomFontToTab(typeface, tab, mMainActivityTabsSharedPreferences.getString((mAccountQualifiedName == null ? "" : mAccountQualifiedName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_TITLE, getString(R.string.local)));
break;
case 2:
Utils.setTitleWithCustomFontToTab(typeface, tab, mMainActivityTabsSharedPreferences.getString((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_TITLE, getString(R.string.all)));
Utils.setTitleWithCustomFontToTab(typeface, tab, mMainActivityTabsSharedPreferences.getString((mAccountQualifiedName == null ? "" : mAccountQualifiedName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_TITLE, getString(R.string.all)));
break;
}
if (position >= tabCount && (mShowFavoriteMultiReddits || mShowMultiReddits ||
@@ -996,7 +1001,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
loadSubscriptions();
multiRedditViewModel = new ViewModelProvider(this, new MultiRedditViewModel.Factory(getApplication(),
mRedditDataRoomDatabase, mAccountName == null ? "-" : mAccountName))
mRedditDataRoomDatabase, mAccountQualifiedName == null ? "-" : mAccountQualifiedName))
.get(MultiRedditViewModel.class);
multiRedditViewModel.getAllFavoriteMultiReddits().observe(this, multiReddits -> {
@@ -1109,6 +1114,11 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
.setCancelable(false)
.show();
}
@Override
public void onCheckFailed(String message) {
applySnackBarTheme(Snackbar.make(findViewById(android.R.id.content), getString(R.string.failed_to_check_token_validity,message), Snackbar.LENGTH_LONG)).show();
}
});
}
}
@@ -1138,9 +1148,35 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
@Override
public void onFetchUserDataFailed() {
mFetchUserInfoSuccess = false;
}
});
mFetchUserInfoSuccess = false;
}
});
if (mAccessToken != null) {
FetchSiteInfo.fetchSiteInfo(mRetrofit.getRetrofit(), mAccessToken, new FetchSiteInfo.FetchSiteInfoListener() {
@Override
public void onFetchSiteInfoSuccess(SiteInfo siteInfo, MyUserInfo myUserInfo) {
String[] version = siteInfo.getVersion().split("\\.");
if (version.length > 0) {
Log.d("MainActvity", "Lemmy Version: " + version[0] + "." + version[1]);
int majorVersion = Integer.parseInt(version[0]);
int minorVersion = Integer.parseInt(version[1]);
if (majorVersion > 0 || (majorVersion == 0 && minorVersion >= 19)) {
mRetrofit.setAccessToken(mAccessToken);
mCurrentAccountSharedPreferences.edit().putBoolean(SharedPreferencesUtils.BEARER_TOKEN_AUTH, true).apply();
checkUserToken();
} else {
mRetrofit.setAccessToken(null);
mCurrentAccountSharedPreferences.edit().putBoolean(SharedPreferencesUtils.BEARER_TOKEN_AUTH, false).apply();
}
}
}
@Override
public void onFetchSiteInfoFailed(boolean parseFailed) {
}
});
}
}
}
@@ -1166,7 +1202,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
int currentPostType = sectionsPagerAdapter.getCurrentPostType();
PostFragment postFragment = sectionsPagerAdapter.getCurrentFragment();
if (postFragment != null) {
SortTypeBottomSheetFragment sortTypeBottomSheetFragment = SortTypeBottomSheetFragment.getNewInstance(currentPostType != PostPagingSource.TYPE_FRONT_PAGE, postFragment.getSortType());
SortTypeBottomSheetFragment sortTypeBottomSheetFragment = SortTypeBottomSheetFragment.getNewInstance(currentPostType, postFragment.getSortType());
sortTypeBottomSheetFragment.show(getSupportFragmentManager(), sortTypeBottomSheetFragment.getTag());
}
}
@@ -1558,7 +1594,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
return false;
});
boolean nsfw = mNsfwAndSpoilerSharedPreferences.getBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, false);
boolean nsfw = mNsfwAndSpoilerSharedPreferences.getBoolean((mAccountQualifiedName == null ? "" : mAccountQualifiedName) + SharedPreferencesUtils.NSFW_BASE, false);
thingEditText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
@@ -1670,7 +1706,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
private void randomThing() {
RandomBottomSheetFragment randomBottomSheetFragment = new RandomBottomSheetFragment();
Bundle bundle = new Bundle();
bundle.putBoolean(RandomBottomSheetFragment.EXTRA_IS_NSFW, !mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_NSFW_FOREVER, false) && mNsfwAndSpoilerSharedPreferences.getBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, false));
bundle.putBoolean(RandomBottomSheetFragment.EXTRA_IS_NSFW, !mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_NSFW_FOREVER, false) && mNsfwAndSpoilerSharedPreferences.getBoolean((mAccountQualifiedName == null ? "" : mAccountQualifiedName) + SharedPreferencesUtils.NSFW_BASE, false));
randomBottomSheetFragment.setArguments(bundle);
randomBottomSheetFragment.show(getSupportFragmentManager(), randomBottomSheetFragment.getTag());
}
@@ -1731,8 +1767,8 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
@Override
public Fragment createFragment(int position) {
if (position == 0) {
int postType = mMainActivityTabsSharedPreferences.getInt((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_POST_TYPE, SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_HOME);
String name = mMainActivityTabsSharedPreferences.getString((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_NAME, "");
int postType = mMainActivityTabsSharedPreferences.getInt((mAccountQualifiedName == null ? "" : mAccountQualifiedName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_POST_TYPE, SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_HOME);
String name = mMainActivityTabsSharedPreferences.getString((mAccountQualifiedName == null ? "" : mAccountQualifiedName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_NAME, "");
return generatePostFragment(postType, name);
} else {
if (showFavoriteMultiReddits) {
@@ -1774,11 +1810,11 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
int postType;
String name;
if (position == 1) {
postType = mMainActivityTabsSharedPreferences.getInt((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_POST_TYPE, SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_POPULAR);
name = mMainActivityTabsSharedPreferences.getString((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_NAME, "");
postType = mMainActivityTabsSharedPreferences.getInt((mAccountQualifiedName == null ? "" : mAccountQualifiedName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_POST_TYPE, SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_POPULAR);
name = mMainActivityTabsSharedPreferences.getString((mAccountQualifiedName == null ? "" : mAccountQualifiedName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_NAME, "");
} else {
postType = mMainActivityTabsSharedPreferences.getInt((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_POST_TYPE, SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_ALL);
name = mMainActivityTabsSharedPreferences.getString((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_NAME, "");
postType = mMainActivityTabsSharedPreferences.getInt((mAccountQualifiedName == null ? "" : mAccountQualifiedName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_POST_TYPE, SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_ALL);
name = mMainActivityTabsSharedPreferences.getString((mAccountQualifiedName == null ? "" : mAccountQualifiedName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_NAME, "");
}
return generatePostFragment(postType, name);
}
@@ -1810,7 +1846,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
Bundle bundle = new Bundle();
bundle.putInt(PostFragment.EXTRA_POST_TYPE, mAccessToken == null ? PostPagingSource.TYPE_ANONYMOUS_FRONT_PAGE : PostPagingSource.TYPE_FRONT_PAGE);
bundle.putString(PostFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountName);
bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountQualifiedName);
fragment.setArguments(bundle);
return fragment;
} else if (postType == SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_ALL) {
@@ -1819,7 +1855,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
bundle.putInt(PostFragment.EXTRA_POST_TYPE, PostPagingSource.TYPE_FRONT_PAGE);
bundle.putString(PostFragment.EXTRA_NAME, "all");
bundle.putString(PostFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountName);
bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountQualifiedName);
fragment.setArguments(bundle);
return fragment;
} else if (postType == SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_SUBREDDIT) {
@@ -1828,7 +1864,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
bundle.putInt(PostFragment.EXTRA_POST_TYPE, PostPagingSource.TYPE_SUBREDDIT);
bundle.putString(PostFragment.EXTRA_NAME, name);
bundle.putString(PostFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountName);
bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountQualifiedName);
fragment.setArguments(bundle);
return fragment;
} else if (postType == SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_MULTIREDDIT) {
@@ -1837,7 +1873,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
bundle.putString(PostFragment.EXTRA_NAME, name);
bundle.putInt(PostFragment.EXTRA_POST_TYPE, mAccessToken == null ? PostPagingSource.TYPE_ANONYMOUS_MULTIREDDIT : PostPagingSource.TYPE_MULTI_REDDIT);
bundle.putString(PostFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountName);
bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountQualifiedName);
fragment.setArguments(bundle);
return fragment;
} else if (postType == SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_USER) {
@@ -1847,7 +1883,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
bundle.putString(PostFragment.EXTRA_USER_NAME, name);
bundle.putString(PostFragment.EXTRA_USER_WHERE, PostPagingSource.USER_WHERE_SUBMITTED);
bundle.putString(PostFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountName);
bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountQualifiedName);
fragment.setArguments(bundle);
return fragment;
} else if (postType == SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_UPVOTED
@@ -1860,7 +1896,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
bundle.putInt(PostFragment.EXTRA_POST_TYPE, PostPagingSource.TYPE_USER);
bundle.putString(PostFragment.EXTRA_USER_NAME, mAccountName);
bundle.putString(PostFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountName);
bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountQualifiedName);
bundle.putBoolean(PostFragment.EXTRA_DISABLE_READ_POSTS, true);
if (postType == SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_UPVOTED) {
@@ -1883,7 +1919,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
bundle.putInt(PostFragment.EXTRA_POST_TYPE, PostPagingSource.TYPE_FRONT_PAGE);
bundle.putString(PostFragment.EXTRA_NAME, "local");
bundle.putString(PostFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountName);
bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountQualifiedName);
fragment.setArguments(bundle);
return fragment;
}

View File

@@ -117,7 +117,7 @@ public class MultiredditSelectionActivity extends BaseActivity implements Activi
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null);
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_QUALIFIED_NAME, null);
if (savedInstanceState == null) {
bindView(true);

View File

@@ -147,7 +147,6 @@ public class PostFilterUsageListingActivity extends BaseActivity {
titleStringId = R.string.user;
break;
case PostFilterUsage.MULTIREDDIT_TYPE:
textInputEditText.setHint(R.string.settings_tab_multi_reddit_name);
titleStringId = R.string.multi_reddit;
break;
}

View File

@@ -39,7 +39,7 @@ import com.google.android.material.divider.MaterialDivider;
import com.google.android.material.materialswitch.MaterialSwitch;
import com.google.android.material.snackbar.Snackbar;
import com.google.gson.Gson;
import com.libRG.CustomTextView;
import eu.toldi.infinityforlemmy.CustomTextView;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;

View File

@@ -39,7 +39,7 @@ import com.google.android.material.divider.MaterialDivider;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.materialswitch.MaterialSwitch;
import com.google.android.material.snackbar.Snackbar;
import com.libRG.CustomTextView;
import eu.toldi.infinityforlemmy.CustomTextView;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;

View File

@@ -36,7 +36,7 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.divider.MaterialDivider;
import com.google.android.material.materialswitch.MaterialSwitch;
import com.google.android.material.snackbar.Snackbar;
import com.libRG.CustomTextView;
import eu.toldi.infinityforlemmy.CustomTextView;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;

View File

@@ -35,7 +35,7 @@ import com.google.android.material.snackbar.Snackbar;
import com.google.android.material.textfield.TextInputEditText;
import com.google.android.material.textfield.TextInputLayout;
import com.google.gson.Gson;
import com.libRG.CustomTextView;
import eu.toldi.infinityforlemmy.CustomTextView;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;

View File

@@ -35,7 +35,7 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.divider.MaterialDivider;
import com.google.android.material.materialswitch.MaterialSwitch;
import com.google.android.material.snackbar.Snackbar;
import com.libRG.CustomTextView;
import eu.toldi.infinityforlemmy.CustomTextView;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;

View File

@@ -42,7 +42,7 @@ import com.google.android.material.divider.MaterialDivider;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.materialswitch.MaterialSwitch;
import com.google.android.material.snackbar.Snackbar;
import com.libRG.CustomTextView;
import eu.toldi.infinityforlemmy.CustomTextView;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;

View File

@@ -55,8 +55,10 @@ import eu.toldi.infinityforlemmy.recentsearchquery.RecentSearchQuery;
import eu.toldi.infinityforlemmy.recentsearchquery.RecentSearchQueryViewModel;
import eu.toldi.infinityforlemmy.subreddit.ParseSubredditData;
import eu.toldi.infinityforlemmy.subreddit.SubredditData;
import eu.toldi.infinityforlemmy.subreddit.SubredditWithSelection;
import eu.toldi.infinityforlemmy.subscribedsubreddit.SubscribedSubredditData;
import eu.toldi.infinityforlemmy.utils.APIUtils;
import eu.toldi.infinityforlemmy.utils.LemmyUtils;
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
import eu.toldi.infinityforlemmy.utils.Utils;
import retrofit2.Call;
@@ -190,9 +192,9 @@ public class SearchActivity extends BaseActivity {
if (searchOnlySubreddits) {
Intent returnIntent = new Intent();
if (getIntent().getBooleanExtra(EXTRA_IS_MULTI_SELECTION, false)) {
ArrayList<String> subredditNameList = new ArrayList<>();
subredditNameList.add(subredditData.getName());
returnIntent.putStringArrayListExtra(RETURN_EXTRA_SELECTED_SUBREDDIT_NAMES, subredditNameList);
ArrayList<SubredditWithSelection> subredditNameList = new ArrayList<>();
subredditNameList.add(new SubredditWithSelection(subredditData.getName(), subredditData.getIconUrl(), LemmyUtils.actorID2FullName(subredditData.getActorId())));
returnIntent.putParcelableArrayListExtra(RETURN_EXTRA_SELECTED_SUBREDDIT_NAMES, subredditNameList);
} else {
returnIntent.putExtra(EXTRA_RETURN_SUBREDDIT_NAME, new SubscribedSubredditData(subredditData));
returnIntent.putExtra(EXTRA_RETURN_SUBREDDIT_ICON_URL, subredditData.getIconUrl());
@@ -262,7 +264,7 @@ public class SearchActivity extends BaseActivity {
});
searchEditText.setOnEditorActionListener((v, actionId, event) -> {
if ((actionId == EditorInfo.IME_ACTION_DONE || actionId == EditorInfo.IME_ACTION_SEARCH) || (event.getKeyCode() == KeyEvent.KEYCODE_ENTER && event.getAction() == KeyEvent.ACTION_DOWN )) {
if ((actionId == EditorInfo.IME_ACTION_DONE || actionId == EditorInfo.IME_ACTION_SEARCH) || (event.getKeyCode() == KeyEvent.KEYCODE_ENTER && event.getAction() == KeyEvent.ACTION_DOWN)) {
if (!searchEditText.getText().toString().isEmpty()) {
search(searchEditText.getText().toString());
return true;
@@ -385,6 +387,11 @@ public class SearchActivity extends BaseActivity {
intent.putExtra(SearchUsersResultActivity.EXTRA_QUERY, query);
intent.putExtra(SearchUsersResultActivity.EXTRA_IS_MULTI_SELECTION, getIntent().getBooleanExtra(EXTRA_IS_MULTI_SELECTION, false));
startActivityForResult(intent, USER_SEARCH_REQUEST_CODE);
} else if (query.startsWith("http://") || query.startsWith("https://")) {
Intent intent = new Intent(this, LinkResolverActivity.class);
intent.setData(Uri.parse(query));
startActivity(intent);
finish();
} else {
Intent intent = new Intent(SearchActivity.this, SearchResultActivity.class);
intent.putExtra(SearchResultActivity.EXTRA_QUERY, query);
@@ -398,6 +405,7 @@ public class SearchActivity extends BaseActivity {
}
startActivity(intent);
finish();
}
}
@@ -468,7 +476,7 @@ public class SearchActivity extends BaseActivity {
} else if (requestCode == SUBREDDIT_SEARCH_REQUEST_CODE) {
Intent returnIntent = new Intent();
if (getIntent().getBooleanExtra(EXTRA_IS_MULTI_SELECTION, false)) {
returnIntent.putStringArrayListExtra(RETURN_EXTRA_SELECTED_SUBREDDIT_NAMES, data.getStringArrayListExtra(SearchSubredditsResultActivity.RETURN_EXTRA_SELECTED_SUBREDDIT_NAMES));
returnIntent.putParcelableArrayListExtra(RETURN_EXTRA_SELECTED_SUBREDDIT_NAMES, data.getParcelableArrayListExtra(SearchSubredditsResultActivity.RETURN_EXTRA_SELECTED_SUBREDDIT_NAMES));
} else {
SubscribedSubredditData communityData = data.getParcelableExtra(SearchSubredditsResultActivity.EXTRA_RETURN_SUBREDDIT_NAME);
String iconUrl = data.getStringExtra(SearchSubredditsResultActivity.EXTRA_RETURN_SUBREDDIT_ICON_URL);

View File

@@ -59,13 +59,13 @@ import eu.toldi.infinityforlemmy.bottomsheetfragments.FABMoreOptionsBottomSheetF
import eu.toldi.infinityforlemmy.bottomsheetfragments.PostLayoutBottomSheetFragment;
import eu.toldi.infinityforlemmy.bottomsheetfragments.PostTypeBottomSheetFragment;
import eu.toldi.infinityforlemmy.bottomsheetfragments.RandomBottomSheetFragment;
import eu.toldi.infinityforlemmy.bottomsheetfragments.SearchPostSortTypeBottomSheetFragment;
import eu.toldi.infinityforlemmy.bottomsheetfragments.SearchUserAndSubredditSortTypeBottomSheetFragment;
import eu.toldi.infinityforlemmy.bottomsheetfragments.SortTimeBottomSheetFragment;
import eu.toldi.infinityforlemmy.bottomsheetfragments.SortTypeBottomSheetFragment;
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
import eu.toldi.infinityforlemmy.customviews.slidr.Slidr;
import eu.toldi.infinityforlemmy.events.ChangeNSFWEvent;
import eu.toldi.infinityforlemmy.events.SwitchAccountEvent;
import eu.toldi.infinityforlemmy.fragments.CommentsListingFragment;
import eu.toldi.infinityforlemmy.fragments.PostFragment;
import eu.toldi.infinityforlemmy.fragments.SubredditListingFragment;
import eu.toldi.infinityforlemmy.fragments.UserListingFragment;
@@ -271,6 +271,9 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
case 2:
Utils.setTitleWithCustomFontToTab(typeface, tab, getString(R.string.users));
break;
case 3:
Utils.setTitleWithCustomFontToTab(typeface, tab, getString(R.string.comments));
break;
}
}).attach();
fixViewPager2Sensitivity(viewPager2);
@@ -336,7 +339,7 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_CHANGE_SORT_TYPE: {
Fragment fragment = sectionsPagerAdapter.getCurrentFragment();
if (fragment instanceof PostFragment) {
SearchPostSortTypeBottomSheetFragment searchPostSortTypeBottomSheetFragment = SearchPostSortTypeBottomSheetFragment.getNewInstance(((PostFragment) fragment).getSortType());
SortTypeBottomSheetFragment searchPostSortTypeBottomSheetFragment = SortTypeBottomSheetFragment.getNewInstance(SortTypeBottomSheetFragment.PAGE_TYPE_SEARCH,((PostFragment) fragment).getSortType());
searchPostSortTypeBottomSheetFragment.show(getSupportFragmentManager(), searchPostSortTypeBottomSheetFragment.getTag());
}
break;
@@ -402,17 +405,18 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
private void displaySortTypeBottomSheetFragment() {
Fragment fragment = sectionsPagerAdapter.getCurrentFragment();
if (fragment instanceof PostFragment) {
SearchPostSortTypeBottomSheetFragment searchPostSortTypeBottomSheetFragment = SearchPostSortTypeBottomSheetFragment.getNewInstance(((PostFragment) fragment).getSortType());
SortTypeBottomSheetFragment searchPostSortTypeBottomSheetFragment = SortTypeBottomSheetFragment.getNewInstance(SortTypeBottomSheetFragment.PAGE_TYPE_SEARCH,((PostFragment) fragment).getSortType());
searchPostSortTypeBottomSheetFragment.show(getSupportFragmentManager(), searchPostSortTypeBottomSheetFragment.getTag());
} else {
if (fragment instanceof SubredditListingFragment) {
SearchUserAndSubredditSortTypeBottomSheetFragment searchUserAndSubredditSortTypeBottomSheetFragment
= SearchUserAndSubredditSortTypeBottomSheetFragment.getNewInstance(viewPager2.getCurrentItem(), ((SubredditListingFragment) fragment).getSortType());
searchUserAndSubredditSortTypeBottomSheetFragment.show(getSupportFragmentManager(), searchUserAndSubredditSortTypeBottomSheetFragment.getTag());
SortTypeBottomSheetFragment searchPostSortTypeBottomSheetFragment = SortTypeBottomSheetFragment.getNewInstance(SortTypeBottomSheetFragment.PAGE_TYPE_SEARCH,((SubredditListingFragment) fragment).getSortType());
searchPostSortTypeBottomSheetFragment.show(getSupportFragmentManager(), searchPostSortTypeBottomSheetFragment.getTag());
} else if (fragment instanceof UserListingFragment) {
SearchUserAndSubredditSortTypeBottomSheetFragment searchUserAndSubredditSortTypeBottomSheetFragment
= SearchUserAndSubredditSortTypeBottomSheetFragment.getNewInstance(viewPager2.getCurrentItem(), ((UserListingFragment) fragment).getSortType());
searchUserAndSubredditSortTypeBottomSheetFragment.show(getSupportFragmentManager(), searchUserAndSubredditSortTypeBottomSheetFragment.getTag());
SortTypeBottomSheetFragment searchPostSortTypeBottomSheetFragment = SortTypeBottomSheetFragment.getNewInstance(SortTypeBottomSheetFragment.PAGE_TYPE_SEARCH,((UserListingFragment) fragment).getSortType());
searchPostSortTypeBottomSheetFragment.show(getSupportFragmentManager(), searchPostSortTypeBottomSheetFragment.getTag());
} else if (fragment instanceof CommentsListingFragment) {
SortTypeBottomSheetFragment searchPostSortTypeBottomSheetFragment = SortTypeBottomSheetFragment.getNewInstance(SortTypeBottomSheetFragment.PAGE_TYPE_SEARCH,((CommentsListingFragment) fragment).getSortType());
searchPostSortTypeBottomSheetFragment.show(getSupportFragmentManager(), searchPostSortTypeBottomSheetFragment.getTag());
}
}
}
@@ -472,7 +476,6 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
if (sectionsPagerAdapter != null) {
sectionsPagerAdapter.changeSortType(sortType);
}
}
@Override
@@ -776,7 +779,7 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
bundle.putString(PostFragment.EXTRA_QUERY, mQuery);
bundle.putString(PostFragment.EXTRA_TRENDING_SOURCE, getIntent().getStringExtra(EXTRA_TRENDING_SOURCE));
bundle.putString(PostFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountName);
bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountQualifiedName);
mFragment.setArguments(bundle);
return mFragment;
}
@@ -791,7 +794,7 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
mFragment.setArguments(bundle);
return mFragment;
}
default: {
case 2: {
UserListingFragment mFragment = new UserListingFragment();
Bundle bundle = new Bundle();
bundle.putString(UserListingFragment.EXTRA_QUERY, mQuery);
@@ -801,6 +804,15 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
mFragment.setArguments(bundle);
return mFragment;
}
default: {
CommentsListingFragment mFragment = new CommentsListingFragment();
Bundle bundle = new Bundle();
bundle.putString(CommentsListingFragment.EXTRA_SEARCH_QUERY, mQuery);
bundle.putString(CommentsListingFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
bundle.putString(CommentsListingFragment.EXTRA_ACCOUNT_NAME, mAccountName);
mFragment.setArguments(bundle);
return mFragment;
}
}
}
@@ -825,9 +837,19 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
void changeSortType(SortType sortType) {
Fragment fragment = getCurrentFragment();
if (fragment instanceof PostFragment) {
((PostFragment) fragment).changeSortType(sortType);
displaySortTypeInToolbar();
} else if (fragment instanceof SubredditListingFragment) {
((SubredditListingFragment) fragment).changeSortType(sortType);
displaySortTypeInToolbar();
} else if (fragment instanceof UserListingFragment) {
((UserListingFragment) fragment).changeSortType(sortType);
displaySortTypeInToolbar();
} else if (fragment instanceof CommentsListingFragment) {
((CommentsListingFragment) fragment).changeSortType(sortType);
displaySortTypeInToolbar();
}
}
@@ -870,6 +892,8 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
((SubredditListingFragment) fragment).goBackToTop();
} else if (fragment instanceof UserListingFragment) {
((UserListingFragment) fragment).goBackToTop();
} else if (fragment instanceof CommentsListingFragment) {
((CommentsListingFragment) fragment).goBackToTop();
}
}
@@ -884,6 +908,9 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
} else if (fragment instanceof UserListingFragment) {
SortType sortType = ((UserListingFragment) fragment).getSortType();
Utils.displaySortTypeInToolbar(sortType, toolbar);
} else if (fragment instanceof CommentsListingFragment) {
SortType sortType = ((CommentsListingFragment) fragment).getSortType();
Utils.displaySortTypeInToolbar(sortType, toolbar);
}
}
@@ -903,7 +930,7 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
@Override
public int getItemCount() {
return 3;
return 4;
}
}

View File

@@ -35,6 +35,7 @@ import eu.toldi.infinityforlemmy.customviews.slidr.Slidr;
import eu.toldi.infinityforlemmy.events.SwitchAccountEvent;
import eu.toldi.infinityforlemmy.fragments.SubredditListingFragment;
import eu.toldi.infinityforlemmy.subreddit.SubredditData;
import eu.toldi.infinityforlemmy.subreddit.SubredditWithSelection;
import eu.toldi.infinityforlemmy.subscribedsubreddit.SubscribedSubredditData;
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
@@ -171,9 +172,9 @@ public class SearchSubredditsResultActivity extends BaseActivity implements Acti
return true;
} else if (item.getItemId() == R.id.action_save_search_subreddits_result_activity) {
if (mFragment != null) {
ArrayList<String> selectedSubredditNames = ((SubredditListingFragment) mFragment).getSelectedSubredditNames();
ArrayList<SubredditWithSelection> selectedSubredditNames = ((SubredditListingFragment) mFragment).getSelectedSubredditNames();
Intent returnIntent = new Intent();
returnIntent.putStringArrayListExtra(RETURN_EXTRA_SELECTED_SUBREDDIT_NAMES, selectedSubredditNames);
returnIntent.putParcelableArrayListExtra(RETURN_EXTRA_SELECTED_SUBREDDIT_NAMES, selectedSubredditNames);
setResult(Activity.RESULT_OK, returnIntent);
finish();
}

View File

@@ -138,7 +138,7 @@ public class SelectUserFlairActivity extends BaseActivity implements ActivityToo
flairEditText.requestFocus();
Utils.showKeyboard(this, new Handler(), flairEditText);
new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme)
.setTitle(R.string.edit_flair)
.setTitle("")
.setView(dialogView)
.setPositiveButton(R.string.ok, (dialogInterface, i)
-> {
@@ -156,13 +156,13 @@ public class SelectUserFlairActivity extends BaseActivity implements ActivityToo
} else {
if (userFlair == null) {
new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme)
.setTitle(R.string.clear_user_flair)
.setTitle("")
.setPositiveButton(R.string.yes, (dialogInterface, i) -> selectUserFlair(userFlair))
.setNegativeButton(R.string.no, null)
.show();
} else {
new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme)
.setTitle(R.string.select_this_user_flair)
.setTitle("")
.setMessage(userFlair.getText())
.setPositiveButton(R.string.yes, (dialogInterface, i) -> selectUserFlair(userFlair))
.setNegativeButton(R.string.no, null)
@@ -181,9 +181,9 @@ public class SelectUserFlairActivity extends BaseActivity implements ActivityToo
@Override
public void success() {
if (userFlair == null) {
Toast.makeText(SelectUserFlairActivity.this, R.string.clear_user_flair_success, Toast.LENGTH_SHORT).show();
Toast.makeText(SelectUserFlairActivity.this, "", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(SelectUserFlairActivity.this, R.string.select_user_flair_success, Toast.LENGTH_SHORT).show();
Toast.makeText(SelectUserFlairActivity.this, "", Toast.LENGTH_SHORT).show();
}
finish();
}
@@ -192,9 +192,9 @@ public class SelectUserFlairActivity extends BaseActivity implements ActivityToo
public void failed(String errorMessage) {
if (errorMessage == null || errorMessage.equals("")) {
if (userFlair == null) {
Snackbar.make(coordinatorLayout, R.string.clear_user_flair_success, Snackbar.LENGTH_SHORT).show();
Snackbar.make(coordinatorLayout, "", Snackbar.LENGTH_SHORT).show();
} else {
Snackbar.make(coordinatorLayout, R.string.select_user_flair_success, Snackbar.LENGTH_SHORT).show();
Snackbar.make(coordinatorLayout, "", Snackbar.LENGTH_SHORT).show();
}
} else {
Snackbar.make(coordinatorLayout, errorMessage, Snackbar.LENGTH_SHORT).show();

View File

@@ -18,7 +18,6 @@ import com.google.android.material.appbar.CollapsingToolbarLayout;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import java.util.ArrayList;
import java.util.Collections;
import javax.inject.Inject;
import javax.inject.Named;
@@ -29,10 +28,10 @@ import eu.toldi.infinityforlemmy.ActivityToolbarInterface;
import eu.toldi.infinityforlemmy.Infinity;
import eu.toldi.infinityforlemmy.R;
import eu.toldi.infinityforlemmy.adapters.SelectedSubredditsRecyclerViewAdapter;
import eu.toldi.infinityforlemmy.bottomsheetfragments.SelectSubredditsOrUsersOptionsBottomSheetFragment;
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
import eu.toldi.infinityforlemmy.customviews.LinearLayoutManagerBugFixed;
import eu.toldi.infinityforlemmy.customviews.slidr.Slidr;
import eu.toldi.infinityforlemmy.subreddit.SubredditWithSelection;
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
public class SelectedSubredditsAndUsersActivity extends BaseActivity implements ActivityToolbarInterface {
@@ -62,7 +61,7 @@ public class SelectedSubredditsAndUsersActivity extends BaseActivity implements
CustomThemeWrapper mCustomThemeWrapper;
private LinearLayoutManagerBugFixed linearLayoutManager;
private SelectedSubredditsRecyclerViewAdapter adapter;
private ArrayList<String> subreddits;
private ArrayList<SubredditWithSelection> subreddits;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -86,12 +85,11 @@ public class SelectedSubredditsAndUsersActivity extends BaseActivity implements
setToolbarGoToTop(toolbar);
if (savedInstanceState != null) {
subreddits = savedInstanceState.getStringArrayList(SELECTED_SUBREDDITS_STATE);
subreddits = savedInstanceState.getParcelableArrayList(SELECTED_SUBREDDITS_STATE);
} else {
subreddits = getIntent().getStringArrayListExtra(EXTRA_SELECTED_SUBREDDITS);
subreddits = getIntent().getParcelableArrayListExtra(EXTRA_SELECTED_SUBREDDITS);
}
Collections.sort(subreddits);
adapter = new SelectedSubredditsRecyclerViewAdapter(this, mCustomThemeWrapper, subreddits);
linearLayoutManager = new LinearLayoutManagerBugFixed(this);
@@ -110,8 +108,7 @@ public class SelectedSubredditsAndUsersActivity extends BaseActivity implements
});
fab.setOnClickListener(view -> {
SelectSubredditsOrUsersOptionsBottomSheetFragment selectSubredditsOrUsersOptionsBottomSheetFragment = new SelectSubredditsOrUsersOptionsBottomSheetFragment();
selectSubredditsOrUsersOptionsBottomSheetFragment.show(getSupportFragmentManager(), selectSubredditsOrUsersOptionsBottomSheetFragment.getTag());
selectSubreddits();
});
}
@@ -158,7 +155,7 @@ public class SelectedSubredditsAndUsersActivity extends BaseActivity implements
if (subreddits == null) {
subreddits = new ArrayList<>();
}
subreddits = data.getStringArrayListExtra(SubredditMultiselectionActivity.EXTRA_RETURN_SELECTED_SUBREDDITS);
subreddits = data.getParcelableArrayListExtra(SubredditMultiselectionActivity.EXTRA_RETURN_SELECTED_SUBREDDITS);
adapter.addSubreddits(subreddits);
}
} else if (requestCode == USER_SELECTION_REQUEST_CODE) {
@@ -176,7 +173,7 @@ public class SelectedSubredditsAndUsersActivity extends BaseActivity implements
protected void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
if (adapter != null) {
outState.putStringArrayList(SELECTED_SUBREDDITS_STATE, adapter.getSubreddits());
outState.putParcelableArrayList(SELECTED_SUBREDDITS_STATE, adapter.getSubreddits());
}
}

View File

@@ -81,7 +81,7 @@ public class SettingsActivity extends BaseActivity implements
setSupportActionBar(binding.toolbarSettingsActivity);
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null);
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_QUALIFIED_NAME, null);
if (savedInstanceState == null) {
getSupportFragmentManager()

View File

@@ -37,7 +37,7 @@ import com.google.android.material.button.MaterialButton;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.materialswitch.MaterialSwitch;
import com.google.android.material.snackbar.Snackbar;
import com.libRG.CustomTextView;
import eu.toldi.infinityforlemmy.CustomTextView;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
@@ -71,7 +71,7 @@ import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
import pl.droidsonroids.gif.GifImageView;
import retrofit2.Retrofit;
public class SubmitCrosspostActivity extends BaseActivity implements FlairBottomSheetFragment.FlairSelectionCallback,
public class SubmitCrosspostActivity extends BaseActivity implements
AccountChooserBottomSheetFragment.AccountChooserListener {
public static final String EXTRA_POST = "EP";
@@ -110,8 +110,6 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom
MaterialButton rulesButton;
@BindView(R.id.divider_1_submit_crosspost_activity)
View divider1;
@BindView(R.id.flair_custom_text_view_submit_crosspost_activity)
CustomTextView flairTextView;
@BindView(R.id.nsfw_custom_text_view_submit_crosspost_activity)
CustomTextView nsfwTextView;
@BindView(R.id.divider_2_submit_crosspost_activity)
@@ -240,7 +238,6 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom
if (subredditName != null) {
subredditNameTextView.setTextColor(primaryTextColor);
subredditNameTextView.setText(subredditName);
flairTextView.setVisibility(View.VISIBLE);
if (!loadSubredditIconSuccessful) {
loadSubredditIcon();
}
@@ -251,12 +248,6 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom
mPostingSnackbar.show();
}
if (flair != null) {
flairTextView.setText(flair.getText());
flairTextView.setBackgroundColor(flairBackgroundColor);
flairTextView.setBorderColor(flairBackgroundColor);
flairTextView.setTextColor(flairTextColor);
}
if (isNSFW) {
nsfwTextView.setBackgroundColor(nsfwBackgroundColor);
nsfwTextView.setBorderColor(nsfwBackgroundColor);
@@ -342,27 +333,6 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom
}
});
flairTextView.setOnClickListener(view -> {
if (flair == null) {
flairSelectionBottomSheetFragment = new FlairBottomSheetFragment();
Bundle bundle = new Bundle();
bundle.putString(FlairBottomSheetFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
if (subredditIsUser) {
bundle.putString(FlairBottomSheetFragment.EXTRA_SUBREDDIT_NAME, "u_" + subredditName);
} else {
bundle.putString(FlairBottomSheetFragment.EXTRA_SUBREDDIT_NAME, subredditName);
}
flairSelectionBottomSheetFragment.setArguments(bundle);
flairSelectionBottomSheetFragment.show(getSupportFragmentManager(), flairSelectionBottomSheetFragment.getTag());
} else {
flairTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
flairTextView.setTextColor(primaryTextColor);
flairTextView.setText(getString(R.string.flair));
flair = null;
}
});
nsfwTextView.setOnClickListener(view -> {
if (!isNSFW) {
nsfwTextView.setBackgroundColor(nsfwBackgroundColor);
@@ -442,7 +412,6 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom
spoilerTextColor = mCustomThemeWrapper.getSpoilerTextColor();
nsfwBackgroundColor = mCustomThemeWrapper.getNsfwBackgroundColor();
nsfwTextColor = mCustomThemeWrapper.getNsfwTextColor();
flairTextView.setTextColor(primaryTextColor);
nsfwTextView.setTextColor(primaryTextColor);
titleEditText.setTextColor(primaryTextColor);
titleEditText.setHintTextColor(secondaryTextColor);
@@ -454,7 +423,6 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom
subredditNameTextView.setTypeface(typeface);
rulesButton.setTypeface(typeface);
receivePostReplyNotificationsTextView.setTypeface(typeface);
flairTextView.setTypeface(typeface);
nsfwTextView.setTypeface(typeface);
titleEditText.setTypeface(typeface);
}
@@ -612,10 +580,6 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom
subredditNameTextView.setText(subredditName);
displaySubredditIcon();
flairTextView.setVisibility(View.VISIBLE);
flairTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
flairTextView.setTextColor(primaryTextColor);
flairTextView.setText(getString(R.string.flair));
flair = null;
}
}
@@ -627,14 +591,6 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom
super.onDestroy();
}
@Override
public void flairSelected(Flair flair) {
this.flair = flair;
flairTextView.setText(flair.getText());
flairTextView.setBackgroundColor(flairBackgroundColor);
flairTextView.setBorderColor(flairBackgroundColor);
flairTextView.setTextColor(flairTextColor);
}
@Override
public void onAccountSelected(Account account) {

View File

@@ -37,13 +37,14 @@ import eu.toldi.infinityforlemmy.ActivityToolbarInterface;
import eu.toldi.infinityforlemmy.Infinity;
import eu.toldi.infinityforlemmy.R;
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
import eu.toldi.infinityforlemmy.RetrofitHolder;
import eu.toldi.infinityforlemmy.adapters.SubredditMultiselectionRecyclerViewAdapter;
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
import eu.toldi.infinityforlemmy.customviews.LinearLayoutManagerBugFixed;
import eu.toldi.infinityforlemmy.customviews.slidr.Slidr;
import eu.toldi.infinityforlemmy.subreddit.SubredditWithSelection;
import eu.toldi.infinityforlemmy.subscribedsubreddit.SubscribedSubredditViewModel;
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
import retrofit2.Retrofit;
public class SubredditMultiselectionActivity extends BaseActivity implements ActivityToolbarInterface {
@@ -70,8 +71,8 @@ public class SubredditMultiselectionActivity extends BaseActivity implements Act
@BindView(R.id.error_text_view_subscribed_subreddits_multiselection_activity)
TextView mErrorTextView;
@Inject
@Named("oauth")
Retrofit mOauthRetrofit;
@Named("no_oauth")
RetrofitHolder mRetrofit;
@Inject
RedditDataRoomDatabase mRedditDataRoomDatabase;
@Inject
@@ -131,7 +132,7 @@ public class SubredditMultiselectionActivity extends BaseActivity implements Act
mSwipeRefreshLayout.setEnabled(false);
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, "-");
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_QUALIFIED_NAME, "-");
bindView();
}
@@ -150,7 +151,7 @@ public class SubredditMultiselectionActivity extends BaseActivity implements Act
if (subscribedSubredditData == null || subscribedSubredditData.size() == 0) {
mRecyclerView.setVisibility(View.GONE);
mLinearLayout.setVisibility(View.VISIBLE);
mGlide.load(R.drawable.error_image).into(mImageView);
mGlide.load(R.mipmap.ic_launcher_round).into(mImageView);
} else {
mLinearLayout.setVisibility(View.GONE);
mRecyclerView.setVisibility(View.VISIBLE);
@@ -177,7 +178,7 @@ public class SubredditMultiselectionActivity extends BaseActivity implements Act
} else if (itemId == R.id.action_save_subreddit_multiselection_activity) {
if (mAdapter != null) {
Intent returnIntent = new Intent();
returnIntent.putStringArrayListExtra(EXTRA_RETURN_SELECTED_SUBREDDITS,
returnIntent.putExtra(EXTRA_RETURN_SELECTED_SUBREDDITS,
mAdapter.getAllSelectedSubreddits());
setResult(RESULT_OK, returnIntent);
}
@@ -198,12 +199,12 @@ public class SubredditMultiselectionActivity extends BaseActivity implements Act
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == SUBREDDIT_SEARCH_REQUEST_CODE && resultCode == RESULT_OK && data != null && mAdapter != null) {
Intent returnIntent = new Intent();
ArrayList<String> selectedSubreddits = mAdapter.getAllSelectedSubreddits();
ArrayList<String> searchedSubreddits = data.getStringArrayListExtra(SearchActivity.RETURN_EXTRA_SELECTED_SUBREDDIT_NAMES);
ArrayList<SubredditWithSelection> selectedSubreddits = mAdapter.getAllSelectedSubreddits();
ArrayList<SubredditWithSelection> searchedSubreddits = data.getParcelableArrayListExtra(SearchActivity.RETURN_EXTRA_SELECTED_SUBREDDIT_NAMES);
if (searchedSubreddits != null) {
selectedSubreddits.addAll(searchedSubreddits);
}
returnIntent.putStringArrayListExtra(EXTRA_RETURN_SELECTED_SUBREDDITS, selectedSubreddits);
returnIntent.putParcelableArrayListExtra(EXTRA_RETURN_SELECTED_SUBREDDITS, selectedSubreddits);
setResult(RESULT_OK, returnIntent);
finish();
}

View File

@@ -63,7 +63,6 @@ import eu.toldi.infinityforlemmy.events.SwitchAccountEvent;
import eu.toldi.infinityforlemmy.fragments.FollowedUsersListingFragment;
import eu.toldi.infinityforlemmy.fragments.MultiRedditListingFragment;
import eu.toldi.infinityforlemmy.fragments.SubscribedSubredditsListingFragment;
import eu.toldi.infinityforlemmy.multireddit.DeleteMultiReddit;
import eu.toldi.infinityforlemmy.multireddit.FetchMyMultiReddits;
import eu.toldi.infinityforlemmy.multireddit.MultiReddit;
import eu.toldi.infinityforlemmy.subreddit.SubredditData;
@@ -236,7 +235,7 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
viewPager.setAdapter(sectionsPagerAdapter);
viewPager.setOffscreenPageLimit(1);
if (viewPager.getCurrentItem() != 2) {
if (viewPager.getCurrentItem() != 1) {
fab.hide();
}
viewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@@ -247,7 +246,7 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
fab.hide();
} else {
lockSwipeRightToGoBack();
if (position != 2) {
if (position != 1) {
fab.hide();
} else {
fab.show();
@@ -258,7 +257,7 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
tabLayout.setupWithViewPager(viewPager);
if (showMultiReddits) {
viewPager.setCurrentItem(2, false);
viewPager.setCurrentItem(1, false);
}
loadSubscriptions(false);
@@ -386,7 +385,7 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
FetchMyMultiReddits.fetchMyMultiReddits(mOauthRetrofit, mAccessToken, new FetchMyMultiReddits.FetchMyMultiRedditsListener() {
@Override
public void success(ArrayList<MultiReddit> multiReddits) {
InsertMultireddit.insertMultireddits(mExecutor, new Handler(), mRedditDataRoomDatabase, multiReddits, mAccountName, () -> {
InsertMultireddit.insertMultireddits(mExecutor, new Handler(), mRedditDataRoomDatabase, multiReddits, mAccountQualifiedName, () -> {
mInsertMultiredditSuccess = true;
sectionsPagerAdapter.stopMultiRedditRefreshProgressbar();
});
@@ -408,27 +407,11 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
.setMessage(R.string.delete_multi_reddit_dialog_message)
.setPositiveButton(R.string.delete, (dialogInterface, i)
-> {
if (mAccessToken == null) {
DeleteMultiredditInDatabase.deleteMultiredditInDatabase(mExecutor, new Handler(), mRedditDataRoomDatabase, mAccountName, multiReddit.getPath(),
() -> Toast.makeText(SubscribedThingListingActivity.this,
R.string.delete_multi_reddit_success, Toast.LENGTH_SHORT).show());
} else {
DeleteMultiReddit.deleteMultiReddit(mExecutor, new Handler(), mOauthRetrofit, mRedditDataRoomDatabase,
mAccessToken, mAccountName, multiReddit.getPath(), new DeleteMultiReddit.DeleteMultiRedditListener() {
@Override
public void success() {
Toast.makeText(SubscribedThingListingActivity.this,
R.string.delete_multi_reddit_success, Toast.LENGTH_SHORT).show();
//loadMultiReddits();
}
@Override
public void failed() {
Toast.makeText(SubscribedThingListingActivity.this,
R.string.delete_multi_reddit_failed, Toast.LENGTH_SHORT).show();
}
});
}
DeleteMultiredditInDatabase.deleteMultiredditInDatabase(mExecutor, new Handler(), mRedditDataRoomDatabase, mAccountQualifiedName, multiReddit.getPath(),
() -> Toast.makeText(SubscribedThingListingActivity.this,
R.string.delete_multi_reddit_success, Toast.LENGTH_SHORT).show());
})
.setNegativeButton(R.string.cancel, null)
.show();
@@ -484,7 +467,7 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
@Override
public Fragment getItem(int position) {
switch (position) {
default:
case 0: {
SubscribedSubredditsListingFragment fragment = new SubscribedSubredditsListingFragment();
Bundle bundle = new Bundle();
@@ -495,12 +478,20 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
fragment.setArguments(bundle);
return fragment;
}
default: {
MultiRedditListingFragment fragment = new MultiRedditListingFragment();
Bundle bundle = new Bundle();
bundle.putString(MultiRedditListingFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
bundle.putString(MultiRedditListingFragment.EXTRA_ACCOUNT_NAME, mAccountName == null ? "-" : mAccountQualifiedName);
fragment.setArguments(bundle);
return fragment;
}
}
}
@Override
public int getCount() {
return 1;
return 2;
}
@Override
@@ -509,8 +500,6 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
case 0:
return Utils.getTabTextWithCustomFont(typeface, getString(R.string.communities));
case 1:
return Utils.getTabTextWithCustomFont(typeface, getString(R.string.users));
case 2:
return Utils.getTabTextWithCustomFont(typeface, getString(R.string.multi_reddits));
}
@@ -523,8 +512,6 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
Fragment fragment = (Fragment) super.instantiateItem(container, position);
if (position == 0) {
subscribedSubredditsListingFragment = (SubscribedSubredditsListingFragment) fragment;
} else if (position == 1) {
followedUsersListingFragment = (FollowedUsersListingFragment) fragment;
} else {
multiRedditListingFragment = (MultiRedditListingFragment) fragment;
}

View File

@@ -278,7 +278,7 @@ public class TrendingActivity extends BaseActivity {
private void showErrorView(int stringId) {
errorLinearLayout.setVisibility(View.VISIBLE);
mGlide.load(R.drawable.error_image).into(errorImageView);
mGlide.load(R.mipmap.ic_launcher_round).into(errorImageView);
errorTextView.setText(stringId);
}

View File

@@ -62,10 +62,8 @@ import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
import eu.toldi.infinityforlemmy.customviews.NavigationWrapper;
import eu.toldi.infinityforlemmy.customviews.slidr.Slidr;
import eu.toldi.infinityforlemmy.events.GoBackToMainPageEvent;
import eu.toldi.infinityforlemmy.events.RefreshMultiRedditsEvent;
import eu.toldi.infinityforlemmy.events.SwitchAccountEvent;
import eu.toldi.infinityforlemmy.fragments.PostFragment;
import eu.toldi.infinityforlemmy.multireddit.DeleteMultiReddit;
import eu.toldi.infinityforlemmy.multireddit.MultiReddit;
import eu.toldi.infinityforlemmy.post.MarkPostAsRead;
import eu.toldi.infinityforlemmy.post.Post;
@@ -430,7 +428,7 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
bundle.putString(PostFragment.EXTRA_NAME, multiPath);
bundle.putInt(PostFragment.EXTRA_POST_TYPE, mAccessToken == null ? PostPagingSource.TYPE_ANONYMOUS_MULTIREDDIT : PostPagingSource.TYPE_MULTI_REDDIT);
bundle.putString(PostFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountName);
bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountQualifiedName);
mFragment.setArguments(bundle);
getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_view_multi_reddit_detail_activity, mFragment).commit();
}
@@ -592,7 +590,7 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
private void showSortTypeBottomSheetFragment() {
if (mFragment instanceof PostFragment) {
SortTypeBottomSheetFragment sortTypeBottomSheetFragment = SortTypeBottomSheetFragment.getNewInstance(true, ((PostFragment) mFragment).getSortType());
SortTypeBottomSheetFragment sortTypeBottomSheetFragment = SortTypeBottomSheetFragment.getNewInstance(SortTypeBottomSheetFragment.PAGE_TYPE_MULTICOMMUNITY, ((PostFragment) mFragment).getSortType());
sortTypeBottomSheetFragment.show(getSupportFragmentManager(), sortTypeBottomSheetFragment.getTag());
}
}
@@ -678,7 +676,7 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
-> {
Utils.hideKeyboard(this);
Intent subredditIntent = new Intent(this, ViewSubredditDetailActivity.class);
subredditIntent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, thingEditText.getText().toString());
subredditIntent.putExtra(ViewSubredditDetailActivity.EXTRA_COMMUNITY_FULL_NAME_KEY, thingEditText.getText().toString());
startActivity(subredditIntent);
})
.setNegativeButton(R.string.cancel, (dialogInterface, i) -> {
@@ -699,7 +697,7 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
if (i == EditorInfo.IME_ACTION_DONE) {
Utils.hideKeyboard(this);
Intent userIntent = new Intent(this, ViewUserDetailActivity.class);
userIntent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, thingEditText.getText().toString());
userIntent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, thingEditText.getText().toString());
startActivity(userIntent);
return true;
}
@@ -764,6 +762,7 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
Intent editIntent = new Intent(this, EditMultiRedditActivity.class);
editIntent.putExtra(EditMultiRedditActivity.EXTRA_MULTI_PATH, multiPath);
startActivity(editIntent);
finish();
return true;
} else if (itemId == R.id.action_delete_view_multi_reddit_detail_activity) {
new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme)
@@ -771,30 +770,13 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
.setMessage(R.string.delete_multi_reddit_dialog_message)
.setPositiveButton(R.string.delete, (dialogInterface, i)
-> {
if (mAccessToken == null) {
DeleteMultiredditInDatabase.deleteMultiredditInDatabase(mExecutor, new Handler(), mRedditDataRoomDatabase, mAccountName, multiPath,
() -> {
Toast.makeText(this, R.string.delete_multi_reddit_success, Toast.LENGTH_SHORT).show();
finish();
});
} else {
DeleteMultiReddit.deleteMultiReddit(mExecutor, new Handler(), mOauthRetrofit, mRedditDataRoomDatabase,
mAccessToken, mAccountName, multiPath, new DeleteMultiReddit.DeleteMultiRedditListener() {
@Override
public void success() {
Toast.makeText(ViewMultiRedditDetailActivity.this,
R.string.delete_multi_reddit_success, Toast.LENGTH_SHORT).show();
EventBus.getDefault().post(new RefreshMultiRedditsEvent());
finish();
}
@Override
public void failed() {
Toast.makeText(ViewMultiRedditDetailActivity.this,
R.string.delete_multi_reddit_failed, Toast.LENGTH_SHORT).show();
}
});
}
DeleteMultiredditInDatabase.deleteMultiredditInDatabase(mExecutor, new Handler(), mRedditDataRoomDatabase, mAccountName, multiPath,
() -> {
Toast.makeText(this, R.string.delete_multi_reddit_success, Toast.LENGTH_SHORT).show();
finish();
});
})
.setNegativeButton(R.string.cancel, null)
.show();

View File

@@ -392,6 +392,14 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null);
mAccountQualifiedName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_QUALIFIED_NAME, null);
if (mAccessToken != null) {
mRetrofit.setAccessToken(mAccessToken);
}
String instance = (mAccessToken == null) ? mSharedPreferences.getString(SharedPreferencesUtils.ANONYMOUS_ACCOUNT_INSTANCE, APIUtils.API_BASE_URI) : mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_INSTANCE, null);
if (instance != null) {
mRetrofit.setBaseURL(instance);
}
if (savedInstanceState == null) {
mMessageFullname = getIntent().getIntExtra(EXTRA_MESSAGE_FULLNAME, 0);
mNewAccountName = getIntent().getStringExtra(EXTRA_NEW_ACCOUNT_NAME);
@@ -1206,7 +1214,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
private void displaySortTypeBottomSheetFragment() {
Fragment fragment = fragmentManager.findFragmentByTag("f0");
if (fragment instanceof PostFragment) {
SortTypeBottomSheetFragment sortTypeBottomSheetFragment = SortTypeBottomSheetFragment.getNewInstance(true, ((PostFragment) fragment).getSortType());
SortTypeBottomSheetFragment sortTypeBottomSheetFragment = SortTypeBottomSheetFragment.getNewInstance(SortTypeBottomSheetFragment.PAGE_TYPE_COMMUNITY, ((PostFragment) fragment).getSortType());
sortTypeBottomSheetFragment.show(fragmentManager, sortTypeBottomSheetFragment.getTag());
}
}
@@ -1313,6 +1321,12 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
} else if (itemId == R.id.action_add_to_home_screen_view_subreddit_detail_activity) {
Bitmap icon = subredditIconBitmap == null ? decodeResource(getResources(), R.drawable.subreddit_default_icon) : subredditIconBitmap;
return ShortcutManager.requestPinShortcut(this, qualifiedName, icon);
} else if (itemId == R.id.action_view_instance_view_subreddit_detail_activity) {
String instance = communityData.getActorId().split("/")[2];
Intent intent = new Intent(this,InstanceInfoActivity.class);
intent.putExtra(InstanceInfoActivity.EXTRA_INSTANCE_DOMAIN, instance);
intent.putExtra(InstanceInfoActivity.EXTRA_INSTANCE_ID, communityData.getInstanceId());
startActivity(intent);
}
return false;
}
@@ -1737,7 +1751,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
bundle.putString(PostFragment.EXTRA_NAME, qualifiedName);
bundle.putInt(PostFragment.EXTRA_POST_TYPE, PostPagingSource.TYPE_SUBREDDIT);
bundle.putString(PostFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountName);
bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountQualifiedName);
fragment.setArguments(bundle);
return fragment;
}

View File

@@ -83,6 +83,7 @@ import eu.toldi.infinityforlemmy.asynctasks.AddSubredditOrUserToMultiReddit;
import eu.toldi.infinityforlemmy.asynctasks.CheckIsFollowingUser;
import eu.toldi.infinityforlemmy.asynctasks.SwitchAccount;
import eu.toldi.infinityforlemmy.blockedcommunity.BlockedCommunityData;
import eu.toldi.infinityforlemmy.blockedinstances.BlockedInstanceData;
import eu.toldi.infinityforlemmy.blockeduser.BlockedUserData;
import eu.toldi.infinityforlemmy.bottomsheetfragments.CopyTextBottomSheetFragment;
import eu.toldi.infinityforlemmy.bottomsheetfragments.FABMoreOptionsBottomSheetFragment;
@@ -188,21 +189,11 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
@BindView(R.id.comment_count_text_view_view_user_detail_activity)
TextView commentCountTextView;
@BindView(R.id.upvote_count_post_text_view_view_user_detail_activity)
TextView upvoteCountPostTextView;
@BindView(R.id.upvote_count_comment_text_view_view_user_detail_activity)
TextView upvoteCountCommentTextView;
@BindView(R.id.posts_count_icon_image_view_view_user_detail_activity)
ImageView postsCountIconImageView;
@BindView(R.id.comments_count_icon_image_view_view_user_detail_activity)
ImageView commentsCountIconImageView;
@BindView(R.id.upvote_count_posts_icon_image_view_view_user_detail_activity)
ImageView postUpvoteCountIconImageView;
@BindView(R.id.upvote_count_comments_icon_image_view_view_user_detail_activity)
ImageView commentUpvoteCountIconImageView;
@BindView(R.id.account_created_cake_icon_image_view_view_user_detail_activity)
ImageView accountCreatedCakeIconImageView;
@@ -261,7 +252,6 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
private String description;
private boolean showStatistics;
private boolean showScore;
private boolean subscriptionReady = false;
private boolean mFetchUserInfoSuccess = false;
private int expandedTabTextColor;
@@ -327,7 +317,6 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
lockBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.LOCK_BOTTOM_APP_BAR, false);
showStatistics = mSharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_STATISTICS, true);
showScore = mSharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_POST_AND_COMMENT_SCORE, true);
if (savedInstanceState == null) {
mMessageId = getIntent().getIntExtra(EXTRA_MESSAGE_FULLNAME, 0);
@@ -630,17 +619,8 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
UserStats userStats = mUserData.getStats();
if (userStats != null && showStatistics) {
userStatisticsBlock.setVisibility(View.VISIBLE);
postCountTextView.setText(String.valueOf(userStats.getPostCount()));
commentCountTextView.setText(String.valueOf(userStats.getCommentCount()));
if (showScore) {
upvoteCountPostTextView.setText(String.valueOf(userStats.getPostScore()));
upvoteCountCommentTextView.setText(String.valueOf(userStats.getCommentScore()));
} else {
upvoteCountPostTextView.setVisibility(View.GONE);
upvoteCountCommentTextView.setVisibility(View.GONE);
postUpvoteCountIconImageView.setVisibility(View.GONE);
commentUpvoteCountIconImageView.setVisibility(View.GONE);
}
postCountTextView.setText(getString(R.string.post_count_detail, userStats.getPostCount()));
commentCountTextView.setText(getString(R.string.comment_count_detail, userStats.getCommentCount()));
}
if (userData.getDescription() == null || userData.getDescription().equals("")) {
@@ -710,9 +690,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
subscribedColor = mCustomThemeWrapper.getSubscribed();
userNameTextView.setTextColor(mCustomThemeWrapper.getUsername());
postCountTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
upvoteCountPostTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
commentCountTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
upvoteCountCommentTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
postsCountIconImageView.setColorFilter(mCustomThemeWrapper.getPrimaryTextColor(), PorterDuff.Mode.SRC_IN);
commentsCountIconImageView.setColorFilter(mCustomThemeWrapper.getPrimaryTextColor(), PorterDuff.Mode.SRC_IN);
accountCreatedCakeIconImageView.setColorFilter(mCustomThemeWrapper.getPrimaryTextColor(), PorterDuff.Mode.SRC_IN);
@@ -725,9 +703,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
if (typeface != null) {
userNameTextView.setTypeface(typeface);
postCountTextView.setTypeface(typeface);
upvoteCountPostTextView.setTypeface(typeface);
commentCountTextView.setTypeface(typeface);
upvoteCountCommentTextView.setTypeface(typeface);
cakedayTextView.setTypeface(typeface);
subscribeUserChip.setTypeface(typeface);
descriptionTextView.setTypeface(typeface);
@@ -1179,7 +1155,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
FetchBlockedThings.fetchBlockedThings(mRetrofit.getRetrofit(), mAccessToken, mAccountQualifiedName, new FetchBlockedThings.FetchBlockedThingsListener() {
@Override
public void onFetchBlockedThingsSuccess(List<BlockedUserData> blockedUsers, List<BlockedCommunityData> blockedCommunities) {
public void onFetchBlockedThingsSuccess(List<BlockedUserData> blockedUsers, List<BlockedCommunityData> blockedCommunities, List<BlockedInstanceData> blockedInstances) {
for (BlockedUserData blockedUserData : blockedUsers) {
if (blockedUserData.getQualifiedName().equals(qualifiedName)) {
isBlocked = true;
@@ -1233,7 +1209,6 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
getMenuInflater().inflate(R.menu.view_user_detail_activity, menu);
if (username.equals(mAccountName)) {
menu.findItem(R.id.action_send_private_message_view_user_detail_activity).setVisible(false);
menu.findItem(R.id.action_report_view_user_detail_activity).setVisible(false);
menu.findItem(R.id.action_block_user_view_user_detail_activity).setVisible(false);
} else {
menu.findItem(R.id.action_edit_profile_view_user_detail_activity).setVisible(false);
@@ -1299,11 +1274,6 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
intent.putExtra(PostFilterPreferenceActivity.EXTRA_USER_NAME, username);
startActivity(intent);
return true;
} else if (itemId == R.id.action_report_view_user_detail_activity) {
Intent reportIntent = new Intent(this, LinkResolverActivity.class);
reportIntent.setData(Uri.parse("https://www.reddithelp.com/en/categories/rules-reporting/account-and-community-restrictions/what-should-i-do-if-i-see-something-i"));
startActivity(reportIntent);
return true;
} else if (itemId == R.id.action_block_user_view_user_detail_activity) {
if (mAccessToken == null) {
Toast.makeText(this, R.string.login_first, Toast.LENGTH_SHORT).show();
@@ -1353,6 +1323,12 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
Toast.makeText(ViewUserDetailActivity.this, R.string.unblock_user_failed, Toast.LENGTH_SHORT).show();
}
});
} else if (itemId == R.id.action_view_instance_view_user_detail_activity) {
String instance = mUserData.getActorId().split("/")[2];
Intent intent = new Intent(this, InstanceInfoActivity.class);
intent.putExtra(InstanceInfoActivity.EXTRA_INSTANCE_DOMAIN, instance);
intent.putExtra(InstanceInfoActivity.EXTRA_INSTANCE_ID, mUserData.getInstanceId());
startActivity(intent);
}
return false;
}
@@ -1789,7 +1765,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
bundle.putString(PostFragment.EXTRA_USER_NAME, qualifiedName);
bundle.putString(PostFragment.EXTRA_USER_WHERE, PostPagingSource.USER_WHERE_SUBMITTED);
bundle.putString(PostFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountName);
bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountQualifiedName);
fragment.setArguments(bundle);
return fragment;
}

View File

@@ -68,7 +68,6 @@ import com.google.android.exoplayer2.util.MimeTypes;
import com.google.android.exoplayer2.video.VideoSize;
import com.google.android.material.bottomappbar.BottomAppBar;
import com.google.android.material.button.MaterialButton;
import com.google.android.material.snackbar.Snackbar;
import com.google.common.collect.ImmutableList;
import com.otaliastudios.zoom.ZoomEngine;
import com.otaliastudios.zoom.ZoomSurfaceView;
@@ -88,7 +87,7 @@ import app.futured.hauler.LockableNestedScrollView;
import butterknife.BindView;
import butterknife.ButterKnife;
import eu.toldi.infinityforlemmy.CustomFontReceiver;
import eu.toldi.infinityforlemmy.FetchGfycatOrRedgifsVideoLinks;
import eu.toldi.infinityforlemmy.FetchRedgifsVideoLinks;
import eu.toldi.infinityforlemmy.FetchStreamableVideo;
import eu.toldi.infinityforlemmy.Infinity;
import eu.toldi.infinityforlemmy.R;
@@ -133,7 +132,7 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
public static final String EXTRA_POST = "EP";
public static final String EXTRA_PROGRESS_SECONDS = "EPS";
public static final String EXTRA_VIDEO_TYPE = "EVT";
public static final String EXTRA_GFYCAT_ID = "EGI";
public static final String EXTRA_REDGIFS_ID = "ERI";
public static final String EXTRA_V_REDD_IT_URL = "EVRIU";
public static final String EXTRA_STREAMABLE_SHORT_CODE = "ESSC";
public static final String EXTRA_IS_NSFW = "EIN";
@@ -142,7 +141,6 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
public static final int VIDEO_TYPE_V_REDD_IT = 4;
public static final int VIDEO_TYPE_DIRECT = 3;
public static final int VIDEO_TYPE_REDGIFS = 2;
public static final int VIDEO_TYPE_GFYCAT = 1;
private static final int VIDEO_TYPE_NORMAL = 0;
private static final int PERMISSION_REQUEST_WRITE_EXTERNAL_STORAGE = 0;
@@ -204,10 +202,6 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
@Named("no_oauth")
RetrofitHolder retrofit;
@Inject
@Named("gfycat")
Retrofit gfycatRetrofit;
@Inject
@Named("redgifs")
Retrofit redgifsRetrofit;
@@ -548,29 +542,21 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
}
} else if (videoType == VIDEO_TYPE_V_REDD_IT) {
loadVReddItVideo(savedInstanceState);
} else if (videoType == VIDEO_TYPE_GFYCAT || videoType == VIDEO_TYPE_REDGIFS) {
} else if (videoType == VIDEO_TYPE_REDGIFS) {
if (savedInstanceState != null) {
videoDownloadUrl = savedInstanceState.getString(VIDEO_DOWNLOAD_URL_STATE);
} else {
videoDownloadUrl = intent.getStringExtra(EXTRA_VIDEO_DOWNLOAD_URL);
}
String gfycatId = intent.getStringExtra(EXTRA_GFYCAT_ID);
if (gfycatId != null && gfycatId.contains("-")) {
gfycatId = gfycatId.substring(0, gfycatId.indexOf('-'));
}
if (videoType == VIDEO_TYPE_GFYCAT) {
videoFileName = "Gfycat-" + gfycatId + ".mp4";
} else {
videoFileName = "Redgifs-" + gfycatId + ".mp4";
String redgifsId = intent.getStringExtra(EXTRA_REDGIFS_ID);
if (redgifsId != null && redgifsId.contains("-")) {
redgifsId = redgifsId.substring(0, redgifsId.indexOf('-'));
}
videoFileName = "Redgifs-" + redgifsId + ".mp4";
if (mVideoUri == null) {
if (videoType == VIDEO_TYPE_GFYCAT) {
loadGfycatOrRedgifsVideo(gfycatRetrofit, gfycatId, true, savedInstanceState, true);
} else {
loadGfycatOrRedgifsVideo(redgifsRetrofit, gfycatId, false, savedInstanceState, false);
}
loadRedgifsVideo(redgifsId, savedInstanceState);
} else {
dataSourceFactory = new CacheDataSource.Factory().setCache(mSimpleCache)
.setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setAllowCrossProtocolRedirects(true).setUserAgent(APIUtils.USER_AGENT));
@@ -725,61 +711,28 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
return C.TRACK_TYPE_UNKNOWN;
}
private void loadGfycatOrRedgifsVideo(Retrofit retrofit, String gfycatId, boolean isGfycatVideo,
Bundle savedInstanceState, boolean needErrorHandling) {
private void loadRedgifsVideo(String redgifsId, Bundle savedInstanceState) {
progressBar.setVisibility(View.VISIBLE);
if (isGfycatVideo) {
FetchGfycatOrRedgifsVideoLinks.fetchGfycatVideoLinks(mExecutor, new Handler(), retrofit, gfycatId,
new FetchGfycatOrRedgifsVideoLinks.FetchGfycatOrRedgifsVideoLinksListener() {
@Override
public void success(String webm, String mp4) {
progressBar.setVisibility(View.GONE);
mVideoUri = Uri.parse(webm);
videoDownloadUrl = mp4;
dataSourceFactory = new CacheDataSource.Factory().setCache(mSimpleCache)
.setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setAllowCrossProtocolRedirects(true).setUserAgent(APIUtils.USER_AGENT));
preparePlayer(savedInstanceState);
player.prepare();
player.setMediaSource(new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(mVideoUri)));
}
FetchRedgifsVideoLinks.fetchRedgifsVideoLinks(mExecutor, new Handler(), redgifsRetrofit,
redgifsId, new FetchRedgifsVideoLinks.FetchRedgifsVideoLinksListener() {
@Override
public void success(String webm, String mp4) {
progressBar.setVisibility(View.GONE);
mVideoUri = Uri.parse(webm);
videoDownloadUrl = mp4;
dataSourceFactory = new CacheDataSource.Factory().setCache(mSimpleCache)
.setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setAllowCrossProtocolRedirects(true).setUserAgent(APIUtils.USER_AGENT));
preparePlayer(savedInstanceState);
player.prepare();
player.setMediaSource(new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(mVideoUri)));
}
@Override
public void failed(int errorCode) {
if (errorCode == 404 && needErrorHandling) {
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.AUTOMATICALLY_TRY_REDGIFS, true)) {
loadGfycatOrRedgifsVideo(redgifsRetrofit, gfycatId, false, savedInstanceState, false);
} else {
Snackbar.make(coordinatorLayout, R.string.load_video_in_redgifs, Snackbar.LENGTH_INDEFINITE).setAction(R.string.yes,
view -> loadGfycatOrRedgifsVideo(redgifsRetrofit, gfycatId, false, savedInstanceState, false)).show();
}
} else {
progressBar.setVisibility(View.GONE);
Toast.makeText(ViewVideoActivity.this, R.string.fetch_gfycat_video_failed, Toast.LENGTH_SHORT).show();
}
}
});
} else {
FetchGfycatOrRedgifsVideoLinks.fetchRedgifsVideoLinks(mExecutor, new Handler(), redgifsRetrofit,
gfycatId, new FetchGfycatOrRedgifsVideoLinks.FetchGfycatOrRedgifsVideoLinksListener() {
@Override
public void success(String webm, String mp4) {
progressBar.setVisibility(View.GONE);
mVideoUri = Uri.parse(webm);
videoDownloadUrl = mp4;
dataSourceFactory = new CacheDataSource.Factory().setCache(mSimpleCache)
.setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setAllowCrossProtocolRedirects(true).setUserAgent(APIUtils.USER_AGENT));
preparePlayer(savedInstanceState);
player.prepare();
player.setMediaSource(new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(mVideoUri)));
}
@Override
public void failed(int errorCode) {
progressBar.setVisibility(View.GONE);
Toast.makeText(ViewVideoActivity.this, R.string.fetch_redgifs_video_failed, Toast.LENGTH_SHORT).show();
}
});
}
@Override
public void failed(int errorCode) {
progressBar.setVisibility(View.GONE);
Toast.makeText(ViewVideoActivity.this, R.string.fetch_redgifs_video_failed, Toast.LENGTH_SHORT).show();
}
});
}
private void loadVReddItVideo(Bundle savedInstanceState) {
@@ -797,30 +750,14 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
postEnricher, new FetchPost.FetchPostListener() {
@Override
public void fetchPostSuccess(Post post) {
if (post.isGfycat()) {
videoType = VIDEO_TYPE_GFYCAT;
String gfycatId = post.getGfycatId();
if (gfycatId != null && gfycatId.contains("-")) {
gfycatId = gfycatId.substring(0, gfycatId.indexOf('-'));
}
if (videoType == VIDEO_TYPE_GFYCAT) {
videoFileName = "Gfycat-" + gfycatId + ".mp4";
} else {
videoFileName = "Redgifs-" + gfycatId + ".mp4";
}
loadGfycatOrRedgifsVideo(gfycatRetrofit, gfycatId, true, savedInstanceState, true);
} else if (post.isRedgifs()) {
if (post.isRedgifs()) {
videoType = VIDEO_TYPE_REDGIFS;
String gfycatId = post.getGfycatId();
if (gfycatId != null && gfycatId.contains("-")) {
gfycatId = gfycatId.substring(0, gfycatId.indexOf('-'));
String redgifsId = post.getRedgifsId();
if (redgifsId != null && redgifsId.contains("-")) {
redgifsId = redgifsId.substring(0, redgifsId.indexOf('-'));
}
if (videoType == VIDEO_TYPE_GFYCAT) {
videoFileName = "Gfycat-" + gfycatId + ".mp4";
} else {
videoFileName = "Redgifs-" + gfycatId + ".mp4";
}
loadGfycatOrRedgifsVideo(redgifsRetrofit, gfycatId, false, savedInstanceState, false);
videoFileName = "Redgifs-" + redgifsId + ".mp4";
loadRedgifsVideo(redgifsId, savedInstanceState);
} else if (post.isStreamable()) {
videoType = VIDEO_TYPE_STREAMABLE;
String shortCode = post.getStreamableShortCode();

View File

@@ -176,7 +176,7 @@ public class WikiActivity extends BaseActivity {
return true;
};
markwon = MarkdownUtils.createFullRedditMarkwon(this,
miscPlugin, markdownColor, spoilerBackgroundColor, onLinkLongClickListener, mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_IMAGE_PREVIEW, false));
miscPlugin, markdownColor, spoilerBackgroundColor, mGlide, onLinkLongClickListener, mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_IMAGE_PREVIEW, false));
markwonAdapter = MarkdownUtils.createTablesAdapter();
LinearLayoutManagerBugFixed linearLayoutManager = new SwipeLockLinearLayoutManager(this, new SwipeLockInterface() {
@@ -259,7 +259,7 @@ public class WikiActivity extends BaseActivity {
swipeRefreshLayout.setRefreshing(false);
mFetchWikiInfoLinearLayout.setVisibility(View.VISIBLE);
mFetchWikiInfoTextView.setText(stringResId);
mGlide.load(R.drawable.error_image).into(mFetchWikiInfoImageView);
mGlide.load(R.mipmap.ic_launcher_round).into(mFetchWikiInfoImageView);
}
@Override

View File

@@ -0,0 +1,279 @@
package eu.toldi.infinityforlemmy.adapters;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.RequestManager;
import com.bumptech.glide.request.RequestOptions;
import java.util.List;
import java.util.concurrent.Executor;
import butterknife.BindView;
import butterknife.ButterKnife;
import eu.toldi.infinityforlemmy.R;
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
import eu.toldi.infinityforlemmy.activities.BaseActivity;
import eu.toldi.infinityforlemmy.activities.InstanceInfoActivity;
import eu.toldi.infinityforlemmy.blockedinstances.BlockedInstanceData;
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
import me.zhanghai.android.fastscroll.PopupTextProvider;
import pl.droidsonroids.gif.GifImageView;
import retrofit2.Retrofit;
public class BlockedInstancesRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements PopupTextProvider {
private static final int VIEW_TYPE_FAVORITE_SUBREDDIT_DIVIDER = 0;
private static final int VIEW_TYPE_FAVORITE_SUBREDDIT = 1;
private static final int VIEW_TYPE_SUBREDDIT_DIVIDER = 2;
private static final int VIEW_TYPE_SUBREDDIT = 3;
private BaseActivity mActivity;
private Executor mExecutor;
private Retrofit mOauthRetrofit;
private RedditDataRoomDatabase mRedditDataRoomDatabase;
private List<BlockedInstanceData> mBlockedInstanceData;
private List<BlockedInstanceData> mFavoriteBlockedInstanceData;
private RequestManager glide;
private ItemClickListener itemClickListener;
private String accessToken;
private String instancename;
private String instanceIconUrl;
private boolean hasClearSelectionRow;
private int primaryTextColor;
private int secondaryTextColor;
public BlockedInstancesRecyclerViewAdapter(BaseActivity activity, Executor executor, Retrofit oauthRetrofit,
RedditDataRoomDatabase redditDataRoomDatabase,
CustomThemeWrapper customThemeWrapper,
String accessToken) {
mActivity = activity;
mExecutor = executor;
glide = Glide.with(activity);
mOauthRetrofit = oauthRetrofit;
mRedditDataRoomDatabase = redditDataRoomDatabase;
this.accessToken = accessToken;
primaryTextColor = customThemeWrapper.getPrimaryTextColor();
secondaryTextColor = customThemeWrapper.getSecondaryTextColor();
}
public BlockedInstancesRecyclerViewAdapter(BaseActivity activity, Executor executor, Retrofit oauthRetrofit,
RedditDataRoomDatabase redditDataRoomDatabase,
CustomThemeWrapper customThemeWrapper,
String accessToken, boolean hasClearSelectionRow,
ItemClickListener itemClickListener) {
this(activity, executor, oauthRetrofit, redditDataRoomDatabase, customThemeWrapper, accessToken);
this.hasClearSelectionRow = hasClearSelectionRow;
this.itemClickListener = itemClickListener;
}
@Override
public int getItemViewType(int position) {
if (mFavoriteBlockedInstanceData != null && mFavoriteBlockedInstanceData.size() > 0) {
if (itemClickListener != null && !hasClearSelectionRow) {
if (position == 0) {
return VIEW_TYPE_SUBREDDIT;
} else if (position == 1) {
return VIEW_TYPE_FAVORITE_SUBREDDIT_DIVIDER;
} else if (position == mFavoriteBlockedInstanceData.size() + 2) {
return VIEW_TYPE_SUBREDDIT_DIVIDER;
} else if (position <= mFavoriteBlockedInstanceData.size() + 1) {
return VIEW_TYPE_FAVORITE_SUBREDDIT;
} else {
return VIEW_TYPE_SUBREDDIT;
}
} else if (hasClearSelectionRow) {
if (position == 0) {
return VIEW_TYPE_SUBREDDIT;
} else if (position == 1) {
return VIEW_TYPE_SUBREDDIT;
} else if (position == 2) {
return VIEW_TYPE_FAVORITE_SUBREDDIT_DIVIDER;
} else if (position == mFavoriteBlockedInstanceData.size() + 3) {
return VIEW_TYPE_SUBREDDIT_DIVIDER;
} else if (position <= mFavoriteBlockedInstanceData.size() + 2) {
return VIEW_TYPE_FAVORITE_SUBREDDIT;
} else {
return VIEW_TYPE_SUBREDDIT;
}
} else {
if (position == 0) {
return VIEW_TYPE_FAVORITE_SUBREDDIT_DIVIDER;
} else if (position == mFavoriteBlockedInstanceData.size() + 1) {
return VIEW_TYPE_SUBREDDIT_DIVIDER;
} else if (position <= mFavoriteBlockedInstanceData.size()) {
return VIEW_TYPE_FAVORITE_SUBREDDIT;
} else {
return VIEW_TYPE_SUBREDDIT;
}
}
} else {
return VIEW_TYPE_SUBREDDIT;
}
}
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
return new InstanceViewHolder(LayoutInflater.from(viewGroup.getContext())
.inflate(R.layout.item_subscribed_thing, viewGroup, false));
}
@Override
public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder viewHolder, int i) {
String name;
String iconUrl;
if (hasClearSelectionRow && viewHolder.getBindingAdapterPosition() == 0) {
((InstanceViewHolder) viewHolder).subredditNameTextView.setText(R.string.all_communities);
viewHolder.itemView.setOnClickListener(view -> itemClickListener.onClick(null));
return;
} else {
int offset = hasClearSelectionRow ? 1 : 0;
BlockedInstanceData instanceData = mBlockedInstanceData.get(viewHolder.getBindingAdapterPosition() - offset);
String domain = mBlockedInstanceData.get(viewHolder.getBindingAdapterPosition() - offset).getDomain();
String instanceName = mBlockedInstanceData.get(viewHolder.getBindingAdapterPosition() - offset).getName();
name = instanceName != null ? instanceName + " (" + domain + ")" : domain;
iconUrl = mBlockedInstanceData.get(viewHolder.getBindingAdapterPosition() - offset).getIcon();
}
((InstanceViewHolder) viewHolder).itemView.setOnClickListener(view -> {
if (mBlockedInstanceData != null) {
BlockedInstanceData instanceData = mBlockedInstanceData.get(viewHolder.getBindingAdapterPosition());
Intent intent = new Intent(mActivity, InstanceInfoActivity.class);
intent.putExtra(InstanceInfoActivity.EXTRA_INSTANCE_DOMAIN, instanceData.getDomain());
intent.putExtra(InstanceInfoActivity.EXTRA_INSTANCE_ID, instanceData.getId());
mActivity.startActivity(intent);
}
});
if (iconUrl == null || iconUrl.equals("")) {
((InstanceViewHolder) viewHolder).iconGifImageView.setVisibility(View.GONE);
} else {
((InstanceViewHolder) viewHolder).iconGifImageView.setVisibility(View.VISIBLE);
glide.load(iconUrl)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
.error(glide.load(R.drawable.subreddit_default_icon)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
.into(((InstanceViewHolder) viewHolder).iconGifImageView);
}
((InstanceViewHolder) viewHolder).subredditNameTextView.setText(name);
}
@Override
public int getItemCount() {
if (mBlockedInstanceData != null) {
if (itemClickListener != null) {
return mBlockedInstanceData.size() > 0 ? mBlockedInstanceData.size() + ((hasClearSelectionRow) ? 1 : 0) : 0;
}
return mBlockedInstanceData.size();
}
return 0;
}
@Override
public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) {
glide.clear(((InstanceViewHolder) holder).iconGifImageView);
}
public void blockedInstances(List<BlockedInstanceData> subscribedSubreddits) {
mBlockedInstanceData = subscribedSubreddits;
notifyDataSetChanged();
}
public void setFavoriteSubscribedSubreddits(List<BlockedInstanceData> favoriteBlockedInstanceData) {
mFavoriteBlockedInstanceData = favoriteBlockedInstanceData;
notifyDataSetChanged();
}
public void addInstance(String instancename, String instanceIconUrl) {
this.instancename = instancename;
this.instanceIconUrl = instanceIconUrl;
}
@NonNull
@Override
public String getPopupText(int position) {
switch (getItemViewType(position)) {
case VIEW_TYPE_SUBREDDIT:
if (hasClearSelectionRow && position == 0) {
return "";
} else if (itemClickListener != null && !hasClearSelectionRow && position == 0) {
return "";
} else if (hasClearSelectionRow && position == 1) {
return "";
} else {
int offset;
if (itemClickListener != null) {
if (hasClearSelectionRow) {
offset = (mFavoriteBlockedInstanceData != null && mFavoriteBlockedInstanceData.size() > 0) ?
mFavoriteBlockedInstanceData.size() + 4 : 0;
} else {
offset = (mFavoriteBlockedInstanceData != null && mFavoriteBlockedInstanceData.size() > 0) ?
mFavoriteBlockedInstanceData.size() + 3 : 0;
}
} else {
offset = (mFavoriteBlockedInstanceData != null && mFavoriteBlockedInstanceData.size() > 0) ?
mFavoriteBlockedInstanceData.size() + 2 : 0;
}
return mBlockedInstanceData.get(position - offset).getDomain().substring(0, 1).toUpperCase();
}
case VIEW_TYPE_FAVORITE_SUBREDDIT:
int offset;
if (itemClickListener != null) {
if (hasClearSelectionRow) {
offset = 3;
} else {
offset = 2;
}
} else {
offset = 1;
}
return mFavoriteBlockedInstanceData.get(position - offset).getDomain().substring(0, 1).toUpperCase();
default:
return "";
}
}
public interface ItemClickListener {
void onClick(BlockedInstanceData subredditData);
}
class InstanceViewHolder extends RecyclerView.ViewHolder {
@BindView(R.id.thing_icon_gif_image_view_item_subscribed_thing)
GifImageView iconGifImageView;
@BindView(R.id.thing_name_text_view_item_subscribed_thing)
TextView subredditNameTextView;
@BindView(R.id.thing_instance_text_view_item_subscribed_thing)
TextView instanceInstanceTextView;
InstanceViewHolder(View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
if (mActivity.typeface != null) {
subredditNameTextView.setTypeface(mActivity.typeface);
}
subredditNameTextView.setTextColor(primaryTextColor);
}
}
}

View File

@@ -24,6 +24,7 @@ import androidx.recyclerview.widget.DiffUtil;
import androidx.recyclerview.widget.ItemTouchHelper;
import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.Glide;
import com.google.android.material.button.MaterialButton;
import java.util.Locale;
@@ -170,7 +171,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
return true;
};
mMarkwon = MarkdownUtils.createFullRedditMarkwon(mActivity,
miscPlugin, mCommentColor, commentSpoilerBackgroundColor, onLinkLongClickListener, sharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_IMAGE_PREVIEW, false));
miscPlugin, mCommentColor, commentSpoilerBackgroundColor, Glide.with(mActivity.getApplication()), onLinkLongClickListener, sharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_IMAGE_PREVIEW, false));
recycledViewPool = new RecyclerView.RecycledViewPool();
}
@@ -202,10 +203,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
} else {
((CommentBaseViewHolder) holder).commentTimeTextView.setText(Utils.getFormattedTime(mLocale, comment.getCommentTimeMillis(), mTimeFormatPattern));
}
((CommentViewHolder) holder).markwonAdapter.setMarkdown(mMarkwon, comment.getCommentMarkdown());
// noinspection NotifyDataSetChanged
((CommentBaseViewHolder) holder).markwonAdapter.notifyDataSetChanged();
mMarkwon.setMarkdown(((CommentBaseViewHolder) holder).commentMarkdownView, comment.getCommentMarkdown());
String commentText = Utils.getNVotes(mShowAbsoluteNumberOfVotes,
comment.getScore() + comment.getVoteType());
@@ -253,8 +251,6 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
if (holder instanceof CommentBaseViewHolder) {
((CommentBaseViewHolder) holder).authorFlairTextView.setText("");
((CommentBaseViewHolder) holder).authorFlairTextView.setVisibility(View.GONE);
((CommentBaseViewHolder) holder).awardsTextView.setText("");
((CommentBaseViewHolder) holder).awardsTextView.setVisibility(View.GONE);
((CommentBaseViewHolder) holder).upvoteButton.setIconResource(R.drawable.ic_upvote_24dp);
((CommentBaseViewHolder) holder).upvoteButton.setIconTint(ColorStateList.valueOf(mCommentIconAndInfoColor));
((CommentBaseViewHolder) holder).scoreTextView.setTextColor(mCommentIconAndInfoColor);
@@ -326,8 +322,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
TextView authorTextView;
TextView authorFlairTextView;
TextView commentTimeTextView;
TextView awardsTextView;
RecyclerView commentMarkdownView;
TextView commentMarkdownView;
ConstraintLayout bottomConstraintLayout;
MaterialButton upvoteButton;
TextView scoreTextView;
@@ -337,7 +332,6 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
MaterialButton saveButton;
MaterialButton replyButton;
View commentDivider;
CustomMarkwonAdapter markwonAdapter;
CommentBaseViewHolder(@NonNull View itemView) {
super(itemView);
@@ -347,8 +341,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
TextView authorTextView,
TextView authorFlairTextView,
TextView commentTimeTextView,
TextView awardsTextView,
RecyclerView commentMarkdownView,
TextView commentMarkdownView,
ConstraintLayout bottomConstraintLayout,
MaterialButton upvoteButton,
TextView scoreTextView,
@@ -364,7 +357,6 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
this.authorTextView = authorTextView;
this.authorFlairTextView = authorFlairTextView;
this.commentTimeTextView = commentTimeTextView;
this.awardsTextView = awardsTextView;
this.commentMarkdownView = commentMarkdownView;
this.bottomConstraintLayout = bottomConstraintLayout;
this.upvoteButton = upvoteButton;
@@ -429,14 +421,12 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
authorTextView.setTypeface(mActivity.typeface);
authorFlairTextView.setTypeface(mActivity.typeface);
commentTimeTextView.setTypeface(mActivity.typeface);
awardsTextView.setTypeface(mActivity.typeface);
upvoteButton.setTypeface(mActivity.typeface);
}
itemView.setBackgroundColor(mCommentBackgroundColor);
authorTextView.setTextColor(mUsernameColor);
authorFlairTextView.setTextColor(mAuthorFlairColor);
commentTimeTextView.setTextColor(mSecondaryTextColor);
awardsTextView.setTextColor(mSecondaryTextColor);
upvoteButton.setIconTint(ColorStateList.valueOf(mCommentIconAndInfoColor));
scoreTextView.setTextColor(mCommentIconAndInfoColor);
downvoteButton.setIconTint(ColorStateList.valueOf(mCommentIconAndInfoColor));
@@ -494,7 +484,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
}
});
commentMarkdownView.setRecycledViewPool(recycledViewPool);
LinearLayoutManagerBugFixed linearLayoutManager = new SwipeLockLinearLayoutManager(mActivity, new SwipeLockInterface() {
@Override
public void lockSwipe() {
@@ -506,18 +496,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
mActivity.unlockSwipeRightToGoBack();
}
});
commentMarkdownView.setLayoutManager(linearLayoutManager);
markwonAdapter = MarkdownUtils.createCustomTablesAdapter();
markwonAdapter.setOnClickListener(view -> {
if (view instanceof SpoilerOnClickTextView) {
if (((SpoilerOnClickTextView) view).isSpoilerOnClick()) {
((SpoilerOnClickTextView) view).setSpoilerOnClick(false);
return;
}
}
itemView.callOnClick();
});
commentMarkdownView.setAdapter(markwonAdapter);
upvoteButton.setOnClickListener(view -> {
if (mAccessToken == null) {
@@ -558,7 +537,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
comment.getScore() + comment.getVoteType()));
VoteThing.votePost(mActivity, retrofit, mAccessToken, new VoteThing.VoteThingListener() {
VoteThing.voteComment(mActivity, retrofit, mAccessToken, new VoteThing.VoteThingListener() {
@Override
public void onVoteThingSuccess(int position1) {
int currentPosition = getBindingAdapterPosition();
@@ -637,7 +616,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
comment.getScore() + comment.getVoteType()));
VoteThing.votePost(mActivity, retrofit, mAccessToken, new VoteThing.VoteThingListener() {
VoteThing.voteComment(mActivity, retrofit, mAccessToken, new VoteThing.VoteThingListener() {
@Override
public void onVoteThingSuccess(int position1) {
int currentPosition = getBindingAdapterPosition();
@@ -738,7 +717,6 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
binding.authorTextViewItemPostComment,
binding.authorFlairTextViewItemPostComment,
binding.commentTimeTextViewItemPostComment,
binding.awardsTextViewItemComment,
binding.commentMarkdownViewItemPostComment,
binding.bottomConstraintLayoutItemPostComment,
binding.upvoteButtonItemPostComment,

View File

@@ -43,6 +43,7 @@ import java.util.regex.Pattern;
import butterknife.BindView;
import butterknife.ButterKnife;
import eu.toldi.infinityforlemmy.DualBadgeDrawable;
import eu.toldi.infinityforlemmy.R;
import eu.toldi.infinityforlemmy.RetrofitHolder;
import eu.toldi.infinityforlemmy.SaveComment;
@@ -155,6 +156,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
private int mUsernameColor;
private int mSubmitterColor;
private int mModeratorColor;
private int mAdminColor;
private int mCurrentUserColor;
private int mAuthorFlairTextColor;
private int mUpvotedColor;
@@ -221,7 +223,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
return true;
};
mCommentMarkwon = MarkdownUtils.createFullRedditMarkwon(mActivity,
miscPlugin, mCommentTextColor, commentSpoilerBackgroundColor, onLinkLongClickListener, sharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_IMAGE_PREVIEW, false));
miscPlugin, mCommentTextColor, commentSpoilerBackgroundColor, mGlide, onLinkLongClickListener, sharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_IMAGE_PREVIEW, false));
recycledViewPool = new RecyclerView.RecycledViewPool();
mAccessToken = accessToken;
mAccountQualifiedName = accountName;
@@ -271,6 +273,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
mCommentBackgroundColor = customThemeWrapper.getCommentBackgroundColor();
mSubmitterColor = customThemeWrapper.getSubmitter();
mModeratorColor = customThemeWrapper.getModerator();
mAdminColor = customThemeWrapper.getAdmin();
mCurrentUserColor = customThemeWrapper.getCurrentUser();
mAuthorFlairTextColor = customThemeWrapper.getAuthorFlairTextColor();
mUsernameColor = customThemeWrapper.getUsername();
@@ -392,11 +395,23 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
Drawable submitterDrawable = Utils.getTintedDrawable(mActivity, R.drawable.ic_mic_14dp, mSubmitterColor);
((CommentBaseViewHolder) holder).authorTextView.setCompoundDrawablesWithIntrinsicBounds(
submitterDrawable, null, null, null);
} else if (comment.isModerator() && comment.isAdmin()) {
((CommentBaseViewHolder) holder).authorTextView.setTextColor(mModeratorColor);
Drawable moderatorDrawable = Utils.getTintedDrawable(mActivity, R.drawable.ic_verified_user_14dp, mModeratorColor);
Drawable adminDrawable = Utils.getTintedDrawable(mActivity, R.drawable.ic_verified_user_14dp, mAdminColor);
Drawable dualDrawable = new DualBadgeDrawable(adminDrawable, moderatorDrawable);
((CommentBaseViewHolder) holder).authorTextView.setCompoundDrawablesWithIntrinsicBounds(
dualDrawable, null, null, null);
} else if (comment.isModerator()) {
((CommentBaseViewHolder) holder).authorTextView.setTextColor(mModeratorColor);
Drawable moderatorDrawable = Utils.getTintedDrawable(mActivity, R.drawable.ic_verified_user_14dp, mModeratorColor);
((CommentBaseViewHolder) holder).authorTextView.setCompoundDrawablesWithIntrinsicBounds(
moderatorDrawable, null, null, null);
} else if (comment.isAdmin()) {
((CommentBaseViewHolder) holder).authorTextView.setTextColor(mAdminColor);
Drawable adminDrawable = Utils.getTintedDrawable(mActivity, R.drawable.ic_verified_user_14dp, mAdminColor);
((CommentBaseViewHolder) holder).authorTextView.setCompoundDrawablesWithIntrinsicBounds(
adminDrawable, null, null, null);
} else if (comment.getAuthorQualifiedName().equals(mAccountQualifiedName)) {
((CommentBaseViewHolder) holder).authorTextView.setTextColor(mCurrentUserColor);
Drawable currentUserDrawable = Utils.getTintedDrawable(mActivity, R.drawable.ic_current_user_14dp, mCurrentUserColor);
@@ -443,11 +458,15 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
((CommentBaseViewHolder) holder).bottomConstraintLayout.getLayoutParams().height = LinearLayout.LayoutParams.WRAP_CONTENT;
((CommentBaseViewHolder) holder).topScoreTextView.setVisibility(View.GONE);
}
String text = comment.getCommentMarkdown();
if (comment.isRemoved()) {
text = "*"+mActivity.getString(R.string.removed_by_moderator)+"*";
} else if (comment.isDeleted()) {
text = "*"+mActivity.getString(R.string.deleted_by_creator)+"*";
}
mCommentMarkwon.setMarkdown(((CommentBaseViewHolder) holder).commentMarkdownView,text);
((CommentBaseViewHolder) holder).mMarkwonAdapter.setMarkdown(mCommentMarkwon, comment.getCommentMarkdown());
// noinspection NotifyDataSetChanged
((CommentBaseViewHolder) holder).mMarkwonAdapter.notifyDataSetChanged();
if (mHideDownvotes) {
((CommentBaseViewHolder) holder).downvoteButton.setVisibility(View.GONE);
((CommentBaseViewHolder) holder).downvoteTextView.setVisibility(View.GONE);
@@ -1159,8 +1178,6 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
((CommentBaseViewHolder) holder).authorTextView.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
mGlide.clear(((CommentBaseViewHolder) holder).authorIconImageView);
((CommentBaseViewHolder) holder).topScoreTextView.setTextColor(mSecondaryTextColor);
((CommentBaseViewHolder) holder).awardsTextView.setText("");
((CommentBaseViewHolder) holder).awardsTextView.setVisibility(View.GONE);
((CommentBaseViewHolder) holder).expandButton.setVisibility(View.GONE);
((CommentBaseViewHolder) holder).upvoteButton.setIconResource(R.drawable.ic_upvote_24dp);
((CommentBaseViewHolder) holder).upvoteButton.setIconTint(ColorStateList.valueOf(mCommentIconAndInfoColor));
@@ -1210,8 +1227,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
TextView authorFlairTextView;
TextView commentTimeTextView;
TextView topScoreTextView;
TextView awardsTextView;
RecyclerView commentMarkdownView;
TextView commentMarkdownView;
TextView editedTextView;
ConstraintLayout bottomConstraintLayout;
MaterialButton upvoteButton;
@@ -1225,7 +1241,6 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
MaterialButton replyButton;
CommentIndentationView commentIndentationView;
View commentDivider;
CustomMarkwonAdapter mMarkwonAdapter;
CommentBaseViewHolder(@NonNull View itemView) {
super(itemView);
@@ -1237,8 +1252,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
TextView authorFlairTextView,
TextView commentTimeTextView,
TextView topScoreTextView,
TextView awardsTextView,
RecyclerView commentMarkdownView,
TextView commentMarkdownView,
TextView editedTextView,
ConstraintLayout bottomConstraintLayout,
MaterialButton upvoteButton,
@@ -1258,7 +1272,6 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
this.authorFlairTextView = authorFlairTextView;
this.commentTimeTextView = commentTimeTextView;
this.topScoreTextView = topScoreTextView;
this.awardsTextView = awardsTextView;
this.commentMarkdownView = commentMarkdownView;
this.editedTextView = editedTextView;
this.bottomConstraintLayout = bottomConstraintLayout;
@@ -1336,7 +1349,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
authorFlairTextView.setTypeface(mActivity.typeface);
topScoreTextView.setTypeface(mActivity.typeface);
editedTextView.setTypeface(mActivity.typeface);
awardsTextView.setTypeface(mActivity.typeface);
scoreTextView.setTypeface(mActivity.typeface);
downvoteTextView.setTypeface(mActivity.typeface);
expandButton.setTypeface(mActivity.typeface);
@@ -1349,7 +1362,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
((ConstraintLayout.LayoutParams) authorFlairTextView.getLayoutParams()).leftMargin = 0;
}
commentMarkdownView.setRecycledViewPool(recycledViewPool);
LinearLayoutManagerBugFixed linearLayoutManager = new SwipeLockLinearLayoutManager(mActivity, new SwipeLockInterface() {
@Override
public void lockSwipe() {
@@ -1361,9 +1374,6 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
((ViewPostDetailActivity) mActivity).unlockSwipeRightToGoBack();
}
});
commentMarkdownView.setLayoutManager(linearLayoutManager);
mMarkwonAdapter = MarkdownUtils.createCustomTablesAdapter();
commentMarkdownView.setAdapter(mMarkwonAdapter);
itemView.setBackgroundColor(mCommentBackgroundColor);
authorTextView.setTextColor(mUsernameColor);
@@ -1372,7 +1382,6 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
topScoreTextView.setTextColor(mSecondaryTextColor);
downvoteTextView.setTextColor(mSecondaryTextColor);
editedTextView.setTextColor(mSecondaryTextColor);
awardsTextView.setTextColor(mSecondaryTextColor);
commentDivider.setBackgroundColor(mDividerColor);
upvoteButton.setIconTint(ColorStateList.valueOf(mCommentIconAndInfoColor));
scoreTextView.setTextColor(mCommentIconAndInfoColor);
@@ -1793,41 +1802,19 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
View.OnLongClickListener hideToolbarOnLongClickListener = view -> hideToolbar();
itemView.setOnLongClickListener(hideToolbarOnLongClickListener);
commentTimeTextView.setOnLongClickListener(hideToolbarOnLongClickListener);
mMarkwonAdapter.setOnLongClickListener(v -> {
if (v instanceof TextView) {
if (((TextView) v).getSelectionStart() == -1 && ((TextView) v).getSelectionEnd() == -1) {
hideToolbar();
}
}
commentMarkdownView.setOnLongClickListener(v -> {
hideToolbar();
return true;
});
}
mMarkwonAdapter.setOnClickListener(v -> {
if (v instanceof SpoilerOnClickTextView) {
if (((SpoilerOnClickTextView) v).isSpoilerOnClick()) {
((SpoilerOnClickTextView) v).setSpoilerOnClick(false);
return;
}
}
expandComments();
});
itemView.setOnClickListener(view -> expandComments());
} else {
if (mCommentToolbarHideOnClick) {
mMarkwonAdapter.setOnClickListener(view -> {
if (view instanceof SpoilerOnClickTextView) {
if (((SpoilerOnClickTextView) view).isSpoilerOnClick()) {
((SpoilerOnClickTextView) view).setSpoilerOnClick(false);
return;
}
}
hideToolbar();
});
View.OnClickListener hideToolbarOnClickListener = view -> hideToolbar();
itemView.setOnClickListener(hideToolbarOnClickListener);
commentTimeTextView.setOnClickListener(hideToolbarOnClickListener);
}
mMarkwonAdapter.setOnLongClickListener(view -> {
commentMarkdownView.setOnLongClickListener(view -> {
if (view instanceof TextView) {
if (((TextView) view).getSelectionStart() == -1 && ((TextView) view).getSelectionEnd() == -1) {
expandComments();
@@ -1875,7 +1862,6 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
binding.authorFlairTextViewItemPostComment,
binding.commentTimeTextViewItemPostComment,
binding.topScoreTextViewItemPostComment,
binding.awardsTextViewItemComment,
binding.commentMarkdownViewItemPostComment,
binding.editedTextViewItemPostComment,
binding.bottomConstraintLayoutItemPostComment,

View File

@@ -52,7 +52,7 @@ public class FlairBottomSheetRecyclerViewAdapter extends RecyclerView.Adapter<Fl
flairEditText.requestFocus();
Utils.showKeyboard(activity, new Handler(), flairEditText);
new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme)
.setTitle(R.string.edit_flair)
.setTitle("")
.setView(dialogView)
.setPositiveButton(R.string.ok, (dialogInterface, i)
-> {

View File

@@ -156,7 +156,7 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<CommentInteract
CommentInteraction message = getItem(holder.getBindingAdapterPosition());
if (message != null) {
if (message.isRead()) {
if (!message.isRead()) {
if (markAllMessagesAsRead) {
message.markAsRead();
} else {
@@ -193,7 +193,7 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<CommentInteract
mActivity.startActivity(intent);
}
if (message.isRead()) {
if (!message.isRead()) {
holder.itemView.setBackgroundColor(mMessageBackgroundColor);

View File

@@ -6,7 +6,6 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
@@ -20,19 +19,18 @@ import java.util.concurrent.Executor;
import butterknife.BindView;
import butterknife.ButterKnife;
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
import me.zhanghai.android.fastscroll.PopupTextProvider;
import eu.toldi.infinityforlemmy.R;
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
import eu.toldi.infinityforlemmy.activities.BaseActivity;
import eu.toldi.infinityforlemmy.asynctasks.InsertMultireddit;
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
import eu.toldi.infinityforlemmy.multireddit.FavoriteMultiReddit;
import eu.toldi.infinityforlemmy.multireddit.MultiReddit;
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
import me.zhanghai.android.fastscroll.PopupTextProvider;
import pl.droidsonroids.gif.GifImageView;
import retrofit2.Retrofit;
public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements PopupTextProvider {
public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements PopupTextProvider {
private static final int VIEW_TYPE_FAVORITE_MULTI_REDDIT_DIVIDER = 0;
private static final int VIEW_TYPE_FAVORITE_MULTI_REDDIT = 1;
@@ -54,6 +52,7 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter<
public interface OnItemClickListener {
void onClick(MultiReddit multiReddit);
void onLongClick(MultiReddit multiReddit);
}
@@ -120,80 +119,31 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter<
MultiReddit multiReddit = mMultiReddits.get(holder.getBindingAdapterPosition() - offset);
name = multiReddit.getDisplayName();
iconUrl = multiReddit.getIconUrl();
if(multiReddit.isFavorite()) {
if (multiReddit.isFavorite()) {
((MultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_24dp);
} else {
((MultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_border_24dp);
}
((MultiRedditViewHolder) holder).favoriteImageView.setOnClickListener(view -> {
if(multiReddit.isFavorite()) {
if (multiReddit.isFavorite()) {
((MultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_border_24dp);
multiReddit.setFavorite(false);
if (mAccessToken == null) {
InsertMultireddit.insertMultireddit(mExecutor, new Handler(), mRedditDataRoomDatabase, multiReddit,
() -> {
//Do nothing
});
} else {
FavoriteMultiReddit.favoriteMultiReddit(mExecutor, new Handler(), mOauthRetrofit, mRedditDataRoomDatabase,
mAccessToken, false, multiReddit,
new FavoriteMultiReddit.FavoriteMultiRedditListener() {
@Override
public void success() {
int position = holder.getBindingAdapterPosition() - offset;
if(position >= 0 && mMultiReddits.size() > position) {
mMultiReddits.get(position).setFavorite(false);
}
((MultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_border_24dp);
}
@Override
public void failed() {
Toast.makeText(mActivity, R.string.thing_unfavorite_failed, Toast.LENGTH_SHORT).show();
int position = holder.getBindingAdapterPosition() - offset;
if(position >= 0 && mMultiReddits.size() > position) {
mMultiReddits.get(position).setFavorite(true);
}
((MultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_24dp);
}
}
);
}
InsertMultireddit.insertMultireddit(mExecutor, new Handler(), mRedditDataRoomDatabase, multiReddit,
() -> {
//Do nothing
});
} else {
((MultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_24dp);
multiReddit.setFavorite(true);
if (mAccessToken == null) {
InsertMultireddit.insertMultireddit(mExecutor, new Handler(), mRedditDataRoomDatabase, multiReddit,
() -> {
//Do nothing
});
} else {
FavoriteMultiReddit.favoriteMultiReddit(mExecutor, new Handler(), mOauthRetrofit, mRedditDataRoomDatabase,
mAccessToken, true, multiReddit,
new FavoriteMultiReddit.FavoriteMultiRedditListener() {
@Override
public void success() {
int position = holder.getBindingAdapterPosition() - offset;
if(position >= 0 && mMultiReddits.size() > position) {
mMultiReddits.get(position).setFavorite(true);
}
((MultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_24dp);
}
@Override
public void failed() {
Toast.makeText(mActivity, R.string.thing_favorite_failed, Toast.LENGTH_SHORT).show();
int position = holder.getBindingAdapterPosition() - offset;
if(position >= 0 && mMultiReddits.size() > position) {
mMultiReddits.get(position).setFavorite(false);
}
((MultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_border_24dp);
}
}
);
}
InsertMultireddit.insertMultireddit(mExecutor, new Handler(), mRedditDataRoomDatabase, multiReddit,
() -> {
//Do nothing
});
}
});
holder.itemView.setOnClickListener(view -> {
mOnItemClickListener.onClick(multiReddit);
@@ -220,79 +170,29 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter<
MultiReddit multiReddit = mFavoriteMultiReddits.get(holder.getBindingAdapterPosition() - 1);
String name = multiReddit.getDisplayName();
String iconUrl = multiReddit.getIconUrl();
if(multiReddit.isFavorite()) {
if (multiReddit.isFavorite()) {
((FavoriteMultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_24dp);
} else {
((FavoriteMultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_border_24dp);
}
((FavoriteMultiRedditViewHolder) holder).favoriteImageView.setOnClickListener(view -> {
if(multiReddit.isFavorite()) {
if (multiReddit.isFavorite()) {
((FavoriteMultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_border_24dp);
multiReddit.setFavorite(false);
if (mAccessToken == null) {
InsertMultireddit.insertMultireddit(mExecutor, new Handler(), mRedditDataRoomDatabase, multiReddit,
() -> {
//Do nothing
});
} else {
FavoriteMultiReddit.favoriteMultiReddit(mExecutor, new Handler(), mOauthRetrofit, mRedditDataRoomDatabase,
mAccessToken, false, multiReddit,
new FavoriteMultiReddit.FavoriteMultiRedditListener() {
@Override
public void success() {
int position = holder.getBindingAdapterPosition() - 1;
if(position >= 0 && mFavoriteMultiReddits.size() > position) {
mFavoriteMultiReddits.get(position).setFavorite(false);
}
((FavoriteMultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_border_24dp);
}
InsertMultireddit.insertMultireddit(mExecutor, new Handler(), mRedditDataRoomDatabase, multiReddit,
() -> {
//Do nothing
});
@Override
public void failed() {
Toast.makeText(mActivity, R.string.thing_unfavorite_failed, Toast.LENGTH_SHORT).show();
int position = holder.getBindingAdapterPosition() - 1;
if(position >= 0 && mFavoriteMultiReddits.size() > position) {
mFavoriteMultiReddits.get(position).setFavorite(true);
}
((FavoriteMultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_24dp);
}
}
);
}
} else {
((FavoriteMultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_24dp);
multiReddit.setFavorite(true);
if (mAccessToken == null) {
InsertMultireddit.insertMultireddit(mExecutor, new Handler(), mRedditDataRoomDatabase, multiReddit,
() -> {
//Do nothing
});
} else {
FavoriteMultiReddit.favoriteMultiReddit(mExecutor, new Handler(), mOauthRetrofit, mRedditDataRoomDatabase,
mAccessToken, true, multiReddit,
new FavoriteMultiReddit.FavoriteMultiRedditListener() {
@Override
public void success() {
int position = holder.getBindingAdapterPosition() - 1;
if(position >= 0 && mFavoriteMultiReddits.size() > position) {
mFavoriteMultiReddits.get(position).setFavorite(true);
}
((FavoriteMultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_24dp);
}
@Override
public void failed() {
Toast.makeText(mActivity, R.string.thing_favorite_failed, Toast.LENGTH_SHORT).show();
int position = holder.getBindingAdapterPosition() - 1;
if(position >= 0 && mFavoriteMultiReddits.size() > position) {
mFavoriteMultiReddits.get(position).setFavorite(false);
}
((FavoriteMultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_border_24dp);
}
}
);
}
InsertMultireddit.insertMultireddit(mExecutor, new Handler(), mRedditDataRoomDatabase, multiReddit,
() -> {
//Do nothing
});
}
});
holder.itemView.setOnClickListener(view -> {
@@ -322,7 +222,7 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter<
@Override
public int getItemCount() {
if (mMultiReddits != null) {
if(mFavoriteMultiReddits != null && mFavoriteMultiReddits.size() > 0) {
if (mFavoriteMultiReddits != null && mFavoriteMultiReddits.size() > 0) {
return mMultiReddits.size() > 0 ?
mFavoriteMultiReddits.size() + mMultiReddits.size() + 2 : 0;
}
@@ -334,7 +234,7 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter<
@Override
public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) {
if(holder instanceof MultiRedditViewHolder) {
if (holder instanceof MultiRedditViewHolder) {
mGlide.clear(((MultiRedditViewHolder) holder).iconImageView);
} else if (holder instanceof FavoriteMultiRedditViewHolder) {
mGlide.clear(((FavoriteMultiRedditViewHolder) holder).iconImageView);
@@ -403,7 +303,8 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter<
}
class FavoriteMultiRedditsDividerViewHolder extends RecyclerView.ViewHolder {
@BindView(R.id.divider_text_view_item_favorite_thing_divider) TextView dividerTextView;
@BindView(R.id.divider_text_view_item_favorite_thing_divider)
TextView dividerTextView;
FavoriteMultiRedditsDividerViewHolder(@NonNull View itemView) {
super(itemView);
@@ -417,7 +318,8 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter<
}
class AllMultiRedditsDividerViewHolder extends RecyclerView.ViewHolder {
@BindView(R.id.divider_text_view_item_favorite_thing_divider) TextView dividerTextView;
@BindView(R.id.divider_text_view_item_favorite_thing_divider)
TextView dividerTextView;
AllMultiRedditsDividerViewHolder(@NonNull View itemView) {
super(itemView);

View File

@@ -49,7 +49,7 @@ import com.google.android.exoplayer2.ui.PlayerView;
import com.google.android.exoplayer2.ui.TimeBar;
import com.google.android.material.button.MaterialButton;
import com.google.common.collect.ImmutableList;
import com.libRG.CustomTextView;
import eu.toldi.infinityforlemmy.CustomTextView;
import java.util.ArrayList;
import java.util.Locale;
@@ -58,7 +58,8 @@ import java.util.regex.Pattern;
import javax.inject.Provider;
import eu.toldi.infinityforlemmy.FetchGfycatOrRedgifsVideoLinks;
import eu.toldi.infinityforlemmy.DualBadgeDrawable;
import eu.toldi.infinityforlemmy.FetchRedgifsVideoLinks;
import eu.toldi.infinityforlemmy.FetchStreamableVideo;
import eu.toldi.infinityforlemmy.R;
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
@@ -78,7 +79,6 @@ import eu.toldi.infinityforlemmy.activities.ViewRedditGalleryActivity;
import eu.toldi.infinityforlemmy.activities.ViewSubredditDetailActivity;
import eu.toldi.infinityforlemmy.activities.ViewUserDetailActivity;
import eu.toldi.infinityforlemmy.activities.ViewVideoActivity;
import eu.toldi.infinityforlemmy.apis.GfycatAPI;
import eu.toldi.infinityforlemmy.apis.RedgifsAPI;
import eu.toldi.infinityforlemmy.apis.StreamableAPI;
import eu.toldi.infinityforlemmy.asynctasks.LoadSubredditIcon;
@@ -140,7 +140,6 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
private ViewPostDetailFragment mFragment;
private Executor mExecutor;
private RetrofitHolder mRetrofit;
private Retrofit mGfycatRetrofit;
private Retrofit mRedgifsRetrofit;
private final Provider<StreamableAPI> mStreamableApiProvider;
private RedditDataRoomDatabase mRedditDataRoomDatabase;
@@ -166,7 +165,6 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
private boolean mMuteAutoplayingVideos;
private double mStartAutoplayVisibleAreaOffset;
private boolean mMuteNSFWVideo;
private boolean mAutomaticallyTryRedgifs;
private boolean mDataSavingMode;
private boolean mDisableImagePreview;
private boolean mOnlyDisablePreviewInVideoAndGifPosts;
@@ -198,6 +196,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
private int mSubredditColor;
private int mUsernameColor;
private int mModeratorColor;
private int mAdminColor;
private int mAuthorFlairTextColor;
private int mSpoilerBackgroundColor;
private int mSpoilerTextColor;
@@ -227,7 +226,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
public PostDetailRecyclerViewAdapter(BaseActivity activity, ViewPostDetailFragment fragment,
Executor executor, CustomThemeWrapper customThemeWrapper,
RetrofitHolder retrofit, Retrofit gfycatRetrofit,
RetrofitHolder retrofit,
Retrofit redgifsRetrofit, Provider<StreamableAPI> streamableApiProvider,
RedditDataRoomDatabase redditDataRoomDatabase, RequestManager glide,
boolean separatePostAndComments, String accessToken,
@@ -242,7 +241,6 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
mFragment = fragment;
mExecutor = executor;
mRetrofit = retrofit;
mGfycatRetrofit = gfycatRetrofit;
mRedgifsRetrofit = redgifsRetrofit;
mStreamableApiProvider = streamableApiProvider;
mRedditDataRoomDatabase = redditDataRoomDatabase;
@@ -299,7 +297,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
return true;
};
mPostDetailMarkwon = MarkdownUtils.createFullRedditMarkwon(mActivity,
miscPlugin, markdownColor, postSpoilerBackgroundColor, onLinkLongClickListener, sharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_IMAGE_PREVIEW, false));
miscPlugin, markdownColor, postSpoilerBackgroundColor, mGlide, onLinkLongClickListener, sharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_IMAGE_PREVIEW, false));
mMarkwonAdapter = MarkdownUtils.createTablesAdapter();
mSeparatePostAndComments = separatePostAndComments;
@@ -335,7 +333,6 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
sharedPreferences.getInt(SharedPreferencesUtils.START_AUTOPLAY_VISIBLE_AREA_OFFSET_LANDSCAPE, 50) / 100.0;
mMuteNSFWVideo = sharedPreferences.getBoolean(SharedPreferencesUtils.MUTE_NSFW_VIDEO, false);
mAutomaticallyTryRedgifs = sharedPreferences.getBoolean(SharedPreferencesUtils.AUTOMATICALLY_TRY_REDGIFS, true);
String dataSavingModeString = sharedPreferences.getString(SharedPreferencesUtils.DATA_SAVING_MODE, SharedPreferencesUtils.DATA_SAVING_MODE_OFF);
if (dataSavingModeString.equals(SharedPreferencesUtils.DATA_SAVING_MODE_ALWAYS)) {
@@ -385,6 +382,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
mSubredditColor = customThemeWrapper.getSubreddit();
mUsernameColor = customThemeWrapper.getUsername();
mModeratorColor = customThemeWrapper.getModerator();
mAdminColor = customThemeWrapper.getAdmin();
mUpvotedColor = customThemeWrapper.getUpvoted();
mDownvotedColor = customThemeWrapper.getDownvoted();
mVoteAndReplyUnavailableVoteButtonColor = customThemeWrapper.getVoteAndReplyUnavailableButtonColor();
@@ -605,15 +603,25 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
((PostDetailBaseViewHolder) holder).mUserInstanceTextView.setText('@' + mPost.getAuthorNamePrefixed().split(Pattern.quote("@"))[1]);
((PostDetailBaseViewHolder) holder).mCommunityInstanceTextView.setTextColor(CustomThemeWrapper.darkenColor(mSubredditColor, 0.7f));
((PostDetailBaseViewHolder) holder).mUserInstanceTextView.setTextColor(CustomThemeWrapper.darkenColor(mPost.isModerator() || mPost.isAdmin() ? mModeratorColor : mUsernameColor, 0.7f));
((PostDetailBaseViewHolder) holder).userTextView.setText(mPost.getAuthor());
((PostDetailBaseViewHolder) holder).mUserInstanceTextView.setTextColor(CustomThemeWrapper.darkenColor(mPost.isModerator() ? mModeratorColor : mPost.isAdmin() ? mAdminColor : mUsernameColor, 0.7f));
}
if (mPost.isModerator() || mPost.isAdmin()) {
if (mPost.isAdmin() && mPost.isModerator()) {
((PostDetailBaseViewHolder) holder).userTextView.setTextColor(mModeratorColor);
Drawable adminDrawable = Utils.getTintedDrawable(mActivity, R.drawable.ic_verified_user_14dp, mAdminColor);
Drawable moderatorDrawable = Utils.getTintedDrawable(mActivity, R.drawable.ic_verified_user_14dp, mModeratorColor);
Drawable dualBadge = new DualBadgeDrawable(adminDrawable, moderatorDrawable);
((PostDetailBaseViewHolder) holder).userTextView.setCompoundDrawablesWithIntrinsicBounds(
dualBadge, null, null, null);
} else if (mPost.isModerator()) {
((PostDetailBaseViewHolder) holder).userTextView.setTextColor(mModeratorColor);
Drawable moderatorDrawable = Utils.getTintedDrawable(mActivity, R.drawable.ic_verified_user_14dp, mModeratorColor);
((PostDetailBaseViewHolder) holder).userTextView.setCompoundDrawablesWithIntrinsicBounds(
moderatorDrawable, null, null, null);
} else if (mPost.isAdmin()) {
((PostDetailBaseViewHolder) holder).userTextView.setTextColor(mAdminColor);
Drawable moderatorDrawable = Utils.getTintedDrawable(mActivity, R.drawable.ic_verified_user_14dp, mAdminColor);
((PostDetailBaseViewHolder) holder).userTextView.setCompoundDrawablesWithIntrinsicBounds(
moderatorDrawable, null, null, null);
}
if (mShowElapsedTime) {
@@ -673,17 +681,14 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
if (mPost.getSelfText() != null && !mPost.getSelfText().equals("")) {
((PostDetailBaseViewHolder) holder).contentMarkdownView.setVisibility(View.VISIBLE);
((PostDetailBaseViewHolder) holder).contentMarkdownView.setAdapter(mMarkwonAdapter);
mMarkwonAdapter.setMarkdown(mPostDetailMarkwon, mPost.getSelfText());
// noinspection NotifyDataSetChanged
mMarkwonAdapter.notifyDataSetChanged();
mPostDetailMarkwon.setMarkdown(((PostDetailBaseViewHolder) holder).contentMarkdownView,mPost.getSelfText());
}
if (holder instanceof PostDetailBaseVideoAutoplayViewHolder) {
((PostDetailBaseVideoAutoplayViewHolder) holder).previewImageView.setVisibility(View.VISIBLE);
Post.Preview preview = getSuitablePreview(mPost.getPreviews());
if (preview != null) {
mGlide.load(preview.getPreviewUrl()).centerInside().downsample(mSaveMemoryCenterInsideDownsampleStrategy).into(new CustomTarget<Drawable>() {
mGlide.load(preview.getPreviewUrl()).centerInside().thumbnail(0.1f).downsample(mSaveMemoryCenterInsideDownsampleStrategy).into(new CustomTarget<Drawable>() {
@Override
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
int width = resource.getIntrinsicWidth();
@@ -704,45 +709,43 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
((PostDetailBaseVideoAutoplayViewHolder) holder).setVolume((mMuteAutoplayingVideos || (mPost.isNSFW() && mMuteNSFWVideo)) ? 0f : 1f);
}
if (mPost.isGfycat() || mPost.isRedgifs() && !mPost.isLoadGfycatOrStreamableVideoSuccess()) {
((PostDetailBaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall =
mPost.isGfycat() ? mGfycatRetrofit.create(GfycatAPI.class).getGfycatData(mPost.getGfycatId()) :
mRedgifsRetrofit.create(RedgifsAPI.class).getRedgifsData(mPost.getGfycatId());
FetchGfycatOrRedgifsVideoLinks.fetchGfycatOrRedgifsVideoLinksInRecyclerViewAdapter(mExecutor, new Handler(),
((PostDetailBaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall,
mPost.isGfycat(), mAutomaticallyTryRedgifs,
new FetchGfycatOrRedgifsVideoLinks.FetchGfycatOrRedgifsVideoLinksListener() {
if (mPost.isRedgifs() && !mPost.isLoadVideoSuccess()) {
((PostDetailBaseVideoAutoplayViewHolder) holder).fetchStreamableVideoCall =
mRedgifsRetrofit.create(RedgifsAPI.class).getRedgifsData(mPost.getRedgifsId());
FetchRedgifsVideoLinks.fetchRedgifsVideoLinksInRecyclerViewAdapter(mExecutor, new Handler(),
((PostDetailBaseVideoAutoplayViewHolder) holder).fetchStreamableVideoCall,
new FetchRedgifsVideoLinks.FetchRedgifsVideoLinksListener() {
@Override
public void success(String webm, String mp4) {
mPost.setVideoDownloadUrl(mp4);
mPost.setVideoUrl(mp4);
mPost.setLoadGfyOrStreamableVideoSuccess(true);
mPost.setLoadVideoSuccess(true);
((PostDetailBaseVideoAutoplayViewHolder) holder).bindVideoUri(Uri.parse(mPost.getVideoUrl()));
}
@Override
public void failed(int errorCode) {
((PostDetailBaseVideoAutoplayViewHolder) holder).mErrorLoadingGfycatImageView.setVisibility(View.VISIBLE);
((PostDetailBaseVideoAutoplayViewHolder) holder).mErrorLoadingVideoImageView.setVisibility(View.VISIBLE);
}
});
} else if(mPost.isStreamable() && !mPost.isLoadGfycatOrStreamableVideoSuccess()) {
((PostDetailBaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall =
} else if(mPost.isStreamable() && !mPost.isLoadVideoSuccess()) {
((PostDetailBaseVideoAutoplayViewHolder) holder).fetchStreamableVideoCall =
mStreamableApiProvider.get().getStreamableData(mPost.getStreamableShortCode());
FetchStreamableVideo.fetchStreamableVideoInRecyclerViewAdapter(mExecutor, new Handler(),
((PostDetailBaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall,
((PostDetailBaseVideoAutoplayViewHolder) holder).fetchStreamableVideoCall,
new FetchStreamableVideo.FetchStreamableVideoListener() {
@Override
public void success(StreamableVideo streamableVideo) {
StreamableVideo.Media media = streamableVideo.mp4 == null ? streamableVideo.mp4Mobile : streamableVideo.mp4;
mPost.setVideoDownloadUrl(media.url);
mPost.setVideoUrl(media.url);
mPost.setLoadGfyOrStreamableVideoSuccess(true);
mPost.setLoadVideoSuccess(true);
((PostDetailBaseVideoAutoplayViewHolder) holder).bindVideoUri(Uri.parse(mPost.getVideoUrl()));
}
@Override
public void failed() {
((PostDetailBaseVideoAutoplayViewHolder) holder).mErrorLoadingGfycatImageView.setVisibility(View.VISIBLE);
((PostDetailBaseVideoAutoplayViewHolder) holder).mErrorLoadingVideoImageView.setVisibility(View.VISIBLE);
}
});
} else {
@@ -904,7 +907,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
});
if (blurImage) {
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10))).into(new CustomTarget<Drawable>() {
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10))).thumbnail(0.1f).into(new CustomTarget<Drawable>() {
@Override
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
int width = resource.getIntrinsicWidth();
@@ -924,7 +927,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
}
});
} else {
imageRequestBuilder.centerInside().downsample(mSaveMemoryCenterInsideDownsampleStrategy).into(new CustomTarget<Drawable>() {
imageRequestBuilder.centerInside().downsample(mSaveMemoryCenterInsideDownsampleStrategy).thumbnail(0.1f).into(new CustomTarget<Drawable>() {
@Override
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
int width = resource.getIntrinsicWidth();
@@ -1143,11 +1146,11 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
((PostDetailBaseViewHolder) holder).contentMarkdownView.setVisibility(View.GONE);
if (holder instanceof PostDetailBaseVideoAutoplayViewHolder) {
if (((PostDetailBaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall != null && !((PostDetailBaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall.isCanceled()) {
((PostDetailBaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall.cancel();
((PostDetailBaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall = null;
if (((PostDetailBaseVideoAutoplayViewHolder) holder).fetchStreamableVideoCall != null && !((PostDetailBaseVideoAutoplayViewHolder) holder).fetchStreamableVideoCall.isCanceled()) {
((PostDetailBaseVideoAutoplayViewHolder) holder).fetchStreamableVideoCall.cancel();
((PostDetailBaseVideoAutoplayViewHolder) holder).fetchStreamableVideoCall = null;
}
((PostDetailBaseVideoAutoplayViewHolder) holder).mErrorLoadingGfycatImageView.setVisibility(View.GONE);
((PostDetailBaseVideoAutoplayViewHolder) holder).mErrorLoadingVideoImageView.setVisibility(View.GONE);
((PostDetailBaseVideoAutoplayViewHolder) holder).muteButton.setVisibility(View.GONE);
if (!((PostDetailBaseVideoAutoplayViewHolder) holder).isManuallyPaused) {
((PostDetailBaseVideoAutoplayViewHolder) holder).resetVolume();
@@ -1210,7 +1213,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
CustomTextView flairTextView;
TextView awardsTextView;
TextView upvoteRatioTextView;
RecyclerView contentMarkdownView;
TextView contentMarkdownView;
ConstraintLayout bottomConstraintLayout;
MaterialButton upvoteButton;
TextView scoreTextView;
@@ -1242,7 +1245,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
CustomTextView flairTextView,
TextView awardsTextView,
TextView upvoteRatioTextView,
RecyclerView contentMarkdownView,
TextView contentMarkdownView,
ConstraintLayout bottomConstraintLayout,
MaterialButton upvoteButton,
TextView scoreTextView,
@@ -1338,7 +1341,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
mActivity.startActivity(intent);
});
contentMarkdownView.setLayoutManager(new SwipeLockLinearLayoutManager(mActivity, new SwipeLockInterface() {
/*contentMarkdownView.setLayoutManager(new SwipeLockLinearLayoutManager(mActivity, new SwipeLockInterface() {
@Override
public void lockSwipe() {
((ViewPostDetailActivity) mActivity).lockSwipeRightToGoBack();
@@ -1348,7 +1351,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
public void unlockSwipe() {
((ViewPostDetailActivity) mActivity).unlockSwipeRightToGoBack();
}
}));
}));*/
upvoteButton.setOnClickListener(view -> {
if (mPost.isArchived()) {
@@ -1778,11 +1781,11 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
}
class PostDetailBaseVideoAutoplayViewHolder extends PostDetailBaseViewHolder implements ToroPlayer {
public Call<String> fetchGfycatOrStreamableVideoCall;
public Call<String> fetchStreamableVideoCall;
AspectRatioFrameLayout aspectRatioFrameLayout;
PlayerView playerView;
GifImageView previewImageView;
ImageView mErrorLoadingGfycatImageView;
ImageView mErrorLoadingVideoImageView;
ImageView muteButton;
ImageView fullscreenButton;
ImageView pauseButton;
@@ -1799,7 +1802,9 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
public PostDetailBaseVideoAutoplayViewHolder(@NonNull View itemView,
AspectRatioGifImageView iconGifImageView,
TextView subredditTextView,
TextView communityInstance,
TextView userTextView,
TextView userInstanceTextView,
TextView authorFlairTextView,
TextView postTimeTextView,
TextView titleTextView,
@@ -1815,16 +1820,17 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
AspectRatioFrameLayout aspectRatioFrameLayout,
PlayerView playerView,
GifImageView previewImageView,
ImageView errorLoadingGfycatImageView,
ImageView errorLoadingVideoImageView,
ImageView muteButton,
ImageView fullscreenButton,
ImageView pauseButton,
ImageView playButton,
DefaultTimeBar progressBar,
RecyclerView contentMarkdownView,
TextView contentMarkdownView,
ConstraintLayout bottomConstraintLayout,
MaterialButton upvoteButton,
TextView scoreTextView,
TextView downvoteTextView,
MaterialButton downvoteButton,
MaterialButton commentsCountButton,
MaterialButton saveButton,
@@ -1832,9 +1838,9 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
super(itemView);
setBaseView(iconGifImageView,
subredditTextView,
mCommunityInstanceTextView,
communityInstance,
userTextView,
mUserInstanceTextView,
userInstanceTextView,
authorFlairTextView,
postTimeTextView,
titleTextView,
@@ -1851,7 +1857,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
bottomConstraintLayout,
upvoteButton,
scoreTextView,
mDownvoteTextView,
downvoteTextView,
downvoteButton,
commentsCountButton,
saveButton,
@@ -1859,7 +1865,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
this.aspectRatioFrameLayout = aspectRatioFrameLayout;
this.previewImageView = previewImageView;
this.mErrorLoadingGfycatImageView = errorLoadingGfycatImageView;
this.mErrorLoadingVideoImageView = errorLoadingVideoImageView;
this.playerView = playerView;
this.muteButton = muteButton;
this.fullscreenButton = fullscreenButton;
@@ -1890,17 +1896,10 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
if (mPost.isImgur()) {
intent.setData(Uri.parse(mPost.getVideoUrl()));
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_IMGUR);
} else if (mPost.isGfycat()) {
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_GFYCAT);
intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, mPost.getGfycatId());
if (mPost.isLoadGfycatOrStreamableVideoSuccess()) {
intent.setData(Uri.parse(mPost.getVideoUrl()));
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, mPost.getVideoDownloadUrl());
}
} else if (mPost.isRedgifs()) {
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_REDGIFS);
intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, mPost.getGfycatId());
if (mPost.isLoadGfycatOrStreamableVideoSuccess()) {
intent.putExtra(ViewVideoActivity.EXTRA_REDGIFS_ID, mPost.getRedgifsId());
if (mPost.isLoadVideoSuccess()) {
intent.setData(Uri.parse(mPost.getVideoUrl()));
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, mPost.getVideoDownloadUrl());
}
@@ -2079,7 +2078,9 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
super(binding.getRoot(),
binding.iconGifImageViewItemPostDetailVideoAutoplay,
binding.subredditTextViewItemPostDetailVideoAutoplay,
binding.communityInstanceTextViewItemPostDetailVideoAutoplay,
binding.userTextViewItemPostDetailVideoAutoplay,
binding.userInstanceTextViewItemPostDetailVideoAutoplay,
binding.authorFlairTextViewItemPostDetailVideoAutoplay,
binding.postTimeTextViewItemPostDetailVideoAutoplay,
binding.titleTextViewItemPostDetailVideoAutoplay,
@@ -2095,7 +2096,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
binding.aspectRatioFrameLayoutItemPostDetailVideoAutoplay,
binding.playerViewItemPostDetailVideoAutoplay,
binding.previewImageViewItemPostDetailVideoAutoplay,
binding.errorLoadingGfycatImageViewItemPostDetailVideoAutoplay,
binding.errorLoadingVideoImageViewItemPostDetailVideoAutoplay,
binding.getRoot().findViewById(R.id.mute_exo_playback_control_view),
binding.getRoot().findViewById(R.id.fullscreen_exo_playback_control_view),
binding.getRoot().findViewById(R.id.exo_pause),
@@ -2105,6 +2106,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
binding.bottomConstraintLayoutItemPostDetailVideoAutoplay,
binding.upvoteButtonItemPostDetailVideoAutoplay,
binding.scoreTextViewItemPostDetailVideoAutoplay,
binding.downvoteTextViewItemPostDetailVideoAutoplay,
binding.downvoteButtonItemPostDetailVideoAutoplay,
binding.commentsCountButtonItemPostDetailVideoAutoplay,
binding.saveButtonItemPostDetailVideoAutoplay,
@@ -2117,7 +2119,9 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
super(binding.getRoot(),
binding.iconGifImageViewItemPostDetailVideoAutoplay,
binding.subredditTextViewItemPostDetailVideoAutoplay,
binding.communityInstanceTextViewItemPostDetailVideoAutoplay,
binding.userTextViewItemPostDetailVideoAutoplay,
binding.userInstanceTextViewItemPostDetailVideoAutoplay,
binding.authorFlairTextViewItemPostDetailVideoAutoplay,
binding.postTimeTextViewItemPostDetailVideoAutoplay,
binding.titleTextViewItemPostDetailVideoAutoplay,
@@ -2133,7 +2137,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
binding.aspectRatioFrameLayoutItemPostDetailVideoAutoplay,
binding.playerViewItemPostDetailVideoAutoplay,
binding.previewImageViewItemPostDetailVideoAutoplay,
binding.errorLoadingGfycatImageViewItemPostDetailVideoAutoplay,
binding.errorLoadingVideoImageViewItemPostDetailVideoAutoplay,
binding.getRoot().findViewById(R.id.mute_exo_playback_control_view),
binding.getRoot().findViewById(R.id.fullscreen_exo_playback_control_view),
binding.getRoot().findViewById(R.id.exo_pause),
@@ -2143,6 +2147,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
binding.bottomConstraintLayoutItemPostDetailVideoAutoplay,
binding.upvoteButtonItemPostDetailVideoAutoplay,
binding.scoreTextViewItemPostDetailVideoAutoplay,
binding.downvoteTextViewItemPostDetailVideoAutoplay,
binding.downvoteButtonItemPostDetailVideoAutoplay,
binding.commentsCountButtonItemPostDetailVideoAutoplay,
binding.saveButtonItemPostDetailVideoAutoplay,
@@ -2196,12 +2201,9 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
if (mPost.isImgur()) {
intent.setData(Uri.parse(mPost.getVideoUrl()));
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_IMGUR);
} else if (mPost.isGfycat()) {
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_GFYCAT);
intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, mPost.getGfycatId());
} else if (mPost.isRedgifs()) {
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_REDGIFS);
intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, mPost.getGfycatId());
intent.putExtra(ViewVideoActivity.EXTRA_REDGIFS_ID, mPost.getRedgifsId());
} else if (mPost.isStreamable()) {
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_STREAMABLE);
intent.putExtra(ViewVideoActivity.EXTRA_STREAMABLE_SHORT_CODE, mPost.getStreamableShortCode());
@@ -2382,12 +2384,9 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
if (mPost != null) {
if (mPost.getPostType() == Post.VIDEO_TYPE) {
Intent intent = new Intent(mActivity, ViewVideoActivity.class);
if (mPost.isGfycat()) {
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_GFYCAT);
intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, mPost.getGfycatId());
} else if (mPost.isRedgifs()) {
if (mPost.isRedgifs()) {
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_REDGIFS);
intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, mPost.getGfycatId());
intent.putExtra(ViewVideoActivity.EXTRA_REDGIFS_ID, mPost.getRedgifsId());
} else if (mPost.isStreamable()) {
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_STREAMABLE);
intent.putExtra(ViewVideoActivity.EXTRA_STREAMABLE_SHORT_CODE, mPost.getStreamableShortCode());

View File

@@ -18,17 +18,18 @@ import com.bumptech.glide.RequestBuilder;
import com.bumptech.glide.RequestManager;
import com.bumptech.glide.load.DataSource;
import com.bumptech.glide.load.engine.GlideException;
import com.bumptech.glide.load.resource.bitmap.DownsampleStrategy;
import com.bumptech.glide.request.RequestListener;
import com.bumptech.glide.request.RequestOptions;
import com.bumptech.glide.request.target.Target;
import java.util.ArrayList;
import io.noties.markwon.Markwon;
import jp.wasabeef.glide.transformations.BlurTransformation;
import eu.toldi.infinityforlemmy.SaveMemoryCenterInisdeDownsampleStrategy;
import eu.toldi.infinityforlemmy.databinding.ItemGalleryImageInPostFeedBinding;
import eu.toldi.infinityforlemmy.post.Post;
import io.noties.markwon.Markwon;
import jp.wasabeef.glide.transformations.BlurTransformation;
public class PostGalleryTypeImageRecyclerViewAdapter extends RecyclerView.Adapter<PostGalleryTypeImageRecyclerViewAdapter.ImageViewHolder> {
private RequestManager glide;
@@ -128,7 +129,7 @@ public class PostGalleryTypeImageRecyclerViewAdapter extends RecyclerView.Adapte
return;
}
RequestBuilder<Drawable> imageRequestBuilder = glide.load(galleryImages.get(index).url).listener(new RequestListener<>() {
RequestBuilder<Drawable> imageRequestBuilder = glide.load(galleryImages.get(index).url).override(1024).listener(new RequestListener<>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
holder.binding.progressBarItemGalleryImageInPostFeed.setVisibility(View.GONE);
@@ -144,10 +145,10 @@ public class PostGalleryTypeImageRecyclerViewAdapter extends RecyclerView.Adapte
}
});
if (blurImage) {
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10)))
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10))).thumbnail(0.1f).downsample(DownsampleStrategy.CENTER_INSIDE).override(1024)
.into(holder.binding.imageViewItemGalleryImageInPostFeed);
} else {
imageRequestBuilder.centerInside().downsample(saveMemoryCenterInisdeDownsampleStrategy).into(holder.binding.imageViewItemGalleryImageInPostFeed);
imageRequestBuilder.centerInside().downsample(saveMemoryCenterInisdeDownsampleStrategy).override(1024).thumbnail(0.1f).downsample(DownsampleStrategy.CENTER_INSIDE).into(holder.binding.imageViewItemGalleryImageInPostFeed);
}
}

View File

@@ -54,7 +54,7 @@ import com.google.android.exoplayer2.ui.PlayerView;
import com.google.android.exoplayer2.ui.TimeBar;
import com.google.android.material.button.MaterialButton;
import com.google.common.collect.ImmutableList;
import com.libRG.CustomTextView;
import eu.toldi.infinityforlemmy.CustomTextView;
import org.greenrobot.eventbus.EventBus;
@@ -67,7 +67,8 @@ import javax.inject.Provider;
import butterknife.BindView;
import butterknife.ButterKnife;
import eu.toldi.infinityforlemmy.FetchGfycatOrRedgifsVideoLinks;
import eu.toldi.infinityforlemmy.DualBadgeDrawable;
import eu.toldi.infinityforlemmy.FetchRedgifsVideoLinks;
import eu.toldi.infinityforlemmy.FetchStreamableVideo;
import eu.toldi.infinityforlemmy.MarkPostAsReadInterface;
import eu.toldi.infinityforlemmy.R;
@@ -86,7 +87,6 @@ import eu.toldi.infinityforlemmy.activities.ViewRedditGalleryActivity;
import eu.toldi.infinityforlemmy.activities.ViewSubredditDetailActivity;
import eu.toldi.infinityforlemmy.activities.ViewUserDetailActivity;
import eu.toldi.infinityforlemmy.activities.ViewVideoActivity;
import eu.toldi.infinityforlemmy.apis.GfycatAPI;
import eu.toldi.infinityforlemmy.apis.RedgifsAPI;
import eu.toldi.infinityforlemmy.apis.StreamableAPI;
import eu.toldi.infinityforlemmy.bottomsheetfragments.ShareLinkBottomSheetFragment;
@@ -171,7 +171,6 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
private SharedPreferences mCurrentAccountSharedPreferences;
private Executor mExecutor;
private RetrofitHolder retrofit;
private Retrofit mGfycatRetrofit;
private Retrofit mRedgifsRetrofit;
private Provider<StreamableAPI> mStreamableApiProvider;
private String mAccessToken;
@@ -200,6 +199,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
private int mSubredditColor;
private int mUsernameColor;
private int mModeratorColor;
private int mAdminColor;
private int mSpoilerBackgroundColor;
private int mSpoilerTextColor;
private int mFlairBackgroundColor;
@@ -236,7 +236,6 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
private boolean mShowThumbnailOnTheRightInCompactLayout;
private double mStartAutoplayVisibleAreaOffset;
private boolean mMuteNSFWVideo;
private boolean mAutomaticallyTryRedgifs;
private boolean mLongPressToHideToolbarInCompactLayout;
private boolean mCompactLayoutToolbarHiddenByDefault;
private boolean mDataSavingMode = false;
@@ -269,7 +268,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
private RecyclerView.RecycledViewPool mGalleryRecycledViewPool;
public PostRecyclerViewAdapter(BaseActivity activity, PostFragment fragment, Executor executor, RetrofitHolder retrofit,
Retrofit gfycatRetrofit, Retrofit redgifsRetrofit, Provider<StreamableAPI> streamableApiProvider,
Retrofit redgifsRetrofit, Provider<StreamableAPI> streamableApiProvider,
CustomThemeWrapper customThemeWrapper, Locale locale,
String accessToken, String accountName, int postType, int postLayout, boolean displaySubredditName,
SharedPreferences sharedPreferences, SharedPreferences currentAccountSharedPreferences,
@@ -284,7 +283,6 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
mCurrentAccountSharedPreferences = currentAccountSharedPreferences;
mExecutor = executor;
this.retrofit = retrofit;
mGfycatRetrofit = gfycatRetrofit;
mRedgifsRetrofit = redgifsRetrofit;
mStreamableApiProvider = streamableApiProvider;
mAccessToken = accessToken;
@@ -316,7 +314,6 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
sharedPreferences.getInt(SharedPreferencesUtils.START_AUTOPLAY_VISIBLE_AREA_OFFSET_LANDSCAPE, 50) / 100.0;
mMuteNSFWVideo = sharedPreferences.getBoolean(SharedPreferencesUtils.MUTE_NSFW_VIDEO, false);
mAutomaticallyTryRedgifs = sharedPreferences.getBoolean(SharedPreferencesUtils.AUTOMATICALLY_TRY_REDGIFS, true);
mLongPressToHideToolbarInCompactLayout = sharedPreferences.getBoolean(SharedPreferencesUtils.LONG_PRESS_TO_HIDE_TOOLBAR_IN_COMPACT_LAYOUT, false);
mCompactLayoutToolbarHiddenByDefault = sharedPreferences.getBoolean(SharedPreferencesUtils.POST_COMPACT_LAYOUT_TOOLBAR_HIDDEN_BY_DEFAULT, false);
@@ -370,6 +367,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
mSubredditColor = customThemeWrapper.getSubreddit();
mUsernameColor = customThemeWrapper.getUsername();
mModeratorColor = customThemeWrapper.getModerator();
mAdminColor = customThemeWrapper.getAdmin();
mSpoilerBackgroundColor = customThemeWrapper.getSpoilerBackgroundColor();
mSpoilerTextColor = customThemeWrapper.getSpoilerTextColor();
mFlairBackgroundColor = customThemeWrapper.getFlairBackgroundColor();
@@ -638,12 +636,31 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
((PostBaseViewHolder) holder).communityInstanceTextView.setText('@' + post.getSubredditNamePrefixed().split(Pattern.quote("@"))[1]);
((PostBaseViewHolder) holder).userInstanceTextView.setText('@' + post.getAuthorNamePrefixed().split(Pattern.quote("@"))[1]);
((PostBaseViewHolder) holder).communityInstanceTextView.setTextColor(CustomThemeWrapper.darkenColor(mSubredditColor, 0.7f));
((PostBaseViewHolder) holder).userInstanceTextView.setTextColor(CustomThemeWrapper.darkenColor(post.isModerator() || post.isAdmin() ? mModeratorColor : mUsernameColor, 0.7f));
((PostBaseViewHolder) holder).userInstanceTextView.setTextColor(CustomThemeWrapper.darkenColor(post.isModerator() ? mModeratorColor : post.isAdmin() ? mAdminColor : mUsernameColor, 0.7f));
}
((PostBaseViewHolder) holder).userTextView.setTextColor(
post.isModerator() || post.isAdmin() ? mModeratorColor : mUsernameColor);
if (post.isAdmin() && post.isModerator()) {
((PostBaseViewHolder) holder).userTextView.setTextColor(mModeratorColor);
Drawable adminDrawable = Utils.getTintedDrawable(mActivity, R.drawable.ic_verified_user_14dp, mAdminColor);
Drawable moderatorDrawable = Utils.getTintedDrawable(mActivity, R.drawable.ic_verified_user_14dp, mModeratorColor);
Drawable dualBadge = new DualBadgeDrawable(adminDrawable, moderatorDrawable);
((PostBaseViewHolder) holder).userTextView.setCompoundDrawablesWithIntrinsicBounds(
dualBadge, null, null, null);
} else if (post.isModerator()) {
((PostBaseViewHolder) holder).userTextView.setTextColor(mModeratorColor);
Drawable moderatorDrawable = Utils.getTintedDrawable(mActivity, R.drawable.ic_verified_user_14dp, mModeratorColor);
((PostBaseViewHolder) holder).userTextView.setCompoundDrawablesWithIntrinsicBounds(
moderatorDrawable, null, null, null);
} else if (post.isAdmin()) {
((PostBaseViewHolder) holder).userTextView.setTextColor(mAdminColor);
Drawable moderatorDrawable = Utils.getTintedDrawable(mActivity, R.drawable.ic_verified_user_14dp, mAdminColor);
((PostBaseViewHolder) holder).userTextView.setCompoundDrawablesWithIntrinsicBounds(
moderatorDrawable, null, null, null);
}
if (mDisplaySubredditName) {
if (authorPrefixed.equals(post.getSubredditNamePrefixed())) {
if (post.getAuthorIconUrl() == null) {
@@ -881,19 +898,17 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
}
}
if ((post.isGfycat() || post.isRedgifs()) && !post.isLoadGfycatOrStreamableVideoSuccess()) {
((PostBaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall =
post.isGfycat() ? mGfycatRetrofit.create(GfycatAPI.class).getGfycatData(post.getGfycatId()) :
mRedgifsRetrofit.create(RedgifsAPI.class).getRedgifsData(post.getGfycatId());
FetchGfycatOrRedgifsVideoLinks.fetchGfycatOrRedgifsVideoLinksInRecyclerViewAdapter(mExecutor, new Handler(),
((PostBaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall,
post.isGfycat(), mAutomaticallyTryRedgifs,
new FetchGfycatOrRedgifsVideoLinks.FetchGfycatOrRedgifsVideoLinksListener() {
if (post.isRedgifs() && !post.isLoadVideoSuccess()) {
((PostBaseVideoAutoplayViewHolder) holder).fetchStreamableVideoCall =
mRedgifsRetrofit.create(RedgifsAPI.class).getRedgifsData(post.getRedgifsId());
FetchRedgifsVideoLinks.fetchRedgifsVideoLinksInRecyclerViewAdapter(mExecutor, new Handler(),
((PostBaseVideoAutoplayViewHolder) holder).fetchStreamableVideoCall,
new FetchRedgifsVideoLinks.FetchRedgifsVideoLinksListener() {
@Override
public void success(String webm, String mp4) {
post.setVideoDownloadUrl(mp4);
post.setVideoUrl(mp4);
post.setLoadGfyOrStreamableVideoSuccess(true);
post.setLoadVideoSuccess(true);
if (position == holder.getBindingAdapterPosition()) {
((PostBaseVideoAutoplayViewHolder) holder).bindVideoUri(Uri.parse(post.getVideoUrl()));
}
@@ -902,22 +917,22 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
@Override
public void failed(int errorCode) {
if (position == holder.getBindingAdapterPosition()) {
((PostBaseVideoAutoplayViewHolder) holder).errorLoadingGfycatImageView.setVisibility(View.VISIBLE);
((PostBaseVideoAutoplayViewHolder) holder).errorLoadingVideoImageView.setVisibility(View.VISIBLE);
}
}
});
} else if (post.isStreamable() && !post.isLoadGfycatOrStreamableVideoSuccess()) {
((PostBaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall =
} else if (post.isStreamable() && !post.isLoadVideoSuccess()) {
((PostBaseVideoAutoplayViewHolder) holder).fetchStreamableVideoCall =
mStreamableApiProvider.get().getStreamableData(post.getStreamableShortCode());
FetchStreamableVideo.fetchStreamableVideoInRecyclerViewAdapter(mExecutor, new Handler(),
((PostBaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall,
((PostBaseVideoAutoplayViewHolder) holder).fetchStreamableVideoCall,
new FetchStreamableVideo.FetchStreamableVideoListener() {
@Override
public void success(StreamableVideo streamableVideo) {
StreamableVideo.Media media = streamableVideo.mp4 == null ? streamableVideo.mp4Mobile : streamableVideo.mp4;
post.setVideoDownloadUrl(media.url);
post.setVideoUrl(media.url);
post.setLoadGfyOrStreamableVideoSuccess(true);
post.setLoadVideoSuccess(true);
if (position == holder.getBindingAdapterPosition()) {
((PostBaseVideoAutoplayViewHolder) holder).bindVideoUri(Uri.parse(post.getVideoUrl()));
}
@@ -926,7 +941,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
@Override
public void failed() {
if (position == holder.getBindingAdapterPosition()) {
((PostBaseVideoAutoplayViewHolder) holder).errorLoadingGfycatImageView.setVisibility(View.VISIBLE);
((PostBaseVideoAutoplayViewHolder) holder).errorLoadingVideoImageView.setVisibility(View.VISIBLE);
}
}
});
@@ -1073,19 +1088,17 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
}
}
if ((post.isGfycat() || post.isRedgifs()) && !post.isLoadGfycatOrStreamableVideoSuccess()) {
((PostCard2BaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall =
post.isGfycat() ? mGfycatRetrofit.create(GfycatAPI.class).getGfycatData(post.getGfycatId()) :
mRedgifsRetrofit.create(RedgifsAPI.class).getRedgifsData(post.getGfycatId());
FetchGfycatOrRedgifsVideoLinks.fetchGfycatOrRedgifsVideoLinksInRecyclerViewAdapter(mExecutor, new Handler(),
((PostCard2BaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall,
post.isGfycat(), mAutomaticallyTryRedgifs,
new FetchGfycatOrRedgifsVideoLinks.FetchGfycatOrRedgifsVideoLinksListener() {
if (post.isRedgifs() && !post.isLoadVideoSuccess()) {
((PostCard2BaseVideoAutoplayViewHolder) holder).fetchStreamableVideoCall =
mRedgifsRetrofit.create(RedgifsAPI.class).getRedgifsData(post.getRedgifsId());
FetchRedgifsVideoLinks.fetchRedgifsVideoLinksInRecyclerViewAdapter(mExecutor, new Handler(),
((PostCard2BaseVideoAutoplayViewHolder) holder).fetchStreamableVideoCall,
new FetchRedgifsVideoLinks.FetchRedgifsVideoLinksListener() {
@Override
public void success(String webm, String mp4) {
post.setVideoDownloadUrl(mp4);
post.setVideoUrl(mp4);
post.setLoadGfyOrStreamableVideoSuccess(true);
post.setLoadVideoSuccess(true);
if (position == holder.getBindingAdapterPosition()) {
((PostCard2BaseVideoAutoplayViewHolder) holder).bindVideoUri(Uri.parse(post.getVideoUrl()));
}
@@ -1094,22 +1107,22 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
@Override
public void failed(int errorCode) {
if (position == holder.getBindingAdapterPosition()) {
((PostCard2BaseVideoAutoplayViewHolder) holder).errorLoadingGfycatImageView.setVisibility(View.VISIBLE);
((PostCard2BaseVideoAutoplayViewHolder) holder).errorLoadingVideoImageView.setVisibility(View.VISIBLE);
}
}
});
} else if (post.isStreamable() && !post.isLoadGfycatOrStreamableVideoSuccess()) {
((PostCard2BaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall =
} else if (post.isStreamable() && !post.isLoadVideoSuccess()) {
((PostCard2BaseVideoAutoplayViewHolder) holder).fetchStreamableVideoCall =
mStreamableApiProvider.get().getStreamableData(post.getStreamableShortCode());
FetchStreamableVideo.fetchStreamableVideoInRecyclerViewAdapter(mExecutor, new Handler(),
((PostCard2BaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall,
((PostCard2BaseVideoAutoplayViewHolder) holder).fetchStreamableVideoCall,
new FetchStreamableVideo.FetchStreamableVideoListener() {
@Override
public void success(StreamableVideo streamableVideo) {
StreamableVideo.Media media = streamableVideo.mp4 == null ? streamableVideo.mp4Mobile : streamableVideo.mp4;
post.setVideoDownloadUrl(media.url);
post.setVideoUrl(media.url);
post.setLoadGfyOrStreamableVideoSuccess(true);
post.setLoadVideoSuccess(true);
if (position == holder.getBindingAdapterPosition()) {
((PostCard2BaseVideoAutoplayViewHolder) holder).bindVideoUri(Uri.parse(post.getVideoUrl()));
}
@@ -1118,7 +1131,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
@Override
public void failed() {
if (position == holder.getBindingAdapterPosition()) {
((PostCard2BaseVideoAutoplayViewHolder) holder).errorLoadingGfycatImageView.setVisibility(View.VISIBLE);
((PostCard2BaseVideoAutoplayViewHolder) holder).errorLoadingVideoImageView.setVisibility(View.VISIBLE);
}
}
});
@@ -1890,19 +1903,17 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
}
}
if ((post.isGfycat() || post.isRedgifs()) && !post.isLoadGfycatOrStreamableVideoSuccess()) {
((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall =
post.isGfycat() ? mGfycatRetrofit.create(GfycatAPI.class).getGfycatData(post.getGfycatId()) :
mRedgifsRetrofit.create(RedgifsAPI.class).getRedgifsData(post.getGfycatId());
FetchGfycatOrRedgifsVideoLinks.fetchGfycatOrRedgifsVideoLinksInRecyclerViewAdapter(mExecutor, new Handler(),
((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall,
post.isGfycat(), mAutomaticallyTryRedgifs,
new FetchGfycatOrRedgifsVideoLinks.FetchGfycatOrRedgifsVideoLinksListener() {
if (post.isRedgifs() && !post.isLoadVideoSuccess()) {
((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).fetchStreamableVideoCall =
mRedgifsRetrofit.create(RedgifsAPI.class).getRedgifsData(post.getRedgifsId());
FetchRedgifsVideoLinks.fetchRedgifsVideoLinksInRecyclerViewAdapter(mExecutor, new Handler(),
((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).fetchStreamableVideoCall,
new FetchRedgifsVideoLinks.FetchRedgifsVideoLinksListener() {
@Override
public void success(String webm, String mp4) {
post.setVideoDownloadUrl(mp4);
post.setVideoUrl(mp4);
post.setLoadGfyOrStreamableVideoSuccess(true);
post.setLoadVideoSuccess(true);
if (position == holder.getBindingAdapterPosition()) {
((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).bindVideoUri(Uri.parse(post.getVideoUrl()));
}
@@ -1911,22 +1922,22 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
@Override
public void failed(int errorCode) {
if (position == holder.getBindingAdapterPosition()) {
((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).errorLoadingGfycatImageView.setVisibility(View.VISIBLE);
((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).errorLoadingVideoImageView.setVisibility(View.VISIBLE);
}
}
});
} else if (post.isStreamable() && !post.isLoadGfycatOrStreamableVideoSuccess()) {
((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall =
} else if (post.isStreamable() && !post.isLoadVideoSuccess()) {
((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).fetchStreamableVideoCall =
mStreamableApiProvider.get().getStreamableData(post.getStreamableShortCode());
FetchStreamableVideo.fetchStreamableVideoInRecyclerViewAdapter(mExecutor, new Handler(),
((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall,
((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).fetchStreamableVideoCall,
new FetchStreamableVideo.FetchStreamableVideoListener() {
@Override
public void success(StreamableVideo streamableVideo) {
StreamableVideo.Media media = streamableVideo.mp4 == null ? streamableVideo.mp4Mobile : streamableVideo.mp4;
post.setVideoDownloadUrl(media.url);
post.setVideoUrl(media.url);
post.setLoadGfyOrStreamableVideoSuccess(true);
post.setLoadVideoSuccess(true);
if (position == holder.getBindingAdapterPosition()) {
((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).bindVideoUri(Uri.parse(post.getVideoUrl()));
}
@@ -1935,7 +1946,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
@Override
public void failed() {
if (position == holder.getBindingAdapterPosition()) {
((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).errorLoadingGfycatImageView.setVisibility(View.VISIBLE);
((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).errorLoadingVideoImageView.setVisibility(View.VISIBLE);
}
}
});
@@ -2549,13 +2560,14 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
}
mGlide.clear(((PostBaseViewHolder) holder).iconGifImageView);
((PostBaseViewHolder) holder).titleTextView.setTextColor(mPostTitleColor);
((PostBaseViewHolder) holder).userTextView.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
if (holder instanceof PostBaseVideoAutoplayViewHolder) {
((PostBaseVideoAutoplayViewHolder) holder).mediaUri = null;
if (((PostBaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall != null && !((PostBaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall.isCanceled()) {
((PostBaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall.cancel();
((PostBaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall = null;
if (((PostBaseVideoAutoplayViewHolder) holder).fetchStreamableVideoCall != null && !((PostBaseVideoAutoplayViewHolder) holder).fetchStreamableVideoCall.isCanceled()) {
((PostBaseVideoAutoplayViewHolder) holder).fetchStreamableVideoCall.cancel();
((PostBaseVideoAutoplayViewHolder) holder).fetchStreamableVideoCall = null;
}
((PostBaseVideoAutoplayViewHolder) holder).errorLoadingGfycatImageView.setVisibility(View.GONE);
((PostBaseVideoAutoplayViewHolder) holder).errorLoadingVideoImageView.setVisibility(View.GONE);
((PostBaseVideoAutoplayViewHolder) holder).muteButton.setVisibility(View.GONE);
if (!((PostBaseVideoAutoplayViewHolder) holder).isManuallyPaused) {
((PostBaseVideoAutoplayViewHolder) holder).resetVolume();
@@ -2581,11 +2593,11 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
((PostTextTypeViewHolder) holder).binding.contentTextViewItemPostTextType.setVisibility(View.GONE);
} else if (holder instanceof PostCard2BaseVideoAutoplayViewHolder) {
((PostCard2BaseVideoAutoplayViewHolder) holder).mediaUri = null;
if (((PostCard2BaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall != null && !((PostCard2BaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall.isCanceled()) {
((PostCard2BaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall.cancel();
((PostCard2BaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall = null;
if (((PostCard2BaseVideoAutoplayViewHolder) holder).fetchStreamableVideoCall != null && !((PostCard2BaseVideoAutoplayViewHolder) holder).fetchStreamableVideoCall.isCanceled()) {
((PostCard2BaseVideoAutoplayViewHolder) holder).fetchStreamableVideoCall.cancel();
((PostCard2BaseVideoAutoplayViewHolder) holder).fetchStreamableVideoCall = null;
}
((PostCard2BaseVideoAutoplayViewHolder) holder).errorLoadingGfycatImageView.setVisibility(View.GONE);
((PostCard2BaseVideoAutoplayViewHolder) holder).errorLoadingVideoImageView.setVisibility(View.GONE);
((PostCard2BaseVideoAutoplayViewHolder) holder).muteButton.setVisibility(View.GONE);
((PostCard2BaseVideoAutoplayViewHolder) holder).resetVolume();
mGlide.clear(((PostCard2BaseVideoAutoplayViewHolder) holder).previewImageView);
@@ -2695,11 +2707,11 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
((PostMaterial3CardBaseViewHolder) holder).titleTextView.setTextColor(mPostTitleColor);
if (holder instanceof PostMaterial3CardBaseVideoAutoplayViewHolder) {
((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).mediaUri = null;
if (((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall != null && !((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall.isCanceled()) {
((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall.cancel();
((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall = null;
if (((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).fetchStreamableVideoCall != null && !((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).fetchStreamableVideoCall.isCanceled()) {
((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).fetchStreamableVideoCall.cancel();
((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).fetchStreamableVideoCall = null;
}
((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).errorLoadingGfycatImageView.setVisibility(View.GONE);
((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).errorLoadingVideoImageView.setVisibility(View.GONE);
((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).muteButton.setVisibility(View.GONE);
if (!((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).isManuallyPaused) {
((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).resetVolume();
@@ -2822,12 +2834,9 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
if (post.isImgur()) {
intent.setData(Uri.parse(post.getVideoUrl()));
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_IMGUR);
} else if (post.isGfycat()) {
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_GFYCAT);
intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, post.getGfycatId());
} else if (post.isRedgifs()) {
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_REDGIFS);
intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, post.getGfycatId());
intent.putExtra(ViewVideoActivity.EXTRA_REDGIFS_ID, post.getRedgifsId());
} else if (post.isStreamable()) {
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_STREAMABLE);
intent.putExtra(ViewVideoActivity.EXTRA_STREAMABLE_SHORT_CODE, post.getStreamableShortCode());
@@ -2888,7 +2897,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
ImageView stickiedPostImageView;
TextView postTimeTextView;
TextView titleTextView;
CustomTextView typeTextView;
eu.toldi.infinityforlemmy.CustomTextView typeTextView;
ImageView archivedImageView;
ImageView lockedImageView;
ImageView crosspostImageView;
@@ -2923,7 +2932,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
ImageView stickiedPostImageView,
TextView postTimeTextView,
TextView titleTextView,
CustomTextView typeTextView,
eu.toldi.infinityforlemmy.CustomTextView typeTextView,
ImageView archivedImageView,
ImageView lockedImageView,
ImageView crosspostImageView,
@@ -3497,7 +3506,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
ImageView stickiedPostImageView,
TextView postTimeTextView,
TextView titleTextView,
CustomTextView typeTextView,
eu.toldi.infinityforlemmy.CustomTextView typeTextView,
ImageView archivedImageView,
ImageView lockedImageView,
ImageView crosspostImageView,
@@ -3546,7 +3555,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
class PostBaseVideoAutoplayViewHolder extends PostBaseViewHolder implements ToroPlayer {
AspectRatioFrameLayout aspectRatioFrameLayout;
GifImageView previewImageView;
ImageView errorLoadingGfycatImageView;
ImageView errorLoadingVideoImageView;
PlayerView videoPlayer;
ImageView muteButton;
ImageView fullscreenButton;
@@ -3559,7 +3568,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
ExoPlayerViewHelper helper;
private Uri mediaUri;
private float volume;
public Call<String> fetchGfycatOrStreamableVideoCall;
public Call<String> fetchStreamableVideoCall;
private boolean isManuallyPaused;
PostBaseVideoAutoplayViewHolder(View rootView,
@@ -3571,7 +3580,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
ImageView stickiedPostImageView,
TextView postTimeTextView,
TextView titleTextView,
CustomTextView typeTextView,
eu.toldi.infinityforlemmy.CustomTextView typeTextView,
ImageView crosspostImageView,
ImageView archivedImageView,
ImageView lockedImageView,
@@ -3581,7 +3590,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
CustomTextView awardsTextView,
AspectRatioFrameLayout aspectRatioFrameLayout,
GifImageView previewImageView,
ImageView errorLoadingGfycatImageView,
ImageView errorLoadingVideoImageView,
PlayerView videoPlayer,
ImageView muteButton,
ImageView fullscreenButton,
@@ -3625,7 +3634,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
this.aspectRatioFrameLayout = aspectRatioFrameLayout;
this.previewImageView = previewImageView;
this.errorLoadingGfycatImageView = errorLoadingGfycatImageView;
this.errorLoadingVideoImageView = errorLoadingVideoImageView;
this.videoPlayer = videoPlayer;
this.muteButton = muteButton;
this.fullscreenButton = fullscreenButton;
@@ -3665,17 +3674,10 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
if (post.isImgur()) {
intent.setData(Uri.parse(post.getVideoUrl()));
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_IMGUR);
} else if (post.isGfycat()) {
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_GFYCAT);
intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, post.getGfycatId());
if (post.isLoadGfycatOrStreamableVideoSuccess()) {
intent.setData(Uri.parse(post.getVideoUrl()));
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl());
}
} else if (post.isRedgifs()) {
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_REDGIFS);
intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, post.getGfycatId());
if (post.isLoadGfycatOrStreamableVideoSuccess()) {
intent.putExtra(ViewVideoActivity.EXTRA_REDGIFS_ID, post.getRedgifsId());
if (post.isLoadVideoSuccess()) {
intent.setData(Uri.parse(post.getVideoUrl()));
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl());
}
@@ -3876,7 +3878,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
binding.awardsTextViewItemPostVideoTypeAutoplay,
binding.aspectRatioFrameLayoutItemPostVideoTypeAutoplay,
binding.previewImageViewItemPostVideoTypeAutoplay,
binding.errorLoadingGfycatImageViewItemPostVideoTypeAutoplay,
binding.errorLoadingVideoImageViewItemPostVideoTypeAutoplay,
binding.playerViewItemPostVideoTypeAutoplay,
binding.getRoot().findViewById(R.id.mute_exo_playback_control_view),
binding.getRoot().findViewById(R.id.fullscreen_exo_playback_control_view),
@@ -3915,7 +3917,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
binding.awardsTextViewItemPostVideoTypeAutoplay,
binding.aspectRatioFrameLayoutItemPostVideoTypeAutoplay,
binding.previewImageViewItemPostVideoTypeAutoplay,
binding.errorLoadingGfycatImageViewItemPostVideoTypeAutoplay,
binding.errorLoadingVideoImageViewItemPostVideoTypeAutoplay,
binding.playerViewItemPostVideoTypeAutoplay,
binding.getRoot().findViewById(R.id.mute_exo_playback_control_view),
binding.getRoot().findViewById(R.id.fullscreen_exo_playback_control_view),
@@ -4036,7 +4038,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
ImageView stickiedPostImageView,
TextView postTimeTextView,
TextView titleTextView,
CustomTextView typeTextView,
eu.toldi.infinityforlemmy.CustomTextView typeTextView,
ImageView archivedImageView,
ImageView lockedImageView,
ImageView crosspostImageView,
@@ -5329,7 +5331,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
class PostCard2BaseVideoAutoplayViewHolder extends PostBaseViewHolder implements ToroPlayer {
AspectRatioFrameLayout aspectRatioFrameLayout;
GifImageView previewImageView;
ImageView errorLoadingGfycatImageView;
ImageView errorLoadingVideoImageView;
PlayerView videoPlayer;
ImageView muteButton;
ImageView fullscreenButton;
@@ -5343,7 +5345,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
ExoPlayerViewHelper helper;
private Uri mediaUri;
private float volume;
public Call<String> fetchGfycatOrStreamableVideoCall;
public Call<String> fetchStreamableVideoCall;
private boolean isManuallyPaused;
PostCard2BaseVideoAutoplayViewHolder(View itemView,
@@ -5355,7 +5357,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
ImageView stickiedPostImageView,
TextView postTimeTextView,
TextView titleTextView,
CustomTextView typeTextView,
eu.toldi.infinityforlemmy.CustomTextView typeTextView,
ImageView crosspostImageView,
ImageView archivedImageView,
ImageView lockedImageView,
@@ -5365,7 +5367,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
CustomTextView awardsTextView,
AspectRatioFrameLayout aspectRatioFrameLayout,
GifImageView previewImageView,
ImageView errorLoadingGfycatImageView,
ImageView errorLoadingVideoImageView,
PlayerView videoPlayer,
ImageView muteButton,
ImageView fullscreenButton,
@@ -5411,7 +5413,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
this.aspectRatioFrameLayout = aspectRatioFrameLayout;
this.previewImageView = previewImageView;
this.errorLoadingGfycatImageView = errorLoadingGfycatImageView;
this.errorLoadingVideoImageView = errorLoadingVideoImageView;
this.videoPlayer = videoPlayer;
this.muteButton = muteButton;
this.fullscreenButton = fullscreenButton;
@@ -5452,17 +5454,10 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
if (post.isImgur()) {
intent.setData(Uri.parse(post.getVideoUrl()));
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_IMGUR);
} else if (post.isGfycat()) {
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_GFYCAT);
intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, post.getGfycatId());
if (post.isLoadGfycatOrStreamableVideoSuccess()) {
intent.setData(Uri.parse(post.getVideoUrl()));
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl());
}
} else if (post.isRedgifs()) {
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_REDGIFS);
intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, post.getGfycatId());
if (post.isLoadGfycatOrStreamableVideoSuccess()) {
intent.putExtra(ViewVideoActivity.EXTRA_REDGIFS_ID, post.getRedgifsId());
if (post.isLoadVideoSuccess()) {
intent.setData(Uri.parse(post.getVideoUrl()));
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl());
}
@@ -5662,7 +5657,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
binding.awardsTextViewItemPostCard2VideoAutoplay,
binding.aspectRatioFrameLayoutItemPostCard2VideoAutoplay,
binding.previewImageViewItemPostCard2VideoAutoplay,
binding.errorLoadingGfycatImageViewItemPostCard2VideoAutoplay,
binding.errorLoadingVideoImageViewItemPostCard2VideoAutoplay,
binding.playerViewItemPostCard2VideoAutoplay,
binding.getRoot().findViewById(R.id.mute_exo_playback_control_view),
binding.getRoot().findViewById(R.id.fullscreen_exo_playback_control_view),
@@ -5702,7 +5697,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
binding.awardsTextViewItemPostCard2VideoAutoplay,
binding.aspectRatioFrameLayoutItemPostCard2VideoAutoplay,
binding.previewImageViewItemPostCard2VideoAutoplay,
binding.errorLoadingGfycatImageViewItemPostCard2VideoAutoplay,
binding.errorLoadingVideoImageViewItemPostCard2VideoAutoplay,
binding.playerViewItemPostCard2VideoAutoplay,
binding.getRoot().findViewById(R.id.mute_exo_playback_control_view),
binding.getRoot().findViewById(R.id.fullscreen_exo_playback_control_view),
@@ -6397,7 +6392,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
class PostMaterial3CardBaseVideoAutoplayViewHolder extends PostMaterial3CardBaseViewHolder implements ToroPlayer {
AspectRatioFrameLayout aspectRatioFrameLayout;
GifImageView previewImageView;
ImageView errorLoadingGfycatImageView;
ImageView errorLoadingVideoImageView;
PlayerView videoPlayer;
ImageView muteButton;
ImageView fullscreenButton;
@@ -6410,7 +6405,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
ExoPlayerViewHelper helper;
private Uri mediaUri;
private float volume;
public Call<String> fetchGfycatOrStreamableVideoCall;
public Call<String> fetchStreamableVideoCall;
private boolean isManuallyPaused;
PostMaterial3CardBaseVideoAutoplayViewHolder(View rootView,
@@ -6422,7 +6417,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
TextView titleTextView,
AspectRatioFrameLayout aspectRatioFrameLayout,
GifImageView previewImageView,
ImageView errorLoadingGfycatImageView,
ImageView errorLoadingVideoImageView,
PlayerView videoPlayer,
ImageView muteButton,
ImageView fullscreenButton,
@@ -6457,7 +6452,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
this.aspectRatioFrameLayout = aspectRatioFrameLayout;
this.previewImageView = previewImageView;
this.errorLoadingGfycatImageView = errorLoadingGfycatImageView;
this.errorLoadingVideoImageView = errorLoadingVideoImageView;
this.videoPlayer = videoPlayer;
this.muteButton = muteButton;
this.fullscreenButton = fullscreenButton;
@@ -6497,17 +6492,10 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
if (post.isImgur()) {
intent.setData(Uri.parse(post.getVideoUrl()));
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_IMGUR);
} else if (post.isGfycat()) {
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_GFYCAT);
intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, post.getGfycatId());
if (post.isLoadGfycatOrStreamableVideoSuccess()) {
intent.setData(Uri.parse(post.getVideoUrl()));
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl());
}
} else if (post.isRedgifs()) {
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_REDGIFS);
intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, post.getGfycatId());
if (post.isLoadGfycatOrStreamableVideoSuccess()) {
intent.putExtra(ViewVideoActivity.EXTRA_REDGIFS_ID, post.getRedgifsId());
if (post.isLoadVideoSuccess()) {
intent.setData(Uri.parse(post.getVideoUrl()));
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl());
}
@@ -6698,7 +6686,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
binding.titleTextViewItemPostCard3VideoTypeAutoplay,
binding.aspectRatioFrameLayoutItemPostCard3VideoTypeAutoplay,
binding.previewImageViewItemPostCard3VideoTypeAutoplay,
binding.errorLoadingGfycatImageViewItemPostCard3VideoTypeAutoplay,
binding.errorLoadingVideoImageViewItemPostCard3VideoTypeAutoplay,
binding.playerViewItemPostCard3VideoTypeAutoplay,
binding.getRoot().findViewById(R.id.mute_exo_playback_control_view),
binding.getRoot().findViewById(R.id.fullscreen_exo_playback_control_view),
@@ -6726,7 +6714,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
binding.titleTextViewItemPostCard3VideoTypeAutoplay,
binding.aspectRatioFrameLayoutItemPostCard3VideoTypeAutoplay,
binding.previewImageViewItemPostCard3VideoTypeAutoplay,
binding.errorLoadingGfycatImageViewItemPostCard3VideoTypeAutoplay,
binding.errorLoadingVideoImageViewItemPostCard3VideoTypeAutoplay,
binding.playerViewItemPostCard3VideoTypeAutoplay,
binding.getRoot().findViewById(R.id.mute_exo_playback_control_view),
binding.getRoot().findViewById(R.id.fullscreen_exo_playback_control_view),

View File

@@ -12,6 +12,8 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.Glide;
import java.util.ArrayList;
import butterknife.BindView;
@@ -84,7 +86,7 @@ public class RulesRecyclerViewAdapter extends RecyclerView.Adapter<RulesRecycler
return true;
};
markwon = MarkdownUtils.createFullRedditMarkwon(activity,
miscPlugin, mPrimaryTextColor, spoilerBackgroundColor, onLinkLongClickListener, mDisableImagePreview);
miscPlugin, mPrimaryTextColor, spoilerBackgroundColor, Glide.with(activity.getApplication()), onLinkLongClickListener, mDisableImagePreview);
}
@NonNull

View File

@@ -16,13 +16,14 @@ import butterknife.ButterKnife;
import eu.toldi.infinityforlemmy.R;
import eu.toldi.infinityforlemmy.activities.BaseActivity;
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
import eu.toldi.infinityforlemmy.subreddit.SubredditWithSelection;
public class SelectedSubredditsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private BaseActivity activity;
private CustomThemeWrapper customThemeWrapper;
private ArrayList<String> subreddits;
private ArrayList<SubredditWithSelection> subreddits;
public SelectedSubredditsRecyclerViewAdapter(BaseActivity activity, CustomThemeWrapper customThemeWrapper, ArrayList<String> subreddits) {
public SelectedSubredditsRecyclerViewAdapter(BaseActivity activity, CustomThemeWrapper customThemeWrapper, ArrayList<SubredditWithSelection> subreddits) {
this.activity = activity;
this.customThemeWrapper = customThemeWrapper;
if (subreddits == null) {
@@ -42,7 +43,7 @@ public class SelectedSubredditsRecyclerViewAdapter extends RecyclerView.Adapter<
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
if (holder instanceof SubredditViewHolder) {
((SubredditViewHolder) holder).subredditNameTextView.setText(subreddits.get(holder.getBindingAdapterPosition()));
((SubredditViewHolder) holder).subredditNameTextView.setText(subreddits.get(holder.getBindingAdapterPosition()).getQualifiedName());
((SubredditViewHolder) holder).deleteButton.setOnClickListener(view -> {
subreddits.remove(holder.getBindingAdapterPosition());
notifyItemRemoved(holder.getBindingAdapterPosition());
@@ -55,18 +56,22 @@ public class SelectedSubredditsRecyclerViewAdapter extends RecyclerView.Adapter<
return subreddits.size();
}
public void addSubreddits(ArrayList<String> newSubreddits) {
public void addSubreddits(ArrayList<SubredditWithSelection> newSubreddits) {
int oldSize = subreddits.size();
subreddits.addAll(newSubreddits);
for (SubredditWithSelection subreddit : newSubreddits) {
if (!subreddits.contains(subreddit)) {
subreddits.add(subreddit);
}
}
notifyItemRangeInserted(oldSize, newSubreddits.size());
}
public void addUserInSubredditType(String username) {
subreddits.add(username);
notifyItemInserted(subreddits.size());
/*subreddits.add(username);
notifyItemInserted(subreddits.size());*/
}
public ArrayList<String> getSubreddits() {
public ArrayList<SubredditWithSelection> getSubreddits() {
return subreddits;
}

View File

@@ -19,12 +19,12 @@ import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
import eu.toldi.infinityforlemmy.R;
import eu.toldi.infinityforlemmy.activities.BaseActivity;
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
import eu.toldi.infinityforlemmy.subreddit.SubredditWithSelection;
import eu.toldi.infinityforlemmy.subscribedsubreddit.SubscribedSubredditData;
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
import pl.droidsonroids.gif.GifImageView;
public class SubredditMultiselectionRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
@@ -53,6 +53,7 @@ public class SubredditMultiselectionRecyclerViewAdapter extends RecyclerView.Ada
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
if (holder instanceof SubscribedSubredditViewHolder) {
((SubscribedSubredditViewHolder) holder).nameTextView.setText(subscribedSubreddits.get(position).getName());
((SubscribedSubredditViewHolder) holder).instanceTextView.setText(subscribedSubreddits.get(position).getQualifiedName().substring(subscribedSubreddits.get(position).getQualifiedName().indexOf("@")));
glide.load(subscribedSubreddits.get(position).getIconUrl())
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
.error(glide.load(R.drawable.subreddit_default_icon)
@@ -91,11 +92,11 @@ public class SubredditMultiselectionRecyclerViewAdapter extends RecyclerView.Ada
notifyDataSetChanged();
}
public ArrayList<String> getAllSelectedSubreddits() {
ArrayList<String> selectedSubreddits = new ArrayList<>();
public ArrayList<SubredditWithSelection> getAllSelectedSubreddits() {
ArrayList<SubredditWithSelection> selectedSubreddits = new ArrayList<>();
for (SubredditWithSelection s : subscribedSubreddits) {
if (s.isSelected()) {
selectedSubreddits.add(s.getName());
selectedSubreddits.add(s);
}
}
return selectedSubreddits;
@@ -107,6 +108,9 @@ public class SubredditMultiselectionRecyclerViewAdapter extends RecyclerView.Ada
GifImageView iconImageView;
@BindView(R.id.name_text_view_item_subscribed_subreddit_multiselection)
TextView nameTextView;
@BindView(R.id.instance_text_view_item_subscribed_subreddit_multiselection)
TextView instanceTextView;
@BindView(R.id.checkbox_item_subscribed_subreddit_multiselection)
CheckBox checkBox;
@@ -115,10 +119,12 @@ public class SubredditMultiselectionRecyclerViewAdapter extends RecyclerView.Ada
this.itemView = itemView;
ButterKnife.bind(this, itemView);
nameTextView.setTextColor(primaryTextColor);
instanceTextView.setTextColor(primaryTextColor);
checkBox.setButtonTintList(ColorStateList.valueOf(colorAccent));
if (activity.typeface != null) {
nameTextView.setTypeface(activity.typeface);
instanceTextView.setTypeface(activity.typeface);
}
}
}

View File

@@ -47,7 +47,6 @@ public class UserFlairRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerV
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
if (holder instanceof UserFlairViewHolder) {
if (position == 0) {
((UserFlairViewHolder) holder).userFlairHtmlTextView.setText(R.string.clear_user_flair);
((UserFlairViewHolder) holder).editUserFlairImageView.setVisibility(View.GONE);
} else {
UserFlair userFlair = userFlairs.get(holder.getBindingAdapterPosition() - 1);

View File

@@ -24,8 +24,8 @@ public class AccountSectionRecyclerViewAdapter extends RecyclerView.Adapter<Recy
private static final int VIEW_TYPE_MENU_GROUP_TITLE = 1;
private static final int VIEW_TYPE_MENU_ITEM = 2;
private static final int ACCOUNT_SECTION_ITEMS = 4;
private static final int ANONYMOUS_ACCOUNT_SECTION_ITEMS = 1;
private static final int ACCOUNT_SECTION_ITEMS = 5;
private static final int ANONYMOUS_ACCOUNT_SECTION_ITEMS = 2;
private BaseActivity baseActivity;
private int inboxCount;
@@ -113,6 +113,10 @@ public class AccountSectionRecyclerViewAdapter extends RecyclerView.Adapter<Recy
baseActivity.startActivity(intent);
});
break;
case 4:
stringId = R.string.multi_reddit;
drawableId = R.drawable.ic_multi_reddit_24dp;
break;
default:
stringId = R.string.account_saved_thing_activity_label;
drawableId = R.drawable.ic_outline_bookmarks_24dp;
@@ -125,6 +129,10 @@ public class AccountSectionRecyclerViewAdapter extends RecyclerView.Adapter<Recy
stringId = R.string.subscriptions;
drawableId = R.drawable.ic_subscritptions_bottom_app_bar_24dp;
break;
case 2:
stringId = R.string.multi_reddit;
drawableId = R.drawable.ic_multi_reddit_24dp;
break;
default:
stringId = R.string.anonymous_account_instance;
drawableId = R.drawable.ic_account_circle_24dp;

View File

@@ -1,10 +0,0 @@
package eu.toldi.infinityforlemmy.apis;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Path;
public interface GfycatAPI {
@GET("{gfyid}")
Call<String> getGfycatData(@Path("gfyid") String gfyId);
}

View File

@@ -7,6 +7,7 @@ import com.google.common.util.concurrent.ListenableFuture;
import eu.toldi.infinityforlemmy.dto.AccountLoginDTO;
import eu.toldi.infinityforlemmy.dto.AuthDTO;
import eu.toldi.infinityforlemmy.dto.BlockCommunityDTO;
import eu.toldi.infinityforlemmy.dto.BlockInstanceDTO;
import eu.toldi.infinityforlemmy.dto.CommentDTO;
import eu.toldi.infinityforlemmy.dto.CommentVoteDTO;
import eu.toldi.infinityforlemmy.dto.DeleteCommentDTO;
@@ -275,6 +276,11 @@ public interface LemmyAPI {
@Query("auth") String auth
);
@POST("/api/v3/site/block")
Call<String> blockInstance(
@Body BlockInstanceDTO params
);
@GET("api/v3/private_message/list")
Call<String> privateMessagesList(
@Query("page") Integer page,

View File

@@ -13,11 +13,7 @@ public class DeleteMultiredditInDatabase {
String accountName, String multipath,
DeleteMultiredditInDatabaseListener deleteMultiredditInDatabaseListener) {
executor.execute(() -> {
if (accountName.equals("-")) {
redditDataRoomDatabase.multiRedditDao().anonymousDeleteMultiReddit(multipath);
} else {
redditDataRoomDatabase.multiRedditDao().deleteMultiReddit(multipath, accountName);
}
redditDataRoomDatabase.multiRedditDao().anonymousDeleteMultiReddit(multipath);
handler.post(deleteMultiredditInDatabaseListener::success);
});
}

View File

@@ -12,6 +12,7 @@ import java.util.concurrent.Executor;
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
import eu.toldi.infinityforlemmy.blockedcommunity.BlockedCommunityDao;
import eu.toldi.infinityforlemmy.blockedcommunity.BlockedCommunityData;
import eu.toldi.infinityforlemmy.blockedinstances.BlockedInstanceData;
import eu.toldi.infinityforlemmy.blockeduser.BlockedUserDao;
import eu.toldi.infinityforlemmy.blockeduser.BlockedUserData;
@@ -22,6 +23,7 @@ public class InsertBlockedThings {
RedditDataRoomDatabase redditDataRoomDatabase, @Nullable String accountName,
List<BlockedCommunityData> blockedCommunityDataList,
List<BlockedUserData> blockedUserDataDataList,
List<BlockedInstanceData> blockedInstanceDataList,
InsertBlockedThingListener insertSubscribedThingListener) {
executor.execute(() -> {
@@ -68,6 +70,23 @@ public class InsertBlockedThings {
}
}
if (blockedInstanceDataList != null) {
List<BlockedInstanceData> existingBlockedInstanceDataList =
redditDataRoomDatabase.blockedInstanceDao().getAllInstanceInstancesList(accountName);
Collections.sort(blockedInstanceDataList, (subscribedInstanceData, t1) -> subscribedInstanceData.getDomain().compareToIgnoreCase(t1.getDomain()));
List<String> unblockedInstances = new ArrayList<>();
compareTwoBlockedInstanceList(blockedInstanceDataList, existingBlockedInstanceDataList,
unblockedInstances);
for (String unblocked : unblockedInstances) {
redditDataRoomDatabase.blockedInstanceDao().deleteInstanceUser(unblocked, accountName);
}
for (BlockedInstanceData s : blockedInstanceDataList) {
redditDataRoomDatabase.blockedInstanceDao().insert(s);
}
}
handler.post(insertSubscribedThingListener::insertSuccess);
});
}
@@ -124,6 +143,32 @@ public class InsertBlockedThings {
}
}
private static void compareTwoBlockedInstanceList(List<BlockedInstanceData> newBlockedInstances,
List<BlockedInstanceData> oldBlockedInstances,
List<String> unblockedInstances) {
int newIndex = 0;
for (int oldIndex = 0; oldIndex < oldBlockedInstances.size(); oldIndex++) {
if (newIndex >= newBlockedInstances.size()) {
for (; oldIndex < oldBlockedInstances.size(); oldIndex++) {
unblockedInstances.add(oldBlockedInstances.get(oldIndex).getDomain());
}
return;
}
BlockedInstanceData old = oldBlockedInstances.get(oldIndex);
for (; newIndex < newBlockedInstances.size(); newIndex++) {
if (newBlockedInstances.get(newIndex).getDomain().compareToIgnoreCase(old.getDomain()) == 0) {
newIndex++;
break;
}
if (newBlockedInstances.get(newIndex).getDomain().compareToIgnoreCase(old.getDomain()) > 0) {
unblockedInstances.add(old.getDomain());
break;
}
}
}
}
public interface InsertBlockedThingListener {
void insertSuccess();
}

View File

@@ -11,6 +11,7 @@ import eu.toldi.infinityforlemmy.RetrofitHolder;
import eu.toldi.infinityforlemmy.account.Account;
import eu.toldi.infinityforlemmy.site.FetchSiteInfo;
import eu.toldi.infinityforlemmy.site.SiteInfo;
import eu.toldi.infinityforlemmy.user.MyUserInfo;
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
public class SwitchAccount {
@@ -33,7 +34,7 @@ public class SwitchAccount {
retrofitHolder.setAccessToken(null);
FetchSiteInfo.fetchSiteInfo(retrofitHolder.getRetrofit(), account.getAccessToken(), new FetchSiteInfo.FetchSiteInfoListener() {
@Override
public void onFetchSiteInfoSuccess(SiteInfo siteInfo) {
public void onFetchSiteInfoSuccess(SiteInfo siteInfo, MyUserInfo myUserInfo) {
boolean canDownvote = siteInfo.isEnable_downvotes();
currentAccountSharedPreferences.edit().putBoolean(SharedPreferencesUtils.CAN_DOWNVOTE, canDownvote).apply();
String[] version = siteInfo.getVersion().split("\\.");
@@ -49,7 +50,7 @@ public class SwitchAccount {
}
@Override
public void onFetchSiteInfoFailed() {
public void onFetchSiteInfoFailed(boolean parseFailed) {
Log.e("SwitchAccount", "Failed to fetch site info");
currentAccountSharedPreferences.edit().putBoolean(SharedPreferencesUtils.CAN_DOWNVOTE, true).apply();
}

View File

@@ -0,0 +1,30 @@
package eu.toldi.infinityforlemmy.blockedinstances;
import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;
import java.util.List;
@Dao
public interface BlockedInstanceDao {
@Insert(onConflict = OnConflictStrategy.REPLACE)
void insert(BlockedInstanceData instanceData);
@Insert(onConflict = OnConflictStrategy.REPLACE)
void insertAll(List<BlockedInstanceData> blockedUserDataDataList);
@Query("SELECT * FROM blocked_instances WHERE account_name = :accountName AND domain LIKE '%' || :searchQuery || '%' COLLATE NOCASE ORDER BY domain COLLATE NOCASE ASC")
LiveData<List<BlockedInstanceData>> getAllBlockedInstancesWithSearchQuery(String accountName, String searchQuery);
@Query("SELECT * FROM blocked_instances WHERE account_name = :accountName COLLATE NOCASE ORDER BY domain COLLATE NOCASE ASC")
List<BlockedInstanceData> getAllInstanceInstancesList(String accountName);
@Query("SELECT * FROM blocked_instances WHERE domain = :domain COLLATE NOCASE AND account_name = :accountName COLLATE NOCASE LIMIT 1")
BlockedInstanceData getInstanceUser(String domain, String accountName);
@Query("DELETE FROM blocked_instances WHERE domain = :domain COLLATE NOCASE AND account_name = :accountName COLLATE NOCASE")
void deleteInstanceUser(String domain, String accountName);
}

View File

@@ -0,0 +1,57 @@
package eu.toldi.infinityforlemmy.blockedinstances;
import androidx.annotation.NonNull;
import androidx.room.ColumnInfo;
import androidx.room.Entity;
@Entity(tableName = "blocked_instances", primaryKeys = {"id", "account_name"})
public class BlockedInstanceData {
@ColumnInfo(name = "id")
private final int id;
@ColumnInfo(name = "domain")
private String domain;
@NonNull
@ColumnInfo(name = "account_name")
private String accountName;
@ColumnInfo(name = "instance_name")
private String name;
@ColumnInfo(name = "icon")
private String icon;
public BlockedInstanceData(int id, String domain, String name, String icon, String accountName) {
this.id = id;
this.domain = domain;
this.icon = icon;
this.name = name;
this.accountName = accountName;
}
public int getId() {
return id;
}
public String getDomain() {
return domain;
}
public String getAccountName() {
return accountName;
}
public void setAccountName(String accountName) {
this.accountName = accountName;
}
public String getName() {
return name;
}
public String getIcon() {
return icon;
}
}

View File

@@ -0,0 +1,47 @@
package eu.toldi.infinityforlemmy.blockedinstances;
import android.os.AsyncTask;
import androidx.lifecycle.LiveData;
import java.util.List;
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
public class BlockedInstanceRepository {
private BlockedInstanceDao blockedInstanceDao;
private String mAccountName;
BlockedInstanceRepository(RedditDataRoomDatabase redditDataRoomDatabase, String accountName) {
blockedInstanceDao = redditDataRoomDatabase.blockedInstanceDao();
mAccountName = accountName;
}
LiveData<List<BlockedInstanceData>> getAllBlockedInstancesWithSearchQuery(String searchQuery) {
return blockedInstanceDao.getAllBlockedInstancesWithSearchQuery(mAccountName, searchQuery);
}
LiveData<List<BlockedInstanceData>> getAllFavoriteSubscribedInstancesWithSearchQuery(String searchQuery) {
return blockedInstanceDao.getAllBlockedInstancesWithSearchQuery(mAccountName, searchQuery);
}
public void insert(BlockedInstanceData BlockedInstanceData) {
new BlockedInstanceRepository.insertAsyncTask(blockedInstanceDao).execute(BlockedInstanceData);
}
private static class insertAsyncTask extends AsyncTask<BlockedInstanceData, Void, Void> {
private BlockedInstanceDao mAsyncTaskDao;
insertAsyncTask(BlockedInstanceDao dao) {
mAsyncTaskDao = dao;
}
@Override
protected Void doInBackground(final BlockedInstanceData... params) {
mAsyncTaskDao.insert(params[0]);
return null;
}
}
}

View File

@@ -0,0 +1,61 @@
package eu.toldi.infinityforlemmy.blockedinstances;
import android.app.Application;
import androidx.annotation.NonNull;
import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.Transformations;
import androidx.lifecycle.ViewModel;
import androidx.lifecycle.ViewModelProvider;
import java.util.List;
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
public class BlockedInstanceViewModel extends AndroidViewModel {
private BlockedInstanceRepository blockedInstanceRepository;
private LiveData<List<BlockedInstanceData>> mAllSubscribedInstances;
private MutableLiveData<String> searchQueryLiveData;
public BlockedInstanceViewModel(Application application, RedditDataRoomDatabase redditDataRoomDatabase, String accountName) {
super(application);
blockedInstanceRepository = new BlockedInstanceRepository(redditDataRoomDatabase, accountName);
searchQueryLiveData = new MutableLiveData<>();
searchQueryLiveData.postValue("");
mAllSubscribedInstances = Transformations.switchMap(searchQueryLiveData, searchQuery -> blockedInstanceRepository.getAllFavoriteSubscribedInstancesWithSearchQuery(searchQuery));
}
public LiveData<List<BlockedInstanceData>> getAllSubscribedInstances() {
return mAllSubscribedInstances;
}
public void insert(BlockedInstanceData BlockedInstanceData) {
blockedInstanceRepository.insert(BlockedInstanceData);
}
public void setSearchQuery(String searchQuery) {
searchQueryLiveData.postValue(searchQuery);
}
public static class Factory extends ViewModelProvider.NewInstanceFactory {
private Application mApplication;
private RedditDataRoomDatabase mRedditDataRoomDatabase;
private String mAccountName;
public Factory(Application application, RedditDataRoomDatabase redditDataRoomDatabase, String accountName) {
mApplication = application;
mRedditDataRoomDatabase = redditDataRoomDatabase;
mAccountName = accountName;
}
@NonNull
@Override
public <T extends ViewModel> T create(@NonNull Class<T> modelClass) {
return (T) new BlockedInstanceViewModel(mApplication, mRedditDataRoomDatabase, mAccountName);
}
}
}

View File

@@ -111,7 +111,7 @@ public class FlairBottomSheetFragment extends LandscapeExpandedBottomSheetDialog
progressBar.setVisibility(View.GONE);
if (flairs == null || flairs.size() == 0) {
errorTextView.setVisibility(View.VISIBLE);
errorTextView.setText(R.string.no_flair);
errorTextView.setText("");
} else {
errorTextView.setVisibility(View.GONE);
mAdapter.changeDataset(flairs);
@@ -122,7 +122,7 @@ public class FlairBottomSheetFragment extends LandscapeExpandedBottomSheetDialog
public void fetchFailed() {
progressBar.setVisibility(View.GONE);
errorTextView.setVisibility(View.VISIBLE);
errorTextView.setText(R.string.error_loading_flairs);
errorTextView.setText("");
errorTextView.setOnClickListener(view -> fetchFlairs());
}
});

View File

@@ -29,11 +29,20 @@ import eu.toldi.infinityforlemmy.utils.Utils;
*/
public class SortTypeBottomSheetFragment extends LandscapeExpandedRoundedBottomSheetDialogFragment {
public static final String EXTRA_NO_BEST_TYPE = "ENBT";
public static final String EXTRA_CURRENT_SORT_TYPE = "ECST";
public static final String EXTRA_PAGE_TYPE = "EPT";
public static final int PAGE_TYPE_FRONT_PAGE = 0;
public static final int PAGE_TYPE_COMMUNITY = 1;
public static final int PAGE_TYPE_USER = 2;
public static final int PAGE_TYPE_SEARCH = 3;
public static final int PAGE_TYPE_MULTICOMMUNITY = 4;
public static final int PAGE_TYPE_ANONYMOUS_FRONT_PAGE = 5;
@BindView(R.id.best_type_text_view_sort_type_bottom_sheet_fragment)
TextView bestTypeTextView;
TextView activeTypeTextView;
@BindView(R.id.hot_type_text_view_sort_type_bottom_sheet_fragment)
TextView hotTypeTextView;
@BindView(R.id.new_type_text_view_sort_type_bottom_sheet_fragment)
@@ -49,16 +58,22 @@ public class SortTypeBottomSheetFragment extends LandscapeExpandedRoundedBottomS
@BindView(R.id.controversial_type_text_view_sort_type_bottom_sheet_fragment)
TextView controversialTypeTextView;
@BindView(R.id.most_comments_type_text_view_sort_type_bottom_sheet_fragment)
TextView mostCommentsTypeTextView;
@BindView(R.id.new_comments_type_text_view_sort_type_bottom_sheet_fragment)
TextView newCommentsTypeTextView;
private BaseActivity activity;
public SortTypeBottomSheetFragment() {
// Required empty public constructor
}
public static SortTypeBottomSheetFragment getNewInstance(boolean isNoBestType, SortType currentSortType) {
public static SortTypeBottomSheetFragment getNewInstance(int pageType, SortType currentSortType) {
SortTypeBottomSheetFragment fragment = new SortTypeBottomSheetFragment();
Bundle bundle = new Bundle();
bundle.putBoolean(EXTRA_NO_BEST_TYPE, isNoBestType);
bundle.putInt(EXTRA_PAGE_TYPE, pageType);
bundle.putString(EXTRA_CURRENT_SORT_TYPE, currentSortType.getType().fullName);
fragment.setArguments(bundle);
return fragment;
@@ -75,18 +90,32 @@ public class SortTypeBottomSheetFragment extends LandscapeExpandedRoundedBottomS
rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
}
if (getArguments().getBoolean(EXTRA_NO_BEST_TYPE)) {
bestTypeTextView.setVisibility(View.GONE);
} else {
bestTypeTextView.setOnClickListener(view -> {
((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.ACTIVE));
dismiss();
});
int pageType = getArguments().getInt(EXTRA_PAGE_TYPE, PAGE_TYPE_USER);
switch (pageType) {
case PAGE_TYPE_MULTICOMMUNITY:
case PAGE_TYPE_USER:
case PAGE_TYPE_ANONYMOUS_FRONT_PAGE:
activeTypeTextView.setVisibility(View.GONE);
hotTypeTextView.setVisibility(View.GONE);
scaledTypeTextView.setVisibility(View.GONE);
controversialTypeTextView.setVisibility(View.GONE);
mostCommentsTypeTextView.setVisibility(View.GONE);
newCommentsTypeTextView.setVisibility(View.GONE);
break;
default:
case PAGE_TYPE_COMMUNITY:
case PAGE_TYPE_FRONT_PAGE:
case PAGE_TYPE_SEARCH:
break;
}
String currentSortType = getArguments().getString(EXTRA_CURRENT_SORT_TYPE);
if (currentSortType.equals(SortType.Type.ACTIVE.fullName)) {
bestTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(bestTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null);
activeTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(activeTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null);
} else if (currentSortType.equals(SortType.Type.HOT.fullName)) {
hotTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(hotTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null);
} else if (currentSortType.equals(SortType.Type.NEW.fullName)) {
@@ -99,8 +128,17 @@ public class SortTypeBottomSheetFragment extends LandscapeExpandedRoundedBottomS
scaledTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(scaledTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null);
} else if (currentSortType.equals(SortType.Type.CONTROVERSIAL.fullName)) {
controversialTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(controversialTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null);
} else if (currentSortType.equals(SortType.Type.MOST_COMMENTS.fullName)) {
mostCommentsTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(mostCommentsTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null);
} else if (currentSortType.equals(SortType.Type.NEW_COMMENTS.fullName)) {
newCommentsTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(newCommentsTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null);
}
activeTypeTextView.setOnClickListener(view -> {
((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.ACTIVE));
dismiss();
});
hotTypeTextView.setOnClickListener(view -> {
((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.HOT));
dismiss();
@@ -131,6 +169,16 @@ public class SortTypeBottomSheetFragment extends LandscapeExpandedRoundedBottomS
dismiss();
});
mostCommentsTypeTextView.setOnClickListener(view -> {
((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.MOST_COMMENTS));
dismiss();
});
newCommentsTypeTextView.setOnClickListener(view -> {
((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.NEW_COMMENTS));
dismiss();
});
if (activity.typeface != null) {
Utils.setFontToAllTextViews(rootView, activity.typeface);

View File

@@ -37,8 +37,6 @@ public class UserThingSortTypeBottomSheetFragment extends LandscapeExpandedRound
TextView hotTypeTextView;
@BindView(R.id.top_type_text_view_user_thing_sort_type_bottom_sheet_fragment)
TextView topTypeTextView;
@BindView(R.id.controversial_type_text_view_user_thing_sort_type_bottom_sheet_fragment)
TextView controversialTypeTextView;
private BaseActivity activity;
public UserThingSortTypeBottomSheetFragment() {
@@ -95,12 +93,6 @@ public class UserThingSortTypeBottomSheetFragment extends LandscapeExpandedRound
dismiss();
});
/* controversialTypeTextView.setOnClickListener(view -> {
if (activity != null) {
((SortTypeSelectionCallback) activity).sortTypeSelected(SortType.Type.CONTROVERSIAL.name());
}
dismiss();
});*/
if (activity.typeface != null) {
Utils.setFontToAllTextViews(rootView, activity.typeface);

View File

@@ -44,13 +44,15 @@ public class Comment implements Parcelable {
private int upvotes;
private int voteType;
private boolean isSubmitter;
private String distinguished;
private boolean isModerator;
private boolean isAdmin;
private String permalink;
private int depth;
private int childCount;
private boolean collapsed;
private boolean isDeleted;
private boolean isRemoved;
private boolean hasReply;
private boolean saved;
private boolean isExpanded;
@@ -68,8 +70,8 @@ public class Comment implements Parcelable {
public Comment(int id, int postId, BasicUserInfo author, String linkAuthor,
long commentTimeMillis, String commentMarkdown, String commentRawText,
String linkId, String communityName, String communityQualifiedName, Integer parentId, int downvotes, int upvotes,
int voteType, boolean isSubmitter, String distinguished, String permalink,
int depth, boolean collapsed, boolean hasReply, boolean saved, boolean deleted, long edited, String[] path) {
int voteType, boolean isSubmitter, boolean isModerator, boolean isAdmin, String permalink,
int depth, boolean collapsed, boolean hasReply, boolean saved, boolean deleted,boolean removed, long edited, String[] path) {
this.id = id;
this.postId = postId;
this.author = author;
@@ -85,13 +87,15 @@ public class Comment implements Parcelable {
this.upvotes = upvotes;
this.voteType = voteType;
this.isSubmitter = isSubmitter;
this.distinguished = distinguished;
this.isModerator = isModerator;
this.isAdmin = isAdmin;
this.permalink = permalink;
this.depth = depth;
this.collapsed = collapsed;
this.hasReply = hasReply;
this.saved = saved;
this.isDeleted = deleted;
this.isRemoved = removed;
this.isExpanded = false;
this.hasExpandedBefore = false;
this.editedTimeMillis = edited;
@@ -132,7 +136,8 @@ public class Comment implements Parcelable {
upvotes = in.readInt();
voteType = in.readInt();
isSubmitter = in.readByte() != 0;
distinguished = in.readString();
isModerator = in.readByte() != 0;
isAdmin = in.readByte() != 0;
permalink = in.readString();
depth = in.readInt();
childCount = in.readInt();
@@ -140,6 +145,8 @@ public class Comment implements Parcelable {
hasReply = in.readByte() != 0;
isExpanded = in.readByte() != 0;
hasExpandedBefore = in.readByte() != 0;
isDeleted = in.readByte() != 0;
isRemoved = in.readByte() != 0;
children = new ArrayList<>();
in.readTypedList(children, Comment.CREATOR);
moreChildrenIds = new ArrayList<>();
@@ -254,11 +261,11 @@ public class Comment implements Parcelable {
}
public boolean isModerator() {
return distinguished != null && distinguished.equals("moderator");
return isModerator;
}
public boolean isAdmin() {
return distinguished != null && distinguished.equals("admin");
return isAdmin;
}
public String getPermalink() {
@@ -443,7 +450,8 @@ public class Comment implements Parcelable {
parcel.writeInt(upvotes);
parcel.writeInt(voteType);
parcel.writeByte((byte) (isSubmitter ? 1 : 0));
parcel.writeString(distinguished);
parcel.writeByte((byte) (isModerator ? 1 : 0));
parcel.writeByte((byte) (isAdmin ? 1 : 0));
parcel.writeString(permalink);
parcel.writeInt(depth);
parcel.writeInt(childCount);
@@ -451,6 +459,8 @@ public class Comment implements Parcelable {
parcel.writeByte((byte) (hasReply ? 1 : 0));
parcel.writeByte((byte) (isExpanded ? 1 : 0));
parcel.writeByte((byte) (hasExpandedBefore ? 1 : 0));
parcel.writeByte((byte) (isDeleted ? 1 : 0));
parcel.writeByte((byte) (isRemoved ? 1 : 0));
parcel.writeTypedList(children);
List<String> childrenIds = new ArrayList<>();
if (moreChildrenIds != null) {
@@ -492,4 +502,12 @@ public class Comment implements Parcelable {
public BasicUserInfo getAuthor() {
return author;
}
public boolean isRemoved() {
return isRemoved;
}
public boolean isDeleted() {
return isDeleted;
}
}

View File

@@ -29,6 +29,7 @@ public class CommentDataSource extends PageKeyedDataSource<Integer, Comment> {
@Nullable
private String accessToken;
private String username;
private String query;
private SortType sortType;
private boolean areSavedComments;
@@ -39,12 +40,13 @@ public class CommentDataSource extends PageKeyedDataSource<Integer, Comment> {
private LoadParams<Integer> params;
private LoadCallback<Integer, Comment> callback;
CommentDataSource(Retrofit retrofit, Locale locale, @Nullable String accessToken, String username, SortType sortType,
boolean areSavedComments) {
CommentDataSource(Retrofit retrofit, Locale locale, @Nullable String accessToken, String username,
String query,SortType sortType, boolean areSavedComments) {
this.retrofit = retrofit;
this.locale = locale;
this.accessToken = accessToken;
this.username = username;
this.query = query;
this.sortType = sortType;
this.areSavedComments = areSavedComments;
paginationNetworkStateLiveData = new MutableLiveData<>();
@@ -69,6 +71,68 @@ public class CommentDataSource extends PageKeyedDataSource<Integer, Comment> {
}
@Override
public void loadInitial(@NonNull LoadInitialParams<Integer> params, @NonNull LoadInitialCallback<Integer, Comment> callback) {
updateNetworkState(initialLoadStateLiveData, NetworkState.LOADING);
LemmyAPI api = retrofit.create(LemmyAPI.class);
if (query != null && !query.isEmpty()) {
fetchComments(api.search(query, null, null, null,"Comments", sortType.getType().value,"All",1, 25, accessToken), callback, true);
} else {
fetchComments(api.getUserComments(username, sortType.getType().value, 1, 25, areSavedComments, accessToken), callback, true);
}
}
@Override
public void loadAfter(@NonNull LoadParams<Integer> params, @NonNull LoadCallback<Integer, Comment> callback) {
this.params = params;
updateNetworkState(paginationNetworkStateLiveData, NetworkState.LOADING);
LemmyAPI api = retrofit.create(LemmyAPI.class);
if (query != null && !query.isEmpty()) {
fetchComments(api.search(query, null, null, null,"Comments", sortType.getType().value,"All",params.key, 25, accessToken), callback, false);
} else {
fetchComments(api.getUserComments(username, sortType.getType().value, params.key, 25, areSavedComments, accessToken), callback, false);
}
}
private void fetchComments(Call<String> call, Object callback, boolean isInitialLoad) {
call.enqueue(new Callback<String>() {
@Override
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
if (response.isSuccessful()) {
new ParseCommentAsyncTask(response.body(), locale, new ParseCommentAsyncTask.ParseCommentAsyncTaskListener() {
@Override
public void parseSuccessful(ArrayList<Comment> comments, Integer page) {
if (isInitialLoad) {
((LoadInitialCallback<Integer, Comment>) callback).onResult(comments, null, comments.isEmpty() ? null : 2);
hasPostLiveData.postValue(!comments.isEmpty());
} else {
((LoadCallback<Integer, Comment>) callback).onResult(comments, page);
}
updateNetworkState(isInitialLoad ? initialLoadStateLiveData : paginationNetworkStateLiveData, NetworkState.LOADED);
}
@Override
public void parseFailed() {
updateNetworkState(isInitialLoad ? initialLoadStateLiveData : paginationNetworkStateLiveData, new NetworkState(NetworkState.Status.FAILED, "Error parsing data"));
}
}).execute();
} else {
updateNetworkState(isInitialLoad ? initialLoadStateLiveData : paginationNetworkStateLiveData, new NetworkState(NetworkState.Status.FAILED, "Error fetching data"));
}
}
@Override
public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) {
updateNetworkState(isInitialLoad ? initialLoadStateLiveData : paginationNetworkStateLiveData, new NetworkState(NetworkState.Status.FAILED, "Error fetching data"));
}
});
}
private void updateNetworkState(MutableLiveData<NetworkState> liveData, NetworkState state) {
liveData.postValue(state);
}
/*
@Override
public void loadInitial(@NonNull LoadInitialParams<Integer> params, @NonNull LoadInitialCallback<Integer, Comment> callback) {
initialLoadStateLiveData.postValue(NetworkState.LOADING);
@@ -109,12 +173,12 @@ public class CommentDataSource extends PageKeyedDataSource<Integer, Comment> {
}
});
}
*/
@Override
public void loadBefore(@NonNull LoadParams<Integer> params, @NonNull LoadCallback<Integer, Comment> callback) {
}
/*
@Override
public void loadAfter(@NonNull LoadParams<Integer> params, @NonNull LoadCallback<Integer, Comment> callback) {
this.params = params;
@@ -154,7 +218,7 @@ public class CommentDataSource extends PageKeyedDataSource<Integer, Comment> {
paginationNetworkStateLiveData.postValue(new NetworkState(NetworkState.Status.FAILED, "Error fetching data"));
}
});
}
}*/
private static class ParseCommentAsyncTask extends AsyncTask<Void, ArrayList<Comment>, ArrayList<Comment>> {
private Integer after;

View File

@@ -15,6 +15,7 @@ class CommentDataSourceFactory extends DataSource.Factory {
private Locale locale;
private String accessToken;
private String username;
private String query;
private SortType sortType;
private boolean areSavedComments;
@@ -22,12 +23,13 @@ class CommentDataSourceFactory extends DataSource.Factory {
private MutableLiveData<CommentDataSource> commentDataSourceLiveData;
CommentDataSourceFactory(Retrofit retrofit, Locale locale, @Nullable String accessToken,
String username, SortType sortType,
String username,String query, SortType sortType,
boolean areSavedComments) {
this.retrofit = retrofit;
this.locale = locale;
this.accessToken = accessToken;
this.username = username;
this.query = query;
this.sortType = sortType;
this.areSavedComments = areSavedComments;
commentDataSourceLiveData = new MutableLiveData<>();
@@ -36,8 +38,8 @@ class CommentDataSourceFactory extends DataSource.Factory {
@NonNull
@Override
public DataSource create() {
commentDataSource = new CommentDataSource(retrofit, locale, accessToken, username, sortType,
areSavedComments);
commentDataSource = new CommentDataSource(retrofit, locale, accessToken, username, query,
sortType, areSavedComments);
commentDataSourceLiveData.postValue(commentDataSource);
return commentDataSource;
}

View File

@@ -23,9 +23,9 @@ public class CommentViewModel extends ViewModel {
private LiveData<PagedList<Comment>> comments;
private MutableLiveData<SortType> sortTypeLiveData;
public CommentViewModel(Retrofit retrofit, Locale locale, String accessToken, String username, SortType sortType,
public CommentViewModel(Retrofit retrofit, Locale locale, String accessToken, String username, String query, SortType sortType,
boolean areSavedComments) {
commentDataSourceFactory = new CommentDataSourceFactory(retrofit, locale, accessToken, username, sortType,
commentDataSourceFactory = new CommentDataSourceFactory(retrofit, locale, accessToken, username,query, sortType,
areSavedComments);
initialLoadingState = Transformations.switchMap(commentDataSourceFactory.getCommentDataSourceLiveData(),
@@ -84,15 +84,17 @@ public class CommentViewModel extends ViewModel {
private Locale locale;
private String accessToken;
private String username;
private String query;
private SortType sortType;
private boolean areSavedComments;
public Factory(Retrofit retrofit, Locale locale, String accessToken, String username,
SortType sortType, boolean areSavedComments) {
String query, SortType sortType, boolean areSavedComments) {
this.retrofit = retrofit;
this.locale = locale;
this.accessToken = accessToken;
this.username = username;
this.query = query;
this.sortType = sortType;
this.areSavedComments = areSavedComments;
}
@@ -100,7 +102,7 @@ public class CommentViewModel extends ViewModel {
@NonNull
@Override
public <T extends ViewModel> T create(@NonNull Class<T> modelClass) {
return (T) new CommentViewModel(retrofit, locale, accessToken, username, sortType, areSavedComments);
return (T) new CommentViewModel(retrofit, locale, accessToken, username,query, sortType, areSavedComments);
}
}
}

View File

@@ -292,6 +292,9 @@ public class ParseComment {
JSONObject postObj = jsonObject.getJSONObject("post");
JSONObject communityObj = jsonObject.getJSONObject("community");
JSONObject countsObj = jsonObject.getJSONObject("counts");
boolean isModerator = jsonObject.optBoolean("creator_is_moderator");
boolean isAdmin = jsonObject.optBoolean("creator_is_admin");
int id = commentObj.getInt("id");
int postID = postObj.getInt("id");
@@ -342,7 +345,7 @@ public class ParseComment {
}
}
boolean isSubmitter = creatorObj.getInt("id") == postObj.getInt("creator_id");
String distinguished = commentObj.getString("distinguished");
String permalink = commentObj.getString("ap_id");
String[] path = commentObj.getString("path").split(Pattern.quote("."));
@@ -354,11 +357,12 @@ public class ParseComment {
boolean hasReply = countsObj.getInt("child_count") > 0;
boolean saved = jsonObject.getBoolean("saved");
boolean deleted = commentObj.getBoolean("deleted");
boolean removed = commentObj.getBoolean("removed");
long edited = 0;
BasicUserInfo authorInfo = new BasicUserInfo(creatorObj.getInt("id"), author, authorQualifiedName, creatorObj.optString("avatar", ""), creatorObj.optString("display_name", author));
Comment comment = new Comment(id, postID, authorInfo, linkAuthor, commentTimeMillis,
commentMarkdown, commentRawText, linkId, communityName, communityQualifiedName, parentId,
downvotes, upvotes, voteType, isSubmitter, distinguished, permalink, depth, collapsed, hasReply, saved, deleted, edited, path);
downvotes, upvotes, voteType, isSubmitter, isModerator, isAdmin, permalink, depth, collapsed, hasReply, saved, deleted, removed, edited, path);
int child_count = countsObj.getInt("child_count");
comment.setChildCount(child_count);
comment.setAuthorIconUrl(authorAvatar);

View File

@@ -263,69 +263,64 @@ public class CustomTheme {
customTheme.readPostFilledCardViewBackgroundColor = customThemeSettingsItems.get(23).colorValue;
customTheme.commentBackgroundColor = customThemeSettingsItems.get(24).colorValue;
customTheme.fullyCollapsedCommentBackgroundColor = customThemeSettingsItems.get(25).colorValue;
customTheme.awardedCommentBackgroundColor = customThemeSettingsItems.get(26).colorValue;
customTheme.receivedMessageBackgroundColor = customThemeSettingsItems.get(27).colorValue;
customTheme.sentMessageBackgroundColor = customThemeSettingsItems.get(28).colorValue;
customTheme.bottomAppBarBackgroundColor = customThemeSettingsItems.get(29).colorValue;
customTheme.primaryIconColor = customThemeSettingsItems.get(30).colorValue;
customTheme.bottomAppBarIconColor = customThemeSettingsItems.get(31).colorValue;
customTheme.postIconAndInfoColor = customThemeSettingsItems.get(32).colorValue;
customTheme.commentIconAndInfoColor = customThemeSettingsItems.get(33).colorValue;
customTheme.fabIconColor = customThemeSettingsItems.get(34).colorValue;
customTheme.sendMessageIconColor = customThemeSettingsItems.get(35).colorValue;
customTheme.toolbarPrimaryTextAndIconColor = customThemeSettingsItems.get(36).colorValue;
customTheme.toolbarSecondaryTextColor = customThemeSettingsItems.get(37).colorValue;
customTheme.circularProgressBarBackground = customThemeSettingsItems.get(38).colorValue;
customTheme.mediaIndicatorIconColor = customThemeSettingsItems.get(39).colorValue;
customTheme.mediaIndicatorBackgroundColor = customThemeSettingsItems.get(40).colorValue;
customTheme.tabLayoutWithExpandedCollapsingToolbarTabBackground = customThemeSettingsItems.get(41).colorValue;
customTheme.tabLayoutWithExpandedCollapsingToolbarTextColor = customThemeSettingsItems.get(42).colorValue;
customTheme.tabLayoutWithExpandedCollapsingToolbarTabIndicator = customThemeSettingsItems.get(43).colorValue;
customTheme.tabLayoutWithCollapsedCollapsingToolbarTabBackground = customThemeSettingsItems.get(44).colorValue;
customTheme.tabLayoutWithCollapsedCollapsingToolbarTextColor = customThemeSettingsItems.get(45).colorValue;
customTheme.tabLayoutWithCollapsedCollapsingToolbarTabIndicator = customThemeSettingsItems.get(46).colorValue;
customTheme.upvoted = customThemeSettingsItems.get(47).colorValue;
customTheme.downvoted = customThemeSettingsItems.get(48).colorValue;
customTheme.postTypeBackgroundColor = customThemeSettingsItems.get(49).colorValue;
customTheme.postTypeTextColor = customThemeSettingsItems.get(50).colorValue;
customTheme.spoilerBackgroundColor = customThemeSettingsItems.get(51).colorValue;
customTheme.spoilerTextColor = customThemeSettingsItems.get(52).colorValue;
customTheme.nsfwBackgroundColor = customThemeSettingsItems.get(53).colorValue;
customTheme.nsfwTextColor = customThemeSettingsItems.get(54).colorValue;
customTheme.flairBackgroundColor = customThemeSettingsItems.get(55).colorValue;
customTheme.flairTextColor = customThemeSettingsItems.get(56).colorValue;
customTheme.awardsBackgroundColor = customThemeSettingsItems.get(57).colorValue;
customTheme.awardsTextColor = customThemeSettingsItems.get(58).colorValue;
customTheme.archivedTint = customThemeSettingsItems.get(59).colorValue;
customTheme.lockedIconTint = customThemeSettingsItems.get(60).colorValue;
customTheme.crosspostIconTint = customThemeSettingsItems.get(61).colorValue;
customTheme.upvoteRatioIconTint = customThemeSettingsItems.get(62).colorValue;
customTheme.stickiedPostIconTint = customThemeSettingsItems.get(63).colorValue;
customTheme.noPreviewPostTypeIconTint = customThemeSettingsItems.get(64).colorValue;
customTheme.subscribed = customThemeSettingsItems.get(65).colorValue;
customTheme.unsubscribed = customThemeSettingsItems.get(66).colorValue;
customTheme.username = customThemeSettingsItems.get(67).colorValue;
customTheme.subreddit = customThemeSettingsItems.get(68).colorValue;
customTheme.authorFlairTextColor = customThemeSettingsItems.get(69).colorValue;
customTheme.submitter = customThemeSettingsItems.get(70).colorValue;
customTheme.moderator = customThemeSettingsItems.get(71).colorValue;
customTheme.currentUser = customThemeSettingsItems.get(72).colorValue;
customTheme.singleCommentThreadBackgroundColor = customThemeSettingsItems.get(73).colorValue;
customTheme.unreadMessageBackgroundColor = customThemeSettingsItems.get(74).colorValue;
customTheme.dividerColor = customThemeSettingsItems.get(75).colorValue;
customTheme.noPreviewPostTypeBackgroundColor = customThemeSettingsItems.get(76).colorValue;
customTheme.voteAndReplyUnavailableButtonColor = customThemeSettingsItems.get(77).colorValue;
customTheme.commentVerticalBarColor1 = customThemeSettingsItems.get(78).colorValue;
customTheme.commentVerticalBarColor2 = customThemeSettingsItems.get(79).colorValue;
customTheme.commentVerticalBarColor3 = customThemeSettingsItems.get(80).colorValue;
customTheme.commentVerticalBarColor4 = customThemeSettingsItems.get(81).colorValue;
customTheme.commentVerticalBarColor5 = customThemeSettingsItems.get(82).colorValue;
customTheme.commentVerticalBarColor6 = customThemeSettingsItems.get(83).colorValue;
customTheme.commentVerticalBarColor7 = customThemeSettingsItems.get(84).colorValue;
customTheme.navBarColor = customThemeSettingsItems.get(85).colorValue;
customTheme.isLightStatusBar = customThemeSettingsItems.get(86).isEnabled;
customTheme.isLightNavBar = customThemeSettingsItems.get(87).isEnabled;
customTheme.isChangeStatusBarIconColorAfterToolbarCollapsedInImmersiveInterface = customThemeSettingsItems.get(88).isEnabled;
customTheme.receivedMessageBackgroundColor = customThemeSettingsItems.get(26).colorValue;
customTheme.sentMessageBackgroundColor = customThemeSettingsItems.get(27).colorValue;
customTheme.bottomAppBarBackgroundColor = customThemeSettingsItems.get(28).colorValue;
customTheme.primaryIconColor = customThemeSettingsItems.get(29).colorValue;
customTheme.bottomAppBarIconColor = customThemeSettingsItems.get(30).colorValue;
customTheme.postIconAndInfoColor = customThemeSettingsItems.get(31).colorValue;
customTheme.commentIconAndInfoColor = customThemeSettingsItems.get(32).colorValue;
customTheme.fabIconColor = customThemeSettingsItems.get(33).colorValue;
customTheme.sendMessageIconColor = customThemeSettingsItems.get(34).colorValue;
customTheme.toolbarPrimaryTextAndIconColor = customThemeSettingsItems.get(35).colorValue;
customTheme.toolbarSecondaryTextColor = customThemeSettingsItems.get(36).colorValue;
customTheme.circularProgressBarBackground = customThemeSettingsItems.get(37).colorValue;
customTheme.mediaIndicatorIconColor = customThemeSettingsItems.get(38).colorValue;
customTheme.mediaIndicatorBackgroundColor = customThemeSettingsItems.get(39).colorValue;
customTheme.tabLayoutWithExpandedCollapsingToolbarTabBackground = customThemeSettingsItems.get(40).colorValue;
customTheme.tabLayoutWithExpandedCollapsingToolbarTextColor = customThemeSettingsItems.get(41).colorValue;
customTheme.tabLayoutWithExpandedCollapsingToolbarTabIndicator = customThemeSettingsItems.get(42).colorValue;
customTheme.tabLayoutWithCollapsedCollapsingToolbarTabBackground = customThemeSettingsItems.get(43).colorValue;
customTheme.tabLayoutWithCollapsedCollapsingToolbarTextColor = customThemeSettingsItems.get(44).colorValue;
customTheme.tabLayoutWithCollapsedCollapsingToolbarTabIndicator = customThemeSettingsItems.get(45).colorValue;
customTheme.upvoted = customThemeSettingsItems.get(46).colorValue;
customTheme.downvoted = customThemeSettingsItems.get(47).colorValue;
customTheme.postTypeBackgroundColor = customThemeSettingsItems.get(48).colorValue;
customTheme.postTypeTextColor = customThemeSettingsItems.get(49).colorValue;
customTheme.spoilerBackgroundColor = customThemeSettingsItems.get(50).colorValue;
customTheme.spoilerTextColor = customThemeSettingsItems.get(51).colorValue;
customTheme.nsfwBackgroundColor = customThemeSettingsItems.get(52).colorValue;
customTheme.nsfwTextColor = customThemeSettingsItems.get(53).colorValue;
customTheme.archivedTint = customThemeSettingsItems.get(54).colorValue;
customTheme.lockedIconTint = customThemeSettingsItems.get(55).colorValue;
customTheme.crosspostIconTint = customThemeSettingsItems.get(56).colorValue;
customTheme.upvoteRatioIconTint = customThemeSettingsItems.get(57).colorValue;
customTheme.stickiedPostIconTint = customThemeSettingsItems.get(58).colorValue;
customTheme.noPreviewPostTypeIconTint = customThemeSettingsItems.get(59).colorValue;
customTheme.subscribed = customThemeSettingsItems.get(60).colorValue;
customTheme.unsubscribed = customThemeSettingsItems.get(61).colorValue;
customTheme.username = customThemeSettingsItems.get(62).colorValue;
customTheme.subreddit = customThemeSettingsItems.get(63).colorValue;
customTheme.submitter = customThemeSettingsItems.get(64).colorValue;
customTheme.moderator = customThemeSettingsItems.get(65).colorValue;
customTheme.currentUser = customThemeSettingsItems.get(66).colorValue;
customTheme.singleCommentThreadBackgroundColor = customThemeSettingsItems.get(67).colorValue;
customTheme.unreadMessageBackgroundColor = customThemeSettingsItems.get(68).colorValue;
customTheme.dividerColor = customThemeSettingsItems.get(69).colorValue;
customTheme.noPreviewPostTypeBackgroundColor = customThemeSettingsItems.get(70).colorValue;
customTheme.voteAndReplyUnavailableButtonColor = customThemeSettingsItems.get(71).colorValue;
customTheme.commentVerticalBarColor1 = customThemeSettingsItems.get(72).colorValue;
customTheme.commentVerticalBarColor2 = customThemeSettingsItems.get(73).colorValue;
customTheme.commentVerticalBarColor3 = customThemeSettingsItems.get(74).colorValue;
customTheme.commentVerticalBarColor4 = customThemeSettingsItems.get(75).colorValue;
customTheme.commentVerticalBarColor5 = customThemeSettingsItems.get(76).colorValue;
customTheme.commentVerticalBarColor6 = customThemeSettingsItems.get(77).colorValue;
customTheme.commentVerticalBarColor7 = customThemeSettingsItems.get(78).colorValue;
customTheme.navBarColor = customThemeSettingsItems.get(79).colorValue;
customTheme.isLightStatusBar = customThemeSettingsItems.get(80).isEnabled;
customTheme.isLightNavBar = customThemeSettingsItems.get(81).isEnabled;
customTheme.isChangeStatusBarIconColorAfterToolbarCollapsedInImmersiveInterface = customThemeSettingsItems.get(82).isEnabled;
return customTheme;
}

View File

@@ -160,10 +160,6 @@ public class CustomThemeSettingsItem implements Parcelable {
context.getString(R.string.theme_item_fully_collapsed_comment_background_color),
context.getString(R.string.theme_item_fully_collapsed_comment_background_color_detail),
customTheme.fullyCollapsedCommentBackgroundColor));
customThemeSettingsItems.add(new CustomThemeSettingsItem(
context.getString(R.string.theme_item_awarded_comment_background_color),
context.getString(R.string.theme_item_awarded_comment_background_color_detail),
customTheme.awardedCommentBackgroundColor));
customThemeSettingsItems.add(new CustomThemeSettingsItem(
context.getString(R.string.theme_item_received_message_background_color),
context.getString(R.string.theme_item_received_message_background_color_detail),
@@ -276,24 +272,6 @@ public class CustomThemeSettingsItem implements Parcelable {
context.getString(R.string.theme_item_nsfw_text_color),
context.getString(R.string.theme_item_nsfw_text_color_detail),
customTheme.nsfwTextColor));
customThemeSettingsItems.add(new CustomThemeSettingsItem(
context.getString(R.string.theme_item_flair_background_color),
context.getString(R.string.theme_item_flair_background_color_detail),
customTheme.flairBackgroundColor));
customThemeSettingsItems.add(new CustomThemeSettingsItem(
context.getString(R.string.theme_item_flair_text_color),
context.getString(R.string.theme_item_flair_text_color_detail),
customTheme.flairTextColor));
customThemeSettingsItems.add(new CustomThemeSettingsItem(
context.getString(R.string.theme_item_awards_background_color),
context.getString(R.string.theme_item_awards_background_color_detail),
customTheme.awardsBackgroundColor
));
customThemeSettingsItems.add(new CustomThemeSettingsItem(
context.getString(R.string.theme_item_awards_text_color),
context.getString(R.string.theme_item_awards_text_color_detail),
customTheme.awardsTextColor
));
customThemeSettingsItems.add(new CustomThemeSettingsItem(
context.getString(R.string.theme_item_archived_tint),
context.getString(R.string.theme_item_archived_tint_detail),
@@ -336,10 +314,6 @@ public class CustomThemeSettingsItem implements Parcelable {
context.getString(R.string.theme_item_community_color),
context.getString(R.string.theme_item_community_color_detail),
customTheme.subreddit));
customThemeSettingsItems.add(new CustomThemeSettingsItem(
context.getString(R.string.theme_item_author_flair_text_color),
context.getString(R.string.theme_item_author_flair_text_color_detail),
customTheme.authorFlairTextColor));
customThemeSettingsItems.add(new CustomThemeSettingsItem(
context.getString(R.string.theme_item_submitter_color),
context.getString(R.string.theme_item_submitter_color_detail),

View File

@@ -348,7 +348,7 @@ public class CustomThemeWrapper {
}
public int getAdmin() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.MODERATOR,
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.ADMIN,
getDefaultColor("#a5222f", "#c94f6d", "#EE5396"));
}
@@ -831,7 +831,7 @@ public class CustomThemeWrapper {
customTheme.colorPrimary = Color.parseColor("#FFFFFF");
customTheme.colorPrimaryDark = Color.parseColor("#FFFFFF");
customTheme.colorAccent = Color.parseColor("#000000");
customTheme.colorPrimaryLightTheme = Color.parseColor("#FFFFFF");
customTheme.colorPrimaryLightTheme = Color.parseColor("#000000");
customTheme.primaryTextColor = Color.parseColor("#000000");
customTheme.secondaryTextColor = Color.parseColor("#8A000000");
customTheme.postTitleColor = Color.parseColor("#000000");
@@ -839,7 +839,7 @@ public class CustomThemeWrapper {
customTheme.readPostTitleColor = Color.parseColor("#9D9D9D");
customTheme.readPostContentColor = Color.parseColor("#9D9D9D");
customTheme.commentColor = Color.parseColor("#000000");
customTheme.buttonTextColor = Color.parseColor("#000000");
customTheme.buttonTextColor = Color.parseColor("#FFFFFF");
customTheme.backgroundColor = Color.parseColor("#FFFFFF");
customTheme.cardViewBackgroundColor = Color.parseColor("#FFFFFF");
customTheme.readPostCardViewBackgroundColor = Color.parseColor("#F5F5F5");

View File

@@ -3,11 +3,13 @@ package eu.toldi.infinityforlemmy.dto;
public class ReadPostDTO {
private int post_id;
private int[] post_ids;
private boolean read;
private String auth;
public ReadPostDTO(int post_id, boolean read, String auth) {
this.post_id = post_id;
this.post_ids = new int[]{post_id};
this.read = read;
this.auth = auth;
}

View File

@@ -137,7 +137,7 @@ public class BlockedCommunitiesListingFragment extends Fragment implements Fragm
if (subscribedSubredditData == null || subscribedSubredditData.size() == 0) {
mRecyclerView.setVisibility(View.GONE);
mLinearLayout.setVisibility(View.VISIBLE);
mGlide.load(R.drawable.error_image).into(mImageView);
mGlide.load(R.mipmap.ic_launcher_round).into(mImageView);
} else {
mLinearLayout.setVisibility(View.GONE);
mRecyclerView.setVisibility(View.VISIBLE);

View File

@@ -0,0 +1,173 @@
package eu.toldi.infinityforlemmy.fragments;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.os.Build;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import com.bumptech.glide.Glide;
import com.bumptech.glide.RequestManager;
import java.util.concurrent.Executor;
import javax.inject.Inject;
import javax.inject.Named;
import butterknife.BindView;
import butterknife.ButterKnife;
import eu.toldi.infinityforlemmy.FragmentCommunicator;
import eu.toldi.infinityforlemmy.Infinity;
import eu.toldi.infinityforlemmy.R;
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
import eu.toldi.infinityforlemmy.activities.BaseActivity;
import eu.toldi.infinityforlemmy.activities.BlockedThingListingActivity;
import eu.toldi.infinityforlemmy.adapters.BlockedInstancesRecyclerViewAdapter;
import eu.toldi.infinityforlemmy.blockedinstances.BlockedInstanceViewModel;
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
import eu.toldi.infinityforlemmy.customviews.LinearLayoutManagerBugFixed;
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
import me.zhanghai.android.fastscroll.FastScrollerBuilder;
import retrofit2.Retrofit;
public class BlockedInstancesListingFragment extends Fragment implements FragmentCommunicator {
public static final String EXTRA_ACCOUNT_NAME = "EAN";
public static final String EXTRA_ACCESS_TOKEN = "EAT";
@BindView(R.id.swipe_refresh_layout_followed_users_listing_fragment)
SwipeRefreshLayout mSwipeRefreshLayout;
@BindView(R.id.recycler_view_followed_users_listing_fragment)
RecyclerView mRecyclerView;
@BindView(R.id.no_subscriptions_linear_layout_followed_users_listing_fragment)
LinearLayout mLinearLayout;
@BindView(R.id.no_subscriptions_image_view_followed_users_listing_fragment)
ImageView mImageView;
@BindView(R.id.error_text_view_followed_users_listing_fragment)
TextView mErrorTextView;
@Inject
@Named("oauth")
Retrofit mOauthRetrofit;
@Inject
@Named("default")
SharedPreferences mSharedPreferences;
@Inject
RedditDataRoomDatabase mRedditDataRoomDatabase;
@Inject
CustomThemeWrapper mCustomThemeWrapper;
@Inject
Executor mExecutor;
BlockedInstanceViewModel blockedInstanceViewModel;
private BaseActivity mActivity;
private RequestManager mGlide;
private LinearLayoutManagerBugFixed mLinearLayoutManager;
public BlockedInstancesListingFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_followed_users_listing, container, false);
ButterKnife.bind(this, rootView);
((Infinity) mActivity.getApplication()).getAppComponent().inject(this);
applyTheme();
Resources resources = getResources();
if ((mActivity instanceof BaseActivity && ((BaseActivity) mActivity).isImmersiveInterface())) {
mRecyclerView.setPadding(0, 0, 0, ((BaseActivity) mActivity).getNavBarHeight());
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
&& mSharedPreferences.getBoolean(SharedPreferencesUtils.IMMERSIVE_INTERFACE_KEY, true)) {
int navBarResourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
if (navBarResourceId > 0) {
mRecyclerView.setPadding(0, 0, 0, resources.getDimensionPixelSize(navBarResourceId));
}
}
mGlide = Glide.with(this);
String accessToken = getArguments().getString(EXTRA_ACCESS_TOKEN);
if (accessToken == null) {
mSwipeRefreshLayout.setEnabled(false);
}
mLinearLayoutManager = new LinearLayoutManagerBugFixed(mActivity);
mRecyclerView.setLayoutManager(mLinearLayoutManager);
BlockedInstancesRecyclerViewAdapter adapter = new BlockedInstancesRecyclerViewAdapter(mActivity,
mExecutor, mOauthRetrofit, mRedditDataRoomDatabase, mCustomThemeWrapper, accessToken);
mRecyclerView.setAdapter(adapter);
new FastScrollerBuilder(mRecyclerView).useMd2Style().build();
blockedInstanceViewModel = new ViewModelProvider(this,
new BlockedInstanceViewModel.Factory(mActivity.getApplication(), mRedditDataRoomDatabase, getArguments().getString(EXTRA_ACCOUNT_NAME)))
.get(BlockedInstanceViewModel.class);
blockedInstanceViewModel.getAllSubscribedInstances().observe(getViewLifecycleOwner(), blockedInstanceData -> {
mSwipeRefreshLayout.setRefreshing(false);
if (blockedInstanceData == null || blockedInstanceData.size() == 0) {
mRecyclerView.setVisibility(View.GONE);
mLinearLayout.setVisibility(View.VISIBLE);
mGlide.load(R.mipmap.ic_launcher_round).into(mImageView);
mErrorTextView.setText(R.string.no_blocked_instances);
} else {
mLinearLayout.setVisibility(View.GONE);
mRecyclerView.setVisibility(View.VISIBLE);
mGlide.clear(mImageView);
}
adapter.blockedInstances(blockedInstanceData);
});
return rootView;
}
@Override
public void onAttach(@NonNull Context context) {
super.onAttach(context);
mActivity = (BaseActivity) context;
}
@Override
public void stopRefreshProgressbar() {
mSwipeRefreshLayout.setRefreshing(false);
}
@Override
public void applyTheme() {
if (mActivity instanceof BlockedThingListingActivity) {
mSwipeRefreshLayout.setOnRefreshListener(() -> ((BlockedThingListingActivity) mActivity).loadBlocks(true));
mSwipeRefreshLayout.setProgressBackgroundColorSchemeColor(mCustomThemeWrapper.getCircularProgressBarBackground());
mSwipeRefreshLayout.setColorSchemeColors(mCustomThemeWrapper.getColorAccent());
} else {
mSwipeRefreshLayout.setEnabled(false);
}
mErrorTextView.setTextColor(mCustomThemeWrapper.getSecondaryTextColor());
if (mActivity.typeface != null) {
mErrorTextView.setTypeface(mActivity.typeface);
}
}
public void goBackToTop() {
if (mLinearLayoutManager != null) {
mLinearLayoutManager.scrollToPositionWithOffset(0, 0);
}
}
public void changeSearchQuery(String searchQuery) {
blockedInstanceViewModel.setSearchQuery(searchQuery);
}
}

View File

@@ -122,7 +122,7 @@ public class BlockedUsersListingFragment extends Fragment implements FragmentCom
if (subscribedUserData == null || subscribedUserData.size() == 0) {
mRecyclerView.setVisibility(View.GONE);
mLinearLayout.setVisibility(View.VISIBLE);
mGlide.load(R.drawable.error_image).into(mImageView);
mGlide.load(R.mipmap.ic_launcher_round).into(mImageView);
} else {
mLinearLayout.setVisibility(View.GONE);
mRecyclerView.setVisibility(View.VISIBLE);

View File

@@ -60,6 +60,7 @@ import eu.toldi.infinityforlemmy.utils.Utils;
public class CommentsListingFragment extends Fragment implements FragmentCommunicator {
public static final String EXTRA_USERNAME = "EN";
public static final String EXTRA_SEARCH_QUERY = "ESQ";
public static final String EXTRA_ACCESS_TOKEN = "EAT";
public static final String EXTRA_ACCOUNT_NAME = "EAN";
public static final String EXTRA_ARE_SAVED_COMMENTS = "EISC";
@@ -266,6 +267,8 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni
() -> mCommentViewModel.retryLoadingMore());
String username = getArguments().getString(EXTRA_USERNAME);
String query = getArguments().getString(EXTRA_SEARCH_QUERY);
String sort = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_USER_COMMENT, SortType.Type.NEW.name());
if (sort.equals(SortType.Type.TOP.name())) {
String sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_USER_COMMENT, SortType.Time.ALL.name());
@@ -293,7 +296,7 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni
factory = new CommentViewModel.Factory(mRetrofit.getRetrofit(),
resources.getConfiguration().locale, mAccessToken, username, sortType,
resources.getConfiguration().locale, mAccessToken, username, query,sortType,
getArguments().getBoolean(EXTRA_ARE_SAVED_COMMENTS));
@@ -379,7 +382,7 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni
mSwipeRefreshLayout.setRefreshing(false);
mFetchCommentInfoLinearLayout.setVisibility(View.VISIBLE);
mFetchCommentInfoTextView.setText(stringResId);
mGlide.load(R.drawable.error_image).into(mFetchCommentInfoImageView);
mGlide.load(R.mipmap.ic_launcher_round).into(mFetchCommentInfoImageView);
}
}

View File

@@ -29,7 +29,6 @@ import javax.inject.Named;
import butterknife.BindView;
import butterknife.ButterKnife;
import me.zhanghai.android.fastscroll.FastScrollerBuilder;
import eu.toldi.infinityforlemmy.FragmentCommunicator;
import eu.toldi.infinityforlemmy.Infinity;
import eu.toldi.infinityforlemmy.R;
@@ -41,6 +40,7 @@ import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
import eu.toldi.infinityforlemmy.customviews.LinearLayoutManagerBugFixed;
import eu.toldi.infinityforlemmy.subscribeduser.SubscribedUserViewModel;
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
import me.zhanghai.android.fastscroll.FastScrollerBuilder;
import retrofit2.Retrofit;
@@ -128,7 +128,7 @@ public class FollowedUsersListingFragment extends Fragment implements FragmentCo
if (subscribedUserData == null || subscribedUserData.size() == 0) {
mRecyclerView.setVisibility(View.GONE);
mLinearLayout.setVisibility(View.VISIBLE);
mGlide.load(R.drawable.error_image).into(mImageView);
mGlide.load(R.mipmap.ic_launcher_round).into(mImageView);
} else {
mLinearLayout.setVisibility(View.GONE);
mRecyclerView.setVisibility(View.VISIBLE);

View File

@@ -171,7 +171,7 @@ public class InboxFragment extends Fragment implements FragmentCommunicator {
mSwipeRefreshLayout.setRefreshing(false);
mFetchMessageInfoLinearLayout.setVisibility(View.VISIBLE);
mFetchMessageInfoTextView.setText(stringResId);
mGlide.load(R.drawable.error_image).into(mFetchMessageInfoImageView);
mGlide.load(R.mipmap.ic_launcher_round).into(mFetchMessageInfoImageView);
}
@Override

View File

@@ -29,7 +29,6 @@ import javax.inject.Named;
import butterknife.BindView;
import butterknife.ButterKnife;
import me.zhanghai.android.fastscroll.FastScrollerBuilder;
import eu.toldi.infinityforlemmy.FragmentCommunicator;
import eu.toldi.infinityforlemmy.Infinity;
import eu.toldi.infinityforlemmy.R;
@@ -45,6 +44,7 @@ import eu.toldi.infinityforlemmy.customviews.LinearLayoutManagerBugFixed;
import eu.toldi.infinityforlemmy.multireddit.MultiReddit;
import eu.toldi.infinityforlemmy.multireddit.MultiRedditViewModel;
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
import me.zhanghai.android.fastscroll.FastScrollerBuilder;
import retrofit2.Retrofit;
public class MultiRedditListingFragment extends Fragment implements FragmentCommunicator {
@@ -111,9 +111,9 @@ public class MultiRedditListingFragment extends Fragment implements FragmentComm
String accessToken = getArguments().getString(EXTRA_ACCESS_TOKEN);
boolean isGettingMultiredditInfo = getArguments().getBoolean(EXTRA_IS_GETTING_MULTIREDDIT_INFO, false);
if (accessToken == null) {
mSwipeRefreshLayout.setEnabled(false);
}
mSwipeRefreshLayout.setEnabled(false);
mGlide = Glide.with(this);
@@ -122,7 +122,7 @@ public class MultiRedditListingFragment extends Fragment implements FragmentComm
MultiRedditListingRecyclerViewAdapter adapter = new MultiRedditListingRecyclerViewAdapter(mActivity,
mExecutor, mOauthRetrofit, mRedditDataRoomDatabase, mCustomThemeWrapper, accessToken,
new MultiRedditListingRecyclerViewAdapter.OnItemClickListener() {
@Override
@Override
public void onClick(MultiReddit multiReddit) {
if (mActivity instanceof MultiredditSelectionActivity) {
((MultiredditSelectionActivity) mActivity).getSelectedMultireddit(multiReddit);
@@ -164,7 +164,7 @@ public class MultiRedditListingFragment extends Fragment implements FragmentComm
if (subscribedUserData == null || subscribedUserData.size() == 0) {
mRecyclerView.setVisibility(View.GONE);
mErrorLinearLayout.setVisibility(View.VISIBLE);
mGlide.load(R.drawable.error_image).into(mErrorImageView);
mGlide.load(R.mipmap.ic_launcher_round).into(mErrorImageView);
} else {
mErrorLinearLayout.setVisibility(View.GONE);
mRecyclerView.setVisibility(View.VISIBLE);

View File

@@ -187,9 +187,6 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
@Named("oauth")
Retrofit mOauthRetrofit;
@Inject
@Named("gfycat")
Retrofit mGfycatRetrofit;
@Inject
@Named("redgifs")
Retrofit mRedgifsRetrofit;
@Inject
@@ -438,7 +435,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
postType = getArguments().getInt(EXTRA_POST_TYPE);
mSwipeRefreshLayout.setEnabled(mSharedPreferences.getBoolean(SharedPreferencesUtils.PULL_TO_REFRESH, true) && postType != PostPagingSource.TYPE_ANONYMOUS_FRONT_PAGE);
mSwipeRefreshLayout.setEnabled(mSharedPreferences.getBoolean(SharedPreferencesUtils.PULL_TO_REFRESH, true));
mSwipeRefreshLayout.setOnRefreshListener(this::refresh);
accessToken = getArguments().getString(EXTRA_ACCESS_TOKEN);
@@ -468,7 +465,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
sortType = new SortType(st == null ? SortType.Type.TOP_ALL : st,sortTime != null ? SortType.Time.valueOf(sortTime) : null);
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_SEARCH_POST, defaultPostLayout);
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mRetrofit, mGfycatRetrofit,
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mRetrofit,
mRedgifsRetrofit, mStreamableApiProvider, mCustomThemeWrapper, locale,
accessToken, accountName, postType, postLayout, true,
mSharedPreferences, mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
@@ -543,7 +540,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_SUBREDDIT_POST_BASE + subredditName, defaultPostLayout);
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mRetrofit, mGfycatRetrofit,
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mRetrofit,
mRedgifsRetrofit, mStreamableApiProvider, mCustomThemeWrapper, locale,
accessToken, accountName, postType, postLayout, displaySubredditName,
mSharedPreferences, mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
@@ -600,7 +597,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
String sortTime = null;
sort = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_MULTI_REDDIT_POST_BASE + multiRedditPath,
SortType.Type.HOT.name());
SortType.Type.NEW.name());
if (sort.equals(SortType.Type.TOP.name())) {
sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_MULTI_REDDIT_POST_BASE + multiRedditPath,
SortType.Time.ALL.name());
@@ -612,7 +609,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
defaultPostLayout);
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mRetrofit, mGfycatRetrofit,
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mRetrofit,
mRedgifsRetrofit, mStreamableApiProvider, mCustomThemeWrapper, locale,
accessToken, accountName, postType, postLayout, true,
mSharedPreferences, mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
@@ -678,7 +675,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_USER_POST_BASE + username, defaultPostLayout);
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mRetrofit, mGfycatRetrofit,
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mRetrofit,
mRedgifsRetrofit, mStreamableApiProvider, mCustomThemeWrapper, locale,
accessToken, accountName, postType, postLayout, true,
mSharedPreferences, mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
@@ -731,7 +728,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
nameOfUsage = PostFilterUsage.NO_USAGE;
subredditName = getArguments().getString(EXTRA_NAME);
String sort = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_SUBREDDIT_POST_BASE + "-", SortType.Type.HOT.name());
String sort = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_SUBREDDIT_POST_BASE + "-", SortType.Type.NEW.name());
String sortTime = null;
if (sort.equals(SortType.Type.TOP.name())) {
sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_SUBREDDIT_POST_BASE + "-", SortType.Time.ALL.name());
@@ -740,7 +737,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_FRONT_PAGE_POST, defaultPostLayout);
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mRetrofit, mGfycatRetrofit,
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mRetrofit,
mRedgifsRetrofit, mStreamableApiProvider, mCustomThemeWrapper, locale,
accessToken, accountName, postType, postLayout, true,
mSharedPreferences, mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
@@ -799,7 +796,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_MULTI_REDDIT_POST_BASE + multiRedditPath, defaultPostLayout);
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mRetrofit, mGfycatRetrofit,
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mRetrofit,
mRedgifsRetrofit, mStreamableApiProvider, mCustomThemeWrapper, locale,
accessToken, accountName, postType, postLayout, true,
mSharedPreferences, mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
@@ -855,7 +852,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
sortType = newSortType(sort, sortTime);
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_FRONT_PAGE_POST, defaultPostLayout);
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mRetrofit, mGfycatRetrofit,
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mRetrofit,
mRedgifsRetrofit, mStreamableApiProvider, mCustomThemeWrapper, locale,
accessToken, accountName, postType, postLayout, true,
mSharedPreferences, mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
@@ -970,7 +967,8 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
this.postFilter = postFilter;
postFilter.allowNSFW = !mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_NSFW_FOREVER, false) && mNsfwAndSpoilerSharedPreferences.getBoolean(SharedPreferencesUtils.NSFW_BASE, false);
this.concatenatedSubredditNames = concatenatedSubredditNames;
showErrorView(R.string.anonymous_homepage_not_implemented);
//showErrorView(R.string.anonymous_homepage_not_implemented);
initializeAndBindPostViewModelForAnonymous(concatenatedSubredditNames);
}
});
} else {
@@ -1012,7 +1010,8 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
if (activity != null && !activity.isFinishing() && !activity.isDestroyed() && !isDetached()) {
postFilter.allowNSFW = !mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_NSFW_FOREVER, false) && mNsfwAndSpoilerSharedPreferences.getBoolean(SharedPreferencesUtils.NSFW_BASE, false);
this.concatenatedSubredditNames = concatenatedSubredditNames;
showErrorView(R.string.anonymous_homepage_not_implemented);
//showErrorView(R.string.anonymous_homepage_not_implemented);
initializeAndBindPostViewModelForAnonymous(concatenatedSubredditNames);
}
});
} else {
@@ -1355,12 +1354,8 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
}
mFetchPostInfoLinearLayout.setOnClickListener(null);
if (accessToken != null) {
showErrorView(R.string.no_posts);
} else {
showErrorView(R.string.anonymous_homepage_not_implemented);
}
showErrorView(R.string.no_posts);
}
public void changeSortType(SortType sortType) {
@@ -1504,7 +1499,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
mSwipeRefreshLayout.setRefreshing(false);
mFetchPostInfoLinearLayout.setVisibility(View.VISIBLE);
mFetchPostInfoTextView.setText(stringResId);
mGlide.load(R.drawable.error_image).into(mFetchPostInfoImageView);
mGlide.load(R.mipmap.ic_launcher_round).into(mFetchPostInfoImageView);
}
}

View File

@@ -162,7 +162,7 @@ public class PrivateMessageFragment extends Fragment implements FragmentCommunic
mSwipeRefreshLayout.setRefreshing(false);
mFetchMessageInfoLinearLayout.setVisibility(View.VISIBLE);
mFetchMessageInfoTextView.setText(stringResId);
mGlide.load(R.drawable.error_image).into(mFetchMessageInfoImageView);
mGlide.load(R.mipmap.ic_launcher_round).into(mFetchMessageInfoImageView);
}
@Override

View File

@@ -21,6 +21,7 @@ import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import com.bumptech.glide.Glide;
import com.evernote.android.state.State;
import com.google.android.material.card.MaterialCardView;
@@ -232,7 +233,7 @@ public class SidebarFragment extends Fragment {
return true;
};
markwon = MarkdownUtils.createFullRedditMarkwon(activity,
miscPlugin, markdownColor, spoilerBackgroundColor, onLinkLongClickListener, mDisableImagePreview);
miscPlugin, markdownColor, spoilerBackgroundColor, Glide.with(activity.getApplication()), onLinkLongClickListener, mDisableImagePreview);
markwonAdapter = MarkdownUtils.createTablesAdapter();
linearLayoutManager = new LinearLayoutManagerBugFixed(activity);

Some files were not shown because too many files have changed in this diff Show More