90 Commits

Author SHA1 Message Date
Balazs Toldi
134c895cd4 The .profm sorting in build.gradle instead of excluding them from the build
Signed-off-by: Balazs Toldi <balazs@toldi.eu>
2023-10-20 07:49:58 +02:00
Balazs Toldi
ec6567b9b2 Add python to build
Signed-off-by: Balazs Toldi <balazs@toldi.eu>
2023-10-20 07:49:14 +02:00
Balazs Toldi
40fa3a1987 Fully reproducible build
Signed-off-by: Balazs Toldi <balazs@toldi.eu>
2023-10-20 07:39:12 +02:00
Balazs Toldi
05123c7068 Reproducible classes2.dex
Signed-off-by: Balazs Toldi <balazs@toldi.eu>
2023-10-19 22:00:03 +02:00
Balazs Toldi
908f294130 Fix issue with marking as read when swiping
This commit fixes the issue where the 'swiping between posts' and 'mark post as read' options are enable. Previously, it only marked the first post as read, and not the ones that were swiped to. Now, all posts are marked read in these scenarios.
Signed-off-by: Balazs Toldi <balazs@toldi.eu>
2023-10-19 08:18:14 +02:00
Balazs Toldi
95408f8125 Fix link for translation
Signed-off-by: Balazs Toldi <balazs@toldi.eu>
2023-10-16 18:58:49 +02:00
Balazs Toldi
6d5ba059f8 Fixing issue with swiping to see new posts.
This commit fixes the issue with Fetching new posts when swiping on the post detail page.
2023-10-13 18:21:37 +02:00
Balazs Toldi
ecdd9da9c8 Fix issue where display name makes impossible to load saved things
This commit fixes an issue where the display name of a user makes it
impossible to load saved things. The problem is that the display name
was used in the url to load the saved things instead of the username.

Closes #179

Signed-off-by: Balazs Toldi <balazs@toldi.eu>
2023-10-12 09:16:56 +02:00
Balazs Toldi
1c17e6b7d2 Fix some issues with the "goto User" and "goto Community" options
This commit allows the user to input the communities with their "!" prefix. Similarly, it also allows the "@" prefix for users when trying to navigate to them with their corresponding "go to" options.

Also fixes issues with these options in the Community and User pages.
2023-10-12 08:26:50 +02:00
Balazs Toldi
9f60eca225 Fix crash when trying to open the community lists in some cases.
In some cases the app crashed when trying to select a community. This commit attempts to fix this issue
2023-10-12 08:08:02 +02:00
Balazs Toldi
9deba8b10e Fixing some sort type issues
This commit fixes issues where the sort type/time isn't loaded properly and the app resets back to NEW on the frontpage and Hot on Community pages.

Heads up: You might need to change the sort type in your settings if you see any issues.
2023-10-12 08:06:06 +02:00
Balazs Toldi
05948d74f4 Fix authentication when opening the app 2023-10-11 14:00:07 +02:00
Balazs Toldi
1007be50f8 Fix autherntiction on first logging in to Lemmy 0.19 2023-10-11 13:56:14 +02:00
Balazs Toldi
28617cf9a8 Compatibility for Lemmy 0.19
Closes #197
2023-10-06 12:56:33 +02:00
Bazsalanszky
5d2d43eebc Merge pull request 'Add preview to RedGIFs posts' (#187) from tinsukE/Eternity:regifs-preview into master
Reviewed-on: https://codeberg.org/Bazsalanszky/Eternity/pulls/187
Reviewed-by: Bazsalanszky <bazsalanszky@noreply.codeberg.org>
2023-10-06 06:15:34 +00:00
Bazsalanszky
f2b2525823 Merge pull request 'Fix parsing posts and userdata: admin flag removed in recent versions of Lemmy' (#190) from otaconix/Eternity:fix-for-missing-admin-flag into master
Reviewed-on: https://codeberg.org/Bazsalanszky/Eternity/pulls/190
Reviewed-by: Bazsalanszky <bazsalanszky@noreply.codeberg.org>
2023-10-06 06:01:11 +00:00
Balazs Toldi
29547f4750 Show instance for user listings
Closes #166
2023-09-12 09:02:27 +02:00
Balazs Toldi
af63bba54a Show instance for community listings 2023-09-12 08:43:56 +02:00
Stefan Zwanenburg
caf4f177d2 Fix parsing posts and userdata: admin flag removed in recent versions of Lemmy
See: https://github.com/LemmyNet/lemmy/pull/3403

For now, I guess we can try parsing the flag if it's present, and fall
back on assuming the associated user is *not* an admin.
2023-09-11 11:46:08 +02:00
Angelo Suzuki
1e67b34440 Add previews to RedGIFs posts
- Setup Glide with OkHttp in the custom application
- Add PostEnricher framework, that allows to add more data to fetched Posts. This was used to fetch the RedGIFs preview from their API.
2023-09-07 13:03:08 +02:00
Angelo Suzuki
67afcd7e88 Cleanup RedGIFs API usage
- Add User-Agent and authentication transparently
- Provide RedgifsAPI instance
2023-09-07 13:02:59 +02:00
Bazsalanszky
9406f29562 Merge pull request 'Use an OkHttpClient with User-Agent when initializing BigImageViewer' (#185) from tinsukE/Eternity:glide_user_agent into master
Reviewed-on: https://codeberg.org/Bazsalanszky/Eternity/pulls/185
Reviewed-by: Bazsalanszky <bazsalanszky@noreply.codeberg.org>
2023-09-07 08:48:52 +00:00
Angelo Suzuki
b626c5fb73 Use an OkHttpClient with User-Agent when initializing BigImageViewer.
If not passed, BigImageViewer overrides the Glide OkHttp downloader upon initialization with an empty one:
https://github.com/Piasy/BigImageViewer/blob/067f8eb/GlideImageLoader/src/main/java/com/github/piasy/biv/loader/glide/GlideProgressSupport.java#L76

In that case, Glide creates a default User-Agent:
cbdc1e78b4/library/src/main/java/com/bumptech/glide/load/model/LazyHeaders.java (L103-L106)

Example User-Agent: Dalvik/2.1.0 (Linux; U; Android 11; sdk_gphone_x86 Build/RSR1.201013.001)

https://files.catbox.moe is filtering out that User-Agent. Using the App one fixes it.
2023-09-05 11:42:38 +02:00
Balazs Toldi
0393ff6e77 Fix link text colour on the InstanceInfoActivity 2023-09-03 10:31:07 +02:00
Balazs Toldi
30ecc17d55 Fixing crash on opening community selector on post creation page 2023-09-03 10:21:43 +02:00
Bazsalanszky
7c5f184cc8 Updated Readme.md 2023-08-30 10:13:23 +02:00
Balazs Toldi
d5fff14cb0 Fix flashing screen on the MainActivity when changing the anonymous instance 2023-08-25 22:23:20 +02:00
Balazs Toldi
5cdda037b2 Change artifact name on tagged builds 2023-08-25 17:41:24 +02:00
Balazs Toldi
0942f7c5ec Bump version 2023-08-25 17:34:14 +02:00
Balazs Toldi
efe90d0030 Changed default media download location to the "Eternity" folder 2023-08-25 17:23:56 +02:00
Balazs Toldi
2d45f337d7 Somewhat better phone images 2023-08-25 17:15:50 +02:00
Balazs Toldi
70cf6f3340 Fix bug with unsubscribing from communities 2023-08-25 17:14:23 +02:00
Balazs Toldi
6542859892 Fix IndexOutOfBoundsException in CommentsRecyclerViewAdapter 2023-08-25 09:36:37 +02:00
Balazs Toldi
143bc5e1b6 Fix issues with resolving Links
This commit changes how resolving links work. It will not use the resolve object function now for local instance links, as they would fail almost every time.

It also opens toasts in the application context instead of the activity context. This might prevent some crashes
2023-08-25 09:02:39 +02:00
Balazs Toldi
6e51ea6ee7 Fix crashes and issues with searching in communities 2023-08-25 08:35:05 +02:00
Balazs Toldi
d7c4e3d5bc Truncate long names in the navigation header 2023-08-24 23:11:34 +02:00
Balazs Toldi
1ed86c138e Removed automatically added dependency 2023-08-24 23:10:46 +02:00
Balazs Toldi
2d83545865 Fix theming on multiple elements
Fixed theming on:
- Post content on PostImage and PostLink activities
- Report content forms

Closes #163
2023-08-24 20:09:52 +02:00
Balazs Toldi
3594f10fdd Fix issues with subscription listing after marking communities as favorite
Previously, when marking a community as favorite made some communities disappear on the subscription list
2023-08-24 19:53:48 +02:00
Balazs Toldi
a903ac9dbd Attempt to fix crash when deleted comment add necessary placeholder 2023-08-23 23:23:10 +02:00
Balazs Toldi
ed90a278a6 Fix crashes related to sort types
Closes #153 and #113
2023-08-23 22:53:41 +02:00
Balazs Toldi
6221b33a3d Fix user name on collapsed comments
Closes #161
2023-08-23 22:35:51 +02:00
Balazs Toldi
2561ba8bd0 Fix post layouts 2023-08-23 21:39:08 +02:00
Balazs Toldi
9859608764 Merge remote-tracking branch 'weblate/master'
# Conflicts:
#	app/src/main/res/values/strings.xml
2023-08-23 21:24:20 +02:00
SomeTr
b40077f83f Translated using Weblate (Ukrainian)
Currently translated at 99.7% (1249 of 1252 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/uk/
2023-08-23 19:19:38 +00:00
Bazsalanszky
76dc0ff083 Translated using Weblate (Hungarian)
Currently translated at 81.7% (1024 of 1252 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/hu/
2023-08-23 19:19:38 +00:00
Bazsalanszky
6a2d59ed48 Translated using Weblate (English)
Currently translated at 100.0% (1252 of 1252 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/en/
2023-08-23 19:19:38 +00:00
Balazs Toldi
a09d6f85f8 Add option to share links on local instance 2023-08-23 21:14:53 +02:00
SomeTr
2f3d39ed31 Translated using Weblate (Ukrainian)
Currently translated at 99.6% (1248 of 1252 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/uk/
2023-08-23 09:21:45 +00:00
American_Jesus
83e0fc039f Translated using Weblate (Portuguese)
Currently translated at 99.1% (1235 of 1245 strings)

Translation: Infinity for Lemmy/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/pt/
2023-08-23 09:21:45 +00:00
julroy67
d4ca682882 Translated using Weblate (French)
Currently translated at 94.5% (1177 of 1245 strings)

Translation: Infinity for Lemmy/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/fr/
2023-08-23 09:21:45 +00:00
dieserniko
e2b75a3928 Translated using Weblate (German)
Currently translated at 98.2% (1223 of 1245 strings)

Translation: Infinity for Lemmy/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/de/
2023-08-23 09:21:45 +00:00
Balazs Toldi
d9f9fb51db Fix instance info activity card background colours 2023-08-23 11:21:19 +02:00
Balazs Toldi
a8b2091e69 Bump version 2023-08-22 22:18:03 +02:00
Balazs Toldi
f14ebe9a0d Added option to show displayname and hide the instance for comment author names 2023-08-22 22:10:39 +02:00
Balazs Toldi
4010e02438 Fix instance info navigation bar colour 2023-08-22 21:53:08 +02:00
Balazs Toldi
5cbe6152c9 Fix nightly 2023-08-22 21:50:48 +02:00
Balazs Toldi
c7233e05c4 Instance Info page 2023-08-22 21:49:12 +02:00
Bazsalanszky
9d4657dea8 Merge pull request 'Set nightfox as default themes' (#147) from American_Jesus/Infinity-For-Lemmy:feature/default-themes-nightfox into master
Reviewed-on: https://codeberg.org/Bazsalanszky/Eternity/pulls/147
Reviewed-by: Bazsalanszky <bazsalanszky@noreply.codeberg.org>
2023-08-21 18:42:44 +00:00
Bazsalanszky
7c3ddfda5c Merge pull request 'Add new themes Dayfox,Nightfox,Carbonfox' (#146) from American_Jesus/Infinity-For-Lemmy:feature/nightfox-themes into master
Reviewed-on: https://codeberg.org/Bazsalanszky/Eternity/pulls/146
Reviewed-by: Bazsalanszky <bazsalanszky@noreply.codeberg.org>
2023-08-21 18:32:53 +00:00
SomeTr
77f37a5698 Translated using Weblate (Ukrainian)
Currently translated at 99.8% (1243 of 1245 strings)

Translation: Infinity for Lemmy/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/uk/
2023-08-21 11:56:44 +00:00
dieserniko
c45528a7f3 Translated using Weblate (German)
Currently translated at 98.3% (1224 of 1245 strings)

Translation: Infinity for Lemmy/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/de/
2023-08-21 11:56:44 +00:00
Bazsalanszky
0dcc441bae Change app name 2023-08-21 11:01:08 +02:00
Bazsalanszky
8c05b6e1ea Revert gradle related changes 2023-08-21 10:09:07 +02:00
Bazsalanszky
351033600f Merge remote-tracking branch 'origin/master' 2023-08-21 09:43:47 +02:00
Bazsalanszky
fb4289a812 Bump SDK in build pipeline 2023-08-21 09:43:39 +02:00
Generator
37eb16f6c4 Set nightfox default themes 2023-08-20 20:53:51 +01:00
SomeTr
77c5bcb038 Translated using Weblate (Ukrainian)
Currently translated at 99.5% (1239 of 1244 strings)

Translation: Infinity for Lemmy/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/uk/
2023-08-20 19:32:00 +00:00
Balazs Toldi
3c65bfcf1b Better sidebar for community pages 2023-08-20 21:31:40 +02:00
Balazs Toldi
ce7c284c6b Add stats to community "about" tab 2023-08-20 14:51:57 +02:00
Balazs Toldi
267570d7b4 Re-added favorite community functionality
This commit re-adds the ability to mark communities as 'favorites'. This function only works locally as Lemmy does not have an API/functionality for this.
2023-08-20 14:26:03 +02:00
Balazs Toldi
c9e6a0bc2e Fix comment refreshing bug on single thread view
Closes #143
2023-08-20 10:56:41 +02:00
Balazs Toldi
1f8348bbfa Merge remote-tracking branch 'codeberg/master' 2023-08-20 10:33:16 +02:00
Balazs Toldi
d4fe5235e2 Fix opening Image view activity from embedded images 2023-08-20 10:33:10 +02:00
Balazs Toldi
76fee50cd5 Do not show statistics block while loading 2023-08-20 10:24:09 +02:00
SomeTr
e2956e3f1c Translated using Weblate (Ukrainian)
Currently translated at 99.1% (1230 of 1241 strings)

Translation: Infinity for Lemmy/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/uk/
2023-08-19 20:25:36 +00:00
American_Jesus
21b0b36359 Translated using Weblate (Portuguese)
Currently translated at 98.3% (1221 of 1241 strings)

Translation: Infinity for Lemmy/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/pt/
2023-08-19 20:25:36 +00:00
Fjuro
a55820a11d Translated using Weblate (Czech)
Currently translated at 100.0% (1241 of 1241 strings)

Translation: Infinity for Lemmy/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/cs/
2023-08-19 20:25:36 +00:00
Balazs Toldi
3322b5b4e8 Add option to disable statistics block and post/comment score
As per users requested, I've added two options to the interface section:
1. Disable statistics (under users and community pages): Disables the statistics block on user/community pages
2. Disable post and comment scores: Disables the post and comment scores show on users pages
2023-08-19 22:25:26 +02:00
Balazs Toldi
0384914c16 Readded instance switcher to navbar for anonymous accounts 2023-08-19 16:57:08 +02:00
Balazs Toldi
0550219d58 Fix Streamable videos 2023-08-19 16:46:46 +02:00
Balazs Toldi
deaa4e596d Fix switch account toast when opening a notification
Closes #100
2023-08-19 16:36:22 +02:00
Balazs Toldi
bf1036c919 Fix crash when exiting ot of profile page while loading 2023-08-19 15:35:18 +02:00
Balazs Toldi
116deebf87 Use application context for MarkdownUtils 2023-08-18 23:35:33 +02:00
Balazs Toldi
0f3197d7e4 Use application context for Glide 2023-08-18 23:35:21 +02:00
Balazs Toldi
db9edc47c0 Merge changes 2023-08-18 22:14:47 +02:00
Balazs Toldi
2392d9fa29 Merge remote-tracking branch 'codeberg/master' 2023-08-18 21:51:38 +02:00
Balazs Toldi
3272f609a8 Potential fix for crash when closing a comment too fast 2023-08-18 21:51:30 +02:00
Bazsalanszky
bbbd4ddcb0 Merge pull request 'Basic Private messages' (#119) from feature/privatemessages into master
Reviewed-on: https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy/pulls/119
2023-08-18 13:57:19 +00:00
Generator
a245ebad09 add new themes Dayfox,Nightfox,Carbonfox 2023-08-18 14:39:52 +01:00
154 changed files with 3764 additions and 1115 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

View File

@@ -2,13 +2,14 @@ steps:
build:
image: alvrme/alpine-android:android-33-jdk11
commands:
- apk add --no-cache python3
- ./gradlew :app:assembleRelease
when:
path: [ app/**, build.gradle ]
sign:
image: alvrme/alpine-android:android-33-jdk11
commands:
- ./scripts/apk-sign.sh LemmInfinity-signed.apk app/build/outputs/apk/release/app-release-unsigned.apk
- ./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 ]
when:
event: [ tag ]
@@ -17,7 +18,7 @@ steps:
settings:
base_url: https://codeberg.org
files:
- LemmInfinity-signed.apk
- Eternity-signed.apk
api_key:
from_secret: GITEA_ACCESS_TOKEN
target: main

View File

@@ -8,6 +8,7 @@ steps:
build:
image: alvrme/alpine-android:android-33-jdk11
commands:
- apk add --no-cache python3
- ./gradlew :app:assembleNightly
sign:
image: alvrme/alpine-android:android-33-jdk11
@@ -23,7 +24,7 @@ steps:
- cd repoconfig
- pwd
- git clone --depth 1 https://codeberg.org/Bazsalanszky/fdroid-repo-config
- cp /woodpecker/src/codeberg.org/Bazsalanszky/Infinity-For-Lemmy/eu.toldi.infinityforlemmy.nightly.apk fdroid-repo-config/repo/
- cp /woodpecker/src/codeberg.org/Bazsalanszky/Eternity/eu.toldi.infinityforlemmy.nightly.apk fdroid-repo-config/repo/
pull-pages:
image: codeberg.org/freeyourgadget/android-fdroid-tools:latest

View File

@@ -1,5 +1,5 @@
<h1 align="center">
Infinity for Lemmy
Eternity (formerly Infinity for Lemmy)
</h1>
<div align="center">
@@ -10,29 +10,35 @@ A Lemmy client for Android written in Java. It's a fork of the [Infinity for Red
<br>
<div align="center">
<img src="https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy/raw/branch/master/fastlane/metadata/android/en-US/images/icon.png" width=256>
<img src="https://codeberg.org/Bazsalanszky/Eternity/raw/branch/master/fastlane/metadata/android/en-US/images/icon.png" width=256>
[![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)
<a href="https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy/issues">Report a Bug</a>
<a href="https://codeberg.org/Bazsalanszky/Eternity/issues">Report a Bug</a>
</div>
<div align="center">
<a href="https://play.google.com/store/apps/details?id=eu.toldi.infinityforlemmy">
<img src="./.assets/google-play-badge.png" height="80">
</a>
<a href="https://apt.izzysoft.de/fdroid/index/apk/eu.toldi.infinityforlemmy">
<img src="./.assets/IzzyOnDroid.png" height="80">
</a>
<a href="https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy/releases/">
<a href="https://codeberg.org/Bazsalanszky/Eternity/releases/">
<img src="./.assets/codeberg.png" height="80">
</a>
</div>
---
## Action Items for Infinity for Lemmy
## Action Items for Eternity
Infinity for Lemmy is currently in the early stages of development. Expect many unfinished features and bugs!
Eternity is currently in the early stages of development. Expect many unfinished features and bugs!
- [x] Implementation of basic post browsing feature
- [x] Support for multiple account handling
@@ -43,7 +49,7 @@ Infinity for Lemmy is currently in the early stages of development. Expect many
- [x] Edit/Delete posts and comments
- [x] Basic inbox
- [ ] Elimination of code/string references specific to Reddit
- [ ] Incorporation of private messaging feature
- [x] Incorporation of private messaging feature
- [x] Feature for saving posts/comments
- [x] Resolving links
- [ ] Account editing function
@@ -66,19 +72,19 @@ Don't forget to give the project a star! Thanks again!
### Translation
You can alos help Infinity for Lemmy by translating it to your native langugage! Translations are done via [Weblate](https://translate.codeberg.org/projects/infinity-for-lemmy/app/)!
You can alos help Eternity by translating it to your native langugage! Translations are done via [Weblate](https://translate.codeberg.org/projects/infinity-for-lemmy/app/)!
[![Translation](https://translate.codeberg.org/widgets/infinity-for-lemmy/-/app/multi-auto.svg)](https://translate.codeberg.org/engage/infinity-for-lemmy/)
[![Translation](https://translate.codeberg.org/widgets/infinity-for-lemmy/-/app/multi-auto.svg)](https://translate.codeberg.org/engage/Eternity/)
### Reporting bugs
You can also contribute by [reporting bugs](https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy/issues)
You can also contribute by [reporting bugs](https://codeberg.org/Bazsalanszky/Eternity/issues)
<p align="right">(<a href="#top">back to top</a>)</p>
## License
Distributed under the AGPL-3.0 License. See <a href="https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy/src/branch/master/LICENSE">LICENSE</a> for more information.
Distributed under the AGPL-3.0 License. See <a href="https://codeberg.org/Bazsalanszky/Eternity/src/branch/master/LICENSE">LICENSE</a> for more information.
<p align="right">(<a href="#top">back to top</a>)</p>
@@ -86,6 +92,6 @@ Distributed under the AGPL-3.0 License. See <a href="https://codeberg.org/Bazsal
[@bazsalanszky@lemmy.toldi.eu](https://lemmy.toldi.eu/u/bazsalanszky) - (Owner)
Project Link: [https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy](https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy)
Project Link: [https://codeberg.org/Bazsalanszky/Eternity](https://codeberg.org/Bazsalanszky/Eternity)
<p align="right">(<a href="#top">back to top</a>)</p>

View File

@@ -21,8 +21,8 @@ android {
applicationId "eu.toldi.infinityforlemmy"
minSdk 21
targetSdk 33
versionCode 128
versionName "0.0.8"
versionCode 130
versionName "0.1.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
javaCompileOptions {
annotationProcessorOptions {
@@ -98,6 +98,30 @@ android {
doNotStrip '**/*.so'
}
namespace 'eu.toldi.infinityforlemmy'
task rearrangeClass(type: Exec) {
commandLine 'python', '../scripts/fixEventBus.py'
}
applicationVariants.all { variant ->
if (variant.name == 'release') {
task("compileSingleFile${variant.name.capitalize()}", type: JavaCompile, dependsOn: rearrangeClass) {
def filePath = project.rootDir.absolutePath + '/app/build/generated/ap_generated_sources/release/out/eu/toldi/infinityforlemmy/'
source = files(filePath)
includes = ["**/EventBusIndex.java"]
classpath = variant.getCompileClasspath() + files(project.rootDir.absolutePath + '/app/build/intermediates/javac/release/classes')
destinationDir = file("$buildDir/intermediates/javac/release/classes")
}
tasks.withType(JavaCompile).all { task ->
if (task.name == 'compileReleaseJavaWithJavac') {
task.finalizedBy "compileSingleFile${variant.name.capitalize()}"
}
}
}
}
}
dependencies {
@@ -108,6 +132,7 @@ dependencies {
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
def lifecycleVersion = "2.5.1"
implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycleVersion"
implementation "androidx.lifecycle:lifecycle-livedata:$lifecycleVersion"
@@ -153,6 +178,7 @@ dependencies {
implementation "com.google.dagger:dagger:$daggerVersion"
annotationProcessor "com.google.dagger:dagger-compiler:$daggerVersion"
// Binding
// NOTE: Deprecated in favor of viewbinding
def butterknifeVersion = "10.2.3"
@@ -194,6 +220,7 @@ dependencies {
def glideVersion = "4.12.0"
implementation "com.github.bumptech.glide:glide:$glideVersion"
annotationProcessor "com.github.bumptech.glide:compiler:$glideVersion"
implementation "com.github.bumptech.glide:okhttp-integration:$glideVersion"
implementation 'jp.wasabeef:glide-transformations:4.3.0'
implementation 'com.github.santalu:aspect-ratio-imageview:1.0.9'
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.23'
@@ -243,3 +270,34 @@ dependencies {
//debugImplementation 'com.squareup.leakcanary:leakcanary-android:x.y'
}
// NB: Android Studio can't find the imports; this does not affect the
// actual build since Gradle can find them just fine.
import com.android.tools.profgen.ArtProfileKt
import com.android.tools.profgen.ArtProfileSerializer
import com.android.tools.profgen.DexFile
project.afterEvaluate {
tasks.each { task ->
if (task.name.startsWith("compile") && task.name.endsWith("ReleaseArtProfile")) {
task.doLast {
outputs.files.each { file ->
if (file.name.endsWith(".profm")) {
println("Sorting ${file} ...")
def version = ArtProfileSerializer.valueOf("METADATA_0_0_2")
def profile = ArtProfileKt.ArtProfile(file)
def keys = new ArrayList(profile.profileData.keySet())
def sortedData = new LinkedHashMap()
Collections.sort keys, new DexFile.Companion()
keys.each { key -> sortedData[key] = profile.profileData[key] }
new FileOutputStream(file).with {
write(version.magicBytes$profgen)
write(version.versionBytes$profgen)
version.write$profgen(it, sortedData, "")
}
}
}
}
}
}
}

View File

@@ -1,3 +1,3 @@
<resources>
<string name="application_name" translatable="false">Infinity for Lemmy (Debug)</string>
<string name="application_name" translatable="false">Eternity (Debug)</string>
</resources>

View File

@@ -22,8 +22,7 @@
android:maxSdkVersion="28" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<application
android:name=".Infinity"
@@ -35,6 +34,12 @@
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true"
tools:replace="android:label">
<activity
android:name=".activities.InstanceInfoActivity"
android:label="@string/instance_info"
android:configChanges="orientation|screenLayout|screenSize|layoutDirection"
android:parentActivityName=".activities.MainActivity"
android:theme="@style/AppTheme.Slidable" />
<activity
android:name=".activities.HistoryActivity"
android:exported="false"
@@ -469,7 +474,6 @@
android:name=".activities.ViewUserDetailActivity"
android:parentActivityName=".activities.MainActivity"
android:theme="@style/AppTheme.Slidable" />
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.provider"

View File

@@ -2,6 +2,8 @@ package eu.toldi.infinityforlemmy;
import android.app.Application;
import org.jetbrains.annotations.NotNull;
import javax.inject.Singleton;
import dagger.BindsInstance;
@@ -25,6 +27,7 @@ import eu.toldi.infinityforlemmy.activities.FullMarkdownActivity;
import eu.toldi.infinityforlemmy.activities.GiveAwardActivity;
import eu.toldi.infinityforlemmy.activities.HistoryActivity;
import eu.toldi.infinityforlemmy.activities.InboxActivity;
import eu.toldi.infinityforlemmy.activities.InstanceInfoActivity;
import eu.toldi.infinityforlemmy.activities.LinkResolverActivity;
import eu.toldi.infinityforlemmy.activities.LockScreenActivity;
import eu.toldi.infinityforlemmy.activities.LoginActivity;
@@ -110,7 +113,7 @@ import eu.toldi.infinityforlemmy.settings.TranslationFragment;
import eu.toldi.infinityforlemmy.settings.VideoPreferenceFragment;
@Singleton
@Component(modules = {AppModule.class, NetworkModule.class})
@Component(modules = {AppModule.class, NetworkModule.class, PostEnricherModule.class})
public interface AppComponent {
void inject(MainActivity mainActivity);
@@ -322,6 +325,8 @@ public interface AppComponent {
void inject(PrivateMessageFragment privateMessageFragment);
void inject(@NotNull InstanceInfoActivity instanceInfoActivity);
@Component.Factory
interface Factory {
AppComponent create(@BindsInstance Application application);

View File

@@ -1,7 +1,5 @@
package eu.toldi.infinityforlemmy;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Handler;
import org.json.JSONException;
@@ -12,9 +10,7 @@ import java.util.concurrent.Executor;
import eu.toldi.infinityforlemmy.apis.GfycatAPI;
import eu.toldi.infinityforlemmy.apis.RedgifsAPI;
import eu.toldi.infinityforlemmy.utils.APIUtils;
import eu.toldi.infinityforlemmy.utils.JSONUtils;
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
import retrofit2.Call;
import retrofit2.Response;
import retrofit2.Retrofit;
@@ -44,14 +40,12 @@ public class FetchGfycatOrRedgifsVideoLinks {
});
}
public static void fetchRedgifsVideoLinks(Context context, Executor executor, Handler handler, Retrofit redgifsRetrofit,
SharedPreferences currentAccountSharedPreferences,
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(APIUtils.getRedgifsOAuthHeader(currentAccountSharedPreferences.getString(SharedPreferencesUtils.REDGIFS_ACCESS_TOKEN, "")),
gfycatId, APIUtils.USER_AGENT).execute();
Response<String> response = redgifsRetrofit.create(RedgifsAPI.class).getRedgifsData(gfycatId).execute();
if (response.isSuccessful()) {
parseRedgifsVideoLinks(handler, response.body(), fetchGfycatOrRedgifsVideoLinksListener);
} else {

View File

@@ -20,6 +20,7 @@ import retrofit2.Response;
public class FetchStreamableVideo {
public interface FetchStreamableVideoListener {
void success(StreamableVideo streamableVideo);
void failed();
}
@@ -33,7 +34,12 @@ public class FetchStreamableVideo {
String title = jsonObject.getString(JSONUtils.TITLE_KEY);
JSONObject filesObject = jsonObject.getJSONObject(JSONUtils.FILES_KEY);
StreamableVideo.Media mp4 = parseMedia(filesObject.getJSONObject(JSONUtils.MP4_KEY));
StreamableVideo.Media mp4Mobile = parseMedia(filesObject.getJSONObject(JSONUtils.MP4_MOBILE_KEY));
StreamableVideo.Media mp4MobileTemp = null;
try {
mp4MobileTemp = parseMedia(filesObject.getJSONObject(JSONUtils.MP4_MOBILE_KEY));
} catch (JSONException e) {
}
StreamableVideo.Media mp4Mobile = mp4MobileTemp;
handler.post(() -> fetchStreamableVideoListener.success(new StreamableVideo(title, mp4, mp4Mobile)));
} else {
handler.post(fetchStreamableVideoListener::failed);
@@ -55,7 +61,12 @@ public class FetchStreamableVideo {
String title = jsonObject.getString(JSONUtils.TITLE_KEY);
JSONObject filesObject = jsonObject.getJSONObject(JSONUtils.FILES_KEY);
StreamableVideo.Media mp4 = parseMedia(filesObject.getJSONObject(JSONUtils.MP4_KEY));
StreamableVideo.Media mp4Mobile = parseMedia(filesObject.getJSONObject(JSONUtils.MP4_MOBILE_KEY));
StreamableVideo.Media mp4MobileTemp = null;
try {
mp4MobileTemp = parseMedia(filesObject.getJSONObject(JSONUtils.MP4_MOBILE_KEY));
} catch (JSONException e) {
}
StreamableVideo.Media mp4Mobile = mp4MobileTemp;
if (mp4 == null && mp4Mobile == null) {
handler.post(fetchStreamableVideoListener::failed);
return;

View File

@@ -11,6 +11,16 @@ import android.os.Bundle;
import android.view.WindowManager;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleObserver;
import androidx.lifecycle.OnLifecycleEvent;
import androidx.lifecycle.ProcessLifecycleOwner;
import com.bumptech.glide.Glide;
import com.bumptech.glide.integration.okhttp3.OkHttpUrlLoader;
import com.bumptech.glide.load.model.GlideUrl;
import com.evernote.android.state.StateSaver;
import com.livefront.bridge.Bridge;
import com.livefront.bridge.SavedStateHandler;
@@ -18,15 +28,11 @@ import com.livefront.bridge.SavedStateHandler;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import java.io.InputStream;
import javax.inject.Inject;
import javax.inject.Named;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleObserver;
import androidx.lifecycle.OnLifecycleEvent;
import androidx.lifecycle.ProcessLifecycleOwner;
import eu.toldi.infinityforlemmy.activities.LockScreenActivity;
import eu.toldi.infinityforlemmy.broadcastreceivers.NetworkWifiStatusReceiver;
import eu.toldi.infinityforlemmy.broadcastreceivers.WallpaperChangeReceiver;
@@ -38,6 +44,8 @@ import eu.toldi.infinityforlemmy.font.FontFamily;
import eu.toldi.infinityforlemmy.font.TitleFontFamily;
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
import eu.toldi.infinityforlemmy.utils.Utils;
import okhttp3.Call;
import okhttp3.OkHttpClient;
public class Infinity extends Application implements LifecycleObserver {
public Typeface typeface;
@@ -55,6 +63,9 @@ public class Infinity extends Application implements LifecycleObserver {
@Inject
@Named("security")
SharedPreferences mSecuritySharedPreferences;
@Inject
@Named("glide")
OkHttpClient glideOkHttpClient;
@Override
public void onCreate() {
@@ -159,6 +170,9 @@ public class Infinity extends Application implements LifecycleObserver {
registerReceiver(mNetworkWifiStatusReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
registerReceiver(new WallpaperChangeReceiver(mSharedPreferences), new IntentFilter(Intent.ACTION_WALLPAPER_CHANGED));
OkHttpUrlLoader.Factory factory = new OkHttpUrlLoader.Factory((Call.Factory) glideOkHttpClient);
Glide.get(this).getRegistry().replace(GlideUrl.class, InputStream.class, factory);
}
@OnLifecycleEvent(Lifecycle.Event.ON_START)

View File

@@ -9,10 +9,11 @@ import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
import eu.toldi.infinityforlemmy.apis.RedgifsAPI;
import eu.toldi.infinityforlemmy.apis.StreamableAPI;
import eu.toldi.infinityforlemmy.privatemessage.LemmyPrivateMessageAPI;
import eu.toldi.infinityforlemmy.comment.LemmyCommentAPI;
import eu.toldi.infinityforlemmy.post.LemmyPostAPI;
import eu.toldi.infinityforlemmy.privatemessage.LemmyPrivateMessageAPI;
import eu.toldi.infinityforlemmy.utils.APIUtils;
import okhttp3.ConnectionPool;
import okhttp3.Interceptor;
@@ -34,6 +35,21 @@ abstract class NetworkModule {
.build();
}
@Provides
@Named("glide")
@Singleton
static OkHttpClient provideGlideOkHttp(@Named("base") OkHttpClient baseOkHttp,
@Named("RedgifsAccessTokenAuthenticator") Interceptor redGifsAuthenticator) {
return baseOkHttp.newBuilder()
.addInterceptor(chain -> chain.proceed(
chain.request()
.newBuilder()
.header("User-Agent", APIUtils.USER_AGENT)
.build()
))
.addInterceptor(redGifsAuthenticator)
.build();
}
@Provides
@Named("base")
@@ -165,6 +181,12 @@ abstract class NetworkModule {
.build();
}
@Provides
@Singleton
static RedgifsAPI provideRedgifsAPI(@Named("redgifs") Retrofit redgifsRetrofit) {
return redgifsRetrofit.create(RedgifsAPI.class);
}
@Provides
@Named("imgur")
@Singleton

View File

@@ -111,7 +111,7 @@ class ParseSubscribedThing {
int instanceId = community.getInt("instance_id");
int subscribers = data.getJSONObject("counts").getInt("subscribers");
boolean isBlocked = data.getBoolean("blocked");
newSubscribedSubredditData.add(new SubscribedSubredditData(id, title, LemmyUtils.actorID2FullName(actorId), iconUrl, accountName));
newSubscribedSubredditData.add(new SubscribedSubredditData(id, title, LemmyUtils.actorID2FullName(actorId), iconUrl, accountName, false));
newSubredditData.add(new SubredditData(id, name, title, description, removed, published, updated, deleted, nsfw, actorId, local, iconUrl, bannerImageUrl, hidden, postingRestrictedToMods, instanceId, subscribers, isBlocked));
}

View File

@@ -0,0 +1,26 @@
package eu.toldi.infinityforlemmy;
import java.util.Set;
import dagger.Module;
import dagger.Provides;
import dagger.multibindings.IntoSet;
import eu.toldi.infinityforlemmy.apis.RedgifsAPI;
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 {
@Provides
@IntoSet
static PostEnricher provideRedGifsPostEnricher(RedgifsAPI redgifsAPI) {
return new RedGifsPostEnricher(redgifsAPI);
}
@Provides
static PostEnricher providePostEnricher(Set<PostEnricher> postEnrichers) {
return new CompositePostEnricher(postEnrichers);
}
}

View File

@@ -42,7 +42,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}, version = 26)
ReadPost.class, PostFilter.class, PostFilterUsage.class, AnonymousMultiredditSubreddit.class, BlockedUserData.class, BlockedCommunityData.class}, version = 27)
public abstract class RedditDataRoomDatabase extends RoomDatabase {
public static RedditDataRoomDatabase create(final Context context) {
@@ -53,7 +53,7 @@ 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_21_22, MIGRATION_22_23, MIGRATION_23_24, MIGRATION_24_25, MIGRATION_25_26, MIGRATION_26_27)
.build();
}
@@ -416,4 +416,12 @@ public abstract class RedditDataRoomDatabase extends RoomDatabase {
}
};
private static final Migration MIGRATION_26_27 = new Migration(26, 27) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase database) {
database.execSQL("ALTER TABLE subscribed_subreddits"
+ " ADD COLUMN is_favorite INTEGER DEFAULT 0 NOT NULL");
}
};
}

View File

@@ -14,7 +14,6 @@ import java.util.Map;
import eu.toldi.infinityforlemmy.apis.RedgifsAPI;
import eu.toldi.infinityforlemmy.utils.APIUtils;
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
import okhttp3.Headers;
import okhttp3.Interceptor;
import okhttp3.Response;
import retrofit2.Call;
@@ -22,6 +21,8 @@ import retrofit2.Retrofit;
import retrofit2.converter.scalars.ScalarsConverterFactory;
public class RedgifsAccessTokenAuthenticator implements Interceptor {
private static final String REDGIFS_HOST = "redgifs.com";
private SharedPreferences mCurrentAccountSharedPreferences;
public RedgifsAccessTokenAuthenticator(SharedPreferences currentAccountSharedPreferences) {
@@ -60,7 +61,17 @@ public class RedgifsAccessTokenAuthenticator implements Interceptor {
@NonNull
@Override
public Response intercept(@NonNull Chain chain) throws IOException {
Response response = chain.proceed(chain.request());
if (!chain.request().url().host().endsWith(REDGIFS_HOST)) {
return chain.proceed(chain.request());
}
String currentAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.REDGIFS_ACCESS_TOKEN, "");
Response response = chain.proceed(
chain.request().newBuilder()
.addHeader(APIUtils.AUTHORIZATION_KEY, APIUtils.AUTHORIZATION_BASE + currentAccessToken)
.build()
);
if (response.code() == 401 || response.code() == 400) {
String accessTokenHeader = response.request().header(APIUtils.AUTHORIZATION_KEY);
if (accessTokenHeader == null) {
@@ -74,13 +85,21 @@ public class RedgifsAccessTokenAuthenticator implements Interceptor {
String newAccessToken = refreshAccessToken();
if (!newAccessToken.equals("")) {
response.close();
return chain.proceed(response.request().newBuilder().headers(Headers.of(APIUtils.getRedgifsOAuthHeader(newAccessToken))).build());
return chain.proceed(
chain.request().newBuilder()
.addHeader(APIUtils.AUTHORIZATION_KEY, APIUtils.AUTHORIZATION_BASE + newAccessToken)
.build()
);
} else {
return response;
}
} else {
response.close();
return chain.proceed(response.request().newBuilder().headers(Headers.of(APIUtils.getRedgifsOAuthHeader(accessTokenFromSharedPreferences))).build());
return chain.proceed(
chain.request().newBuilder()
.addHeader(APIUtils.AUTHORIZATION_KEY, APIUtils.AUTHORIZATION_BASE + accessTokenFromSharedPreferences)
.build()
);
}
}
}

View File

@@ -1,7 +1,10 @@
package eu.toldi.infinityforlemmy;
import android.util.Log;
import eu.toldi.infinityforlemmy.network.SortTypeConverterFactory;
import eu.toldi.infinityforlemmy.utils.APIUtils;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import retrofit2.Retrofit;
import retrofit2.adapter.guava.GuavaCallAdapterFactory;
@@ -12,8 +15,14 @@ public class RetrofitHolder {
private Retrofit retrofit;
private OkHttpClient okHttpClient;
private OkHttpClient okHttpClientBase;
private String baseURL = APIUtils.API_BASE_URI;
private String accessToken = null;
private Interceptor oAuthInterceptor;
public Retrofit getRetrofit() {
return retrofit;
}
@@ -33,6 +42,7 @@ public class RetrofitHolder {
public RetrofitHolder(OkHttpClient okHttpClient) {
this.okHttpClient = okHttpClient;
this.okHttpClientBase = okHttpClient;
this.retrofit = createRetrofit(okHttpClient, APIUtils.API_BASE_URI);
}
@@ -46,4 +56,18 @@ public class RetrofitHolder {
.addConverterFactory(GsonConverterFactory.create())
.build();
}
public void setAccessToken(String accessToken) {
this.accessToken = accessToken;
OkHttpClient.Builder builder = okHttpClientBase.newBuilder();
Log.d("RetrofitHolder", "Access token changed");
if (accessToken != null && !accessToken.equals("")) {
Log.i("RetrofitHolder", "Setting access token interceptor");
oAuthInterceptor = APIUtils.getOAuthInterceptor(accessToken);
builder.addInterceptor(oAuthInterceptor);
}
okHttpClient = builder.build();
retrofit = createRetrofit(okHttpClient, baseURL);
}
}

View File

@@ -69,15 +69,15 @@ public class SortType {
}
public enum Time {
HOUR("TopHour", "Top Hour"),
SIX_HOURS("TopSixHour", "Top Six Hours"),
TWELVE_HOURS("TopTwelveHour", "Top Twelve Hours"),
HOUR("hour", "Hour"),
SIX_HOURS("SixHour", "Six Hours"),
TWELVE_HOURS("TwelveHour", "Twelve Hours"),
DAY("day", "Day"),
WEEK("week", "Week"),
MONTH("month", "Month"),
THREE_MONTHS("TopThreeMonth", "Top Three Months"),
SIX_MONTHS("TopSixMonth", "Top Six Months"),
NINE_MONTHS("TopNineMonth", "Top Nine Months"),
THREE_MONTHS("ThreeMonths", "Three Months"),
SIX_MONTHS("SixMonths", "Six Months"),
NINE_MONTHS("NineMonths", "Nine Months"),
YEAR("year", "Year"),
ALL("all", "All Time");
@@ -88,5 +88,14 @@ public class SortType {
this.value = value;
this.fullName = fullName;
}
public static Time fromValue(String value) {
for (Time time : values()) {
if (time.value.equalsIgnoreCase(value)) {
return time;
}
}
return null;
}
}
}

View File

@@ -283,7 +283,7 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
PostFragment fragment = new PostFragment();
Bundle bundle = new Bundle();
bundle.putInt(PostFragment.EXTRA_POST_TYPE, PostPagingSource.TYPE_USER);
bundle.putString(PostFragment.EXTRA_USER_NAME, mAccountName);
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);
@@ -293,7 +293,7 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
}
CommentsListingFragment fragment = new CommentsListingFragment();
Bundle bundle = new Bundle();
bundle.putString(CommentsListingFragment.EXTRA_USERNAME, mAccountName);
bundle.putString(CommentsListingFragment.EXTRA_USERNAME, mAccountQualifiedName);
bundle.putString(CommentsListingFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
bundle.putString(CommentsListingFragment.EXTRA_ACCOUNT_NAME, mAccountName);
bundle.putBoolean(CommentsListingFragment.EXTRA_ARE_SAVED_COMMENTS, true);

View File

@@ -226,7 +226,7 @@ public class CommentActivity extends BaseActivity implements UploadImageEnabledA
setSupportActionBar(binding.commentToolbar);
mGlide = Glide.with(this);
mGlide = Glide.with(getApplication());
if (savedInstanceState != null) {
selectedAccount = savedInstanceState.getParcelable(SELECTED_ACCOUNT_STATE);

View File

@@ -172,7 +172,7 @@ public class EditPostActivity extends BaseActivity implements UploadImageEnabled
contentEditText.setText(mPost.getSelfText());
linkEditText.setText(mPost.getUrl());
mGlide = Glide.with(this);
mGlide = Glide.with(getApplication());
if (mPost.getUrl() != null && mPost.getUrl().matches(picturePattern)) {
loadImage();
@@ -354,7 +354,7 @@ public class EditPostActivity extends BaseActivity implements UploadImageEnabled
Uri imageUri = data.getData();
mExecutor.execute(() -> {
try {
Bitmap bitmap = Glide.with(this).asBitmap().load(imageUri).submit().get();
Bitmap bitmap = Glide.with(getApplication()).asBitmap().load(imageUri).submit().get();
String imageUrlOrError = UploadImageUtils.uploadImage(mRetrofit, mAccessToken, bitmap);
handler.post(() -> {
if (imageUrlOrError != null && !imageUrlOrError.startsWith("Error: ")) {

View File

@@ -38,7 +38,6 @@ import javax.inject.Named;
import butterknife.BindView;
import butterknife.ButterKnife;
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
import eu.toldi.infinityforlemmy.Infinity;
import eu.toldi.infinityforlemmy.R;
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
@@ -52,6 +51,7 @@ import eu.toldi.infinityforlemmy.user.UserViewModel;
import eu.toldi.infinityforlemmy.utils.EditProfileUtils;
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
import eu.toldi.infinityforlemmy.utils.Utils;
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
import pl.droidsonroids.gif.GifImageView;
import retrofit2.Retrofit;
@@ -135,7 +135,7 @@ public class EditProfileActivity extends BaseActivity {
startPickImage(PICK_IMAGE_AVATAR_REQUEST_CODE);
});
final RequestManager glide = Glide.with(this);
final RequestManager glide = Glide.with(getApplication());
final UserViewModel.Factory userViewModelFactory =
new UserViewModel.Factory(getApplication(), mRedditDataRoomDatabase, mAccountName);
final UserViewModel userViewModel =

View File

@@ -29,12 +29,6 @@ import javax.inject.Named;
import butterknife.BindView;
import butterknife.ButterKnife;
import io.noties.markwon.AbstractMarkwonPlugin;
import io.noties.markwon.Markwon;
import io.noties.markwon.MarkwonConfiguration;
import io.noties.markwon.MarkwonPlugin;
import io.noties.markwon.core.MarkwonTheme;
import io.noties.markwon.recycler.MarkwonAdapter;
import eu.toldi.infinityforlemmy.Infinity;
import eu.toldi.infinityforlemmy.R;
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
@@ -45,6 +39,12 @@ import eu.toldi.infinityforlemmy.customviews.slidr.Slidr;
import eu.toldi.infinityforlemmy.events.SwitchAccountEvent;
import eu.toldi.infinityforlemmy.markdown.MarkdownUtils;
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
import io.noties.markwon.AbstractMarkwonPlugin;
import io.noties.markwon.Markwon;
import io.noties.markwon.MarkwonConfiguration;
import io.noties.markwon.MarkwonPlugin;
import io.noties.markwon.core.MarkwonTheme;
import io.noties.markwon.recycler.MarkwonAdapter;
public class FullMarkdownActivity extends BaseActivity {

View File

@@ -0,0 +1,266 @@
package eu.toldi.infinityforlemmy.activities;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.net.Uri;
import android.os.Bundle;
import android.text.Spanned;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.Toolbar;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.card.MaterialCardView;
import java.util.List;
import javax.inject.Inject;
import javax.inject.Named;
import eu.toldi.infinityforlemmy.Infinity;
import eu.toldi.infinityforlemmy.R;
import eu.toldi.infinityforlemmy.RetrofitHolder;
import eu.toldi.infinityforlemmy.adapters.AdminRecyclerViewAdapter;
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.FetchSiteInfo;
import eu.toldi.infinityforlemmy.site.SiteInfo;
import eu.toldi.infinityforlemmy.site.SiteStatistics;
import eu.toldi.infinityforlemmy.user.BasicUserInfo;
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
import io.noties.markwon.AbstractMarkwonPlugin;
import io.noties.markwon.Markwon;
import io.noties.markwon.MarkwonConfiguration;
import io.noties.markwon.MarkwonPlugin;
import io.noties.markwon.core.MarkwonTheme;
import io.noties.markwon.recycler.MarkwonAdapter;
public class InstanceInfoActivity extends BaseActivity {
@Inject
@Named("default")
SharedPreferences mSharedPreferences;
@Inject
CustomThemeWrapper mCustomThemeWrapper;
@Inject
@Named("no_oauth")
RetrofitHolder mRetorifitHolder;
ActivityInstanceInfoBinding mInstanceInfoActivityViewBinding;
private CoordinatorLayout coordinatorLayout;
private Toolbar toolbar;
private AppBarLayout appBarLayout;
private ConstraintLayout mLoadingConstraintLayout;
private MaterialCardView mStatisticsCardView;
private TextView mUsersTextView;
private TextView mCommunitiesTextView;
private TextView mPostsTextView;
private TextView mCommentsTextView;
private TextView mActiveUsersTextView;
private ImageView mUsersImageView;
private ImageView mCommunitiesImageView;
private ImageView mPostsImageView;
private ImageView mCommentsImageView;
private ImageView mActiveUsersImageView;
private MaterialCardView mDescriptionCardView;
private RecyclerView mContentMarkdownView;
private RecyclerView mAdminsRecyclerView;
private MaterialCardView mAdminsCardView;
private MarkwonAdapter mMarkwonAdapter;
private Markwon mPostDetailMarkwon;
private AdminRecyclerViewAdapter mAdminAdapter;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
((Infinity) getApplication()).getAppComponent().inject(this);
super.onCreate(savedInstanceState);
mInstanceInfoActivityViewBinding = ActivityInstanceInfoBinding.inflate(getLayoutInflater());
View view = mInstanceInfoActivityViewBinding.getRoot();
setImmersiveModeNotApplicable();
setContentView(view);
setSupportActionBar(mInstanceInfoActivityViewBinding.toolbarInstanceInfoActivity);
setUpBindings();
applyCustomTheme();
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK, true)) {
Slidr.attach(this);
}
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// Remove transparency from navigation bar
getWindow().setNavigationBarColor(mCustomThemeWrapper.getBackgroundColor());
int markdownColor = customThemeWrapper.getPostContentColor();
int postSpoilerBackgroundColor = markdownColor | 0xFF000000;
int linkColor = customThemeWrapper.getLinkColor();
MarkwonPlugin miscPlugin = new AbstractMarkwonPlugin() {
@Override
public void beforeSetText(@NonNull TextView textView, @NonNull Spanned markdown) {
if (InstanceInfoActivity.this.contentTypeface != null) {
textView.setTypeface(InstanceInfoActivity.this.contentTypeface);
}
textView.setTextColor(markdownColor);
textView.setHighlightColor(Color.TRANSPARENT);
}
@Override
public void configureConfiguration(@NonNull MarkwonConfiguration.Builder builder) {
builder.linkResolver((view, link) -> {
Intent intent = new Intent(InstanceInfoActivity.this, LinkResolverActivity.class);
Uri uri = Uri.parse(link);
intent.setData(uri);
InstanceInfoActivity.this.startActivity(intent);
});
}
@Override
public void configureTheme(@NonNull MarkwonTheme.Builder builder) {
builder.linkColor(linkColor);
}
};
mPostDetailMarkwon = MarkdownUtils.createFullRedditMarkwon(this,
miscPlugin, markdownColor, postSpoilerBackgroundColor, null);
mMarkwonAdapter = MarkdownUtils.createTablesAdapter();
mContentMarkdownView.setAdapter(mMarkwonAdapter);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
mContentMarkdownView.setLayoutManager(linearLayoutManager);
mAdminAdapter = new AdminRecyclerViewAdapter(InstanceInfoActivity.this, customThemeWrapper);
mAdminsRecyclerView.setLayoutManager(new LinearLayoutManagerBugFixed(InstanceInfoActivity.this));
mAdminsRecyclerView.setAdapter(mAdminAdapter);
fetchInstanceInfo();
}
@Override
protected void onStart() {
super.onStart();
fetchInstanceInfo();
}
private void fetchInstanceInfo() {
FetchSiteInfo.fetchSiteInfo(mRetorifitHolder.getRetrofit(), null, new FetchSiteInfo.FetchSiteInfoListener() {
@Override
public void onFetchSiteInfoSuccess(SiteInfo siteInfo) {
mLoadingConstraintLayout.setVisibility(View.GONE);
toolbar.setTitle(siteInfo.getName());
if (siteInfo.getSidebar() != null) {
mMarkwonAdapter.setMarkdown(mPostDetailMarkwon, siteInfo.getSidebar());
Log.i("SiteInfo", "onFetchSiteInfoSuccess: " + siteInfo.getSidebar());
// noinspection NotifyDataSetChanged
mMarkwonAdapter.notifyDataSetChanged();
mDescriptionCardView.setVisibility(View.VISIBLE);
}
List<BasicUserInfo> admins = siteInfo.getAdmins();
if (admins != null && !admins.isEmpty()) {
mAdminsCardView.setVisibility(View.VISIBLE);
mAdminAdapter.setUsers(admins);
}
SiteStatistics siteStatistics = siteInfo.getSiteStatistics();
if (siteStatistics != null) {
mStatisticsCardView.setVisibility(View.VISIBLE);
mUsersTextView.setText(getString(R.string.user_number_detail, siteStatistics.getUsers()));
mCommunitiesTextView.setText(getString(R.string.community_number_detail, siteStatistics.getCommunities()));
mPostsTextView.setText(getString(R.string.post_count_detail, siteStatistics.getPosts()));
mCommentsTextView.setText(getString(R.string.comment_count_detail, siteStatistics.getComments()));
mActiveUsersTextView.setText(getString(R.string.active_users_number_detail, siteStatistics.getUsers_active()));
}
}
@Override
public void onFetchSiteInfoFailed() {
}
});
}
protected void setUpBindings() {
coordinatorLayout = mInstanceInfoActivityViewBinding.coordinatorLayoutInstanceInfoActivity;
toolbar = mInstanceInfoActivityViewBinding.toolbarInstanceInfoActivity;
appBarLayout = mInstanceInfoActivityViewBinding.appbarLayoutInstanceInfoActivity;
mStatisticsCardView = mInstanceInfoActivityViewBinding.statisticsCardInstanceInfoActivity;
mDescriptionCardView = mInstanceInfoActivityViewBinding.descriptionCardInstanceInfoActivity;
mContentMarkdownView = mInstanceInfoActivityViewBinding.markdownRecyclerViewInstanceInfoActivity;
mAdminsCardView = mInstanceInfoActivityViewBinding.moderatorsCardInstanceInfoActivity;
mLoadingConstraintLayout = mInstanceInfoActivityViewBinding.loadingLayoutInstanceInfoActivity;
mAdminsRecyclerView = mInstanceInfoActivityViewBinding.recyclerViewAdminsInstanceInfoActivity;
mUsersTextView = mInstanceInfoActivityViewBinding.registeredUserCountTextViewInstanceInfoActivity;
mCommunitiesTextView = mInstanceInfoActivityViewBinding.communityCountInstanceInfoActivity;
mPostsTextView = mInstanceInfoActivityViewBinding.postCountTextViewInstanceInfoActivity;
mCommentsTextView = mInstanceInfoActivityViewBinding.commentCountTextViewInstanceInfoActivity;
mActiveUsersTextView = mInstanceInfoActivityViewBinding.activeUserCountTextViewInstanceInfoActivity;
mUsersImageView = mInstanceInfoActivityViewBinding.registeredUserCountImageViewInstanceInfoActivity;
mCommunitiesImageView = mInstanceInfoActivityViewBinding.communitiesIconImageViewInstanceInfoActivity;
mPostsImageView = mInstanceInfoActivityViewBinding.postCountImageViewInstanceInfoActivity;
mCommentsImageView = mInstanceInfoActivityViewBinding.commentCountImageViewInstanceInfoActivity;
mActiveUsersImageView = mInstanceInfoActivityViewBinding.activeUserCountImageViewInstanceInfoActivity;
}
@Override
protected SharedPreferences getDefaultSharedPreferences() {
return mSharedPreferences;
}
@Override
protected CustomThemeWrapper getCustomThemeWrapper() {
return mCustomThemeWrapper;
}
@Override
protected void applyCustomTheme() {
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, null, toolbar);
mStatisticsCardView.setCardBackgroundColor(mCustomThemeWrapper.getCardViewBackgroundColor());
mDescriptionCardView.setCardBackgroundColor(mCustomThemeWrapper.getCardViewBackgroundColor());
mAdminsCardView.setCardBackgroundColor(mCustomThemeWrapper.getCardViewBackgroundColor());
mUsersImageView.setColorFilter(mCustomThemeWrapper.getPrimaryTextColor(), PorterDuff.Mode.SRC_IN);
mCommunitiesImageView.setColorFilter(mCustomThemeWrapper.getPrimaryTextColor(), PorterDuff.Mode.SRC_IN);
mPostsImageView.setColorFilter(mCustomThemeWrapper.getPrimaryTextColor(), PorterDuff.Mode.SRC_IN);
mCommentsImageView.setColorFilter(mCustomThemeWrapper.getPrimaryTextColor(), PorterDuff.Mode.SRC_IN);
mActiveUsersImageView.setColorFilter(mCustomThemeWrapper.getPrimaryTextColor(), PorterDuff.Mode.SRC_IN);
mUsersTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
mCommunitiesTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
mPostsTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
mCommentsTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
mActiveUsersTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == android.R.id.home) {
finish();
return true;
}
return false;
}
}

View File

@@ -7,6 +7,7 @@ import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.webkit.URLUtil;
import android.widget.Toast;
@@ -17,8 +18,11 @@ import androidx.browser.customtabs.CustomTabsService;
import org.apache.commons.io.FilenameUtils;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Executor;
import javax.inject.Inject;
import javax.inject.Named;
@@ -29,8 +33,10 @@ import eu.toldi.infinityforlemmy.RetrofitHolder;
import eu.toldi.infinityforlemmy.comment.Comment;
import eu.toldi.infinityforlemmy.comment.FetchComment;
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
import eu.toldi.infinityforlemmy.post.FetchPost;
import eu.toldi.infinityforlemmy.post.ObjectResolver;
import eu.toldi.infinityforlemmy.post.Post;
import eu.toldi.infinityforlemmy.post.enrich.PostEnricher;
import eu.toldi.infinityforlemmy.utils.LemmyUtils;
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
@@ -75,6 +81,12 @@ public class LinkResolverActivity extends AppCompatActivity {
@Named("no_oauth")
RetrofitHolder mRetrofit;
@Inject
Executor mExecutor;
@Inject
PostEnricher postEnricher;
private String mAccessToken;
private Uri getRedditUriByPath(String path) {
@@ -94,20 +106,23 @@ public class LinkResolverActivity extends AppCompatActivity {
if (mAccessToken != null) {
String instance = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_INSTANCE, null);
mRetrofit.setBaseURL(instance);
if (mCurrentAccountSharedPreferences.getBoolean(SharedPreferencesUtils.BEARER_TOKEN_AUTH, true)) {
mRetrofit.setAccessToken(mAccessToken);
}
}
Uri uri = getIntent().getData();
if (uri == null) {
String url = getIntent().getStringExtra(Intent.EXTRA_TEXT);
if (!URLUtil.isValidUrl(url)) {
Toast.makeText(this, R.string.invalid_link, Toast.LENGTH_SHORT).show();
Toast.makeText(getApplicationContext(), R.string.invalid_link, Toast.LENGTH_SHORT).show();
finish();
return;
}
try {
uri = Uri.parse(url);
} catch (NullPointerException e) {
Toast.makeText(this, R.string.invalid_link, Toast.LENGTH_SHORT).show();
Toast.makeText(getApplicationContext(), R.string.invalid_link, Toast.LENGTH_SHORT).show();
finish();
return;
}
@@ -115,7 +130,7 @@ public class LinkResolverActivity extends AppCompatActivity {
if (uri.getScheme() == null && uri.getHost() == null) {
if (uri.toString().isEmpty()) {
Toast.makeText(this, R.string.invalid_link, Toast.LENGTH_SHORT).show();
Toast.makeText(getApplicationContext(), R.string.invalid_link, Toast.LENGTH_SHORT).show();
finish();
return;
}
@@ -127,7 +142,7 @@ public class LinkResolverActivity extends AppCompatActivity {
private void handleUri(Uri uri) {
if (uri == null) {
Toast.makeText(this, R.string.no_link_available, Toast.LENGTH_SHORT).show();
Toast.makeText(getApplicationContext(), R.string.no_link_available, Toast.LENGTH_SHORT).show();
} else {
String path = uri.getPath();
if (path == null) {
@@ -201,23 +216,52 @@ public class LinkResolverActivity extends AppCompatActivity {
intent.putExtra(ViewPostDetailActivity.EXTRA_NEW_ACCOUNT_NAME, newAccountName);
startActivity(intent);
} else {
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);
}
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) {
@Override
public void onResolveObjectFailed() {
Toast.makeText(LinkResolverActivity.this, R.string.could_not_resolve_link, Toast.LENGTH_SHORT).show();
finish();
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 (!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) {
@@ -237,30 +281,61 @@ public class LinkResolverActivity extends AppCompatActivity {
@Override
public void onFetchCommentFailed() {
Toast.makeText(LinkResolverActivity.this, R.string.could_not_resolve_link, Toast.LENGTH_SHORT).show();
Toast.makeText(getApplicationContext(), R.string.could_not_resolve_link, Toast.LENGTH_SHORT).show();
finish();
}
});
} else {
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);
}
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 onResolveObjectFailed() {
Toast.makeText(LinkResolverActivity.this, R.string.could_not_resolve_link, Toast.LENGTH_SHORT).show();
finish();
@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_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);

View File

@@ -8,7 +8,6 @@ import android.os.Bundle;
import android.os.Handler;
import android.text.Editable;
import android.util.Log;
import android.util.Patterns;
import android.view.InflateException;
import android.view.MenuItem;
import android.widget.Button;
@@ -180,6 +179,7 @@ public class LoginActivity extends BaseActivity {
try {
JSONObject responseJSON = new JSONObject(accountResponse);
String accessToken = responseJSON.getString("jwt");
mRetrofit.setAccessToken(null);
FetchMyInfo.fetchAccountInfo(mRetrofit.getRetrofit(), mRedditDataRoomDatabase, username,
accessToken, new FetchMyInfo.FetchMyInfoListener() {
@@ -189,13 +189,23 @@ public class LoginActivity extends BaseActivity {
@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(),
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();
}
}
}
@Override

View File

@@ -336,11 +336,14 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
fragmentManager = getSupportFragmentManager();
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
if (mCurrentAccountSharedPreferences.getBoolean(SharedPreferencesUtils.BEARER_TOKEN_AUTH, true)) {
mRetrofit.setAccessToken(mAccessToken);
}
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null);
mAccountQualifiedName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_QUALIFIED_NAME, null);
String instance = (mAccessToken == null) ? mSharedPreferences.getString(SharedPreferencesUtils.ANONYMOUS_ACCOUNT_INSTANCE, APIUtils.API_BASE_URI) : mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_INSTANCE, null);
if(instance != null) {
if (instance != null) {
mRetrofit.setBaseURL(instance);
}
@@ -365,7 +368,8 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
super.onResume();
if (mAccessToken == null) {
String instancePreference = mSharedPreferences.getString(SharedPreferencesUtils.ANONYMOUS_ACCOUNT_INSTANCE, APIUtils.API_BASE_URI);
if (!mRetrofit.getBaseURL().equalsIgnoreCase(instancePreference)) {
if (!instancePreference.startsWith(mRetrofit.getBaseURL())) {
mRetrofit.setBaseURL(instancePreference);
this.recreate();
}
}
@@ -882,9 +886,11 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
});
} else if (stringId == R.string.anonymous_account_instance) {
changeAnonymousAccountInstance();
} else if (stringId == R.string.blocks) {
intent = new Intent(MainActivity.this, BlockedThingListingActivity.class);
}
} else if (stringId == R.string.blocks) {
intent = new Intent(MainActivity.this, BlockedThingListingActivity.class);
} else if (stringId == R.string.instance_info) {
intent = new Intent(MainActivity.this, InstanceInfoActivity.class);
}
if (intent != null) {
startActivity(intent);
}
@@ -1011,12 +1017,12 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
sectionsPagerAdapter.setSubscribedSubreddits(subscribedSubredditData);
}
});
/*subscribedSubredditViewModel.getAllFavoriteSubscribedSubreddits().observe(this, subscribedSubredditData -> {
subscribedSubredditViewModel.getAllFavoriteSubscribedSubreddits().observe(this, subscribedSubredditData -> {
adapter.setFavoriteSubscribedSubreddits(subscribedSubredditData);
if (mShowFavoriteSubscribedSubreddits && sectionsPagerAdapter != null) {
sectionsPagerAdapter.setFavoriteSubscribedSubreddits(subscribedSubredditData);
}
});*/
});
accountViewModel = new ViewModelProvider(this,
new AccountViewModel.Factory(mRedditDataRoomDatabase)).get(AccountViewModel.class);
@@ -1508,7 +1514,12 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
if (i == EditorInfo.IME_ACTION_DONE) {
Utils.hideKeyboard(this);
Intent subredditIntent = new Intent(this, ViewSubredditDetailActivity.class);
subredditIntent.putExtra(ViewSubredditDetailActivity.EXTRA_COMMUNITY_FULL_NAME_KEY, thingEditText.getText().toString());
String communityName = thingEditText.getText().toString();
if (communityName.startsWith("!")) {
communityName = communityName.substring(1);
}
subredditIntent.putExtra(ViewSubredditDetailActivity.EXTRA_COMMUNITY_FULL_NAME_KEY, communityName);
startActivity(subredditIntent);
return true;
}
@@ -1566,7 +1577,11 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
-> {
Utils.hideKeyboard(this);
Intent subredditIntent = new Intent(this, ViewSubredditDetailActivity.class);
subredditIntent.putExtra(ViewSubredditDetailActivity.EXTRA_COMMUNITY_FULL_NAME_KEY, thingEditText.getText().toString());
String communityName = thingEditText.getText().toString();
if (communityName.startsWith("!")) {
communityName = communityName.substring(1);
}
subredditIntent.putExtra(ViewSubredditDetailActivity.EXTRA_COMMUNITY_FULL_NAME_KEY, communityName);
startActivity(subredditIntent);
})
.setNegativeButton(R.string.cancel, (dialogInterface, i) -> {
@@ -1587,7 +1602,11 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
if (i == EditorInfo.IME_ACTION_DONE) {
Utils.hideKeyboard(this);
Intent userIntent = new Intent(this, ViewUserDetailActivity.class);
userIntent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, thingEditText.getText().toString());
String qualifiedName = thingEditText.getText().toString();
if (qualifiedName.startsWith("@")) {
qualifiedName = qualifiedName.substring(1);
}
userIntent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, qualifiedName);
startActivity(userIntent);
return true;
}
@@ -1600,7 +1619,11 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
-> {
Utils.hideKeyboard(this);
Intent userIntent = new Intent(this, ViewUserDetailActivity.class);
userIntent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, thingEditText.getText().toString());
String qualifiedName = thingEditText.getText().toString();
if (qualifiedName.startsWith("@")) {
qualifiedName = qualifiedName.substring(1);
}
userIntent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, qualifiedName);
startActivity(userIntent);
})
.setNegativeButton(R.string.cancel, (dialogInterface, i) -> {

View File

@@ -214,7 +214,7 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
mGlide = Glide.with(this);
mGlide = Glide.with(getApplication());
mPostingSnackbar = Snackbar.make(coordinatorLayout, R.string.posting, Snackbar.LENGTH_INDEFINITE);
@@ -504,7 +504,7 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee
}
private void loadSubredditIcon() {
LoadSubredditIcon.loadSubredditIcon(mExecutor, new Handler(), mRedditDataRoomDatabase, subredditName, mAccessToken, mOauthRetrofit, mRetrofit.getRetrofit(), iconImageUrl -> {
LoadSubredditIcon.loadSubredditIcon(mExecutor, new Handler(), mRedditDataRoomDatabase, subredditName, mAccessToken, mRetrofit.getRetrofit(), iconImageUrl -> {
iconUrl = iconImageUrl;
displaySubredditIcon();
loadSubredditIconSuccessful = true;

View File

@@ -228,7 +228,7 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
mGlide = Glide.with(this);
mGlide = Glide.with(getApplication());
mPostingSnackbar = Snackbar.make(coordinatorLayout, R.string.posting, Snackbar.LENGTH_INDEFINITE);
@@ -475,6 +475,8 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
nsfwTextView.setTextColor(primaryTextColor);
titleEditText.setTextColor(primaryTextColor);
titleEditText.setHintTextColor(secondaryTextColor);
contentEditText.setTextColor(primaryTextColor);
contentEditText.setHintTextColor(secondaryTextColor);
boolean circleFab = mSharedPreferences.getBoolean(SharedPreferencesUtils.USE_CIRCULAR_FAB, false);
applyFABTheme(captureFab, circleFab);
applyFABTheme(selectFromLibraryFab, circleFab);
@@ -487,6 +489,10 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
titleEditText.setTypeface(typeface);
selectAgainTextView.setTypeface(typeface);
}
if (contentTypeface != null) {
contentEditText.setTypeface(contentTypeface);
}
}
private void loadImage() {
@@ -511,7 +517,7 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
}
private void loadSubredditIcon() {
LoadSubredditIcon.loadSubredditIcon(mExecutor, new Handler(), mRedditDataRoomDatabase, communityData.getQualified_name(), mAccessToken, mOauthRetrofit, mRetrofit.getRetrofit(), iconImageUrl -> {
LoadSubredditIcon.loadSubredditIcon(mExecutor, new Handler(), mRedditDataRoomDatabase, communityData.getQualified_name(), mAccessToken, mRetrofit.getRetrofit(), iconImageUrl -> {
iconUrl = iconImageUrl;
displaySubredditIcon();
loadSubredditIconSuccessful = true;

View File

@@ -217,7 +217,7 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
mGlide = Glide.with(this);
mGlide = Glide.with(getApplication());
mPostingSnackbar = Snackbar.make(coordinatorLayout, R.string.posting, Snackbar.LENGTH_INDEFINITE);
@@ -458,6 +458,8 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
titleEditText.setHintTextColor(secondaryTextColor);
suggestTitleButton.setBackgroundColor(mCustomThemeWrapper.getColorPrimaryLightTheme());
suggestTitleButton.setTextColor(mCustomThemeWrapper.getButtonTextColor());
contentEditText.setTextColor(primaryTextColor);
contentEditText.setHintTextColor(secondaryTextColor);
linkEditText.setTextColor(primaryTextColor);
linkEditText.setHintTextColor(secondaryTextColor);
if (typeface != null) {
@@ -470,6 +472,7 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
}
if (contentTypeface != null) {
linkEditText.setTypeface(contentTypeface);
contentEditText.setTypeface(contentTypeface);
}
}
@@ -489,7 +492,7 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
private void loadSubredditIcon() {
LoadSubredditIcon.loadSubredditIcon(mExecutor, new Handler(), mRedditDataRoomDatabase, communityData.getQualified_name(),
mAccessToken, mOauthRetrofit, mRetrofit.getRetrofit(), iconImageUrl -> {
mAccessToken, mRetrofit.getRetrofit(), iconImageUrl -> {
iconUrl = iconImageUrl;
displaySubredditIcon();
loadSubredditIconSuccessful = true;

View File

@@ -219,7 +219,7 @@ public class PostPollActivity extends BaseActivity implements FlairBottomSheetFr
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
mGlide = Glide.with(this);
mGlide = Glide.with(getApplication());
mPostingSnackbar = Snackbar.make(coordinatorLayout, R.string.posting, Snackbar.LENGTH_INDEFINITE);
@@ -500,7 +500,7 @@ public class PostPollActivity extends BaseActivity implements FlairBottomSheetFr
}
private void loadSubredditIcon() {
LoadSubredditIcon.loadSubredditIcon(mExecutor, new Handler(), mRedditDataRoomDatabase, subredditName, mAccessToken, mOauthRetrofit, mRetrofit.getRetrofit(), iconImageUrl -> {
LoadSubredditIcon.loadSubredditIcon(mExecutor, new Handler(), mRedditDataRoomDatabase, subredditName, mAccessToken, mRetrofit.getRetrofit(), iconImageUrl -> {
iconUrl = iconImageUrl;
displaySubredditIcon();
loadSubredditIconSuccessful = true;

View File

@@ -208,7 +208,7 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
mGlide = Glide.with(this);
mGlide = Glide.with(getApplication());
mPostingSnackbar = Snackbar.make(coordinatorLayout, R.string.posting, Snackbar.LENGTH_INDEFINITE);
@@ -451,11 +451,11 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
private void loadSubredditIcon() {
LoadSubredditIcon.loadSubredditIcon(mExecutor, new Handler(), mRedditDataRoomDatabase, communityData.getQualified_name(),
mAccessToken, mOauthRetrofit, mRetrofit.getRetrofit(), iconImageUrl -> {
iconUrl = iconImageUrl;
displaySubredditIcon();
loadSubredditIconSuccessful = true;
});
mAccessToken, mRetrofit.getRetrofit(), iconImageUrl -> {
iconUrl = iconImageUrl;
displaySubredditIcon();
loadSubredditIconSuccessful = true;
});
}
private void promptAlertDialog(int titleResId, int messageResId) {

View File

@@ -216,7 +216,7 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
mGlide = Glide.with(this);
mGlide = Glide.with(getApplication());
player = new ExoPlayer.Builder(this).build();
videoPlayerView.setPlayer(player);
@@ -486,11 +486,11 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
private void loadSubredditIcon() {
LoadSubredditIcon.loadSubredditIcon(mExecutor, new Handler(), mRedditDataRoomDatabase, subredditName,
mAccessToken, mOauthRetrofit, mRetrofit.getRetrofit(), iconImageUrl -> {
iconUrl = iconImageUrl;
displaySubredditIcon();
loadSubredditIconSuccessful = true;
});
mAccessToken, mRetrofit.getRetrofit(), iconImageUrl -> {
iconUrl = iconImageUrl;
displaySubredditIcon();
loadSubredditIconSuccessful = true;
});
}
private void promptAlertDialog(int titleResId, int messageResId) {

View File

@@ -433,12 +433,14 @@ public class SearchActivity extends BaseActivity {
if (resultCode == RESULT_OK && data != null) {
if (requestCode == SUBREDDIT_SELECTION_REQUEST_CODE) {
communityData = data.getParcelableExtra(SubredditSelectionActivity.EXTRA_RETURN_COMMUNITY_DATA);
subredditName = communityData.getName();
subredditIsUser = false;
if (subredditName == null) {
if (communityData == null) {
subredditNameTextView.setText(R.string.all_communities);
} else {
subredditName = communityData.getName();
communityQualifiedName = communityData.getQualified_name();
subredditNameTextView.setText(subredditName);
}
} else if (requestCode == SUBREDDIT_SEARCH_REQUEST_CODE) {

View File

@@ -204,7 +204,7 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
mGlide = Glide.with(this);
mGlide = Glide.with(getApplication());
mPostingSnackbar = Snackbar.make(coordinatorLayout, R.string.posting, Snackbar.LENGTH_INDEFINITE);
@@ -499,11 +499,11 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom
private void loadSubredditIcon() {
LoadSubredditIcon.loadSubredditIcon(mExecutor, new Handler(), mRedditDataRoomDatabase, subredditName,
mAccessToken, mOauthRetrofit, mRetrofit.getRetrofit(), iconImageUrl -> {
iconUrl = iconImageUrl;
displaySubredditIcon();
loadSubredditIconSuccessful = true;
});
mAccessToken, mRetrofit.getRetrofit(), iconImageUrl -> {
iconUrl = iconImageUrl;
displaySubredditIcon();
loadSubredditIconSuccessful = true;
});
}
private void promptAlertDialog(int titleResId, int messageResId) {

View File

@@ -127,7 +127,7 @@ public class SubredditMultiselectionActivity extends BaseActivity implements Act
setSupportActionBar(mToolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
mGlide = Glide.with(this);
mGlide = Glide.with(getApplication());
mSwipeRefreshLayout.setEnabled(false);

View File

@@ -152,7 +152,7 @@ public class TrendingActivity extends BaseActivity {
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
mGlide = Glide.with(this);
mGlide = Glide.with(getApplication());
DisplayMetrics displayMetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
@@ -201,7 +201,7 @@ public class TrendingActivity extends BaseActivity {
isRefreshing = true;
errorLinearLayout.setVisibility(View.GONE);
Glide.with(this).clear(errorImageView);
Glide.with(getApplication()).clear(errorImageView);
swipeRefreshLayout.setRefreshing(true);
trendingSearches = null;
adapter.setTrendingSearches(null);

View File

@@ -78,6 +78,7 @@ import eu.toldi.infinityforlemmy.font.TitleFontStyle;
import eu.toldi.infinityforlemmy.services.DownloadMediaService;
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
import eu.toldi.infinityforlemmy.utils.Utils;
import okhttp3.OkHttpClient;
public class ViewImageOrGifActivity extends AppCompatActivity implements SetAsWallpaperCallback, CustomFontReceiver {
@@ -108,6 +109,9 @@ public class ViewImageOrGifActivity extends AppCompatActivity implements SetAsWa
@Named("default")
SharedPreferences mSharedPreferences;
@Inject
@Named("glide")
OkHttpClient okHttpClient;
@Inject
Executor mExecutor;
private boolean isActionBarHidden = false;
private boolean isDownloading = false;
@@ -146,7 +150,7 @@ public class ViewImageOrGifActivity extends AppCompatActivity implements SetAsWa
getTheme().applyStyle(ContentFontFamily.valueOf(mSharedPreferences
.getString(SharedPreferencesUtils.CONTENT_FONT_FAMILY_KEY, ContentFontFamily.Default.name())).getResId(), true);
BigImageViewer.initialize(GlideImageLoader.with(this.getApplicationContext()));
BigImageViewer.initialize(GlideImageLoader.with(this.getApplicationContext(), okHttpClient));
setContentView(R.layout.activity_view_image_or_gif);
@@ -161,7 +165,7 @@ public class ViewImageOrGifActivity extends AppCompatActivity implements SetAsWa
Slidr.attach(this, new SlidrConfig.Builder().position(SlidrPosition.VERTICAL).distanceThreshold(0.125f).build());
}
glide = Glide.with(this);
glide = Glide.with(getApplication());
handler = new Handler();

View File

@@ -67,6 +67,7 @@ import eu.toldi.infinityforlemmy.SaveComment;
import eu.toldi.infinityforlemmy.SaveThing;
import eu.toldi.infinityforlemmy.SortType;
import eu.toldi.infinityforlemmy.SortTypeSelectionCallback;
import eu.toldi.infinityforlemmy.apis.LemmyAPI;
import eu.toldi.infinityforlemmy.apis.RedditAPI;
import eu.toldi.infinityforlemmy.asynctasks.SwitchAccount;
import eu.toldi.infinityforlemmy.comment.Comment;
@@ -81,10 +82,12 @@ import eu.toldi.infinityforlemmy.post.HistoryPostPagingSource;
import eu.toldi.infinityforlemmy.post.ParsePost;
import eu.toldi.infinityforlemmy.post.Post;
import eu.toldi.infinityforlemmy.post.PostPagingSource;
import eu.toldi.infinityforlemmy.post.enrich.PostEnricher;
import eu.toldi.infinityforlemmy.postfilter.PostFilter;
import eu.toldi.infinityforlemmy.readpost.ReadPost;
import eu.toldi.infinityforlemmy.utils.APIUtils;
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
import okhttp3.OkHttpClient;
import retrofit2.Call;
import retrofit2.Response;
import retrofit2.Retrofit;
@@ -147,6 +150,11 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
CustomThemeWrapper mCustomThemeWrapper;
@Inject
Executor mExecutor;
@Inject
@Named("glide")
OkHttpClient okHttpClient;
@Inject
PostEnricher postEnricher;
@State
ArrayList<Post> posts;
@State
@@ -181,6 +189,8 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
private SectionsPagerAdapter sectionsPagerAdapter;
private String mAccessToken;
private String mAccountName;
private String mAccountQalifiedName;
private long postFragmentId;
private int postListPosition;
private int orientation;
@@ -193,7 +203,7 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
super.onCreate(savedInstanceState);
BigImageViewer.initialize(GlideImageLoader.with(this.getApplicationContext()));
BigImageViewer.initialize(GlideImageLoader.with(this.getApplicationContext(), okHttpClient));
setContentView(R.layout.activity_view_post_detail);
@@ -269,6 +279,7 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null);
mAccountQalifiedName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_QUALIFIED_NAME, null);
mVolumeKeysNavigateComments = mSharedPreferences.getBoolean(SharedPreferencesUtils.VOLUME_KEYS_NAVIGATE_COMMENTS, false);
@@ -353,8 +364,8 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
private void checkNewAccountAndBindView(Bundle savedInstanceState) {
if (mNewAccountName != null) {
if (mAccountName == null || !mAccountName.equals(mNewAccountName)) {
SwitchAccount.switchAccount(mRedditDataRoomDatabase,mRetrofit, mCurrentAccountSharedPreferences,
if (mAccountName == null || !mAccountQalifiedName.equals(mNewAccountName)) {
SwitchAccount.switchAccount(mRedditDataRoomDatabase, mRetrofit, mCurrentAccountSharedPreferences,
mExecutor, new Handler(), mNewAccountName, newAccount -> {
EventBus.getDefault().post(new SwitchAccountEvent(getClass().getName()));
Toast.makeText(this, R.string.account_switched, Toast.LENGTH_SHORT).show();
@@ -523,69 +534,38 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
Handler handler = new Handler(Looper.getMainLooper());
if (postType != HistoryPostPagingSource.TYPE_READ_POSTS) {
int nextPage = posts.size() / 25 + 1;
mExecutor.execute(() -> {
RedditAPI api = (mAccessToken == null ? mRetrofit.getRetrofit() : mOauthRetrofit).create(RedditAPI.class);
LemmyAPI api = mRetrofit.getRetrofit().create(LemmyAPI.class);
Call<String> call;
String afterKey = posts.isEmpty() ? null : posts.get(posts.size() - 1).getFullName();
switch (postType) {
case PostPagingSource.TYPE_SUBREDDIT:
if (mAccessToken == null) {
call = api.getSubredditBestPosts(subredditName, sortType, sortTime, afterKey);
} else {
call = api.getSubredditBestPostsOauth(subredditName, sortType,
sortTime, afterKey, APIUtils.getOAuthHeader(mAccessToken));
}
call = api.getPosts(null, sortType.value, nextPage, 25, null, post.getSubredditNamePrefixed(), false, mAccessToken);
break;
case PostPagingSource.TYPE_USER:
if (mAccessToken == null) {
call = api.getUserPosts(username, afterKey, sortType, sortTime);
} else {
call = api.getUserPostsOauth(username, userWhere, afterKey, sortType,
sortTime, APIUtils.getOAuthHeader(mAccessToken));
}
call = api.getUserPosts(username, sortType.value, nextPage, 25, false, mAccessToken);
break;
case PostPagingSource.TYPE_SEARCH:
if (subredditName == null) {
if (mAccessToken == null) {
call = api.searchPosts(query, afterKey, sortType, sortTime,
trendingSource);
} else {
call = api.searchPostsOauth(query, afterKey, sortType,
sortTime, trendingSource, APIUtils.getOAuthHeader(mAccessToken));
}
} else {
if (mAccessToken == null) {
call = api.searchPostsInSpecificSubreddit(subredditName, query,
sortType, sortTime, afterKey);
} else {
call = api.searchPostsInSpecificSubredditOauth(subredditName, query,
sortType, sortTime, afterKey,
APIUtils.getOAuthHeader(mAccessToken));
}
}
call = api.search(query, null, subredditName, null, "Post", sortType.value, "All", nextPage, 25, mAccessToken);
break;
case PostPagingSource.TYPE_MULTI_REDDIT:
if (mAccessToken == null) {
call = api.getMultiRedditPosts(multiPath, afterKey, sortTime);
} else {
call = api.getMultiRedditPostsOauth(multiPath, afterKey,
sortTime, APIUtils.getOAuthHeader(mAccessToken));
}
break;
// TODO: Implement multi community
case PostPagingSource.TYPE_ANONYMOUS_FRONT_PAGE:
//case PostPagingSource.TYPE_ANONYMOUS_MULTIREDDIT
call = api.getSubredditBestPosts(subredditName, sortType, sortTime, afterKey);
break;
// TODO: Implement anonymous front page
default:
call = api.getBestPosts(sortType, sortTime, afterKey,
APIUtils.getOAuthHeader(mAccessToken));
String type = (subredditName.equals("all")) ? "All" : (subredditName.equals("local")) ? "Local" : "Subscribed";
call = api.getPosts(type, sortType.value, nextPage, 25, null, null, false, mAccessToken);
}
try {
Response<String> response = call.execute();
if (response.isSuccessful()) {
String responseString = response.body();
LinkedHashSet<Post> newPosts = ParsePost.parsePostsSync(responseString, -1, postFilter, readPostList);
LinkedHashSet<Post> newPosts = ParsePost.parsePostsSync(responseString, -1, postFilter, readPostList, postEnricher);
if (newPosts == null) {
handler.post(() -> {
loadingMorePostsStatus = LoadingMorePostsStatus.NO_MORE_POSTS;
@@ -667,7 +647,7 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
Response<String> response = historyPosts.execute();
if (response.isSuccessful()) {
String responseString = response.body();
LinkedHashSet<Post> newPosts = ParsePost.parsePostsSync(responseString, -1, postFilter, null);
LinkedHashSet<Post> newPosts = ParsePost.parsePostsSync(responseString, -1, postFilter, null, postEnricher);
if (newPosts == null || newPosts.isEmpty()) {
handler.post(() -> {
loadingMorePostsStatus = LoadingMorePostsStatus.NO_MORE_POSTS;

View File

@@ -27,6 +27,7 @@ import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
@@ -184,6 +185,9 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
@BindView(R.id.comment_count_image_view_view_subreddit_detail_activity)
ImageView nCommentsImageView;
@BindView(R.id.community_statistics_block_view_subreddit_detail_activity)
ConstraintLayout communityStatisticsBlock;
@BindView(R.id.description_text_view_view_subreddit_detail_activity)
TextView descriptionTextView;
@@ -257,6 +261,8 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
private int fabOption;
private MaterialAlertDialogBuilder nsfwWarningBuilder;
private boolean showStatistics;
private boolean hideSubredditDescription;
@Override
@@ -270,6 +276,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
ButterKnife.bind(this);
hideFab = mSharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_FAB_IN_POST_FEED, false);
showStatistics = mSharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_STATISTICS, true);
showBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.BOTTOM_APP_BAR_KEY, false);
navigationWrapper = new NavigationWrapper(findViewById(R.id.bottom_app_bar_bottom_app_bar), findViewById(R.id.linear_layout_bottom_app_bar),
findViewById(R.id.option_1_bottom_app_bar), findViewById(R.id.option_2_bottom_app_bar),
@@ -506,7 +513,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
setSupportActionBar(toolbar);
setToolbarGoToTop(toolbar);
glide = Glide.with(this);
glide = Glide.with(getApplication());
Locale locale = getResources().getConfiguration().locale;
MarkwonPlugin miscPlugin = new AbstractMarkwonPlugin() {
@@ -592,17 +599,11 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
String nSubscribers = getString(R.string.subscribers_number_detail, subredditData.getNSubscribers());
nSubscribersTextView.setText(nSubscribers);
if (mCommunityStats != null) {
if (mCommunityStats != null && showStatistics) {
communityStatisticsBlock.setVisibility(View.VISIBLE);
nActiveUsersTextView.setText(getString(R.string.active_users_number_detail, mCommunityStats.getActiveUsers()));
nPostsTextView.setText(getString(R.string.post_count_detail, mCommunityStats.getPosts()));
nCommentsTextView.setText(getString(R.string.comment_count_detail, mCommunityStats.getComments()));
} else {
nActiveUsersTextView.setVisibility(View.GONE);
nPostsTextView.setVisibility(View.GONE);
nCommentsTextView.setVisibility(View.GONE);
nActiveUsersImageView.setVisibility(View.GONE);
nPostsImageView.setVisibility(View.GONE);
nCommentsImageView.setVisibility(View.GONE);
}
description = subredditData.getDescription();
@@ -1517,7 +1518,11 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
if (i == EditorInfo.IME_ACTION_DONE) {
Utils.hideKeyboard(this);
Intent subredditIntent = new Intent(this, ViewSubredditDetailActivity.class);
subredditIntent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, thingEditText.getText().toString());
String communityName = thingEditText.getText().toString();
if (communityName.startsWith("!")) {
communityName = communityName.substring(1);
}
subredditIntent.putExtra(ViewSubredditDetailActivity.EXTRA_COMMUNITY_FULL_NAME_KEY, communityName);
startActivity(subredditIntent);
return true;
}
@@ -1575,7 +1580,11 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
-> {
Utils.hideKeyboard(this);
Intent subredditIntent = new Intent(this, ViewSubredditDetailActivity.class);
subredditIntent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, thingEditText.getText().toString());
String communityName = thingEditText.getText().toString();
if (communityName.startsWith("!")) {
communityName = communityName.substring(1);
}
subredditIntent.putExtra(ViewSubredditDetailActivity.EXTRA_COMMUNITY_FULL_NAME_KEY, communityName);
startActivity(subredditIntent);
})
.setNegativeButton(R.string.cancel, (dialogInterface, i) -> {
@@ -1596,7 +1605,11 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
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());
String qualifiedName = thingEditText.getText().toString();
if (qualifiedName.startsWith("@")) {
qualifiedName = qualifiedName.substring(1);
}
userIntent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, qualifiedName);
startActivity(userIntent);
return true;
}
@@ -1609,7 +1622,11 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
-> {
Utils.hideKeyboard(this);
Intent userIntent = new Intent(this, ViewUserDetailActivity.class);
userIntent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, thingEditText.getText().toString());
String qualifiedName = thingEditText.getText().toString();
if (qualifiedName.startsWith("@")) {
qualifiedName = qualifiedName.substring(1);
}
userIntent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, qualifiedName);
startActivity(userIntent);
})
.setNegativeButton(R.string.cancel, (dialogInterface, i) -> {
@@ -1690,6 +1707,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
bundle.putString(SidebarFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
bundle.putString(SidebarFragment.EXTRA_SUBREDDIT_NAME, communityName);
bundle.putString(SidebarFragment.EXTRA_COMMUNITY_QUALIFIED_NAME, qualifiedName);
bundle.putBoolean(SidebarFragment.EXTRA_SHOW_STATISTICS, !showStatistics);
fragment.setArguments(bundle);
return fragment;
}

View File

@@ -29,6 +29,7 @@ import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
@@ -197,9 +198,17 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
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;
@BindView(R.id.user_statistics_block_view_user_detail_activity)
ConstraintLayout userStatisticsBlock;
@BindView(R.id.cake_day_text_view_view_user_detail_activity)
TextView cakedayTextView;
@BindView(R.id.description_text_view_view_user_detail_activity)
@@ -250,6 +259,9 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
private String qualifiedName;
private String description;
private boolean showStatistics;
private boolean showScore;
private boolean subscriptionReady = false;
private boolean mFetchUserInfoSuccess = false;
private int expandedTabTextColor;
@@ -314,6 +326,8 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
mAccountQualifiedName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_QUALIFIED_NAME, null);
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);
@@ -434,7 +448,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
});
}
glide = Glide.with(this);
glide = Glide.with(getApplication());
Locale locale = getResources().getConfiguration().locale;
MarkwonPlugin miscPlugin = new AbstractMarkwonPlugin() {
@@ -614,11 +628,19 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
cakedayTextView.setText((String) userData.getCakeday());
UserStats userStats = mUserData.getStats();
if (userStats != null) {
if (userStats != null && showStatistics) {
userStatisticsBlock.setVisibility(View.VISIBLE);
postCountTextView.setText(String.valueOf(userStats.getPostCount()));
commentCountTextView.setText(String.valueOf(userStats.getCommentCount()));
upvoteCountPostTextView.setText(String.valueOf(userStats.getPostScore()));
upvoteCountCommentTextView.setText(String.valueOf(userStats.getCommentScore()));
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);
}
}
if (userData.getDescription() == null || userData.getDescription().equals("")) {
@@ -1492,7 +1514,11 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
if (i == EditorInfo.IME_ACTION_DONE) {
Utils.hideKeyboard(this);
Intent subredditIntent = new Intent(this, ViewSubredditDetailActivity.class);
subredditIntent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, thingEditText.getText().toString());
String communityName = thingEditText.getText().toString();
if (communityName.startsWith("!")) {
communityName = communityName.substring(1);
}
subredditIntent.putExtra(ViewSubredditDetailActivity.EXTRA_COMMUNITY_FULL_NAME_KEY, communityName);
startActivity(subredditIntent);
return true;
}
@@ -1550,7 +1576,11 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
-> {
Utils.hideKeyboard(this);
Intent subredditIntent = new Intent(this, ViewSubredditDetailActivity.class);
subredditIntent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, thingEditText.getText().toString());
String communityName = thingEditText.getText().toString();
if (communityName.startsWith("!")) {
communityName = communityName.substring(1);
}
subredditIntent.putExtra(ViewSubredditDetailActivity.EXTRA_COMMUNITY_FULL_NAME_KEY, communityName);
startActivity(subredditIntent);
})
.setNegativeButton(R.string.cancel, (dialogInterface, i) -> {
@@ -1571,7 +1601,11 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
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());
String userName = thingEditText.getText().toString();
if (userName.startsWith("@")) {
userName = userName.substring(1);
}
userIntent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, userName);
startActivity(userIntent);
return true;
}
@@ -1584,7 +1618,11 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
-> {
Utils.hideKeyboard(this);
Intent userIntent = new Intent(this, ViewUserDetailActivity.class);
userIntent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, thingEditText.getText().toString());
String userName = thingEditText.getText().toString();
if (userName.startsWith("@")) {
userName = userName.substring(1);
}
userIntent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, userName);
startActivity(userIntent);
})
.setNegativeButton(R.string.cancel, (dialogInterface, i) -> {

View File

@@ -108,6 +108,7 @@ import eu.toldi.infinityforlemmy.font.TitleFontFamily;
import eu.toldi.infinityforlemmy.font.TitleFontStyle;
import eu.toldi.infinityforlemmy.post.FetchPost;
import eu.toldi.infinityforlemmy.post.Post;
import eu.toldi.infinityforlemmy.post.enrich.PostEnricher;
import eu.toldi.infinityforlemmy.services.DownloadMediaService;
import eu.toldi.infinityforlemmy.services.DownloadRedditVideoService;
import eu.toldi.infinityforlemmy.utils.APIUtils;
@@ -222,10 +223,6 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
@Named("default")
SharedPreferences mSharedPreferences;
@Inject
@Named("current_account")
SharedPreferences mCurrentAccountSharedPreferences;
@Inject
CustomThemeWrapper mCustomThemeWrapper;
@@ -235,6 +232,9 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
@Inject
SimpleCache mSimpleCache;
@Inject
PostEnricher postEnricher;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -756,8 +756,8 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
}
});
} else {
FetchGfycatOrRedgifsVideoLinks.fetchRedgifsVideoLinks(this, mExecutor, new Handler(), redgifsRetrofit,
mCurrentAccountSharedPreferences, gfycatId, new FetchGfycatOrRedgifsVideoLinks.FetchGfycatOrRedgifsVideoLinksListener() {
FetchGfycatOrRedgifsVideoLinks.fetchRedgifsVideoLinks(mExecutor, new Handler(), redgifsRetrofit,
gfycatId, new FetchGfycatOrRedgifsVideoLinks.FetchGfycatOrRedgifsVideoLinksListener() {
@Override
public void success(String webm, String mp4) {
progressBar.setVisibility(View.GONE);
@@ -791,7 +791,7 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
int commentsIndex = segments.lastIndexOf("comments");
String postId = segments.get(commentsIndex + 1);
FetchPost.fetchPost(mExecutor, new Handler(), retrofit.getRetrofit(), postId, null,
new FetchPost.FetchPostListener() {
postEnricher, new FetchPost.FetchPostListener() {
@Override
public void fetchPostSuccess(Post post) {
if (post.isGfycat()) {

View File

@@ -35,16 +35,9 @@ import javax.inject.Named;
import butterknife.BindView;
import butterknife.ButterKnife;
import eu.toldi.infinityforlemmy.RetrofitHolder;
import io.noties.markwon.AbstractMarkwonPlugin;
import io.noties.markwon.Markwon;
import io.noties.markwon.MarkwonConfiguration;
import io.noties.markwon.MarkwonPlugin;
import io.noties.markwon.core.MarkwonTheme;
import io.noties.markwon.recycler.MarkwonAdapter;
import me.saket.bettermovementmethod.BetterLinkMovementMethod;
import eu.toldi.infinityforlemmy.Infinity;
import eu.toldi.infinityforlemmy.R;
import eu.toldi.infinityforlemmy.RetrofitHolder;
import eu.toldi.infinityforlemmy.apis.RedditAPI;
import eu.toldi.infinityforlemmy.bottomsheetfragments.UrlMenuBottomSheetFragment;
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
@@ -57,10 +50,16 @@ import eu.toldi.infinityforlemmy.markdown.MarkdownUtils;
import eu.toldi.infinityforlemmy.utils.JSONUtils;
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
import eu.toldi.infinityforlemmy.utils.Utils;
import io.noties.markwon.AbstractMarkwonPlugin;
import io.noties.markwon.Markwon;
import io.noties.markwon.MarkwonConfiguration;
import io.noties.markwon.MarkwonPlugin;
import io.noties.markwon.core.MarkwonTheme;
import io.noties.markwon.recycler.MarkwonAdapter;
import me.saket.bettermovementmethod.BetterLinkMovementMethod;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
public class WikiActivity extends BaseActivity {
@@ -139,7 +138,7 @@ public class WikiActivity extends BaseActivity {
}
}
mGlide = Glide.with(this);
mGlide = Glide.with(getApplication());
swipeRefreshLayout.setEnabled(mSharedPreferences.getBoolean(SharedPreferencesUtils.PULL_TO_REFRESH, true));
swipeRefreshLayout.setOnRefreshListener(this::loadWiki);
@@ -219,7 +218,7 @@ public class WikiActivity extends BaseActivity {
swipeRefreshLayout.setRefreshing(true);
Glide.with(this).clear(mFetchWikiInfoImageView);
Glide.with(getApplication()).clear(mFetchWikiInfoImageView);
mFetchWikiInfoLinearLayout.setVisibility(View.GONE);
retrofit.getRetrofit().create(RedditAPI.class).getWikiPage(getIntent().getStringExtra(EXTRA_SUBREDDIT_NAME), getIntent().getStringExtra(EXTRA_WIKI_PATH)).enqueue(new Callback<String>() {

View File

@@ -0,0 +1,22 @@
package eu.toldi.infinityforlemmy.adapters;
import eu.toldi.infinityforlemmy.activities.BaseActivity;
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
import eu.toldi.infinityforlemmy.user.BasicUserRecyclerViewAdapter;
public class AdminRecyclerViewAdapter extends BasicUserRecyclerViewAdapter {
CustomThemeWrapper mCustomThemeWrapper;
public AdminRecyclerViewAdapter(BaseActivity activity, CustomThemeWrapper customThemeWrapper) {
super(activity, customThemeWrapper);
mCustomThemeWrapper = customThemeWrapper;
}
@Override
protected int getUserNameTextColor() {
return mCustomThemeWrapper.getAdmin();
}
}

View File

@@ -15,6 +15,7 @@ import com.bumptech.glide.request.RequestOptions;
import java.util.List;
import java.util.concurrent.Executor;
import java.util.regex.Pattern;
import butterknife.BindView;
import butterknife.ButterKnife;
@@ -186,6 +187,10 @@ public class BlockedCommunitiesRecyclerViewAdapter extends RecyclerView.Adapter<
.into(((SubredditViewHolder) viewHolder).iconGifImageView);
}
((SubredditViewHolder) viewHolder).subredditNameTextView.setText(name);
if (fullname.contains("@")) {
((SubredditViewHolder) viewHolder).communityInstanceTextView.setText("@" + fullname.split(Pattern.quote("@"), 2)[1]);
((SubredditViewHolder) viewHolder).communityInstanceTextView.setTextColor(CustomThemeWrapper.darkenColor(primaryTextColor, 0.7f));
}
} else if (viewHolder instanceof FavoriteSubredditViewHolder) {
int offset;
if (itemClickListener != null) {
@@ -318,6 +323,9 @@ public class BlockedCommunitiesRecyclerViewAdapter extends RecyclerView.Adapter<
@BindView(R.id.thing_name_text_view_item_subscribed_thing)
TextView subredditNameTextView;
@BindView(R.id.thing_instance_text_view_item_subscribed_thing)
TextView communityInstanceTextView;
SubredditViewHolder(View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);

View File

@@ -450,7 +450,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
Comment comment = getItem(getBindingAdapterPosition());
if (comment != null) {
Bundle bundle = new Bundle();
if (comment.getAuthor().equals(mAccountName)) {
if (comment.getAuthorName().equals(mAccountName)) {
bundle.putBoolean(CommentMoreBottomSheetFragment.EXTRA_EDIT_AND_DELETE_AVAILABLE, true);
}
bundle.putString(CommentMoreBottomSheetFragment.EXTRA_ACCESS_TOKEN, mAccessToken);

View File

@@ -39,10 +39,12 @@ import java.util.List;
import java.util.Locale;
import java.util.Set;
import java.util.concurrent.Executor;
import java.util.regex.Pattern;
import butterknife.BindView;
import butterknife.ButterKnife;
import eu.toldi.infinityforlemmy.R;
import eu.toldi.infinityforlemmy.RetrofitHolder;
import eu.toldi.infinityforlemmy.SaveComment;
import eu.toldi.infinityforlemmy.SaveThing;
import eu.toldi.infinityforlemmy.SortType;
@@ -95,7 +97,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
private BaseActivity mActivity;
private ViewPostDetailFragment mFragment;
private Executor mExecutor;
private Retrofit mRetrofit;
private RetrofitHolder mRetrofit;
private Retrofit mOauthRetrofit;
private Markwon mCommentMarkwon;
private String mAccessToken;
@@ -134,6 +136,9 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
private boolean isInitiallyLoadingFailed;
private boolean mHasMoreComments;
private boolean loadMoreCommentsFailed;
private boolean mHideUserInstance;
private boolean mShowUserDisplayName;
private Drawable expandDrawable;
private Drawable collapseDrawable;
@@ -165,7 +170,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
public CommentsRecyclerViewAdapter(BaseActivity activity, ViewPostDetailFragment fragment,
CustomThemeWrapper customThemeWrapper,
Executor executor, Retrofit retrofit,
Executor executor, RetrofitHolder retrofit,
String accessToken, String accountName,
Post post, Locale locale, Integer singleCommentId,
boolean isSingleCommentThreadMode,
@@ -176,7 +181,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
mFragment = fragment;
mExecutor = executor;
mRetrofit = retrofit;
mGlide = Glide.with(activity);
mGlide = Glide.with(activity.getApplicationContext());
mSecondaryTextColor = customThemeWrapper.getSecondaryTextColor();
mCommentTextColor = customThemeWrapper.getCommentColor();
int commentSpoilerBackgroundColor = mCommentTextColor | 0xFF000000;
@@ -242,6 +247,8 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
mShowAuthorAvatar = sharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_AUTHOR_AVATAR, false);
mAlwaysShowChildCommentCount = sharedPreferences.getBoolean(SharedPreferencesUtils.ALWAYS_SHOW_CHILD_COMMENT_COUNT, false);
mHideTheNumberOfVotes = sharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_THE_NUMBER_OF_VOTES_IN_COMMENTS, false);
mHideUserInstance = sharedPreferences.getBoolean(SharedPreferencesUtils.COMMENT_HIDE_USER_INSTANCE, false);
mShowUserDisplayName = sharedPreferences.getBoolean(SharedPreferencesUtils.COMMENT_DISPLAY_NAME_INSTEAD_OF_USERNAME, true);
mHideDownvotes = !currentAccountSharedPreferences.getBoolean(SharedPreferencesUtils.CAN_DOWNVOTE, true);
mSeperateUpandDownvote = sharedPreferences.getBoolean(SharedPreferencesUtils.COMMENT_SEPARATE_UP_AND_DOWN_VOTES, true) && !mHideDownvotes;
mDepthThreshold = sharedPreferences.getInt(SharedPreferencesUtils.SHOW_FEWER_TOOLBAR_OPTIONS_THRESHOLD, 5);
@@ -375,9 +382,9 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
if (mIsSingleCommentThreadMode && comment.getId() == mSingleCommentId) {
holder.itemView.setBackgroundColor(mSingleCommentThreadBackgroundColor);
}
String authorPrefixed = comment.getAuthorQualifiedName();
((CommentViewHolder) holder).authorTextView.setText(authorPrefixed);
String authorDisplayName = (mShowUserDisplayName) ? comment.getAuthorName() : comment.getAuthor().getUsername();
String authorInstance = (mHideUserInstance) ? "" : "@" + comment.getAuthor().getQualifiedName().split(Pattern.quote("@"))[1];
((CommentViewHolder) holder).authorTextView.setText(authorDisplayName + authorInstance);
if (comment.isSubmitter()) {
@@ -565,7 +572,9 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
} else if (holder instanceof CommentFullyCollapsedViewHolder) {
Comment comment = getCurrentComment(position);
if (comment != null) {
String authorWithPrefix = "u/" + comment.getAuthor();
String author_name = (mShowUserDisplayName) ? comment.getAuthorName() : comment.getAuthor().getUsername();
String authorInstance = (mHideUserInstance) ? "" : "@" + comment.getAuthor().getQualifiedName().split(Pattern.quote("@"))[1];
String authorWithPrefix = author_name + authorInstance;
((CommentFullyCollapsedViewHolder) holder).usernameTextView.setText(authorWithPrefix);
if (comment.getAuthorIconUrl() == null) {
@@ -648,28 +657,28 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
mVisibleComments.get(commentPosition).setLoadMoreChildrenFailed(false);
((LoadMoreChildCommentsViewHolder) holder).placeholderTextView.setText(R.string.loading);
Retrofit retrofit = mRetrofit;
Retrofit retrofit = mRetrofit.getRetrofit();
SortType.Type sortType = mCommentRecyclerViewAdapterCallback.getSortType();
FetchComment.fetchComments(mExecutor, new Handler(), retrofit, mAccessToken,
mPost.getId(), parentComment.getId(), sortType,
mExpandChildren, 1, new FetchComment.FetchCommentListener() {
@Override
public void onFetchCommentSuccess(ArrayList<Comment> expandedComments, Integer parentId, ArrayList<Integer> children) {
if (mVisibleComments.size() > parentPosition
&& parentComment.getId() == mVisibleComments.get(parentPosition).getId()) {
if (parentComment.getId() == mVisibleComments.get(parentPosition).getId()) {
if (mVisibleComments.get(parentPosition).isExpanded()) {
mVisibleComments.get(parentPosition).getChildren()
.remove(mVisibleComments.get(parentPosition).getChildren().size() - 1);
// mVisibleComments.get(parentPosition).removeMoreChildrenIds();
int placeholderPosition = findLoadMoreCommentsPlaceholderPosition(parentComment.getFullName(), commentPosition);
if (placeholderPosition != -1) {
mVisibleComments.remove(placeholderPosition);
if (position != -1) {
if (mIsSingleCommentThreadMode) {
notifyItemRemoved(placeholderPosition + 1);
mVisibleComments.remove(position - 1);
notifyItemRemoved(position + 1);
} else {
notifyItemRemoved(placeholderPosition);
mVisibleComments.remove(position);
notifyItemRemoved(position);
}
List<Comment> trulyNewComments = new ArrayList<>();
for (int i = 0; i < expandedComments.size(); i++) {
@@ -679,11 +688,13 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
trulyNewComments.add(expandedComments.get(i));
loadedComments.add(expandedComments.get(i).getId());
}
mVisibleComments.addAll(placeholderPosition, trulyNewComments);
if (mIsSingleCommentThreadMode) {
notifyItemRangeInserted(placeholderPosition + 1, trulyNewComments.size());
} else {
notifyItemRangeInserted(placeholderPosition, trulyNewComments.size());
if (!trulyNewComments.isEmpty()) {
mVisibleComments.addAll(position, trulyNewComments);
if (mIsSingleCommentThreadMode) {
notifyItemRangeInserted(position + 1, trulyNewComments.size());
} else {
notifyItemRangeInserted(position, trulyNewComments.size());
}
}
}
@@ -713,7 +724,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
if (mVisibleComments.get(i).getFullName().equals(parentComment.getFullName())) {
if (mVisibleComments.get(i).isExpanded()) {
int placeholderPositionHint = i + mVisibleComments.get(i).getChildren().size();
int placeholderPosition = findLoadMoreCommentsPlaceholderPosition(parentComment.getFullName(), placeholderPositionHint);
int placeholderPosition = findLoadMoreCommentsPlaceholderPosition(parentComment.getId(), placeholderPositionHint);
if (placeholderPosition != -1) {
mVisibleComments.get(placeholderPosition).setLoadingMoreChildren(false);
@@ -751,7 +762,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
@Override
public void onFetchCommentFailed() {
int currentParentPosition = findCommentPosition(parentComment.getFullName(), parentPosition);
int currentParentPosition = findCommentPosition(parentComment.getId(), parentPosition);
if (currentParentPosition == -1) {
// note: returning here is probably a mistake, because
// parent is just not visible, but it can still exist in the comments tree.
@@ -761,7 +772,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
if (currentParentComment.isExpanded()) {
int placeholderPositionHint = currentParentPosition + currentParentComment.getChildren().size();
int placeholderPosition = findLoadMoreCommentsPlaceholderPosition(parentComment.getFullName(), placeholderPositionHint);
int placeholderPosition = findLoadMoreCommentsPlaceholderPosition(parentComment.getId(), placeholderPositionHint);
if (placeholderPosition != -1) {
mVisibleComments.get(placeholderPosition).setLoadingMoreChildren(false);
@@ -810,7 +821,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
*
* @return position of the placeholder or -1 if not found
*/
private int findCommentPosition(String fullName, int positionHint) {
private int findCommentPosition(int fullName, int positionHint) {
return findCommentPosition(fullName, positionHint, Comment.NOT_PLACEHOLDER);
}
@@ -820,20 +831,20 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
*
* @return position of the placeholder or -1 if not found
*/
private int findLoadMoreCommentsPlaceholderPosition(String fullName, int positionHint) {
return findCommentPosition(fullName, positionHint, Comment.PLACEHOLDER_LOAD_MORE_COMMENTS);
private int findLoadMoreCommentsPlaceholderPosition(int id, int positionHint) {
return findCommentPosition(id, positionHint, Comment.PLACEHOLDER_LOAD_MORE_COMMENTS);
}
private int findCommentPosition(String fullName, int positionHint, int placeholderType) {
private int findCommentPosition(int id, int positionHint, int placeholderType) {
if (0 <= positionHint && positionHint < mVisibleComments.size()
&& mVisibleComments.get(positionHint).getFullName().equals(fullName)
&& mVisibleComments.get(positionHint).getId() == id
&& mVisibleComments.get(positionHint).getPlaceholderType() == placeholderType) {
return positionHint;
}
for (int i = 0; i < mVisibleComments.size(); i++) {
Comment comment = mVisibleComments.get(i);
if (comment.getFullName().equals(fullName) && comment.getPlaceholderType() == placeholderType) {
if (comment.getId() == id && comment.getPlaceholderType() == placeholderType) {
return i;
}
}
@@ -905,7 +916,8 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
loadedComments.add(comments.get(i).getId());
}
if (mIsSingleCommentThreadMode) {
notifyItemRangeInserted(sizeBefore, comments.size() + 1);
int offset = (comments.size() > 0) ? 1 : 0;
notifyItemRangeInserted(sizeBefore, comments.size() + offset);
} else {
notifyItemRangeInserted(sizeBefore, comments.size());
}
@@ -1478,7 +1490,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
comment.getScore() + comment.getVoteType())));
}
VoteThing.voteComment(mActivity, mRetrofit, mAccessToken, new VoteThing.VoteThingListener() {
VoteThing.voteComment(mActivity, mRetrofit.getRetrofit(), mAccessToken, new VoteThing.VoteThingListener() {
@Override
public void onVoteThingSuccess(int position) {
int currentPosition = getBindingAdapterPosition();
@@ -1585,7 +1597,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
}
int position = getBindingAdapterPosition();
VoteThing.voteComment(mActivity, mRetrofit, mAccessToken, new VoteThing.VoteThingListener() {
VoteThing.voteComment(mActivity, mRetrofit.getRetrofit(), mAccessToken, new VoteThing.VoteThingListener() {
@Override
public void onVoteThingSuccess(int position1) {
int currentPosition = getBindingAdapterPosition();
@@ -1593,9 +1605,9 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
comment.setVoteType(Comment.VOTE_TYPE_DOWNVOTE);
if (currentPosition == position) {
downvoteButton.setColorFilter(mDownvotedColor, PorterDuff.Mode.SRC_IN);
if(mSeperateUpandDownvote){
if (mSeperateUpandDownvote) {
downvoteTextView.setTextColor(mDownvotedColor);
}else {
} else {
scoreTextView.setTextColor(mDownvotedColor);
}
topScoreTextView.setTextColor(mDownvotedColor);
@@ -1645,7 +1657,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
SaveComment saveComment = new SaveComment();
if (comment.isSaved()) {
comment.setSaved(false);
saveComment.unsaveThing(mRetrofit, mAccessToken, comment.getId(), new SaveThing.SaveThingListener() {
saveComment.unsaveThing(mRetrofit.getRetrofit(), mAccessToken, comment.getId(), new SaveThing.SaveThingListener() {
@Override
public void success() {
comment.setSaved(false);
@@ -1666,7 +1678,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
});
} else {
comment.setSaved(true);
saveComment.saveThing(mRetrofit, mAccessToken, comment.getId(), new SaveThing.SaveThingListener() {
saveComment.saveThing(mRetrofit.getRetrofit(), mAccessToken, comment.getId(), new SaveThing.SaveThingListener() {
@Override
public void success() {
comment.setSaved(true);
@@ -1695,7 +1707,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
return;
}
Intent intent = new Intent(mActivity, ViewUserDetailActivity.class);
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, comment.getAuthor());
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, comment.getAuthorName());
intent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, comment.getAuthorQualifiedName());
mActivity.startActivity(intent);
});

View File

@@ -139,7 +139,6 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
private BaseActivity mActivity;
private HistoryPostFragment mFragment;
private SharedPreferences mSharedPreferences;
private SharedPreferences mCurrentAccountSharedPreferences;
private Executor mExecutor;
private Retrofit retrofit;
private Retrofit mGfycatRetrofit;
@@ -227,7 +226,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
Retrofit gfycatRetrofit, Retrofit redgifsRetrofit, Provider<StreamableAPI> streambleApiProvider,
CustomThemeWrapper customThemeWrapper, Locale locale,
String accessToken, String accountName, int postType, int postLayout, boolean displaySubredditName,
SharedPreferences sharedPreferences, SharedPreferences currentAccountSharedPreferences,
SharedPreferences sharedPreferences,
SharedPreferences nsfwAndSpoilerSharedPreferences,
ExoCreator exoCreator, Callback callback) {
super(DIFF_CALLBACK);
@@ -235,7 +234,6 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
mActivity = activity;
mFragment = fragment;
mSharedPreferences = sharedPreferences;
mCurrentAccountSharedPreferences = currentAccountSharedPreferences;
mExecutor = executor;
retrofit = oauthRetrofit;
mGfycatRetrofit = gfycatRetrofit;
@@ -698,7 +696,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
if ((post.isGfycat() || post.isRedgifs()) && !post.isLoadGfycatOrStreamableVideoSuccess()) {
((PostVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall =
post.isGfycat() ? mGfycatRetrofit.create(GfycatAPI.class).getGfycatData(post.getGfycatId()) :
mRedgifsRetrofit.create(RedgifsAPI.class).getRedgifsData(APIUtils.getRedgifsOAuthHeader(mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.REDGIFS_ACCESS_TOKEN, "")), post.getGfycatId(), APIUtils.USER_AGENT);
mRedgifsRetrofit.create(RedgifsAPI.class).getRedgifsData(post.getGfycatId());
FetchGfycatOrRedgifsVideoLinks.fetchGfycatOrRedgifsVideoLinksInRecyclerViewAdapter(mExecutor, new Handler(),
((PostVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall,
post.isGfycat(), mAutomaticallyTryRedgifs,
@@ -875,7 +873,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
if ((post.isGfycat() || post.isRedgifs()) && !post.isLoadGfycatOrStreamableVideoSuccess()) {
((PostCard2VideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall =
post.isGfycat() ? mGfycatRetrofit.create(GfycatAPI.class).getGfycatData(post.getGfycatId()) :
mRedgifsRetrofit.create(RedgifsAPI.class).getRedgifsData(APIUtils.getRedgifsOAuthHeader(mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.REDGIFS_ACCESS_TOKEN, "")), post.getGfycatId(), APIUtils.USER_AGENT);
mRedgifsRetrofit.create(RedgifsAPI.class).getRedgifsData(post.getGfycatId());
FetchGfycatOrRedgifsVideoLinks.fetchGfycatOrRedgifsVideoLinksInRecyclerViewAdapter(mExecutor, new Handler(),
((PostCard2VideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall,
post.isGfycat(), mAutomaticallyTryRedgifs,

View File

@@ -217,7 +217,7 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<CommentInteract
((DataViewHolder) holder).authorTextView.setOnClickListener(view -> {
Intent intent = new Intent(mActivity, ViewUserDetailActivity.class);
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, message.getComment().getAuthor());
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, message.getComment().getAuthorName());
intent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, message.getComment().getAuthorQualifiedName());
mActivity.startActivity(intent);
});

View File

@@ -0,0 +1,20 @@
package eu.toldi.infinityforlemmy.adapters;
import eu.toldi.infinityforlemmy.activities.BaseActivity;
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
import eu.toldi.infinityforlemmy.user.BasicUserRecyclerViewAdapter;
public class ModeratorRecyclerViewAdapter extends BasicUserRecyclerViewAdapter {
private final int mModeratorColor;
public ModeratorRecyclerViewAdapter(BaseActivity activity, CustomThemeWrapper customThemeWrapper) {
super(activity, customThemeWrapper);
mModeratorColor = customThemeWrapper.getModerator();
}
@Override
protected int getUserNameTextColor() {
return mModeratorColor;
}
}

View File

@@ -67,6 +67,7 @@ import eu.toldi.infinityforlemmy.FetchGfycatOrRedgifsVideoLinks;
import eu.toldi.infinityforlemmy.FetchStreamableVideo;
import eu.toldi.infinityforlemmy.R;
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
import eu.toldi.infinityforlemmy.RetrofitHolder;
import eu.toldi.infinityforlemmy.SaveMemoryCenterInisdeDownsampleStrategy;
import eu.toldi.infinityforlemmy.SavePost;
import eu.toldi.infinityforlemmy.SaveThing;
@@ -135,8 +136,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
private BaseActivity mActivity;
private ViewPostDetailFragment mFragment;
private Executor mExecutor;
private Retrofit mRetrofit;
private Retrofit mOauthRetrofit;
private RetrofitHolder mRetrofit;
private Retrofit mGfycatRetrofit;
private Retrofit mRedgifsRetrofit;
private final Provider<StreamableAPI> mStreamableApiProvider;
@@ -172,6 +172,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
private boolean mHideUpvoteRatio;
private boolean mHideTheNumberOfAwards;
private boolean mHideSubredditAndUserPrefix;
private boolean mShareOnLocalInstance;
private boolean mShowDisplayNames;
private boolean mHideTheNumberOfVotes;
@@ -223,7 +224,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
public PostDetailRecyclerViewAdapter(BaseActivity activity, ViewPostDetailFragment fragment,
Executor executor, CustomThemeWrapper customThemeWrapper,
Retrofit retrofit, Retrofit gfycatRetrofit,
RetrofitHolder retrofit, Retrofit gfycatRetrofit,
Retrofit redgifsRetrofit, Provider<StreamableAPI> streamableApiProvider,
RedditDataRoomDatabase redditDataRoomDatabase, RequestManager glide,
boolean separatePostAndComments, String accessToken,
@@ -347,6 +348,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
mHideUpvoteRatio = postDetailsSharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_UPVOTE_RATIO, false);
mHideTheNumberOfAwards = postDetailsSharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_THE_NUMBER_OF_AWARDS, false);
mHideSubredditAndUserPrefix = postDetailsSharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_SUBREDDIT_AND_USER_PREFIX, false);
mShareOnLocalInstance = postDetailsSharedPreferences.getBoolean(SharedPreferencesUtils.SHARE_LINK_ON_LOCAL_INSTANCE, false);
mShowDisplayNames = postDetailsSharedPreferences.getBoolean(SharedPreferencesUtils.POST_DETAIL_DISPLAY_NAME_INSTEAD_OF_USERNAME, true);
mHideTheNumberOfVotes = postDetailsSharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_THE_NUMBER_OF_VOTES, false);
mHideDownvotes = !currentAccountSharedPreferences.getBoolean(SharedPreferencesUtils.CAN_DOWNVOTE, true);
@@ -485,7 +487,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
((PostDetailBaseViewHolder) holder).mTitleTextView.setText(mPost.getTitle());
if (mPost.getSubredditNamePrefixed().startsWith("u/")) {
if (mPost.getAuthorIconUrl() == null) {
LoadUserData.loadUserData(mExecutor, new Handler(), mRedditDataRoomDatabase,mPost.getAuthorNamePrefixed(), mOauthRetrofit, iconImageUrl -> {
LoadUserData.loadUserData(mExecutor, new Handler(), mRedditDataRoomDatabase, mPost.getAuthorNamePrefixed(), mRetrofit.getRetrofit(), iconImageUrl -> {
if (mActivity != null && getItemCount() > 0) {
if (iconImageUrl == null || iconImageUrl.equals("")) {
mGlide.load(R.drawable.subreddit_default_icon)
@@ -519,7 +521,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
if (mPost.getSubredditIconUrl() == null) {
LoadSubredditIcon.loadSubredditIcon(mExecutor, new Handler(),
mRedditDataRoomDatabase, mPost.getSubredditNamePrefixed(),
mAccessToken, mOauthRetrofit, mRetrofit, iconImageUrl -> {
mAccessToken, mRetrofit.getRetrofit(), iconImageUrl -> {
if (iconImageUrl == null || iconImageUrl.equals("")) {
mGlide.load(R.drawable.subreddit_default_icon)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
@@ -696,7 +698,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
if (mPost.isGfycat() || mPost.isRedgifs() && !mPost.isLoadGfycatOrStreamableVideoSuccess()) {
((PostDetailVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall =
mPost.isGfycat() ? mGfycatRetrofit.create(GfycatAPI.class).getGfycatData(mPost.getGfycatId()) :
mRedgifsRetrofit.create(RedgifsAPI.class).getRedgifsData(APIUtils.getRedgifsOAuthHeader(mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.REDGIFS_ACCESS_TOKEN, "")), mPost.getGfycatId(), APIUtils.USER_AGENT);
mRedgifsRetrofit.create(RedgifsAPI.class).getRedgifsData(mPost.getGfycatId());
FetchGfycatOrRedgifsVideoLinks.fetchGfycatOrRedgifsVideoLinksInRecyclerViewAdapter(mExecutor, new Handler(),
((PostDetailVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall,
mPost.isGfycat(), mAutomaticallyTryRedgifs,
@@ -1385,7 +1387,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
mPostDetailRecyclerViewAdapterCallback.updatePost(mPost);
VoteThing.votePost(mActivity, mRetrofit, mAccessToken, new VoteThing.VoteThingWithoutPositionListener() {
VoteThing.votePost(mActivity, mRetrofit.getRetrofit(), mAccessToken, new VoteThing.VoteThingWithoutPositionListener() {
@Override
public void onVoteThingSuccess() {
if (newVoteType == Integer.parseInt(APIUtils.DIR_UPVOTE)) {
@@ -1491,13 +1493,13 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
mPostDetailRecyclerViewAdapterCallback.updatePost(mPost);
VoteThing.votePost(mActivity, mRetrofit, mAccessToken, new VoteThing.VoteThingWithoutPositionListener() {
VoteThing.votePost(mActivity, mRetrofit.getRetrofit(), mAccessToken, new VoteThing.VoteThingWithoutPositionListener() {
@Override
public void onVoteThingSuccess() {
if (newVoteType == Integer.parseInt(APIUtils.DIR_DOWNVOTE)) {
mPost.setVoteType(-1);
mDownvoteButton.setColorFilter(mDownvotedColor, PorterDuff.Mode.SRC_IN);
if(mSeperateUpvoteAndDownvote) {
if (mSeperateUpvoteAndDownvote) {
mDownvoteTextView.setTextColor(mDownvotedColor);
} else {
mScoreTextView.setTextColor(mDownvotedColor);
@@ -1587,7 +1589,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
SavePost savePost = new SavePost();
if (mPost.isSaved()) {
mSaveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
savePost.unsaveThing(mRetrofit, mAccessToken, mPost.getId(),
savePost.unsaveThing(mRetrofit.getRetrofit(), mAccessToken, mPost.getId(),
new SaveThing.SaveThingListener() {
@Override
public void success() {
@@ -1607,7 +1609,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
});
} else {
mSaveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
savePost.saveThing(mRetrofit, mAccessToken, mPost.getId(),
savePost.saveThing(mRetrofit.getRetrofit(), mAccessToken, mPost.getId(),
new SaveThing.SaveThingListener() {
@Override
public void success() {
@@ -1629,8 +1631,9 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
});
mShareButton.setOnClickListener(view -> {
String link = (mShareOnLocalInstance) ? mRetrofit.getBaseURL() + "/post/" + mPost.getId() : mPost.getPermalink();
Bundle bundle = new Bundle();
bundle.putString(ShareLinkBottomSheetFragment.EXTRA_POST_LINK, mPost.getPermalink());
bundle.putString(ShareLinkBottomSheetFragment.EXTRA_POST_LINK, link);
if (mPost.getPostType() != Post.TEXT_TYPE) {
bundle.putInt(ShareLinkBottomSheetFragment.EXTRA_MEDIA_TYPE, mPost.getPostType());
switch (mPost.getPostType()) {
@@ -1651,7 +1654,8 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
});
mShareButton.setOnLongClickListener(view -> {
mActivity.copyLink(mPost.getPermalink());
String link = (mShareOnLocalInstance) ? mRetrofit.getBaseURL() + "/post/" + mPost.getId() : mPost.getPermalink();
mActivity.copyLink(link);
return true;
});

View File

@@ -71,6 +71,7 @@ import eu.toldi.infinityforlemmy.FetchGfycatOrRedgifsVideoLinks;
import eu.toldi.infinityforlemmy.FetchStreamableVideo;
import eu.toldi.infinityforlemmy.MarkPostAsReadInterface;
import eu.toldi.infinityforlemmy.R;
import eu.toldi.infinityforlemmy.RetrofitHolder;
import eu.toldi.infinityforlemmy.SaveMemoryCenterInisdeDownsampleStrategy;
import eu.toldi.infinityforlemmy.SavePost;
import eu.toldi.infinityforlemmy.SaveThing;
@@ -150,7 +151,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
private SharedPreferences mSharedPreferences;
private SharedPreferences mCurrentAccountSharedPreferences;
private Executor mExecutor;
private Retrofit retrofit;
private RetrofitHolder retrofit;
private Retrofit mGfycatRetrofit;
private Retrofit mRedgifsRetrofit;
private Provider<StreamableAPI> mStreamableApiProvider;
@@ -230,6 +231,8 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
private boolean mShowDisplayNames;
private boolean mHideTheNumberOfVotes;
private boolean mShareLinkOnLocalInstance;
private boolean mSeparateUpandDownVotes;
private boolean mHideDownvotes;
@@ -244,7 +247,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
private boolean canPlayVideo = true;
private RecyclerView.RecycledViewPool mGalleryRecycledViewPool;
public PostRecyclerViewAdapter(BaseActivity activity, PostFragment fragment, Executor executor, Retrofit oauthRetrofit,
public PostRecyclerViewAdapter(BaseActivity activity, PostFragment fragment, Executor executor, RetrofitHolder retrofit,
Retrofit gfycatRetrofit, Retrofit redgifsRetrofit, Provider<StreamableAPI> streamableApiProvider,
CustomThemeWrapper customThemeWrapper, Locale locale,
String accessToken, String accountName, int postType, int postLayout, boolean displaySubredditName,
@@ -259,7 +262,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
mSharedPreferences = sharedPreferences;
mCurrentAccountSharedPreferences = currentAccountSharedPreferences;
mExecutor = executor;
retrofit = oauthRetrofit;
this.retrofit = retrofit;
mGfycatRetrofit = gfycatRetrofit;
mRedgifsRetrofit = redgifsRetrofit;
mStreamableApiProvider = streamableApiProvider;
@@ -316,6 +319,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
mHideSubredditAndUserPrefix = sharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_SUBREDDIT_AND_USER_PREFIX, false);
mShowDisplayNames = sharedPreferences.getBoolean(SharedPreferencesUtils.POST_DISPLAY_NAME_INSTEAD_OF_USERNAME, true);
mHideTheNumberOfVotes = sharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_THE_NUMBER_OF_VOTES, false);
mShareLinkOnLocalInstance = sharedPreferences.getBoolean(SharedPreferencesUtils.SHARE_LINK_ON_LOCAL_INSTANCE, false);
mHideDownvotes = !currentAccountSharedPreferences.getBoolean(SharedPreferencesUtils.CAN_DOWNVOTE, true);
mSeparateUpandDownVotes = sharedPreferences.getBoolean(SharedPreferencesUtils.POST_SEPARATE_UP_AND_DOWN_VOTES, true) && !mHideDownvotes;
mHideTheNumberOfComments = sharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_THE_NUMBER_OF_COMMENTS, false);
@@ -783,7 +787,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
if ((post.isGfycat() || post.isRedgifs()) && !post.isLoadGfycatOrStreamableVideoSuccess()) {
((PostVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall =
post.isGfycat() ? mGfycatRetrofit.create(GfycatAPI.class).getGfycatData(post.getGfycatId()) :
mRedgifsRetrofit.create(RedgifsAPI.class).getRedgifsData(APIUtils.getRedgifsOAuthHeader(mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.REDGIFS_ACCESS_TOKEN, "")), post.getGfycatId(), APIUtils.USER_AGENT);
mRedgifsRetrofit.create(RedgifsAPI.class).getRedgifsData(post.getGfycatId());
FetchGfycatOrRedgifsVideoLinks.fetchGfycatOrRedgifsVideoLinksInRecyclerViewAdapter(mExecutor, new Handler(),
((PostVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall,
post.isGfycat(), mAutomaticallyTryRedgifs,
@@ -975,7 +979,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
if ((post.isGfycat() || post.isRedgifs()) && !post.isLoadGfycatOrStreamableVideoSuccess()) {
((PostCard2VideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall =
post.isGfycat() ? mGfycatRetrofit.create(GfycatAPI.class).getGfycatData(post.getGfycatId()) :
mRedgifsRetrofit.create(RedgifsAPI.class).getRedgifsData(APIUtils.getRedgifsOAuthHeader(mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.REDGIFS_ACCESS_TOKEN, "")), post.getGfycatId(), APIUtils.USER_AGENT);
mRedgifsRetrofit.create(RedgifsAPI.class).getRedgifsData(post.getGfycatId());
FetchGfycatOrRedgifsVideoLinks.fetchGfycatOrRedgifsVideoLinksInRecyclerViewAdapter(mExecutor, new Handler(),
((PostCard2VideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall,
post.isGfycat(), mAutomaticallyTryRedgifs,
@@ -1893,8 +1897,9 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
}
private void shareLink(Post post) {
String link = (mShareLinkOnLocalInstance) ? retrofit.getBaseURL() + "/post/" + post.getId() : post.getPermalink();
Bundle bundle = new Bundle();
bundle.putString(ShareLinkBottomSheetFragment.EXTRA_POST_LINK, post.getPermalink());
bundle.putString(ShareLinkBottomSheetFragment.EXTRA_POST_LINK, link);
if (post.getPostType() != Post.TEXT_TYPE) {
bundle.putInt(ShareLinkBottomSheetFragment.EXTRA_MEDIA_TYPE, post.getPostType());
switch (post.getPostType()) {
@@ -2666,7 +2671,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
}
}
VoteThing.votePost(mActivity, retrofit, mAccessToken, new VoteThing.VoteThingListener() {
VoteThing.votePost(mActivity, retrofit.getRetrofit(), mAccessToken, new VoteThing.VoteThingListener() {
@Override
public void onVoteThingSuccess(int position1) {
int currentPosition = getBindingAdapterPosition();
@@ -2782,7 +2787,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
}
}
VoteThing.votePost(mActivity, retrofit, mAccessToken, new VoteThing.VoteThingListener() {
VoteThing.votePost(mActivity, retrofit.getRetrofit(), mAccessToken, new VoteThing.VoteThingListener() {
@Override
public void onVoteThingSuccess(int position1) {
int currentPosition = getBindingAdapterPosition();
@@ -2790,9 +2795,9 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
post.setVoteType(-1);
if (currentPosition == position) {
downvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
if(mSeparateUpandDownVotes){
if (mSeparateUpandDownVotes) {
downvoteTextView.setTextColor(mDownvotedColor);
}else {
} else {
scoreTextView.setTextColor(mDownvotedColor);
}
}
@@ -2855,7 +2860,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
SavePost savePost = new SavePost();
if (post.isSaved()) {
saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
savePost.unsaveThing(retrofit, mAccessToken, post.getId(),
savePost.unsaveThing(retrofit.getRetrofit(), mAccessToken, post.getId(),
new SaveThing.SaveThingListener() {
@Override
public void success() {
@@ -2879,7 +2884,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
});
} else {
saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
savePost.saveThing(retrofit, mAccessToken, post.getId(),
savePost.saveThing(retrofit.getRetrofit(), mAccessToken, post.getId(),
new SaveThing.SaveThingListener() {
@Override
public void success() {
@@ -2923,7 +2928,8 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
}
Post post = getItem(position);
if (post != null) {
mActivity.copyLink(post.getPermalink());
String link = (mShareLinkOnLocalInstance) ? retrofit.getBaseURL() + "/post/" + post.getId() : post.getPermalink();
mActivity.copyLink(link);
return true;
}
return false;
@@ -4118,7 +4124,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType()));
}
VoteThing.votePost(mActivity, retrofit, mAccessToken, new VoteThing.VoteThingListener() {
VoteThing.votePost(mActivity, retrofit.getRetrofit(), mAccessToken, new VoteThing.VoteThingListener() {
@Override
public void onVoteThingSuccess(int position1) {
int currentPosition = getBindingAdapterPosition();
@@ -4224,7 +4230,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
}
}
VoteThing.votePost(mActivity, retrofit, mAccessToken, new VoteThing.VoteThingListener() {
VoteThing.votePost(mActivity, retrofit.getRetrofit(), mAccessToken, new VoteThing.VoteThingListener() {
@Override
public void onVoteThingSuccess(int position1) {
int currentPosition = getBindingAdapterPosition();
@@ -4232,7 +4238,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
post.setVoteType(-1);
if (currentPosition == position) {
downvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
if(mSeparateUpandDownVotes) {
if (mSeparateUpandDownVotes) {
downvoteTextView.setTextColor(mDownvotedColor);
} else {
scoreTextView.setTextColor(mDownvotedColor);
@@ -4297,7 +4303,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
SavePost postSave = new SavePost();
if (post.isSaved()) {
saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
postSave.unsaveThing(retrofit, mAccessToken, post.getId(),
postSave.unsaveThing(retrofit.getRetrofit(), mAccessToken, post.getId(),
new SaveThing.SaveThingListener() {
@Override
public void success() {
@@ -4321,7 +4327,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
});
} else {
saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
postSave.saveThing(retrofit, mAccessToken, post.getId(),
postSave.saveThing(retrofit.getRetrofit(), mAccessToken, post.getId(),
new SaveThing.SaveThingListener() {
@Override
public void success() {
@@ -4365,7 +4371,8 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
}
Post post = getItem(position);
if (post != null) {
mActivity.copyLink(post.getPermalink());
String link = (mShareLinkOnLocalInstance) ? retrofit.getBaseURL() + "/post/" + post.getId() : post.getPermalink();
mActivity.copyLink(link);
return true;
}
return false;

View File

@@ -16,13 +16,6 @@ import java.util.ArrayList;
import butterknife.BindView;
import butterknife.ButterKnife;
import io.noties.markwon.AbstractMarkwonPlugin;
import io.noties.markwon.Markwon;
import io.noties.markwon.MarkwonConfiguration;
import io.noties.markwon.MarkwonPlugin;
import io.noties.markwon.core.MarkwonTheme;
import io.noties.markwon.recycler.MarkwonAdapter;
import me.saket.bettermovementmethod.BetterLinkMovementMethod;
import eu.toldi.infinityforlemmy.R;
import eu.toldi.infinityforlemmy.Rule;
import eu.toldi.infinityforlemmy.activities.BaseActivity;
@@ -33,6 +26,13 @@ import eu.toldi.infinityforlemmy.customviews.SwipeLockInterface;
import eu.toldi.infinityforlemmy.customviews.SwipeLockLinearLayoutManager;
import eu.toldi.infinityforlemmy.customviews.slidr.widget.SliderPanel;
import eu.toldi.infinityforlemmy.markdown.MarkdownUtils;
import io.noties.markwon.AbstractMarkwonPlugin;
import io.noties.markwon.Markwon;
import io.noties.markwon.MarkwonConfiguration;
import io.noties.markwon.MarkwonPlugin;
import io.noties.markwon.core.MarkwonTheme;
import io.noties.markwon.recycler.MarkwonAdapter;
import me.saket.bettermovementmethod.BetterLinkMovementMethod;
public class RulesRecyclerViewAdapter extends RecyclerView.Adapter<RulesRecyclerViewAdapter.RuleViewHolder> {
private BaseActivity activity;

View File

@@ -141,7 +141,8 @@ public class SubredditListingRecyclerViewAdapter extends PagedListAdapter<Subred
.into(((DataViewHolder) holder).iconGifImageView);
}
((DataViewHolder) holder).subredditNameTextView.setText(subredditData.getName());
((DataViewHolder) holder).subredditNameTextView.setText(subredditData.getTitle());
((DataViewHolder) holder).communityInstanceTextView.setText('@' + LemmyUtils.actorID2FullName(subredditData.getActorId()).split("@")[1]);
((DataViewHolder) holder).subscriberCountTextView.setText(activity.getString(R.string.subscribers_number_detail, subredditData.getNSubscribers()));
if (!isMultiSelection) {
@@ -262,6 +263,9 @@ public class SubredditListingRecyclerViewAdapter extends PagedListAdapter<Subred
GifImageView iconGifImageView;
@BindView(R.id.subreddit_name_text_view_item_subreddit_listing)
TextView subredditNameTextView;
@BindView(R.id.community_instance_text_view_item_subreddit_listing)
TextView communityInstanceTextView;
@BindView(R.id.subscriber_count_text_view_item_subreddit_listing)
TextView subscriberCountTextView;
@BindView(R.id.subscribe_image_view_item_subreddit_listing)
@@ -273,6 +277,7 @@ public class SubredditListingRecyclerViewAdapter extends PagedListAdapter<Subred
super(itemView);
ButterKnife.bind(this, itemView);
subredditNameTextView.setTextColor(primaryTextColor);
communityInstanceTextView.setTextColor(CustomThemeWrapper.darkenColor(primaryTextColor, 0.7f));
subscriberCountTextView.setTextColor(secondaryTextColor);
subscribeButton.setColorFilter(unsubscribed, android.graphics.PorterDuff.Mode.SRC_IN);
if (isMultiSelection) {

View File

@@ -1,9 +1,11 @@
package eu.toldi.infinityforlemmy.adapters;
import android.content.Intent;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
@@ -22,6 +24,7 @@ import eu.toldi.infinityforlemmy.R;
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
import eu.toldi.infinityforlemmy.activities.BaseActivity;
import eu.toldi.infinityforlemmy.activities.ViewSubredditDetailActivity;
import eu.toldi.infinityforlemmy.asynctasks.InsertSubscribedThings;
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
import eu.toldi.infinityforlemmy.subscribedsubreddit.SubscribedSubredditData;
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
@@ -81,12 +84,10 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
if (mFavoriteSubscribedSubredditData != null && mFavoriteSubscribedSubredditData.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 == mFavoriteSubscribedSubredditData.size() + 2) {
} else if (position == mFavoriteSubscribedSubredditData.size() + 1) {
return VIEW_TYPE_SUBREDDIT_DIVIDER;
} else if (position <= mFavoriteSubscribedSubredditData.size() + 1) {
} else if (position <= mFavoriteSubscribedSubredditData.size()) {
return VIEW_TYPE_FAVORITE_SUBREDDIT;
} else {
return VIEW_TYPE_SUBREDDIT;
@@ -95,12 +96,10 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
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 == mFavoriteSubscribedSubredditData.size() + 3) {
} else if (position == mFavoriteSubscribedSubredditData.size() + 2) {
return VIEW_TYPE_SUBREDDIT_DIVIDER;
} else if (position <= mFavoriteSubscribedSubredditData.size() + 2) {
} else if (position < mFavoriteSubscribedSubredditData.size() + 2) {
return VIEW_TYPE_FAVORITE_SUBREDDIT;
} else {
return VIEW_TYPE_SUBREDDIT;
@@ -152,17 +151,52 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
viewHolder.itemView.setOnClickListener(view -> itemClickListener.onClick(null));
return;
} else {
int offset = hasClearSelectionRow ? 1 : 0;
SubscribedSubredditData communityData = mSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset);
int offset;
if (itemClickListener != null) {
if (hasClearSelectionRow) {
offset = (mFavoriteSubscribedSubredditData != null && mFavoriteSubscribedSubredditData.size() > 0) ?
mFavoriteSubscribedSubredditData.size() + 3 : 1;
} else {
offset = (mFavoriteSubscribedSubredditData != null && mFavoriteSubscribedSubredditData.size() > 0) ?
mFavoriteSubscribedSubredditData.size() + 2 : 0;
}
} else {
offset = (mFavoriteSubscribedSubredditData != null && mFavoriteSubscribedSubredditData.size() > 0) ?
mFavoriteSubscribedSubredditData.size() + 2 : 0;
}
name = mSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset).getName();
fullname = mSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset).getQualified_name();
iconUrl = mSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset).getIconUrl();
if (mSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset).isFavorite()) {
((SubredditViewHolder) viewHolder).favoriteImageView.setImageResource(R.drawable.ic_favorite_24dp);
} else {
((SubredditViewHolder) viewHolder).favoriteImageView.setImageResource(R.drawable.ic_favorite_border_24dp);
}
((SubredditViewHolder) viewHolder).favoriteImageView.setOnClickListener(view -> {
if (mSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset).isFavorite()) {
((SubredditViewHolder) viewHolder).favoriteImageView.setImageResource(R.drawable.ic_favorite_border_24dp);
mSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset).setFavorite(false);
} else {
((SubredditViewHolder) viewHolder).favoriteImageView.setImageResource(R.drawable.ic_favorite_24dp);
mSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset).setFavorite(true);
}
InsertSubscribedThings.insertSubscribedThings(mExecutor, new Handler(), mRedditDataRoomDatabase, mSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset),
() -> {
});
});
if (itemClickListener != null) {
SubscribedSubredditData communityData = mSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset);
viewHolder.itemView.setOnClickListener(view -> itemClickListener.onClick(communityData));
}
}
if (itemClickListener == null) {
String finalFullname = fullname;
viewHolder.itemView.setOnClickListener(view -> {
@@ -186,27 +220,52 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
.into(((SubredditViewHolder) viewHolder).iconGifImageView);
}
((SubredditViewHolder) viewHolder).subredditNameTextView.setText(name);
if (fullname.contains("@")) {
((SubredditViewHolder) viewHolder).communityInstanceTextView.setText(fullname.substring(fullname.indexOf("@")));
}
} else if (viewHolder instanceof FavoriteSubredditViewHolder) {
int offset;
if (itemClickListener != null) {
if (hasClearSelectionRow) {
offset = 3;
} else {
offset = 2;
} else {
offset = 1;
}
} else {
offset = 1;
}
SubscribedSubredditData communityData = mFavoriteSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset);
String name = mFavoriteSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset).getName();
String fullname = mFavoriteSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset).getQualified_name();
String iconUrl = mFavoriteSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset).getIconUrl();
if (mFavoriteSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset).isFavorite()) {
((FavoriteSubredditViewHolder) viewHolder).favoriteImageView.setImageResource(R.drawable.ic_favorite_24dp);
} else {
((FavoriteSubredditViewHolder) viewHolder).favoriteImageView.setImageResource(R.drawable.ic_favorite_border_24dp);
}
((FavoriteSubredditViewHolder) viewHolder).favoriteImageView.setOnClickListener(view -> {
if (mFavoriteSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset).isFavorite()) {
((FavoriteSubredditViewHolder) viewHolder).favoriteImageView.setImageResource(R.drawable.ic_favorite_border_24dp);
mFavoriteSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset).setFavorite(false);
} else {
((FavoriteSubredditViewHolder) viewHolder).favoriteImageView.setImageResource(R.drawable.ic_favorite_24dp);
mFavoriteSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset).setFavorite(true);
}
InsertSubscribedThings.insertSubscribedThings(mExecutor, new Handler(), mRedditDataRoomDatabase, mFavoriteSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset),
() -> {
});
});
if (itemClickListener != null) {
viewHolder.itemView.setOnClickListener(view -> itemClickListener.onClick(communityData));
} else {
viewHolder.itemView.setOnClickListener(view -> {
Intent intent = new Intent(mActivity, ViewSubredditDetailActivity.class);
intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, name);
intent.putExtra(ViewSubredditDetailActivity.EXTRA_COMMUNITY_FULL_NAME_KEY,
mFavoriteSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset).getQualified_name());
mActivity.startActivity(intent);
});
}
@@ -223,15 +282,26 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
.into(((FavoriteSubredditViewHolder) viewHolder).iconGifImageView);
}
((FavoriteSubredditViewHolder) viewHolder).subredditNameTextView.setText(name);
if (fullname.contains("@")) {
((FavoriteSubredditViewHolder) viewHolder).communityInstanceTextView.setText(fullname.substring(fullname.indexOf("@")));
}
}
}
@Override
public int getItemCount() {
if (mSubscribedSubredditData != null) {
if (mFavoriteSubscribedSubredditData != null && mFavoriteSubscribedSubredditData.size() > 0) {
if (itemClickListener != null) {
return mSubscribedSubredditData.size() > 0 ?
mFavoriteSubscribedSubredditData.size() + mSubscribedSubredditData.size() + ((hasClearSelectionRow) ? 3 : 2) : 0;
}
return mSubscribedSubredditData.size() > 0 ?
mFavoriteSubscribedSubredditData.size() + mSubscribedSubredditData.size() + 2 : 0;
}
if (itemClickListener != null) {
return mSubscribedSubredditData.size() > 0 ? mSubscribedSubredditData.size() + ((hasClearSelectionRow) ? 1 : 0) : 0;
return (hasClearSelectionRow) ? mSubscribedSubredditData.size() + 1 : mSubscribedSubredditData.size();
}
return mSubscribedSubredditData.size();
@@ -239,10 +309,12 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
return 0;
}
@Override
public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) {
if(holder instanceof SubredditViewHolder) {
glide.clear(((SubredditViewHolder) holder).iconGifImageView);
((SubredditViewHolder) holder).favoriteImageView.setVisibility(View.VISIBLE);
} else if (holder instanceof FavoriteSubredditViewHolder) {
glide.clear(((FavoriteSubredditViewHolder) holder).iconGifImageView);
}
@@ -279,10 +351,10 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
if (itemClickListener != null) {
if (hasClearSelectionRow) {
offset = (mFavoriteSubscribedSubredditData != null && mFavoriteSubscribedSubredditData.size() > 0) ?
mFavoriteSubscribedSubredditData.size() + 4 : 0;
mFavoriteSubscribedSubredditData.size() + 3 : 0;
} else {
offset = (mFavoriteSubscribedSubredditData != null && mFavoriteSubscribedSubredditData.size() > 0) ?
mFavoriteSubscribedSubredditData.size() + 3 : 0;
mFavoriteSubscribedSubredditData.size() + 2 : 0;
}
} else {
offset = (mFavoriteSubscribedSubredditData != null && mFavoriteSubscribedSubredditData.size() > 0) ?
@@ -295,9 +367,9 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
int offset;
if (itemClickListener != null) {
if (hasClearSelectionRow) {
offset = 3;
} else {
offset = 2;
} else {
offset = 1;
}
} else {
offset = 1;
@@ -318,13 +390,20 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
@BindView(R.id.thing_name_text_view_item_subscribed_thing)
TextView subredditNameTextView;
@BindView(R.id.thing_instance_text_view_item_subscribed_thing)
TextView communityInstanceTextView;
@BindView(R.id.favorite_image_view_item_subscribed_thing)
ImageView favoriteImageView;
SubredditViewHolder(View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
if (mActivity.typeface != null) {
subredditNameTextView.setTypeface(mActivity.typeface);
communityInstanceTextView.setTypeface(mActivity.typeface);
}
subredditNameTextView.setTextColor(primaryTextColor);
communityInstanceTextView.setTextColor(CustomThemeWrapper.darkenColor(primaryTextColor, 0.7f));
}
}
@@ -334,13 +413,21 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
@BindView(R.id.thing_name_text_view_item_subscribed_thing)
TextView subredditNameTextView;
@BindView(R.id.thing_instance_text_view_item_subscribed_thing)
TextView communityInstanceTextView;
@BindView(R.id.favorite_image_view_item_subscribed_thing)
ImageView favoriteImageView;
FavoriteSubredditViewHolder(View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
if (mActivity.typeface != null) {
subredditNameTextView.setTypeface(mActivity.typeface);
communityInstanceTextView.setTypeface(mActivity.typeface);
}
subredditNameTextView.setTextColor(primaryTextColor);
communityInstanceTextView.setTextColor(CustomThemeWrapper.darkenColor(primaryTextColor, 0.7f));
}
}

View File

@@ -136,7 +136,9 @@ public class UserListingRecyclerViewAdapter extends PagedListAdapter<UserData, R
.into(((DataViewHolder) holder).iconGifImageView);
}
((DataViewHolder) holder).userNameTextView.setText(userData.getName());
((DataViewHolder) holder).userNameTextView.setText(userData.getTitle().equals("") ? userData.getName() : userData.getTitle());
String qualifiedName = LemmyUtils.actorID2FullName(userData.getActorId());
((DataViewHolder) holder).userInstanceTextView.setText(qualifiedName.substring(qualifiedName.indexOf('@')));
if (!isMultiSelection) {
CheckIsFollowingUser.checkIsFollowingUser(executor, new Handler(), redditDataRoomDatabase,
@@ -237,6 +239,9 @@ public class UserListingRecyclerViewAdapter extends PagedListAdapter<UserData, R
GifImageView iconGifImageView;
@BindView(R.id.user_name_text_view_item_user_listing)
TextView userNameTextView;
@BindView(R.id.user_instance_text_view_item_user_listing)
TextView userInstanceTextView;
@BindView(R.id.subscribe_image_view_item_user_listing)
ImageView subscribeButton;
@BindView(R.id.checkbox__item_user_listing)
@@ -246,6 +251,7 @@ public class UserListingRecyclerViewAdapter extends PagedListAdapter<UserData, R
super(itemView);
ButterKnife.bind(this, itemView);
userNameTextView.setTextColor(primaryTextColor);
userInstanceTextView.setTextColor(CustomThemeWrapper.darkenColor(primaryTextColor, 0.7f));
subscribeButton.setColorFilter(unsubscribedColor, android.graphics.PorterDuff.Mode.SRC_IN);
if (activity.typeface != null) {

View File

@@ -24,7 +24,7 @@ public class LemmySectionRecyclerViewAdapter extends RecyclerView.Adapter<Recycl
private static final int VIEW_TYPE_MENU_ITEM = 2;
private static final int LEMMY_SECTION_ITEMS = 2;
private static final int LEMMY_SECTION_ANONYMOUS_ITEMS = 1;
private static final int LEMMY_SECTION_ANONYMOUS_ITEMS = 2;
private final boolean isLoggedIn;
private BaseActivity baseActivity;
@@ -93,9 +93,15 @@ public class LemmySectionRecyclerViewAdapter extends RecyclerView.Adapter<Recycl
drawableId = R.drawable.ic_baseline_info_24;
break;
case 2:
stringId = R.string.blocks;
drawableId = R.drawable.ic_outline_lock_24dp;
break;
if (isLoggedIn) {
stringId = R.string.blocks;
drawableId = R.drawable.ic_outline_lock_24dp;
break;
} else {
stringId = R.string.anonymous_account_instance;
drawableId = R.drawable.ic_account_circle_24dp;
break;
}
}
((MenuItemViewHolder) holder).menuTextView.setText(stringId);

View File

@@ -101,7 +101,16 @@ public interface LemmyAPI {
Call<String> postDelete(@Body DeletePostDTO params);
@GET("api/v3/user")
ListenableFuture<Response<String>> getUserPosts(
ListenableFuture<Response<String>> getUserPostsListenableFuture(
@Query("username") String username,
@Query("sort") String sort,
@Query("page") Integer page,
@Query("limit") Integer limit,
@Query("saved_only") Boolean saved_only,
@Query("auth") String access_token);
@GET("api/v3/user")
Call<String> getUserPosts(
@Query("username") String username,
@Query("sort") String sort,
@Query("page") Integer page,
@@ -129,7 +138,19 @@ public interface LemmyAPI {
);
@GET("api/v3/post/list")
ListenableFuture<Response<String>> getPosts(
ListenableFuture<Response<String>> getPostsListenableFuture(
@Query("type_") String type_,
@Query("sort") String sort,
@Query("page") Integer page,
@Query("limit") Integer limit,
@Query("community_id") Integer community_id,
@Query("community_name") String community_name,
@Query("saved_only") Boolean saved_only,
@Query("auth") String auth
);
@GET("api/v3/post/list")
Call<String> getPosts(
@Query("type_") String type_,
@Query("sort") String sort,
@Query("page") Integer page,

View File

@@ -6,14 +6,16 @@ import retrofit2.Call;
import retrofit2.http.FieldMap;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.HeaderMap;
import retrofit2.http.POST;
import retrofit2.http.Path;
import retrofit2.http.Query;
public interface RedgifsAPI {
@GET("/v2/gifs/{id}")
Call<String> getRedgifsData(@HeaderMap Map<String, String> headers, @Path("id") String id, @Query("user-agent") String userAgent);
Call<String> getRedgifsData(@Path("id") String id);
@GET("/v2/gifs")
Call<String> getRedgifsMultipleData(@Query("ids") String ids);
@FormUrlEncoded
@POST("/v2/oauth/client")

View File

@@ -38,7 +38,7 @@ public class InsertSubscribedThings {
if (subscribedSubredditDataList != null) {
List<SubscribedSubredditData> existingSubscribedSubredditDataList =
subscribedSubredditDao.getAllSubscribedSubredditsList(accountName);
Collections.sort(subscribedSubredditDataList, (subscribedSubredditData, t1) -> subscribedSubredditData.getName().compareToIgnoreCase(t1.getName()));
Collections.sort(subscribedSubredditDataList, (subscribedSubredditData, t1) -> subscribedSubredditData.getQualified_name().compareToIgnoreCase(t1.getQualified_name()));
List<String> unsubscribedSubreddits = new ArrayList<>();
compareTwoSubscribedSubredditList(subscribedSubredditDataList, existingSubscribedSubredditDataList,
unsubscribedSubreddits);
@@ -48,6 +48,9 @@ public class InsertSubscribedThings {
}
for (SubscribedSubredditData s : subscribedSubredditDataList) {
if (existingSubscribedSubredditDataList.contains(s)) {
continue;
}
subscribedSubredditDao.insert(s);
}
}
@@ -79,7 +82,8 @@ public class InsertSubscribedThings {
});
}
public static void insertSubscribedThings(Executor executor, Handler handler, RedditDataRoomDatabase redditDataRoomDatabase,
public static void insertSubscribedThings(Executor executor, Handler
handler, RedditDataRoomDatabase redditDataRoomDatabase,
SubscribedSubredditData singleSubscribedSubredditData,
InsertSubscribedThingListener insertSubscribedThingListener) {
executor.execute(() -> {
@@ -94,7 +98,8 @@ public class InsertSubscribedThings {
});
}
public static void insertSubscribedThings(Executor executor, Handler handler, RedditDataRoomDatabase redditDataRoomDatabase,
public static void insertSubscribedThings(Executor executor, Handler
handler, RedditDataRoomDatabase redditDataRoomDatabase,
SubscribedUserData mSingleSubscribedUserData,
InsertSubscribedThingListener insertSubscribedThingListener) {
executor.execute(() -> {
@@ -109,35 +114,32 @@ public class InsertSubscribedThings {
});
}
private static void compareTwoSubscribedSubredditList(List<SubscribedSubredditData> newSubscribedSubreddits,
List<SubscribedSubredditData> oldSubscribedSubreddits,
List<String> unsubscribedSubredditNames) {
int newIndex = 0;
for (int oldIndex = 0; oldIndex < oldSubscribedSubreddits.size(); oldIndex++) {
if (newIndex >= newSubscribedSubreddits.size()) {
for (; oldIndex < oldSubscribedSubreddits.size(); oldIndex++) {
unsubscribedSubredditNames.add(oldSubscribedSubreddits.get(oldIndex).getName());
}
return;
}
private static void compareTwoSubscribedSubredditList
(List<SubscribedSubredditData> newSubscribedSubreddits,
List<SubscribedSubredditData> oldSubscribedSubreddits,
List<String> unsubscribedSubredditNames) {
List<String> oldSubredditNames = new ArrayList<>();
for (SubscribedSubredditData subredditData : oldSubscribedSubreddits) {
oldSubredditNames.add(subredditData.getQualified_name());
}
SubscribedSubredditData old = oldSubscribedSubreddits.get(oldIndex);
for (; newIndex < newSubscribedSubreddits.size(); newIndex++) {
if (newSubscribedSubreddits.get(newIndex).getName().compareToIgnoreCase(old.getName()) == 0) {
newIndex++;
break;
}
if (newSubscribedSubreddits.get(newIndex).getName().compareToIgnoreCase(old.getName()) > 0) {
unsubscribedSubredditNames.add(old.getName());
break;
}
List<String> newSubredditNames = new ArrayList<>();
for (SubscribedSubredditData subredditData : newSubscribedSubreddits) {
newSubredditNames.add(subredditData.getQualified_name());
}
for (String subredditName : oldSubredditNames) {
if (!newSubredditNames.contains(subredditName)) {
unsubscribedSubredditNames.add(subredditName);
}
}
}
private static void compareTwoSubscribedUserList(List<SubscribedUserData> newSubscribedUsers,
List<SubscribedUserData> oldSubscribedUsers,
List<String> unsubscribedUserNames) {
private static void compareTwoSubscribedUserList
(List<SubscribedUserData> newSubscribedUsers,
List<SubscribedUserData> oldSubscribedUsers,
List<String> unsubscribedUserNames) {
int newIndex = 0;
for (int oldIndex = 0; oldIndex < oldSubscribedUsers.size(); oldIndex++) {
if (newIndex >= newSubscribedUsers.size()) {

View File

@@ -15,7 +15,7 @@ import retrofit2.Retrofit;
public class LoadSubredditIcon {
public static void loadSubredditIcon(Executor executor, Handler handler, RedditDataRoomDatabase redditDataRoomDatabase,
String subredditName, String accessToken, Retrofit oauthRetrofit, Retrofit retrofit,
String subredditName, String accessToken, Retrofit retrofit,
LoadSubredditIconAsyncTaskListener loadSubredditIconAsyncTaskListener) {
executor.execute(() -> {
SubredditDao subredditDao = redditDataRoomDatabase.subredditDao();

View File

@@ -2,6 +2,7 @@ package eu.toldi.infinityforlemmy.asynctasks;
import android.content.SharedPreferences;
import android.os.Handler;
import android.util.Log;
import java.util.concurrent.Executor;
@@ -25,18 +26,31 @@ public class SwitchAccount {
.putString(SharedPreferencesUtils.ACCESS_TOKEN, account.getAccessToken())
.putString(SharedPreferencesUtils.ACCOUNT_NAME, account.getDisplay_name())
.putString(SharedPreferencesUtils.ACCOUNT_QUALIFIED_NAME, account.getAccountName())
.putString(SharedPreferencesUtils.ACCOUNT_INSTANCE,account.getInstance_url())
.putString(SharedPreferencesUtils.ACCOUNT_INSTANCE, account.getInstance_url())
.putBoolean(SharedPreferencesUtils.BEARER_TOKEN_AUTH, false)
.putString(SharedPreferencesUtils.ACCOUNT_IMAGE_URL, account.getProfileImageUrl()).apply();
retrofitHolder.setBaseURL(account.getInstance_url());
retrofitHolder.setAccessToken(null);
FetchSiteInfo.fetchSiteInfo(retrofitHolder.getRetrofit(), account.getAccessToken(), new FetchSiteInfo.FetchSiteInfoListener() {
@Override
public void onFetchSiteInfoSuccess(SiteInfo siteInfo) {
boolean canDownvote = siteInfo.isEnable_downvotes();
currentAccountSharedPreferences.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)) {
retrofitHolder.setAccessToken(account.getAccessToken());
currentAccountSharedPreferences.edit().putBoolean(SharedPreferencesUtils.BEARER_TOKEN_AUTH, true).apply();
}
}
}
@Override
public void onFetchSiteInfoFailed() {
Log.e("SwitchAccount", "Failed to fetch site info");
currentAccountSharedPreferences.edit().putBoolean(SharedPreferencesUtils.CAN_DOWNVOTE, true).apply();
}
});

View File

@@ -4,6 +4,7 @@ package eu.toldi.infinityforlemmy.bottomsheetfragments;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
@@ -23,6 +24,7 @@ import androidx.fragment.app.Fragment;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import javax.inject.Inject;
import javax.inject.Named;
import butterknife.BindView;
import butterknife.ButterKnife;
@@ -37,6 +39,7 @@ import eu.toldi.infinityforlemmy.comment.Comment;
import eu.toldi.infinityforlemmy.comment.LemmyCommentAPI;
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
import eu.toldi.infinityforlemmy.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment;
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
import eu.toldi.infinityforlemmy.utils.Utils;
@@ -72,8 +75,14 @@ public class CommentMoreBottomSheetFragment extends LandscapeExpandedRoundedBott
@Inject
CustomThemeWrapper mCustomThemeWrapper;
@Inject
@Named("default")
SharedPreferences mSharedPreferences;
private BaseActivity activity;
private boolean mShareLinksOnLocalInstance;
public CommentMoreBottomSheetFragment() {
// Required empty public constructor
}
@@ -103,6 +112,7 @@ public class CommentMoreBottomSheetFragment extends LandscapeExpandedRoundedBott
String accessToken = bundle.getString(EXTRA_ACCESS_TOKEN);
boolean editAndDeleteAvailable = bundle.getBoolean(EXTRA_EDIT_AND_DELETE_AVAILABLE, false);
boolean showReplyAndSaveOption = bundle.getBoolean(EXTRA_SHOW_REPLY_AND_SAVE_OPTION, false);
mShareLinksOnLocalInstance = mSharedPreferences.getBoolean(SharedPreferencesUtils.SHARE_LINK_ON_LOCAL_INSTANCE, false);
if (accessToken != null && !accessToken.equals("")) {
@@ -167,13 +177,13 @@ public class CommentMoreBottomSheetFragment extends LandscapeExpandedRoundedBott
dismiss();
});
}
String link = (mShareLinksOnLocalInstance) ? lemmyCommentAPI.getRetrofitHolder().getBaseURL() + "/comment/" + comment.getId() : comment.getPermalink();
shareTextView.setOnClickListener(view -> {
dismiss();
try {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, comment.getPermalink());
intent.putExtra(Intent.EXTRA_TEXT, link);
activity.startActivity(Intent.createChooser(intent, getString(R.string.share)));
} catch (ActivityNotFoundException e) {
Toast.makeText(activity, R.string.no_activity_found_for_share, Toast.LENGTH_SHORT).show();
@@ -182,7 +192,7 @@ public class CommentMoreBottomSheetFragment extends LandscapeExpandedRoundedBott
shareTextView.setOnLongClickListener(view -> {
dismiss();
activity.copyLink(comment.getPermalink());
activity.copyLink(link);
return true;
});
@@ -201,6 +211,12 @@ public class CommentMoreBottomSheetFragment extends LandscapeExpandedRoundedBott
LayoutInflater dialog_inflater = LayoutInflater.from(activity);
View dialog_view = dialog_inflater.inflate(R.layout.dialog_report, null);
EditText reasonEditText = dialog_view.findViewById(R.id.reasonEditText);
reasonEditText.setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
reasonEditText.setHintTextColor(mCustomThemeWrapper.getSecondaryTextColor());
if (activity.typeface != null) {
reasonEditText.setTypeface(activity.typeface);
}
reasonEditText.setHighlightColor(mCustomThemeWrapper.getColorAccent());
MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(activity)
.setTitle(R.string.report_post)

View File

@@ -8,6 +8,7 @@ import java.util.Arrays;
import java.util.List;
import eu.toldi.infinityforlemmy.BuildConfig;
import eu.toldi.infinityforlemmy.user.BasicUserInfo;
public class Comment implements Parcelable {
public static final int VOTE_TYPE_NO_VOTE = 0;
@@ -29,9 +30,7 @@ public class Comment implements Parcelable {
};
private int id;
private String fullName;
private String author;
private String authorQualifiedName;
private String authorIconUrl;
private BasicUserInfo author;
private String linkAuthor;
private long commentTimeMillis;
private String commentMarkdown;
@@ -66,16 +65,14 @@ public class Comment implements Parcelable {
private List<String> path;
private int postId;
public Comment(int id, int postId, String fullName, String author, String authorQualifiedName, String linkAuthor,
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,
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) {
this.id = id;
this.postId = postId;
this.fullName = fullName;
this.author = author;
this.authorQualifiedName = authorQualifiedName;
this.linkAuthor = linkAuthor;
this.commentTimeMillis = commentTimeMillis;
this.commentMarkdown = commentMarkdown;
@@ -122,10 +119,7 @@ public class Comment implements Parcelable {
protected Comment(Parcel in) {
id = in.readInt();
postId = in.readInt();
fullName = in.readString();
author = in.readString();
authorQualifiedName = in.readString();
authorIconUrl = in.readString();
author = in.readParcelable(BasicUserInfo.class.getClassLoader());
linkAuthor = in.readString();
commentTimeMillis = in.readLong();
commentMarkdown = in.readString();
@@ -169,8 +163,8 @@ public class Comment implements Parcelable {
return fullName;
}
public String getAuthor() {
return author;
public String getAuthorName() {
return author.getDisplayName();
}
public boolean isAuthorDeleted() {
@@ -178,16 +172,17 @@ public class Comment implements Parcelable {
}
public void setAuthor(String author) {
this.author = author;
//this.author = author;
}
public String getAuthorIconUrl() {
return authorIconUrl;
return author.getAvatar();
}
public void setAuthorIconUrl(String authorIconUrl) {
this.authorIconUrl = authorIconUrl;
//this.authorIconUrl = authorIconUrl;
}
public String getLinkAuthor() {
@@ -435,10 +430,7 @@ public class Comment implements Parcelable {
public void writeToParcel(Parcel parcel, int i) {
parcel.writeInt(id);
parcel.writeInt(postId);
parcel.writeString(fullName);
parcel.writeString(author);
parcel.writeString(authorQualifiedName);
parcel.writeString(authorIconUrl);
parcel.writeParcelable(author, i);
parcel.writeString(linkAuthor);
parcel.writeLong(commentTimeMillis);
parcel.writeString(commentMarkdown);
@@ -486,7 +478,7 @@ public class Comment implements Parcelable {
}
public String getAuthorQualifiedName() {
return authorQualifiedName;
return author.getQualifiedName();
}
public String getCommunityQualifiedName() {
@@ -496,4 +488,8 @@ public class Comment implements Parcelable {
public int getPostId() {
return postId;
}
public BasicUserInfo getAuthor() {
return author;
}
}

View File

@@ -110,7 +110,7 @@ public class FetchRemovedComment {
boolean isSubmitter = result.getBoolean(JSONUtils.IS_SUBMITTER_KEY);
if (id.equals(comment.getId()) &&
(!author.equals(comment.getAuthor()) ||
(!author.equals(comment.getAuthorName()) ||
!body.equals(comment.getCommentRawText()))
) {
comment.setAuthor(author);

View File

@@ -56,7 +56,7 @@ public class FetchRemovedCommentReveddit {
String author = result.getString(JSONUtils.AUTHOR_KEY);
String body = Utils.modifyMarkdown(Utils.trimTrailingWhitespace(result.optString(JSONUtils.BODY_KEY)));
if (id.equals(comment.getId()) && (!author.equals(comment.getAuthor()) || !body.equals(comment.getCommentRawText()))) {
if (id.equals(comment.getId()) && (!author.equals(comment.getAuthorName()) || !body.equals(comment.getCommentRawText()))) {
comment.setAuthor(author);
comment.setCommentMarkdown(body);
comment.setCommentRawText(body);

View File

@@ -24,6 +24,7 @@ import java.util.TimeZone;
import java.util.concurrent.Executor;
import java.util.regex.Pattern;
import eu.toldi.infinityforlemmy.user.BasicUserInfo;
import eu.toldi.infinityforlemmy.utils.JSONUtils;
import eu.toldi.infinityforlemmy.utils.LemmyUtils;
@@ -340,10 +341,10 @@ public class ParseComment {
boolean saved = jsonObject.getBoolean("saved");
boolean deleted = commentObj.getBoolean("deleted");
long edited = 0;
Comment comment = new Comment(id, postID, fullName, author, authorQualifiedName, linkAuthor, commentTimeMillis,
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, distinguished, permalink, depth, collapsed, hasReply, saved, deleted, edited, path);
int child_count = countsObj.getInt("child_count");
comment.setChildCount(child_count);
comment.setAuthorIconUrl(authorAvatar);

View File

@@ -54,407 +54,412 @@ public class CustomThemeWrapper {
public int getColorPrimary() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.COLOR_PRIMARY,
getDefaultColor("#0336FF", "#393A59", "#000000"));
getDefaultColor("#F2E9E1", "#2B3B51", "#282828"));
}
public int getColorPrimaryDark() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.COLOR_PRIMARY_DARK,
getDefaultColor("#002BF0", "#393A59", "#000000"));
getDefaultColor("#F2E9E1", "#192330", "#161616"));
}
public int getColorAccent() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.COLOR_ACCENT,
getDefaultColor("#FF1868", "#F8F8F2", "#FF1868"));
getDefaultColor("#3D2B5A", "#CDCECF", "#F2F4F8"));
}
public int getColorPrimaryLightTheme() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.COLOR_PRIMARY_LIGHT_THEME,
getDefaultColor("#0336FF", "#393A59", "#0336FF"));
getDefaultColor("#F2E9E1", "#192330", "#161616"));
}
public int getPrimaryTextColor() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.PRIMARY_TEXT_COLOR,
getDefaultColor("#000000", "#FFFFFF", "#FFFFFF"));
getDefaultColor("#3D2B5A", "#CDCECF", "#F2F4F8"));
}
public int getSecondaryTextColor() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.SECONDARY_TEXT_COLOR,
getDefaultColor("#8A000000", "#B3FFFFFF", "#B3FFFFFF"));
getDefaultColor("#352C24", "#DFDFE0", "#E4E4E5"));
}
public int getPostTitleColor() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.POST_TITLE_COLOR,
getDefaultColor("#000000", "#FFFFFF", "#FFFFFF"));
getDefaultColor("#3D2B5A", "#CDCECF", "#F2F4F8"));
}
public int getPostContentColor() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.POST_CONTENT_COLOR,
getDefaultColor("#8A000000", "#B3FFFFFF", "#B3FFFFFF"));
getDefaultColor("#352C24", "#DFDFE0", "#E4E4E5"));
}
public int getReadPostTitleColor() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.READ_POST_TITLE_COLOR,
getDefaultColor("#9D9D9D", "#9D9D9D", "#979797"));
getDefaultColor("#352C24", "#738091", "#484848"));
}
public int getReadPostContentColor() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.READ_POST_CONTENT_COLOR,
getDefaultColor("#9D9D9D", "#9D9D9D", "#979797"));
getDefaultColor("#352C24", "#738091", "#484848"));
}
public int getCommentColor() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.COMMENT_COLOR,
getDefaultColor("#000000", "#FFFFFF", "#FFFFFF"));
getDefaultColor("#3D2B5A", "#CDCECF", "#F2F4F8"));
}
public int getButtonTextColor() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.BUTTON_TEXT_COLOR,
getDefaultColor("#FFFFFF", "#FFFFFF", "#FFFFFF"));
getDefaultColor("#3D2B5A", "#CDCECF", "#F2F4F8"));
}
public int getBackgroundColor() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.BACKGROUND_COLOR,
getDefaultColor("#FFFFFF", "#282A36", "#000000"));
getDefaultColor("#F6F2EE", "#192330", "#161616"));
}
public int getCardViewBackgroundColor() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.CARD_VIEW_BACKGROUND_COLOR,
getDefaultColor("#FFFFFF", "#393A59", "#000000"));
getDefaultColor("#F2E9E1", "#2B3B51", "#282828"));
}
public int getReadPostCardViewBackgroundColor() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.READ_POST_CARD_VIEW_BACKGROUND_COLOR,
getDefaultColor("#F5F5F5", "#1C1F3D", "#000000"));
getDefaultColor("#F2E9E1", "#2B3B51", "#282828"));
}
public int getCommentBackgroundColor() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.COMMENT_BACKGROUND_COLOR,
getDefaultColor("#FFFFFF", "#393A59", "#000000"));
getDefaultColor("#F6F2EE", "#192330", "#282828"));
}
public int getBottomAppBarBackgroundColor() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.BOTTOM_APP_BAR_BACKGROUND_COLOR,
getDefaultColor("#FFFFFF", "#393A59", "#000000"));
getDefaultColor("#F2E9E1", "#2B3B51", "#161616"));
}
public int getPrimaryIconColor() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.PRIMARY_ICON_COLOR,
getDefaultColor("#000000", "#FFFFFF", "#FFFFFF"));
getDefaultColor("#3D2B5A", "#CDCECF", "#F2F4F8"));
}
public int getBottomAppBarIconColor() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.BOTTOM_APP_BAR_ICON_COLOR,
getDefaultColor("#000000", "#FFFFFF", "#FFFFFF"));
getDefaultColor("#3D2B5A", "#CDCECF", "#F2F4F8"));
}
public int getPostIconAndInfoColor() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.POST_ICON_AND_INFO_COLOR,
getDefaultColor("#8A000000", "#B3FFFFFF", "#B3FFFFFF"));
getDefaultColor("#352C24", "#DFDFE0", "#E4E4E5"));
}
public int getCommentIconAndInfoColor() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.COMMENT_ICON_AND_INFO_COLOR,
getDefaultColor("#8A000000", "#B3FFFFFF", "#B3FFFFFF"));
getDefaultColor("#352C24", "#DFDFE0", "#E4E4E5"));
}
public int getToolbarPrimaryTextAndIconColor() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.TOOLBAR_PRIMARY_TEXT_AND_ICON_COLOR,
getDefaultColor("#FFFFFF", "#FFFFFF", "#FFFFFF"));
getDefaultColor("#352C24", "#CDCECF", "#F2F4F8"));
}
public int getToolbarSecondaryTextColor() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.TOOLBAR_SECONDARY_TEXT_COLOR,
getDefaultColor("#FFFFFF", "#FFFFFF", "#FFFFFF"));
getDefaultColor("#352C24", "#CDCECF", "#F2F4F8"));
}
public int getCircularProgressBarBackground() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.CIRCULAR_PROGRESS_BAR_BACKGROUND,
getDefaultColor("#FFFFFF", "#393A59", "#000000"));
getDefaultColor("#F6F2EE", "#2B3B51", "#282828"));
}
public int getMediaIndicatorIconColor() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.MEDIA_INDICATOR_ICON_COLOR,
getDefaultColor("#FFFFFF", "#FFFFFF", "#000000"));
getDefaultColor("#F6F2EE", "#393B44", "#161616"));
}
public int getMediaIndicatorBackgroundColor() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.MEDIA_INDICATOR_BACKGROUND_COLOR,
getDefaultColor("#000000", "#000000", "#FFFFFF"));
getDefaultColor("#3D2B5A", "#CDCECF", "#F2F4F8"));
}
public int getTabLayoutWithExpandedCollapsingToolbarTabBackground() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.TAB_LAYOUT_WITH_EXPANDED_COLLAPSING_TOOLBAR_TAB_BACKGROUND,
getDefaultColor("#FFFFFF", "#393A59", "#000000"));
getDefaultColor("#F6F2EE", "#2B3B51", "#282828"));
}
public int getTabLayoutWithExpandedCollapsingToolbarTextColor() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.TAB_LAYOUT_WITH_EXPANDED_COLLAPSING_TOOLBAR_TEXT_COLOR,
getDefaultColor("#0336FF", "#FFFFFF", "#FFFFFF"));
getDefaultColor("#352C24", "#CDCECF", "#F2F4F8"));
}
public int getTabLayoutWithExpandedCollapsingToolbarTabIndicator() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.TAB_LAYOUT_WITH_EXPANDED_COLLAPSING_TOOLBAR_TAB_INDICATOR,
getDefaultColor("#0336FF", "#FFFFFF", "#FFFFFF"));
getDefaultColor("#352C24", "#CDCECF", "#F2F4F8"));
}
public int getTabLayoutWithCollapsedCollapsingToolbarTabBackground() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.TAB_LAYOUT_WITH_COLLAPSED_COLLAPSING_TOOLBAR_TAB_BACKGROUND,
getDefaultColor("#0336FF", "#393A59", "#000000"));
getDefaultColor("#F6F2EE", "#2B3B51", "#282828"));
}
public int getTabLayoutWithCollapsedCollapsingToolbarTextColor() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.TAB_LAYOUT_WITH_COLLAPSED_COLLAPSING_TOOLBAR_TEXT_COLOR,
getDefaultColor("#FFFFFF", "#FFFFFF", "#FFFFFF"));
getDefaultColor("#352C24", "#CDCECF", "#F2F4F8"));
}
public int getTabLayoutWithCollapsedCollapsingToolbarTabIndicator() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.TAB_LAYOUT_WITH_COLLAPSED_COLLAPSING_TOOLBAR_TAB_INDICATOR,
getDefaultColor("#FFFFFF", "#FFFFFF", "#FFFFFF"));
getDefaultColor("#352C24", "#CDCECF", "#F2F4F8"));
}
public int getUpvoted() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.UPVOTED,
getDefaultColor("#FF1868", "#FF008C", "#FF1868"));
getDefaultColor("#A5222F", "#DBC074", "#F16DA6"));
}
public int getDownvoted() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.DOWNVOTED,
getDefaultColor("#007DDE", "#007DDE", "#007DDE"));
getDefaultColor("#4863B6", "#D16983", "#52BDFF"));
}
public int getPostTypeBackgroundColor() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.POST_TYPE_BACKGROUND_COLOR,
getDefaultColor("#002BF0", "#0336FF", "#0336FF"));
getDefaultColor("#4863B6", "#719CD6", "#33B1FF"));
}
public int getPostTypeTextColor() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.POST_TYPE_TEXT_COLOR,
getDefaultColor("#FFFFFF", "#FFFFFF", "#FFFFFF"));
getDefaultColor("#F6F2EE", "#DFDFE0", "#282828"));
}
public int getSpoilerBackgroundColor() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.SPOILER_BACKGROUND_COLOR,
getDefaultColor("#EE02EB", "#EE02EB", "#EE02EB"));
getDefaultColor("#A440B5", "#E0C989", "#F16DA6"));
}
public int getSpoilerTextColor() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.SPOILER_TEXT_COLOR,
getDefaultColor("#FFFFFF", "#FFFFFF", "#FFFFFF"));
getDefaultColor("#F6F2EE", "#393B44", "#282828"));
}
public int getNsfwBackgroundColor() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.NSFW_BACKGROUND_COLOR,
getDefaultColor("#FF1868", "#FF1868", "#FF1868"));
getDefaultColor("#A5222F", "#D16983", "#F16DA6"));
}
public int getNsfwTextColor() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.NSFW_TEXT_COLOR,
getDefaultColor("#FFFFFF", "#FFFFFF", "#FFFFFF"));
getDefaultColor("#F6F2EE", "#393B44", "#282828"));
}
public int getFlairBackgroundColor() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.FLAIR_BACKGROUND_COLOR,
getDefaultColor("#00AA8C", "#00AA8C", "#00AA8C"));
getDefaultColor("#488D93", "#9D79D6", "#3DDBD9"));
}
public int getFlairTextColor() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.FLAIR_TEXT_COLOR,
getDefaultColor("#FFFFFF", "#FFFFFF", "#FFFFFF"));
getDefaultColor("#F6F2EE", "#DFDFE0", "#282828"));
}
public int getAwardsBackgroundColor() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.AWARDS_BACKGROUND_COLOR,
getDefaultColor("#EEAB02", "#EEAB02", "#EEAB02"));
getDefaultColor("#B86E28", "#E0C989", "#3DDBD9"));
}
public int getAwardsTextColor() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.AWARDS_TEXT_COLOR,
getDefaultColor("#FFFFFF", "#FFFFFF", "#FFFFFF"));
getDefaultColor("#F6F2EE", "#575860", "#282828"));
}
public int getArchivedIconTint() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.ARCHIVED_ICON_TINT,
getDefaultColor("#B4009F", "#B4009F", "#B4009F"));
getDefaultColor("#A440B5", "#D67AD2", "#EE5396"));
}
public int getLockedIconTint() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.LOCKED_ICON_TINT,
getDefaultColor("#EE7302", "#EE7302", "#EE7302"));
getDefaultColor("#AC5402", "#F4A261", "#EE5396"));
}
public int getCrosspostIconTint() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.CROSSPOST_ICON_TINT,
getDefaultColor("#FF1868", "#FF1868", "#FF1868"));
getDefaultColor("#A5222F", "#DBC074", "#F16DA6"));
}
public int getUpvoteRatioIconTint() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.UPVOTE_RATIO_ICON_TINT,
getDefaultColor("#0256EE", "#0256EE", "#0256EE"));
getDefaultColor("#2848A9", "#86ABDC", "#33B1FF"));
}
public int getStickiedPostIconTint() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.STICKIED_POST_ICON_TINT,
getDefaultColor("#002BF0", "#02ABEE", "#0336FF"));
getDefaultColor("#4863B6", "#719CD6", "#33B1FF"));
}
public int getNoPreviewPostTypeIconTint() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.NO_PREVIEW_POST_TYPE_ICON_TINT,
getDefaultColor("#808080", "#FFFFFF", "#808080"));
getDefaultColor("#F6F2EE", "#CDCECF", "#F2F4F8"));
}
public int getSubscribed() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.SUBSCRIBED,
getDefaultColor("#FF1868", "#FF1868", "#FF1868"));
getDefaultColor("#A5222F", "#D16983", "#F16DA6"));
}
public int getUnsubscribed() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.UNSUBSCRIBED,
getDefaultColor("#002BF0", "#002BF0", "#0336FF"));
getDefaultColor("#4863B6", "#719CD6", "#33B1FF"));
}
public int getUsername() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.USERNAME,
getDefaultColor("#002BF0", "#1E88E5", "#1E88E5"));
getDefaultColor("#4863B6", "#86ABDC", "#52BDFF"));
}
public int getSubreddit() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.SUBREDDIT,
getDefaultColor("#FF1868", "#FF4B9C", "#FF1868"));
getDefaultColor("#A5222F", "#DBC074", "#F16DA6"));
}
public int getAuthorFlairTextColor() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.AUTHOR_FLAIR_TEXT_COLOR,
getDefaultColor("#EE02C4", "#EE02C4", "#EE02C4"));
getDefaultColor("#A440B5", "#D67AD2", "#F16DA6"));
}
public int getSubmitter() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.SUBMITTER,
getDefaultColor("#EE8A02", "#EE8A02", "#EE8A02"));
getDefaultColor("#AC5402", "#E0C989", "#3DDBD9"));
}
public int getModerator() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.MODERATOR,
getDefaultColor("#00BA81", "#00BA81", "#00BA81"));
getDefaultColor("#577F63", "#D67AD2", "#25BE6A"));
}
public int getAdmin() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.MODERATOR,
getDefaultColor("#a5222f", "#c94f6d", "#EE5396"));
}
public int getCurrentUser() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.CURRENT_USER,
getDefaultColor("#00D5EA", "#00D5EA", "#00D5EA"));
getDefaultColor("#488D93", "#7AD5D6", "#2DC7C4"));
}
public int getSingleCommentThreadBackgroundColor() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.SINGLE_COMMENT_THREAD_BACKGROUND_COLOR,
getDefaultColor("#B3E5F9", "#5F5B85", "#123E77"));
getDefaultColor("#F2E9E1", "#2B3B51", "#484848"));
}
public int getUnreadMessageBackgroundColor() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.UNREAD_MESSAGE_BACKGROUND_COLOR,
getDefaultColor("#B3E5F9", "#5F5B85", "#123E77"));
getDefaultColor("#F6F2EE", "#393B44", "#484848"));
}
public int getDividerColor() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.DIVIDER_COLOR,
getDefaultColor("#E0E0E0", "#69666C", "#69666C"));
getDefaultColor("#F2E9E1", "#2B3B51", "#484848"));
}
public int getNoPreviewPostTypeBackgroundColor() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.NO_PREVIEW_POST_TYPE_BACKGROUND_COLOR,
getDefaultColor("#E0E0E0", "#6272A4", "#424242"));
getDefaultColor("#3D2B5A", "#D16983", "#161616"));
}
public int getVoteAndReplyUnavailableButtonColor() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.VOTE_AND_REPLY_UNAVAILABLE_BUTTON_COLOR,
getDefaultColor("#F0F0F0", "#777C82", "#3C3C3C"));
getDefaultColor("#F6F2EE", "#192330", "#484848"));
}
public int getCommentVerticalBarColor1() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.COMMENT_VERTICAL_BAR_COLOR_1,
getDefaultColor("#0336FF", "#8BE9FD", "#0336FF"));
getDefaultColor("#2848A9", "#719CD6", "#33B1FF"));
}
public int getCommentVerticalBarColor2() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.COMMENT_VERTICAL_BAR_COLOR_2,
getDefaultColor("#EE02BE", "#50FA7B", "#C300B3"));
getDefaultColor("#A440B5", "#D16983", "#C8A5FF"));
}
public int getCommentVerticalBarColor3() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.COMMENT_VERTICAL_BAR_COLOR_3,
getDefaultColor("#02DFEE", "#FFB86C", "#00B8DA"));
getDefaultColor("#4863B6", "#86ABDC", "#2DC7C4"));
}
public int getCommentVerticalBarColor4() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.COMMENT_VERTICAL_BAR_COLOR_4,
getDefaultColor("#EED502", "#FF79C6", "#EDCA00"));
getDefaultColor("#B86E28", "#DBC074", "#78A9FF"));
}
public int getCommentVerticalBarColor5() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.COMMENT_VERTICAL_BAR_COLOR_5,
getDefaultColor("#EE0220", "#BD93F9", "#EE0219"));
getDefaultColor("#B3434E", "#C94F6D", "#EE5396"));
}
public int getCommentVerticalBarColor6() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.COMMENT_VERTICAL_BAR_COLOR_6,
getDefaultColor("#02EE6E", "#FF5555", "#00B925"));
getDefaultColor("#577F63", "#81B27A", "#25BE6A"));
}
public int getCommentVerticalBarColor7() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.COMMENT_VERTICAL_BAR_COLOR_7,
getDefaultColor("#EE4602", "#F1FA8C", "#EE4602"));
getDefaultColor("#955F61", "#D16983", "#FF7EB6"));
}
public int getFABIconColor() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.FAB_ICON_COLOR,
getDefaultColor("#FFFFFF", "#000000", "#FFFFFF"));
getDefaultColor("#F6F2EE", "#192330", "#161616"));
}
public int getChipTextColor() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.CHIP_TEXT_COLOR,
getDefaultColor("#FFFFFF", "#FFFFFF", "#FFFFFF"));
getDefaultColor("#F6F2EE", "#CDCECF", "#282828"));
}
public int getLinkColor() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.LINK_COLOR,
getDefaultColor("#FF1868", "#FF1868", "#FF1868"));
getDefaultColor("#A5222F", "#DBC074", "#F16DA6"));
}
public int getReceivedMessageTextColor() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.RECEIVED_MESSAGE_TEXT_COLOR,
getDefaultColor("#FFFFFF", "#FFFFFF", "#FFFFFF"));
getDefaultColor("#3D2B5A", "#CDCECF", "#F2F4F8"));
}
public int getSentMessageTextColor() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.SENT_MESSAGE_TEXT_COLOR,
getDefaultColor("#FFFFFF", "#FFFFFF", "#FFFFFF"));
getDefaultColor("#F6F2EE", "#CDCECF", "#F2F4F8"));
}
public int getReceivedMessageBackgroundColor() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.RECEIVED_MESSAGE_BACKROUND_COLOR,
getDefaultColor("#4185F4", "#4185F4", "#4185F4"));
getDefaultColor("#F2E9E1", "#2B3B51", "#484848"));
}
public int getSentMessageBackgroundColor() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.SENT_MESSAGE_BACKGROUND_COLOR,
getDefaultColor("#31BF7D", "#31BF7D", "#31BF7D"));
getDefaultColor("#577F63", "#393B44", "#46C880"));
}
public int getSendMessageIconColor() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.SEND_MESSAGE_ICON_COLOR,
getDefaultColor("#4185F4", "#4185F4", "#4185F4"));
getDefaultColor("#4863B6", "#C94F6D", "#52BDFF"));
}
public int getFullyCollapsedCommentBackgroundColor() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.FULLY_COLLAPSED_COMMENT_BACKGROUND_COLOR,
getDefaultColor("#8EDFBA", "#21C561", "#21C561"));
getDefaultColor("#F2E9E1", "#2B3B51", "#484848"));
}
public int getAwardedCommentBackgroundColor() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.AWARDED_COMMENT_BACKGROUND_COLOR,
getDefaultColor("#FFFFFF", "#393A59", "#000000"));
getDefaultColor("#F6F2EE", "#E0C989", "#282828"));
}
public int getNavBarColor() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.NAV_BAR_COLOR,
getDefaultColor("#FFFFFF", "#393A59", "#000000"));
getDefaultColor("#F6F2EE", "#192330", "#161616"));
}
public boolean isLightStatusBar() {
@@ -493,6 +498,12 @@ public class CustomThemeWrapper {
return getDracula(context);
} else if (name.equals(context.getString(R.string.theme_name_calm_pastel))) {
return getCalmPastel(context);
} else if (name.equals(context.getString(R.string.theme_name_dayfox))) {
return getDayfox(context);
} else if (name.equals(context.getString(R.string.theme_name_nightfox))) {
return getNightfox(context);
} else if (name.equals(context.getString(R.string.theme_name_carbonfox))) {
return getCarbonfox(context);
} else {
return getIndigo(context);
}
@@ -511,6 +522,9 @@ public class CustomThemeWrapper {
customThemes.add(getRedAmoled(context));
customThemes.add(getDracula(context));
customThemes.add(getCalmPastel(context));
customThemes.add(getDayfox(context));
customThemes.add(getNightfox(context));
customThemes.add(getCarbonfox(context));
return customThemes;
}
@@ -1537,6 +1551,288 @@ public class CustomThemeWrapper {
return customTheme;
}
private static CustomTheme getDayfox(Context context) {
CustomTheme customTheme = new CustomTheme(context.getString(R.string.theme_name_dayfox));
customTheme.isLightTheme = true;
customTheme.isDarkTheme = false;
customTheme.isAmoledTheme = false;
customTheme.colorPrimary = Color.parseColor("#F2E9E1");
customTheme.colorPrimaryDark = Color.parseColor("#F2E9E1");
customTheme.colorAccent = Color.parseColor("#3D2B5A");
customTheme.colorPrimaryLightTheme = Color.parseColor("#F2E9E1");
customTheme.primaryTextColor = Color.parseColor("#3D2B5A");
customTheme.secondaryTextColor = Color.parseColor("#352C24");
customTheme.postTitleColor = Color.parseColor("#3D2B5A");
customTheme.postContentColor = Color.parseColor("#352C24");
customTheme.readPostTitleColor = Color.parseColor("#352C24");
customTheme.readPostContentColor = Color.parseColor("#352C24");
customTheme.commentColor = Color.parseColor("#3D2B5A");
customTheme.buttonTextColor = Color.parseColor("#3D2B5A");
customTheme.backgroundColor = Color.parseColor("#F6F2EE");
customTheme.cardViewBackgroundColor = Color.parseColor("#F2E9E1");
customTheme.readPostCardViewBackgroundColor = Color.parseColor("#F2E9E1");
customTheme.commentBackgroundColor = Color.parseColor("#F6F2EE");
customTheme.bottomAppBarBackgroundColor = Color.parseColor("#F2E9E1");
customTheme.primaryIconColor = Color.parseColor("#3D2B5A");
customTheme.bottomAppBarIconColor = Color.parseColor("#3D2B5A");
customTheme.postIconAndInfoColor = Color.parseColor("#352C24");
customTheme.commentIconAndInfoColor = Color.parseColor("#352C24");
customTheme.toolbarPrimaryTextAndIconColor = Color.parseColor("#352C24");
customTheme.toolbarSecondaryTextColor = Color.parseColor("#352C24");
customTheme.circularProgressBarBackground = Color.parseColor("#F6F2EE");
customTheme.mediaIndicatorIconColor = Color.parseColor("#F6F2EE");
customTheme.mediaIndicatorBackgroundColor = Color.parseColor("#3D2B5A");
customTheme.tabLayoutWithExpandedCollapsingToolbarTabBackground = Color.parseColor("#F6F2EE");
customTheme.tabLayoutWithExpandedCollapsingToolbarTextColor = Color.parseColor("#352C24");
customTheme.tabLayoutWithExpandedCollapsingToolbarTabIndicator = Color.parseColor("#F6F2EE");
customTheme.tabLayoutWithCollapsedCollapsingToolbarTabBackground = Color.parseColor("#F6F2EE");
customTheme.tabLayoutWithCollapsedCollapsingToolbarTextColor = Color.parseColor("#352C24");
customTheme.tabLayoutWithCollapsedCollapsingToolbarTabIndicator = Color.parseColor("#352C24");
customTheme.upvoted = Color.parseColor("#A5222F");
customTheme.downvoted = Color.parseColor("#4863B6");
customTheme.postTypeBackgroundColor = Color.parseColor("#4863B6");
customTheme.postTypeTextColor = Color.parseColor("#F6F2EE");
customTheme.spoilerBackgroundColor = Color.parseColor("#A440B5");
customTheme.spoilerTextColor = Color.parseColor("#F6F2EE");
customTheme.nsfwBackgroundColor = Color.parseColor("#A5222F");
customTheme.nsfwTextColor = Color.parseColor("#F6F2EE");
customTheme.flairBackgroundColor = Color.parseColor("#488D93");
customTheme.flairTextColor = Color.parseColor("#F6F2EE");
customTheme.awardsBackgroundColor = Color.parseColor("#B86E28");
customTheme.awardsTextColor = Color.parseColor("#F6F2EE");
customTheme.archivedTint = Color.parseColor("#A440B5");
customTheme.lockedIconTint = Color.parseColor("#AC5402");
customTheme.crosspostIconTint = Color.parseColor("#A5222F");
customTheme.upvoteRatioIconTint = Color.parseColor("#2848A9");
customTheme.stickiedPostIconTint = Color.parseColor("#4863B6");
customTheme.noPreviewPostTypeIconTint = Color.parseColor("#F6F2EE");
customTheme.subscribed = Color.parseColor("#A5222F");
customTheme.unsubscribed = Color.parseColor("#4863B6");
customTheme.username = Color.parseColor("#4863B6");
customTheme.subreddit = Color.parseColor("#A5222F");
customTheme.authorFlairTextColor = Color.parseColor("#A440B5");
customTheme.submitter = Color.parseColor("#AC5402");
customTheme.moderator = Color.parseColor("#577F63");
customTheme.currentUser = Color.parseColor("#488D93");
customTheme.singleCommentThreadBackgroundColor = Color.parseColor("#F2E9E1");
customTheme.unreadMessageBackgroundColor = Color.parseColor("#F6F2EE");
customTheme.dividerColor = Color.parseColor("#F2E9E1");
customTheme.noPreviewPostTypeBackgroundColor = Color.parseColor("#3D2B5A");
customTheme.voteAndReplyUnavailableButtonColor = Color.parseColor("#F6F2EE");
customTheme.commentVerticalBarColor1 = Color.parseColor("#2848A9");
customTheme.commentVerticalBarColor2 = Color.parseColor("#A440B5");
customTheme.commentVerticalBarColor3 = Color.parseColor("#4863B6");
customTheme.commentVerticalBarColor4 = Color.parseColor("#B86E28");
customTheme.commentVerticalBarColor5 = Color.parseColor("#B3434E");
customTheme.commentVerticalBarColor6 = Color.parseColor("#577F63");
customTheme.commentVerticalBarColor7 = Color.parseColor("#955F61");
customTheme.fabIconColor = Color.parseColor("#F6F2EE");
customTheme.chipTextColor = Color.parseColor("#F6F2EE");
customTheme.linkColor = Color.parseColor("#A5222F");
customTheme.receivedMessageTextColor = Color.parseColor("#3D2B5A");
customTheme.sentMessageTextColor = Color.parseColor("#F6F2EE");
customTheme.receivedMessageBackgroundColor = Color.parseColor("#F2E9E1");
customTheme.sentMessageBackgroundColor = Color.parseColor("#577F63");
customTheme.sendMessageIconColor = Color.parseColor("#4863B6");
customTheme.fullyCollapsedCommentBackgroundColor = Color.parseColor("#F2E9E1");
customTheme.awardedCommentBackgroundColor = Color.parseColor("#F6F2EE");
customTheme.navBarColor = Color.parseColor("#F6F2EE");
customTheme.isLightStatusBar = true;
customTheme.isLightNavBar = true;
customTheme.isChangeStatusBarIconColorAfterToolbarCollapsedInImmersiveInterface = false;
return customTheme;
}
private static CustomTheme getNightfox(Context context) {
CustomTheme customTheme = new CustomTheme(context.getString(R.string.theme_name_nightfox));
customTheme.isLightTheme = false;
customTheme.isDarkTheme = true;
customTheme.isAmoledTheme = false;
customTheme.colorPrimary = Color.parseColor("#2B3B51");
customTheme.colorPrimaryDark = Color.parseColor("#192330");
customTheme.colorAccent = Color.parseColor("#CDCECF");
customTheme.colorPrimaryLightTheme = Color.parseColor("#192330");
customTheme.primaryTextColor = Color.parseColor("#CDCECF");
customTheme.secondaryTextColor = Color.parseColor("#DFDFE0");
customTheme.postTitleColor = Color.parseColor("#CDCECF");
customTheme.postContentColor = Color.parseColor("#DFDFE0");
customTheme.readPostTitleColor = Color.parseColor("#738091");
customTheme.readPostContentColor = Color.parseColor("#738091");
customTheme.commentColor = Color.parseColor("#CDCECF");
customTheme.buttonTextColor = Color.parseColor("#CDCECF");
customTheme.backgroundColor = Color.parseColor("#192330");
customTheme.cardViewBackgroundColor = Color.parseColor("#2B3B51");
customTheme.readPostCardViewBackgroundColor = Color.parseColor("#2B3B51");
customTheme.commentBackgroundColor = Color.parseColor("#192330");
customTheme.bottomAppBarBackgroundColor = Color.parseColor("#2B3B51");
customTheme.primaryIconColor = Color.parseColor("#CDCECF");
customTheme.bottomAppBarIconColor = Color.parseColor("#CDCECF");
customTheme.postIconAndInfoColor = Color.parseColor("#DFDFE0");
customTheme.commentIconAndInfoColor = Color.parseColor("#DFDFE0");
customTheme.toolbarPrimaryTextAndIconColor = Color.parseColor("#CDCECF");
customTheme.toolbarSecondaryTextColor = Color.parseColor("#CDCECF");
customTheme.circularProgressBarBackground = Color.parseColor("#2B3B51");
customTheme.mediaIndicatorIconColor = Color.parseColor("#393B44");
customTheme.mediaIndicatorBackgroundColor = Color.parseColor("#CDCECF");
customTheme.tabLayoutWithExpandedCollapsingToolbarTabBackground = Color.parseColor("#2B3B51");
customTheme.tabLayoutWithExpandedCollapsingToolbarTextColor = Color.parseColor("#CDCECF");
customTheme.tabLayoutWithExpandedCollapsingToolbarTabIndicator = Color.parseColor("#2B3B51");
customTheme.tabLayoutWithCollapsedCollapsingToolbarTabBackground = Color.parseColor("#2B3B51");
customTheme.tabLayoutWithCollapsedCollapsingToolbarTextColor = Color.parseColor("#CDCECF");
customTheme.tabLayoutWithCollapsedCollapsingToolbarTabIndicator = Color.parseColor("#CDCECF");
customTheme.upvoted = Color.parseColor("#DBC074");
customTheme.downvoted = Color.parseColor("#D16983");
customTheme.postTypeBackgroundColor = Color.parseColor("#719CD6");
customTheme.postTypeTextColor = Color.parseColor("#DFDFE0");
customTheme.spoilerBackgroundColor = Color.parseColor("#E0C989");
customTheme.spoilerTextColor = Color.parseColor("#393B44");
customTheme.nsfwBackgroundColor = Color.parseColor("#D16983");
customTheme.nsfwTextColor = Color.parseColor("#393B44");
customTheme.flairBackgroundColor = Color.parseColor("#9D79D6");
customTheme.flairTextColor = Color.parseColor("#DFDFE0");
customTheme.awardsBackgroundColor = Color.parseColor("#E0C989");
customTheme.awardsTextColor = Color.parseColor("#575860");
customTheme.archivedTint = Color.parseColor("#D67AD2");
customTheme.lockedIconTint = Color.parseColor("#F4A261");
customTheme.crosspostIconTint = Color.parseColor("#DBC074");
customTheme.upvoteRatioIconTint = Color.parseColor("#86ABDC");
customTheme.stickiedPostIconTint = Color.parseColor("#719CD6");
customTheme.noPreviewPostTypeIconTint = Color.parseColor("#CDCECF");
customTheme.subscribed = Color.parseColor("#D16983");
customTheme.unsubscribed = Color.parseColor("#719CD6");
customTheme.username = Color.parseColor("#86ABDC");
customTheme.subreddit = Color.parseColor("#DBC074");
customTheme.authorFlairTextColor = Color.parseColor("#D67AD2");
customTheme.submitter = Color.parseColor("#E0C989");
customTheme.moderator = Color.parseColor("#D67AD2");
customTheme.currentUser = Color.parseColor("#7AD5D6");
customTheme.singleCommentThreadBackgroundColor = Color.parseColor("#2B3B51");
customTheme.unreadMessageBackgroundColor = Color.parseColor("#393B44");
customTheme.dividerColor = Color.parseColor("#2B3B51");
customTheme.noPreviewPostTypeBackgroundColor = Color.parseColor("#D16983");
customTheme.voteAndReplyUnavailableButtonColor = Color.parseColor("#192330");
customTheme.commentVerticalBarColor1 = Color.parseColor("#719CD6");
customTheme.commentVerticalBarColor2 = Color.parseColor("#D16983");
customTheme.commentVerticalBarColor3 = Color.parseColor("#86ABDC");
customTheme.commentVerticalBarColor4 = Color.parseColor("#DBC074");
customTheme.commentVerticalBarColor5 = Color.parseColor("#C94F6D");
customTheme.commentVerticalBarColor6 = Color.parseColor("#81B27A");
customTheme.commentVerticalBarColor7 = Color.parseColor("#D16983");
customTheme.fabIconColor = Color.parseColor("#192330");
customTheme.chipTextColor = Color.parseColor("#CDCECF");
customTheme.linkColor = Color.parseColor("#DBC074");
customTheme.receivedMessageTextColor = Color.parseColor("#CDCECF");
customTheme.sentMessageTextColor = Color.parseColor("#CDCECF");
customTheme.receivedMessageBackgroundColor = Color.parseColor("#2B3B51");
customTheme.sentMessageBackgroundColor = Color.parseColor("#393B44");
customTheme.sendMessageIconColor = Color.parseColor("#C94F6D");
customTheme.fullyCollapsedCommentBackgroundColor = Color.parseColor("#2B3B51");
customTheme.awardedCommentBackgroundColor = Color.parseColor("#2B3B51");
customTheme.navBarColor = Color.parseColor("#192330");
customTheme.isLightStatusBar = false;
customTheme.isLightNavBar = false;
customTheme.isChangeStatusBarIconColorAfterToolbarCollapsedInImmersiveInterface = false;
return customTheme;
}
private static CustomTheme getCarbonfox(Context context) {
CustomTheme customTheme = new CustomTheme(context.getString(R.string.theme_name_carbonfox));
customTheme.isLightTheme = false;
customTheme.isDarkTheme = false;
customTheme.isAmoledTheme = true;
customTheme.colorPrimary = Color.parseColor("#282828");
customTheme.colorPrimaryDark = Color.parseColor("#161616");
customTheme.colorAccent = Color.parseColor("#F2F4F8");
customTheme.colorPrimaryLightTheme = Color.parseColor("#161616");
customTheme.primaryTextColor = Color.parseColor("#F2F4F8");
customTheme.secondaryTextColor = Color.parseColor("#E4E4E5");
customTheme.postTitleColor = Color.parseColor("#F2F4F8");
customTheme.postContentColor = Color.parseColor("#E4E4E5");
customTheme.readPostTitleColor = Color.parseColor("#484848");
customTheme.readPostContentColor = Color.parseColor("#484848");
customTheme.commentColor = Color.parseColor("#F2F4F8");
customTheme.buttonTextColor = Color.parseColor("#F2F4F8");
customTheme.backgroundColor = Color.parseColor("#161616");
customTheme.cardViewBackgroundColor = Color.parseColor("#282828");
customTheme.readPostCardViewBackgroundColor = Color.parseColor("#282828");
customTheme.commentBackgroundColor = Color.parseColor("#282828");
customTheme.bottomAppBarBackgroundColor = Color.parseColor("#161616");
customTheme.primaryIconColor = Color.parseColor("#F2F4F8");
customTheme.bottomAppBarIconColor = Color.parseColor("#F2F4F8");
customTheme.postIconAndInfoColor = Color.parseColor("#E4E4E5");
customTheme.commentIconAndInfoColor = Color.parseColor("#E4E4E5");
customTheme.toolbarPrimaryTextAndIconColor = Color.parseColor("#F2F4F8");
customTheme.toolbarSecondaryTextColor = Color.parseColor("#F2F4F8");
customTheme.circularProgressBarBackground = Color.parseColor("#282828");
customTheme.mediaIndicatorIconColor = Color.parseColor("#161616");
customTheme.mediaIndicatorBackgroundColor = Color.parseColor("#F2F4F8");
customTheme.tabLayoutWithExpandedCollapsingToolbarTabBackground = Color.parseColor("#282828");
customTheme.tabLayoutWithExpandedCollapsingToolbarTextColor = Color.parseColor("#F2F4F8");
customTheme.tabLayoutWithExpandedCollapsingToolbarTabIndicator = Color.parseColor("#282828");
customTheme.tabLayoutWithCollapsedCollapsingToolbarTabBackground = Color.parseColor("#282828");
customTheme.tabLayoutWithCollapsedCollapsingToolbarTextColor = Color.parseColor("#F2F4F8");
customTheme.tabLayoutWithCollapsedCollapsingToolbarTabIndicator = Color.parseColor("#F2F4F8");
customTheme.upvoted = Color.parseColor("#F16DA6");
customTheme.downvoted = Color.parseColor("#52BDFF");
customTheme.postTypeBackgroundColor = Color.parseColor("#33B1FF");
customTheme.postTypeTextColor = Color.parseColor("#282828");
customTheme.spoilerBackgroundColor = Color.parseColor("#F16DA6");
customTheme.spoilerTextColor = Color.parseColor("#282828");
customTheme.nsfwBackgroundColor = Color.parseColor("#F16DA6");
customTheme.nsfwTextColor = Color.parseColor("#282828");
customTheme.flairBackgroundColor = Color.parseColor("#3DDBD9");
customTheme.flairTextColor = Color.parseColor("#282828");
customTheme.awardsBackgroundColor = Color.parseColor("#3DDBD9");
customTheme.awardsTextColor = Color.parseColor("#282828");
customTheme.archivedTint = Color.parseColor("#EE5396");
customTheme.lockedIconTint = Color.parseColor("#EE5396");
customTheme.crosspostIconTint = Color.parseColor("#F16DA6");
customTheme.upvoteRatioIconTint = Color.parseColor("#33B1FF");
customTheme.stickiedPostIconTint = Color.parseColor("#33B1FF");
customTheme.noPreviewPostTypeIconTint = Color.parseColor("#F2F4F8");
customTheme.subscribed = Color.parseColor("#F16DA6");
customTheme.unsubscribed = Color.parseColor("#33B1FF");
customTheme.username = Color.parseColor("#52BDFF");
customTheme.subreddit = Color.parseColor("#F16DA6");
customTheme.authorFlairTextColor = Color.parseColor("#F16DA6");
customTheme.submitter = Color.parseColor("#3DDBD9");
customTheme.moderator = Color.parseColor("#25BE6A");
customTheme.currentUser = Color.parseColor("#2DC7C4");
customTheme.singleCommentThreadBackgroundColor = Color.parseColor("#484848");
customTheme.unreadMessageBackgroundColor = Color.parseColor("#484848");
customTheme.dividerColor = Color.parseColor("#484848");
customTheme.noPreviewPostTypeBackgroundColor = Color.parseColor("#161616");
customTheme.voteAndReplyUnavailableButtonColor = Color.parseColor("#484848");
customTheme.commentVerticalBarColor1 = Color.parseColor("#33B1FF");
customTheme.commentVerticalBarColor2 = Color.parseColor("#C8A5FF");
customTheme.commentVerticalBarColor3 = Color.parseColor("#2DC7C4");
customTheme.commentVerticalBarColor4 = Color.parseColor("#78A9FF");
customTheme.commentVerticalBarColor5 = Color.parseColor("#EE5396");
customTheme.commentVerticalBarColor6 = Color.parseColor("#25BE6A");
customTheme.commentVerticalBarColor7 = Color.parseColor("#FF7EB6");
customTheme.fabIconColor = Color.parseColor("#161616");
customTheme.chipTextColor = Color.parseColor("#282828");
customTheme.linkColor = Color.parseColor("#F16DA6");
customTheme.receivedMessageTextColor = Color.parseColor("#F2F4F8");
customTheme.sentMessageTextColor = Color.parseColor("#F2F4F8");
customTheme.receivedMessageBackgroundColor = Color.parseColor("#484848");
customTheme.sentMessageBackgroundColor = Color.parseColor("#46C880");
customTheme.sendMessageIconColor = Color.parseColor("#52BDFF");
customTheme.fullyCollapsedCommentBackgroundColor = Color.parseColor("#484848");
customTheme.awardedCommentBackgroundColor = Color.parseColor("#282828");
customTheme.navBarColor = Color.parseColor("#161616");
customTheme.isLightStatusBar = false;
customTheme.isLightNavBar = false;
customTheme.isChangeStatusBarIconColorAfterToolbarCollapsedInImmersiveInterface = false;
return customTheme;
}
public static int darkenColor(int color, float factor) {
int a = Color.alpha(color);
int r = Math.round(Color.red(color) * factor);

View File

@@ -124,6 +124,7 @@ import eu.toldi.infinityforlemmy.events.ShowThumbnailOnTheRightInCompactLayoutEv
import eu.toldi.infinityforlemmy.post.HistoryPostPagingSource;
import eu.toldi.infinityforlemmy.post.HistoryPostViewModel;
import eu.toldi.infinityforlemmy.post.Post;
import eu.toldi.infinityforlemmy.post.enrich.PostEnricher;
import eu.toldi.infinityforlemmy.postfilter.PostFilter;
import eu.toldi.infinityforlemmy.postfilter.PostFilterUsage;
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
@@ -178,9 +179,6 @@ public class HistoryPostFragment extends Fragment implements FragmentCommunicato
@Named("default")
SharedPreferences mSharedPreferences;
@Inject
@Named("current_account")
SharedPreferences mCurrentAccountSharedPreferences;
@Inject
@Named("post_layout")
SharedPreferences mPostLayoutSharedPreferences;
@Inject
@@ -198,6 +196,8 @@ public class HistoryPostFragment extends Fragment implements FragmentCommunicato
ExoCreator mExoCreator;
@Inject
Executor mExecutor;
@Inject
PostEnricher postEnricher;
private RequestManager mGlide;
private BaseActivity activity;
private LinearLayoutManagerBugFixed mLinearLayoutManager;
@@ -383,7 +383,7 @@ public class HistoryPostFragment extends Fragment implements FragmentCommunicato
mAdapter = new HistoryPostRecyclerViewAdapter(activity, this, mExecutor, mRetrofit.getRetrofit(), mGfycatRetrofit,
mRedgifsRetrofit, mStreamableApiProvider, mCustomThemeWrapper, locale,
accessToken, accountName, postType, postLayout, true,
mSharedPreferences, mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences,
mSharedPreferences, mNsfwAndSpoilerSharedPreferences,
mExoCreator, new HistoryPostRecyclerViewAdapter.Callback() {
@Override
public void typeChipClicked(int filter) {
@@ -654,15 +654,10 @@ public class HistoryPostFragment extends Fragment implements FragmentCommunicato
}
private void initializeAndBindPostViewModel(String accessToken) {
if (postType == HistoryPostPagingSource.TYPE_READ_POSTS) {
mHistoryPostViewModel = new ViewModelProvider(HistoryPostFragment.this, new HistoryPostViewModel.Factory(mExecutor,
accessToken == null ? mRetrofit.getRetrofit() : mOauthRetrofit, mRedditDataRoomDatabase, accessToken,
accountName, mSharedPreferences, HistoryPostPagingSource.TYPE_READ_POSTS, postFilter)).get(HistoryPostViewModel.class);
} else {
mHistoryPostViewModel = new ViewModelProvider(HistoryPostFragment.this, new HistoryPostViewModel.Factory(mExecutor,
accessToken == null ? mRetrofit.getRetrofit() : mOauthRetrofit, mRedditDataRoomDatabase, accessToken,
accountName, mSharedPreferences, HistoryPostPagingSource.TYPE_READ_POSTS, postFilter)).get(HistoryPostViewModel.class);
}
mHistoryPostViewModel = new ViewModelProvider(HistoryPostFragment.this, new HistoryPostViewModel.Factory(mExecutor,
accessToken == null ? mRetrofit.getRetrofit() : mOauthRetrofit, mRedditDataRoomDatabase, accessToken,
accountName, mSharedPreferences, HistoryPostPagingSource.TYPE_READ_POSTS, postFilter, postEnricher))
.get(HistoryPostViewModel.class);
bindPostViewModel();
}
@@ -933,7 +928,7 @@ public class HistoryPostFragment extends Fragment implements FragmentCommunicato
} else {
if (isSubreddit) {
LoadSubredditIcon.loadSubredditIcon(mExecutor, new Handler(), mRedditDataRoomDatabase,
subredditOrUserName, accessToken, mOauthRetrofit, mRetrofit.getRetrofit(),
subredditOrUserName, accessToken, mRetrofit.getRetrofit(),
iconImageUrl -> {
subredditOrUserIcons.put(subredditOrUserName, iconImageUrl);
loadIconListener.loadIconSuccess(subredditOrUserName, iconImageUrl);
@@ -1447,4 +1442,4 @@ public class HistoryPostFragment extends Fragment implements FragmentCommunicato
public interface LoadIconListener {
void loadIconSuccess(String subredditOrUserName, String iconUrl);
}
}
}

View File

@@ -135,6 +135,7 @@ import eu.toldi.infinityforlemmy.events.ShowThumbnailOnTheRightInCompactLayoutEv
import eu.toldi.infinityforlemmy.post.Post;
import eu.toldi.infinityforlemmy.post.PostPagingSource;
import eu.toldi.infinityforlemmy.post.PostViewModel;
import eu.toldi.infinityforlemmy.post.enrich.PostEnricher;
import eu.toldi.infinityforlemmy.postfilter.PostFilter;
import eu.toldi.infinityforlemmy.postfilter.PostFilterUsage;
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
@@ -222,6 +223,8 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
ExoCreator mExoCreator;
@Inject
Executor mExecutor;
@Inject
PostEnricher postEnricher;
private RequestManager mGlide;
private BaseActivity activity;
private LinearLayoutManagerBugFixed mLinearLayoutManager;
@@ -465,7 +468,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.getRetrofit(), mGfycatRetrofit,
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mRetrofit, mGfycatRetrofit,
mRedgifsRetrofit, mStreamableApiProvider, mCustomThemeWrapper, locale,
accessToken, accountName, postType, postLayout, true,
mSharedPreferences, mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
@@ -533,16 +536,14 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_SUBREDDIT_POST_BASE + subredditName,
mSharedPreferences.getString(SharedPreferencesUtils.SUBREDDIT_DEFAULT_SORT_TIME, SortType.Time.ALL.name()));
}
sortType = newSortType(sort, sortTime);
boolean displaySubredditName = subredditName != null && (subredditName.equals("local") || subredditName.equals("all"));
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_SUBREDDIT_POST_BASE + subredditName, defaultPostLayout);
if (sortTime != null) {
sortType = new SortType(SortType.Type.fromValue(sortTime));
} else {
sortType = new SortType(SortType.Type.valueOf(sort));
}
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mRetrofit.getRetrofit(), mGfycatRetrofit,
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mRetrofit, mGfycatRetrofit,
mRedgifsRetrofit, mStreamableApiProvider, mCustomThemeWrapper, locale,
accessToken, accountName, postType, postLayout, displaySubredditName,
mSharedPreferences, mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
@@ -604,16 +605,14 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_MULTI_REDDIT_POST_BASE + multiRedditPath,
SortType.Time.ALL.name());
}
sortType = newSortType(sort, sortTime);
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_MULTI_REDDIT_POST_BASE + multiRedditPath,
defaultPostLayout);
if (sortTime != null) {
sortType = new SortType(SortType.Type.valueOf(sort), SortType.Time.valueOf(sortTime));
} else {
sortType = new SortType(SortType.Type.valueOf(sort));
}
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mRetrofit.getRetrofit(), mGfycatRetrofit,
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mRetrofit, mGfycatRetrofit,
mRedgifsRetrofit, mStreamableApiProvider, mCustomThemeWrapper, locale,
accessToken, accountName, postType, postLayout, true,
mSharedPreferences, mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
@@ -669,16 +668,17 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
String sort = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_USER_POST_BASE + username,
mSharedPreferences.getString(SharedPreferencesUtils.USER_DEFAULT_SORT_TYPE, SortType.Type.NEW.name()));
String sortTime = null;
if (sort.equalsIgnoreCase(SortType.Type.TOP.value)) {
String sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_USER_POST_BASE + username,
sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_USER_POST_BASE + username,
mSharedPreferences.getString(SharedPreferencesUtils.USER_DEFAULT_SORT_TIME, SortType.Time.ALL.name()));
sortType = new SortType(SortType.Type.fromValue(sortTime));
} else {
sortType = new SortType(SortType.Type.valueOf(sort));
}
sortType = newSortType(sort, sortTime);
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_USER_POST_BASE + username, defaultPostLayout);
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mRetrofit.getRetrofit(), mGfycatRetrofit,
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mRetrofit, mGfycatRetrofit,
mRedgifsRetrofit, mStreamableApiProvider, mCustomThemeWrapper, locale,
accessToken, accountName, postType, postLayout, true,
mSharedPreferences, mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
@@ -732,16 +732,15 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
subredditName = getArguments().getString(EXTRA_NAME);
String sort = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_SUBREDDIT_POST_BASE + "-", SortType.Type.HOT.name());
String sortTime = null;
if (sort.equals(SortType.Type.TOP.name())) {
String sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_SUBREDDIT_POST_BASE + "-", SortType.Time.ALL.name());
sortType = new SortType(SortType.Type.valueOf(sort), SortType.Time.valueOf(sortTime));
} else {
sortType = new SortType(SortType.Type.valueOf(sort));
sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_SUBREDDIT_POST_BASE + "-", SortType.Time.ALL.name());
}
sortType = newSortType(sort, sortTime);
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_FRONT_PAGE_POST, defaultPostLayout);
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mRetrofit.getRetrofit(), mGfycatRetrofit,
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mRetrofit, mGfycatRetrofit,
mRedgifsRetrofit, mStreamableApiProvider, mCustomThemeWrapper, locale,
accessToken, accountName, postType, postLayout, true,
mSharedPreferences, mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
@@ -792,16 +791,15 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
nameOfUsage = multiRedditPath;
String sort = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_MULTI_REDDIT_POST_BASE + multiRedditPath, SortType.Type.HOT.name());
String sortTime = null;
if (sort.equals(SortType.Type.TOP.name())) {
String sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_MULTI_REDDIT_POST_BASE + multiRedditPath, SortType.Time.ALL.name());
sortType = new SortType(SortType.Type.valueOf(sort), SortType.Time.valueOf(sortTime));
} else {
sortType = new SortType(SortType.Type.valueOf(sort));
sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_MULTI_REDDIT_POST_BASE + multiRedditPath, SortType.Time.ALL.name());
}
sortType = newSortType(sort, sortTime);
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_MULTI_REDDIT_POST_BASE + multiRedditPath, defaultPostLayout);
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mRetrofit.getRetrofit(), mGfycatRetrofit,
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mRetrofit, mGfycatRetrofit,
mRedgifsRetrofit, mStreamableApiProvider, mCustomThemeWrapper, locale,
accessToken, accountName, postType, postLayout, true,
mSharedPreferences, mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
@@ -850,15 +848,14 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
nameOfUsage = PostFilterUsage.NO_USAGE;
subredditName = getArguments().getString(EXTRA_NAME);
String sort = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_BEST_POST, SortType.Type.ACTIVE.name());
String sortTime = null;
if (sort.equals(SortType.Type.TOP.name())) {
String sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_BEST_POST, SortType.Time.ALL.name());
sortType = new SortType(SortType.Type.valueOf(sort), SortType.Time.valueOf(sortTime));
} else {
sortType = new SortType(SortType.Type.valueOf(sort));
sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_BEST_POST, SortType.Time.ALL.name());
}
sortType = newSortType(sort, sortTime);
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_FRONT_PAGE_POST, defaultPostLayout);
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mRetrofit.getRetrofit(), mGfycatRetrofit,
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mRetrofit, mGfycatRetrofit,
mRedgifsRetrofit, mStreamableApiProvider, mCustomThemeWrapper, locale,
accessToken, accountName, postType, postLayout, true,
mSharedPreferences, mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
@@ -1206,30 +1203,36 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
mRetrofit, accessToken,
accountName, mSharedPreferences,
mPostFeedScrolledPositionSharedPreferences, mPostHistorySharedPreferences, subredditName,
query, trendingSource, postType, sortType, postFilter, readPosts)).get(PostViewModel.class);
query, trendingSource, postType, sortType, postFilter, readPosts, postEnricher))
.get(PostViewModel.class);
} else if (postType == PostPagingSource.TYPE_SUBREDDIT) {
mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(mExecutor,
mRetrofit, accessToken,
accountName, mSharedPreferences, mPostFeedScrolledPositionSharedPreferences,
mPostHistorySharedPreferences, subredditName, postType, sortType, postFilter, readPosts))
mPostHistorySharedPreferences, subredditName, postType, sortType, postFilter, readPosts,
postEnricher))
.get(PostViewModel.class);
} else if (postType == PostPagingSource.TYPE_MULTI_REDDIT) {
mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(mExecutor,
mRetrofit, accessToken,
accountName, mSharedPreferences, mPostFeedScrolledPositionSharedPreferences,
mPostHistorySharedPreferences, multiRedditPath, postType, sortType, postFilter, readPosts))
mPostHistorySharedPreferences, multiRedditPath, postType, sortType, postFilter, readPosts,
postEnricher))
.get(PostViewModel.class);
} else if (postType == PostPagingSource.TYPE_USER) {
mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(mExecutor,
mRetrofit, accessToken,
accountName, mSharedPreferences, mPostFeedScrolledPositionSharedPreferences,
mPostHistorySharedPreferences, username, postType, sortType, postFilter, where, readPosts))
mPostHistorySharedPreferences, username, postType, sortType, postFilter, where, readPosts,
postEnricher))
.get(PostViewModel.class);
} else {
mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(mExecutor,
mRetrofit, accessToken,
accountName, mSharedPreferences, mPostFeedScrolledPositionSharedPreferences,
mPostHistorySharedPreferences, postType, sortType, postFilter, readPosts, subredditName)).get(PostViewModel.class);
mPostHistorySharedPreferences, postType, sortType, postFilter, readPosts, subredditName,
postEnricher))
.get(PostViewModel.class);
}
bindPostViewModel();
@@ -1241,26 +1244,27 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(mExecutor,
mRetrofit, null, accountName, mSharedPreferences,
mPostFeedScrolledPositionSharedPreferences, null, subredditName, query, trendingSource,
postType, sortType, postFilter, readPosts)).get(PostViewModel.class);
postType, sortType, postFilter, readPosts, postEnricher)).get(PostViewModel.class);
} else if (postType == PostPagingSource.TYPE_SUBREDDIT) {
mPostViewModel = new ViewModelProvider(this, new PostViewModel.Factory(mExecutor,
mRetrofit, null, accountName, mSharedPreferences,
mPostFeedScrolledPositionSharedPreferences, null, subredditName, postType, sortType,
postFilter, readPosts)).get(PostViewModel.class);
postFilter, readPosts, postEnricher)).get(PostViewModel.class);
} else if (postType == PostPagingSource.TYPE_MULTI_REDDIT) {
mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(mExecutor,
mRetrofit, null, accountName, mSharedPreferences,
mPostFeedScrolledPositionSharedPreferences, null, multiRedditPath,
postType, sortType, postFilter, readPosts)).get(PostViewModel.class);
postType, sortType, postFilter, readPosts, postEnricher)).get(PostViewModel.class);
} else if (postType == PostPagingSource.TYPE_USER) {
mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(mExecutor,
mRetrofit, null, accountName, mSharedPreferences,
mPostFeedScrolledPositionSharedPreferences, null, username, postType, sortType, postFilter,
where, readPosts)).get(PostViewModel.class);
where, readPosts, postEnricher)).get(PostViewModel.class);
} else {
//Anonymous Front Page
mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(mExecutor,
mRetrofit, mSharedPreferences, concatenatedSubredditNames, postType, sortType, postFilter, subredditName))
mRetrofit, mSharedPreferences, concatenatedSubredditNames, postType, sortType, postFilter, subredditName,
postEnricher))
.get(PostViewModel.class);
}
@@ -1364,25 +1368,25 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SAVE_SORT_TYPE, true)) {
switch (postType) {
case PostPagingSource.TYPE_FRONT_PAGE:
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_BEST_POST, sortType.getType().name()).apply();
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_BEST_POST, sortType.getType().value).apply();
if (sortType.getTime() != null) {
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TIME_BEST_POST, sortType.getTime().name()).apply();
}
break;
case PostPagingSource.TYPE_SUBREDDIT:
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_SUBREDDIT_POST_BASE + subredditName, sortType.getType().name()).apply();
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_SUBREDDIT_POST_BASE + subredditName, sortType.getType().value).apply();
if (sortType.getTime() != null) {
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TIME_SUBREDDIT_POST_BASE + subredditName, sortType.getTime().name()).apply();
}
break;
case PostPagingSource.TYPE_USER:
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_USER_POST_BASE + username, sortType.getType().name()).apply();
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_USER_POST_BASE + username, sortType.getType().value).apply();
if (sortType.getTime() != null) {
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TIME_USER_POST_BASE + username, sortType.getTime().name()).apply();
}
break;
case PostPagingSource.TYPE_SEARCH:
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_SEARCH_POST, sortType.getType().name()).apply();
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_SEARCH_POST, sortType.getType().value).apply();
if (sortType.getTime() != null) {
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TIME_SEARCH_POST, sortType.getTime().name()).apply();
}else {
@@ -1392,14 +1396,14 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
case PostPagingSource.TYPE_MULTI_REDDIT:
case PostPagingSource.TYPE_ANONYMOUS_MULTIREDDIT:
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_MULTI_REDDIT_POST_BASE + multiRedditPath,
sortType.getType().name()).apply();
sortType.getType().value).apply();
if (sortType.getTime() != null) {
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TIME_MULTI_REDDIT_POST_BASE + multiRedditPath,
sortType.getTime().name()).apply();
}
break;
case PostPagingSource.TYPE_ANONYMOUS_FRONT_PAGE:
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_SUBREDDIT_POST_BASE + "-", sortType.getType().name()).apply();
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_SUBREDDIT_POST_BASE + "-", sortType.getType().value).apply();
if (sortType.getTime() != null) {
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TIME_SUBREDDIT_POST_BASE + "-", sortType.getTime().name()).apply();
}
@@ -1750,7 +1754,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
} else {
if (isSubreddit) {
LoadSubredditIcon.loadSubredditIcon(mExecutor, new Handler(), mRedditDataRoomDatabase,
subredditOrUserName, accessToken, mRetrofit.getRetrofit(), mRetrofit.getRetrofit(),
subredditOrUserName, accessToken, mRetrofit.getRetrofit(),
iconImageUrl -> {
subredditOrUserIcons.put(subredditOrUserName, iconImageUrl);
loadIconListener.loadIconSuccess(subredditOrUserName, iconImageUrl);
@@ -2238,6 +2242,24 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
return false;
}
public SortType newSortType(String sortTypeText, String sortTimeText) {
SortType.Type st = SortType.Type.fromValue(sortTypeText);
st = st == null ? SortType.Type.NEW : st;
SortType result;
if (sortTypeText.startsWith("Top")) {
sortTimeText = st.value.substring(3);
result = new SortType(st, SortType.Time.fromValue(sortTimeText));
} else if (sortTimeText != null) {
SortType.Time sortTime = SortType.Time.fromValue(sortTimeText);
SortType.Type sortType = SortType.Type.fromValue("Top" + sortTimeText);
result = new SortType(sortType != null ? sortType : st, sortTime);
} else {
result = new SortType(st);
}
return result;
}
private static abstract class LazyModeRunnable implements Runnable {
private int currentPosition = -1;

View File

@@ -2,6 +2,7 @@ package eu.toldi.infinityforlemmy.fragments;
import android.content.Context;
import android.content.Intent;
import android.graphics.PorterDuff;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
@@ -9,15 +10,20 @@ import android.text.Spanned;
import android.view.LayoutInflater;
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.constraintlayout.widget.ConstraintLayout;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import com.evernote.android.state.State;
import com.google.android.material.card.MaterialCardView;
import java.util.concurrent.Executor;
import javax.inject.Inject;
@@ -31,15 +37,18 @@ import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
import eu.toldi.infinityforlemmy.RetrofitHolder;
import eu.toldi.infinityforlemmy.activities.LinkResolverActivity;
import eu.toldi.infinityforlemmy.activities.ViewSubredditDetailActivity;
import eu.toldi.infinityforlemmy.adapters.ModeratorRecyclerViewAdapter;
import eu.toldi.infinityforlemmy.asynctasks.InsertSubredditData;
import eu.toldi.infinityforlemmy.bottomsheetfragments.CopyTextBottomSheetFragment;
import eu.toldi.infinityforlemmy.bottomsheetfragments.UrlMenuBottomSheetFragment;
import eu.toldi.infinityforlemmy.community.CommunityStats;
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
import eu.toldi.infinityforlemmy.customviews.LinearLayoutManagerBugFixed;
import eu.toldi.infinityforlemmy.markdown.MarkdownUtils;
import eu.toldi.infinityforlemmy.subreddit.FetchSubredditData;
import eu.toldi.infinityforlemmy.subreddit.SubredditData;
import eu.toldi.infinityforlemmy.subreddit.SubredditViewModel;
import eu.toldi.infinityforlemmy.user.BasicUserRecyclerViewAdapter;
import eu.toldi.infinityforlemmy.utils.LemmyUtils;
import io.noties.markwon.AbstractMarkwonPlugin;
import io.noties.markwon.Markwon;
@@ -55,11 +64,50 @@ public class SidebarFragment extends Fragment {
public static final String EXTRA_SUBREDDIT_NAME = "ESN";
public static final String EXTRA_ACCESS_TOKEN = "EAT";
public static final String EXTRA_COMMUNITY_QUALIFIED_NAME = "ECQN";
public static final String EXTRA_SHOW_STATISTICS = "ESS";
public SubredditViewModel mSubredditViewModel;
@BindView(R.id.swipe_refresh_layout_sidebar_fragment)
SwipeRefreshLayout swipeRefreshLayout;
@BindView(R.id.markdown_recycler_view_sidebar_fragment)
RecyclerView recyclerView;
@BindView(R.id.recycler_view_moderators_side_fragment)
RecyclerView moderatorsRecyclerView;
@BindView(R.id.subscriber_count_text_view_sidebar_fragment)
TextView nSubscribersTextView;
@BindView(R.id.active_user_count_text_view_sidebar_fragment)
TextView nActiveUsersTextView;
@BindView(R.id.post_count_text_view_sidebar_fragment)
TextView nPostsTextView;
@BindView(R.id.comment_count_text_view_sidebar_fragment)
TextView nCommentsTextView;
@BindView(R.id.subscriber_count_image_view_sidebar_fragment)
ImageView nSubscribersImageView;
@BindView(R.id.active_user_count_image_view_sidebar_fragment)
ImageView nActiveUsersImageView;
@BindView(R.id.post_count_image_view_sidebar_fragment)
ImageView nPostsImageView;
@BindView(R.id.comment_count_image_view_sidebar_fragment)
ImageView nCommentsImageView;
@BindView(R.id.community_statistics_block_sidebar_fragment)
ConstraintLayout communityStatisticsBlock;
@BindView(R.id.moderators_text_view_sidebar_fragment)
TextView moderatorsTextView;
@BindView(R.id.moderators_card_sidebar_fragment)
MaterialCardView moderatorsCard;
@BindView(R.id.description_card_sidebar_fragment)
MaterialCardView descriptionCard;
@BindView(R.id.statistics_card_sidebar_fragment)
MaterialCardView statisticsCard;
@Inject
@Named("no_oauth")
RetrofitHolder mRetrofit;
@@ -76,11 +124,17 @@ public class SidebarFragment extends Fragment {
private String mAccessToken;
private String subredditName;
private boolean mShowStatistics;
private String communityQualifiedName;
private LinearLayoutManagerBugFixed linearLayoutManager;
private int markdownColor;
private String sidebarDescription;
@State
CommunityStats mCommunityStats;
private BasicUserRecyclerViewAdapter moderatorAdapter;
public SidebarFragment() {
// Required empty public constructor
}
@@ -98,6 +152,7 @@ public class SidebarFragment extends Fragment {
mAccessToken = getArguments().getString(EXTRA_ACCESS_TOKEN);
subredditName = getArguments().getString(EXTRA_SUBREDDIT_NAME);
communityQualifiedName = getArguments().getString(EXTRA_COMMUNITY_QUALIFIED_NAME);
mShowStatistics = getArguments().getBoolean(EXTRA_SHOW_STATISTICS, true);
if (communityQualifiedName == null) {
Toast.makeText(activity, R.string.error_getting_community_name, Toast.LENGTH_SHORT).show();
return rootView;
@@ -105,6 +160,27 @@ public class SidebarFragment extends Fragment {
swipeRefreshLayout.setProgressBackgroundColorSchemeColor(mCustomThemeWrapper.getCircularProgressBarBackground());
swipeRefreshLayout.setColorSchemeColors(mCustomThemeWrapper.getColorAccent());
int mCardViewBackgroundColor = mCustomThemeWrapper.getCardViewBackgroundColor();
int primaryTextColor = mCustomThemeWrapper.getPrimaryTextColor();
nSubscribersTextView.setTextColor(primaryTextColor);
nActiveUsersTextView.setTextColor(primaryTextColor);
nPostsTextView.setTextColor(primaryTextColor);
nCommentsTextView.setTextColor(primaryTextColor);
moderatorsTextView.setTextColor(primaryTextColor);
moderatorsTextView.setTypeface(activity.contentTypeface);
nSubscribersImageView.setColorFilter(mCustomThemeWrapper.getPrimaryTextColor(), PorterDuff.Mode.SRC_IN);
nActiveUsersImageView.setColorFilter(mCustomThemeWrapper.getPrimaryTextColor(), PorterDuff.Mode.SRC_IN);
nPostsImageView.setColorFilter(mCustomThemeWrapper.getPrimaryTextColor(), PorterDuff.Mode.SRC_IN);
nCommentsImageView.setColorFilter(mCustomThemeWrapper.getPrimaryTextColor(), PorterDuff.Mode.SRC_IN);
moderatorsCard.setCardBackgroundColor(mCardViewBackgroundColor);
descriptionCard.setCardBackgroundColor(mCardViewBackgroundColor);
if (mShowStatistics) {
statisticsCard.setCardBackgroundColor(mCardViewBackgroundColor);
} else {
statisticsCard.setVisibility(View.GONE);
}
markdownColor = mCustomThemeWrapper.getPrimaryTextColor();
int spoilerBackgroundColor = markdownColor | 0xFF000000;
@@ -166,6 +242,11 @@ public class SidebarFragment extends Fragment {
}
});
moderatorsRecyclerView.setLayoutManager(new LinearLayoutManagerBugFixed(activity));
moderatorAdapter = new ModeratorRecyclerViewAdapter(activity,
mCustomThemeWrapper);
moderatorsRecyclerView.setAdapter(moderatorAdapter);
mSubredditViewModel = new ViewModelProvider(activity,
new SubredditViewModel.Factory(activity.getApplication(), mRedditDataRoomDatabase, LemmyUtils.qualifiedCommunityName2ActorId(communityQualifiedName)))
.get(SubredditViewModel.class);
@@ -180,6 +261,16 @@ public class SidebarFragment extends Fragment {
} else {
fetchSubredditData();
}
if (mCommunityStats != null) {
communityStatisticsBlock.setVisibility(View.VISIBLE);
nSubscribersTextView.setText(getString(R.string.subscribers_number_detail, mCommunityStats.getSubscribers()));
nActiveUsersTextView.setText(getString(R.string.active_users_number_detail, mCommunityStats.getActiveUsers()));
nPostsTextView.setText(getString(R.string.post_count_detail, mCommunityStats.getPosts()));
nCommentsTextView.setText(getString(R.string.comment_count_detail, mCommunityStats.getComments()));
} else {
fetchSubredditData();
}
});
swipeRefreshLayout.setOnRefreshListener(this::fetchSubredditData);
@@ -199,6 +290,8 @@ public class SidebarFragment extends Fragment {
@Override
public void onFetchSubredditDataSuccess(SubredditData subredditData, int nCurrentOnlineSubscribers) {
swipeRefreshLayout.setRefreshing(false);
mCommunityStats = subredditData.getCommunityStats();
moderatorAdapter.setUsers(subredditData.getModerators());
InsertSubredditData.insertSubredditData(mExecutor, new Handler(), mRedditDataRoomDatabase,
subredditData, () -> swipeRefreshLayout.setRefreshing(false));
}

View File

@@ -157,16 +157,16 @@ public class SubscribedSubredditsListingFragment extends Fragment implements Fra
adapter.setSubscribedSubreddits(subscribedSubredditData);
});
/* mSubscribedSubredditViewModel.getAllFavoriteSubscribedSubreddits().observe(getViewLifecycleOwner(), favoriteSubscribedSubredditData -> {
mSwipeRefreshLayout.setRefreshing(false);
if (favoriteSubscribedSubredditData != null && favoriteSubscribedSubredditData.size() > 0) {
mLinearLayout.setVisibility(View.GONE);
mRecyclerView.setVisibility(View.VISIBLE);
mGlide.clear(mImageView);
}
mSubscribedSubredditViewModel.getAllFavoriteSubscribedSubreddits().observe(getViewLifecycleOwner(), favoriteSubscribedSubredditData -> {
mSwipeRefreshLayout.setRefreshing(false);
if (favoriteSubscribedSubredditData != null && favoriteSubscribedSubredditData.size() > 0) {
mLinearLayout.setVisibility(View.GONE);
mRecyclerView.setVisibility(View.VISIBLE);
mGlide.clear(mImageView);
}
adapter.setFavoriteSubscribedSubreddits(favoriteSubscribedSubredditData);
});*/
adapter.setFavoriteSubscribedSubreddits(favoriteSubscribedSubredditData);
});
return rootView;
}

View File

@@ -112,6 +112,7 @@ import eu.toldi.infinityforlemmy.post.HidePost;
import eu.toldi.infinityforlemmy.post.LemmyPostAPI;
import eu.toldi.infinityforlemmy.post.MarkPostAsRead;
import eu.toldi.infinityforlemmy.post.Post;
import eu.toldi.infinityforlemmy.post.enrich.PostEnricher;
import eu.toldi.infinityforlemmy.readpost.InsertReadPost;
import eu.toldi.infinityforlemmy.subreddit.FetchSubredditData;
import eu.toldi.infinityforlemmy.subreddit.SubredditData;
@@ -200,6 +201,8 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
MarkPostAsRead markPostAsRead;
@Inject
LemmyPostAPI mLemmyPostAPI;
@Inject
PostEnricher postEnricher;
@State
Post mPost;
@State
@@ -324,7 +327,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
mLockFab = mSharedPreferences.getBoolean(SharedPreferencesUtils.LOCK_JUMP_TO_NEXT_TOP_LEVEL_COMMENT_BUTTON, false);
mSwipeUpToHideFab = mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_UP_TO_HIDE_JUMP_TO_NEXT_TOP_LEVEL_COMMENT_BUTTON, false);
mExpandChildren = !mSharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_TOP_LEVEL_COMMENTS_FIRST, false);
mMarkPostsAsRead = mPostHistorySharedPreferences.getBoolean(mAccountQualifiedName + SharedPreferencesUtils.MARK_POSTS_AS_READ_BASE, false);
mMarkPostsAsRead = mPostHistorySharedPreferences.getBoolean(mAccountName + SharedPreferencesUtils.MARK_POSTS_AS_READ_BASE, false);
if (savedInstanceState == null) {
mRespectSubredditRecommendedSortType = mSharedPreferences.getBoolean(SharedPreferencesUtils.RESPECT_SUBREDDIT_RECOMMENDED_COMMENT_SORT_TYPE, false);
viewPostDetailFragmentId = System.currentTimeMillis();
@@ -614,13 +617,13 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
setupMenu();
mPostAdapter = new PostDetailRecyclerViewAdapter(activity,
this, mExecutor, mCustomThemeWrapper, mRetrofit.getRetrofit(), mGfycatRetrofit,
this, mExecutor, mCustomThemeWrapper, mRetrofit, mGfycatRetrofit,
mRedgifsRetrofit, mStreamableApiProvider, mRedditDataRoomDatabase, mGlide,
mSeparatePostAndComments, mAccessToken, mAccountName, mPost, mLocale,
mSharedPreferences, mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostDetailsSharedPreferences,
mExoCreator, post -> EventBus.getDefault().post(new PostUpdateEventToPostList(mPost, postListPosition)));
mCommentsAdapter = new CommentsRecyclerViewAdapter(activity,
this, mCustomThemeWrapper, mExecutor, mRetrofit.getRetrofit(),
this, mCustomThemeWrapper, mExecutor, mRetrofit,
mAccessToken, mAccountQualifiedName, mPost, mLocale, mSingleCommentId
, isSingleCommentThreadMode, mSharedPreferences, mCurrentAccountSharedPreferences,
new CommentsRecyclerViewAdapter.CommentRecyclerViewAdapterCallback() {
@@ -1155,10 +1158,6 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
.show();
return true;
} else if (itemId == R.id.action_report_view_post_detail_fragment) {
if (mAccessToken == null) {
Toast.makeText(activity, R.string.login_first, Toast.LENGTH_SHORT).show();
return true;
}
if (mAccessToken == null) {
Toast.makeText(activity, R.string.login_first, Toast.LENGTH_SHORT).show();
return true;
@@ -1166,7 +1165,11 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
LayoutInflater inflater = LayoutInflater.from(activity);
View view = inflater.inflate(R.layout.dialog_report, null);
EditText reasonEditText = view.findViewById(R.id.reasonEditText);
reasonEditText.setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
reasonEditText.setHintTextColor(mCustomThemeWrapper.getSecondaryTextColor());
if (activity.typeface != null) {
reasonEditText.setTypeface(activity.typeface);
}
MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(activity)
.setTitle(R.string.report_post)
.setView(view)
@@ -1329,7 +1332,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
mSwipeRefreshLayout.setRefreshing(true);
mGlide.clear(mFetchPostInfoImageView);
FetchPost.fetchPost(mExecutor, new Handler(), mRetrofit.getRetrofit(), String.valueOf(subredditId), mAccessToken,
new FetchPost.FetchPostListener() {
postEnricher, new FetchPost.FetchPostListener() {
@Override
public void fetchPostSuccess(Post post) {
if (!isAdded()) {
@@ -1338,7 +1341,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
mPost = post;
mPostAdapter = new PostDetailRecyclerViewAdapter(activity,
ViewPostDetailFragment.this, mExecutor, mCustomThemeWrapper,
mRetrofit.getRetrofit(), mGfycatRetrofit, mRedgifsRetrofit,
mRetrofit, mGfycatRetrofit, mRedgifsRetrofit,
mStreamableApiProvider, mRedditDataRoomDatabase, mGlide, mSeparatePostAndComments,
mAccessToken, mAccountName, mPost, mLocale, mSharedPreferences,
mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences,
@@ -1351,7 +1354,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
pages_loaded++;
mCommentsAdapter = new CommentsRecyclerViewAdapter(activity,
ViewPostDetailFragment.this, mCustomThemeWrapper, mExecutor,
mRetrofit.getRetrofit(), mAccessToken, mAccountQualifiedName, mPost, mLocale,
mRetrofit, mAccessToken, mAccountQualifiedName, mPost, mLocale,
mSingleCommentId, isSingleCommentThreadMode, mSharedPreferences, mCurrentAccountSharedPreferences,
new CommentsRecyclerViewAdapter.CommentRecyclerViewAdapterCallback() {
@Override
@@ -1588,7 +1591,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
Retrofit retrofit = mRetrofit.getRetrofit();
FetchPost.fetchPost(mExecutor, new Handler(), retrofit, String.valueOf(mPost.getId()), mAccessToken,
new FetchPost.FetchPostListener() {
postEnricher, new FetchPost.FetchPostListener() {
@Override
public void fetchPostSuccess(Post post) {
if (isAdded()) {

View File

@@ -52,6 +52,7 @@ import java.io.File;
import java.util.concurrent.Executor;
import javax.inject.Inject;
import javax.inject.Named;
import butterknife.BindView;
import butterknife.ButterKnife;
@@ -69,6 +70,7 @@ import eu.toldi.infinityforlemmy.bottomsheetfragments.UrlMenuBottomSheetFragment
import eu.toldi.infinityforlemmy.post.Post;
import eu.toldi.infinityforlemmy.services.DownloadMediaService;
import eu.toldi.infinityforlemmy.utils.Utils;
import okhttp3.OkHttpClient;
public class ViewRedditGalleryImageOrGifFragment extends Fragment {
@@ -105,6 +107,9 @@ public class ViewRedditGalleryImageOrGifFragment extends Fragment {
ImageView wallpaperImageView;
@Inject
Executor mExecutor;
@Inject
@Named("glide")
OkHttpClient okHttpClient;
private ViewRedditGalleryActivity activity;
private RequestManager glide;
@@ -122,7 +127,7 @@ public class ViewRedditGalleryImageOrGifFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
BigImageViewer.initialize(GlideImageLoader.with(activity.getApplicationContext()));
BigImageViewer.initialize(GlideImageLoader.with(activity.getApplicationContext(), okHttpClient));
View rootView = inflater.inflate(R.layout.fragment_view_reddit_gallery_image_or_gif, container, false);

View File

@@ -1,5 +1,6 @@
package eu.toldi.infinityforlemmy.markdown;
import android.app.Activity;
import android.content.Context;
import android.text.util.Linkify;
@@ -29,16 +30,17 @@ import me.saket.bettermovementmethod.BetterLinkMovementMethod;
public class MarkdownUtils {
/**
* Creates a Markwon instance with all the plugins required for processing Reddit's markdown.
*
* @return configured Markwon instance
*/
@NonNull
public static Markwon createFullRedditMarkwon(@NonNull Context context,
public static Markwon createFullRedditMarkwon(@NonNull Activity context,
@NonNull MarkwonPlugin miscPlugin,
int markdownColor,
int spoilerBackgroundColor,
@Nullable BetterLinkMovementMethod.OnLinkLongClickListener onLinkLongClickListener) {
return Markwon.builder(context)
.usePlugin(GlideImagesPlugin.create(context))
.usePlugin(GlideImagesPlugin.create(context.getApplicationContext()))
.usePlugin(MarkwonInlineParserPlugin.create(plugin -> {
plugin.excludeInlineProcessor(HtmlInlineProcessor.class);
}))
@@ -57,7 +59,7 @@ public class MarkdownUtils {
}
@NonNull
public static Markwon createDescriptionMarkwon(Context context, MarkwonPlugin miscPlugin,
public static Markwon createDescriptionMarkwon(Activity context, MarkwonPlugin miscPlugin,
BetterLinkMovementMethod.OnLinkLongClickListener onLinkLongClickListener) {
return Markwon.builder(context)
.usePlugin(MarkwonInlineParserPlugin.create(plugin -> {
@@ -71,7 +73,7 @@ public class MarkdownUtils {
.setOnLinkLongClickListener(onLinkLongClickListener)))
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
.usePlugin(TableEntryPlugin.create(context))
.usePlugin(GlideImagesPlugin.create(context))
.usePlugin(GlideImagesPlugin.create(context.getApplicationContext()))
.usePlugin(new MarkwonLemmyLinkPlugin())
.build();
}

View File

@@ -8,6 +8,7 @@ import java.util.concurrent.Executor;
import eu.toldi.infinityforlemmy.apis.LemmyAPI;
import eu.toldi.infinityforlemmy.apis.RedditAPI;
import eu.toldi.infinityforlemmy.post.enrich.PostEnricher;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
@@ -15,7 +16,7 @@ import retrofit2.Retrofit;
public class FetchPost {
public static void fetchPost(Executor executor, Handler handler, Retrofit retrofit, String id, String accessToken,
FetchPostListener fetchPostListener) {
PostEnricher postEnricher, FetchPostListener fetchPostListener) {
Call<String> postCall;
// Use LemmyAPI.postInfo() instead of RedditAPI.getPost()
postCall = retrofit.create(LemmyAPI.class).postInfo(Integer.parseInt(id), null, accessToken);
@@ -24,7 +25,7 @@ public class FetchPost {
@Override
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
if (response.isSuccessful()) {
ParsePost.parsePost(executor, handler, response.body(), new ParsePost.ParsePostListener() {
ParsePost.parsePost(executor, handler, postEnricher, response.body(), new ParsePost.ParsePostListener() {
@Override
public void onParsePostSuccess(Post post) {
fetchPostListener.fetchPostSuccess(post);

View File

@@ -19,6 +19,7 @@ import java.util.concurrent.Executor;
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
import eu.toldi.infinityforlemmy.apis.RedditAPI;
import eu.toldi.infinityforlemmy.post.enrich.PostEnricher;
import eu.toldi.infinityforlemmy.postfilter.PostFilter;
import eu.toldi.infinityforlemmy.readpost.ReadPost;
import eu.toldi.infinityforlemmy.utils.APIUtils;
@@ -39,10 +40,11 @@ public class HistoryPostPagingSource extends ListenableFuturePagingSource<String
private String username;
private int postType;
private PostFilter postFilter;
private PostEnricher postEnricher;
public HistoryPostPagingSource(Retrofit retrofit, Executor executor, RedditDataRoomDatabase redditDataRoomDatabase,
String accessToken, String accountName, SharedPreferences sharedPreferences,
String username, int postType, PostFilter postFilter) {
String username, int postType, PostFilter postFilter, PostEnricher postEnricher) {
this.retrofit = retrofit;
this.executor = executor;
this.redditDataRoomDatabase = redditDataRoomDatabase;
@@ -52,6 +54,7 @@ public class HistoryPostPagingSource extends ListenableFuturePagingSource<String
this.username = username;
this.postType = postType;
this.postFilter = postFilter;
this.postEnricher = postEnricher;
}
@Nullable
@@ -92,7 +95,7 @@ public class HistoryPostPagingSource extends ListenableFuturePagingSource<String
Response<String> response = historyPosts.execute();
if (response.isSuccessful()) {
String responseString = response.body();
LinkedHashSet<Post> newPosts = ParsePost.parsePostsSync(responseString, -1, postFilter, null);
LinkedHashSet<Post> newPosts = ParsePost.parsePostsSync(responseString, -1, postFilter, null, postEnricher);
if (newPosts == null) {
return new LoadResult.Error<>(new Exception("Error parsing posts"));
} else {

View File

@@ -17,6 +17,7 @@ import androidx.paging.PagingLiveData;
import java.util.concurrent.Executor;
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
import eu.toldi.infinityforlemmy.post.enrich.PostEnricher;
import eu.toldi.infinityforlemmy.postfilter.PostFilter;
import retrofit2.Retrofit;
@@ -29,6 +30,7 @@ public class HistoryPostViewModel extends ViewModel {
private SharedPreferences sharedPreferences;
private int postType;
private PostFilter postFilter;
private PostEnricher postEnricher;
private LiveData<PagingData<Post>> posts;
@@ -36,7 +38,7 @@ public class HistoryPostViewModel extends ViewModel {
public HistoryPostViewModel(Executor executor, Retrofit retrofit, RedditDataRoomDatabase redditDataRoomDatabase,
String accessToken, String accountName, SharedPreferences sharedPreferences,
int postType, PostFilter postFilter) {
int postType, PostFilter postFilter, PostEnricher postEnricher) {
this.executor = executor;
this.retrofit = retrofit;
this.redditDataRoomDatabase = redditDataRoomDatabase;
@@ -45,11 +47,12 @@ public class HistoryPostViewModel extends ViewModel {
this.sharedPreferences = sharedPreferences;
this.postType = postType;
this.postFilter = postFilter;
this.postEnricher = postEnricher;
postFilterLiveData = new MutableLiveData<>();
postFilterLiveData.postValue(postFilter);
Pager<String, Post> pager = new Pager<>(new PagingConfig(25, 25, false), this::returnPagingSoruce);
Pager<String, Post> pager = new Pager<>(new PagingConfig(25, 25, false), this::returnPagingSource);
posts = Transformations.switchMap(postFilterLiveData, postFilterValue -> PagingLiveData.cachedIn(PagingLiveData.getLiveData(pager), ViewModelKt.getViewModelScope(this)));
}
@@ -58,19 +61,9 @@ public class HistoryPostViewModel extends ViewModel {
return posts;
}
public HistoryPostPagingSource returnPagingSoruce() {
HistoryPostPagingSource paging3PagingSource;
switch (postType) {
case HistoryPostPagingSource.TYPE_READ_POSTS:
paging3PagingSource = new HistoryPostPagingSource(retrofit, executor, redditDataRoomDatabase, accessToken, accountName,
sharedPreferences, accountName, postType, postFilter);
break;
default:
paging3PagingSource = new HistoryPostPagingSource(retrofit, executor, redditDataRoomDatabase, accessToken, accountName,
sharedPreferences, accountName, postType, postFilter);
break;
}
return paging3PagingSource;
public HistoryPostPagingSource returnPagingSource() {
return new HistoryPostPagingSource(retrofit, executor, redditDataRoomDatabase, accessToken, accountName,
sharedPreferences, accountName, postType, postFilter, postEnricher);
}
public void changePostFilter(PostFilter postFilter) {
@@ -86,10 +79,11 @@ public class HistoryPostViewModel extends ViewModel {
private SharedPreferences sharedPreferences;
private int postType;
private PostFilter postFilter;
private PostEnricher postEnricher;
public Factory(Executor executor, Retrofit retrofit, RedditDataRoomDatabase redditDataRoomDatabase,
String accessToken, String accountName, SharedPreferences sharedPreferences, int postType,
PostFilter postFilter) {
PostFilter postFilter, PostEnricher postEnricher) {
this.executor = executor;
this.retrofit = retrofit;
this.redditDataRoomDatabase = redditDataRoomDatabase;
@@ -98,18 +92,14 @@ public class HistoryPostViewModel extends ViewModel {
this.sharedPreferences = sharedPreferences;
this.postType = postType;
this.postFilter = postFilter;
this.postEnricher = postEnricher;
}
@NonNull
@Override
public <T extends ViewModel> T create(@NonNull Class<T> modelClass) {
if (postType == HistoryPostPagingSource.TYPE_READ_POSTS) {
return (T) new HistoryPostViewModel(executor, retrofit, redditDataRoomDatabase, accessToken, accountName, sharedPreferences,
postType, postFilter);
} else {
return (T) new HistoryPostViewModel(executor, retrofit, redditDataRoomDatabase, accessToken, accountName, sharedPreferences,
postType, postFilter);
}
return (T) new HistoryPostViewModel(executor, retrofit, redditDataRoomDatabase, accessToken, accountName, sharedPreferences,
postType, postFilter, postEnricher);
}
}
}

View File

@@ -34,6 +34,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import eu.toldi.infinityforlemmy.community.BasicCommunityInfo;
import eu.toldi.infinityforlemmy.post.enrich.PostEnricher;
import eu.toldi.infinityforlemmy.postfilter.PostFilter;
import eu.toldi.infinityforlemmy.user.BasicUserInfo;
import eu.toldi.infinityforlemmy.utils.JSONUtils;
@@ -45,7 +46,8 @@ import eu.toldi.infinityforlemmy.utils.Utils;
*/
public class ParsePost {
public static LinkedHashSet<Post> parsePostsSync(String response, int nPosts, PostFilter postFilter, List<String> readPostList) {
public static LinkedHashSet<Post> parsePostsSync(String response, int nPosts, PostFilter postFilter,
List<String> readPostList, PostEnricher postEnricher) {
LinkedHashSet<Post> newPosts = new LinkedHashSet<>();
try {
JSONObject jsonResponse = new JSONObject(response);
@@ -80,6 +82,8 @@ public class ParsePost {
}
}
postEnricher.enrich(newPosts);
return newPosts;
} catch (JSONException e) {
e.printStackTrace();
@@ -87,21 +91,9 @@ public class ParsePost {
}
}
public static String getLastItem(String response) {
try {
JSONObject object = new JSONObject(response).getJSONObject(JSONUtils.DATA_KEY);
return object.isNull(JSONUtils.AFTER_KEY) ? null : object.getString(JSONUtils.AFTER_KEY);
} catch (JSONException e) {
e.printStackTrace();
return null;
}
}
public static void parsePost(Executor executor, Handler handler, String response, ParsePostListener parsePostListener) {
PostFilter postFilter = new PostFilter();
postFilter.allowNSFW = true;
public static void parsePost(Executor executor, Handler handler, PostEnricher postEnricher,
String response, ParsePostListener parsePostListener) {
executor.execute(() -> {
try {
JSONObject allData = new JSONObject(response).getJSONObject("post_view");
@@ -111,6 +103,7 @@ public class ParsePost {
}
Post post = parseBasicData(allData);
postEnricher.enrich(List.of(post));
handler.post(() -> parsePostListener.onParsePostSuccess(post));
} catch (JSONException e) {
e.printStackTrace();
@@ -188,7 +181,7 @@ public class ParsePost {
boolean nsfw = post.getBoolean("nsfw");
boolean locked = post.getBoolean("locked");
boolean saved = data.getBoolean("saved");
String distinguished = (creator.getBoolean("admin") ? "admin" : "");
String distinguished = creator.optBoolean("admin") ? "admin" : "";
String suggestedSort = "";
ArrayList<Post.Preview> previews = new ArrayList<>();
if (!post.isNull("thumbnail_url")) {

View File

@@ -21,6 +21,7 @@ import java.util.concurrent.Executor;
import eu.toldi.infinityforlemmy.RetrofitHolder;
import eu.toldi.infinityforlemmy.SortType;
import eu.toldi.infinityforlemmy.apis.LemmyAPI;
import eu.toldi.infinityforlemmy.post.enrich.PostEnricher;
import eu.toldi.infinityforlemmy.postfilter.PostFilter;
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
import retrofit2.HttpException;
@@ -57,6 +58,7 @@ public class PostPagingSource extends ListenableFuturePagingSource<Integer, Post
private List<String> readPostList;
private String userWhere;
private String multiRedditPath;
private final PostEnricher postEnricher;
private LinkedHashSet<Post> postLinkedHashSet;
private int page = 1;
@@ -64,7 +66,8 @@ public class PostPagingSource extends ListenableFuturePagingSource<Integer, Post
PostPagingSource(Executor executor, RetrofitHolder retrofit, String accessToken, String accountName,
SharedPreferences sharedPreferences,
SharedPreferences postFeedScrolledPositionSharedPreferences, int postType,
SortType sortType, PostFilter postFilter, List<String> readPostList, String option) {
SortType sortType, PostFilter postFilter, List<String> readPostList, String option,
PostEnricher postEnricher) {
this.executor = executor;
this.retrofit = retrofit;
this.accessToken = accessToken;
@@ -76,13 +79,14 @@ public class PostPagingSource extends ListenableFuturePagingSource<Integer, Post
this.sortType = sortType == null ? new SortType(SortType.Type.ACTIVE) : sortType;
this.postFilter = postFilter;
this.readPostList = readPostList;
this.postEnricher = postEnricher;
postLinkedHashSet = new LinkedHashSet<>();
}
PostPagingSource(Executor executor, RetrofitHolder retrofit, String accessToken, String accountName,
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
String path, int postType, SortType sortType, PostFilter postFilter,
List<String> readPostList) {
List<String> readPostList, PostEnricher postEnricher) {
this.executor = executor;
this.retrofit = retrofit;
this.accessToken = accessToken;
@@ -114,13 +118,14 @@ public class PostPagingSource extends ListenableFuturePagingSource<Integer, Post
}
this.postFilter = postFilter;
this.readPostList = readPostList;
this.postEnricher = postEnricher;
postLinkedHashSet = new LinkedHashSet<>();
}
PostPagingSource(Executor executor, RetrofitHolder retrofit, String accessToken, String accountName,
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
String subredditOrUserName, int postType, SortType sortType, PostFilter postFilter,
String where, List<String> readPostList) {
String where, List<String> readPostList, PostEnricher postEnricher) {
this.executor = executor;
this.retrofit = retrofit;
this.accessToken = accessToken;
@@ -133,13 +138,14 @@ public class PostPagingSource extends ListenableFuturePagingSource<Integer, Post
this.postFilter = postFilter;
userWhere = where;
this.readPostList = readPostList;
this.postEnricher = postEnricher;
postLinkedHashSet = new LinkedHashSet<>();
}
PostPagingSource(Executor executor, RetrofitHolder retrofit, String accessToken, String accountName,
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
String subredditOrUserName, String query, String trendingSource, int postType,
SortType sortType, PostFilter postFilter, List<String> readPostList) {
SortType sortType, PostFilter postFilter, List<String> readPostList, PostEnricher postEnricher) {
this.executor = executor;
this.retrofit = retrofit;
this.accessToken = accessToken;
@@ -152,8 +158,9 @@ public class PostPagingSource extends ListenableFuturePagingSource<Integer, Post
this.postType = postType;
this.sortType = sortType == null ? new SortType(SortType.Type.TOP) : sortType;
this.postFilter = postFilter;
postLinkedHashSet = new LinkedHashSet<>();
this.readPostList = readPostList;
this.postEnricher = postEnricher;
postLinkedHashSet = new LinkedHashSet<>();
}
@Nullable
@@ -190,7 +197,7 @@ public class PostPagingSource extends ListenableFuturePagingSource<Integer, Post
public LoadResult<Integer, Post> transformData(Response<String> response) {
if (response.isSuccessful()) {
String responseString = response.body();
LinkedHashSet<Post> newPosts = ParsePost.parsePostsSync(responseString, -1, postFilter, readPostList);
LinkedHashSet<Post> newPosts = ParsePost.parsePostsSync(responseString, -1, postFilter, readPostList, postEnricher);
if (newPosts == null) {
return new LoadResult.Error<>(new Exception("Error parsing posts"));
@@ -236,7 +243,7 @@ public class PostPagingSource extends ListenableFuturePagingSource<Integer, Post
}
String feed_type = Objects.equals(subredditOrUserName, "all") ? "All" : Objects.equals(subredditOrUserName, "local") ? "Local" : "Subscribed";
bestPost = api.getPosts(feed_type,sortType.getType().value,page,25,null,null,false,accessToken);
bestPost = api.getPostsListenableFuture(feed_type, sortType.getType().value, page, 25, null, null, false, accessToken);
ListenableFuture<LoadResult<Integer, Post>> pageFuture = Futures.transform(bestPost, this::transformData, executor);
@@ -251,7 +258,7 @@ public class PostPagingSource extends ListenableFuturePagingSource<Integer, Post
private ListenableFuture<LoadResult<Integer, Post>> loadSubredditPosts(@NonNull LoadParams<Integer> loadParams, LemmyAPI api) {
ListenableFuture<Response<String>> subredditPost;
subredditPost = api.getPosts(null,sortType.getType().value,loadParams.getKey(),25,null,subredditOrUserName,false,accessToken);
subredditPost = api.getPostsListenableFuture(null, sortType.getType().value, loadParams.getKey(), 25, null, subredditOrUserName, false, accessToken);
ListenableFuture<LoadResult<Integer, Post>> pageFuture = Futures.transform(subredditPost, this::transformData, executor);
@@ -266,7 +273,7 @@ public class PostPagingSource extends ListenableFuturePagingSource<Integer, Post
private ListenableFuture<LoadResult<Integer, Post>> loadUserPosts(@NonNull LoadParams<Integer> loadParams, LemmyAPI api) {
ListenableFuture<Response<String>> userPosts;
userPosts = api.getUserPosts(subredditOrUserName, sortType.getType().value, loadParams.getKey(), 25, userWhere.equals(USER_WHERE_SAVED), accessToken);
userPosts = api.getUserPostsListenableFuture(subredditOrUserName, sortType.getType().value, loadParams.getKey(), 25, userWhere.equals(USER_WHERE_SAVED), accessToken);
ListenableFuture<LoadResult<Integer, Post>> pageFuture = Futures.transform(userPosts, this::transformData, executor);

View File

@@ -23,6 +23,7 @@ import java.util.concurrent.Executor;
import eu.toldi.infinityforlemmy.RetrofitHolder;
import eu.toldi.infinityforlemmy.SortType;
import eu.toldi.infinityforlemmy.post.enrich.PostEnricher;
import eu.toldi.infinityforlemmy.postfilter.PostFilter;
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
@@ -41,6 +42,7 @@ public class PostViewModel extends ViewModel {
private PostFilter postFilter;
private String userWhere;
private List<String> readPostList;
private PostEnricher postEnricher;
private MutableLiveData<Boolean> currentlyReadPostIdsLiveData = new MutableLiveData<>();
private LiveData<PagingData<Post>> posts;
@@ -53,7 +55,7 @@ public class PostViewModel extends ViewModel {
public PostViewModel(Executor executor, RetrofitHolder retrofit, String accessToken, String accountName,
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
@Nullable SharedPreferences postHistorySharedPreferences, int postType,
SortType sortType, PostFilter postFilter, List<String> readPostList, String option) {
SortType sortType, PostFilter postFilter, List<String> readPostList, String option, PostEnricher postEnricher) {
this.executor = executor;
this.retrofit = retrofit;
this.accessToken = accessToken;
@@ -65,6 +67,7 @@ public class PostViewModel extends ViewModel {
this.postFilter = postFilter;
this.readPostList = readPostList;
this.name = option;
this.postEnricher = postEnricher;
sortTypeLiveData = new MutableLiveData<>();
sortTypeLiveData.postValue(sortType);
@@ -95,7 +98,7 @@ public class PostViewModel extends ViewModel {
public PostViewModel(Executor executor, RetrofitHolder retrofit, String accessToken, String accountName,
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
@Nullable SharedPreferences postHistorySharedPreferences, String subredditName, int postType,
SortType sortType, PostFilter postFilter, List<String> readPostList) {
SortType sortType, PostFilter postFilter, List<String> readPostList, PostEnricher postEnricher) {
this.executor = executor;
this.retrofit = retrofit;
this.accessToken = accessToken;
@@ -107,6 +110,7 @@ public class PostViewModel extends ViewModel {
this.postFilter = postFilter;
this.readPostList = readPostList;
this.name = subredditName;
this.postEnricher = postEnricher;
sortTypeLiveData = new MutableLiveData<>();
sortTypeLiveData.postValue(sortType);
@@ -139,7 +143,7 @@ public class PostViewModel extends ViewModel {
SharedPreferences postFeedScrolledPositionSharedPreferences,
@Nullable SharedPreferences postHistorySharedPreferences, String username,
int postType, SortType sortType, PostFilter postFilter, String userWhere,
List<String> readPostList) {
List<String> readPostList, PostEnricher postEnricher) {
this.executor = executor;
this.retrofit = retrofit;
this.accessToken = accessToken;
@@ -152,6 +156,7 @@ public class PostViewModel extends ViewModel {
this.readPostList = readPostList;
this.name = username;
this.userWhere = userWhere;
this.postEnricher = postEnricher;
sortTypeLiveData = new MutableLiveData<>();
sortTypeLiveData.postValue(sortType);
@@ -183,7 +188,7 @@ public class PostViewModel extends ViewModel {
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
@Nullable SharedPreferences postHistorySharedPreferences, String subredditName, String query,
String trendingSource, int postType, SortType sortType, PostFilter postFilter,
List<String> readPostList) {
List<String> readPostList, PostEnricher postEnricher) {
this.executor = executor;
this.retrofit = retrofit;
this.accessToken = accessToken;
@@ -197,6 +202,7 @@ public class PostViewModel extends ViewModel {
this.name = subredditName;
this.query = query;
this.trendingSource = trendingSource;
this.postEnricher = postEnricher;
sortTypeLiveData = new MutableLiveData<>();
sortTypeLiveData.postValue(sortType);
@@ -238,25 +244,25 @@ public class PostViewModel extends ViewModel {
case PostPagingSource.TYPE_FRONT_PAGE:
paging3PagingSource = new PostPagingSource(executor, retrofit, accessToken, accountName,
sharedPreferences, postFeedScrolledPositionSharedPreferences, postType, sortType,
postFilter, readPostList,name);
postFilter, readPostList, name, postEnricher);
break;
case PostPagingSource.TYPE_SUBREDDIT:
case PostPagingSource.TYPE_MULTI_REDDIT:
case PostPagingSource.TYPE_ANONYMOUS_FRONT_PAGE:
paging3PagingSource = new PostPagingSource(executor, retrofit, accessToken, accountName,
sharedPreferences, postFeedScrolledPositionSharedPreferences, name, postType,
sortType, postFilter, readPostList);
sortType, postFilter, readPostList, postEnricher);
break;
case PostPagingSource.TYPE_SEARCH:
paging3PagingSource = new PostPagingSource(executor, retrofit, accessToken, accountName,
sharedPreferences, postFeedScrolledPositionSharedPreferences, name, query, trendingSource,
postType, sortType, postFilter, readPostList);
postType, sortType, postFilter, readPostList, postEnricher);
break;
default:
//User
paging3PagingSource = new PostPagingSource(executor, retrofit, accessToken, accountName,
sharedPreferences, postFeedScrolledPositionSharedPreferences, name, postType,
sortType, postFilter, userWhere, readPostList);
sortType, postFilter, userWhere, readPostList, postEnricher);
break;
}
return paging3PagingSource;
@@ -291,11 +297,12 @@ public class PostViewModel extends ViewModel {
private PostFilter postFilter;
private String userWhere;
private List<String> readPostList;
private PostEnricher postEnricher;
public Factory(Executor executor, RetrofitHolder retrofit, String accessToken, String accountName,
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
SharedPreferences postHistorySharedPreferences, int postType, SortType sortType,
PostFilter postFilter, List<String> readPostList, String option) {
PostFilter postFilter, List<String> readPostList, String option, PostEnricher postEnricher) {
this.executor = executor;
this.retrofit = retrofit;
this.accessToken = accessToken;
@@ -308,12 +315,13 @@ public class PostViewModel extends ViewModel {
this.postFilter = postFilter;
this.readPostList = readPostList;
this.name = option;
this.postEnricher = postEnricher;
}
public Factory(Executor executor, RetrofitHolder retrofit, String accessToken, String accountName,
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
SharedPreferences postHistorySharedPreferences, String name, int postType, SortType sortType,
PostFilter postFilter, List<String> readPostList) {
PostFilter postFilter, List<String> readPostList, PostEnricher postEnricher) {
this.executor = executor;
this.retrofit = retrofit;
this.accessToken = accessToken;
@@ -326,13 +334,15 @@ public class PostViewModel extends ViewModel {
this.sortType = sortType;
this.postFilter = postFilter;
this.readPostList = readPostList;
this.postEnricher = postEnricher;
}
//User posts
public Factory(Executor executor, RetrofitHolder retrofit, String accessToken, String accountName,
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
SharedPreferences postHistorySharedPreferences, String username, int postType,
SortType sortType, PostFilter postFilter, String where, List<String> readPostList) {
SortType sortType, PostFilter postFilter, String where, List<String> readPostList,
PostEnricher postEnricher) {
this.executor = executor;
this.retrofit = retrofit;
this.accessToken = accessToken;
@@ -346,12 +356,14 @@ public class PostViewModel extends ViewModel {
this.postFilter = postFilter;
userWhere = where;
this.readPostList = readPostList;
this.postEnricher = postEnricher;
}
public Factory(Executor executor, RetrofitHolder retrofit, String accessToken, String accountName,
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
SharedPreferences postHistorySharedPreferences, String name, String query, String trendingSource,
int postType, SortType sortType, PostFilter postFilter, List<String> readPostList) {
int postType, SortType sortType, PostFilter postFilter, List<String> readPostList,
PostEnricher postEnricher) {
this.executor = executor;
this.retrofit = retrofit;
this.accessToken = accessToken;
@@ -366,19 +378,23 @@ public class PostViewModel extends ViewModel {
this.sortType = sortType;
this.postFilter = postFilter;
this.readPostList = readPostList;
this.postEnricher = postEnricher;
}
//Anonymous Front Page
public Factory(Executor executor, RetrofitHolder retrofit, SharedPreferences sharedPreferences,
String concatenatedSubredditNames, int postType, SortType sortType, PostFilter postFilter, String opt) {
String concatenatedSubredditNames, int postType, SortType sortType, PostFilter postFilter,
String opt, PostEnricher postEnricher) {
this.executor = executor;
this.retrofit = retrofit;
this.sharedPreferences = sharedPreferences;
// TODO is this used? because it is getting overwritten with opt
this.name = concatenatedSubredditNames;
this.postType = postType;
this.sortType = sortType;
this.postFilter = postFilter;
this.name = opt;
this.postEnricher = postEnricher;
}
@NonNull
@@ -387,23 +403,23 @@ public class PostViewModel extends ViewModel {
if (postType == PostPagingSource.TYPE_FRONT_PAGE) {
return (T) new PostViewModel(executor, retrofit, accessToken, accountName, sharedPreferences,
postFeedScrolledPositionSharedPreferences, postHistorySharedPreferences, postType,
sortType, postFilter, readPostList,name);
sortType, postFilter, readPostList,name, postEnricher);
} else if (postType == PostPagingSource.TYPE_SEARCH) {
return (T) new PostViewModel(executor, retrofit, accessToken, accountName, sharedPreferences,
postFeedScrolledPositionSharedPreferences, postHistorySharedPreferences, name, query,
trendingSource, postType, sortType, postFilter, readPostList);
trendingSource, postType, sortType, postFilter, readPostList, postEnricher);
} else if (postType == PostPagingSource.TYPE_SUBREDDIT || postType == PostPagingSource.TYPE_MULTI_REDDIT) {
return (T) new PostViewModel(executor, retrofit, accessToken, accountName, sharedPreferences,
postFeedScrolledPositionSharedPreferences, postHistorySharedPreferences, name,
postType, sortType, postFilter, readPostList);
postType, sortType, postFilter, readPostList, postEnricher);
} else if (postType == PostPagingSource.TYPE_ANONYMOUS_FRONT_PAGE) {
return (T) new PostViewModel(executor, retrofit, null, null, sharedPreferences,
null, null, name, postType, sortType,
postFilter, null);
postFilter, null, postEnricher);
} else {
return (T) new PostViewModel(executor, retrofit, accessToken, accountName, sharedPreferences,
postFeedScrolledPositionSharedPreferences, postHistorySharedPreferences, name,
postType, sortType, postFilter, userWhere, readPostList);
postType, sortType, postFilter, userWhere, readPostList, postEnricher);
}
}
}

View File

@@ -15,6 +15,7 @@ import eu.toldi.infinityforlemmy.Flair;
import eu.toldi.infinityforlemmy.RetrofitHolder;
import eu.toldi.infinityforlemmy.apis.LemmyAPI;
import eu.toldi.infinityforlemmy.dto.SubmitPostDTO;
import eu.toldi.infinityforlemmy.post.enrich.PostEnricher;
import eu.toldi.infinityforlemmy.utils.APIUtils;
import eu.toldi.infinityforlemmy.utils.UploadImageUtils;
import retrofit2.Call;
@@ -25,22 +26,24 @@ public class SubmitPost {
public static void submitTextOrLinkPost(Executor executor, Handler handler, Retrofit oauthRetrofit, String accessToken,
int communityId, String title, String body, String url,
Flair flair, boolean isSpoiler, boolean isNSFW,
boolean receivePostReplyNotifications, String kind,
boolean receivePostReplyNotifications, String kind, PostEnricher postEnricher,
SubmitPostListener submitPostListener) {
submitPost(executor, handler, oauthRetrofit, accessToken, communityId, title, body,
isNSFW, receivePostReplyNotifications, kind, url, submitPostListener);
isNSFW, receivePostReplyNotifications, kind, url, postEnricher, submitPostListener);
}
public static void submitImagePost(Executor executor, Handler handler, RetrofitHolder mRetrofit,
String accessToken, int communityId, String title, String body, Bitmap image,
Flair flair, boolean isSpoiler, boolean isNSFW,
boolean receivePostReplyNotifications, SubmitPostListener submitPostListener) {
boolean receivePostReplyNotifications, PostEnricher postEnricher,
SubmitPostListener submitPostListener) {
try {
String imageUrlOrError = UploadImageUtils.uploadImage(mRetrofit, accessToken, image);
if (imageUrlOrError != null && !imageUrlOrError.startsWith("Error: ")) {
submitPost(executor, handler, mRetrofit.getRetrofit(), accessToken,
communityId, title, body, isNSFW,
receivePostReplyNotifications, APIUtils.KIND_IMAGE, imageUrlOrError, submitPostListener);
receivePostReplyNotifications, APIUtils.KIND_IMAGE, imageUrlOrError,
postEnricher, submitPostListener);
} else {
submitPostListener.submitFailed(imageUrlOrError);
}
@@ -53,17 +56,18 @@ public class SubmitPost {
public static void submitCrosspost(Executor executor, Handler handler, Retrofit oauthRetrofit, String accessToken,
int communityId, String title, String crosspostFullname,
Flair flair, boolean isSpoiler, boolean isNSFW,
boolean receivePostReplyNotifications, String kind,
boolean receivePostReplyNotifications, String kind, PostEnricher postEnricher,
SubmitPostListener submitPostListener) {
submitPost(executor, handler, oauthRetrofit, accessToken, communityId, title, crosspostFullname,
isNSFW, receivePostReplyNotifications, kind, null, submitPostListener);
isNSFW, receivePostReplyNotifications, kind, null, postEnricher, submitPostListener);
}
private static void submitPost(Executor executor, Handler handler, Retrofit oauthRetrofit, String accessToken,
int communityId, String title, String content,
boolean isNSFW,
boolean receivePostReplyNotifications, String kind,
@Nullable String posterUrl, SubmitPostListener submitPostListener) {
@Nullable String posterUrl, PostEnricher postEnricher,
SubmitPostListener submitPostListener) {
LemmyAPI api = oauthRetrofit.create(LemmyAPI.class);
@@ -73,7 +77,7 @@ public class SubmitPost {
Response<String> response = submitPostCall.execute();
if (response.isSuccessful()) {
getSubmittedPost(executor, handler, response.body(), kind, oauthRetrofit, accessToken,
submitPostListener);
postEnricher, submitPostListener);
} else {
submitPostListener.submitFailed(response.message());
}
@@ -84,10 +88,10 @@ public class SubmitPost {
}
private static void getSubmittedPost(Executor executor, Handler handler, String response, String kind,
Retrofit oauthRetrofit, String accessToken,
Retrofit oauthRetrofit, String accessToken, PostEnricher postEnricher,
SubmitPostListener submitPostListener) throws JSONException, IOException {
ParsePost.parsePost(executor, handler, response, new ParsePost.ParsePostListener() {
ParsePost.parsePost(executor, handler, postEnricher, response, new ParsePost.ParsePostListener() {
@Override
public void onParsePostSuccess(Post post) {
submitPostListener.submitSuccessful(post);

View File

@@ -153,7 +153,7 @@ public class DownloadMediaService extends Service {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
File directory = getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
if (directory != null) {
String directoryPath = separateDownloadFolder && subredditName != null && !subredditName.equals("") ? directory.getAbsolutePath() + "/Infinity/" + subredditName + "/" : directory.getAbsolutePath() + "/Infinity/";
String directoryPath = separateDownloadFolder && subredditName != null && !subredditName.equals("") ? directory.getAbsolutePath() + "/Eternity/" + subredditName + "/" : directory.getAbsolutePath() + "/Eternity/";
File infinityDir = new File(directoryPath);
if (!infinityDir.exists() && !infinityDir.mkdirs()) {
downloadFinished(mediaType, randomNotificationIdOffset, mimeType,
@@ -168,7 +168,7 @@ public class DownloadMediaService extends Service {
}
} else {
String dir = mediaType == EXTRA_MEDIA_TYPE_VIDEO ? Environment.DIRECTORY_MOVIES : Environment.DIRECTORY_PICTURES;
destinationFileUriString = separateDownloadFolder && subredditName != null && !subredditName.equals("") ? dir + "/Infinity/" + subredditName + "/" : dir + "/Infinity/";
destinationFileUriString = separateDownloadFolder && subredditName != null && !subredditName.equals("") ? dir + "/Eternity/" + subredditName + "/" : dir + "/Eternity/";
}
isDefaultDestination = true;
} else {

View File

@@ -54,6 +54,7 @@ import eu.toldi.infinityforlemmy.events.SubmitPollPostEvent;
import eu.toldi.infinityforlemmy.events.SubmitTextOrLinkPostEvent;
import eu.toldi.infinityforlemmy.post.Post;
import eu.toldi.infinityforlemmy.post.SubmitPost;
import eu.toldi.infinityforlemmy.post.enrich.PostEnricher;
import eu.toldi.infinityforlemmy.utils.APIUtils;
import eu.toldi.infinityforlemmy.utils.JSONUtils;
import eu.toldi.infinityforlemmy.utils.NotificationUtils;
@@ -102,6 +103,8 @@ public class SubmitPostService extends Service {
CustomThemeWrapper mCustomThemeWrapper;
@Inject
Executor mExecutor;
@Inject
PostEnricher postEnricher;
private Handler handler;
private ServiceHandler serviceHandler;
@@ -221,7 +224,7 @@ public class SubmitPostService extends Service {
String kind) {
SubmitPost.submitTextOrLinkPost(mExecutor, handler, newAuthenticatorOauthRetrofit, selectedAccount.getAccessToken(),
communityId, title, body, url, flair, isSpoiler,
isNSFW, receivePostReplyNotifications, kind, new SubmitPost.SubmitPostListener() {
isNSFW, receivePostReplyNotifications, kind, postEnricher, new SubmitPost.SubmitPostListener() {
@Override
public void submitSuccessful(Post post) {
handler.post(() -> EventBus.getDefault().post(new SubmitTextOrLinkPostEvent(true, post, null)));
@@ -243,7 +246,7 @@ public class SubmitPostService extends Service {
String title, String content, Flair flair, boolean isSpoiler, boolean isNSFW,
boolean receivePostReplyNotifications) {
SubmitPost.submitCrosspost(executor, handler, newAuthenticatorOauthRetrofit, selectedAccount.getAccessToken(), communityId, title,
content, flair, isSpoiler, isNSFW, receivePostReplyNotifications, APIUtils.KIND_CROSSPOST,
content, flair, isSpoiler, isNSFW, receivePostReplyNotifications, APIUtils.KIND_CROSSPOST, postEnricher,
new SubmitPost.SubmitPostListener() {
@Override
public void submitSuccessful(Post post) {
@@ -266,7 +269,8 @@ public class SubmitPostService extends Service {
try {
Bitmap resource = Glide.with(this).asBitmap().load(mediaUri).submit().get();
SubmitPost.submitImagePost(mExecutor, handler, newAuthenticatorOauthRetrofit,
selectedAccount.getAccessToken(), communityId, title, body, resource, flair, isSpoiler, isNSFW, receivePostReplyNotifications,
selectedAccount.getAccessToken(), communityId, title, body, resource, flair, isSpoiler,
isNSFW, receivePostReplyNotifications, postEnricher,
new SubmitPost.SubmitPostListener() {
@Override
public void submitSuccessful(Post post) {

View File

@@ -68,7 +68,7 @@ public class AboutPreferenceFragment extends CustomFontPreferenceFragmentCompat
if (subredditPreference != null) {
subredditPreference.setOnPreferenceClickListener(preference -> {
Intent intent = new Intent(activity, LinkResolverActivity.class);
intent.setData(Uri.parse("https://lemdro.id/c/infinityforlemmy"));
intent.setData(Uri.parse("https://lemdro.id/c/eternityapp"));
activity.startActivity(intent);
return true;
});

View File

@@ -1,8 +1,15 @@
package eu.toldi.infinityforlemmy.site;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.List;
import eu.toldi.infinityforlemmy.user.BasicUserInfo;
import eu.toldi.infinityforlemmy.utils.LemmyUtils;
public class SiteInfo {
private int id;
@@ -13,14 +20,23 @@ public class SiteInfo {
private boolean enable_nsfw;
private boolean community_creation_admin_only;
public SiteInfo(int id, String name, String sidebar, String description, boolean enable_downvotes, boolean enable_nsfw, boolean community_creation_admin_only) {
private String version;
private List<BasicUserInfo> admins;
SiteStatistics siteStatistics;
public SiteInfo(int id, String name, String version, String sidebar, String description, boolean enable_downvotes, boolean enable_nsfw, boolean community_creation_admin_only, List<BasicUserInfo> admins, SiteStatistics siteStatistics) {
this.id = id;
this.name = name;
this.version = version;
this.sidebar = sidebar;
this.description = description;
this.enable_downvotes = enable_downvotes;
this.enable_nsfw = enable_nsfw;
this.community_creation_admin_only = community_creation_admin_only;
this.admins = admins;
this.siteStatistics = siteStatistics;
}
public int getId() {
@@ -51,6 +67,18 @@ public class SiteInfo {
return community_creation_admin_only;
}
public List<BasicUserInfo> getAdmins() {
return admins;
}
public SiteStatistics getSiteStatistics() {
return siteStatistics;
}
public String getVersion() {
return version;
}
public static SiteInfo parseSiteInfo(String siteInfoJson) {
try {
JSONObject siteInfo = new JSONObject(siteInfoJson);
@@ -63,6 +91,7 @@ public class SiteInfo {
String sidebar = null;
if (site.has("sidebar"))
sidebar = site.getString("sidebar");
String version = siteInfo.getString("version");
String description = null;
if (site.has("description"))
@@ -72,9 +101,20 @@ public class SiteInfo {
boolean enable_nsfw = localSite.getBoolean("enable_nsfw");
boolean community_creation_admin_only = localSite.getBoolean("community_creation_admin_only");
SiteInfo si = new SiteInfo(id, name, sidebar, description, enable_downvotes, enable_nsfw, community_creation_admin_only);
JSONObject counts = siteView.getJSONObject("counts");
List<BasicUserInfo> admins = new ArrayList<>();
if (siteInfo.has("admins")) {
JSONArray adminsJson = siteInfo.getJSONArray("admins");
for (int i = 0; i < adminsJson.length(); i++) {
JSONObject adminJson = adminsJson.getJSONObject(i).getJSONObject("person");
admins.add(new BasicUserInfo(adminJson.getInt("id"), adminJson.getString("name"),
LemmyUtils.actorID2FullName(adminJson.getString("actor_id")), adminJson.optString("avatar ", ""),
adminJson.optString("display_name", adminJson.getString("name")))
);
}
}
return si;
return new SiteInfo(id, name, version, sidebar, description, enable_downvotes, enable_nsfw, community_creation_admin_only, admins, SiteStatistics.parseSiteStatistics(counts));
} catch (JSONException e) {
e.printStackTrace();
return null;

View File

@@ -0,0 +1,55 @@
package eu.toldi.infinityforlemmy.site;
import org.json.JSONException;
import org.json.JSONObject;
public class SiteStatistics {
private final int users;
private final int posts;
private final int comments;
private final int communities;
private final int users_active;
public SiteStatistics(int users, int posts, int comments, int communities, int users_active) {
this.users = users;
this.posts = posts;
this.comments = comments;
this.communities = communities;
this.users_active = users_active;
}
public int getUsers() {
return users;
}
public int getPosts() {
return posts;
}
public int getComments() {
return comments;
}
public int getCommunities() {
return communities;
}
public int getUsers_active() {
return users_active;
}
public static SiteStatistics parseSiteStatistics(JSONObject countsJson) {
try {
int users = countsJson.getInt("users");
int posts = countsJson.getInt("posts");
int comments = countsJson.getInt("comments");
int communities = countsJson.getInt("communities");
int users_active = countsJson.getInt("users_active_month");
return new SiteStatistics(users, posts, comments, communities, users_active);
} catch (JSONException e) {
e.printStackTrace();
return null;
}
}
}

View File

@@ -112,7 +112,7 @@ public class CommunitySubscription {
SubredditSubscriptionListener subredditSubscriptionListener) {
executor.execute(() -> {
SubscribedSubredditData subscribedSubredditData = new SubscribedSubredditData(subredditData.getId(), subredditData.getName(), LemmyUtils.actorID2FullName(subredditData.getActorId()),
subredditData.getIconUrl(), accountName);
subredditData.getIconUrl(), accountName, false);
if (accountName.equals("-")) {
if (!redditDataRoomDatabase.accountDao().isAnonymousAccountInserted()) {
redditDataRoomDatabase.accountDao().insert(Account.getAnonymousAccount());

View File

@@ -16,7 +16,9 @@ import java.util.Locale;
import java.util.TimeZone;
import eu.toldi.infinityforlemmy.community.CommunityStats;
import eu.toldi.infinityforlemmy.user.BasicUserInfo;
import eu.toldi.infinityforlemmy.utils.JSONUtils;
import eu.toldi.infinityforlemmy.utils.LemmyUtils;
public class ParseSubredditData {
public static void parseSubredditData(String response, ParseSubredditDataListener parseSubredditDataListener) {
@@ -80,7 +82,6 @@ public class ParseSubredditData {
int commentCount = counts.getInt("comments");
stats = new CommunityStats(subscribers, activeUserCount, postCount, commentCount);
}
return new SubredditData(id, name, title, description, removed, published, updated, deleted, isNSFW, actorId, local, iconUrl, bannerImageUrl, hidden, postingRestrictedToMods, instanceId, subscribers, blocked, stats);
}
@@ -120,6 +121,16 @@ public class ParseSubredditData {
JSONObject data = jsonResponse.getJSONObject("community_view");
mNCurrentOnlineSubscribers = 0;// data.getInt(JSONUtils.ACTIVE_USER_COUNT_KEY);
subredditData = parseSubredditData(data, true);
JSONArray moderators = jsonResponse.getJSONArray("moderators");
for (int i = 0; i < moderators.length(); i++) {
JSONObject moderator = moderators.getJSONObject(i).getJSONObject("moderator");
int mod_id = moderator.getInt("id");
String mod_name = moderator.getString("name");
String mod_displayName = moderator.optString("display_name", mod_name);
String mod_qualified_name = LemmyUtils.actorID2FullName(moderator.getString("actor_id"));
String avatarUrl = moderator.optString("avatar", "");
subredditData.addModerator(new BasicUserInfo(mod_id, mod_name, mod_qualified_name, avatarUrl, mod_displayName));
}
} catch (JSONException e) {
parseFailed = true;
e.printStackTrace();

View File

@@ -9,7 +9,11 @@ import androidx.room.Entity;
import androidx.room.Ignore;
import androidx.room.PrimaryKey;
import java.util.ArrayList;
import java.util.List;
import eu.toldi.infinityforlemmy.community.CommunityStats;
import eu.toldi.infinityforlemmy.user.BasicUserInfo;
@Entity(tableName = "subreddits")
public class SubredditData implements Parcelable {
@@ -76,6 +80,9 @@ public class SubredditData implements Parcelable {
@Ignore
private CommunityStats communityStats;
@Ignore
private List<BasicUserInfo> moderators = new ArrayList<>();
protected SubredditData(Parcel in) {
id = in.readInt();
name = in.readString();
@@ -366,4 +373,12 @@ public class SubredditData implements Parcelable {
public void setCommunityStats(CommunityStats communityStats) {
this.communityStats = communityStats;
}
public List<BasicUserInfo> getModerators() {
return moderators;
}
public void addModerator(BasicUserInfo moderator) {
moderators.add(moderator);
}
}

View File

@@ -31,6 +31,9 @@ public interface SubscribedSubredditDao {
@Query("SELECT * from subscribed_subreddits WHERE qualified_name = :qualified_name COLLATE NOCASE AND username = :accountName COLLATE NOCASE LIMIT 1")
SubscribedSubredditData getSubscribedSubredditByQualifiedName(String qualified_name, String accountName);
@Query("DELETE FROM subscribed_subreddits WHERE name = :subredditName COLLATE NOCASE AND username = :accountName COLLATE NOCASE")
@Query("DELETE FROM subscribed_subreddits WHERE qualified_name = :subredditName COLLATE NOCASE AND username = :accountName COLLATE NOCASE")
void deleteSubscribedSubreddit(String subredditName, String accountName);
@Query("SELECT * from subscribed_subreddits WHERE username = :qualified_name AND name LIKE '%' || :searchQuery || '%' COLLATE NOCASE AND is_favorite = 1 ORDER BY name COLLATE NOCASE ASC")
LiveData<List<SubscribedSubredditData>> getAllFavoriteSubscribedSubredditsWithSearchQuery(String qualified_name, String searchQuery);
}

View File

@@ -4,6 +4,7 @@ import android.os.Parcel;
import android.os.Parcelable;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.ForeignKey;
@@ -30,12 +31,16 @@ public class SubscribedSubredditData implements Parcelable {
@ColumnInfo(name = "username")
private String username;
public SubscribedSubredditData(@NonNull int id, String name, @NonNull String qualified_name, String iconUrl, @NonNull String username) {
@ColumnInfo(name = "is_favorite")
private boolean favorite;
public SubscribedSubredditData(@NonNull int id, String name, @NonNull String qualified_name, String iconUrl, @NonNull String username, boolean favorite) {
this.id = id;
this.name = name;
this.iconUrl = iconUrl;
this.username = username;
this.qualified_name = qualified_name;
this.favorite = favorite;
}
public SubscribedSubredditData(@NonNull SubredditData communityData) {
@@ -44,6 +49,7 @@ public class SubscribedSubredditData implements Parcelable {
this.iconUrl = communityData.getIconUrl();
this.username = "-";
this.qualified_name = LemmyUtils.actorID2FullName(communityData.getActorId());
this.favorite = false;
}
@NonNull
@@ -89,6 +95,7 @@ public class SubscribedSubredditData implements Parcelable {
parcel.writeString(iconUrl);
parcel.writeString(username);
parcel.writeString(qualified_name);
parcel.writeByte((byte) (favorite ? 1 : 0));
}
public SubscribedSubredditData(Parcel in) {
@@ -97,6 +104,7 @@ public class SubscribedSubredditData implements Parcelable {
iconUrl = in.readString();
username = in.readString();
qualified_name = in.readString();
favorite = in.readByte() != 0;
}
public static final Creator<SubscribedSubredditData> CREATOR = new Creator<>() {
@@ -110,4 +118,25 @@ public class SubscribedSubredditData implements Parcelable {
return new SubscribedSubredditData[size];
}
};
public boolean isFavorite() {
return favorite;
}
public void setFavorite(boolean favorite) {
this.favorite = favorite;
}
@Override
public int hashCode() {
return id + username.hashCode();
}
@Override
public boolean equals(@Nullable Object obj) {
if (obj instanceof SubscribedSubredditData) {
return id == ((SubscribedSubredditData) obj).getId() && username.equalsIgnoreCase(((SubscribedSubredditData) obj).getUsername());
}
return false;
}
}

View File

@@ -21,6 +21,10 @@ public class SubscribedSubredditRepository {
return mSubscribedSubredditDao.getAllSubscribedSubredditsWithSearchQuery(mAccountName, searchQuery);
}
public LiveData<List<SubscribedSubredditData>> getAllFavoriteSubscribedSubredditsWithSearchQuery(String searchQuery) {
return mSubscribedSubredditDao.getAllFavoriteSubscribedSubredditsWithSearchQuery(mAccountName, searchQuery);
}
public void insert(SubscribedSubredditData subscribedSubredditData) {
new insertAsyncTask(mSubscribedSubredditDao).execute(subscribedSubredditData);
}

View File

@@ -17,6 +17,7 @@ import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
public class SubscribedSubredditViewModel extends AndroidViewModel {
private SubscribedSubredditRepository mSubscribedSubredditRepository;
private LiveData<List<SubscribedSubredditData>> mAllSubscribedSubreddits;
private LiveData<List<SubscribedSubredditData>> mAllFavoriteSubscribedSubreddits;
private MutableLiveData<String> searchQueryLiveData;
public SubscribedSubredditViewModel(Application application, RedditDataRoomDatabase redditDataRoomDatabase, String accountName) {
@@ -26,12 +27,17 @@ public class SubscribedSubredditViewModel extends AndroidViewModel {
searchQueryLiveData.postValue("");
mAllSubscribedSubreddits = Transformations.switchMap(searchQueryLiveData, searchQuery -> mSubscribedSubredditRepository.getAllSubscribedSubredditsWithSearchQuery(searchQuery));
mAllFavoriteSubscribedSubreddits = Transformations.switchMap(searchQueryLiveData, searchQuery -> mSubscribedSubredditRepository.getAllFavoriteSubscribedSubredditsWithSearchQuery(searchQuery));
}
public LiveData<List<SubscribedSubredditData>> getAllSubscribedSubreddits() {
return mAllSubscribedSubreddits;
}
public LiveData<List<SubscribedSubredditData>> getAllFavoriteSubscribedSubreddits() {
return mAllFavoriteSubscribedSubreddits;
}
public void insert(SubscribedSubredditData subscribedSubredditData) {
mSubscribedSubredditRepository.insert(subscribedSubredditData);
}

View File

@@ -0,0 +1,139 @@
package eu.toldi.infinityforlemmy.user;
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 butterknife.BindView;
import butterknife.ButterKnife;
import eu.toldi.infinityforlemmy.R;
import eu.toldi.infinityforlemmy.activities.BaseActivity;
import eu.toldi.infinityforlemmy.activities.ViewUserDetailActivity;
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
import me.zhanghai.android.fastscroll.PopupTextProvider;
import pl.droidsonroids.gif.GifImageView;
public class BasicUserRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements PopupTextProvider {
private static final int VIEW_TYPE_FAVORITE_USER_DIVIDER = 0;
private static final int VIEW_TYPE_FAVORITE_USER = 1;
private static final int VIEW_TYPE_USER_DIVIDER = 2;
private static final int VIEW_TYPE_USER = 3;
private List<BasicUserInfo> basicUserInfo;
private BaseActivity mActivity;
private RequestManager glide;
private int mPrimaryTextColor;
private int mSecondaryTextColor;
public BasicUserRecyclerViewAdapter(BaseActivity activity,
CustomThemeWrapper customThemeWrapper) {
mActivity = activity;
glide = Glide.with(activity);
mPrimaryTextColor = customThemeWrapper.getPrimaryTextColor();
mSecondaryTextColor = customThemeWrapper.getSecondaryTextColor();
}
@Override
public int getItemViewType(int position) {
return VIEW_TYPE_USER;
}
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
return new UserViewHolder(LayoutInflater.from(viewGroup.getContext())
.inflate(R.layout.item_subscribed_thing, viewGroup, false));
}
@Override
public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder viewHolder, int i) {
if (viewHolder instanceof UserViewHolder) {
if (!basicUserInfo.get(viewHolder.getBindingAdapterPosition()).getAvatar().equals("")) {
glide.load(basicUserInfo.get(viewHolder.getBindingAdapterPosition()).getAvatar())
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
.error(glide.load(R.drawable.subreddit_default_icon)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
.into(((UserViewHolder) viewHolder).iconGifImageView);
} else {
glide.load(R.drawable.subreddit_default_icon)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
.into(((UserViewHolder) viewHolder).iconGifImageView);
}
((UserViewHolder) viewHolder).userNameTextView.setText(basicUserInfo.get(viewHolder.getBindingAdapterPosition()).getDisplayName());
}
}
@Override
public int getItemCount() {
if (basicUserInfo != null && basicUserInfo.size() > 0) {
return basicUserInfo.size();
}
return 0;
}
@Override
public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) {
if (holder instanceof UserViewHolder) {
glide.clear(((UserViewHolder) holder).iconGifImageView);
}
}
public void setUsers(List<BasicUserInfo> subscribedUsers) {
basicUserInfo = subscribedUsers;
notifyDataSetChanged();
}
@NonNull
@Override
public String getPopupText(int position) {
return basicUserInfo.get(position).getQualifiedName().substring(0, 1).toUpperCase();
}
protected int getUserNameTextColor() {
return mPrimaryTextColor;
}
protected class UserViewHolder 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 userNameTextView;
protected UserViewHolder(View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
if (mActivity.typeface != null) {
userNameTextView.setTypeface(mActivity.typeface);
}
userNameTextView.setTextColor(getUserNameTextColor());
itemView.setOnClickListener(view -> {
int position = getBindingAdapterPosition();
if (position >= 0 && basicUserInfo.size() > position) {
Intent intent = new Intent(mActivity, ViewUserDetailActivity.class);
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, basicUserInfo.get(position).getDisplayName());
intent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, basicUserInfo.get(position).getQualifiedName());
mActivity.startActivity(intent);
}
});
}
}
}

View File

@@ -48,7 +48,7 @@ public class ParseUserData {
boolean isBot = personJson.getBoolean("bot_account");
boolean isBanned = personJson.getBoolean("banned");
boolean isLocal = personJson.getBoolean("local");
boolean isAdmin = personJson.getBoolean("admin");
boolean isAdmin = personJson.optBoolean("admin");
boolean isDeleted = personJson.getBoolean("deleted");
String description = "";

View File

@@ -5,7 +5,9 @@ import android.util.Base64;
import java.util.HashMap;
import java.util.Map;
import okhttp3.Interceptor;
import okhttp3.MediaType;
import okhttp3.Request;
import okhttp3.RequestBody;
/**
@@ -142,12 +144,6 @@ public class APIUtils {
return params;
}
public static Map<String, String> getRedgifsOAuthHeader(String redgifsAccessToken) {
Map<String, String> params = new HashMap<>();
params.put(APIUtils.AUTHORIZATION_KEY, APIUtils.AUTHORIZATION_BASE + redgifsAccessToken);
return params;
}
public static RequestBody getRequestBody(String s) {
return RequestBody.create(s, MediaType.parse("text/plain"));
}
@@ -159,4 +155,13 @@ public class APIUtils {
params.put(APIUtils.USER_AGENT_KEY, APIUtils.USER_AGENT);
return params;
}
public static Interceptor getOAuthInterceptor(String accessToken) {
return chain -> {
Request newRequest = chain.request().newBuilder()
.addHeader("Authorization", "Bearer " + accessToken)
.build();
return chain.proceed(newRequest);
};
}
}

View File

@@ -126,6 +126,7 @@ public class JSONUtils {
public static final String Y_KEY = "y";
public static final String DEST_KEY = "dest";
public static final String GIF_KEY = "gif";
public static final String GIFS_KEY = "gifs";
public static final String MAX_EMOJIS_KEY = "max_emojis";
public static final String RICHTEXT_KEY = "richtext";
public static final String SUGGESTED_COMMENT_SORT_KEY = "suggested_comment_sort";

View File

@@ -56,6 +56,9 @@ public class SharedPreferencesUtils {
public static final String POST_DISPLAY_NAME_INSTEAD_OF_USERNAME = "post_display_name_instead_of_user_name";
public static final String COMMENT_DISPLAY_NAME_INSTEAD_OF_USERNAME = "comment_display_name_instead_of_user_name";
public static final String COMMENT_HIDE_USER_INSTANCE = "comment_hide_user_instance";
public static final String POST_DETAIL_DISPLAY_NAME_INSTEAD_OF_USERNAME = "post_detail_display_name_instead_of_user_name";
public static final String SORT_TYPE_SHARED_PREFERENCES_FILE = "eu.toldi.infinityforlemmy.sort_type";
@@ -356,6 +359,8 @@ public class SharedPreferencesUtils {
public static final String CURRENT_ACCOUNT_SHARED_PREFERENCES_FILE = "eu.toldi.infinityforlemmy.current_account";
public static final String ACCOUNT_NAME = "account_name";
public static final String ACCESS_TOKEN = "access_token";
public static final String BEARER_TOKEN_AUTH = "bearer_token_auth";
public static final String ACCOUNT_IMAGE_URL = "account_image_url";
public static final String REDGIFS_ACCESS_TOKEN = "redgifs_access_token";
@@ -411,4 +416,8 @@ public class SharedPreferencesUtils {
public static final String ACCOUNT_INSTANCE = "account_instance";
public static final String ACCOUNT_QUALIFIED_NAME = "account_qualified_name";
public static final String CAN_DOWNVOTE = "can_downvote";
public static final String SHOW_STATISTICS = "show_statistics";
public static final String SHOW_POST_AND_COMMENT_SCORE = "show_score";
public static final String SHARE_LINK_ON_LOCAL_INSTANCE = "share_link_on_local_instance";
}

View File

@@ -0,0 +1,11 @@
package eu.toldi.infinityforlemmy.post.enrich
import eu.toldi.infinityforlemmy.post.Post
class CompositePostEnricher(private val enrichers: Set<PostEnricher>) : PostEnricher {
override fun enrich(posts: Collection<Post>) {
for (enricher in enrichers) {
enricher.enrich(posts)
}
}
}

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