mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2025-11-02 01:39:05 +01:00
Compare commits
265 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6ff46f928a | ||
|
|
81e1c73c65 | ||
|
|
554dfff4ad | ||
|
|
741ec08386 | ||
|
|
f8a21fa3ba | ||
|
|
fd6bc82214 | ||
|
|
0ae8826732 | ||
|
|
5311edc404 | ||
|
|
d8dc8c39b2 | ||
|
|
c43ced8b00 | ||
|
|
908f294130 | ||
|
|
95408f8125 | ||
|
|
6d5ba059f8 | ||
|
|
ecdd9da9c8 | ||
|
|
1c17e6b7d2 | ||
|
|
9f60eca225 | ||
|
|
9deba8b10e | ||
|
|
05948d74f4 | ||
|
|
1007be50f8 | ||
|
|
28617cf9a8 | ||
|
|
5d2d43eebc | ||
|
|
f2b2525823 | ||
|
|
29547f4750 | ||
|
|
af63bba54a | ||
|
|
caf4f177d2 | ||
|
|
1e67b34440 | ||
|
|
67afcd7e88 | ||
|
|
9406f29562 | ||
|
|
b626c5fb73 | ||
|
|
0393ff6e77 | ||
|
|
30ecc17d55 | ||
|
|
7c5f184cc8 | ||
|
|
d5fff14cb0 | ||
|
|
5cdda037b2 | ||
|
|
0942f7c5ec | ||
|
|
efe90d0030 | ||
|
|
2d45f337d7 | ||
|
|
70cf6f3340 | ||
|
|
6542859892 | ||
|
|
143bc5e1b6 | ||
|
|
6e51ea6ee7 | ||
|
|
d7c4e3d5bc | ||
|
|
1ed86c138e | ||
|
|
2d83545865 | ||
|
|
3594f10fdd | ||
|
|
a903ac9dbd | ||
|
|
ed90a278a6 | ||
|
|
6221b33a3d | ||
|
|
2561ba8bd0 | ||
|
|
9859608764 | ||
|
|
b40077f83f | ||
|
|
76dc0ff083 | ||
|
|
6a2d59ed48 | ||
|
|
a09d6f85f8 | ||
|
|
2f3d39ed31 | ||
|
|
83e0fc039f | ||
|
|
d4ca682882 | ||
|
|
e2b75a3928 | ||
|
|
d9f9fb51db | ||
|
|
a8b2091e69 | ||
|
|
f14ebe9a0d | ||
|
|
4010e02438 | ||
|
|
5cbe6152c9 | ||
|
|
c7233e05c4 | ||
|
|
9d4657dea8 | ||
|
|
7c3ddfda5c | ||
|
|
77f37a5698 | ||
|
|
c45528a7f3 | ||
|
|
0dcc441bae | ||
|
|
8c05b6e1ea | ||
|
|
351033600f | ||
|
|
fb4289a812 | ||
|
|
37eb16f6c4 | ||
|
|
77c5bcb038 | ||
|
|
3c65bfcf1b | ||
|
|
ce7c284c6b | ||
|
|
267570d7b4 | ||
|
|
c9e6a0bc2e | ||
|
|
1f8348bbfa | ||
|
|
d4fe5235e2 | ||
|
|
76fee50cd5 | ||
|
|
e2956e3f1c | ||
|
|
21b0b36359 | ||
|
|
a55820a11d | ||
|
|
3322b5b4e8 | ||
|
|
0384914c16 | ||
|
|
0550219d58 | ||
|
|
deaa4e596d | ||
|
|
bf1036c919 | ||
|
|
116deebf87 | ||
|
|
0f3197d7e4 | ||
|
|
db9edc47c0 | ||
|
|
2392d9fa29 | ||
|
|
3272f609a8 | ||
|
|
d5092f50f6 | ||
|
|
d216fc4640 | ||
|
|
f61c12a30b | ||
|
|
bbbd4ddcb0 | ||
|
|
495a1d025f | ||
|
|
a245ebad09 | ||
|
|
0e31e40ef1 | ||
|
|
bae68d4a99 | ||
|
|
3e17e3364d | ||
|
|
9626500586 | ||
|
|
92fcb811c3 | ||
|
|
81e2fdcf91 | ||
|
|
171338f492 | ||
|
|
cc21588a66 | ||
|
|
b5356ee5eb | ||
|
|
ec9be3f6af | ||
|
|
ac5e67c032 | ||
|
|
fd24f04254 | ||
|
|
0b74574fa6 | ||
|
|
2704ff0ecf | ||
|
|
f4c33e08e2 | ||
|
|
5dddf2e39d | ||
|
|
487afce565 | ||
|
|
f31a13568c | ||
|
|
04341991bf | ||
|
|
a7c2a67d0c | ||
|
|
4ec6666f93 | ||
|
|
fcc0181075 | ||
|
|
1c4e5f3659 | ||
|
|
a120fcf068 | ||
|
|
0328f34df2 | ||
|
|
7849115000 | ||
|
|
41e14aab9d | ||
|
|
074b5d012c | ||
|
|
8a3ee7931d | ||
|
|
dce5a8d89c | ||
|
|
a82f2b68e3 | ||
|
|
a36ddccefd | ||
|
|
bbe696a37b | ||
|
|
13ec5f84c4 | ||
|
|
587ebbb309 | ||
|
|
485611970f | ||
|
|
c0738947b7 | ||
|
|
f1145d826e | ||
|
|
aa4f587443 | ||
|
|
e559e4acd2 | ||
|
|
db1e000325 | ||
|
|
4f57c17f73 | ||
|
|
21af736fa4 | ||
|
|
72ba80ff87 | ||
|
|
450e96fdbe | ||
|
|
fcc60e1b16 | ||
|
|
e888282d24 | ||
|
|
237d33f2e4 | ||
|
|
babb0d28bb | ||
|
|
53eb7cbe91 | ||
|
|
fed84f9942 | ||
|
|
d4896a1f87 | ||
|
|
21879bec7d | ||
|
|
bb143cfecb | ||
|
|
6475b4808a | ||
|
|
57a58cc518 | ||
|
|
8a5b6aa972 | ||
|
|
6813770d57 | ||
|
|
118b6cd430 | ||
|
|
b984e35284 | ||
|
|
f2a2a3029d | ||
|
|
b4ab1ba414 | ||
|
|
d244e0ed42 | ||
|
|
81c190a9c0 | ||
|
|
e2f36c334b | ||
|
|
891215fcb3 | ||
|
|
04e022cbbc | ||
|
|
1f4f3a475d | ||
|
|
3e6d435116 | ||
|
|
9c6f946602 | ||
|
|
053c9e73b0 | ||
|
|
acd1aef851 | ||
|
|
a3a753a9dd | ||
|
|
0ea491bcfc | ||
|
|
946d35b5d9 | ||
|
|
5098cb698d | ||
|
|
47a06c372e | ||
|
|
7877001533 | ||
|
|
23d41846d0 | ||
|
|
dc4dc17b6c | ||
|
|
6c8892938a | ||
|
|
2f2d86bc3f | ||
|
|
ecd3d008de | ||
|
|
f5172a17db | ||
|
|
662a5bd597 | ||
|
|
6621748de5 | ||
|
|
37fa76b79a | ||
|
|
c7acb50522 | ||
|
|
64304ad637 | ||
|
|
635ca332da | ||
|
|
e2a15ab925 | ||
|
|
016801419f | ||
|
|
48d79bc353 | ||
|
|
b8094fded8 | ||
|
|
8c82ba0e91 | ||
|
|
3ff9c06843 | ||
|
|
45ae8342ee | ||
|
|
b8c3dae807 | ||
|
|
3afd2601f0 | ||
|
|
82414bba55 | ||
|
|
7a39b2341b | ||
|
|
37ab47bc34 | ||
|
|
21b111cc2d | ||
|
|
b3c2f6213d | ||
|
|
c3de94012a | ||
|
|
804eb64b5b | ||
|
|
6a4aa8075d | ||
|
|
692aca4eca | ||
|
|
dd00802561 | ||
|
|
a3e0fea200 | ||
|
|
304125ea0d | ||
|
|
a465ebb5b4 | ||
|
|
b39d00eba6 | ||
|
|
1ebdce309d | ||
|
|
d29b7585f7 | ||
|
|
276560678c | ||
|
|
10c23a65c5 | ||
|
|
4e4f4377e7 | ||
|
|
2e6c9db614 | ||
|
|
2375ba9d35 | ||
|
|
a11ccb7cf6 | ||
|
|
a54241294d | ||
|
|
46b509c1fb | ||
|
|
b13dd58c70 | ||
|
|
4312b250ce | ||
|
|
ff4c9180a0 | ||
|
|
be0bd40995 | ||
|
|
726d6d0faf | ||
|
|
14ce356c4d | ||
|
|
930a425af5 | ||
|
|
7168cecbcb | ||
|
|
7f067023e7 | ||
|
|
167aecb696 | ||
|
|
9872e6e806 | ||
|
|
05adc343a2 | ||
|
|
58e3dfa084 | ||
|
|
3068423c01 | ||
|
|
3c960f60d1 | ||
|
|
a153fc4afb | ||
|
|
4a19fbb745 | ||
|
|
bb8c10fc98 | ||
|
|
97af73f055 | ||
|
|
73d18082c4 | ||
|
|
4b78e80edd | ||
|
|
78ba4b0fda | ||
|
|
a1c5baac6b | ||
|
|
c4b811090d | ||
|
|
fbdccfb639 | ||
|
|
c1162fd618 | ||
|
|
4d7a148cfe | ||
|
|
c7b1602648 | ||
|
|
a82a454ad2 | ||
|
|
9533378003 | ||
|
|
dc1edcc78c | ||
|
|
6d8b040f6d | ||
|
|
60f07f7707 | ||
|
|
f6b7130d0c | ||
|
|
9fea056063 | ||
|
|
859e9ab5d6 | ||
|
|
4821718407 | ||
|
|
67a13f8ecb | ||
|
|
40e4782b32 | ||
|
|
2ab5ab3ce5 | ||
|
|
88fb054640 | ||
|
|
4ce8fd6a63 |
BIN
.assets/IzzyOnDroid.png
Normal file
BIN
.assets/IzzyOnDroid.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 20 KiB |
BIN
.assets/codeberg.png
Normal file
BIN
.assets/codeberg.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 17 KiB |
BIN
.assets/google-play-badge.png
Normal file
BIN
.assets/google-play-badge.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.8 KiB |
@@ -1,14 +1,15 @@
|
||||
pipeline:
|
||||
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,11 +18,13 @@ pipeline:
|
||||
settings:
|
||||
base_url: https://codeberg.org
|
||||
files:
|
||||
- LemmInfinity-signed.apk
|
||||
- Eternity-signed.apk
|
||||
api_key:
|
||||
from_secret: GITEA_ACCESS_TOKEN
|
||||
target: main
|
||||
prerelease: true
|
||||
note: "This is an alpha release. Expect many bugs and unfinished features!"
|
||||
when:
|
||||
event: [ tag ]
|
||||
event: [ tag ]
|
||||
when:
|
||||
event: [ push, tag, pull_request ]
|
||||
|
||||
77
.woodpecker/nightly.yaml
Normal file
77
.woodpecker/nightly.yaml
Normal file
@@ -0,0 +1,77 @@
|
||||
clone:
|
||||
git:
|
||||
image: woodpeckerci/plugin-git
|
||||
settings:
|
||||
partial: false
|
||||
|
||||
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
|
||||
commands:
|
||||
- ./scripts/apk-sign.sh eu.toldi.infinityforlemmy.nightly.apk app/build/outputs/apk/nightly/eu.toldi.infinityforlemmy.nightly.apk
|
||||
secrets: [ APK_KS_PASS, APK_KS, APK_KS_ALIAS ]
|
||||
pull-repo-config:
|
||||
image: codeberg.org/freeyourgadget/android-fdroid-tools:latest
|
||||
commands:
|
||||
- cd ..
|
||||
- pwd
|
||||
- mkdir repoconfig
|
||||
- cd repoconfig
|
||||
- pwd
|
||||
- git clone --depth 1 https://codeberg.org/Bazsalanszky/fdroid-repo-config
|
||||
- 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
|
||||
commands:
|
||||
- cd ..
|
||||
- pwd
|
||||
- mkdir pages
|
||||
- cd pages
|
||||
- pwd
|
||||
- git clone --depth 2 https://codeberg.org/Bazsalanszky/pages
|
||||
- cd pages
|
||||
- git config user.name "CODEBERG CI"
|
||||
- git config user.email "noreply@nodomain.nodomain"
|
||||
# reset and remove, later force push, to keep repo size small
|
||||
- git reset --soft HEAD~1
|
||||
- git status
|
||||
|
||||
update-fdroid-data:
|
||||
image: cs8898/android-fdroid-sdk:33.0.0
|
||||
commands:
|
||||
- pwd
|
||||
- cd ../repoconfig/fdroid-repo-config/
|
||||
- echo -n "$${FDROID_KS}" | base64 -d > keystore.p12
|
||||
- cat keystore.p12 | sha256sum
|
||||
- sed -i "s|KS_PASS|$${FDROID_KS_PASS}|g" config.yml
|
||||
- sed -i "s|KEY_PASS|$${FDROID_KEY_PASS}|g" config.yml
|
||||
- fdroid update
|
||||
- fdroid deploy
|
||||
- ls -laR repo
|
||||
secrets: [ FDROID_KS_PASS, FDROID_KEY_PASS, FDROID_KS ]
|
||||
push-pages-update-repo:
|
||||
image: codeberg.org/freeyourgadget/android-fdroid-tools:latest
|
||||
commands:
|
||||
- if [ -f .do_not_build ]; then return 0; fi
|
||||
- cd ../pages/pages/
|
||||
- git add -A
|
||||
- git status
|
||||
- git diff
|
||||
- ls -lsR fdroid/repo
|
||||
- git commit -m "autodeploy"
|
||||
- git remote remove origin
|
||||
- git remote add origin https://Bazsalanszky:"$${GITEA_ACCESS_TOKEN}"@codeberg.org/Bazsalanszky/pages.git
|
||||
# force push as we removed all data
|
||||
- git push -f origin main
|
||||
- cd ../../
|
||||
- pwd
|
||||
- ls -la
|
||||
secrets: [ GITEA_ACCESS_TOKEN ]
|
||||
when:
|
||||
event: cron
|
||||
111
README.md
111
README.md
@@ -1,57 +1,96 @@
|
||||
<h1 align="center">
|
||||
Infinity for Lemmy
|
||||
Eternity for Lemmy
|
||||
</h1>
|
||||
|
||||
<div align="center">
|
||||
|
||||
A Lemmy client for Android written in Java. It's a fork of the [Infinity for Reddit](https://github.com/Docile-Alligator/Infinity-For-Reddit) project, currenty in early development.
|
||||
|
||||
<img align="right" src="https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy/raw/branch/master/fastlane/metadata/android/en-US/images/icon.png" width=200>
|
||||
|
||||
</div>
|
||||
|
||||
<br>
|
||||
|
||||
|
||||
<div align="center">
|
||||
<img src="https://codeberg.org/Bazsalanszky/Eternity/raw/branch/master/fastlane/metadata/android/en-US/images/icon.png" width=256>
|
||||
|
||||
[](https://ci.codeberg.org/12474)
|
||||
[](https://ci.codeberg.org/repos/12474)
|
||||
[](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>
|
||||
|
||||
|
||||
|
||||
<br>
|
||||
|
||||
<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/Eternity/releases/">
|
||||
<img src="./.assets/codeberg.png" height="80">
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
## Action Items for Infinity for Lemmy
|
||||
## Features
|
||||
|
||||
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
|
||||
- [x] Functionality for post upvotes/downvotes
|
||||
- [x] Functionality to browse comments
|
||||
- [x] Capability for creating a new post
|
||||
- [x] Ability to create comments
|
||||
- [x] Edit/Delete posts and comments
|
||||
- [x] Basic inbox
|
||||
- [ ] Elimination of code/string references specific to Reddit
|
||||
- [ ] Incorporation of private messaging feature
|
||||
- [x] Feature for saving posts/comments
|
||||
- [x] Resolving links
|
||||
- [ ] Account editing function
|
||||
- [ ] Multi community view?
|
||||
### Browsing Lemmy
|
||||
|
||||
- Explore various feeds (Subscribed/Local/All) and communities
|
||||
- Subscribe or unsubscribe from specific communities, with the option to block
|
||||
- Discover communities federated with the current instance
|
||||
- Favorite a community for quick access
|
||||
- Manage your subscriptions and blocked communities
|
||||
|
||||
### Content Engagement
|
||||
|
||||
- Engage with content by voting, saving, sharing, and creating posts or comments
|
||||
- Enjoy endless scrolling through feeds and posts
|
||||
- Tailor the view settings for posts (card,compact, gallery)
|
||||
- Set default preferences for post and comment sorting
|
||||
- Stay updated with notifications for replies
|
||||
|
||||
### Account Management
|
||||
|
||||
- Sign in to multiple accounts or instances, and effortlessly switch between them
|
||||
- Use the inbox features to view replies, mentions, and private messages
|
||||
- Access your profile to view your posts, comments, and saved content
|
||||
|
||||
### Customization
|
||||
|
||||
- Choose between various theme options including Light, Dark, OLED
|
||||
- Support Material You theming
|
||||
- Explore user-created themes
|
||||
- Customize font settings
|
||||
- Optional bottom navigation bar
|
||||
- Discover a plethora of other customization features
|
||||
|
||||
<img
|
||||
src="https://codeberg.org/Bazsalanszky/Eternity/raw/branch/master/fastlane/metadata/android/en-US/images/phoneScreenshots/1.png"
|
||||
alt="Screenshot 1"
|
||||
height="200" >
|
||||
<img
|
||||
src="https://codeberg.org/Bazsalanszky/Eternity/raw/branch/master/fastlane/metadata/android/en-US/images/phoneScreenshots/2.png"
|
||||
alt="Screenshot 2"
|
||||
height="200" >
|
||||
<img
|
||||
src="https://codeberg.org/Bazsalanszky/Eternity/raw/branch/master/fastlane/metadata/android/en-US/images/phoneScreenshots/3.png"
|
||||
alt="Screenshot 3"
|
||||
height="200" >
|
||||
<img
|
||||
src="https://codeberg.org/Bazsalanszky/Eternity/raw/branch/master/fastlane/metadata/android/en-US/images/phoneScreenshots/4.png"
|
||||
alt="Screenshot 4"
|
||||
height="200" >
|
||||
<img
|
||||
src="https://codeberg.org/Bazsalanszky/Eternity/raw/branch/master/fastlane/metadata/android/en-US/images/phoneScreenshots/5.png"
|
||||
alt="Screenshot 5"
|
||||
height="200" >
|
||||
|
||||
|
||||
## Contributing
|
||||
@@ -69,16 +108,21 @@ Don't forget to give the project a star! Thanks again!
|
||||
4. Push to the Branch (`git push origin feature/AmazingFeature`)
|
||||
5. Open a Pull Request
|
||||
|
||||
Here are other ways you can help:
|
||||
### Translation
|
||||
|
||||
- [Report Bugs](https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy/issues)
|
||||
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/)!
|
||||
|
||||
[](https://translate.codeberg.org/engage/Eternity/)
|
||||
|
||||
### Reporting bugs
|
||||
|
||||
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,7 +130,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>
|
||||
|
||||
104
app/build.gradle
104
app/build.gradle
@@ -1,5 +1,18 @@
|
||||
plugins {
|
||||
id 'com.android.application'
|
||||
id 'org.jetbrains.kotlin.android'
|
||||
}
|
||||
def getCommitVersionCode = { ->
|
||||
try {
|
||||
def stdout = new ByteArrayOutputStream()
|
||||
exec {
|
||||
commandLine 'git', 'rev-list', 'HEAD', '--count'
|
||||
standardOutput = stdout
|
||||
}
|
||||
return Integer.valueOf(stdout.toString().trim())
|
||||
} catch (ignored) {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
android {
|
||||
@@ -8,8 +21,8 @@ android {
|
||||
applicationId "eu.toldi.infinityforlemmy"
|
||||
minSdk 21
|
||||
targetSdk 33
|
||||
versionCode 128
|
||||
versionName "0.0.8"
|
||||
versionCode 131
|
||||
versionName "0.1.2"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
javaCompileOptions {
|
||||
annotationProcessorOptions {
|
||||
@@ -18,10 +31,12 @@ android {
|
||||
}
|
||||
}
|
||||
buildTypes {
|
||||
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
|
||||
minifiedRelease {
|
||||
initWith buildTypes.release
|
||||
zipAlignEnabled true
|
||||
@@ -33,7 +48,33 @@ android {
|
||||
applicationIdSuffix '.debug'
|
||||
versionNameSuffix ' (DEBUG)'
|
||||
}
|
||||
|
||||
nightly {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
applicationIdSuffix '.nightly'
|
||||
versionNameSuffix ' (NIGHTLY)'
|
||||
}
|
||||
applicationVariants.all { variant ->
|
||||
variant.resValue "string", "applicationId", variant.applicationId
|
||||
|
||||
|
||||
if (variant.buildType.name == 'nightly') {
|
||||
variant.outputs.all {
|
||||
setVersionCodeOverride(getCommitVersionCode())
|
||||
|
||||
setVersionNameOverride(variant.versionName)
|
||||
outputFileName = "${applicationId}.apk"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
main.java.srcDirs += 'src/main/kotlin'
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_11
|
||||
targetCompatibility JavaVersion.VERSION_11
|
||||
@@ -57,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 {
|
||||
@@ -67,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"
|
||||
@@ -112,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"
|
||||
@@ -153,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'
|
||||
@@ -201,3 +269,35 @@ dependencies {
|
||||
// debugImplementation because LeakCanary should only run in debug builds.
|
||||
//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, "")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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>
|
||||
@@ -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"
|
||||
@@ -402,6 +407,11 @@
|
||||
android:label="@string/subscriptions"
|
||||
android:parentActivityName=".activities.MainActivity"
|
||||
android:theme="@style/AppTheme.Slidable" />
|
||||
<activity
|
||||
android:name=".activities.BlockedThingListingActivity"
|
||||
android:label="@string/blocks"
|
||||
android:parentActivityName=".activities.MainActivity"
|
||||
android:theme="@style/AppTheme.Slidable" />
|
||||
<activity
|
||||
android:name=".activities.SubredditSelectionActivity"
|
||||
android:label="@string/community_selection_activity_label"
|
||||
@@ -431,11 +441,36 @@
|
||||
android:theme="@style/AppTheme.Launcher"
|
||||
android:windowSoftInputMode="adjustPan">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity-alias
|
||||
android:name=".DefaultIcon"
|
||||
android:targetActivity=".activities.MainActivity"
|
||||
android:label="@string/application_name"
|
||||
android:enabled="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity-alias>
|
||||
|
||||
<activity-alias
|
||||
android:name=".OriginalIcon"
|
||||
android:targetActivity=".activities.MainActivity"
|
||||
android:label="@string/application_name"
|
||||
android:enabled="false"
|
||||
android:icon="@mipmap/original_ic_launcher"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity-alias>
|
||||
|
||||
<activity
|
||||
android:name=".activities.LoginActivity"
|
||||
android:configChanges="orientation|screenLayout|screenSize|layoutDirection"
|
||||
@@ -464,7 +499,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"
|
||||
|
||||
@@ -2,12 +2,15 @@ package eu.toldi.infinityforlemmy;
|
||||
|
||||
import android.app.Application;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import dagger.BindsInstance;
|
||||
import dagger.Component;
|
||||
import eu.toldi.infinityforlemmy.activities.AccountPostsActivity;
|
||||
import eu.toldi.infinityforlemmy.activities.AccountSavedThingActivity;
|
||||
import eu.toldi.infinityforlemmy.activities.BlockedThingListingActivity;
|
||||
import eu.toldi.infinityforlemmy.activities.CommentActivity;
|
||||
import eu.toldi.infinityforlemmy.activities.CreateMultiRedditActivity;
|
||||
import eu.toldi.infinityforlemmy.activities.CustomThemeListingActivity;
|
||||
@@ -24,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;
|
||||
@@ -65,7 +69,10 @@ import eu.toldi.infinityforlemmy.activities.ViewVideoActivity;
|
||||
import eu.toldi.infinityforlemmy.activities.WebViewActivity;
|
||||
import eu.toldi.infinityforlemmy.activities.WikiActivity;
|
||||
import eu.toldi.infinityforlemmy.bottomsheetfragments.AccountChooserBottomSheetFragment;
|
||||
import eu.toldi.infinityforlemmy.bottomsheetfragments.CommentMoreBottomSheetFragment;
|
||||
import eu.toldi.infinityforlemmy.bottomsheetfragments.FlairBottomSheetFragment;
|
||||
import eu.toldi.infinityforlemmy.fragments.BlockedCommunitiesListingFragment;
|
||||
import eu.toldi.infinityforlemmy.fragments.BlockedUsersListingFragment;
|
||||
import eu.toldi.infinityforlemmy.fragments.CommentsListingFragment;
|
||||
import eu.toldi.infinityforlemmy.fragments.FollowedUsersListingFragment;
|
||||
import eu.toldi.infinityforlemmy.fragments.HistoryPostFragment;
|
||||
@@ -73,6 +80,7 @@ import eu.toldi.infinityforlemmy.fragments.InboxFragment;
|
||||
import eu.toldi.infinityforlemmy.fragments.MorePostsInfoFragment;
|
||||
import eu.toldi.infinityforlemmy.fragments.MultiRedditListingFragment;
|
||||
import eu.toldi.infinityforlemmy.fragments.PostFragment;
|
||||
import eu.toldi.infinityforlemmy.fragments.PrivateMessageFragment;
|
||||
import eu.toldi.infinityforlemmy.fragments.SidebarFragment;
|
||||
import eu.toldi.infinityforlemmy.fragments.SubredditListingFragment;
|
||||
import eu.toldi.infinityforlemmy.fragments.SubscribedSubredditsListingFragment;
|
||||
@@ -105,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);
|
||||
|
||||
@@ -307,6 +315,17 @@ public interface AppComponent {
|
||||
|
||||
void inject(MorePostsInfoFragment morePostsInfoFragment);
|
||||
|
||||
void inject(BlockedThingListingActivity blockedThingListingActivity);
|
||||
|
||||
void inject(BlockedCommunitiesListingFragment blockedCommunitiesListingFragment);
|
||||
|
||||
void inject(BlockedUsersListingFragment blockedUsersListingFragment);
|
||||
|
||||
void inject(CommentMoreBottomSheetFragment commentMoreBottomSheetFragment);
|
||||
|
||||
void inject(PrivateMessageFragment privateMessageFragment);
|
||||
|
||||
void inject(@NotNull InstanceInfoActivity instanceInfoActivity);
|
||||
|
||||
@Component.Factory
|
||||
interface Factory {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package eu.toldi.infinityforlemmy;
|
||||
|
||||
import android.os.AsyncTask;
|
||||
import android.text.Html;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
@@ -9,9 +8,6 @@ import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import eu.toldi.infinityforlemmy.apis.LemmyAPI;
|
||||
import eu.toldi.infinityforlemmy.apis.RedditAPI;
|
||||
import eu.toldi.infinityforlemmy.utils.APIUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.JSONUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.LemmyUtils;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
@@ -83,7 +79,7 @@ public class FetchMyInfo {
|
||||
if (!person.isNull("banner")) {
|
||||
bannerImageUrl = person.getString("banner");
|
||||
}
|
||||
display_name = person.getString("name");
|
||||
display_name = (person.has("display_name")) ? person.getString("display_name") : person.getString("name");
|
||||
redditDataRoomDatabase.accountDao().updateAccountInfo(name, profileImageUrl, bannerImageUrl);
|
||||
} catch (JSONException e) {
|
||||
parseFailed = true;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -9,16 +9,16 @@ 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.network.SortTypeConverterFactory;
|
||||
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;
|
||||
import okhttp3.OkHttpClient;
|
||||
import retrofit2.Retrofit;
|
||||
import retrofit2.adapter.guava.GuavaCallAdapterFactory;
|
||||
import retrofit2.converter.gson.GsonConverterFactory;
|
||||
import retrofit2.converter.scalars.ScalarsConverterFactory;
|
||||
|
||||
@Module(includes = AppModule.class)
|
||||
abstract class NetworkModule {
|
||||
@@ -35,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")
|
||||
@@ -166,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
|
||||
@@ -216,4 +237,22 @@ abstract class NetworkModule {
|
||||
static StreamableAPI provideStreamableApi(@Named("streamable") Retrofit streamableRetrofit) {
|
||||
return streamableRetrofit.create(StreamableAPI.class);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
static LemmyPostAPI providePostAPI(@Named("no_oauth") RetrofitHolder retrofitHolder) {
|
||||
return new LemmyPostAPI(retrofitHolder);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
static LemmyCommentAPI provideCommentAPI(@Named("no_oauth") RetrofitHolder retrofitHolder) {
|
||||
return new LemmyCommentAPI(retrofitHolder);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
static LemmyPrivateMessageAPI provideLemmyPrivateMessageAPI(@Named("base") RetrofitHolder retrofit) {
|
||||
return new LemmyPrivateMessageAPI(retrofit);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,9 +110,9 @@ class ParseSubscribedThing {
|
||||
boolean postingRestrictedToMods = community.getBoolean("posting_restricted_to_mods");
|
||||
int instanceId = community.getInt("instance_id");
|
||||
int subscribers = data.getJSONObject("counts").getInt("subscribers");
|
||||
|
||||
newSubscribedSubredditData.add(new SubscribedSubredditData(id, title, LemmyUtils.actorID2FullName(actorId), iconUrl, accountName));
|
||||
newSubredditData.add(new SubredditData(id,name,title,description,removed,published,updated,deleted,nsfw,actorId,local,iconUrl,bannerImageUrl,hidden,postingRestrictedToMods,instanceId,subscribers));
|
||||
boolean isBlocked = data.getBoolean("blocked");
|
||||
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));
|
||||
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,10 @@ import androidx.sqlite.db.SupportSQLiteDatabase;
|
||||
|
||||
import eu.toldi.infinityforlemmy.account.Account;
|
||||
import eu.toldi.infinityforlemmy.account.AccountDao;
|
||||
import eu.toldi.infinityforlemmy.blockedcommunity.BlockedCommunityDao;
|
||||
import eu.toldi.infinityforlemmy.blockedcommunity.BlockedCommunityData;
|
||||
import eu.toldi.infinityforlemmy.blockeduser.BlockedUserDao;
|
||||
import eu.toldi.infinityforlemmy.blockeduser.BlockedUserData;
|
||||
import eu.toldi.infinityforlemmy.customtheme.CustomTheme;
|
||||
import eu.toldi.infinityforlemmy.customtheme.CustomThemeDao;
|
||||
import eu.toldi.infinityforlemmy.multireddit.AnonymousMultiredditSubreddit;
|
||||
@@ -38,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}, version = 24)
|
||||
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) {
|
||||
@@ -49,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_21_22, MIGRATION_22_23, MIGRATION_23_24, MIGRATION_24_25, MIGRATION_25_26, MIGRATION_26_27)
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -59,6 +63,10 @@ public abstract class RedditDataRoomDatabase extends RoomDatabase {
|
||||
|
||||
public abstract SubscribedSubredditDao subscribedSubredditDao();
|
||||
|
||||
public abstract BlockedUserDao blockedUserDao();
|
||||
|
||||
public abstract BlockedCommunityDao blockedCommunityDao();
|
||||
|
||||
public abstract UserDao userDao();
|
||||
|
||||
public abstract SubscribedUserDao subscribedUserDao();
|
||||
@@ -390,4 +398,30 @@ public abstract class RedditDataRoomDatabase extends RoomDatabase {
|
||||
database.execSQL("ALTER TABLE accounts ADD COLUMN can_downvote INTEGER DEFAULT 1 NOT NULL");
|
||||
}
|
||||
};
|
||||
|
||||
private static final Migration MIGRATION_24_25 = new Migration(24, 25) {
|
||||
@Override
|
||||
public void migrate(@NonNull SupportSQLiteDatabase database) {
|
||||
database.execSQL("ALTER TABLE subreddits ADD COLUMN blocked INTEGER DEFAULT 1 NOT NULL");
|
||||
}
|
||||
};
|
||||
|
||||
private static final Migration MIGRATION_25_26 = new Migration(25, 26) {
|
||||
@Override
|
||||
public void migrate(@NonNull SupportSQLiteDatabase database) {
|
||||
database.execSQL("CREATE TABLE blocked_users" +
|
||||
"(name TEXT, id INTEGER NOT NULL, avatar TEXT, qualified_name TEXT, account_name TEXT NOT NULL, PRIMARY KEY( id, account_name))");
|
||||
database.execSQL("CREATE TABLE blocked_communities" +
|
||||
"(name TEXT, icon TEXT, id INTEGER NOT NULL, qualified_name TEXT, account_name TEXT NOT NULL, PRIMARY KEY( id, account_name))");
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
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");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -24,11 +33,16 @@ public class RetrofitHolder {
|
||||
}
|
||||
|
||||
public String getBaseURL() {
|
||||
return baseURL;
|
||||
String result = baseURL;
|
||||
if (baseURL.endsWith("/")) {
|
||||
result = baseURL.substring(0, baseURL.length() - 1);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public RetrofitHolder(OkHttpClient okHttpClient) {
|
||||
this.okHttpClient = okHttpClient;
|
||||
this.okHttpClientBase = okHttpClient;
|
||||
this.retrofit = createRetrofit(okHttpClient, APIUtils.API_BASE_URI);
|
||||
}
|
||||
|
||||
@@ -42,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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ public class SortType {
|
||||
TOP_TWELVE_HOURS("TopTwelveHour", "Top"),
|
||||
TOP_DAY("TopDay", "Top"),
|
||||
TOP_WEEK("TopWeek", "Top"),
|
||||
TOP_MONTH("month", "Top"),
|
||||
TOP_MONTH("TopMonth", "Top"),
|
||||
TOP_THREE_MONTHS("TopThreeMonths", "Top"),
|
||||
TOP_SIX_MONTHS("TopSixMonths", "Top"),
|
||||
TOP_NINE_MONTHS("TopNineMonths", "Top"),
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
package eu.toldi.infinityforlemmy.account;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import eu.toldi.infinityforlemmy.apis.LemmyAPI;
|
||||
import eu.toldi.infinityforlemmy.blockedcommunity.BlockedCommunityData;
|
||||
import eu.toldi.infinityforlemmy.blockeduser.BlockedUserData;
|
||||
import eu.toldi.infinityforlemmy.subreddit.ParseSubredditData;
|
||||
import eu.toldi.infinityforlemmy.subreddit.SubredditData;
|
||||
import eu.toldi.infinityforlemmy.utils.LemmyUtils;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Retrofit;
|
||||
|
||||
public class FetchBlockedThings {
|
||||
|
||||
public static void fetchBlockedThings(Retrofit mRetrofit, String accessToken, String accountName, FetchBlockedThingsListener fetchBlockedThingsListener) {
|
||||
LemmyAPI lemmyAPI = mRetrofit.create(LemmyAPI.class);
|
||||
|
||||
Call<String> call = lemmyAPI.getSiteInfo(accessToken);
|
||||
call.enqueue(new Callback<String>() {
|
||||
@Override
|
||||
public void onResponse(Call<String> call, retrofit2.Response<String> response) {
|
||||
if (response.isSuccessful()) {
|
||||
String siteInfo = response.body();
|
||||
if (siteInfo != null) {
|
||||
List<BlockedUserData> blockedUsers = new ArrayList<>();
|
||||
List<BlockedCommunityData> blockedCommunities = new ArrayList<>();
|
||||
try {
|
||||
JSONObject siteInfoJson = new JSONObject(siteInfo).getJSONObject("my_user");
|
||||
JSONArray blockedUsersJson = (siteInfoJson.has("person_blocks")) ? siteInfoJson.getJSONArray("person_blocks") : null;
|
||||
JSONArray blockedCommunitiesJson = (siteInfoJson.has("community_blocks")) ? siteInfoJson.getJSONArray("community_blocks") : null;
|
||||
if (blockedUsersJson != null) {
|
||||
for (int i = 0; i < blockedUsersJson.length(); i++) {
|
||||
JSONObject blockedUserJson = blockedUsersJson.getJSONObject(i).getJSONObject("target");
|
||||
int id = blockedUserJson.getInt("id");
|
||||
String name = blockedUserJson.getString("name");
|
||||
String avatar = "";
|
||||
if (blockedUserJson.has("avatar"))
|
||||
avatar = blockedUserJson.getString("avatar");
|
||||
|
||||
String qualifiedName = LemmyUtils.actorID2FullName(blockedUserJson.getString("actor_id"));
|
||||
BlockedUserData blockedUserData = new BlockedUserData(id, name, avatar, qualifiedName, accountName);
|
||||
|
||||
blockedUsers.add(blockedUserData);
|
||||
}
|
||||
}
|
||||
if (blockedCommunitiesJson != null) {
|
||||
for (int i = 0; i < blockedCommunitiesJson.length(); i++) {
|
||||
JSONObject blockedCommunityJson = blockedCommunitiesJson.getJSONObject(i);
|
||||
SubredditData blockedCommunityData = ParseSubredditData.parseSubredditData(blockedCommunityJson, true);
|
||||
blockedCommunities.add(new BlockedCommunityData(blockedCommunityData, accountName));
|
||||
}
|
||||
}
|
||||
fetchBlockedThingsListener.onFetchBlockedThingsSuccess(blockedUsers, blockedCommunities);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
fetchBlockedThingsListener.onFetchBlockedThingsFailure();
|
||||
}
|
||||
} else {
|
||||
fetchBlockedThingsListener.onFetchBlockedThingsFailure();
|
||||
}
|
||||
} else {
|
||||
fetchBlockedThingsListener.onFetchBlockedThingsFailure();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<String> call, Throwable t) {
|
||||
fetchBlockedThingsListener.onFetchBlockedThingsFailure();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public interface FetchBlockedThingsListener {
|
||||
void onFetchBlockedThingsSuccess(List<BlockedUserData> blockedUsers, List<BlockedCommunityData> blockedCommunities);
|
||||
|
||||
void onFetchBlockedThingsFailure();
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -0,0 +1,462 @@
|
||||
package eu.toldi.infinityforlemmy.activities;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.EditText;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
import androidx.core.view.inputmethod.EditorInfoCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentPagerAdapter;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
import com.google.android.material.appbar.AppBarLayout;
|
||||
import com.google.android.material.appbar.CollapsingToolbarLayout;
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import eu.toldi.infinityforlemmy.ActivityToolbarInterface;
|
||||
import eu.toldi.infinityforlemmy.FragmentCommunicator;
|
||||
import eu.toldi.infinityforlemmy.Infinity;
|
||||
import eu.toldi.infinityforlemmy.R;
|
||||
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
|
||||
import eu.toldi.infinityforlemmy.RetrofitHolder;
|
||||
import eu.toldi.infinityforlemmy.account.FetchBlockedThings;
|
||||
import eu.toldi.infinityforlemmy.asynctasks.InsertBlockedThings;
|
||||
import eu.toldi.infinityforlemmy.blockedcommunity.BlockedCommunityData;
|
||||
import eu.toldi.infinityforlemmy.blockeduser.BlockedUserData;
|
||||
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||
import eu.toldi.infinityforlemmy.customviews.ViewPagerBugFixed;
|
||||
import eu.toldi.infinityforlemmy.customviews.slidr.Slidr;
|
||||
import eu.toldi.infinityforlemmy.events.GoBackToMainPageEvent;
|
||||
import eu.toldi.infinityforlemmy.events.SwitchAccountEvent;
|
||||
import eu.toldi.infinityforlemmy.fragments.BlockedCommunitiesListingFragment;
|
||||
import eu.toldi.infinityforlemmy.fragments.BlockedUsersListingFragment;
|
||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.Utils;
|
||||
import retrofit2.Retrofit;
|
||||
|
||||
|
||||
public class BlockedThingListingActivity extends BaseActivity implements ActivityToolbarInterface {
|
||||
|
||||
public static final String EXTRA_SHOW_MULTIREDDITS = "ESM";
|
||||
private static final String INSERT_SUBSCRIBED_SUBREDDIT_STATE = "ISSS";
|
||||
private static final String INSERT_MULTIREDDIT_STATE = "IMS";
|
||||
|
||||
@BindView(R.id.coordinator_layout_subscribed_thing_listing_activity)
|
||||
CoordinatorLayout coordinatorLayout;
|
||||
@BindView(R.id.appbar_layout_subscribed_thing_listing_activity)
|
||||
AppBarLayout appBarLayout;
|
||||
@BindView(R.id.collapsing_toolbar_layout_subscribed_thing_listing_activity)
|
||||
CollapsingToolbarLayout collapsingToolbarLayout;
|
||||
@BindView(R.id.toolbar_subscribed_thing_listing_activity)
|
||||
Toolbar toolbar;
|
||||
@BindView(R.id.search_edit_text_subscribed_thing_listing_activity)
|
||||
EditText searchEditText;
|
||||
@BindView(R.id.tab_layout_subscribed_thing_listing_activity)
|
||||
TabLayout tabLayout;
|
||||
@BindView(R.id.view_pager_subscribed_thing_listing_activity)
|
||||
ViewPagerBugFixed viewPager;
|
||||
@BindView(R.id.fab_subscribed_thing_listing_activity)
|
||||
FloatingActionButton fab;
|
||||
@Inject
|
||||
@Named("oauth")
|
||||
Retrofit mOauthRetrofit;
|
||||
|
||||
@Inject
|
||||
@Named("no_oauth")
|
||||
RetrofitHolder mRetrofit;
|
||||
@Inject
|
||||
RedditDataRoomDatabase mRedditDataRoomDatabase;
|
||||
@Inject
|
||||
@Named("default")
|
||||
SharedPreferences mSharedPreferences;
|
||||
@Inject
|
||||
@Named("current_account")
|
||||
SharedPreferences mCurrentAccountSharedPreferences;
|
||||
@Inject
|
||||
CustomThemeWrapper mCustomThemeWrapper;
|
||||
@Inject
|
||||
Executor mExecutor;
|
||||
private String mAccessToken;
|
||||
private String mAccountName;
|
||||
|
||||
private String mAccountQualifiedName;
|
||||
private boolean mInsertSuccess = false;
|
||||
private boolean mInsertMultiredditSuccess = false;
|
||||
private boolean showMultiReddits = false;
|
||||
private SectionsPagerAdapter sectionsPagerAdapter;
|
||||
private Menu mMenu;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
((Infinity) getApplication()).getAppComponent().inject(this);
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setContentView(R.layout.activity_subscribed_thing_listing);
|
||||
|
||||
ButterKnife.bind(this);
|
||||
|
||||
EventBus.getDefault().register(this);
|
||||
|
||||
applyCustomTheme();
|
||||
|
||||
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK, true)) {
|
||||
mSliderPanel = Slidr.attach(this);
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
Window window = getWindow();
|
||||
|
||||
if (isChangeStatusBarIconColor()) {
|
||||
addOnOffsetChangedListener(appBarLayout);
|
||||
}
|
||||
|
||||
if (isImmersiveInterface()) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
window.setDecorFitsSystemWindows(false);
|
||||
} else {
|
||||
window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
|
||||
}
|
||||
adjustToolbar(toolbar);
|
||||
|
||||
int navBarHeight = getNavBarHeight();
|
||||
if (navBarHeight > 0) {
|
||||
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) fab.getLayoutParams();
|
||||
params.bottomMargin += navBarHeight;
|
||||
fab.setLayoutParams(params);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setSupportActionBar(toolbar);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
setToolbarGoToTop(toolbar);
|
||||
|
||||
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
|
||||
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, "-");
|
||||
mAccountQualifiedName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_QUALIFIED_NAME, "-");
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
mInsertSuccess = savedInstanceState.getBoolean(INSERT_SUBSCRIBED_SUBREDDIT_STATE);
|
||||
mInsertMultiredditSuccess = savedInstanceState.getBoolean(INSERT_MULTIREDDIT_STATE);
|
||||
} else {
|
||||
showMultiReddits = getIntent().getBooleanExtra(EXTRA_SHOW_MULTIREDDITS, false);
|
||||
}
|
||||
|
||||
if (mAccessToken == null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
searchEditText.setImeOptions(searchEditText.getImeOptions() | EditorInfoCompat.IME_FLAG_NO_PERSONALIZED_LEARNING);
|
||||
}
|
||||
|
||||
searchEditText.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable editable) {
|
||||
sectionsPagerAdapter.changeSearchQuery(editable.toString());
|
||||
}
|
||||
});
|
||||
initializeViewPagerAndLoadSubscriptions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SharedPreferences getDefaultSharedPreferences() {
|
||||
return mSharedPreferences;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CustomThemeWrapper getCustomThemeWrapper() {
|
||||
return mCustomThemeWrapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void applyCustomTheme() {
|
||||
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
|
||||
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar);
|
||||
applyTabLayoutTheme(tabLayout);
|
||||
applyFABTheme(fab, mSharedPreferences.getBoolean(SharedPreferencesUtils.USE_CIRCULAR_FAB, false));
|
||||
searchEditText.setTextColor(mCustomThemeWrapper.getToolbarPrimaryTextAndIconColor());
|
||||
searchEditText.setHintTextColor(mCustomThemeWrapper.getToolbarSecondaryTextColor());
|
||||
}
|
||||
|
||||
private void initializeViewPagerAndLoadSubscriptions() {
|
||||
fab.setOnClickListener(view -> {
|
||||
Intent intent = new Intent(this, CreateMultiRedditActivity.class);
|
||||
startActivity(intent);
|
||||
});
|
||||
sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
|
||||
viewPager.setAdapter(sectionsPagerAdapter);
|
||||
viewPager.setOffscreenPageLimit(2);
|
||||
if (viewPager.getCurrentItem() != 2) {
|
||||
fab.hide();
|
||||
}
|
||||
viewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
|
||||
@Override
|
||||
public void onPageSelected(int position) {
|
||||
if (position == 0) {
|
||||
unlockSwipeRightToGoBack();
|
||||
fab.hide();
|
||||
} else {
|
||||
lockSwipeRightToGoBack();
|
||||
if (position != 2) {
|
||||
fab.hide();
|
||||
} else {
|
||||
fab.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
tabLayout.setupWithViewPager(viewPager);
|
||||
|
||||
if (showMultiReddits) {
|
||||
viewPager.setCurrentItem(2, false);
|
||||
}
|
||||
|
||||
loadBlocks(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.subscribed_thing_listing_activity, menu);
|
||||
mMenu = menu;
|
||||
applyMenuItemTheme(menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||
if (item.getItemId() == R.id.action_search_subscribed_thing_listing_activity) {
|
||||
item.setVisible(false);
|
||||
searchEditText.setVisibility(View.VISIBLE);
|
||||
searchEditText.requestFocus();
|
||||
if (searchEditText.requestFocus()) {
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
imm.showSoftInput(searchEditText, InputMethodManager.SHOW_IMPLICIT);
|
||||
}
|
||||
return true;
|
||||
} else if (item.getItemId() == android.R.id.home) {
|
||||
if (searchEditText.getVisibility() == View.VISIBLE) {
|
||||
Utils.hideKeyboard(this);
|
||||
searchEditText.setVisibility(View.GONE);
|
||||
searchEditText.setText("");
|
||||
mMenu.findItem(R.id.action_search_subscribed_thing_listing_activity).setVisible(true);
|
||||
sectionsPagerAdapter.changeSearchQuery("");
|
||||
return true;
|
||||
}
|
||||
finish();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (searchEditText.getVisibility() == View.VISIBLE) {
|
||||
Utils.hideKeyboard(this);
|
||||
searchEditText.setVisibility(View.GONE);
|
||||
searchEditText.setText("");
|
||||
mMenu.findItem(R.id.action_search_subscribed_thing_listing_activity).setVisible(true);
|
||||
sectionsPagerAdapter.changeSearchQuery("");
|
||||
} else {
|
||||
super.onBackPressed();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putBoolean(INSERT_SUBSCRIBED_SUBREDDIT_STATE, mInsertSuccess);
|
||||
outState.putBoolean(INSERT_MULTIREDDIT_STATE, mInsertMultiredditSuccess);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
EventBus.getDefault().unregister(this);
|
||||
}
|
||||
|
||||
public void loadBlocks(boolean forceLoad) {
|
||||
if (mAccessToken != null && !(!forceLoad && mInsertSuccess)) {
|
||||
FetchBlockedThings.fetchBlockedThings(mRetrofit.getRetrofit(), mAccessToken, mAccountQualifiedName, new FetchBlockedThings.FetchBlockedThingsListener() {
|
||||
@Override
|
||||
public void onFetchBlockedThingsSuccess(List<BlockedUserData> blockedUsers, List<BlockedCommunityData> blockedCommunities) {
|
||||
InsertBlockedThings.insertBlockedThings(mExecutor, new Handler(), mRedditDataRoomDatabase, mAccountQualifiedName,
|
||||
blockedCommunities, blockedUsers, () -> {
|
||||
mInsertSuccess = true;
|
||||
sectionsPagerAdapter.stopRefreshProgressbar();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFetchBlockedThingsFailure() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Subscribe
|
||||
public void onAccountSwitchEvent(SwitchAccountEvent event) {
|
||||
finish();
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void goBackToMainPageEvent(GoBackToMainPageEvent event) {
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLongPress() {
|
||||
if (sectionsPagerAdapter != null) {
|
||||
sectionsPagerAdapter.goBackToTop();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lockSwipeRightToGoBack() {
|
||||
if (mSliderPanel != null) {
|
||||
mSliderPanel.lock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unlockSwipeRightToGoBack() {
|
||||
if (mSliderPanel != null) {
|
||||
mSliderPanel.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
private class SectionsPagerAdapter extends FragmentPagerAdapter {
|
||||
|
||||
private BlockedCommunitiesListingFragment blockedCommunitiesListingFragment;
|
||||
private BlockedUsersListingFragment followedUsersListingFragment;
|
||||
|
||||
public SectionsPagerAdapter(FragmentManager fm) {
|
||||
super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Fragment getItem(int position) {
|
||||
switch (position) {
|
||||
default:
|
||||
case 0: {
|
||||
BlockedCommunitiesListingFragment fragment = new BlockedCommunitiesListingFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putBoolean(BlockedCommunitiesListingFragment.EXTRA_IS_SUBREDDIT_SELECTION, false);
|
||||
bundle.putString(BlockedCommunitiesListingFragment.EXTRA_ACCOUNT_NAME, mAccountName);
|
||||
bundle.putString(BlockedCommunitiesListingFragment.EXTRA_ACCOUNT_QUALIFIED_NAME, mAccountQualifiedName);
|
||||
bundle.putString(BlockedCommunitiesListingFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
||||
fragment.setArguments(bundle);
|
||||
return fragment;
|
||||
}
|
||||
case 1: {
|
||||
BlockedUsersListingFragment fragment = new BlockedUsersListingFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(BlockedUsersListingFragment.EXTRA_ACCOUNT_NAME, mAccountQualifiedName);
|
||||
bundle.putString(BlockedUsersListingFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
||||
fragment.setArguments(bundle);
|
||||
return fragment;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getPageTitle(int position) {
|
||||
switch (position) {
|
||||
case 0:
|
||||
return Utils.getTabTextWithCustomFont(typeface, getString(R.string.communities));
|
||||
case 1:
|
||||
return Utils.getTabTextWithCustomFont(typeface, getString(R.string.users));
|
||||
case 2:
|
||||
return Utils.getTabTextWithCustomFont(typeface, getString(R.string.multi_reddits));
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Object instantiateItem(@NonNull ViewGroup container, int position) {
|
||||
Fragment fragment = (Fragment) super.instantiateItem(container, position);
|
||||
if (position == 0) {
|
||||
blockedCommunitiesListingFragment = (BlockedCommunitiesListingFragment) fragment;
|
||||
} else if (position == 1) {
|
||||
followedUsersListingFragment = (BlockedUsersListingFragment) fragment;
|
||||
}
|
||||
|
||||
return fragment;
|
||||
}
|
||||
|
||||
void stopRefreshProgressbar() {
|
||||
if (blockedCommunitiesListingFragment != null) {
|
||||
((FragmentCommunicator) blockedCommunitiesListingFragment).stopRefreshProgressbar();
|
||||
}
|
||||
if (followedUsersListingFragment != null) {
|
||||
((FragmentCommunicator) followedUsersListingFragment).stopRefreshProgressbar();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void goBackToTop() {
|
||||
if (viewPager.getCurrentItem() == 0) {
|
||||
blockedCommunitiesListingFragment.goBackToTop();
|
||||
} else if (viewPager.getCurrentItem() == 1) {
|
||||
followedUsersListingFragment.goBackToTop();
|
||||
}
|
||||
}
|
||||
|
||||
void changeSearchQuery(String searchQuery) {
|
||||
if (blockedCommunitiesListingFragment != null) {
|
||||
blockedCommunitiesListingFragment.changeSearchQuery(searchQuery);
|
||||
}
|
||||
if (followedUsersListingFragment != null) {
|
||||
followedUsersListingFragment.changeSearchQuery(searchQuery);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
@@ -308,7 +308,7 @@ public class EditPostActivity extends BaseActivity implements UploadImageEnabled
|
||||
isSubmitting = true;
|
||||
|
||||
Snackbar.make(coordinatorLayout, R.string.posting, Snackbar.LENGTH_SHORT).show();
|
||||
mRetrofit.getRetrofit().create(LemmyAPI.class).postUpdate(new EditPostDTO(mPost.getId(), titleEditText.getText().toString(), linkEditText.getText().toString(), contentEditText.getText().toString(), mPost.isNSFW(), null, mAccessToken))
|
||||
mRetrofit.getRetrofit().create(LemmyAPI.class).postUpdate(new EditPostDTO(mPost.getId(), titleEditText.getText().toString(), (linkEditText.getText().toString().isEmpty()) ? null : linkEditText.getText().toString(), contentEditText.getText().toString(), mPost.isNSFW(), null, mAccessToken))
|
||||
.enqueue(new Callback<String>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||
@@ -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: ")) {
|
||||
|
||||
@@ -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 =
|
||||
|
||||
@@ -272,7 +272,7 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec
|
||||
switch (postType) {
|
||||
case PostPagingSource.TYPE_FRONT_PAGE:
|
||||
case PostPagingSource.TYPE_ANONYMOUS_FRONT_PAGE:
|
||||
getSupportActionBar().setTitle(R.string.home);
|
||||
getSupportActionBar().setTitle(R.string.subscribed_feed);
|
||||
break;
|
||||
case PostPagingSource.TYPE_SEARCH:
|
||||
getSupportActionBar().setTitle(R.string.search);
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -55,6 +55,7 @@ import eu.toldi.infinityforlemmy.events.PassPrivateMessageEvent;
|
||||
import eu.toldi.infinityforlemmy.events.PassPrivateMessageIndexEvent;
|
||||
import eu.toldi.infinityforlemmy.events.SwitchAccountEvent;
|
||||
import eu.toldi.infinityforlemmy.fragments.InboxFragment;
|
||||
import eu.toldi.infinityforlemmy.fragments.PrivateMessageFragment;
|
||||
import eu.toldi.infinityforlemmy.message.CommentInteraction;
|
||||
import eu.toldi.infinityforlemmy.message.FetchMessage;
|
||||
import eu.toldi.infinityforlemmy.message.ReadMessage;
|
||||
@@ -180,7 +181,7 @@ public class InboxActivity extends BaseActivity implements ActivityToolbarInterf
|
||||
if (i == EditorInfo.IME_ACTION_DONE) {
|
||||
Utils.hideKeyboard(this);
|
||||
Intent pmIntent = new Intent(this, SendPrivateMessageActivity.class);
|
||||
pmIntent.putExtra(SendPrivateMessageActivity.EXTRA_RECIPIENT_USERNAME, thingEditText.getText().toString());
|
||||
//pmIntent.putExtra(SendPrivateMessageActivity.EXTRA_RECIPIENT_USERNAME, thingEditText.getText().toString());
|
||||
startActivity(pmIntent);
|
||||
return true;
|
||||
}
|
||||
@@ -193,7 +194,7 @@ public class InboxActivity extends BaseActivity implements ActivityToolbarInterf
|
||||
-> {
|
||||
Utils.hideKeyboard(this);
|
||||
Intent pmIntent = new Intent(this, SendPrivateMessageActivity.class);
|
||||
pmIntent.putExtra(SendPrivateMessageActivity.EXTRA_RECIPIENT_USERNAME, thingEditText.getText().toString());
|
||||
//pmIntent.putExtra(SendPrivateMessageActivity.EXTRA_RECIPIENT_USERNAME, thingEditText.getText().toString());
|
||||
startActivity(pmIntent);
|
||||
})
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
@@ -330,7 +331,7 @@ public class InboxActivity extends BaseActivity implements ActivityToolbarInterf
|
||||
if (resultCode == RESULT_OK && requestCode == SEARCH_USER_REQUEST_CODE && data != null) {
|
||||
String username = data.getStringExtra(SearchActivity.EXTRA_RETURN_USER_NAME);
|
||||
Intent intent = new Intent(this, SendPrivateMessageActivity.class);
|
||||
intent.putExtra(SendPrivateMessageActivity.EXTRA_RECIPIENT_USERNAME, username);
|
||||
//intent.putExtra(SendPrivateMessageActivity.EXTRA_RECIPIENT_USERNAME, username);
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
@@ -441,7 +442,7 @@ public class InboxActivity extends BaseActivity implements ActivityToolbarInterf
|
||||
@NonNull
|
||||
@Override
|
||||
public Fragment createFragment(int position) {
|
||||
InboxFragment fragment = new InboxFragment();
|
||||
Fragment fragment = new InboxFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(InboxFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
||||
switch (position) {
|
||||
@@ -450,11 +451,9 @@ public class InboxActivity extends BaseActivity implements ActivityToolbarInterf
|
||||
break;
|
||||
case 1:
|
||||
bundle.putString(InboxFragment.EXTRA_MESSAGE_WHERE, FetchMessage.WHERE_MENTIONS);
|
||||
fragment.setArguments(bundle);
|
||||
break;
|
||||
case 2:
|
||||
bundle.putString(InboxFragment.EXTRA_MESSAGE_WHERE, FetchMessage.WHERE_MESSAGES);
|
||||
fragment.setArguments(bundle);
|
||||
fragment = new PrivateMessageFragment();
|
||||
break;
|
||||
}
|
||||
fragment.setArguments(bundle);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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,13 +81,19 @@ public class LinkResolverActivity extends AppCompatActivity {
|
||||
@Named("no_oauth")
|
||||
RetrofitHolder mRetrofit;
|
||||
|
||||
@Inject
|
||||
Executor mExecutor;
|
||||
|
||||
@Inject
|
||||
PostEnricher postEnricher;
|
||||
|
||||
private String mAccessToken;
|
||||
|
||||
private Uri getRedditUriByPath(String path) {
|
||||
if (path.charAt(0) != '/') {
|
||||
return Uri.parse("https://www.reddit.com/" + path);
|
||||
return Uri.parse(mRetrofit.getBaseURL() + path);
|
||||
} else {
|
||||
return Uri.parse("https://www.reddit.com" + path);
|
||||
return Uri.parse(mRetrofit.getBaseURL() + path);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,19 +103,26 @@ public class LinkResolverActivity extends AppCompatActivity {
|
||||
|
||||
((Infinity) getApplication()).getAppComponent().inject(this);
|
||||
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
|
||||
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;
|
||||
}
|
||||
@@ -111,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;
|
||||
}
|
||||
@@ -123,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) {
|
||||
@@ -197,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) {
|
||||
@@ -233,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);
|
||||
|
||||
@@ -6,8 +6,8 @@ import android.content.SharedPreferences;
|
||||
import android.graphics.drawable.Drawable;
|
||||
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;
|
||||
@@ -26,6 +26,8 @@ import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import javax.inject.Inject;
|
||||
@@ -139,15 +141,18 @@ public class LoginActivity extends BaseActivity {
|
||||
|
||||
loginButton.setOnClickListener(view -> {
|
||||
Log.i("LoginActivity", "Login button clicked");
|
||||
if(!checkFields())
|
||||
return;
|
||||
loginButton.setEnabled(false);
|
||||
progressBar.setVisibility(ProgressBar.VISIBLE);
|
||||
String username = username_input.getText().toString().trim();
|
||||
String instance = correctURL(instance_input.getText().toString().trim());
|
||||
if (!Patterns.WEB_URL.matcher(instance).matches()) {
|
||||
instance_input.setError("Invalid instance URL");
|
||||
try {
|
||||
URL urlObj = new URL(instance);
|
||||
instance = urlObj.getProtocol() + "://" + urlObj.getHost() + "/";
|
||||
} catch (MalformedURLException e) {
|
||||
instance_input.setError("Invalid URL");
|
||||
Toast.makeText(LoginActivity.this, "Invalid instance URL", Toast.LENGTH_SHORT).show();
|
||||
loginButton.setEnabled(true);
|
||||
progressBar.setVisibility(ProgressBar.GONE);
|
||||
return;
|
||||
}
|
||||
Log.i("LoginActivity", "Instance: " + instance);
|
||||
@@ -155,6 +160,7 @@ public class LoginActivity extends BaseActivity {
|
||||
mRetrofit.setBaseURL(instance);
|
||||
LemmyAPI api = mRetrofit.getRetrofit().create(LemmyAPI.class);
|
||||
Call<String> accessTokenCall = api.userLogin(accountLoginDTO);
|
||||
String finalInstance = instance;
|
||||
accessTokenCall.enqueue(new Callback<String>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||
@@ -173,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() {
|
||||
@@ -182,18 +189,28 @@ 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,instance,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
|
||||
public void onFetchSiteInfoFailed() {
|
||||
ParseAndInsertNewAccount.parseAndInsertNewAccount(mExecutor, new Handler(), name,display_name, accessToken, profileImageUrl, bannerImageUrl, authCode,instance,true, mRedditDataRoomDatabase.accountDao(),
|
||||
ParseAndInsertNewAccount.parseAndInsertNewAccount(mExecutor, new Handler(), name,display_name, accessToken, profileImageUrl, bannerImageUrl, authCode, finalInstance,true, mRedditDataRoomDatabase.accountDao(),
|
||||
() -> {
|
||||
Intent resultIntent = new Intent();
|
||||
setResult(Activity.RESULT_OK, resultIntent);
|
||||
@@ -205,7 +222,7 @@ public class LoginActivity extends BaseActivity {
|
||||
mCurrentAccountSharedPreferences.edit().putString(SharedPreferencesUtils.ACCESS_TOKEN, accessToken)
|
||||
.putString(SharedPreferencesUtils.ACCOUNT_NAME, display_name)
|
||||
.putString(SharedPreferencesUtils.ACCOUNT_QUALIFIED_NAME, name)
|
||||
.putString(SharedPreferencesUtils.ACCOUNT_INSTANCE,instance)
|
||||
.putString(SharedPreferencesUtils.ACCOUNT_INSTANCE,finalInstance)
|
||||
.putString(SharedPreferencesUtils.ACCOUNT_IMAGE_URL, profileImageUrl).apply();
|
||||
}
|
||||
|
||||
@@ -260,6 +277,26 @@ public class LoginActivity extends BaseActivity {
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private boolean checkFields() {
|
||||
boolean result = true;
|
||||
Editable username = username_input.getText();
|
||||
Editable password = password_input.getText();
|
||||
Editable instance = instance_input.getText();
|
||||
if(instance == null || instance.toString().isEmpty()) {
|
||||
instance_input.setError(getString(R.string.instance_cannot_be_empty));
|
||||
result = false;
|
||||
}
|
||||
if(username == null || username.toString().isEmpty()) {
|
||||
username_input.setError(getString(R.string.username_cannot_be_empty));
|
||||
result = false;
|
||||
}
|
||||
if(password == null || password.toString().isEmpty()) {
|
||||
password_input.setError(getString(R.string.password_cannot_be_empty));
|
||||
result = false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
private static String correctURL(String url) {
|
||||
if (url == null || url.isEmpty()) {
|
||||
throw new IllegalArgumentException("URL cannot be null or empty");
|
||||
|
||||
@@ -336,11 +336,13 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
||||
fragmentManager = getSupportFragmentManager();
|
||||
|
||||
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
|
||||
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 +367,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();
|
||||
}
|
||||
}
|
||||
@@ -481,7 +484,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
||||
Intent intent = new Intent(this, ViewUserDetailActivity.class);
|
||||
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, mAccountName);
|
||||
intent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, mAccountQualifiedName);
|
||||
intent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, mAccountName);
|
||||
startActivity(intent);
|
||||
break;
|
||||
}
|
||||
@@ -808,17 +810,17 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
||||
|
||||
adapter = new NavigationDrawerRecyclerViewMergedAdapter(this, mSharedPreferences,
|
||||
mNsfwAndSpoilerSharedPreferences, mNavigationDrawerSharedPreferences, mSecuritySharedPreferences,
|
||||
mCustomThemeWrapper, mAccountName, new NavigationDrawerRecyclerViewMergedAdapter.ItemClickListener() {
|
||||
@Override
|
||||
public void onMenuClick(int stringId) {
|
||||
Intent intent = null;
|
||||
if (stringId == R.string.profile) {
|
||||
intent = new Intent(MainActivity.this, ViewUserDetailActivity.class);
|
||||
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, mAccountName);
|
||||
intent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, mAccountQualifiedName);
|
||||
} else if (stringId == R.string.subscriptions) {
|
||||
intent = new Intent(MainActivity.this, SubscribedThingListingActivity.class);
|
||||
} else if (stringId == R.string.multi_reddit) {
|
||||
mCustomThemeWrapper, mAccountName, mAccountQualifiedName, new NavigationDrawerRecyclerViewMergedAdapter.ItemClickListener() {
|
||||
@Override
|
||||
public void onMenuClick(int stringId) {
|
||||
Intent intent = null;
|
||||
if (stringId == R.string.profile) {
|
||||
intent = new Intent(MainActivity.this, ViewUserDetailActivity.class);
|
||||
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, mAccountName);
|
||||
intent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, mAccountQualifiedName);
|
||||
} else if (stringId == R.string.subscriptions) {
|
||||
intent = new Intent(MainActivity.this, SubscribedThingListingActivity.class);
|
||||
} else if (stringId == R.string.multi_reddit) {
|
||||
intent = new Intent(MainActivity.this, SubscribedThingListingActivity.class);
|
||||
intent.putExtra(SubscribedThingListingActivity.EXTRA_SHOW_MULTIREDDITS, true);
|
||||
} else if (stringId == R.string.history) {
|
||||
@@ -883,7 +885,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.instance_info) {
|
||||
intent = new Intent(MainActivity.this, InstanceInfoActivity.class);
|
||||
}
|
||||
if (intent != null) {
|
||||
startActivity(intent);
|
||||
}
|
||||
@@ -931,7 +937,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
||||
new TabLayoutMediator(tabLayout, viewPager2, (tab, position) -> {
|
||||
switch (position) {
|
||||
case 0:
|
||||
Utils.setTitleWithCustomFontToTab(typeface, tab, mMainActivityTabsSharedPreferences.getString((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_TITLE, getString(R.string.home)));
|
||||
Utils.setTitleWithCustomFontToTab(typeface, tab, mMainActivityTabsSharedPreferences.getString((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_TITLE, getString(R.string.subscribed_feed)));
|
||||
break;
|
||||
case 1:
|
||||
Utils.setTitleWithCustomFontToTab(typeface, tab, mMainActivityTabsSharedPreferences.getString((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_TITLE, getString(R.string.local)));
|
||||
@@ -1010,12 +1016,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);
|
||||
@@ -1507,7 +1513,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;
|
||||
}
|
||||
@@ -1565,7 +1576,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) -> {
|
||||
@@ -1586,7 +1601,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;
|
||||
}
|
||||
@@ -1599,7 +1618,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) -> {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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, subredditName, mAccessToken, mOauthRetrofit, mRetrofit.getRetrofit(), iconImageUrl -> {
|
||||
LoadSubredditIcon.loadSubredditIcon(mExecutor, new Handler(), mRedditDataRoomDatabase, communityData.getQualified_name(), mAccessToken, mRetrofit.getRetrofit(), iconImageUrl -> {
|
||||
iconUrl = iconImageUrl;
|
||||
displaySubredditIcon();
|
||||
loadSubredditIconSuccessful = true;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -488,8 +491,8 @@ public class PostLinkActivity 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, communityData.getQualified_name(),
|
||||
mAccessToken, mRetrofit.getRetrofit(), iconImageUrl -> {
|
||||
iconUrl = iconImageUrl;
|
||||
displaySubredditIcon();
|
||||
loadSubredditIconSuccessful = true;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -450,12 +450,12 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
}
|
||||
|
||||
private void loadSubredditIcon() {
|
||||
LoadSubredditIcon.loadSubredditIcon(mExecutor, new Handler(), mRedditDataRoomDatabase, subredditName,
|
||||
mAccessToken, mOauthRetrofit, mRetrofit.getRetrofit(), iconImageUrl -> {
|
||||
iconUrl = iconImageUrl;
|
||||
displaySubredditIcon();
|
||||
loadSubredditIconSuccessful = true;
|
||||
});
|
||||
LoadSubredditIcon.loadSubredditIcon(mExecutor, new Handler(), mRedditDataRoomDatabase, communityData.getQualified_name(),
|
||||
mAccessToken, mRetrofit.getRetrofit(), iconImageUrl -> {
|
||||
iconUrl = iconImageUrl;
|
||||
displaySubredditIcon();
|
||||
loadSubredditIconSuccessful = true;
|
||||
});
|
||||
}
|
||||
|
||||
private void promptAlertDialog(int titleResId, int messageResId) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -784,7 +784,8 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
|
||||
bundle.putString(SubredditListingFragment.EXTRA_QUERY, mQuery);
|
||||
bundle.putBoolean(SubredditListingFragment.EXTRA_IS_GETTING_SUBREDDIT_INFO, false);
|
||||
bundle.putString(SubredditListingFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
||||
bundle.putString(SubredditListingFragment.EXTRA_ACCOUNT_NAME, mAccountQualifiedName);
|
||||
bundle.putString(SubredditListingFragment.EXTRA_ACCOUNT_NAME, mAccountName);
|
||||
bundle.putString(SubredditListingFragment.EXTRA_ACCOUNT_QUALIFIED_NAME, mAccountQualifiedName);
|
||||
mFragment.setArguments(bundle);
|
||||
return mFragment;
|
||||
}
|
||||
|
||||
@@ -119,7 +119,8 @@ public class SearchSubredditsResultActivity extends BaseActivity implements Acti
|
||||
bundle.putString(SubredditListingFragment.EXTRA_QUERY, query);
|
||||
bundle.putBoolean(SubredditListingFragment.EXTRA_IS_GETTING_SUBREDDIT_INFO, true);
|
||||
bundle.putString(SubredditListingFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
||||
bundle.putString(SubredditListingFragment.EXTRA_ACCOUNT_NAME, mAccountQualifiedName);
|
||||
bundle.putString(SubredditListingFragment.EXTRA_ACCOUNT_NAME, mAccountName);
|
||||
bundle.putString(SubredditListingFragment.EXTRA_ACCOUNT_QUALIFIED_NAME, mAccountQualifiedName);
|
||||
bundle.putBoolean(SubredditListingFragment.EXTRA_IS_MULTI_SELECTION, getIntent().getBooleanExtra(EXTRA_IS_MULTI_SELECTION, false));
|
||||
mFragment.setArguments(bundle);
|
||||
} else {
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
package eu.toldi.infinityforlemmy.activities;
|
||||
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.provider.MediaStore;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
@@ -10,12 +15,20 @@ import android.widget.EditText;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
import androidx.core.content.FileProvider;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.google.android.material.appbar.AppBarLayout;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
@@ -23,13 +36,24 @@ import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import eu.toldi.infinityforlemmy.Infinity;
|
||||
import eu.toldi.infinityforlemmy.R;
|
||||
import eu.toldi.infinityforlemmy.RetrofitHolder;
|
||||
import eu.toldi.infinityforlemmy.UploadImageEnabledActivity;
|
||||
import eu.toldi.infinityforlemmy.UploadedImage;
|
||||
import eu.toldi.infinityforlemmy.adapters.MarkdownBottomBarRecyclerViewAdapter;
|
||||
import eu.toldi.infinityforlemmy.bottomsheetfragments.UploadedImagesBottomSheetFragment;
|
||||
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||
import eu.toldi.infinityforlemmy.message.ComposeMessage;
|
||||
import eu.toldi.infinityforlemmy.customviews.LinearLayoutManagerBugFixed;
|
||||
import eu.toldi.infinityforlemmy.privatemessage.LemmyPrivateMessageAPI;
|
||||
import eu.toldi.infinityforlemmy.privatemessage.PrivateMessage;
|
||||
import eu.toldi.infinityforlemmy.user.BasicUserInfo;
|
||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||
import retrofit2.Retrofit;
|
||||
import eu.toldi.infinityforlemmy.utils.Utils;
|
||||
|
||||
public class SendPrivateMessageActivity extends BaseActivity {
|
||||
public static final String EXTRA_RECIPIENT_USERNAME = "ERU";
|
||||
public class SendPrivateMessageActivity extends BaseActivity implements UploadImageEnabledActivity {
|
||||
public static final String EXTRA_RECIPIENT_USER_INFO = "ERUI";
|
||||
|
||||
private static final int PICK_IMAGE_REQUEST_CODE = 100;
|
||||
private static final int CAPTURE_IMAGE_REQUEST_CODE = 200;
|
||||
@BindView(R.id.coordinator_layout_send_private_message_activity)
|
||||
CoordinatorLayout coordinatorLayout;
|
||||
@BindView(R.id.appbar_layout_send_private_message_activity)
|
||||
@@ -40,15 +64,20 @@ public class SendPrivateMessageActivity extends BaseActivity {
|
||||
EditText usernameEditText;
|
||||
@BindView(R.id.divider_1_send_private_message_activity)
|
||||
View divider1;
|
||||
@BindView(R.id.subjet_edit_text_send_private_message_activity)
|
||||
EditText subjectEditText;
|
||||
@BindView(R.id.divider_2_send_private_message_activity)
|
||||
View divider2;
|
||||
@BindView(R.id.content_edit_text_send_private_message_activity)
|
||||
EditText messageEditText;
|
||||
|
||||
@BindView(R.id.markdown_bottom_bar_recycler_view_send_private_message_activity)
|
||||
RecyclerView markdownBottomBarRecyclerView;
|
||||
@Inject
|
||||
@Named("oauth")
|
||||
Retrofit mOauthRetrofit;
|
||||
@Named("no_oauth")
|
||||
RetrofitHolder mRetrofit;
|
||||
|
||||
@Inject
|
||||
Executor mExecutor;
|
||||
|
||||
@Inject
|
||||
@Named("default")
|
||||
SharedPreferences mSharedPreferences;
|
||||
@@ -57,15 +86,24 @@ public class SendPrivateMessageActivity extends BaseActivity {
|
||||
SharedPreferences mCurrentAccountSharedPreferences;
|
||||
@Inject
|
||||
CustomThemeWrapper mCustomThemeWrapper;
|
||||
|
||||
@Inject
|
||||
LemmyPrivateMessageAPI mLemmyPrivateMessageAPI;
|
||||
private String mAccessToken;
|
||||
|
||||
private BasicUserInfo mRecipientBasicUserInfo;
|
||||
private boolean isSubmitting = false;
|
||||
|
||||
private ArrayList<UploadedImage> uploadedImages = new ArrayList<>();
|
||||
|
||||
private Uri capturedImageUri;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
((Infinity) getApplication()).getAppComponent().inject(this);
|
||||
|
||||
setImmersiveModeNotApplicable();
|
||||
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_send_private_message);
|
||||
|
||||
@@ -77,14 +115,66 @@ public class SendPrivateMessageActivity extends BaseActivity {
|
||||
addOnOffsetChangedListener(appBarLayout);
|
||||
}
|
||||
|
||||
MarkdownBottomBarRecyclerViewAdapter adapter = new MarkdownBottomBarRecyclerViewAdapter(
|
||||
mCustomThemeWrapper, new MarkdownBottomBarRecyclerViewAdapter.ItemClickListener() {
|
||||
@Override
|
||||
public void onClick(int item) {
|
||||
MarkdownBottomBarRecyclerViewAdapter.bindEditTextWithItemClickListener(
|
||||
SendPrivateMessageActivity.this, messageEditText, item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUploadImage() {
|
||||
Utils.hideKeyboard(SendPrivateMessageActivity.this);
|
||||
UploadedImagesBottomSheetFragment fragment = new UploadedImagesBottomSheetFragment();
|
||||
Bundle arguments = new Bundle();
|
||||
arguments.putParcelableArrayList(UploadedImagesBottomSheetFragment.EXTRA_UPLOADED_IMAGES,
|
||||
uploadedImages);
|
||||
fragment.setArguments(arguments);
|
||||
fragment.show(getSupportFragmentManager(), fragment.getTag());
|
||||
}
|
||||
});
|
||||
|
||||
markdownBottomBarRecyclerView.setLayoutManager(new LinearLayoutManagerBugFixed(this,
|
||||
LinearLayoutManagerBugFixed.HORIZONTAL, false));
|
||||
markdownBottomBarRecyclerView.setAdapter(adapter);
|
||||
|
||||
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
|
||||
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
String username = getIntent().getStringExtra(EXTRA_RECIPIENT_USERNAME);
|
||||
if (username != null) {
|
||||
usernameEditText.setText(username);
|
||||
if (savedInstanceState != null) {
|
||||
mRecipientBasicUserInfo = savedInstanceState.getParcelable(EXTRA_RECIPIENT_USER_INFO);
|
||||
} else {
|
||||
mRecipientBasicUserInfo = getIntent().getParcelableExtra(EXTRA_RECIPIENT_USER_INFO);
|
||||
}
|
||||
|
||||
if (mRecipientBasicUserInfo != null) {
|
||||
usernameEditText.setText(mRecipientBasicUserInfo.getQualifiedName());
|
||||
usernameEditText.setEnabled(false);
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (resultCode == RESULT_OK) {
|
||||
if (requestCode == PICK_IMAGE_REQUEST_CODE) {
|
||||
if (data == null) {
|
||||
Toast.makeText(SendPrivateMessageActivity.this, R.string.error_getting_image, Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
Utils.uploadImageToReddit(this, mExecutor, mRetrofit,
|
||||
mAccessToken, messageEditText, coordinatorLayout, data.getData(), uploadedImages);
|
||||
} else if (requestCode == CAPTURE_IMAGE_REQUEST_CODE) {
|
||||
Utils.uploadImageToReddit(this, mExecutor, mRetrofit,
|
||||
mAccessToken, messageEditText, coordinatorLayout, capturedImageUri, uploadedImages);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -108,12 +198,6 @@ public class SendPrivateMessageActivity extends BaseActivity {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (subjectEditText.getText() == null || subjectEditText.getText().toString().equals("")) {
|
||||
isSubmitting = false;
|
||||
Snackbar.make(coordinatorLayout, R.string.message_subject_required, Snackbar.LENGTH_LONG).show();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (messageEditText.getText() == null || messageEditText.getText().toString().equals("")) {
|
||||
isSubmitting = false;
|
||||
Snackbar.make(coordinatorLayout, R.string.message_content_required, Snackbar.LENGTH_LONG).show();
|
||||
@@ -125,32 +209,26 @@ public class SendPrivateMessageActivity extends BaseActivity {
|
||||
Snackbar sendingSnackbar = Snackbar.make(coordinatorLayout, R.string.sending_message, Snackbar.LENGTH_INDEFINITE);
|
||||
sendingSnackbar.show();
|
||||
|
||||
ComposeMessage.composeMessage(mOauthRetrofit, mAccessToken, getResources().getConfiguration().locale,
|
||||
usernameEditText.getText().toString(), subjectEditText.getText().toString(),
|
||||
messageEditText.getText().toString(), new ComposeMessage.ComposeMessageListener() {
|
||||
@Override
|
||||
public void composeMessageSuccess() {
|
||||
isSubmitting = false;
|
||||
item.setEnabled(true);
|
||||
item.getIcon().setAlpha(255);
|
||||
Toast.makeText(SendPrivateMessageActivity.this, R.string.send_message_success, Toast.LENGTH_SHORT).show();
|
||||
finish();
|
||||
}
|
||||
mLemmyPrivateMessageAPI.sendPrivateMessage(mAccessToken, mRecipientBasicUserInfo.getId(), messageEditText.getText().toString(), new LemmyPrivateMessageAPI.PrivateMessageSentListener() {
|
||||
@Override
|
||||
public void onPrivateMessageSentSuccess(@NonNull PrivateMessage privateMessage) {
|
||||
isSubmitting = false;
|
||||
item.setEnabled(true);
|
||||
item.getIcon().setAlpha(255);
|
||||
Toast.makeText(SendPrivateMessageActivity.this, R.string.send_message_success, Toast.LENGTH_SHORT).show();
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void composeMessageFailed(String errorMessage) {
|
||||
isSubmitting = false;
|
||||
sendingSnackbar.dismiss();
|
||||
item.setEnabled(true);
|
||||
item.getIcon().setAlpha(255);
|
||||
@Override
|
||||
public void onPrivateMessageSentError() {
|
||||
isSubmitting = false;
|
||||
sendingSnackbar.dismiss();
|
||||
item.setEnabled(true);
|
||||
item.getIcon().setAlpha(255);
|
||||
|
||||
if (errorMessage == null || errorMessage.equals("")) {
|
||||
Snackbar.make(coordinatorLayout, R.string.send_message_failed, Snackbar.LENGTH_LONG).show();
|
||||
} else {
|
||||
Snackbar.make(coordinatorLayout, errorMessage, Snackbar.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
Snackbar.make(coordinatorLayout, R.string.send_message_failed, Snackbar.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@@ -159,6 +237,7 @@ public class SendPrivateMessageActivity extends BaseActivity {
|
||||
@Override
|
||||
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putParcelable(EXTRA_RECIPIENT_USER_INFO, mRecipientBasicUserInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -177,19 +256,49 @@ public class SendPrivateMessageActivity extends BaseActivity {
|
||||
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, null, toolbar);
|
||||
int primaryTextColor = mCustomThemeWrapper.getPrimaryTextColor();
|
||||
usernameEditText.setTextColor(primaryTextColor);
|
||||
subjectEditText.setTextColor(primaryTextColor);
|
||||
messageEditText.setTextColor(primaryTextColor);
|
||||
int secondaryTextColor = mCustomThemeWrapper.getSecondaryTextColor();
|
||||
usernameEditText.setHintTextColor(secondaryTextColor);
|
||||
subjectEditText.setHintTextColor(secondaryTextColor);
|
||||
messageEditText.setHintTextColor(secondaryTextColor);
|
||||
int dividerColor = mCustomThemeWrapper.getDividerColor();
|
||||
divider1.setBackgroundColor(dividerColor);
|
||||
divider2.setBackgroundColor(dividerColor);
|
||||
if (typeface != null) {
|
||||
usernameEditText.setTypeface(typeface);
|
||||
subjectEditText.setTypeface(typeface);
|
||||
messageEditText.setTypeface(typeface);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uploadImage() {
|
||||
Intent intent = new Intent();
|
||||
intent.setType("image/*");
|
||||
intent.setAction(Intent.ACTION_GET_CONTENT);
|
||||
startActivityForResult(Intent.createChooser(intent,
|
||||
getResources().getString(R.string.select_from_gallery)), PICK_IMAGE_REQUEST_CODE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void captureImage() {
|
||||
Intent pictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||
try {
|
||||
capturedImageUri = FileProvider.getUriForFile(this, "eu.toldi.infinityforlemmy.provider",
|
||||
File.createTempFile("captured_image", ".jpg", getExternalFilesDir(Environment.DIRECTORY_PICTURES)));
|
||||
pictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, capturedImageUri);
|
||||
startActivityForResult(pictureIntent, CAPTURE_IMAGE_REQUEST_CODE);
|
||||
} catch (IOException ex) {
|
||||
Toast.makeText(this, R.string.error_creating_temp_file, Toast.LENGTH_SHORT).show();
|
||||
} catch (ActivityNotFoundException e) {
|
||||
Toast.makeText(this, R.string.no_camera_available, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertImageUrl(UploadedImage uploadedImage) {
|
||||
int start = Math.max(messageEditText.getSelectionStart(), 0);
|
||||
int end = Math.max(messageEditText.getSelectionEnd(), 0);
|
||||
messageEditText.getText().replace(Math.min(start, end), Math.max(start, end),
|
||||
"",
|
||||
0, "![]()".length() + uploadedImage.imageName.length() + uploadedImage.imageUrl.length());
|
||||
}
|
||||
}
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -73,7 +73,6 @@ import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.Utils;
|
||||
import retrofit2.Retrofit;
|
||||
|
||||
;
|
||||
|
||||
public class SubscribedThingListingActivity extends BaseActivity implements ActivityToolbarInterface {
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -5,6 +5,7 @@ import android.content.SharedPreferences;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.util.Log;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
@@ -27,6 +28,7 @@ import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import javax.inject.Inject;
|
||||
@@ -46,14 +48,15 @@ import eu.toldi.infinityforlemmy.customviews.LinearLayoutManagerBugFixed;
|
||||
import eu.toldi.infinityforlemmy.events.PassPrivateMessageEvent;
|
||||
import eu.toldi.infinityforlemmy.events.PassPrivateMessageIndexEvent;
|
||||
import eu.toldi.infinityforlemmy.events.RepliedToPrivateMessageEvent;
|
||||
import eu.toldi.infinityforlemmy.message.Message;
|
||||
import eu.toldi.infinityforlemmy.message.ReadMessage;
|
||||
import eu.toldi.infinityforlemmy.message.ReplyMessage;
|
||||
import eu.toldi.infinityforlemmy.privatemessage.LemmyPrivateMessageAPI;
|
||||
import eu.toldi.infinityforlemmy.privatemessage.PrivateMessage;
|
||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||
import retrofit2.Retrofit;
|
||||
|
||||
public class ViewPrivateMessagesActivity extends BaseActivity implements ActivityToolbarInterface {
|
||||
|
||||
public static final String EXTRA_PRIVATE_MESSAGE = "EPM";
|
||||
public static final String EXTRA_PRIVATE_MESSAGE_INDEX = "EPM";
|
||||
public static final String EXTRA_MESSAGE_POSITION = "EMP";
|
||||
private static final String USER_AVATAR_STATE = "UAS";
|
||||
@@ -91,14 +94,19 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
|
||||
CustomThemeWrapper mCustomThemeWrapper;
|
||||
@Inject
|
||||
Executor mExecutor;
|
||||
|
||||
@Inject
|
||||
LemmyPrivateMessageAPI mLemmyPrivateMessageAPI;
|
||||
private LinearLayoutManagerBugFixed mLinearLayoutManager;
|
||||
private PrivateMessagesDetailRecyclerViewAdapter mAdapter;
|
||||
@State
|
||||
Message privateMessage;
|
||||
PrivateMessage privateMessage;
|
||||
@State
|
||||
Message replyTo;
|
||||
PrivateMessage replyTo;
|
||||
private String mAccessToken;
|
||||
private String mAccountName;
|
||||
|
||||
private String mAccountQualifiedName;
|
||||
private String mUserAvatar;
|
||||
private ArrayList<ProvideUserAvatarCallback> mProvideUserAvatarCallbacks;
|
||||
private boolean isLoadingUserAvatar = false;
|
||||
@@ -128,6 +136,11 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
|
||||
addOnOffsetChangedListener(mAppBarLayout);
|
||||
}
|
||||
|
||||
Intent intent = getIntent();
|
||||
privateMessage = intent.getParcelableExtra(EXTRA_PRIVATE_MESSAGE);
|
||||
|
||||
Log.i("ViewPrivate", "privateMessage: " + privateMessage);
|
||||
|
||||
setSupportActionBar(mToolbar);
|
||||
setToolbarGoToTop(mToolbar);
|
||||
|
||||
@@ -135,6 +148,7 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
|
||||
|
||||
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
|
||||
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null);
|
||||
mAccountQualifiedName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_QUALIFIED_NAME, null);
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
mUserAvatar = savedInstanceState.getString(USER_AVATAR_STATE);
|
||||
@@ -144,36 +158,37 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
|
||||
bindView();
|
||||
}
|
||||
} else {
|
||||
if (privateMessage != null) {
|
||||
bindView();
|
||||
}
|
||||
EventBus.getDefault().post(new PassPrivateMessageIndexEvent(getIntent().getIntExtra(EXTRA_PRIVATE_MESSAGE_INDEX, -1)));
|
||||
}
|
||||
}
|
||||
|
||||
private void bindView() {
|
||||
if (privateMessage != null) {
|
||||
if (privateMessage.getAuthor().equals(mAccountName)) {
|
||||
setTitle(privateMessage.getDestination());
|
||||
if (privateMessage.getCreatorQualifiedName().equals(mAccountQualifiedName)) {
|
||||
setTitle(privateMessage.getRecipientName());
|
||||
mToolbar.setOnClickListener(view -> {
|
||||
if (privateMessage.isDestinationDeleted()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Intent intent = new Intent(this, ViewUserDetailActivity.class);
|
||||
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, privateMessage.getDestination());
|
||||
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, privateMessage.getRecipientName());
|
||||
intent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, privateMessage.getRecipientQualifiedName());
|
||||
startActivity(intent);
|
||||
});
|
||||
} else {
|
||||
setTitle(privateMessage.getAuthor());
|
||||
setTitle(privateMessage.getCreatorName());
|
||||
mToolbar.setOnClickListener(view -> {
|
||||
if (privateMessage.isAuthorDeleted()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Intent intent = new Intent(this, ViewUserDetailActivity.class);
|
||||
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, privateMessage.getAuthor());
|
||||
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, privateMessage.getCreatorName());
|
||||
intent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, privateMessage.getCreatorQualifiedName());
|
||||
startActivity(intent);
|
||||
});
|
||||
}
|
||||
}
|
||||
mAdapter = new PrivateMessagesDetailRecyclerViewAdapter(this, mSharedPreferences,
|
||||
getResources().getConfiguration().locale, privateMessage, mAccountName, mCustomThemeWrapper);
|
||||
getResources().getConfiguration().locale, privateMessage, mAccountQualifiedName, mCustomThemeWrapper);
|
||||
mLinearLayoutManager = new LinearLayoutManagerBugFixed(this);
|
||||
mLinearLayoutManager.setStackFromEnd(true);
|
||||
mRecyclerView.setLayoutManager(mLinearLayoutManager);
|
||||
@@ -184,45 +199,40 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
|
||||
if (!mEditText.getText().toString().equals("")) {
|
||||
//Send Message
|
||||
if (privateMessage != null) {
|
||||
ArrayList<Message> replies = privateMessage.getReplies();
|
||||
List<PrivateMessage> replies = privateMessage.getReplies();
|
||||
if (replyTo == null) {
|
||||
replyTo = privateMessage;
|
||||
}
|
||||
isSendingMessage = true;
|
||||
mSendImageView.setColorFilter(mSecondaryTextColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||
ReplyMessage.replyMessage(mEditText.getText().toString(), replyTo.getFullname(),
|
||||
getResources().getConfiguration().locale, mOauthRetrofit, mAccessToken,
|
||||
new ReplyMessage.ReplyMessageListener() {
|
||||
@Override
|
||||
public void replyMessageSuccess(Message message) {
|
||||
if (mAdapter != null) {
|
||||
mAdapter.addReply(message);
|
||||
}
|
||||
goToBottom();
|
||||
mEditText.setText("");
|
||||
mSendImageView.setColorFilter(mSendMessageIconColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||
isSendingMessage = false;
|
||||
EventBus.getDefault().post(new RepliedToPrivateMessageEvent(message, getIntent().getIntExtra(EXTRA_MESSAGE_POSITION, -1)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void replyMessageFailed(String errorMessage) {
|
||||
if (errorMessage != null && !errorMessage.equals("")) {
|
||||
Snackbar.make(mCoordinatorLayout, errorMessage, Snackbar.LENGTH_LONG).show();
|
||||
} else {
|
||||
Snackbar.make(mCoordinatorLayout, R.string.reply_message_failed, Snackbar.LENGTH_LONG).show();
|
||||
}
|
||||
mSendImageView.setColorFilter(mSendMessageIconColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||
isSendingMessage = false;
|
||||
}
|
||||
});
|
||||
mLemmyPrivateMessageAPI.sendPrivateMessage(mAccessToken, replyTo.getCreatorId(), mEditText.getText().toString(), new LemmyPrivateMessageAPI.PrivateMessageSentListener() {
|
||||
|
||||
@Override
|
||||
public void onPrivateMessageSentSuccess(@NonNull PrivateMessage privateMessage) {
|
||||
if (mAdapter != null) {
|
||||
mAdapter.addReply(privateMessage);
|
||||
}
|
||||
goToBottom();
|
||||
mEditText.setText("");
|
||||
isSendingMessage = false;
|
||||
EventBus.getDefault().post(new RepliedToPrivateMessageEvent(privateMessage, getIntent().getIntExtra(EXTRA_MESSAGE_POSITION, -1)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPrivateMessageSentError() {
|
||||
Snackbar.make(mCoordinatorLayout, R.string.reply_message_failed, Snackbar.LENGTH_LONG).show();
|
||||
mSendImageView.setColorFilter(mSendMessageIconColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||
isSendingMessage = false;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
StringBuilder fullnames = new StringBuilder();
|
||||
if (privateMessage.isNew()) {
|
||||
fullnames.append(privateMessage.getFullname()).append(",");
|
||||
}
|
||||
|
||||
if (replies != null && !replies.isEmpty()) {
|
||||
for (Message m : replies) {
|
||||
if (m.isNew()) {
|
||||
for (PrivateMessage m : replies) {
|
||||
if (!m.getRead()) {
|
||||
fullnames.append(m).append(",");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,12 +3,14 @@ package eu.toldi.infinityforlemmy.activities;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Menu;
|
||||
@@ -18,12 +20,14 @@ import android.view.ViewTreeObserver;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
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;
|
||||
@@ -36,6 +40,7 @@ import androidx.viewpager2.widget.ViewPager2;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.RequestManager;
|
||||
import com.bumptech.glide.request.RequestOptions;
|
||||
import com.evernote.android.state.State;
|
||||
import com.google.android.material.appbar.AppBarLayout;
|
||||
import com.google.android.material.appbar.CollapsingToolbarLayout;
|
||||
import com.google.android.material.appbar.MaterialToolbar;
|
||||
@@ -82,6 +87,8 @@ import eu.toldi.infinityforlemmy.bottomsheetfragments.RandomBottomSheetFragment;
|
||||
import eu.toldi.infinityforlemmy.bottomsheetfragments.SortTimeBottomSheetFragment;
|
||||
import eu.toldi.infinityforlemmy.bottomsheetfragments.SortTypeBottomSheetFragment;
|
||||
import eu.toldi.infinityforlemmy.bottomsheetfragments.UrlMenuBottomSheetFragment;
|
||||
import eu.toldi.infinityforlemmy.community.BlockCommunity;
|
||||
import eu.toldi.infinityforlemmy.community.CommunityStats;
|
||||
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||
import eu.toldi.infinityforlemmy.customviews.NavigationWrapper;
|
||||
import eu.toldi.infinityforlemmy.customviews.slidr.Slidr;
|
||||
@@ -162,12 +169,26 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
||||
TextView communityFullNameTextView;
|
||||
@BindView(R.id.subscriber_count_text_view_view_subreddit_detail_activity)
|
||||
TextView nSubscribersTextView;
|
||||
@BindView(R.id.online_subscriber_count_text_view_view_subreddit_detail_activity)
|
||||
TextView nOnlineSubscribersTextView;
|
||||
@BindView(R.id.since_text_view_view_subreddit_detail_activity)
|
||||
TextView sinceTextView;
|
||||
@BindView(R.id.creation_time_text_view_view_subreddit_detail_activity)
|
||||
TextView creationTimeTextView;
|
||||
@BindView(R.id.active_user_count_text_view_view_subreddit_detail_activity)
|
||||
TextView nActiveUsersTextView;
|
||||
@BindView(R.id.post_count_text_view_view_subreddit_detail_activity)
|
||||
TextView nPostsTextView;
|
||||
@BindView(R.id.comment_count_text_view_view_subreddit_detail_activity)
|
||||
TextView nCommentsTextView;
|
||||
|
||||
@BindView(R.id.subscriber_count_image_view_view_subreddit_detail_activity)
|
||||
ImageView nSubscribersImageView;
|
||||
@BindView(R.id.active_user_count_image_view_view_subreddit_detail_activity)
|
||||
ImageView nActiveUsersImageView;
|
||||
@BindView(R.id.post_count_image_view_view_subreddit_detail_activity)
|
||||
ImageView nPostsImageView;
|
||||
@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;
|
||||
@Inject
|
||||
@@ -210,6 +231,11 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
||||
private String communityName;
|
||||
|
||||
private int communityId;
|
||||
|
||||
@State
|
||||
SubredditData communityData;
|
||||
@State
|
||||
CommunityStats mCommunityStats;
|
||||
private String description;
|
||||
|
||||
private String qualifiedName;
|
||||
@@ -235,6 +261,8 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
||||
private int fabOption;
|
||||
private MaterialAlertDialogBuilder nsfwWarningBuilder;
|
||||
|
||||
private boolean showStatistics;
|
||||
|
||||
private boolean hideSubredditDescription;
|
||||
|
||||
@Override
|
||||
@@ -248,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),
|
||||
@@ -360,19 +389,33 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
||||
mMessageFullname = savedInstanceState.getInt(MESSAGE_FULLNAME_STATE);
|
||||
mNewAccountName = savedInstanceState.getString(NEW_ACCOUNT_NAME_STATE);
|
||||
|
||||
if (mFetchSubredditInfoSuccess) {
|
||||
nOnlineSubscribersTextView.setText(getString(R.string.online_subscribers_number_detail, mNCurrentOnlineSubscribers));
|
||||
}
|
||||
}
|
||||
|
||||
checkNewAccountAndBindView();
|
||||
|
||||
fetchSubredditData();
|
||||
if (communityName != null) {
|
||||
if (communityData != null) {
|
||||
setupVisibleElements();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
Log.e("ViewSubredditDetail", "onStart");
|
||||
if (communityData != null) {
|
||||
setupVisibleElements();
|
||||
} else {
|
||||
fetchSubredditData();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
mFetchSubredditInfoSuccess = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (sectionsPagerAdapter != null) {
|
||||
@@ -414,9 +457,13 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
||||
subscribeSubredditChip.setTextColor(mCustomThemeWrapper.getChipTextColor());
|
||||
int primaryTextColor = mCustomThemeWrapper.getPrimaryTextColor();
|
||||
nSubscribersTextView.setTextColor(primaryTextColor);
|
||||
nOnlineSubscribersTextView.setTextColor(primaryTextColor);
|
||||
sinceTextView.setTextColor(primaryTextColor);
|
||||
creationTimeTextView.setTextColor(primaryTextColor);
|
||||
nActiveUsersTextView.setTextColor(primaryTextColor);
|
||||
nPostsTextView.setTextColor(primaryTextColor);
|
||||
nCommentsTextView.setTextColor(primaryTextColor);
|
||||
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);
|
||||
descriptionTextView.setTextColor(primaryTextColor);
|
||||
navigationWrapper.applyCustomTheme(mCustomThemeWrapper.getBottomAppBarIconColor(), mCustomThemeWrapper.getBottomAppBarBackgroundColor());
|
||||
applyTabLayoutTheme(tabLayout);
|
||||
@@ -425,9 +472,9 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
||||
subredditNameTextView.setTypeface(typeface);
|
||||
subscribeSubredditChip.setTypeface(typeface);
|
||||
nSubscribersTextView.setTypeface(typeface);
|
||||
nOnlineSubscribersTextView.setTypeface(typeface);
|
||||
sinceTextView.setTypeface(typeface);
|
||||
creationTimeTextView.setTypeface(typeface);
|
||||
nActiveUsersTextView.setTypeface(typeface);
|
||||
nPostsTextView.setTypeface(typeface);
|
||||
nCommentsTextView.setTypeface(typeface);
|
||||
descriptionTextView.setTypeface(typeface);
|
||||
}
|
||||
unsubscribedColor = mCustomThemeWrapper.getUnsubscribed();
|
||||
@@ -466,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() {
|
||||
@@ -551,7 +598,13 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
||||
communityFullNameTextView.setText(qualifiedName);
|
||||
String nSubscribers = getString(R.string.subscribers_number_detail, subredditData.getNSubscribers());
|
||||
nSubscribersTextView.setText(nSubscribers);
|
||||
creationTimeTextView.setText(subredditData.getCreatedUTC());
|
||||
|
||||
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()));
|
||||
}
|
||||
description = subredditData.getDescription();
|
||||
|
||||
|
||||
@@ -690,14 +743,15 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
||||
qualifiedName = LemmyUtils.actorID2FullName(communityData.getActorId());
|
||||
if (communityName == null) {
|
||||
communityName = communityData.getTitle();
|
||||
|
||||
setupVisibleElements();
|
||||
}
|
||||
mCommunityStats = communityData.getCommunityStats();
|
||||
setupVisibleElements();
|
||||
communityId = communityData.getId();
|
||||
ViewSubredditDetailActivity.this.communityData = communityData;
|
||||
setupSubscribeChip();
|
||||
|
||||
mNCurrentOnlineSubscribers = nCurrentOnlineSubscribers;
|
||||
nOnlineSubscribersTextView.setText(getString(R.string.online_subscribers_number_detail, nCurrentOnlineSubscribers));
|
||||
|
||||
InsertSubredditData.insertSubredditData(mExecutor, new Handler(), mRedditDataRoomDatabase,
|
||||
communityData, () -> mFetchSubredditInfoSuccess = true);
|
||||
}
|
||||
@@ -730,6 +784,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
||||
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_PROFILE: {
|
||||
Intent intent = new Intent(this, ViewUserDetailActivity.class);
|
||||
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, mAccountName);
|
||||
intent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, mAccountQualifiedName);
|
||||
startActivity(intent);
|
||||
break;
|
||||
}
|
||||
@@ -1123,6 +1178,11 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.view_subreddit_detail_activity, menu);
|
||||
if (communityData != null && communityData.isBlocked()) {
|
||||
menu.findItem(R.id.block_community_view_subreddit_detail_activity).setVisible(false);
|
||||
} else {
|
||||
menu.findItem(R.id.unblock_community_view_subreddit_detail_activity).setVisible(false);
|
||||
}
|
||||
applyMenuItemTheme(menu);
|
||||
return true;
|
||||
}
|
||||
@@ -1151,22 +1211,6 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
||||
PostLayoutBottomSheetFragment postLayoutBottomSheetFragment = new PostLayoutBottomSheetFragment();
|
||||
postLayoutBottomSheetFragment.show(getSupportFragmentManager(), postLayoutBottomSheetFragment.getTag());
|
||||
return true;
|
||||
} else if (itemId == R.id.action_select_user_flair_view_subreddit_detail_activity) {
|
||||
if (mAccessToken == null) {
|
||||
Toast.makeText(this, R.string.login_first, Toast.LENGTH_SHORT).show();
|
||||
return true;
|
||||
}
|
||||
Intent selectUserFlairIntent = new Intent(this, SelectUserFlairActivity.class);
|
||||
selectUserFlairIntent.putExtra(SelectUserFlairActivity.EXTRA_SUBREDDIT_NAME, communityName);
|
||||
startActivity(selectUserFlairIntent);
|
||||
return true;
|
||||
} else if (itemId == R.id.action_add_to_multireddit_view_subreddit_detail_activity) {
|
||||
if (mAccessToken == null) {
|
||||
Toast.makeText(this, R.string.login_first, Toast.LENGTH_SHORT).show();
|
||||
return true;
|
||||
}
|
||||
Intent intent = new Intent(this, MultiredditSelectionActivity.class);
|
||||
startActivityForResult(intent, ADD_TO_MULTIREDDIT_REQUEST_CODE);
|
||||
} else if (itemId == R.id.action_add_to_post_filter_view_subreddit_detail_activity) {
|
||||
Intent intent = new Intent(this, PostFilterPreferenceActivity.class);
|
||||
intent.putExtra(PostFilterPreferenceActivity.EXTRA_SUBREDDIT_NAME, communityName);
|
||||
@@ -1176,23 +1220,59 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
||||
Intent shareIntent = new Intent(Intent.ACTION_SEND);
|
||||
shareIntent.setType("text/plain");
|
||||
String baseURL = mRetrofit.getBaseURL().endsWith("/") ? mRetrofit.getBaseURL() : mRetrofit.getBaseURL() + "/";
|
||||
shareIntent.putExtra(Intent.EXTRA_TEXT, baseURL + "/" + qualifiedName);
|
||||
shareIntent.putExtra(Intent.EXTRA_TEXT, baseURL + "c/" + qualifiedName);
|
||||
if (shareIntent.resolveActivity(getPackageManager()) != null) {
|
||||
startActivity(Intent.createChooser(shareIntent, getString(R.string.share)));
|
||||
} else {
|
||||
Toast.makeText(this, R.string.no_app, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
return true;
|
||||
} else if (itemId == R.id.action_go_to_wiki_view_subreddit_detail_activity) {
|
||||
Intent wikiIntent = new Intent(this, WikiActivity.class);
|
||||
wikiIntent.putExtra(WikiActivity.EXTRA_SUBREDDIT_NAME, communityName);
|
||||
wikiIntent.putExtra(WikiActivity.EXTRA_WIKI_PATH, "index");
|
||||
startActivity(wikiIntent);
|
||||
return true;
|
||||
} else if (itemId == R.id.action_contact_mods_view_subreddit_detail_activity) {
|
||||
Intent intent = new Intent(this, SendPrivateMessageActivity.class);
|
||||
intent.putExtra(SendPrivateMessageActivity.EXTRA_RECIPIENT_USERNAME, "r/" + communityName);
|
||||
startActivity(intent);
|
||||
/* Intent intent = new Intent(this, SendPrivateMessageActivity.class);
|
||||
intent.putExtra(SendPrivateMessageActivity.EXTRA_RECIPIENT_USERNAME, "r/" + communityName);*/
|
||||
//startActivity(intent);
|
||||
return true;
|
||||
} else if (itemId == R.id.block_community_view_subreddit_detail_activity) {
|
||||
if (mAccessToken == null) {
|
||||
Toast.makeText(this, R.string.login_first, Toast.LENGTH_SHORT).show();
|
||||
return true;
|
||||
}
|
||||
new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme)
|
||||
.setTitle(R.string.block_community)
|
||||
.setMessage(R.string.are_you_sure)
|
||||
.setPositiveButton(R.string.yes, (dialogInterface, i)
|
||||
-> BlockCommunity.INSTANCE.blockCommunity(mRetrofit.getRetrofit(), communityId, mAccessToken, new BlockCommunity.BlockCommunityListener() {
|
||||
@Override
|
||||
public void onBlockCommunitySuccess() {
|
||||
communityData.setBlocked(true);
|
||||
Toast.makeText(ViewSubredditDetailActivity.this, R.string.block_community_success, Toast.LENGTH_SHORT).show();
|
||||
ViewSubredditDetailActivity.this.invalidateOptionsMenu();
|
||||
sectionsPagerAdapter.refresh(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockCommunityError() {
|
||||
Toast.makeText(ViewSubredditDetailActivity.this, R.string.block_community_failed, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}))
|
||||
.setNegativeButton(R.string.no, null)
|
||||
.show();
|
||||
return true;
|
||||
} else if (itemId == R.id.unblock_community_view_subreddit_detail_activity) {
|
||||
BlockCommunity.INSTANCE.unBlockCommunity(mRetrofit.getRetrofit(), communityId, mAccessToken, new BlockCommunity.BlockCommunityListener() {
|
||||
@Override
|
||||
public void onBlockCommunitySuccess() {
|
||||
communityData.setBlocked(false);
|
||||
Toast.makeText(ViewSubredditDetailActivity.this, R.string.unblock_community_success, Toast.LENGTH_SHORT).show();
|
||||
ViewSubredditDetailActivity.this.invalidateOptionsMenu();
|
||||
sectionsPagerAdapter.refresh(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockCommunityError() {
|
||||
Toast.makeText(ViewSubredditDetailActivity.this, R.string.unblock_community_failed, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -1285,27 +1365,27 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
||||
break;
|
||||
case PostTypeBottomSheetFragment.TYPE_LINK:
|
||||
intent = new Intent(this, PostLinkActivity.class);
|
||||
intent.putExtra(PostLinkActivity.EXTRA_SUBREDDIT_NAME, communityName);
|
||||
intent.putExtra(PostLinkActivity.EXTRA_SUBREDDIT_NAME, qualifiedName);
|
||||
startActivity(intent);
|
||||
break;
|
||||
case PostTypeBottomSheetFragment.TYPE_IMAGE:
|
||||
intent = new Intent(this, PostImageActivity.class);
|
||||
intent.putExtra(PostImageActivity.EXTRA_SUBREDDIT_NAME, communityName);
|
||||
intent.putExtra(PostImageActivity.EXTRA_SUBREDDIT_NAME, qualifiedName);
|
||||
startActivity(intent);
|
||||
break;
|
||||
case PostTypeBottomSheetFragment.TYPE_VIDEO:
|
||||
intent = new Intent(this, PostVideoActivity.class);
|
||||
intent.putExtra(PostVideoActivity.EXTRA_SUBREDDIT_NAME, communityName);
|
||||
intent.putExtra(PostVideoActivity.EXTRA_SUBREDDIT_NAME, qualifiedName);
|
||||
startActivity(intent);
|
||||
break;
|
||||
case PostTypeBottomSheetFragment.TYPE_GALLERY:
|
||||
intent = new Intent(this, PostGalleryActivity.class);
|
||||
intent.putExtra(PostGalleryActivity.EXTRA_SUBREDDIT_NAME, communityName);
|
||||
intent.putExtra(PostGalleryActivity.EXTRA_SUBREDDIT_NAME, qualifiedName);
|
||||
startActivity(intent);
|
||||
break;
|
||||
case PostTypeBottomSheetFragment.TYPE_POLL:
|
||||
intent = new Intent(this, PostPollActivity.class);
|
||||
intent.putExtra(PostPollActivity.EXTRA_SUBREDDIT_NAME, communityName);
|
||||
intent.putExtra(PostPollActivity.EXTRA_SUBREDDIT_NAME, qualifiedName);
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
@@ -1438,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;
|
||||
}
|
||||
@@ -1496,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) -> {
|
||||
@@ -1517,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;
|
||||
}
|
||||
@@ -1530,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) -> {
|
||||
@@ -1611,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;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
@@ -20,12 +21,15 @@ import android.view.ViewTreeObserver;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
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;
|
||||
@@ -52,6 +56,7 @@ import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
@@ -71,11 +76,14 @@ import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
|
||||
import eu.toldi.infinityforlemmy.RetrofitHolder;
|
||||
import eu.toldi.infinityforlemmy.SortType;
|
||||
import eu.toldi.infinityforlemmy.SortTypeSelectionCallback;
|
||||
import eu.toldi.infinityforlemmy.account.FetchBlockedThings;
|
||||
import eu.toldi.infinityforlemmy.adapters.SubredditAutocompleteRecyclerViewAdapter;
|
||||
import eu.toldi.infinityforlemmy.apis.RedditAPI;
|
||||
import eu.toldi.infinityforlemmy.asynctasks.AddSubredditOrUserToMultiReddit;
|
||||
import eu.toldi.infinityforlemmy.asynctasks.CheckIsFollowingUser;
|
||||
import eu.toldi.infinityforlemmy.asynctasks.SwitchAccount;
|
||||
import eu.toldi.infinityforlemmy.blockedcommunity.BlockedCommunityData;
|
||||
import eu.toldi.infinityforlemmy.blockeduser.BlockedUserData;
|
||||
import eu.toldi.infinityforlemmy.bottomsheetfragments.CopyTextBottomSheetFragment;
|
||||
import eu.toldi.infinityforlemmy.bottomsheetfragments.FABMoreOptionsBottomSheetFragment;
|
||||
import eu.toldi.infinityforlemmy.bottomsheetfragments.PostLayoutBottomSheetFragment;
|
||||
@@ -101,11 +109,13 @@ import eu.toldi.infinityforlemmy.post.PostPagingSource;
|
||||
import eu.toldi.infinityforlemmy.readpost.InsertReadPost;
|
||||
import eu.toldi.infinityforlemmy.subreddit.ParseSubredditData;
|
||||
import eu.toldi.infinityforlemmy.subreddit.SubredditData;
|
||||
import eu.toldi.infinityforlemmy.user.BasicUserInfo;
|
||||
import eu.toldi.infinityforlemmy.user.BlockUser;
|
||||
import eu.toldi.infinityforlemmy.user.FetchUserData;
|
||||
import eu.toldi.infinityforlemmy.user.UserDao;
|
||||
import eu.toldi.infinityforlemmy.user.UserData;
|
||||
import eu.toldi.infinityforlemmy.user.UserFollowing;
|
||||
import eu.toldi.infinityforlemmy.user.UserStats;
|
||||
import eu.toldi.infinityforlemmy.user.UserViewModel;
|
||||
import eu.toldi.infinityforlemmy.utils.APIUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.LemmyUtils;
|
||||
@@ -141,6 +151,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
||||
private static final String FETCH_USER_INFO_STATE = "FSIS";
|
||||
private static final String MESSAGE_FULLNAME_STATE = "MFS";
|
||||
private static final String NEW_ACCOUNT_NAME_STATE = "NANS";
|
||||
private static final String NEW_ACCOUNT_QUALIFIED_NAME_STATE = "NAQNS";
|
||||
|
||||
@BindView(R.id.coordinator_layout_view_user_detail_activity)
|
||||
CoordinatorLayout coordinatorLayout;
|
||||
@@ -165,11 +176,40 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
||||
|
||||
@BindView(R.id.user_qualified_name_text_view_view_user_detail_activity)
|
||||
TextView qualifiedNameTextView;
|
||||
|
||||
@BindView(R.id.loading_user_progress_indicator_view_user_detail_activity)
|
||||
ProgressBar progressBar;
|
||||
@BindView(R.id.subscribe_user_chip_view_user_detail_activity)
|
||||
Chip subscribeUserChip;
|
||||
@BindView(R.id.karma_text_view_view_user_detail_activity)
|
||||
TextView karmaTextView;
|
||||
@BindView(R.id.cakeday_text_view_view_user_detail_activity)
|
||||
|
||||
@BindView(R.id.post_count_text_view_view_user_detail_activity)
|
||||
TextView postCountTextView;
|
||||
|
||||
@BindView(R.id.comment_count_text_view_view_user_detail_activity)
|
||||
TextView commentCountTextView;
|
||||
|
||||
@BindView(R.id.upvote_count_post_text_view_view_user_detail_activity)
|
||||
TextView upvoteCountPostTextView;
|
||||
|
||||
@BindView(R.id.upvote_count_comment_text_view_view_user_detail_activity)
|
||||
TextView upvoteCountCommentTextView;
|
||||
|
||||
@BindView(R.id.posts_count_icon_image_view_view_user_detail_activity)
|
||||
ImageView postsCountIconImageView;
|
||||
@BindView(R.id.comments_count_icon_image_view_view_user_detail_activity)
|
||||
ImageView commentsCountIconImageView;
|
||||
|
||||
@BindView(R.id.upvote_count_posts_icon_image_view_view_user_detail_activity)
|
||||
ImageView postUpvoteCountIconImageView;
|
||||
@BindView(R.id.upvote_count_comments_icon_image_view_view_user_detail_activity)
|
||||
ImageView commentUpvoteCountIconImageView;
|
||||
@BindView(R.id.account_created_cake_icon_image_view_view_user_detail_activity)
|
||||
ImageView accountCreatedCakeIconImageView;
|
||||
|
||||
@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)
|
||||
TextView descriptionTextView;
|
||||
@@ -216,8 +256,12 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
||||
private String mAccountName;
|
||||
private String mAccountQualifiedName;
|
||||
private String username;
|
||||
|
||||
private String qualifiedName;
|
||||
private String description;
|
||||
|
||||
private boolean showStatistics;
|
||||
private boolean showScore;
|
||||
private boolean subscriptionReady = false;
|
||||
private boolean mFetchUserInfoSuccess = false;
|
||||
private int expandedTabTextColor;
|
||||
@@ -238,6 +282,8 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
||||
|
||||
private UserData mUserData;
|
||||
|
||||
private boolean isBlocked;
|
||||
|
||||
//private MaterialAlertDialogBuilder nsfwWarningBuilder;
|
||||
|
||||
@Override
|
||||
@@ -280,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);
|
||||
@@ -288,6 +336,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
||||
mFetchUserInfoSuccess = savedInstanceState.getBoolean(FETCH_USER_INFO_STATE);
|
||||
mMessageId = savedInstanceState.getInt(MESSAGE_FULLNAME_STATE);
|
||||
mNewAccountName = savedInstanceState.getString(NEW_ACCOUNT_NAME_STATE);
|
||||
qualifiedName = savedInstanceState.getString("qualified_name");
|
||||
}
|
||||
|
||||
checkNewAccountAndInitializeViewPager();
|
||||
@@ -299,9 +348,26 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
if (mUserData != null) {
|
||||
setupVisibleElements();
|
||||
} else {
|
||||
fetchUserInfo();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
mFetchUserInfoSuccess = false;
|
||||
}
|
||||
|
||||
private void setupVisibleElements() {
|
||||
Resources resources = getResources();
|
||||
String title = username;
|
||||
progressBar.setVisibility(View.GONE);
|
||||
userNameTextView.setText(title);
|
||||
qualifiedNameTextView.setText(qualifiedName);
|
||||
toolbar.setTitle(title);
|
||||
@@ -382,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() {
|
||||
@@ -559,8 +625,23 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
||||
getSupportActionBar().setTitle(userFullName);
|
||||
}
|
||||
String karma = "";//getString(R.string.karma_info_user_detail, userData.getTotalKarma(), userData.getLinkKarma(), userData.getCommentKarma());
|
||||
karmaTextView.setText(karma);
|
||||
cakedayTextView.setText(getString(R.string.cakeday_info, userData.getCakeday()));
|
||||
|
||||
cakedayTextView.setText((String) userData.getCakeday());
|
||||
UserStats userStats = mUserData.getStats();
|
||||
if (userStats != null && showStatistics) {
|
||||
userStatisticsBlock.setVisibility(View.VISIBLE);
|
||||
postCountTextView.setText(String.valueOf(userStats.getPostCount()));
|
||||
commentCountTextView.setText(String.valueOf(userStats.getCommentCount()));
|
||||
if (showScore) {
|
||||
upvoteCountPostTextView.setText(String.valueOf(userStats.getPostScore()));
|
||||
upvoteCountCommentTextView.setText(String.valueOf(userStats.getCommentScore()));
|
||||
} else {
|
||||
upvoteCountPostTextView.setVisibility(View.GONE);
|
||||
upvoteCountCommentTextView.setVisibility(View.GONE);
|
||||
postUpvoteCountIconImageView.setVisibility(View.GONE);
|
||||
commentUpvoteCountIconImageView.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
if (userData.getDescription() == null || userData.getDescription().equals("")) {
|
||||
descriptionTextView.setVisibility(View.GONE);
|
||||
@@ -628,7 +709,13 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
||||
unsubscribedColor = mCustomThemeWrapper.getUnsubscribed();
|
||||
subscribedColor = mCustomThemeWrapper.getSubscribed();
|
||||
userNameTextView.setTextColor(mCustomThemeWrapper.getUsername());
|
||||
karmaTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
|
||||
postCountTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
|
||||
upvoteCountPostTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
|
||||
commentCountTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
|
||||
upvoteCountCommentTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
|
||||
postsCountIconImageView.setColorFilter(mCustomThemeWrapper.getPrimaryTextColor(), PorterDuff.Mode.SRC_IN);
|
||||
commentsCountIconImageView.setColorFilter(mCustomThemeWrapper.getPrimaryTextColor(), PorterDuff.Mode.SRC_IN);
|
||||
accountCreatedCakeIconImageView.setColorFilter(mCustomThemeWrapper.getPrimaryTextColor(), PorterDuff.Mode.SRC_IN);
|
||||
cakedayTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
|
||||
navigationWrapper.applyCustomTheme(mCustomThemeWrapper.getBottomAppBarIconColor(), mCustomThemeWrapper.getBottomAppBarBackgroundColor());
|
||||
applyFABTheme(navigationWrapper.floatingActionButton, mSharedPreferences.getBoolean(SharedPreferencesUtils.USE_CIRCULAR_FAB, false));
|
||||
@@ -637,7 +724,10 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
||||
applyTabLayoutTheme(tabLayout);
|
||||
if (typeface != null) {
|
||||
userNameTextView.setTypeface(typeface);
|
||||
karmaTextView.setTypeface(typeface);
|
||||
postCountTextView.setTypeface(typeface);
|
||||
upvoteCountPostTextView.setTypeface(typeface);
|
||||
commentCountTextView.setTypeface(typeface);
|
||||
upvoteCountCommentTextView.setTypeface(typeface);
|
||||
cakedayTextView.setTypeface(typeface);
|
||||
subscribeUserChip.setTypeface(typeface);
|
||||
descriptionTextView.setTypeface(typeface);
|
||||
@@ -929,6 +1019,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
||||
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_PROFILE: {
|
||||
Intent intent = new Intent(this, ViewUserDetailActivity.class);
|
||||
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, mAccountName);
|
||||
intent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY,mAccountQualifiedName);
|
||||
startActivity(intent);
|
||||
break;
|
||||
}
|
||||
@@ -1083,8 +1174,27 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
||||
@Override
|
||||
public void onFetchUserDataSuccess(UserData userData, int inboxCount) {
|
||||
mUserData = userData;
|
||||
username = userData.getName();
|
||||
username = userData.getDisplayName();
|
||||
setupVisibleElements();
|
||||
FetchBlockedThings.fetchBlockedThings(mRetrofit.getRetrofit(), mAccessToken, mAccountQualifiedName, new FetchBlockedThings.FetchBlockedThingsListener() {
|
||||
|
||||
@Override
|
||||
public void onFetchBlockedThingsSuccess(List<BlockedUserData> blockedUsers, List<BlockedCommunityData> blockedCommunities) {
|
||||
for (BlockedUserData blockedUserData : blockedUsers) {
|
||||
if (blockedUserData.getQualifiedName().equals(qualifiedName)) {
|
||||
isBlocked = true;
|
||||
invalidateOptionsMenu();
|
||||
return;
|
||||
}
|
||||
}
|
||||
isBlocked = false;
|
||||
invalidateOptionsMenu();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFetchBlockedThingsFailure() {
|
||||
}
|
||||
});
|
||||
new ViewUserDetailActivity.InsertUserDataAsyncTask(mRedditDataRoomDatabase.userDao(), userData,
|
||||
() -> mFetchUserInfoSuccess = true).execute();
|
||||
}
|
||||
@@ -1127,6 +1237,12 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
||||
menu.findItem(R.id.action_block_user_view_user_detail_activity).setVisible(false);
|
||||
} else {
|
||||
menu.findItem(R.id.action_edit_profile_view_user_detail_activity).setVisible(false);
|
||||
if (isBlocked) {
|
||||
menu.findItem(R.id.action_block_user_view_user_detail_activity).setVisible(false);
|
||||
menu.findItem(R.id.action_unblock_user_view_user_detail_activity).setVisible(true);
|
||||
} else {
|
||||
menu.findItem(R.id.action_unblock_user_view_user_detail_activity).setVisible(false);
|
||||
}
|
||||
}
|
||||
applyMenuItemTheme(menu);
|
||||
return true;
|
||||
@@ -1161,7 +1277,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
||||
Intent shareIntent = new Intent(Intent.ACTION_SEND);
|
||||
shareIntent.setType("text/plain");
|
||||
String baseURL = mRetrofit.getBaseURL().endsWith("/") ? mRetrofit.getBaseURL() : mRetrofit.getBaseURL() + "/";
|
||||
shareIntent.putExtra(Intent.EXTRA_TEXT, baseURL + qualifiedName);
|
||||
shareIntent.putExtra(Intent.EXTRA_TEXT, baseURL + "u/" + qualifiedName);
|
||||
if (shareIntent.resolveActivity(getPackageManager()) != null) {
|
||||
startActivity(Intent.createChooser(shareIntent, getString(R.string.share)));
|
||||
} else {
|
||||
@@ -1175,16 +1291,9 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
||||
}
|
||||
|
||||
Intent pmIntent = new Intent(this, SendPrivateMessageActivity.class);
|
||||
pmIntent.putExtra(SendPrivateMessageActivity.EXTRA_RECIPIENT_USERNAME, username);
|
||||
pmIntent.putExtra(SendPrivateMessageActivity.EXTRA_RECIPIENT_USER_INFO, new BasicUserInfo(mUserData.getId(), username, qualifiedName, mUserData.getAvatar(), mUserData.getDisplayName()));
|
||||
startActivity(pmIntent);
|
||||
return true;
|
||||
} else if (itemId == R.id.action_add_to_multireddit_view_user_detail_activity) {
|
||||
if (mAccessToken == null) {
|
||||
Toast.makeText(this, R.string.login_first, Toast.LENGTH_SHORT).show();
|
||||
return true;
|
||||
}
|
||||
Intent intent = new Intent(this, MultiredditSelectionActivity.class);
|
||||
startActivityForResult(intent, ADD_TO_MULTIREDDIT_REQUEST_CODE);
|
||||
} else if (itemId == R.id.action_add_to_post_filter_view_user_detail_activity) {
|
||||
Intent intent = new Intent(this, PostFilterPreferenceActivity.class);
|
||||
intent.putExtra(PostFilterPreferenceActivity.EXTRA_USER_NAME, username);
|
||||
@@ -1205,10 +1314,13 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
||||
.setTitle(R.string.block_user)
|
||||
.setMessage(R.string.are_you_sure)
|
||||
.setPositiveButton(R.string.yes, (dialogInterface, i)
|
||||
-> BlockUser.blockUser(mOauthRetrofit, mAccessToken, username, new BlockUser.BlockUserListener() {
|
||||
-> BlockUser.blockUser(mRetrofit.getRetrofit(), mAccessToken, mUserData.getId(), true, new BlockUser.BlockUserListener() {
|
||||
@Override
|
||||
public void success() {
|
||||
Toast.makeText(ViewUserDetailActivity.this, R.string.block_user_success, Toast.LENGTH_SHORT).show();
|
||||
isBlocked = true;
|
||||
sectionsPagerAdapter.refresh();
|
||||
invalidateOptionsMenu();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1222,6 +1334,25 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
||||
} else if (itemId == R.id.action_edit_profile_view_user_detail_activity) {
|
||||
startActivity(new Intent(this, EditProfileActivity.class));
|
||||
return true;
|
||||
} else if (itemId == R.id.action_unblock_user_view_user_detail_activity) {
|
||||
if (mAccessToken == null) {
|
||||
Toast.makeText(this, R.string.login_first, Toast.LENGTH_SHORT).show();
|
||||
return true;
|
||||
}
|
||||
BlockUser.blockUser(mRetrofit.getRetrofit(), mAccessToken, mUserData.getId(), false, new BlockUser.BlockUserListener() {
|
||||
@Override
|
||||
public void success() {
|
||||
isBlocked = false;
|
||||
Toast.makeText(ViewUserDetailActivity.this, R.string.unblock_user_success, Toast.LENGTH_SHORT).show();
|
||||
sectionsPagerAdapter.refresh();
|
||||
invalidateOptionsMenu();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void failed() {
|
||||
Toast.makeText(ViewUserDetailActivity.this, R.string.unblock_user_failed, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -1270,6 +1401,8 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
||||
outState.putBoolean(FETCH_USER_INFO_STATE, mFetchUserInfoSuccess);
|
||||
outState.putInt(MESSAGE_FULLNAME_STATE, mMessageId);
|
||||
outState.putString(NEW_ACCOUNT_NAME_STATE, mNewAccountName);
|
||||
outState.putString(NEW_ACCOUNT_QUALIFIED_NAME_STATE, mAccountQualifiedName);
|
||||
outState.putString("qualified_name", qualifiedName);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1381,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;
|
||||
}
|
||||
@@ -1439,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) -> {
|
||||
@@ -1460,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;
|
||||
}
|
||||
@@ -1473,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) -> {
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
@@ -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>() {
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,385 @@
|
||||
package eu.toldi.infinityforlemmy.adapters;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.RequestManager;
|
||||
import com.bumptech.glide.request.RequestOptions;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import eu.toldi.infinityforlemmy.R;
|
||||
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
|
||||
import eu.toldi.infinityforlemmy.activities.BaseActivity;
|
||||
import eu.toldi.infinityforlemmy.activities.ViewSubredditDetailActivity;
|
||||
import eu.toldi.infinityforlemmy.blockedcommunity.BlockedCommunityData;
|
||||
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
||||
import me.zhanghai.android.fastscroll.PopupTextProvider;
|
||||
import pl.droidsonroids.gif.GifImageView;
|
||||
import retrofit2.Retrofit;
|
||||
|
||||
public class BlockedCommunitiesRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements PopupTextProvider {
|
||||
private static final int VIEW_TYPE_FAVORITE_SUBREDDIT_DIVIDER = 0;
|
||||
private static final int VIEW_TYPE_FAVORITE_SUBREDDIT = 1;
|
||||
private static final int VIEW_TYPE_SUBREDDIT_DIVIDER = 2;
|
||||
private static final int VIEW_TYPE_SUBREDDIT = 3;
|
||||
|
||||
private BaseActivity mActivity;
|
||||
private Executor mExecutor;
|
||||
private Retrofit mOauthRetrofit;
|
||||
private RedditDataRoomDatabase mRedditDataRoomDatabase;
|
||||
private List<BlockedCommunityData> mBlockedCommunityData;
|
||||
private List<BlockedCommunityData> mFavoriteBlockedCommunityData;
|
||||
private RequestManager glide;
|
||||
private ItemClickListener itemClickListener;
|
||||
|
||||
private String accessToken;
|
||||
private String username;
|
||||
private String userIconUrl;
|
||||
private boolean hasClearSelectionRow;
|
||||
|
||||
private int primaryTextColor;
|
||||
private int secondaryTextColor;
|
||||
|
||||
public BlockedCommunitiesRecyclerViewAdapter(BaseActivity activity, Executor executor, Retrofit oauthRetrofit,
|
||||
RedditDataRoomDatabase redditDataRoomDatabase,
|
||||
CustomThemeWrapper customThemeWrapper,
|
||||
String accessToken) {
|
||||
mActivity = activity;
|
||||
mExecutor = executor;
|
||||
glide = Glide.with(activity);
|
||||
mOauthRetrofit = oauthRetrofit;
|
||||
mRedditDataRoomDatabase = redditDataRoomDatabase;
|
||||
this.accessToken = accessToken;
|
||||
primaryTextColor = customThemeWrapper.getPrimaryTextColor();
|
||||
secondaryTextColor = customThemeWrapper.getSecondaryTextColor();
|
||||
}
|
||||
|
||||
public BlockedCommunitiesRecyclerViewAdapter(BaseActivity activity, Executor executor, Retrofit oauthRetrofit,
|
||||
RedditDataRoomDatabase redditDataRoomDatabase,
|
||||
CustomThemeWrapper customThemeWrapper,
|
||||
String accessToken, boolean hasClearSelectionRow,
|
||||
ItemClickListener itemClickListener) {
|
||||
this(activity, executor, oauthRetrofit, redditDataRoomDatabase, customThemeWrapper, accessToken);
|
||||
this.hasClearSelectionRow = hasClearSelectionRow;
|
||||
this.itemClickListener = itemClickListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
if (mFavoriteBlockedCommunityData != null && mFavoriteBlockedCommunityData.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 == mFavoriteBlockedCommunityData.size() + 2) {
|
||||
return VIEW_TYPE_SUBREDDIT_DIVIDER;
|
||||
} else if (position <= mFavoriteBlockedCommunityData.size() + 1) {
|
||||
return VIEW_TYPE_FAVORITE_SUBREDDIT;
|
||||
} else {
|
||||
return VIEW_TYPE_SUBREDDIT;
|
||||
}
|
||||
} else if (hasClearSelectionRow) {
|
||||
if (position == 0) {
|
||||
return VIEW_TYPE_SUBREDDIT;
|
||||
} else if (position == 1) {
|
||||
return VIEW_TYPE_SUBREDDIT;
|
||||
} else if (position == 2) {
|
||||
return VIEW_TYPE_FAVORITE_SUBREDDIT_DIVIDER;
|
||||
} else if (position == mFavoriteBlockedCommunityData.size() + 3) {
|
||||
return VIEW_TYPE_SUBREDDIT_DIVIDER;
|
||||
} else if (position <= mFavoriteBlockedCommunityData.size() + 2) {
|
||||
return VIEW_TYPE_FAVORITE_SUBREDDIT;
|
||||
} else {
|
||||
return VIEW_TYPE_SUBREDDIT;
|
||||
}
|
||||
} else {
|
||||
if (position == 0) {
|
||||
return VIEW_TYPE_FAVORITE_SUBREDDIT_DIVIDER;
|
||||
} else if (position == mFavoriteBlockedCommunityData.size() + 1) {
|
||||
return VIEW_TYPE_SUBREDDIT_DIVIDER;
|
||||
} else if (position <= mFavoriteBlockedCommunityData.size()) {
|
||||
return VIEW_TYPE_FAVORITE_SUBREDDIT;
|
||||
} else {
|
||||
return VIEW_TYPE_SUBREDDIT;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return VIEW_TYPE_SUBREDDIT;
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
|
||||
switch (i) {
|
||||
case VIEW_TYPE_FAVORITE_SUBREDDIT_DIVIDER:
|
||||
return new FavoriteSubredditsDividerViewHolder(LayoutInflater.from(viewGroup.getContext())
|
||||
.inflate(R.layout.item_favorite_thing_divider, viewGroup, false));
|
||||
case VIEW_TYPE_FAVORITE_SUBREDDIT:
|
||||
return new FavoriteSubredditViewHolder(LayoutInflater.from(viewGroup.getContext())
|
||||
.inflate(R.layout.item_subscribed_thing, viewGroup, false));
|
||||
case VIEW_TYPE_SUBREDDIT_DIVIDER:
|
||||
return new AllSubredditsDividerViewHolder(LayoutInflater.from(viewGroup.getContext())
|
||||
.inflate(R.layout.item_favorite_thing_divider, viewGroup, false));
|
||||
default:
|
||||
return new SubredditViewHolder(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 SubredditViewHolder) {
|
||||
String name;
|
||||
String fullname = "";
|
||||
String iconUrl;
|
||||
|
||||
if (hasClearSelectionRow && viewHolder.getBindingAdapterPosition() == 0) {
|
||||
((SubredditViewHolder) viewHolder).subredditNameTextView.setText(R.string.all_communities);
|
||||
viewHolder.itemView.setOnClickListener(view -> itemClickListener.onClick(null));
|
||||
return;
|
||||
} else {
|
||||
int offset = hasClearSelectionRow ? 1 : 0;
|
||||
BlockedCommunityData communityData = mBlockedCommunityData.get(viewHolder.getBindingAdapterPosition() - offset);
|
||||
name = mBlockedCommunityData.get(viewHolder.getBindingAdapterPosition() - offset).getName();
|
||||
fullname = mBlockedCommunityData.get(viewHolder.getBindingAdapterPosition() - offset).getQualified_name();
|
||||
iconUrl = mBlockedCommunityData.get(viewHolder.getBindingAdapterPosition() - offset).getIconUrl();
|
||||
|
||||
if (itemClickListener != null) {
|
||||
viewHolder.itemView.setOnClickListener(view -> itemClickListener.onClick(communityData));
|
||||
}
|
||||
}
|
||||
|
||||
if (itemClickListener == null) {
|
||||
String finalFullname = fullname;
|
||||
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,
|
||||
finalFullname);
|
||||
mActivity.startActivity(intent);
|
||||
});
|
||||
}
|
||||
|
||||
if (iconUrl != null && !iconUrl.equals("")) {
|
||||
glide.load(iconUrl)
|
||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
||||
.error(glide.load(R.drawable.subreddit_default_icon)
|
||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
|
||||
.into(((SubredditViewHolder) viewHolder).iconGifImageView);
|
||||
} else {
|
||||
glide.load(R.drawable.subreddit_default_icon)
|
||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
||||
.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) {
|
||||
if (hasClearSelectionRow) {
|
||||
offset = 3;
|
||||
} else {
|
||||
offset = 2;
|
||||
}
|
||||
} else {
|
||||
offset = 1;
|
||||
}
|
||||
BlockedCommunityData communityData = mFavoriteBlockedCommunityData.get(viewHolder.getBindingAdapterPosition() - offset);
|
||||
String name = mFavoriteBlockedCommunityData.get(viewHolder.getBindingAdapterPosition() - offset).getName();
|
||||
String iconUrl = mFavoriteBlockedCommunityData.get(viewHolder.getBindingAdapterPosition() - offset).getIconUrl();
|
||||
|
||||
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);
|
||||
mActivity.startActivity(intent);
|
||||
});
|
||||
}
|
||||
|
||||
if (iconUrl != null && !iconUrl.equals("")) {
|
||||
glide.load(iconUrl)
|
||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
||||
.error(glide.load(R.drawable.subreddit_default_icon)
|
||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
|
||||
.into(((FavoriteSubredditViewHolder) viewHolder).iconGifImageView);
|
||||
} else {
|
||||
glide.load(R.drawable.subreddit_default_icon)
|
||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
||||
.into(((FavoriteSubredditViewHolder) viewHolder).iconGifImageView);
|
||||
}
|
||||
((FavoriteSubredditViewHolder) viewHolder).subredditNameTextView.setText(name);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
if (mBlockedCommunityData != null) {
|
||||
|
||||
if (itemClickListener != null) {
|
||||
return mBlockedCommunityData.size() > 0 ? mBlockedCommunityData.size() + ((hasClearSelectionRow) ? 1 : 0) : 0;
|
||||
}
|
||||
|
||||
return mBlockedCommunityData.size();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) {
|
||||
if (holder instanceof SubredditViewHolder) {
|
||||
glide.clear(((SubredditViewHolder) holder).iconGifImageView);
|
||||
} else if (holder instanceof FavoriteSubredditViewHolder) {
|
||||
glide.clear(((FavoriteSubredditViewHolder) holder).iconGifImageView);
|
||||
}
|
||||
}
|
||||
|
||||
public void setSubscribedSubreddits(List<BlockedCommunityData> subscribedSubreddits) {
|
||||
mBlockedCommunityData = subscribedSubreddits;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void setFavoriteSubscribedSubreddits(List<BlockedCommunityData> favoriteBlockedCommunityData) {
|
||||
mFavoriteBlockedCommunityData = favoriteBlockedCommunityData;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void addUser(String username, String userIconUrl) {
|
||||
this.username = username;
|
||||
this.userIconUrl = userIconUrl;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String getPopupText(int position) {
|
||||
switch (getItemViewType(position)) {
|
||||
case VIEW_TYPE_SUBREDDIT:
|
||||
if (hasClearSelectionRow && position == 0) {
|
||||
return "";
|
||||
} else if (itemClickListener != null && !hasClearSelectionRow && position == 0) {
|
||||
return "";
|
||||
} else if (hasClearSelectionRow && position == 1) {
|
||||
return "";
|
||||
} else {
|
||||
int offset;
|
||||
if (itemClickListener != null) {
|
||||
if (hasClearSelectionRow) {
|
||||
offset = (mFavoriteBlockedCommunityData != null && mFavoriteBlockedCommunityData.size() > 0) ?
|
||||
mFavoriteBlockedCommunityData.size() + 4 : 0;
|
||||
} else {
|
||||
offset = (mFavoriteBlockedCommunityData != null && mFavoriteBlockedCommunityData.size() > 0) ?
|
||||
mFavoriteBlockedCommunityData.size() + 3 : 0;
|
||||
}
|
||||
} else {
|
||||
offset = (mFavoriteBlockedCommunityData != null && mFavoriteBlockedCommunityData.size() > 0) ?
|
||||
mFavoriteBlockedCommunityData.size() + 2 : 0;
|
||||
}
|
||||
|
||||
return mBlockedCommunityData.get(position - offset).getName().substring(0, 1).toUpperCase();
|
||||
}
|
||||
case VIEW_TYPE_FAVORITE_SUBREDDIT:
|
||||
int offset;
|
||||
if (itemClickListener != null) {
|
||||
if (hasClearSelectionRow) {
|
||||
offset = 3;
|
||||
} else {
|
||||
offset = 2;
|
||||
}
|
||||
} else {
|
||||
offset = 1;
|
||||
}
|
||||
return mFavoriteBlockedCommunityData.get(position - offset).getName().substring(0, 1).toUpperCase();
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public interface ItemClickListener {
|
||||
void onClick(BlockedCommunityData subredditData);
|
||||
}
|
||||
|
||||
class SubredditViewHolder extends RecyclerView.ViewHolder {
|
||||
@BindView(R.id.thing_icon_gif_image_view_item_subscribed_thing)
|
||||
GifImageView iconGifImageView;
|
||||
@BindView(R.id.thing_name_text_view_item_subscribed_thing)
|
||||
TextView subredditNameTextView;
|
||||
|
||||
@BindView(R.id.thing_instance_text_view_item_subscribed_thing)
|
||||
TextView communityInstanceTextView;
|
||||
|
||||
SubredditViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
ButterKnife.bind(this, itemView);
|
||||
if (mActivity.typeface != null) {
|
||||
subredditNameTextView.setTypeface(mActivity.typeface);
|
||||
}
|
||||
subredditNameTextView.setTextColor(primaryTextColor);
|
||||
}
|
||||
}
|
||||
|
||||
class FavoriteSubredditViewHolder extends RecyclerView.ViewHolder {
|
||||
@BindView(R.id.thing_icon_gif_image_view_item_subscribed_thing)
|
||||
GifImageView iconGifImageView;
|
||||
@BindView(R.id.thing_name_text_view_item_subscribed_thing)
|
||||
TextView subredditNameTextView;
|
||||
|
||||
FavoriteSubredditViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
ButterKnife.bind(this, itemView);
|
||||
if (mActivity.typeface != null) {
|
||||
subredditNameTextView.setTypeface(mActivity.typeface);
|
||||
}
|
||||
subredditNameTextView.setTextColor(primaryTextColor);
|
||||
}
|
||||
}
|
||||
|
||||
class FavoriteSubredditsDividerViewHolder extends RecyclerView.ViewHolder {
|
||||
@BindView(R.id.divider_text_view_item_favorite_thing_divider)
|
||||
TextView dividerTextView;
|
||||
|
||||
FavoriteSubredditsDividerViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
ButterKnife.bind(this, itemView);
|
||||
if (mActivity.typeface != null) {
|
||||
dividerTextView.setTypeface(mActivity.typeface);
|
||||
}
|
||||
dividerTextView.setText(R.string.favorites);
|
||||
dividerTextView.setTextColor(secondaryTextColor);
|
||||
}
|
||||
}
|
||||
|
||||
class AllSubredditsDividerViewHolder extends RecyclerView.ViewHolder {
|
||||
@BindView(R.id.divider_text_view_item_favorite_thing_divider)
|
||||
TextView dividerTextView;
|
||||
|
||||
AllSubredditsDividerViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
ButterKnife.bind(this, itemView);
|
||||
if (mActivity.typeface != null) {
|
||||
dividerTextView.setTypeface(mActivity.typeface);
|
||||
}
|
||||
dividerTextView.setText(R.string.all);
|
||||
dividerTextView.setTextColor(secondaryTextColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,216 @@
|
||||
package eu.toldi.infinityforlemmy.adapters;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.RequestManager;
|
||||
import com.bumptech.glide.request.RequestOptions;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import eu.toldi.infinityforlemmy.R;
|
||||
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
|
||||
import eu.toldi.infinityforlemmy.activities.BaseActivity;
|
||||
import eu.toldi.infinityforlemmy.activities.ViewUserDetailActivity;
|
||||
import eu.toldi.infinityforlemmy.blockeduser.BlockedUserData;
|
||||
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
||||
import me.zhanghai.android.fastscroll.PopupTextProvider;
|
||||
import pl.droidsonroids.gif.GifImageView;
|
||||
import retrofit2.Retrofit;
|
||||
|
||||
public class BlockedUsersRecyclerViewAdapter 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<BlockedUserData> mBlockedUserData;
|
||||
private List<BlockedUserData> mFavoriteBlockedUserData;
|
||||
private BaseActivity mActivity;
|
||||
private Executor mExecutor;
|
||||
private Retrofit mOauthRetrofit;
|
||||
private RedditDataRoomDatabase mRedditDataRoomDatabase;
|
||||
private String mAccessToken;
|
||||
private RequestManager glide;
|
||||
private int mPrimaryTextColor;
|
||||
private int mSecondaryTextColor;
|
||||
|
||||
public BlockedUsersRecyclerViewAdapter(BaseActivity activity, Executor executor, Retrofit oauthRetrofit,
|
||||
RedditDataRoomDatabase redditDataRoomDatabase,
|
||||
CustomThemeWrapper customThemeWrapper,
|
||||
String accessToken) {
|
||||
mActivity = activity;
|
||||
mExecutor = executor;
|
||||
mOauthRetrofit = oauthRetrofit;
|
||||
mRedditDataRoomDatabase = redditDataRoomDatabase;
|
||||
mAccessToken = accessToken;
|
||||
glide = Glide.with(activity);
|
||||
mPrimaryTextColor = customThemeWrapper.getPrimaryTextColor();
|
||||
mSecondaryTextColor = customThemeWrapper.getSecondaryTextColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
if (mFavoriteBlockedUserData != null && mFavoriteBlockedUserData.size() > 0) {
|
||||
if (position == 0) {
|
||||
return VIEW_TYPE_FAVORITE_USER_DIVIDER;
|
||||
} else if (position == mFavoriteBlockedUserData.size() + 1) {
|
||||
return VIEW_TYPE_USER_DIVIDER;
|
||||
} else if (position <= mFavoriteBlockedUserData.size()) {
|
||||
return VIEW_TYPE_FAVORITE_USER;
|
||||
} else {
|
||||
return VIEW_TYPE_USER;
|
||||
}
|
||||
} else {
|
||||
return VIEW_TYPE_USER;
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
|
||||
switch (i) {
|
||||
case VIEW_TYPE_FAVORITE_USER_DIVIDER:
|
||||
return new FavoriteUsersDividerViewHolder(LayoutInflater.from(viewGroup.getContext())
|
||||
.inflate(R.layout.item_favorite_thing_divider, viewGroup, false));
|
||||
case VIEW_TYPE_USER_DIVIDER:
|
||||
return new AllUsersDividerViewHolder(LayoutInflater.from(viewGroup.getContext())
|
||||
.inflate(R.layout.item_favorite_thing_divider, viewGroup, false));
|
||||
default:
|
||||
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) {
|
||||
int offset = 0;
|
||||
|
||||
if (!mBlockedUserData.get(viewHolder.getBindingAdapterPosition() - offset).getAvatar().equals("")) {
|
||||
glide.load(mBlockedUserData.get(viewHolder.getBindingAdapterPosition() - offset).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(mBlockedUserData.get(viewHolder.getBindingAdapterPosition() - offset).getName());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
if (mBlockedUserData != null && mBlockedUserData.size() > 0) {
|
||||
return mBlockedUserData.size();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) {
|
||||
if (holder instanceof UserViewHolder) {
|
||||
glide.clear(((UserViewHolder) holder).iconGifImageView);
|
||||
}
|
||||
}
|
||||
|
||||
public void setSubscribedUsers(List<BlockedUserData> subscribedUsers) {
|
||||
mBlockedUserData = subscribedUsers;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void setFavoriteSubscribedUsers(List<BlockedUserData> favoriteSubscribedUsers) {
|
||||
mFavoriteBlockedUserData = favoriteSubscribedUsers;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String getPopupText(int position) {
|
||||
switch (getItemViewType(position)) {
|
||||
case VIEW_TYPE_USER:
|
||||
int offset = (mFavoriteBlockedUserData != null && mFavoriteBlockedUserData.size() > 0) ?
|
||||
mFavoriteBlockedUserData.size() + 2 : 0;
|
||||
return mBlockedUserData.get(position - offset).getName().substring(0, 1).toUpperCase();
|
||||
case VIEW_TYPE_FAVORITE_USER:
|
||||
return mFavoriteBlockedUserData.get(position - 1).getName().substring(0, 1).toUpperCase();
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
|
||||
UserViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
ButterKnife.bind(this, itemView);
|
||||
if (mActivity.typeface != null) {
|
||||
userNameTextView.setTypeface(mActivity.typeface);
|
||||
}
|
||||
userNameTextView.setTextColor(mPrimaryTextColor);
|
||||
|
||||
itemView.setOnClickListener(view -> {
|
||||
int offset = (mFavoriteBlockedUserData != null && mFavoriteBlockedUserData.size() > 0) ?
|
||||
mFavoriteBlockedUserData.size() + 2 : 0;
|
||||
int position = getBindingAdapterPosition() - offset;
|
||||
if (position >= 0 && mBlockedUserData.size() > position) {
|
||||
Intent intent = new Intent(mActivity, ViewUserDetailActivity.class);
|
||||
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, mBlockedUserData.get(position).getName());
|
||||
intent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, mBlockedUserData.get(position).getQualifiedName());
|
||||
mActivity.startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class FavoriteUsersDividerViewHolder extends RecyclerView.ViewHolder {
|
||||
@BindView(R.id.divider_text_view_item_favorite_thing_divider)
|
||||
TextView dividerTextView;
|
||||
|
||||
FavoriteUsersDividerViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
ButterKnife.bind(this, itemView);
|
||||
if (mActivity.typeface != null) {
|
||||
dividerTextView.setTypeface(mActivity.typeface);
|
||||
}
|
||||
dividerTextView.setText(R.string.favorites);
|
||||
dividerTextView.setTextColor(mSecondaryTextColor);
|
||||
}
|
||||
}
|
||||
|
||||
class AllUsersDividerViewHolder extends RecyclerView.ViewHolder {
|
||||
@BindView(R.id.divider_text_view_item_favorite_thing_divider)
|
||||
TextView dividerTextView;
|
||||
|
||||
AllUsersDividerViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
ButterKnife.bind(this, itemView);
|
||||
if (mActivity.typeface != null) {
|
||||
dividerTextView.setTypeface(mActivity.typeface);
|
||||
}
|
||||
dividerTextView.setText(R.string.all);
|
||||
dividerTextView.setTextColor(mSecondaryTextColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -10,6 +10,7 @@ import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.text.Spanned;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -38,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;
|
||||
@@ -94,11 +97,12 @@ 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;
|
||||
private String mAccountName;
|
||||
private String mAccountQualifiedName;
|
||||
|
||||
private Post mPost;
|
||||
private ArrayList<Comment> mVisibleComments;
|
||||
|
||||
@@ -124,12 +128,17 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
||||
private boolean mShowAuthorAvatar;
|
||||
private boolean mAlwaysShowChildCommentCount;
|
||||
private boolean mHideTheNumberOfVotes;
|
||||
private boolean mSeperateUpandDownvote;
|
||||
private boolean mHideDownvotes;
|
||||
private int mDepthThreshold;
|
||||
private CommentRecyclerViewAdapterCallback mCommentRecyclerViewAdapterCallback;
|
||||
private boolean isInitiallyLoading;
|
||||
private boolean isInitiallyLoadingFailed;
|
||||
private boolean mHasMoreComments;
|
||||
private boolean loadMoreCommentsFailed;
|
||||
|
||||
private boolean mHideUserInstance;
|
||||
private boolean mShowUserDisplayName;
|
||||
private Drawable expandDrawable;
|
||||
private Drawable collapseDrawable;
|
||||
|
||||
@@ -161,17 +170,18 @@ 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,
|
||||
SharedPreferences sharedPreferences,
|
||||
SharedPreferences currentAccountSharedPreferences,
|
||||
CommentRecyclerViewAdapterCallback commentRecyclerViewAdapterCallback) {
|
||||
mActivity = activity;
|
||||
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;
|
||||
@@ -213,7 +223,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
||||
miscPlugin, mCommentTextColor, commentSpoilerBackgroundColor, onLinkLongClickListener);
|
||||
recycledViewPool = new RecyclerView.RecycledViewPool();
|
||||
mAccessToken = accessToken;
|
||||
mAccountName = accountName;
|
||||
mAccountQualifiedName = accountName;
|
||||
mPost = post;
|
||||
mVisibleComments = new ArrayList<>();
|
||||
loadedComments = new HashSet<>();
|
||||
@@ -237,6 +247,10 @@ 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);
|
||||
|
||||
mCommentRecyclerViewAdapterCallback = commentRecyclerViewAdapterCallback;
|
||||
@@ -368,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()) {
|
||||
@@ -383,7 +397,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
||||
Drawable moderatorDrawable = Utils.getTintedDrawable(mActivity, R.drawable.ic_verified_user_14dp, mModeratorColor);
|
||||
((CommentViewHolder) holder).authorTextView.setCompoundDrawablesWithIntrinsicBounds(
|
||||
moderatorDrawable, null, null, null);
|
||||
} else if (comment.getAuthor().equals(mAccountName)) {
|
||||
} else if (comment.getAuthorQualifiedName().equals(mAccountQualifiedName)) {
|
||||
((CommentViewHolder) holder).authorTextView.setTextColor(mCurrentUserColor);
|
||||
Drawable currentUserDrawable = Utils.getTintedDrawable(mActivity, R.drawable.ic_current_user_14dp, mCurrentUserColor);
|
||||
((CommentViewHolder) holder).authorTextView.setCompoundDrawablesWithIntrinsicBounds(
|
||||
@@ -434,6 +448,10 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
||||
((CommentViewHolder) holder).mMarkwonAdapter.setMarkdown(mCommentMarkwon, comment.getCommentMarkdown());
|
||||
// noinspection NotifyDataSetChanged
|
||||
((CommentViewHolder) holder).mMarkwonAdapter.notifyDataSetChanged();
|
||||
if (mHideDownvotes) {
|
||||
((CommentViewHolder) holder).downvoteButton.setVisibility(View.GONE);
|
||||
((CommentViewHolder) holder).downvoteTextView.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if (!mHideTheNumberOfVotes) {
|
||||
String commentText = "";
|
||||
@@ -445,7 +463,21 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
||||
Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||
comment.getScore() + comment.getVoteType()));
|
||||
|
||||
((CommentViewHolder) holder).scoreTextView.setText(commentText);
|
||||
if (mSeperateUpandDownvote) {
|
||||
int upvotes = (comment.getVoteType() == 1) ? comment.getUpvotes() + 1 : comment.getUpvotes();
|
||||
int downvotes = (comment.getVoteType() == -1) ? comment.getDownvotes() + 1 : comment.getDownvotes();
|
||||
((CommentViewHolder) holder).downvoteTextView.setVisibility(View.VISIBLE);
|
||||
((CommentViewHolder) holder).scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, upvotes));
|
||||
((CommentViewHolder) holder).downvoteTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, downvotes));
|
||||
((CommentViewHolder) holder).scoreTextView.setGravity(Gravity.START);
|
||||
((CommentViewHolder) holder).scoreTextView.getLayoutParams().width = (int) (32 * mActivity.getResources().getDisplayMetrics().density);
|
||||
|
||||
((CommentViewHolder) holder).scoreTextView.setPadding(0, 0, 6, 0);
|
||||
((CommentViewHolder) holder).downvoteButton.setPadding(24, 0, 12, 0);
|
||||
((CommentViewHolder) holder).upvoteButton.setPadding(24, 0, 12, 0);
|
||||
} else {
|
||||
((CommentViewHolder) holder).scoreTextView.setText(commentText);
|
||||
}
|
||||
((CommentViewHolder) holder).topScoreTextView.setText(topScoreText);
|
||||
} else {
|
||||
((CommentViewHolder) holder).scoreTextView.setText(mActivity.getString(R.string.vote));
|
||||
@@ -485,13 +517,21 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
||||
.setColorFilter(mUpvotedColor, PorterDuff.Mode.SRC_IN);
|
||||
((CommentViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor);
|
||||
((CommentViewHolder) holder).topScoreTextView.setTextColor(mUpvotedColor);
|
||||
((CommentViewHolder) holder).downvoteTextView.setTextColor(mCommentIconAndInfoColor);
|
||||
break;
|
||||
case Comment.VOTE_TYPE_DOWNVOTE:
|
||||
((CommentViewHolder) holder).downvoteButton
|
||||
.setColorFilter(mDownvotedColor, PorterDuff.Mode.SRC_IN);
|
||||
((CommentViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor);
|
||||
if(mSeperateUpandDownvote) {
|
||||
((CommentViewHolder) holder).downvoteTextView.setTextColor(mDownvotedColor);
|
||||
((CommentViewHolder) holder).scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
||||
} else {
|
||||
((CommentViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor);
|
||||
}
|
||||
((CommentViewHolder) holder).topScoreTextView.setTextColor(mDownvotedColor);
|
||||
break;
|
||||
default:
|
||||
((CommentViewHolder) holder).downvoteTextView.setTextColor(mCommentIconAndInfoColor);
|
||||
}
|
||||
|
||||
if (mPost.isArchived()) {
|
||||
@@ -532,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) {
|
||||
@@ -615,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++) {
|
||||
@@ -646,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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -680,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);
|
||||
@@ -718,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.
|
||||
@@ -728,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);
|
||||
@@ -777,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);
|
||||
}
|
||||
|
||||
@@ -787,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;
|
||||
}
|
||||
}
|
||||
@@ -872,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());
|
||||
}
|
||||
@@ -1190,6 +1235,9 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
||||
ImageView upvoteButton;
|
||||
@BindView(R.id.score_text_view_item_post_comment)
|
||||
TextView scoreTextView;
|
||||
|
||||
@BindView(R.id.downvote_text_view_item_post_comment)
|
||||
TextView downvoteTextView;
|
||||
@BindView(R.id.down_vote_button_item_post_comment)
|
||||
ImageView downvoteButton;
|
||||
@BindView(R.id.placeholder_item_post_comment)
|
||||
@@ -1221,6 +1269,8 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
||||
constraintSet.clear(scoreTextView.getId(), ConstraintSet.END);
|
||||
constraintSet.clear(downvoteButton.getId(), ConstraintSet.START);
|
||||
constraintSet.clear(downvoteButton.getId(), ConstraintSet.END);
|
||||
constraintSet.clear(downvoteTextView.getId(), ConstraintSet.START);
|
||||
constraintSet.clear(downvoteTextView.getId(), ConstraintSet.END);
|
||||
constraintSet.clear(expandButton.getId(), ConstraintSet.START);
|
||||
constraintSet.clear(expandButton.getId(), ConstraintSet.END);
|
||||
constraintSet.clear(saveButton.getId(), ConstraintSet.START);
|
||||
@@ -1233,8 +1283,15 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
||||
constraintSet.connect(upvoteButton.getId(), ConstraintSet.START, placeholder.getId(), ConstraintSet.END);
|
||||
constraintSet.connect(scoreTextView.getId(), ConstraintSet.END, downvoteButton.getId(), ConstraintSet.START);
|
||||
constraintSet.connect(scoreTextView.getId(), ConstraintSet.START, upvoteButton.getId(), ConstraintSet.END);
|
||||
constraintSet.connect(downvoteButton.getId(), ConstraintSet.END, ConstraintSet.PARENT_ID, ConstraintSet.END);
|
||||
constraintSet.connect(downvoteButton.getId(), ConstraintSet.START, scoreTextView.getId(), ConstraintSet.END);
|
||||
if (!mSeperateUpandDownvote) {
|
||||
constraintSet.connect(downvoteButton.getId(), ConstraintSet.END, ConstraintSet.PARENT_ID, ConstraintSet.END);
|
||||
constraintSet.connect(downvoteButton.getId(), ConstraintSet.START, scoreTextView.getId(), ConstraintSet.END);
|
||||
} else {
|
||||
constraintSet.connect(downvoteButton.getId(), ConstraintSet.END, downvoteTextView.getId(), ConstraintSet.START);
|
||||
constraintSet.connect(downvoteButton.getId(), ConstraintSet.START, scoreTextView.getId(), ConstraintSet.END);
|
||||
constraintSet.connect(downvoteTextView.getId(), ConstraintSet.END, ConstraintSet.PARENT_ID, ConstraintSet.END);
|
||||
constraintSet.connect(downvoteTextView.getId(), ConstraintSet.START, downvoteButton.getId(), ConstraintSet.END);
|
||||
}
|
||||
constraintSet.connect(placeholder.getId(), ConstraintSet.END, upvoteButton.getId(), ConstraintSet.START);
|
||||
constraintSet.connect(placeholder.getId(), ConstraintSet.START, moreButton.getId(), ConstraintSet.END);
|
||||
constraintSet.connect(moreButton.getId(), ConstraintSet.START, expandButton.getId(), ConstraintSet.END);
|
||||
@@ -1267,6 +1324,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
||||
editedTextView.setTypeface(mActivity.typeface);
|
||||
awardsTextView.setTypeface(mActivity.typeface);
|
||||
scoreTextView.setTypeface(mActivity.typeface);
|
||||
downvoteTextView.setTypeface(mActivity.typeface);
|
||||
expandButton.setTypeface(mActivity.typeface);
|
||||
}
|
||||
|
||||
@@ -1298,11 +1356,13 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
||||
commentTimeTextView.setTextColor(mSecondaryTextColor);
|
||||
authorFlairTextView.setTextColor(mAuthorFlairTextColor);
|
||||
topScoreTextView.setTextColor(mSecondaryTextColor);
|
||||
downvoteTextView.setTextColor(mSecondaryTextColor);
|
||||
editedTextView.setTextColor(mSecondaryTextColor);
|
||||
awardsTextView.setTextColor(mSecondaryTextColor);
|
||||
commentDivider.setBackgroundColor(mDividerColor);
|
||||
upvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
||||
downvoteTextView.setTextColor(mCommentIconAndInfoColor);
|
||||
downvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||
moreButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||
expandButton.setTextColor(mCommentIconAndInfoColor);
|
||||
@@ -1326,7 +1386,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
||||
Comment comment = getCurrentComment(this);
|
||||
if (comment != null) {
|
||||
Bundle bundle = new Bundle();
|
||||
if (!mPost.isArchived() && !mPost.isLocked() && comment.getAuthor().equals(mAccountName)) {
|
||||
if (!mPost.isArchived() && !mPost.isLocked() && comment.getAuthorQualifiedName().equals(mAccountQualifiedName)) {
|
||||
bundle.putBoolean(CommentMoreBottomSheetFragment.EXTRA_EDIT_AND_DELETE_AVAILABLE, true);
|
||||
}
|
||||
bundle.putString(CommentMoreBottomSheetFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
||||
@@ -1409,18 +1469,28 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
||||
newVoteType = Integer.parseInt(APIUtils.DIR_UNVOTE);
|
||||
upvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
||||
downvoteTextView.setTextColor(mCommentIconAndInfoColor);
|
||||
topScoreTextView.setTextColor(mSecondaryTextColor);
|
||||
}
|
||||
|
||||
if (!mHideTheNumberOfVotes) {
|
||||
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||
comment.getScore() + comment.getVoteType()));
|
||||
if(mSeperateUpandDownvote){
|
||||
int upvoteCount = (comment.getVoteType() == 1) ? comment.getUpvotes() + 1 : comment.getUpvotes();
|
||||
int downvoteCount = (comment.getVoteType() == -1) ? comment.getDownvotes() + 1 : comment.getDownvotes();
|
||||
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||
upvoteCount));
|
||||
downvoteTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||
downvoteCount));
|
||||
}else {
|
||||
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||
comment.getScore() + comment.getVoteType()));
|
||||
}
|
||||
topScoreTextView.setText(mActivity.getString(R.string.top_score,
|
||||
Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||
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();
|
||||
@@ -1430,6 +1500,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
||||
upvoteButton.setColorFilter(mUpvotedColor, PorterDuff.Mode.SRC_IN);
|
||||
scoreTextView.setTextColor(mUpvotedColor);
|
||||
topScoreTextView.setTextColor(mUpvotedColor);
|
||||
downvoteTextView.setTextColor(mCommentIconAndInfoColor);
|
||||
}
|
||||
} else {
|
||||
comment.setVoteType(Comment.VOTE_TYPE_NO_VOTE);
|
||||
@@ -1437,14 +1508,24 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
||||
upvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
||||
topScoreTextView.setTextColor(mSecondaryTextColor);
|
||||
downvoteTextView.setTextColor(mCommentIconAndInfoColor);
|
||||
}
|
||||
}
|
||||
|
||||
if (currentPosition == position) {
|
||||
downvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||
if (!mHideTheNumberOfVotes) {
|
||||
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||
comment.getScore() + comment.getVoteType()));
|
||||
if(mSeperateUpandDownvote){
|
||||
int upvoteCount = (comment.getVoteType() == 1) ? comment.getUpvotes() + 1 : comment.getUpvotes();
|
||||
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||
upvoteCount));
|
||||
int downvoteCount = (comment.getVoteType() == -1) ? comment.getDownvotes() + 1 : comment.getDownvotes();
|
||||
downvoteTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||
downvoteCount));
|
||||
} else {
|
||||
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||
comment.getScore() + comment.getVoteType()));
|
||||
}
|
||||
topScoreTextView.setText(mActivity.getString(R.string.top_score,
|
||||
Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||
comment.getScore() + comment.getVoteType())));
|
||||
@@ -1482,27 +1563,41 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
||||
comment.setVoteType(Comment.VOTE_TYPE_DOWNVOTE);
|
||||
newVoteType = Integer.parseInt(APIUtils.DIR_DOWNVOTE);
|
||||
downvoteButton.setColorFilter(mDownvotedColor, PorterDuff.Mode.SRC_IN);
|
||||
scoreTextView.setTextColor(mDownvotedColor);
|
||||
if(mSeperateUpandDownvote){
|
||||
downvoteTextView.setTextColor(mDownvotedColor);
|
||||
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
||||
}else {
|
||||
scoreTextView.setTextColor(mDownvotedColor);
|
||||
}
|
||||
topScoreTextView.setTextColor(mDownvotedColor);
|
||||
} else {
|
||||
//Downvoted before
|
||||
comment.setVoteType(Comment.VOTE_TYPE_NO_VOTE);
|
||||
newVoteType = Integer.parseInt(APIUtils.DIR_UNVOTE);
|
||||
downvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||
downvoteTextView.setTextColor(mCommentIconAndInfoColor);
|
||||
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
||||
topScoreTextView.setTextColor(mSecondaryTextColor);
|
||||
}
|
||||
|
||||
if (!mHideTheNumberOfVotes) {
|
||||
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||
comment.getScore() + comment.getVoteType()));
|
||||
if(mSeperateUpandDownvote){
|
||||
int downvotes = (comment.getVoteType() == -1) ? comment.getDownvotes() +1 : comment.getDownvotes();
|
||||
int upvotes = (comment.getVoteType() == 1) ? comment.getUpvotes() +1 : comment.getUpvotes();
|
||||
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||
upvotes));
|
||||
downvoteTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, downvotes));
|
||||
} else {
|
||||
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||
comment.getScore() + comment.getVoteType()));
|
||||
}
|
||||
topScoreTextView.setText(mActivity.getString(R.string.top_score,
|
||||
Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||
comment.getScore() + comment.getVoteType())));
|
||||
}
|
||||
|
||||
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();
|
||||
@@ -1510,7 +1605,11 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
||||
comment.setVoteType(Comment.VOTE_TYPE_DOWNVOTE);
|
||||
if (currentPosition == position) {
|
||||
downvoteButton.setColorFilter(mDownvotedColor, PorterDuff.Mode.SRC_IN);
|
||||
scoreTextView.setTextColor(mDownvotedColor);
|
||||
if (mSeperateUpandDownvote) {
|
||||
downvoteTextView.setTextColor(mDownvotedColor);
|
||||
} else {
|
||||
scoreTextView.setTextColor(mDownvotedColor);
|
||||
}
|
||||
topScoreTextView.setTextColor(mDownvotedColor);
|
||||
}
|
||||
} else {
|
||||
@@ -1518,6 +1617,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
||||
if (currentPosition == position) {
|
||||
downvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
||||
downvoteTextView.setTextColor(mCommentIconAndInfoColor);
|
||||
topScoreTextView.setTextColor(mSecondaryTextColor);
|
||||
}
|
||||
}
|
||||
@@ -1525,8 +1625,17 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
||||
if (currentPosition == position) {
|
||||
upvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||
if (!mHideTheNumberOfVotes) {
|
||||
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||
comment.getScore() + comment.getVoteType()));
|
||||
if(mSeperateUpandDownvote){
|
||||
int downvotes = (comment.getVoteType() == -1) ? comment.getDownvotes() +1 : comment.getDownvotes();
|
||||
int upvotes = (comment.getVoteType() == 1) ? comment.getUpvotes() +1 : comment.getUpvotes();
|
||||
downvoteTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, downvotes));
|
||||
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||
upvotes));
|
||||
} else {
|
||||
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||
comment.getScore() + comment.getVoteType()));
|
||||
}
|
||||
|
||||
topScoreTextView.setText(mActivity.getString(R.string.top_score,
|
||||
Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||
comment.getScore() + comment.getVoteType())));
|
||||
@@ -1548,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);
|
||||
@@ -1569,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);
|
||||
@@ -1598,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);
|
||||
});
|
||||
|
||||
@@ -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;
|
||||
@@ -554,9 +552,6 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
|
||||
.into(((PostBaseViewHolder) holder).iconGifImageView);
|
||||
}
|
||||
|
||||
if (holder.getBindingAdapterPosition() >= 0) {
|
||||
post.setSubredditIconUrl(iconUrl);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else if (!post.getSubredditIconUrl().equals("")) {
|
||||
@@ -641,9 +636,12 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
|
||||
break;
|
||||
}
|
||||
|
||||
if (mPostType == PostPagingSource.TYPE_SUBREDDIT && !mDisplaySubredditName && post.isStickied()) {
|
||||
if (mPostType == PostPagingSource.TYPE_SUBREDDIT && !mDisplaySubredditName && post.isFeaturedInCommunity() || post.isFeaturedOnInstance()) {
|
||||
((PostBaseViewHolder) holder).stickiedPostImageView.setVisibility(View.VISIBLE);
|
||||
mGlide.load(R.drawable.ic_thumbtack_24dp).into(((PostBaseViewHolder) holder).stickiedPostImageView);
|
||||
if (post.isFeaturedOnInstance()) {
|
||||
((PostBaseViewHolder) holder).stickiedPostImageView.setColorFilter(mModeratorColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||
}
|
||||
}
|
||||
|
||||
if (post.isArchived()) {
|
||||
@@ -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,
|
||||
@@ -1079,9 +1077,6 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
|
||||
.into(((PostCompactBaseViewHolder) holder).iconGifImageView);
|
||||
}
|
||||
|
||||
if (holder.getBindingAdapterPosition() >= 0) {
|
||||
post.setSubredditIconUrl(iconUrl);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else if (!post.getSubredditIconUrl().equals("")) {
|
||||
@@ -1210,7 +1205,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
|
||||
}
|
||||
}
|
||||
|
||||
if (mPostType == PostPagingSource.TYPE_SUBREDDIT && !mDisplaySubredditName && post.isStickied()) {
|
||||
if (mPostType == PostPagingSource.TYPE_SUBREDDIT && !mDisplaySubredditName && post.isFeaturedInCommunity()) {
|
||||
((PostCompactBaseViewHolder) holder).stickiedPostImageView.setVisibility(View.VISIBLE);
|
||||
mGlide.load(R.drawable.ic_thumbtack_24dp).into(((PostCompactBaseViewHolder) holder).stickiedPostImageView);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.text.Spanned;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
@@ -56,6 +57,7 @@ import com.libRG.CustomTextView;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.inject.Provider;
|
||||
|
||||
@@ -65,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;
|
||||
@@ -98,7 +101,6 @@ import eu.toldi.infinityforlemmy.markdown.MarkdownUtils;
|
||||
import eu.toldi.infinityforlemmy.post.Post;
|
||||
import eu.toldi.infinityforlemmy.post.PostPagingSource;
|
||||
import eu.toldi.infinityforlemmy.utils.APIUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.LemmyUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.Utils;
|
||||
import eu.toldi.infinityforlemmy.videoautoplay.CacheManager;
|
||||
@@ -134,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;
|
||||
@@ -171,9 +172,15 @@ 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;
|
||||
|
||||
private boolean mSeperateUpvoteAndDownvote;
|
||||
private boolean mHideTheNumberOfComments;
|
||||
private boolean mSeparatePostAndComments;
|
||||
private boolean mHideDownvotes;
|
||||
private boolean mLegacyAutoplayVideoControllerUI;
|
||||
private boolean mEasierToWatchInFullScreen;
|
||||
private PostDetailRecyclerViewAdapterCallback mPostDetailRecyclerViewAdapterCallback;
|
||||
@@ -217,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,
|
||||
@@ -341,7 +348,11 @@ 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);
|
||||
mSeperateUpvoteAndDownvote = postDetailsSharedPreferences.getBoolean(SharedPreferencesUtils.POST_DETAIL_SEPARATE_UP_AND_DOWN_VOTES, true) && !mHideDownvotes;
|
||||
mHideTheNumberOfComments = postDetailsSharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_THE_NUMBER_OF_COMMENTS, false);
|
||||
|
||||
mPostDetailRecyclerViewAdapterCallback = postDetailRecyclerViewAdapterCallback;
|
||||
@@ -476,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)
|
||||
@@ -510,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)))
|
||||
@@ -522,8 +533,6 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
|
||||
.into(((PostDetailBaseViewHolder) holder).mIconGifImageView);
|
||||
}
|
||||
|
||||
mPost.setSubredditIconUrl(iconImageUrl);
|
||||
});
|
||||
} else if (!mPost.getSubredditIconUrl().equals("")) {
|
||||
mGlide.load(mPost.getSubredditIconUrl())
|
||||
@@ -544,16 +553,23 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
//Upvote
|
||||
((PostDetailBaseViewHolder) holder).mUpvoteButton.setColorFilter(mUpvotedColor, PorterDuff.Mode.SRC_IN);
|
||||
((PostDetailBaseViewHolder) holder).mScoreTextView.setTextColor(mUpvotedColor);
|
||||
((PostDetailBaseViewHolder) holder).mDownvoteTextView.setTextColor(mPostIconAndInfoColor);
|
||||
break;
|
||||
case -1:
|
||||
//Downvote
|
||||
((PostDetailBaseViewHolder) holder).mDownvoteButton.setColorFilter(mDownvotedColor, PorterDuff.Mode.SRC_IN);
|
||||
((PostDetailBaseViewHolder) holder).mScoreTextView.setTextColor(mDownvotedColor);
|
||||
if(mSeperateUpvoteAndDownvote){
|
||||
((PostDetailBaseViewHolder) holder).mDownvoteTextView.setTextColor(mDownvotedColor);
|
||||
} else {
|
||||
((PostDetailBaseViewHolder) holder).mScoreTextView.setTextColor(mDownvotedColor);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
case 0:
|
||||
((PostDetailBaseViewHolder) holder).mUpvoteButton.setColorFilter(mPostIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||
((PostDetailBaseViewHolder) holder).mDownvoteButton.setColorFilter(mPostIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||
((PostDetailBaseViewHolder) holder).mScoreTextView.setTextColor(mPostIconAndInfoColor);
|
||||
((PostDetailBaseViewHolder) holder).mDownvoteTextView.setTextColor(mPostIconAndInfoColor);
|
||||
}
|
||||
|
||||
if (mPost.isArchived()) {
|
||||
@@ -567,15 +583,20 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
((PostDetailBaseViewHolder) holder).mCrosspostImageView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
if (!mHideSubredditAndUserPrefix) {
|
||||
((PostDetailBaseViewHolder) holder).mSubredditTextView.setText(mPost.getSubredditNamePrefixed());
|
||||
((PostDetailBaseViewHolder) holder).mUserTextView.setText(mPost.getAuthorNamePrefixed());
|
||||
((PostDetailBaseViewHolder) holder).mUserTextView.setText((mShowDisplayNames) ? mPost.getAuthor() : mPost.getAuthorInfo().getUsername());
|
||||
((PostDetailBaseViewHolder) holder).mSubredditTextView.setText((mShowDisplayNames) ? mPost.getSubredditName() : mPost.getCommunityInfo().getName());
|
||||
if (mHideSubredditAndUserPrefix) {
|
||||
((PostDetailBaseViewHolder) holder).mUserTextView.setText((mShowDisplayNames) ? mPost.getAuthor() : mPost.getAuthorInfo().getUsername());
|
||||
} else {
|
||||
((PostDetailBaseViewHolder) holder).mSubredditTextView.setText(mPost.getSubredditName());
|
||||
((PostDetailBaseViewHolder) holder).mUserTextView.setText(mPost.getAuthor());
|
||||
((PostDetailBaseViewHolder) holder).mSubredditTextView.setText((mShowDisplayNames) ? mPost.getSubredditName() : mPost.getCommunityInfo().getName());
|
||||
((PostDetailBaseViewHolder) holder).mCommunityInstanceTextView.setText('@' + mPost.getSubredditNamePrefixed().split(Pattern.quote("@"))[1]);
|
||||
|
||||
((PostDetailBaseViewHolder) holder).mUserInstanceTextView.setText('@' + mPost.getAuthorNamePrefixed().split(Pattern.quote("@"))[1]);
|
||||
((PostDetailBaseViewHolder) holder).mCommunityInstanceTextView.setTextColor(CustomThemeWrapper.darkenColor(mSubredditColor, 0.7f));
|
||||
((PostDetailBaseViewHolder) holder).mUserInstanceTextView.setTextColor(CustomThemeWrapper.darkenColor(mPost.isModerator() || mPost.isAdmin() ? mModeratorColor : mUsernameColor, 0.7f));
|
||||
}
|
||||
|
||||
if (mPost.isModerator()) {
|
||||
if (mPost.isModerator() || mPost.isAdmin()) {
|
||||
((PostDetailBaseViewHolder) holder).mUserTextView.setTextColor(mModeratorColor);
|
||||
Drawable moderatorDrawable = Utils.getTintedDrawable(mActivity, R.drawable.ic_verified_user_14dp, mModeratorColor);
|
||||
((PostDetailBaseViewHolder) holder).mUserTextView.setCompoundDrawablesWithIntrinsicBounds(
|
||||
@@ -611,7 +632,24 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
}
|
||||
|
||||
if (!mHideTheNumberOfVotes) {
|
||||
((PostDetailBaseViewHolder) holder).mScoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, mPost.getScore() + mPost.getVoteType()));
|
||||
if(mSeperateUpvoteAndDownvote){
|
||||
int upvotes = (mPost.getVoteType() == 1) ? mPost.getUpvotes()+1 : mPost.getUpvotes();
|
||||
int downvotes = (mPost.getVoteType() == -1) ? mPost.getDownvotes() +1 : Math.max(mPost.getDownvotes(),0);
|
||||
((PostDetailBaseViewHolder) holder).mScoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, upvotes));
|
||||
((PostDetailBaseViewHolder) holder).mDownvoteTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, downvotes));
|
||||
|
||||
((PostDetailBaseViewHolder) holder).mDownvoteTextView.setVisibility(View.VISIBLE);
|
||||
|
||||
((PostDetailBaseViewHolder) holder).mDownvoteTextView.setGravity(Gravity.START);
|
||||
((PostDetailBaseViewHolder) holder).mScoreTextView.setGravity(Gravity.START);
|
||||
((PostDetailBaseViewHolder) holder).mScoreTextView.getLayoutParams().width = (int) (32 * mActivity.getResources().getDisplayMetrics().density);
|
||||
|
||||
((PostDetailBaseViewHolder) holder).mScoreTextView.setPadding(0, 0, 6, 0);
|
||||
((PostDetailBaseViewHolder) holder).mDownvoteTextView.setPadding(0, 0, 12, 0);
|
||||
((PostDetailBaseViewHolder) holder).mUpvoteButton.setPadding(24, 0, 12, 0);
|
||||
} else {
|
||||
((PostDetailBaseViewHolder) holder).mScoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, mPost.getScore() + mPost.getVoteType()));
|
||||
}
|
||||
} else {
|
||||
((PostDetailBaseViewHolder) holder).mScoreTextView.setText(mActivity.getString(R.string.vote));
|
||||
}
|
||||
@@ -660,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,
|
||||
@@ -1146,7 +1184,9 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
public class PostDetailBaseViewHolder extends RecyclerView.ViewHolder {
|
||||
AspectRatioGifImageView mIconGifImageView;
|
||||
TextView mSubredditTextView;
|
||||
TextView mCommunityInstanceTextView;
|
||||
TextView mUserTextView;
|
||||
TextView mUserInstanceTextView;
|
||||
TextView mAuthorFlairTextView;
|
||||
TextView mPostTimeTextView;
|
||||
TextView mTitleTextView;
|
||||
@@ -1163,6 +1203,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
ConstraintLayout mBottomConstraintLayout;
|
||||
ImageView mUpvoteButton;
|
||||
TextView mScoreTextView;
|
||||
TextView mDownvoteTextView;
|
||||
ImageView mDownvoteButton;
|
||||
TextView commentsCountTextView;
|
||||
ImageView mSaveButton;
|
||||
@@ -1174,7 +1215,9 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
|
||||
void setBaseView(AspectRatioGifImageView mIconGifImageView,
|
||||
TextView mSubredditTextView,
|
||||
TextView mCommunityInstanceTextView,
|
||||
TextView mUserTextView,
|
||||
TextView mUserInstanceTextView,
|
||||
TextView mAuthorFlairTextView,
|
||||
TextView mPostTimeTextView,
|
||||
TextView mTitleTextView,
|
||||
@@ -1191,13 +1234,16 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
ConstraintLayout mBottomConstraintLayout,
|
||||
ImageView mUpvoteButton,
|
||||
TextView mScoreTextView,
|
||||
TextView mDownvoteTextView,
|
||||
ImageView mDownvoteButton,
|
||||
TextView commentsCountTextView,
|
||||
ImageView mSaveButton,
|
||||
ImageView mShareButton) {
|
||||
this.mIconGifImageView = mIconGifImageView;
|
||||
this.mSubredditTextView = mSubredditTextView;
|
||||
this.mCommunityInstanceTextView = mCommunityInstanceTextView;
|
||||
this.mUserTextView = mUserTextView;
|
||||
this.mUserInstanceTextView = mUserInstanceTextView;
|
||||
this.mAuthorFlairTextView = mAuthorFlairTextView;
|
||||
this.mPostTimeTextView = mPostTimeTextView;
|
||||
this.mTitleTextView = mTitleTextView;
|
||||
@@ -1214,6 +1260,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
this.mBottomConstraintLayout = mBottomConstraintLayout;
|
||||
this.mUpvoteButton = mUpvoteButton;
|
||||
this.mScoreTextView = mScoreTextView;
|
||||
this.mDownvoteTextView = mDownvoteTextView;
|
||||
this.mDownvoteButton = mDownvoteButton;
|
||||
this.commentsCountTextView = commentsCountTextView;
|
||||
this.mSaveButton = mSaveButton;
|
||||
@@ -1225,16 +1272,18 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
|
||||
mIconGifImageView.setOnClickListener(view -> mSubredditTextView.performClick());
|
||||
|
||||
mSubredditTextView.setOnClickListener(view -> {
|
||||
View.OnClickListener communityClickListener = view -> {
|
||||
Intent intent;
|
||||
intent = new Intent(mActivity, ViewSubredditDetailActivity.class);
|
||||
intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY,
|
||||
mPost.getSubredditName());
|
||||
intent.putExtra(ViewSubredditDetailActivity.EXTRA_COMMUNITY_FULL_NAME_KEY, mPost.getSubredditNamePrefixed());
|
||||
mActivity.startActivity(intent);
|
||||
});
|
||||
};
|
||||
mSubredditTextView.setOnClickListener(communityClickListener);
|
||||
mCommunityInstanceTextView.setOnClickListener(communityClickListener);
|
||||
|
||||
mUserTextView.setOnClickListener(view -> {
|
||||
View.OnClickListener onUserClick = view -> {
|
||||
if (mPost.isAuthorDeleted()) {
|
||||
return;
|
||||
}
|
||||
@@ -1242,7 +1291,9 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, mPost.getAuthor());
|
||||
intent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, mPost.getAuthorNamePrefixed());
|
||||
mActivity.startActivity(intent);
|
||||
});
|
||||
};
|
||||
mUserTextView.setOnClickListener(onUserClick);
|
||||
mUserInstanceTextView.setOnClickListener(onUserClick);
|
||||
|
||||
mAuthorFlairTextView.setOnClickListener(view -> mUserTextView.performClick());
|
||||
|
||||
@@ -1306,6 +1357,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
int newVoteType;
|
||||
|
||||
mDownvoteButton.setColorFilter(mPostIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||
mDownvoteTextView.setTextColor(mPostIconAndInfoColor);
|
||||
|
||||
if (previousVoteType != 1) {
|
||||
//Not upvoted before
|
||||
@@ -1322,13 +1374,20 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
}
|
||||
|
||||
if (!mHideTheNumberOfVotes) {
|
||||
mScoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||
mPost.getScore() + mPost.getVoteType()));
|
||||
if(mSeperateUpvoteAndDownvote){
|
||||
int upvotes = (mPost.getVoteType() == 1) ? mPost.getUpvotes() + 1 : mPost.getUpvotes();
|
||||
int downvotes = (mPost.getVoteType() == -1) ? mPost.getDownvotes() + 1 : Math.max(mPost.getDownvotes(),0);;
|
||||
mScoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, upvotes));
|
||||
mDownvoteTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, downvotes));
|
||||
} else {
|
||||
mScoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||
mPost.getScore() + mPost.getVoteType()));
|
||||
}
|
||||
}
|
||||
|
||||
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)) {
|
||||
@@ -1343,8 +1402,15 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
|
||||
mDownvoteButton.setColorFilter(mPostIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||
if (!mHideTheNumberOfVotes) {
|
||||
mScoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||
mPost.getScore() + mPost.getVoteType()));
|
||||
if(mSeperateUpvoteAndDownvote){
|
||||
int upvotes = (mPost.getVoteType() == 1) ? mPost.getUpvotes() + 1 : mPost.getUpvotes();
|
||||
int downvotes = (mPost.getVoteType() == -1) ? mPost.getDownvotes() + 1 : Math.max(mPost.getDownvotes(),0);;
|
||||
mScoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, upvotes));
|
||||
mDownvoteTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, downvotes));
|
||||
} else {
|
||||
mScoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||
mPost.getScore() + mPost.getVoteType()));
|
||||
}
|
||||
}
|
||||
|
||||
mPostDetailRecyclerViewAdapterCallback.updatePost(mPost);
|
||||
@@ -1355,8 +1421,15 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
Toast.makeText(mActivity, R.string.vote_failed, Toast.LENGTH_SHORT).show();
|
||||
mPost.setVoteType(previousVoteType);
|
||||
if (!mHideTheNumberOfVotes) {
|
||||
mScoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||
mPost.getScore() + previousVoteType));
|
||||
if(mSeperateUpvoteAndDownvote){
|
||||
int upvotes = (previousVoteType == 1) ? mPost.getUpvotes() + 1 : mPost.getUpvotes();
|
||||
int downvotes = (previousVoteType == -1) ? mPost.getDownvotes() - 1 : Math.max(mPost.getDownvotes(),0);;
|
||||
mScoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, upvotes));
|
||||
mDownvoteTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, downvotes));
|
||||
} else {
|
||||
mScoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||
mPost.getScore() + previousVoteType));
|
||||
}
|
||||
}
|
||||
mUpvoteButton.setColorFilter(previousUpvoteButtonColorFilter);
|
||||
mDownvoteButton.setColorFilter(previousDownvoteButtonColorFilter);
|
||||
@@ -1386,45 +1459,69 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
int newVoteType;
|
||||
|
||||
mUpvoteButton.setColorFilter(mPostIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||
|
||||
mScoreTextView.setTextColor(mPostIconAndInfoColor);
|
||||
if (previousVoteType != -1) {
|
||||
//Not upvoted before
|
||||
mPost.setVoteType(-1);
|
||||
newVoteType = Integer.parseInt(APIUtils.DIR_DOWNVOTE);
|
||||
mDownvoteButton.setColorFilter(mDownvotedColor, PorterDuff.Mode.SRC_IN);
|
||||
mScoreTextView.setTextColor(mDownvotedColor);
|
||||
if(mSeperateUpvoteAndDownvote){
|
||||
mDownvoteTextView.setTextColor(mDownvotedColor);
|
||||
} else {
|
||||
mScoreTextView.setTextColor(mDownvotedColor);
|
||||
}
|
||||
} else {
|
||||
//Upvoted before
|
||||
mPost.setVoteType(0);
|
||||
newVoteType = Integer.parseInt(APIUtils.DIR_UNVOTE);
|
||||
mDownvoteButton.setColorFilter(mPostIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||
mScoreTextView.setTextColor(mPostIconAndInfoColor);
|
||||
mDownvoteTextView.setTextColor(mPostIconAndInfoColor);
|
||||
}
|
||||
|
||||
if (!mHideTheNumberOfVotes) {
|
||||
mScoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||
mPost.getScore() + mPost.getVoteType()));
|
||||
if(mSeperateUpvoteAndDownvote){
|
||||
int upvotes = (mPost.getVoteType() == 1) ? mPost.getUpvotes() + 1 : mPost.getUpvotes();
|
||||
int downvotes = (mPost.getVoteType() == -1) ? mPost.getDownvotes() + 1 : Math.max(mPost.getDownvotes(),0);;
|
||||
mScoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, upvotes));
|
||||
mDownvoteTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, downvotes));
|
||||
} else {
|
||||
mScoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||
mPost.getScore() + mPost.getVoteType()));
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
mScoreTextView.setTextColor(mDownvotedColor);
|
||||
if (mSeperateUpvoteAndDownvote) {
|
||||
mDownvoteTextView.setTextColor(mDownvotedColor);
|
||||
} else {
|
||||
mScoreTextView.setTextColor(mDownvotedColor);
|
||||
}
|
||||
} else {
|
||||
mPost.setVoteType(0);
|
||||
mDownvoteButton.setColorFilter(mPostIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||
mScoreTextView.setTextColor(mPostIconAndInfoColor);
|
||||
mDownvoteTextView.setTextColor(mPostIconAndInfoColor);
|
||||
}
|
||||
|
||||
mUpvoteButton.setColorFilter(mPostIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||
if (!mHideTheNumberOfVotes) {
|
||||
mScoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||
mPost.getScore() + mPost.getVoteType()));
|
||||
if(mSeperateUpvoteAndDownvote){
|
||||
int upvotes = (mPost.getVoteType() == 1) ? mPost.getUpvotes() + 1 : mPost.getUpvotes();
|
||||
int downvotes = (mPost.getVoteType() == -1) ? mPost.getDownvotes() + 1 : Math.max(mPost.getDownvotes(),0);;
|
||||
mScoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, upvotes));
|
||||
mDownvoteTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, downvotes));
|
||||
} else {
|
||||
mScoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||
mPost.getScore() + mPost.getVoteType()));
|
||||
}
|
||||
}
|
||||
|
||||
mPostDetailRecyclerViewAdapterCallback.updatePost(mPost);
|
||||
@@ -1435,8 +1532,15 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
Toast.makeText(mActivity, R.string.vote_failed, Toast.LENGTH_SHORT).show();
|
||||
mPost.setVoteType(previousVoteType);
|
||||
if (!mHideTheNumberOfVotes) {
|
||||
mScoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||
mPost.getScore() + previousVoteType));
|
||||
if(mSeperateUpvoteAndDownvote) {
|
||||
int upvotes = (previousVoteType == 1) ? mPost.getUpvotes() + 1 : mPost.getUpvotes();
|
||||
int downvotes = (previousVoteType == -1) ? mPost.getDownvotes() + 1 : Math.max(mPost.getDownvotes(),0);
|
||||
mScoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, upvotes));
|
||||
mDownvoteTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, downvotes));
|
||||
} else {
|
||||
mScoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||
mPost.getScore() + previousVoteType));
|
||||
}
|
||||
}
|
||||
mUpvoteButton.setColorFilter(previousUpvoteButtonColorFilter);
|
||||
mDownvoteButton.setColorFilter(previousDownvoteButtonColorFilter);
|
||||
@@ -1485,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(mOauthRetrofit, mAccessToken, mPost.getId(),
|
||||
savePost.unsaveThing(mRetrofit.getRetrofit(), mAccessToken, mPost.getId(),
|
||||
new SaveThing.SaveThingListener() {
|
||||
@Override
|
||||
public void success() {
|
||||
@@ -1505,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() {
|
||||
@@ -1527,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()) {
|
||||
@@ -1549,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;
|
||||
});
|
||||
|
||||
@@ -1559,11 +1665,18 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
constraintSet.clear(mUpvoteButton.getId(), ConstraintSet.START);
|
||||
constraintSet.clear(mScoreTextView.getId(), ConstraintSet.START);
|
||||
constraintSet.clear(mDownvoteButton.getId(), ConstraintSet.START);
|
||||
constraintSet.clear(mDownvoteTextView.getId(), ConstraintSet.START);
|
||||
constraintSet.clear(mSaveButton.getId(), ConstraintSet.END);
|
||||
constraintSet.clear(mShareButton.getId(), ConstraintSet.END);
|
||||
constraintSet.connect(mUpvoteButton.getId(), ConstraintSet.END, mScoreTextView.getId(), ConstraintSet.START);
|
||||
constraintSet.connect(mScoreTextView.getId(), ConstraintSet.END, mDownvoteButton.getId(), ConstraintSet.START);
|
||||
constraintSet.connect(mDownvoteButton.getId(), ConstraintSet.END, ConstraintSet.PARENT_ID, ConstraintSet.END);
|
||||
if (!mSeperateUpvoteAndDownvote) {
|
||||
constraintSet.connect(mDownvoteButton.getId(), ConstraintSet.END, ConstraintSet.PARENT_ID, ConstraintSet.END);
|
||||
} else {
|
||||
constraintSet.connect(mDownvoteButton.getId(), ConstraintSet.END, mDownvoteTextView.getId(), ConstraintSet.START);
|
||||
constraintSet.connect(mDownvoteTextView.getId(), ConstraintSet.END, ConstraintSet.PARENT_ID, ConstraintSet.END);
|
||||
}
|
||||
|
||||
constraintSet.connect(commentsCountTextView.getId(), ConstraintSet.START, mSaveButton.getId(), ConstraintSet.END);
|
||||
constraintSet.connect(commentsCountTextView.getId(), ConstraintSet.END, mUpvoteButton.getId(), ConstraintSet.START);
|
||||
constraintSet.connect(mSaveButton.getId(), ConstraintSet.START, mShareButton.getId(), ConstraintSet.END);
|
||||
@@ -1631,8 +1744,14 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
AspectRatioGifImageView mIconGifImageView;
|
||||
@BindView(R.id.subreddit_text_view_item_post_detail_video_autoplay)
|
||||
TextView mSubredditTextView;
|
||||
|
||||
@BindView(R.id.community_instance_text_view_item_post_detail_video_autoplay)
|
||||
TextView mCommunityInstanceTextView;
|
||||
@BindView(R.id.user_text_view_item_post_detail_video_autoplay)
|
||||
TextView mUserTextView;
|
||||
@BindView(R.id.user_instance_text_view_item_post_detail_video_autoplay)
|
||||
TextView mUserInstanceTextView;
|
||||
|
||||
@BindView(R.id.author_flair_text_view_item_post_detail_video_autoplay)
|
||||
TextView mAuthorFlairTextView;
|
||||
@BindView(R.id.post_time_text_view_item_post_detail_video_autoplay)
|
||||
@@ -1683,6 +1802,9 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
ImageView mUpvoteButton;
|
||||
@BindView(R.id.score_text_view_item_post_detail_video_autoplay)
|
||||
TextView mScoreTextView;
|
||||
|
||||
@BindView(R.id.downvote_text_view_item_post_detail_video_autoplay)
|
||||
TextView mDownvoteTextView;
|
||||
@BindView(R.id.minus_button_item_post_detail_video_autoplay)
|
||||
ImageView mDownvoteButton;
|
||||
@BindView(R.id.comments_count_item_post_detail_video_autoplay)
|
||||
@@ -1704,7 +1826,9 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
ButterKnife.bind(this, itemView);
|
||||
setBaseView(mIconGifImageView,
|
||||
mSubredditTextView,
|
||||
mCommunityInstanceTextView,
|
||||
mUserTextView,
|
||||
mUserInstanceTextView,
|
||||
mAuthorFlairTextView,
|
||||
mPostTimeTextView,
|
||||
mTitleTextView,
|
||||
@@ -1721,6 +1845,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
mBottomConstraintLayout,
|
||||
mUpvoteButton,
|
||||
mScoreTextView,
|
||||
mDownvoteTextView,
|
||||
mDownvoteButton,
|
||||
commentsCountTextView,
|
||||
mSaveButton,
|
||||
@@ -1938,8 +2063,12 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
AspectRatioGifImageView mIconGifImageView;
|
||||
@BindView(R.id.subreddit_text_view_item_post_detail_video_and_gif_preview)
|
||||
TextView mSubredditTextView;
|
||||
@BindView(R.id.community_instance_text_view_item_post_detail_video_and_gif_preview)
|
||||
TextView mCommunityInstanceTextView;
|
||||
@BindView(R.id.user_text_view_item_post_detail_video_and_gif_preview)
|
||||
TextView mUserTextView;
|
||||
@BindView(R.id.user_instance_text_view_item_post_detail_video_and_gif_preview)
|
||||
TextView mUserInstanceTextView;
|
||||
@BindView(R.id.author_flair_text_view_item_post_detail_video_and_gif_preview)
|
||||
TextView mAuthorFlairTextView;
|
||||
@BindView(R.id.post_time_text_view_item_post_detail_video_and_gif_preview)
|
||||
@@ -1982,6 +2111,9 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
ImageView mUpvoteButton;
|
||||
@BindView(R.id.score_text_view_item_post_detail_video_and_gif_preview)
|
||||
TextView mScoreTextView;
|
||||
|
||||
@BindView(R.id.downvote_text_view_item_post_detail_video_and_gif_preview)
|
||||
TextView mDownvoteTextView;
|
||||
@BindView(R.id.minus_button_item_post_detail_video_and_gif_preview)
|
||||
ImageView mDownvoteButton;
|
||||
@BindView(R.id.comments_count_item_post_detail_video_and_gif_preview)
|
||||
@@ -1996,7 +2128,9 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
ButterKnife.bind(this, itemView);
|
||||
setBaseView(mIconGifImageView,
|
||||
mSubredditTextView,
|
||||
mCommunityInstanceTextView,
|
||||
mUserTextView,
|
||||
mUserInstanceTextView,
|
||||
mAuthorFlairTextView,
|
||||
mPostTimeTextView,
|
||||
mTitleTextView,
|
||||
@@ -2013,6 +2147,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
mBottomConstraintLayout,
|
||||
mUpvoteButton,
|
||||
mScoreTextView,
|
||||
mDownvoteTextView,
|
||||
mDownvoteButton,
|
||||
commentsCountTextView,
|
||||
mSaveButton,
|
||||
@@ -2067,8 +2202,12 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
AspectRatioGifImageView mIconGifImageView;
|
||||
@BindView(R.id.subreddit_text_view_item_post_detail_image_and_gif_autoplay)
|
||||
TextView mSubredditTextView;
|
||||
@BindView(R.id.community_instance_text_view_item_post_detail_image_and_gif_autoplay)
|
||||
TextView mCommunityInstanceTextView;
|
||||
@BindView(R.id.user_text_view_item_post_detail_image_and_gif_autoplay)
|
||||
TextView mUserTextView;
|
||||
@BindView(R.id.user_instance_text_view_item_post_detail_image_and_gif_autoplay)
|
||||
TextView mUserInstanceTextView;
|
||||
@BindView(R.id.author_flair_text_view_item_post_detail_image_and_gif_autoplay)
|
||||
TextView mAuthorFlairTextView;
|
||||
@BindView(R.id.post_time_text_view_item_post_detail_image_and_gif_autoplay)
|
||||
@@ -2111,6 +2250,9 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
ImageView mUpvoteButton;
|
||||
@BindView(R.id.score_text_view_item_post_detail_image_and_gif_autoplay)
|
||||
TextView mScoreTextView;
|
||||
|
||||
@BindView(R.id.downvote_text_view_item_post_detail_image_and_gif_autoplay)
|
||||
TextView mDownvoteTextView;
|
||||
@BindView(R.id.minus_button_item_post_detail_image_and_gif_autoplay)
|
||||
ImageView mDownvoteButton;
|
||||
@BindView(R.id.comments_count_item_post_detail_image_and_gif_autoplay)
|
||||
@@ -2125,7 +2267,9 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
ButterKnife.bind(this, itemView);
|
||||
setBaseView(mIconGifImageView,
|
||||
mSubredditTextView,
|
||||
mCommunityInstanceTextView,
|
||||
mUserTextView,
|
||||
mUserInstanceTextView,
|
||||
mAuthorFlairTextView,
|
||||
mPostTimeTextView,
|
||||
mTitleTextView,
|
||||
@@ -2142,6 +2286,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
mBottomConstraintLayout,
|
||||
mUpvoteButton,
|
||||
mScoreTextView,
|
||||
mDownvoteTextView,
|
||||
mDownvoteButton,
|
||||
commentsCountTextView,
|
||||
mSaveButton,
|
||||
@@ -2180,8 +2325,12 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
AspectRatioGifImageView mIconGifImageView;
|
||||
@BindView(R.id.subreddit_text_view_item_post_detail_link)
|
||||
TextView mSubredditTextView;
|
||||
@BindView(R.id.community_instance_text_view_item_post_detail_link)
|
||||
TextView mCommunityInstanceTextView;
|
||||
@BindView(R.id.user_text_view_item_post_detail_link)
|
||||
TextView mUserTextView;
|
||||
@BindView(R.id.user_instance_text_view_item_post_detail_link)
|
||||
TextView mUserInstanceTextView;
|
||||
@BindView(R.id.author_flair_text_view_item_post_detail_link)
|
||||
TextView mAuthorFlairTextView;
|
||||
@BindView(R.id.post_time_text_view_item_post_detail_link)
|
||||
@@ -2226,6 +2375,9 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
ImageView mUpvoteButton;
|
||||
@BindView(R.id.score_text_view_item_post_detail_link)
|
||||
TextView mScoreTextView;
|
||||
|
||||
@BindView(R.id.downvote_text_view_item_post_detail_link)
|
||||
TextView mDownvoteTextView;
|
||||
@BindView(R.id.minus_button_item_post_detail_link)
|
||||
ImageView mDownvoteButton;
|
||||
@BindView(R.id.comments_count_item_post_detail_link)
|
||||
@@ -2240,7 +2392,9 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
ButterKnife.bind(this, itemView);
|
||||
setBaseView(mIconGifImageView,
|
||||
mSubredditTextView,
|
||||
mCommunityInstanceTextView,
|
||||
mUserTextView,
|
||||
mUserInstanceTextView,
|
||||
mAuthorFlairTextView,
|
||||
mPostTimeTextView,
|
||||
mTitleTextView,
|
||||
@@ -2257,6 +2411,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
mBottomConstraintLayout,
|
||||
mUpvoteButton,
|
||||
mScoreTextView,
|
||||
mDownvoteTextView,
|
||||
mDownvoteButton,
|
||||
commentsCountTextView,
|
||||
mSaveButton,
|
||||
@@ -2284,8 +2439,12 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
AspectRatioGifImageView mIconGifImageView;
|
||||
@BindView(R.id.subreddit_text_view_item_post_detail_no_preview_link)
|
||||
TextView mSubredditTextView;
|
||||
@BindView(R.id.community_instance_text_view_item_post_detail_no_preview_link)
|
||||
TextView mCommunityInstanceTextView;
|
||||
@BindView(R.id.user_text_view_item_post_detail_no_preview_link)
|
||||
TextView mUserTextView;
|
||||
@BindView(R.id.user_instance_text_view_item_post_detail_no_preview_link)
|
||||
TextView mUserInstanceTextView;
|
||||
@BindView(R.id.author_flair_text_view_item_post_detail_no_preview_link)
|
||||
TextView mAuthorFlairTextView;
|
||||
@BindView(R.id.post_time_text_view_item_post_detail_no_preview_link)
|
||||
@@ -2322,6 +2481,9 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
ImageView mUpvoteButton;
|
||||
@BindView(R.id.score_text_view_item_post_detail_no_preview_link)
|
||||
TextView mScoreTextView;
|
||||
@BindView(R.id.downvote_text_view_item_post_detail_no_preview_link)
|
||||
TextView mDownvoteTextView;
|
||||
|
||||
@BindView(R.id.minus_button_item_post_detail_no_preview_link)
|
||||
ImageView mDownvoteButton;
|
||||
@BindView(R.id.comments_count_item_post_detail_no_preview_link)
|
||||
@@ -2336,7 +2498,9 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
ButterKnife.bind(this, itemView);
|
||||
setBaseView(mIconGifImageView,
|
||||
mSubredditTextView,
|
||||
mCommunityInstanceTextView,
|
||||
mUserTextView,
|
||||
mUserInstanceTextView,
|
||||
mAuthorFlairTextView,
|
||||
mPostTimeTextView,
|
||||
mTitleTextView,
|
||||
@@ -2353,6 +2517,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
mBottomConstraintLayout,
|
||||
mUpvoteButton,
|
||||
mScoreTextView,
|
||||
mDownvoteTextView,
|
||||
mDownvoteButton,
|
||||
commentsCountTextView,
|
||||
mSaveButton,
|
||||
@@ -2425,8 +2590,12 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
AspectRatioGifImageView mIconGifImageView;
|
||||
@BindView(R.id.subreddit_text_view_item_post_detail_gallery)
|
||||
TextView mSubredditTextView;
|
||||
@BindView(R.id.community_instance_text_view_item_post_detail_gallery)
|
||||
TextView mCommunityInstanceTextView;
|
||||
@BindView(R.id.user_text_view_item_post_detail_gallery)
|
||||
TextView mUserTextView;
|
||||
@BindView(R.id.user_instance_text_view_item_post_detail_gallery)
|
||||
TextView mUserInstanceTextView;
|
||||
@BindView(R.id.author_flair_text_view_item_post_detail_gallery)
|
||||
TextView mAuthorFlairTextView;
|
||||
@BindView(R.id.post_time_text_view_item_post_detail_gallery)
|
||||
@@ -2467,6 +2636,8 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
ImageView mUpvoteButton;
|
||||
@BindView(R.id.score_text_view_item_post_detail_gallery)
|
||||
TextView mScoreTextView;
|
||||
@BindView(R.id.downvote_text_view_item_post_detail_gallery)
|
||||
TextView mDownvoteTextView;
|
||||
@BindView(R.id.minus_button_item_post_detail_gallery)
|
||||
ImageView mDownvoteButton;
|
||||
@BindView(R.id.comments_count_item_post_detail_gallery)
|
||||
@@ -2482,7 +2653,9 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
ButterKnife.bind(this, itemView);
|
||||
setBaseView(mIconGifImageView,
|
||||
mSubredditTextView,
|
||||
mCommunityInstanceTextView,
|
||||
mUserTextView,
|
||||
mUserInstanceTextView,
|
||||
mAuthorFlairTextView,
|
||||
mPostTimeTextView,
|
||||
mTitleTextView,
|
||||
@@ -2499,6 +2672,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
mBottomConstraintLayout,
|
||||
mUpvoteButton,
|
||||
mScoreTextView,
|
||||
mDownvoteTextView,
|
||||
mDownvoteButton,
|
||||
commentsCountTextView,
|
||||
mSaveButton,
|
||||
@@ -2620,8 +2794,12 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
AspectRatioGifImageView mIconGifImageView;
|
||||
@BindView(R.id.subreddit_text_view_item_post_detail_text)
|
||||
TextView mSubredditTextView;
|
||||
@BindView(R.id.community_instance_text_view_item_post_detail_text)
|
||||
TextView mCommunityInstanceTextView;
|
||||
@BindView(R.id.user_text_view_item_post_detail_text)
|
||||
TextView mUserTextView;
|
||||
@BindView(R.id.user_instance_text_view_item_post_detail_text)
|
||||
TextView mUserInstanceTextView;
|
||||
@BindView(R.id.author_flair_text_view_item_post_detail_text)
|
||||
TextView mAuthorFlairTextView;
|
||||
@BindView(R.id.post_time_text_view_item_post_detail_text)
|
||||
@@ -2654,6 +2832,9 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
ImageView mUpvoteButton;
|
||||
@BindView(R.id.score_text_view_item_post_detail_text)
|
||||
TextView mScoreTextView;
|
||||
|
||||
@BindView(R.id.downvote_text_view_item_post_detail_text)
|
||||
TextView mDownvoteTextView;
|
||||
@BindView(R.id.minus_button_item_post_detail_text)
|
||||
ImageView mDownvoteButton;
|
||||
@BindView(R.id.comments_count_item_post_detail_text)
|
||||
@@ -2668,7 +2849,9 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
ButterKnife.bind(this, itemView);
|
||||
setBaseView(mIconGifImageView,
|
||||
mSubredditTextView,
|
||||
mCommunityInstanceTextView,
|
||||
mUserTextView,
|
||||
mUserInstanceTextView,
|
||||
mAuthorFlairTextView,
|
||||
mPostTimeTextView,
|
||||
mTitleTextView,
|
||||
@@ -2685,6 +2868,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
mBottomConstraintLayout,
|
||||
mUpvoteButton,
|
||||
mScoreTextView,
|
||||
mDownvoteTextView,
|
||||
mDownvoteButton,
|
||||
commentsCountTextView,
|
||||
mSaveButton,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,343 @@
|
||||
package eu.toldi.infinityforlemmy.adapters;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.net.Uri;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.text.util.Linkify;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.paging.PagedListAdapter;
|
||||
import androidx.recyclerview.widget.DiffUtil;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import eu.toldi.infinityforlemmy.NetworkState;
|
||||
import eu.toldi.infinityforlemmy.R;
|
||||
import eu.toldi.infinityforlemmy.activities.BaseActivity;
|
||||
import eu.toldi.infinityforlemmy.activities.LinkResolverActivity;
|
||||
import eu.toldi.infinityforlemmy.activities.ViewPrivateMessagesActivity;
|
||||
import eu.toldi.infinityforlemmy.activities.ViewUserDetailActivity;
|
||||
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||
import eu.toldi.infinityforlemmy.markdown.RedditHeadingPlugin;
|
||||
import eu.toldi.infinityforlemmy.markdown.SpoilerAwareMovementMethod;
|
||||
import eu.toldi.infinityforlemmy.markdown.SpoilerParserPlugin;
|
||||
import eu.toldi.infinityforlemmy.markdown.SuperscriptPlugin;
|
||||
import eu.toldi.infinityforlemmy.privatemessage.LemmyPrivateMessageAPI;
|
||||
import eu.toldi.infinityforlemmy.privatemessage.PrivateMessage;
|
||||
import io.noties.markwon.AbstractMarkwonPlugin;
|
||||
import io.noties.markwon.Markwon;
|
||||
import io.noties.markwon.MarkwonConfiguration;
|
||||
import io.noties.markwon.core.MarkwonTheme;
|
||||
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
||||
import io.noties.markwon.image.glide.GlideImagesPlugin;
|
||||
import io.noties.markwon.inlineparser.HtmlInlineProcessor;
|
||||
import io.noties.markwon.inlineparser.MarkwonInlineParserPlugin;
|
||||
import io.noties.markwon.linkify.LinkifyPlugin;
|
||||
import io.noties.markwon.movement.MovementMethodPlugin;
|
||||
import retrofit2.Retrofit;
|
||||
|
||||
public class PrivateMessageRecycleViewAdapter extends PagedListAdapter<PrivateMessage, RecyclerView.ViewHolder> {
|
||||
private static final int VIEW_TYPE_DATA = 0;
|
||||
private static final int VIEW_TYPE_ERROR = 1;
|
||||
private static final int VIEW_TYPE_LOADING = 2;
|
||||
private static final DiffUtil.ItemCallback<PrivateMessage> DIFF_CALLBACK = new DiffUtil.ItemCallback<>() {
|
||||
@Override
|
||||
public boolean areItemsTheSame(@NonNull PrivateMessage message, @NonNull PrivateMessage t1) {
|
||||
return message.getId() == t1.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean areContentsTheSame(@NonNull PrivateMessage message, @NonNull PrivateMessage t1) {
|
||||
return message.getContent().equals(t1.getContent());
|
||||
}
|
||||
};
|
||||
private BaseActivity mActivity;
|
||||
private Retrofit retrofit;
|
||||
private Markwon mMarkwon;
|
||||
private String mAccessToken;
|
||||
|
||||
private final LemmyPrivateMessageAPI lemmyPrivateMessageAPI;
|
||||
private int mMessageType;
|
||||
private NetworkState networkState;
|
||||
private RetryLoadingMoreCallback mRetryLoadingMoreCallback;
|
||||
private int mColorAccent;
|
||||
private int mMessageBackgroundColor;
|
||||
private int mUsernameColor;
|
||||
private int mPrimaryTextColor;
|
||||
private int mSecondaryTextColor;
|
||||
private int mUnreadMessageBackgroundColor;
|
||||
private int mColorPrimaryLightTheme;
|
||||
private int mButtonTextColor;
|
||||
private boolean markAllMessagesAsRead = false;
|
||||
|
||||
public PrivateMessageRecycleViewAdapter(BaseActivity activity, Retrofit oauthRetrofit,
|
||||
CustomThemeWrapper customThemeWrapper,
|
||||
String accessToken,
|
||||
LemmyPrivateMessageAPI lemmyPrivateMessageAPI, RetryLoadingMoreCallback retryLoadingMoreCallback) {
|
||||
super(DIFF_CALLBACK);
|
||||
mActivity = activity;
|
||||
retrofit = oauthRetrofit;
|
||||
this.lemmyPrivateMessageAPI = lemmyPrivateMessageAPI;
|
||||
mRetryLoadingMoreCallback = retryLoadingMoreCallback;
|
||||
|
||||
mColorAccent = customThemeWrapper.getColorAccent();
|
||||
mMessageBackgroundColor = customThemeWrapper.getCardViewBackgroundColor();
|
||||
mUsernameColor = customThemeWrapper.getUsername();
|
||||
mPrimaryTextColor = customThemeWrapper.getPrimaryTextColor();
|
||||
mSecondaryTextColor = customThemeWrapper.getSecondaryTextColor();
|
||||
int spoilerBackgroundColor = mSecondaryTextColor | 0xFF000000;
|
||||
mUnreadMessageBackgroundColor = customThemeWrapper.getUnreadMessageBackgroundColor();
|
||||
mColorPrimaryLightTheme = customThemeWrapper.getColorPrimaryLightTheme();
|
||||
mButtonTextColor = customThemeWrapper.getButtonTextColor();
|
||||
|
||||
// todo:https://github.com/Docile-Alligator/Infinity-For-Reddit/issues/1027
|
||||
// add tables support and replace with MarkdownUtils#commonPostMarkwonBuilder
|
||||
mMarkwon = Markwon.builder(mActivity)
|
||||
.usePlugin(MarkwonInlineParserPlugin.create(plugin -> {
|
||||
plugin.excludeInlineProcessor(HtmlInlineProcessor.class);
|
||||
}))
|
||||
.usePlugin(new AbstractMarkwonPlugin() {
|
||||
@Override
|
||||
public void configureConfiguration(@NonNull MarkwonConfiguration.Builder builder) {
|
||||
builder.linkResolver((view, link) -> {
|
||||
Intent intent = new Intent(mActivity, LinkResolverActivity.class);
|
||||
Uri uri = Uri.parse(link);
|
||||
intent.setData(uri);
|
||||
mActivity.startActivity(intent);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configureTheme(@NonNull MarkwonTheme.Builder builder) {
|
||||
builder.linkColor(customThemeWrapper.getLinkColor());
|
||||
}
|
||||
})
|
||||
.usePlugin(SuperscriptPlugin.create())
|
||||
.usePlugin(SpoilerParserPlugin.create(mSecondaryTextColor, spoilerBackgroundColor))
|
||||
.usePlugin(RedditHeadingPlugin.create())
|
||||
.usePlugin(StrikethroughPlugin.create())
|
||||
.usePlugin(MovementMethodPlugin.create(new SpoilerAwareMovementMethod()))
|
||||
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
|
||||
.usePlugin(GlideImagesPlugin.create(mActivity))
|
||||
.build();
|
||||
mAccessToken = accessToken;
|
||||
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
if (viewType == VIEW_TYPE_DATA) {
|
||||
return new DataViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_message, parent, false));
|
||||
} else if (viewType == VIEW_TYPE_ERROR) {
|
||||
return new ErrorViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_footer_error, parent, false));
|
||||
} else {
|
||||
return new LoadingViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_footer_loading, parent, false));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
if (holder instanceof DataViewHolder) {
|
||||
PrivateMessage message = getItem(holder.getBindingAdapterPosition());
|
||||
if (message != null) {
|
||||
|
||||
if (!message.getRead()) {
|
||||
if (markAllMessagesAsRead) {
|
||||
message.setRead(true);
|
||||
} else {
|
||||
holder.itemView.setBackgroundColor(
|
||||
mUnreadMessageBackgroundColor);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
((DataViewHolder) holder).titleTextView.setVisibility(View.GONE);
|
||||
|
||||
|
||||
((DataViewHolder) holder).authorTextView.setText(message.getCreatorQualifiedName());
|
||||
String subject = message.getRecipientQualifiedName();
|
||||
((DataViewHolder) holder).subjectTextView.setText(subject);
|
||||
mMarkwon.setMarkdown(((DataViewHolder) holder).contentCustomMarkwonView, message.getContent());
|
||||
|
||||
holder.itemView.setOnClickListener(view -> {
|
||||
|
||||
Intent intent = new Intent(mActivity, ViewPrivateMessagesActivity.class);
|
||||
intent.putExtra(ViewPrivateMessagesActivity.EXTRA_PRIVATE_MESSAGE, message);
|
||||
mActivity.startActivity(intent);
|
||||
|
||||
|
||||
if (message.getRead()) {
|
||||
holder.itemView.setBackgroundColor(mMessageBackgroundColor);
|
||||
|
||||
|
||||
lemmyPrivateMessageAPI.markPrivateMessageAsRead(mAccessToken, message.getId(), new LemmyPrivateMessageAPI.PrivateMessageMarkedAsReadListener() {
|
||||
|
||||
@Override
|
||||
public void onPrivateMessageMarkedAsReadError() {
|
||||
message.setRead(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPrivateMessageMarkedAsReadSuccess() {
|
||||
message.setRead(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
((DataViewHolder) holder).authorTextView.setOnClickListener(view -> {
|
||||
|
||||
Intent intent = new Intent(mActivity, ViewUserDetailActivity.class);
|
||||
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, message.getCreatorName());
|
||||
intent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, message.getCreatorQualifiedName());
|
||||
mActivity.startActivity(intent);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
// Reached at the end
|
||||
if (hasExtraRow() && position == getItemCount() - 1) {
|
||||
if (networkState.getStatus() == NetworkState.Status.LOADING) {
|
||||
return VIEW_TYPE_LOADING;
|
||||
} else {
|
||||
return VIEW_TYPE_ERROR;
|
||||
}
|
||||
} else {
|
||||
return VIEW_TYPE_DATA;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
if (hasExtraRow()) {
|
||||
return super.getItemCount() + 1;
|
||||
}
|
||||
return super.getItemCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) {
|
||||
super.onViewRecycled(holder);
|
||||
if (holder instanceof DataViewHolder) {
|
||||
((DataViewHolder) holder).itemView.setBackgroundColor(mMessageBackgroundColor);
|
||||
((DataViewHolder) holder).titleTextView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean hasExtraRow() {
|
||||
return networkState != null && networkState.getStatus() != NetworkState.Status.SUCCESS;
|
||||
}
|
||||
|
||||
public void setNetworkState(NetworkState newNetworkState) {
|
||||
NetworkState previousState = this.networkState;
|
||||
boolean previousExtraRow = hasExtraRow();
|
||||
this.networkState = newNetworkState;
|
||||
boolean newExtraRow = hasExtraRow();
|
||||
if (previousExtraRow != newExtraRow) {
|
||||
if (previousExtraRow) {
|
||||
notifyItemRemoved(super.getItemCount());
|
||||
} else {
|
||||
notifyItemInserted(super.getItemCount());
|
||||
}
|
||||
} else if (newExtraRow && !previousState.equals(newNetworkState)) {
|
||||
notifyItemChanged(getItemCount() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateMessageReply(PrivateMessage newReply, int position) {
|
||||
if (position >= 0 && position < super.getItemCount()) {
|
||||
PrivateMessage message = getItem(position);
|
||||
if (message != null) {
|
||||
notifyItemChanged(position);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setMarkAllMessagesAsRead(boolean markAllMessagesAsRead) {
|
||||
this.markAllMessagesAsRead = markAllMessagesAsRead;
|
||||
}
|
||||
|
||||
public interface RetryLoadingMoreCallback {
|
||||
void retryLoadingMore();
|
||||
}
|
||||
|
||||
class DataViewHolder extends RecyclerView.ViewHolder {
|
||||
@BindView(R.id.author_text_view_item_message)
|
||||
TextView authorTextView;
|
||||
@BindView(R.id.subject_text_view_item_message)
|
||||
TextView subjectTextView;
|
||||
@BindView(R.id.title_text_view_item_message)
|
||||
TextView titleTextView;
|
||||
@BindView(R.id.content_custom_markwon_view_item_message)
|
||||
TextView contentCustomMarkwonView;
|
||||
|
||||
DataViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
ButterKnife.bind(this, itemView);
|
||||
if (mActivity.typeface != null) {
|
||||
authorTextView.setTypeface(mActivity.typeface);
|
||||
subjectTextView.setTypeface(mActivity.typeface);
|
||||
titleTextView.setTypeface(mActivity.titleTypeface);
|
||||
contentCustomMarkwonView.setTypeface(mActivity.contentTypeface);
|
||||
}
|
||||
itemView.setBackgroundColor(mMessageBackgroundColor);
|
||||
authorTextView.setTextColor(mUsernameColor);
|
||||
subjectTextView.setTextColor(mPrimaryTextColor);
|
||||
titleTextView.setTextColor(mPrimaryTextColor);
|
||||
contentCustomMarkwonView.setTextColor(mSecondaryTextColor);
|
||||
|
||||
contentCustomMarkwonView.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
|
||||
contentCustomMarkwonView.setOnClickListener(view -> {
|
||||
if (contentCustomMarkwonView.getSelectionStart() == -1 && contentCustomMarkwonView.getSelectionEnd() == -1) {
|
||||
itemView.performClick();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
class ErrorViewHolder extends RecyclerView.ViewHolder {
|
||||
@BindView(R.id.error_text_view_item_footer_error)
|
||||
TextView errorTextView;
|
||||
@BindView(R.id.retry_button_item_footer_error)
|
||||
Button retryButton;
|
||||
|
||||
ErrorViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
ButterKnife.bind(this, itemView);
|
||||
if (mActivity.typeface != null) {
|
||||
errorTextView.setTypeface(mActivity.typeface);
|
||||
retryButton.setTypeface(mActivity.typeface);
|
||||
}
|
||||
errorTextView.setText(R.string.load_comments_failed);
|
||||
errorTextView.setTextColor(mSecondaryTextColor);
|
||||
retryButton.setOnClickListener(view -> mRetryLoadingMoreCallback.retryLoadingMore());
|
||||
retryButton.setBackgroundTintList(ColorStateList.valueOf(mColorPrimaryLightTheme));
|
||||
retryButton.setTextColor(mButtonTextColor);
|
||||
}
|
||||
}
|
||||
|
||||
class LoadingViewHolder extends RecyclerView.ViewHolder {
|
||||
@BindView(R.id.progress_bar_item_footer_loading)
|
||||
ProgressBar progressBar;
|
||||
|
||||
LoadingViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
ButterKnife.bind(this, itemView);
|
||||
progressBar.setIndeterminateTintList(ColorStateList.valueOf(mColorAccent));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,34 +27,35 @@ import java.util.Locale;
|
||||
|
||||
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.core.MarkwonTheme;
|
||||
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
||||
import io.noties.markwon.inlineparser.BangInlineProcessor;
|
||||
import io.noties.markwon.inlineparser.HtmlInlineProcessor;
|
||||
import io.noties.markwon.inlineparser.MarkwonInlineParserPlugin;
|
||||
import io.noties.markwon.linkify.LinkifyPlugin;
|
||||
import io.noties.markwon.movement.MovementMethodPlugin;
|
||||
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
||||
import eu.toldi.infinityforlemmy.R;
|
||||
import eu.toldi.infinityforlemmy.activities.LinkResolverActivity;
|
||||
import eu.toldi.infinityforlemmy.activities.ViewPrivateMessagesActivity;
|
||||
import eu.toldi.infinityforlemmy.activities.ViewUserDetailActivity;
|
||||
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||
import eu.toldi.infinityforlemmy.markdown.ClickableGlideImagesPlugin;
|
||||
import eu.toldi.infinityforlemmy.markdown.RedditHeadingPlugin;
|
||||
import eu.toldi.infinityforlemmy.markdown.SpoilerAwareMovementMethod;
|
||||
import eu.toldi.infinityforlemmy.markdown.SpoilerParserPlugin;
|
||||
import eu.toldi.infinityforlemmy.markdown.SuperscriptPlugin;
|
||||
import eu.toldi.infinityforlemmy.message.Message;
|
||||
import eu.toldi.infinityforlemmy.privatemessage.PrivateMessage;
|
||||
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.core.MarkwonTheme;
|
||||
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
||||
import io.noties.markwon.image.glide.GlideImagesPlugin;
|
||||
import io.noties.markwon.inlineparser.HtmlInlineProcessor;
|
||||
import io.noties.markwon.inlineparser.MarkwonInlineParserPlugin;
|
||||
import io.noties.markwon.linkify.LinkifyPlugin;
|
||||
import io.noties.markwon.movement.MovementMethodPlugin;
|
||||
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
||||
|
||||
public class PrivateMessagesDetailRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
private static final int VIEW_TYPE_MESSAGE_SENT = 0;
|
||||
private static final int VIEW_TYPE_MESSAGE_RECEIVED = 1;
|
||||
private Message mMessage;
|
||||
private PrivateMessage mMessage;
|
||||
private ViewPrivateMessagesActivity mViewPrivateMessagesActivity;
|
||||
private RequestManager mGlide;
|
||||
private Locale mLocale;
|
||||
@@ -70,7 +71,7 @@ public class PrivateMessagesDetailRecyclerViewAdapter extends RecyclerView.Adapt
|
||||
|
||||
public PrivateMessagesDetailRecyclerViewAdapter(ViewPrivateMessagesActivity viewPrivateMessagesActivity,
|
||||
SharedPreferences sharedPreferences, Locale locale,
|
||||
Message message, String accountName,
|
||||
PrivateMessage message, String accountName,
|
||||
CustomThemeWrapper customThemeWrapper) {
|
||||
mMessage = message;
|
||||
mViewPrivateMessagesActivity = viewPrivateMessagesActivity;
|
||||
@@ -83,7 +84,6 @@ public class PrivateMessagesDetailRecyclerViewAdapter extends RecyclerView.Adapt
|
||||
mMarkwon = Markwon.builder(viewPrivateMessagesActivity)
|
||||
.usePlugin(MarkwonInlineParserPlugin.create(plugin -> {
|
||||
plugin.excludeInlineProcessor(HtmlInlineProcessor.class);
|
||||
plugin.excludeInlineProcessor(BangInlineProcessor.class);
|
||||
}))
|
||||
.usePlugin(new AbstractMarkwonPlugin() {
|
||||
@Override
|
||||
@@ -108,6 +108,8 @@ public class PrivateMessagesDetailRecyclerViewAdapter extends RecyclerView.Adapt
|
||||
builder.linkColor(customThemeWrapper.getLinkColor());
|
||||
}
|
||||
})
|
||||
.usePlugin(GlideImagesPlugin.create(viewPrivateMessagesActivity))
|
||||
.usePlugin(ClickableGlideImagesPlugin.create(viewPrivateMessagesActivity))
|
||||
.usePlugin(SuperscriptPlugin.create())
|
||||
.usePlugin(StrikethroughPlugin.create())
|
||||
.usePlugin(SpoilerParserPlugin.create(commentColor, commentColor | 0xFF000000))
|
||||
@@ -127,9 +129,9 @@ public class PrivateMessagesDetailRecyclerViewAdapter extends RecyclerView.Adapt
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
if (position == 0) {
|
||||
return mMessage.getAuthor().equals(mAccountName) ? VIEW_TYPE_MESSAGE_SENT : VIEW_TYPE_MESSAGE_RECEIVED;
|
||||
return mMessage.getCreatorQualifiedName().equals(mAccountName) ? VIEW_TYPE_MESSAGE_SENT : VIEW_TYPE_MESSAGE_RECEIVED;
|
||||
} else {
|
||||
return mMessage.getReplies().get(position - 1).getAuthor().equals(mAccountName) ? VIEW_TYPE_MESSAGE_SENT : VIEW_TYPE_MESSAGE_RECEIVED;
|
||||
return mMessage.getReplies().get(position - 1).getCreatorQualifiedName().equals(mAccountName) ? VIEW_TYPE_MESSAGE_SENT : VIEW_TYPE_MESSAGE_RECEIVED;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,7 +147,7 @@ public class PrivateMessagesDetailRecyclerViewAdapter extends RecyclerView.Adapt
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
Message message;
|
||||
PrivateMessage message;
|
||||
if (holder.getBindingAdapterPosition() == 0) {
|
||||
message = mMessage;
|
||||
} else {
|
||||
@@ -153,12 +155,12 @@ public class PrivateMessagesDetailRecyclerViewAdapter extends RecyclerView.Adapt
|
||||
}
|
||||
if (message != null) {
|
||||
if (holder instanceof MessageViewHolder) {
|
||||
mMarkwon.setMarkdown(((MessageViewHolder) holder).messageTextView, message.getBody());
|
||||
mMarkwon.setMarkdown(((MessageViewHolder) holder).messageTextView, message.getContent());
|
||||
|
||||
if (mShowElapsedTime) {
|
||||
((MessageViewHolder) holder).timeTextView.setText(Utils.getElapsedTime(mViewPrivateMessagesActivity, message.getTimeUTC()));
|
||||
((MessageViewHolder) holder).timeTextView.setText(Utils.getElapsedTime(mViewPrivateMessagesActivity, message.getPublished()));
|
||||
} else {
|
||||
((MessageViewHolder) holder).timeTextView.setText(Utils.getFormattedTime(mLocale, message.getTimeUTC(), mTimeFormatPattern));
|
||||
((MessageViewHolder) holder).timeTextView.setText(Utils.getFormattedTime(mLocale, message.getPublished(), mTimeFormatPattern));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,26 +168,33 @@ public class PrivateMessagesDetailRecyclerViewAdapter extends RecyclerView.Adapt
|
||||
((SentMessageViewHolder) holder).messageTextView.setBackground(Utils.getTintedDrawable(mViewPrivateMessagesActivity,
|
||||
R.drawable.private_message_ballon, mSentMessageBackgroundColor));
|
||||
} else if (holder instanceof ReceivedMessageViewHolder) {
|
||||
mViewPrivateMessagesActivity.fetchUserAvatar(message.getAuthor(), userAvatarUrl -> {
|
||||
if (userAvatarUrl == null || userAvatarUrl.equals("")) {
|
||||
mGlide.load(R.drawable.subreddit_default_icon)
|
||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
||||
.into(((ReceivedMessageViewHolder) holder).userAvatarImageView);
|
||||
} else {
|
||||
mGlide.load(userAvatarUrl)
|
||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
||||
.error(mGlide.load(R.drawable.subreddit_default_icon)
|
||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
|
||||
.into(((ReceivedMessageViewHolder) holder).userAvatarImageView);
|
||||
}
|
||||
});
|
||||
if (!message.getCreatorAvatar().equals("")) {
|
||||
mGlide.load(message.getCreatorAvatar())
|
||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
||||
.error(mGlide.load(R.drawable.subreddit_default_icon)
|
||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
|
||||
.into(((ReceivedMessageViewHolder) holder).userAvatarImageView);
|
||||
} else {
|
||||
mViewPrivateMessagesActivity.fetchUserAvatar(message.getCreatorQualifiedName(), userAvatarUrl -> {
|
||||
if (userAvatarUrl == null || userAvatarUrl.equals("")) {
|
||||
mGlide.load(R.drawable.subreddit_default_icon)
|
||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
||||
.into(((ReceivedMessageViewHolder) holder).userAvatarImageView);
|
||||
} else {
|
||||
mGlide.load(userAvatarUrl)
|
||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
||||
.error(mGlide.load(R.drawable.subreddit_default_icon)
|
||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
|
||||
.into(((ReceivedMessageViewHolder) holder).userAvatarImageView);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
((ReceivedMessageViewHolder) holder).userAvatarImageView.setOnClickListener(view -> {
|
||||
if (message.isAuthorDeleted()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Intent intent = new Intent(mViewPrivateMessagesActivity, ViewUserDetailActivity.class);
|
||||
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, message.getAuthor());
|
||||
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, message.getCreatorName());
|
||||
intent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, message.getCreatorQualifiedName());
|
||||
mViewPrivateMessagesActivity.startActivity(intent);
|
||||
});
|
||||
|
||||
@@ -207,12 +216,12 @@ public class PrivateMessagesDetailRecyclerViewAdapter extends RecyclerView.Adapt
|
||||
}
|
||||
}
|
||||
|
||||
public void setMessage(Message message) {
|
||||
public void setMessage(PrivateMessage message) {
|
||||
mMessage = message;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void addReply(Message reply) {
|
||||
public void addReply(PrivateMessage reply) {
|
||||
int currentSize = getItemCount();
|
||||
|
||||
if (mMessage != null) {
|
||||
@@ -273,7 +282,7 @@ public class PrivateMessagesDetailRecyclerViewAdapter extends RecyclerView.Adapt
|
||||
copyImageView.setColorFilter(mSecondaryTextColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||
|
||||
copyImageView.setOnClickListener(view -> {
|
||||
Message message;
|
||||
PrivateMessage message;
|
||||
if (getBindingAdapterPosition() == 0) {
|
||||
message = mMessage;
|
||||
} else {
|
||||
@@ -282,7 +291,7 @@ public class PrivateMessagesDetailRecyclerViewAdapter extends RecyclerView.Adapt
|
||||
if (message != null) {
|
||||
ClipboardManager clipboard = (ClipboardManager) mViewPrivateMessagesActivity.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
if (clipboard != null) {
|
||||
ClipData clip = ClipData.newPlainText("simple text", message.getBody());
|
||||
ClipData clip = ClipData.newPlainText("simple text", message.getContent());
|
||||
clipboard.setPrimaryClip(clip);
|
||||
if (android.os.Build.VERSION.SDK_INT < 33) {
|
||||
Toast.makeText(mViewPrivateMessagesActivity, R.string.copy_success, Toast.LENGTH_SHORT).show();
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
@@ -148,7 +150,7 @@ public class UserListingRecyclerViewAdapter extends PagedListAdapter<UserData, R
|
||||
|
||||
@Override
|
||||
public void isNotSubscribed() {
|
||||
((DataViewHolder) holder).subscribeButton.setVisibility(View.VISIBLE);
|
||||
|
||||
((DataViewHolder) holder).subscribeButton.setOnClickListener(view -> {
|
||||
UserFollowing.followUser(oauthRetrofit, retrofit,
|
||||
accessToken, userData.getName(), accountName, 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) {
|
||||
|
||||
@@ -25,7 +25,7 @@ public class AccountSectionRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
||||
private static final int VIEW_TYPE_MENU_GROUP_TITLE = 1;
|
||||
private static final int VIEW_TYPE_MENU_ITEM = 2;
|
||||
private static final int ACCOUNT_SECTION_ITEMS = 4;
|
||||
private static final int ANONYMOUS_ACCOUNT_SECTION_ITEMS = 2;
|
||||
private static final int ANONYMOUS_ACCOUNT_SECTION_ITEMS = 1;
|
||||
|
||||
private BaseActivity baseActivity;
|
||||
private int inboxCount;
|
||||
|
||||
@@ -39,6 +39,7 @@ public class HeaderSectionRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
|
||||
private Resources resources;
|
||||
private RequestManager glide;
|
||||
private String accountName;
|
||||
private String accountQualifiedName;
|
||||
private String profileImageUrl;
|
||||
private String bannerImageUrl;
|
||||
private int karma;
|
||||
@@ -50,7 +51,7 @@ public class HeaderSectionRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
|
||||
private boolean hideKarma;
|
||||
|
||||
public HeaderSectionRecyclerViewAdapter(BaseActivity baseActivity, CustomThemeWrapper customThemeWrapper,
|
||||
RequestManager glide, String accountName,
|
||||
RequestManager glide, String accountName, String accountQualifiedName,
|
||||
SharedPreferences sharedPreferences,
|
||||
SharedPreferences navigationDrawerSharedPreferences,
|
||||
SharedPreferences securitySharedPreferences,
|
||||
@@ -62,6 +63,7 @@ public class HeaderSectionRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
|
||||
this.accountName = accountName;
|
||||
isLoggedIn = accountName != null;
|
||||
this.pageToggle = pageToggle;
|
||||
this.accountQualifiedName = accountQualifiedName;
|
||||
requireAuthToAccountSection = securitySharedPreferences.getBoolean(SharedPreferencesUtils.REQUIRE_AUTHENTICATION_TO_GO_TO_ACCOUNT_SECTION_IN_NAVIGATION_DRAWER, false);
|
||||
showAvatarOnTheRightInTheNavigationDrawer = sharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_AVATAR_ON_THE_RIGHT, false);
|
||||
showAvatarOnTheRightInTheNavigationDrawer = navigationDrawerSharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_AVATAR_ON_THE_RIGHT, false);
|
||||
@@ -86,15 +88,11 @@ public class HeaderSectionRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
|
||||
}
|
||||
((NavHeaderViewHolder) holder).profileImageView.setLayoutParams(params);
|
||||
if (isLoggedIn) {
|
||||
if (hideKarma) {
|
||||
int karmaTextHeight = ((NavHeaderViewHolder) holder).karmaTextView.getHeight();
|
||||
((NavHeaderViewHolder) holder).karmaTextView.setVisibility(View.GONE);
|
||||
((NavHeaderViewHolder) holder).accountNameTextView.setTranslationY(karmaTextHeight / 2);
|
||||
} else {
|
||||
((NavHeaderViewHolder) holder).karmaTextView.setVisibility(View.VISIBLE);
|
||||
((NavHeaderViewHolder) holder).karmaTextView.setText(baseActivity.getString(R.string.karma_info, karma));
|
||||
((NavHeaderViewHolder) holder).accountNameTextView.setTranslationY(0);
|
||||
}
|
||||
|
||||
((NavHeaderViewHolder) holder).karmaTextView.setVisibility(View.VISIBLE);
|
||||
((NavHeaderViewHolder) holder).karmaTextView.setText(accountQualifiedName);
|
||||
((NavHeaderViewHolder) holder).accountNameTextView.setTranslationY(0);
|
||||
|
||||
((NavHeaderViewHolder) holder).accountNameTextView.setText(accountName);
|
||||
if (profileImageUrl != null && !profileImageUrl.equals("")) {
|
||||
glide.load(profileImageUrl)
|
||||
|
||||
@@ -18,13 +18,13 @@ import eu.toldi.infinityforlemmy.activities.BaseActivity;
|
||||
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||
|
||||
public class RedditSectionRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
public class LemmySectionRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
||||
private static final int VIEW_TYPE_MENU_GROUP_TITLE = 1;
|
||||
private static final int VIEW_TYPE_MENU_ITEM = 2;
|
||||
private static final int REDDIT_SECTION_ITEMS = 1;
|
||||
private static final int LEMMY_SECTION_ITEMS = 2;
|
||||
|
||||
private static final int REDDIT_SECTION_ANONYMOUS_ITEMS = 2;
|
||||
private static final int LEMMY_SECTION_ANONYMOUS_ITEMS = 2;
|
||||
private final boolean isLoggedIn;
|
||||
|
||||
private BaseActivity baseActivity;
|
||||
@@ -34,9 +34,9 @@ public class RedditSectionRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
|
||||
private boolean collapseRedditSection;
|
||||
private NavigationDrawerRecyclerViewMergedAdapter.ItemClickListener itemClickListener;
|
||||
|
||||
public RedditSectionRecyclerViewAdapter(BaseActivity baseActivity, CustomThemeWrapper customThemeWrapper,
|
||||
SharedPreferences navigationDrawerSharedPreferences,
|
||||
NavigationDrawerRecyclerViewMergedAdapter.ItemClickListener itemClickListener, boolean isLoggedIn) {
|
||||
public LemmySectionRecyclerViewAdapter(BaseActivity baseActivity, CustomThemeWrapper customThemeWrapper,
|
||||
SharedPreferences navigationDrawerSharedPreferences,
|
||||
NavigationDrawerRecyclerViewMergedAdapter.ItemClickListener itemClickListener, boolean isLoggedIn) {
|
||||
this.baseActivity = baseActivity;
|
||||
primaryTextColor = customThemeWrapper.getPrimaryTextColor();
|
||||
secondaryTextColor = customThemeWrapper.getSecondaryTextColor();
|
||||
@@ -76,10 +76,10 @@ public class RedditSectionRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
|
||||
holder.itemView.setOnClickListener(view -> {
|
||||
if (collapseRedditSection) {
|
||||
collapseRedditSection = !collapseRedditSection;
|
||||
notifyItemRangeInserted(holder.getBindingAdapterPosition() + 1, REDDIT_SECTION_ITEMS);
|
||||
notifyItemRangeInserted(holder.getBindingAdapterPosition() + 1, isLoggedIn ? LEMMY_SECTION_ITEMS : LEMMY_SECTION_ANONYMOUS_ITEMS);
|
||||
} else {
|
||||
collapseRedditSection = !collapseRedditSection;
|
||||
notifyItemRangeRemoved(holder.getBindingAdapterPosition() + 1, REDDIT_SECTION_ITEMS);
|
||||
notifyItemRangeRemoved(holder.getBindingAdapterPosition() + 1, isLoggedIn ? LEMMY_SECTION_ITEMS : LEMMY_SECTION_ANONYMOUS_ITEMS);
|
||||
}
|
||||
notifyItemChanged(holder.getBindingAdapterPosition());
|
||||
});
|
||||
@@ -89,12 +89,19 @@ public class RedditSectionRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
|
||||
|
||||
switch (position) {
|
||||
case 1:
|
||||
stringId = R.string.trending;
|
||||
drawableId = R.drawable.ic_trending_24dp;
|
||||
stringId = R.string.instance_info;
|
||||
drawableId = R.drawable.ic_baseline_info_24;
|
||||
break;
|
||||
case 2:
|
||||
stringId = R.string.anonymous_account_instance;
|
||||
drawableId = R.drawable.ic_account_circle_24dp;
|
||||
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);
|
||||
@@ -106,7 +113,7 @@ public class RedditSectionRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return !collapseRedditSection ? (isLoggedIn ? REDDIT_SECTION_ITEMS + 1 : REDDIT_SECTION_ANONYMOUS_ITEMS + 1) : 1;
|
||||
return !collapseRedditSection ? (isLoggedIn ? LEMMY_SECTION_ITEMS + 1 : LEMMY_SECTION_ANONYMOUS_ITEMS + 1) : 1;
|
||||
}
|
||||
|
||||
class MenuGroupTitleViewHolder extends RecyclerView.ViewHolder {
|
||||
@@ -21,6 +21,7 @@ public class NavigationDrawerRecyclerViewMergedAdapter {
|
||||
private FavoriteSubscribedSubredditsSectionRecyclerViewAdapter favoriteSubscribedSubredditsSectionRecyclerViewAdapter;
|
||||
private SubscribedSubredditsRecyclerViewAdapter subscribedSubredditsRecyclerViewAdapter;
|
||||
private AccountManagementSectionRecyclerViewAdapter accountManagementSectionRecyclerViewAdapter;
|
||||
private LemmySectionRecyclerViewAdapter lemmySectionRecyclerViewAdapter;
|
||||
private ConcatAdapter mainPageConcatAdapter;
|
||||
|
||||
public NavigationDrawerRecyclerViewMergedAdapter(BaseActivity baseActivity, SharedPreferences sharedPreferences,
|
||||
@@ -28,12 +29,12 @@ public class NavigationDrawerRecyclerViewMergedAdapter {
|
||||
SharedPreferences navigationDrawerSharedPreferences,
|
||||
SharedPreferences securitySharedPreferences,
|
||||
CustomThemeWrapper customThemeWrapper,
|
||||
String accountName,
|
||||
String accountName, String accountQualifiedName,
|
||||
ItemClickListener itemClickListener) {
|
||||
RequestManager glide = Glide.with(baseActivity);
|
||||
|
||||
headerSectionRecyclerViewAdapter = new HeaderSectionRecyclerViewAdapter(baseActivity, customThemeWrapper,
|
||||
glide, accountName, sharedPreferences, navigationDrawerSharedPreferences, securitySharedPreferences,
|
||||
glide, accountName, accountQualifiedName, sharedPreferences, navigationDrawerSharedPreferences, securitySharedPreferences,
|
||||
new HeaderSectionRecyclerViewAdapter.PageToggle() {
|
||||
@Override
|
||||
public void openAccountSection() {
|
||||
@@ -55,10 +56,13 @@ public class NavigationDrawerRecyclerViewMergedAdapter {
|
||||
customThemeWrapper, navigationDrawerSharedPreferences, itemClickListener);
|
||||
accountManagementSectionRecyclerViewAdapter = new AccountManagementSectionRecyclerViewAdapter(baseActivity,
|
||||
customThemeWrapper, glide, accountName != null, itemClickListener);
|
||||
lemmySectionRecyclerViewAdapter = new LemmySectionRecyclerViewAdapter(baseActivity, customThemeWrapper,
|
||||
navigationDrawerSharedPreferences, itemClickListener, accountName != null);
|
||||
|
||||
mainPageConcatAdapter = new ConcatAdapter(
|
||||
headerSectionRecyclerViewAdapter,
|
||||
accountSectionRecyclerViewAdapter,
|
||||
lemmySectionRecyclerViewAdapter,
|
||||
preferenceSectionRecyclerViewAdapter,
|
||||
favoriteSubscribedSubredditsSectionRecyclerViewAdapter,
|
||||
subscribedSubredditsRecyclerViewAdapter);
|
||||
@@ -70,6 +74,7 @@ public class NavigationDrawerRecyclerViewMergedAdapter {
|
||||
|
||||
private void openAccountSection() {
|
||||
mainPageConcatAdapter.removeAdapter(accountSectionRecyclerViewAdapter);
|
||||
mainPageConcatAdapter.removeAdapter(lemmySectionRecyclerViewAdapter);
|
||||
mainPageConcatAdapter.removeAdapter(preferenceSectionRecyclerViewAdapter);
|
||||
mainPageConcatAdapter.removeAdapter(favoriteSubscribedSubredditsSectionRecyclerViewAdapter);
|
||||
mainPageConcatAdapter.removeAdapter(subscribedSubredditsRecyclerViewAdapter);
|
||||
@@ -81,6 +86,7 @@ public class NavigationDrawerRecyclerViewMergedAdapter {
|
||||
mainPageConcatAdapter.removeAdapter(accountManagementSectionRecyclerViewAdapter);
|
||||
|
||||
mainPageConcatAdapter.addAdapter(accountSectionRecyclerViewAdapter);
|
||||
mainPageConcatAdapter.addAdapter(lemmySectionRecyclerViewAdapter);
|
||||
mainPageConcatAdapter.addAdapter(preferenceSectionRecyclerViewAdapter);
|
||||
mainPageConcatAdapter.addAdapter(favoriteSubscribedSubredditsSectionRecyclerViewAdapter);
|
||||
mainPageConcatAdapter.addAdapter(subscribedSubredditsRecyclerViewAdapter);
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.google.common.util.concurrent.ListenableFuture;
|
||||
|
||||
import eu.toldi.infinityforlemmy.dto.AccountLoginDTO;
|
||||
import eu.toldi.infinityforlemmy.dto.AuthDTO;
|
||||
import eu.toldi.infinityforlemmy.dto.BlockCommunityDTO;
|
||||
import eu.toldi.infinityforlemmy.dto.CommentDTO;
|
||||
import eu.toldi.infinityforlemmy.dto.CommentVoteDTO;
|
||||
import eu.toldi.infinityforlemmy.dto.DeleteCommentDTO;
|
||||
@@ -14,12 +15,19 @@ import eu.toldi.infinityforlemmy.dto.EditCommentDTO;
|
||||
import eu.toldi.infinityforlemmy.dto.EditPostDTO;
|
||||
import eu.toldi.infinityforlemmy.dto.FollowCommunityDTO;
|
||||
import eu.toldi.infinityforlemmy.dto.PostVoteDTO;
|
||||
import eu.toldi.infinityforlemmy.dto.PrivateMessageDTO;
|
||||
import eu.toldi.infinityforlemmy.dto.PrivateMessageReadDTO;
|
||||
import eu.toldi.infinityforlemmy.dto.PrivateMessageReportDTO;
|
||||
import eu.toldi.infinityforlemmy.dto.PrivateMessageUpdateDTO;
|
||||
import eu.toldi.infinityforlemmy.dto.ReadCommentDTO;
|
||||
import eu.toldi.infinityforlemmy.dto.ReadMessageDTO;
|
||||
import eu.toldi.infinityforlemmy.dto.ReadPostDTO;
|
||||
import eu.toldi.infinityforlemmy.dto.ReportCommentDTO;
|
||||
import eu.toldi.infinityforlemmy.dto.ReportPostDTO;
|
||||
import eu.toldi.infinityforlemmy.dto.SaveCommentDTO;
|
||||
import eu.toldi.infinityforlemmy.dto.SavePostDTO;
|
||||
import eu.toldi.infinityforlemmy.dto.SubmitPostDTO;
|
||||
import eu.toldi.infinityforlemmy.dto.UserBlockDTO;
|
||||
import eu.toldi.infinityforlemmy.message.MessageCount;
|
||||
import okhttp3.MultipartBody;
|
||||
import retrofit2.Call;
|
||||
@@ -42,6 +50,10 @@ public interface LemmyAPI {
|
||||
@GET("api/v3/user")
|
||||
Call<String> userInfo(@Query("username") String username, @Query("auth") String access_token);
|
||||
|
||||
@Headers("Content-Type: application/json")
|
||||
@POST("api/v3/user/block")
|
||||
Call<String> userBlock(@Body UserBlockDTO params);
|
||||
|
||||
@GET("api/v3/user/mention")
|
||||
Call<String> userMentions(@Query("sort") String sort, @Query("page") Integer page, @Query("limit") Integer limit, @Query("unread_only") boolean unread_only, @Query("auth") String access_token);
|
||||
|
||||
@@ -76,6 +88,10 @@ public interface LemmyAPI {
|
||||
@POST("api/v3/post")
|
||||
Call<String> postCreate(@Body SubmitPostDTO params);
|
||||
|
||||
@Headers("Content-Type: application/json")
|
||||
@POST("api/v3/post/report")
|
||||
Call<String> postReport(@Body ReportPostDTO params);
|
||||
|
||||
@Headers("Content-Type: application/json")
|
||||
@PUT("api/v3/post")
|
||||
Call<String> postUpdate(@Body EditPostDTO params);
|
||||
@@ -85,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,
|
||||
@@ -113,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,
|
||||
@@ -132,10 +169,18 @@ public interface LemmyAPI {
|
||||
@POST("api/v3/comment/like")
|
||||
Call<String> commentLike(@Body CommentVoteDTO params);
|
||||
|
||||
@Headers("Content-Type: application/json")
|
||||
@POST("api/v3/comment/report")
|
||||
Call<String> commentReport(@Body ReportCommentDTO params);
|
||||
|
||||
@Headers("Content-Type: application/json")
|
||||
@POST("api/v3/community/follow")
|
||||
Call<String> communityFollow(@Body FollowCommunityDTO params);
|
||||
|
||||
@Headers("Content-Type: application/json")
|
||||
@POST("api/v3/community/block")
|
||||
Call<String> communityBlock(@Body BlockCommunityDTO params);
|
||||
|
||||
@Headers("Content-Type: application/json")
|
||||
@PUT("api/v3/post/save")
|
||||
Call<String> postSave(@Body SavePostDTO params);
|
||||
@@ -226,4 +271,37 @@ public interface LemmyAPI {
|
||||
Call<String> getSiteInfo(
|
||||
@Query("auth") String auth
|
||||
);
|
||||
|
||||
@GET("api/v3/private_message/list")
|
||||
Call<String> privateMessagesList(
|
||||
@Query("page") Integer page,
|
||||
@Query("limit") Integer limit,
|
||||
@Query("unread_only") Boolean unread_only,
|
||||
@NonNull @Query("auth") String auth
|
||||
);
|
||||
|
||||
@POST("api/v3/private_message")
|
||||
Call<String> privateMessageSend(
|
||||
@Body PrivateMessageDTO params
|
||||
);
|
||||
|
||||
@PUT("api/v3/private_message")
|
||||
Call<String> privateMessageEdit(
|
||||
@Body PrivateMessageUpdateDTO params
|
||||
);
|
||||
|
||||
@POST("api/v3/private_message/delete")
|
||||
Call<String> privateMessageDelete(
|
||||
@Body PrivateMessageUpdateDTO params
|
||||
);
|
||||
|
||||
@POST("api/v3/private_message/mark_as_read")
|
||||
Call<String> privateMessageMarkAsRead(
|
||||
@Body PrivateMessageReadDTO params
|
||||
);
|
||||
|
||||
@POST("api/v3/private_message/report")
|
||||
Call<String> privateMessageReport(
|
||||
@Body PrivateMessageReportDTO params
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -0,0 +1,130 @@
|
||||
package eu.toldi.infinityforlemmy.asynctasks;
|
||||
|
||||
import android.os.Handler;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
|
||||
import eu.toldi.infinityforlemmy.blockedcommunity.BlockedCommunityDao;
|
||||
import eu.toldi.infinityforlemmy.blockedcommunity.BlockedCommunityData;
|
||||
import eu.toldi.infinityforlemmy.blockeduser.BlockedUserDao;
|
||||
import eu.toldi.infinityforlemmy.blockeduser.BlockedUserData;
|
||||
|
||||
|
||||
public class InsertBlockedThings {
|
||||
|
||||
public static void insertBlockedThings(Executor executor, Handler handler,
|
||||
RedditDataRoomDatabase redditDataRoomDatabase, @Nullable String accountName,
|
||||
List<BlockedCommunityData> blockedCommunityDataList,
|
||||
List<BlockedUserData> blockedUserDataDataList,
|
||||
|
||||
InsertBlockedThingListener insertSubscribedThingListener) {
|
||||
executor.execute(() -> {
|
||||
if (accountName != null && redditDataRoomDatabase.accountDao().getAccountData(accountName) == null) {
|
||||
handler.post(insertSubscribedThingListener::insertSuccess);
|
||||
return;
|
||||
}
|
||||
|
||||
BlockedUserDao blockedUserDao = redditDataRoomDatabase.blockedUserDao();
|
||||
BlockedCommunityDao blockedCommunityDao = redditDataRoomDatabase.blockedCommunityDao();
|
||||
|
||||
|
||||
if (blockedCommunityDataList != null) {
|
||||
List<BlockedCommunityData> existingBlockedCommunityDaoList =
|
||||
blockedCommunityDao.getAllBlockedCommunitiesList(accountName);
|
||||
Collections.sort(blockedCommunityDataList, (subscribedSubredditData, t1) -> subscribedSubredditData.getName().compareToIgnoreCase(t1.getName()));
|
||||
List<String> unsubscribedSubreddits = new ArrayList<>();
|
||||
compareTwoSubscribedSubredditList(blockedCommunityDataList, existingBlockedCommunityDaoList,
|
||||
unsubscribedSubreddits);
|
||||
|
||||
for (String unsubscribed : unsubscribedSubreddits) {
|
||||
blockedCommunityDao.deleteBlockedCommunity(unsubscribed, accountName);
|
||||
}
|
||||
|
||||
for (BlockedCommunityData s : blockedCommunityDataList) {
|
||||
blockedCommunityDao.insert(s);
|
||||
}
|
||||
}
|
||||
|
||||
if (blockedUserDataDataList != null) {
|
||||
List<BlockedUserData> existingBlockedUserDataList =
|
||||
blockedUserDao.getAllBlockedUsersList(accountName);
|
||||
Collections.sort(blockedUserDataDataList, (subscribedUserData, t1) -> subscribedUserData.getName().compareToIgnoreCase(t1.getName()));
|
||||
List<String> unsubscribedUsers = new ArrayList<>();
|
||||
compareTwoSubscribedUserList(blockedUserDataDataList, existingBlockedUserDataList,
|
||||
unsubscribedUsers);
|
||||
|
||||
for (String unsubscribed : unsubscribedUsers) {
|
||||
blockedUserDao.deleteBlockedUser(unsubscribed, accountName);
|
||||
}
|
||||
|
||||
for (BlockedUserData s : blockedUserDataDataList) {
|
||||
blockedUserDao.insert(s);
|
||||
}
|
||||
}
|
||||
|
||||
handler.post(insertSubscribedThingListener::insertSuccess);
|
||||
});
|
||||
}
|
||||
|
||||
private static void compareTwoSubscribedSubredditList(List<BlockedCommunityData> newSubscribedSubreddits,
|
||||
List<BlockedCommunityData> 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).getQualified_name());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
BlockedCommunityData old = oldSubscribedSubreddits.get(oldIndex);
|
||||
for (; newIndex < newSubscribedSubreddits.size(); newIndex++) {
|
||||
if (newSubscribedSubreddits.get(newIndex).getQualified_name().compareToIgnoreCase(old.getQualified_name()) == 0) {
|
||||
newIndex++;
|
||||
break;
|
||||
}
|
||||
if (newSubscribedSubreddits.get(newIndex).getQualified_name().compareToIgnoreCase(old.getQualified_name()) > 0) {
|
||||
unsubscribedSubredditNames.add(old.getQualified_name());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void compareTwoSubscribedUserList(List<BlockedUserData> newSubscribedUsers,
|
||||
List<BlockedUserData> oldSubscribedUsers,
|
||||
List<String> unsubscribedUserNames) {
|
||||
int newIndex = 0;
|
||||
for (int oldIndex = 0; oldIndex < oldSubscribedUsers.size(); oldIndex++) {
|
||||
if (newIndex >= newSubscribedUsers.size()) {
|
||||
for (; oldIndex < oldSubscribedUsers.size(); oldIndex++) {
|
||||
unsubscribedUserNames.add(oldSubscribedUsers.get(oldIndex).getQualifiedName());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
BlockedUserData old = oldSubscribedUsers.get(oldIndex);
|
||||
for (; newIndex < newSubscribedUsers.size(); newIndex++) {
|
||||
if (newSubscribedUsers.get(newIndex).getName().compareToIgnoreCase(old.getName()) == 0) {
|
||||
newIndex++;
|
||||
break;
|
||||
}
|
||||
if (newSubscribedUsers.get(newIndex).getName().compareToIgnoreCase(old.getName()) > 0) {
|
||||
unsubscribedUserNames.add(old.getQualifiedName());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public interface InsertBlockedThingListener {
|
||||
void insertSuccess();
|
||||
}
|
||||
}
|
||||
@@ -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,10 @@ public class InsertSubscribedThings {
|
||||
}
|
||||
|
||||
for (SubscribedSubredditData s : subscribedSubredditDataList) {
|
||||
if (existingSubscribedSubredditDataList.contains(s)) {
|
||||
subscribedSubredditDao.updateSubscribedSubreddit(s.getQualified_name(), s.getName(), s.getIconUrl(), accountName);
|
||||
continue;
|
||||
}
|
||||
subscribedSubredditDao.insert(s);
|
||||
}
|
||||
}
|
||||
@@ -79,7 +83,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 +99,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 +115,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()) {
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package eu.toldi.infinityforlemmy.blockedcommunity;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.room.Dao;
|
||||
import androidx.room.Insert;
|
||||
import androidx.room.OnConflictStrategy;
|
||||
import androidx.room.Query;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Dao
|
||||
public interface BlockedCommunityDao {
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
void insert(BlockedCommunityData communityData);
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
void insertAll(List<BlockedCommunityData> blockedCommunityDataList);
|
||||
|
||||
@Query("SELECT * FROM blocked_communities WHERE account_name = :accountName AND name LIKE '%' || :searchQuery || '%' COLLATE NOCASE ORDER BY name COLLATE NOCASE ASC")
|
||||
LiveData<List<BlockedCommunityData>> getAllBlockedCommunitiesWithSearchQuery(String accountName, String searchQuery);
|
||||
|
||||
@Query("SELECT * FROM blocked_communities WHERE account_name = :accountName COLLATE NOCASE ORDER BY name COLLATE NOCASE ASC")
|
||||
List<BlockedCommunityData> getAllBlockedCommunitiesList(String accountName);
|
||||
|
||||
@Query("SELECT * FROM blocked_communities WHERE name = :name COLLATE NOCASE AND account_name = :accountName COLLATE NOCASE LIMIT 1")
|
||||
BlockedCommunityData getBlockedCommunity(String name, String accountName);
|
||||
|
||||
@Query("DELETE FROM blocked_communities WHERE qualified_name = :name COLLATE NOCASE AND account_name = :accountName COLLATE NOCASE")
|
||||
void deleteBlockedCommunity(String name, String accountName);
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package eu.toldi.infinityforlemmy.blockedcommunity;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.room.ColumnInfo;
|
||||
import androidx.room.Entity;
|
||||
|
||||
import eu.toldi.infinityforlemmy.subreddit.SubredditData;
|
||||
import eu.toldi.infinityforlemmy.utils.LemmyUtils;
|
||||
|
||||
@Entity(tableName = "blocked_communities", primaryKeys = {"id", "account_name"})
|
||||
public class BlockedCommunityData {
|
||||
|
||||
@ColumnInfo(name = "id")
|
||||
private final int id;
|
||||
|
||||
@ColumnInfo(name = "name")
|
||||
private String name;
|
||||
|
||||
@ColumnInfo(name = "qualified_name")
|
||||
private String qualified_name;
|
||||
@ColumnInfo(name = "icon")
|
||||
private String iconUrl;
|
||||
|
||||
@NonNull
|
||||
@ColumnInfo(name = "account_name")
|
||||
private String accountName;
|
||||
|
||||
public BlockedCommunityData(int id, String name, String qualified_name, String iconUrl, @NonNull String accountName) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.qualified_name = qualified_name;
|
||||
this.iconUrl = iconUrl;
|
||||
this.accountName = accountName;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getQualified_name() {
|
||||
return qualified_name;
|
||||
}
|
||||
|
||||
public String getIconUrl() {
|
||||
return iconUrl;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public String getAccountName() {
|
||||
return accountName;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void setQualified_name(String qualified_name) {
|
||||
this.qualified_name = qualified_name;
|
||||
}
|
||||
|
||||
public void setIconUrl(String iconUrl) {
|
||||
this.iconUrl = iconUrl;
|
||||
}
|
||||
|
||||
public void setAccountName(@NonNull String accountName) {
|
||||
this.accountName = accountName;
|
||||
}
|
||||
|
||||
public BlockedCommunityData(SubredditData subredditData, @NonNull String accountName) {
|
||||
this.id = subredditData.getId();
|
||||
this.name = subredditData.getName();
|
||||
this.qualified_name = LemmyUtils.actorID2FullName(subredditData.getActorId());
|
||||
this.iconUrl = subredditData.getIconUrl();
|
||||
this.accountName = accountName;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package eu.toldi.infinityforlemmy.blockedcommunity;
|
||||
|
||||
import android.os.AsyncTask;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
|
||||
|
||||
public class BlockedCommunityRepository {
|
||||
private BlockedCommunityDao blockedCommunityDao;
|
||||
private String mAccountName;
|
||||
|
||||
BlockedCommunityRepository(RedditDataRoomDatabase redditDataRoomDatabase, String accountName) {
|
||||
mAccountName = accountName;
|
||||
blockedCommunityDao = redditDataRoomDatabase.blockedCommunityDao();
|
||||
}
|
||||
|
||||
LiveData<List<BlockedCommunityData>> getAllSubscribedSubredditsWithSearchQuery(String searchQuery) {
|
||||
return blockedCommunityDao.getAllBlockedCommunitiesWithSearchQuery(mAccountName, searchQuery);
|
||||
}
|
||||
|
||||
public void insert(BlockedCommunityData subscribedSubredditData) {
|
||||
new insertAsyncTask(blockedCommunityDao).execute(subscribedSubredditData);
|
||||
}
|
||||
|
||||
private static class insertAsyncTask extends AsyncTask<BlockedCommunityData, Void, Void> {
|
||||
|
||||
private BlockedCommunityDao mAsyncTaskDao;
|
||||
|
||||
insertAsyncTask(BlockedCommunityDao dao) {
|
||||
mAsyncTaskDao = dao;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(final BlockedCommunityData... params) {
|
||||
mAsyncTaskDao.insert(params[0]);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package eu.toldi.infinityforlemmy.blockedcommunity;
|
||||
|
||||
import android.app.Application;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.AndroidViewModel;
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
import androidx.lifecycle.Transformations;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
|
||||
|
||||
public class BlockedCommunityViewModel extends AndroidViewModel {
|
||||
private BlockedCommunityRepository blockedCommunityRepository;
|
||||
private LiveData<List<BlockedCommunityData>> mAllBlockedCommunities;
|
||||
private MutableLiveData<String> searchQueryLiveData;
|
||||
|
||||
public BlockedCommunityViewModel(Application application, RedditDataRoomDatabase redditDataRoomDatabase, String accountName) {
|
||||
super(application);
|
||||
blockedCommunityRepository = new BlockedCommunityRepository(redditDataRoomDatabase, accountName);
|
||||
searchQueryLiveData = new MutableLiveData<>();
|
||||
searchQueryLiveData.postValue("");
|
||||
|
||||
mAllBlockedCommunities = Transformations.switchMap(searchQueryLiveData, searchQuery -> blockedCommunityRepository.getAllSubscribedSubredditsWithSearchQuery(searchQuery));
|
||||
}
|
||||
|
||||
public LiveData<List<BlockedCommunityData>> getAllBlockedCommunities() {
|
||||
return mAllBlockedCommunities;
|
||||
}
|
||||
|
||||
public void insert(BlockedCommunityData subscribedSubredditData) {
|
||||
blockedCommunityRepository.insert(subscribedSubredditData);
|
||||
}
|
||||
|
||||
public void setSearchQuery(String searchQuery) {
|
||||
searchQueryLiveData.postValue(searchQuery);
|
||||
}
|
||||
|
||||
public static class Factory extends ViewModelProvider.NewInstanceFactory {
|
||||
private Application mApplication;
|
||||
private RedditDataRoomDatabase mRedditDataRoomDatabase;
|
||||
private String mAccountName;
|
||||
|
||||
public Factory(Application application, RedditDataRoomDatabase redditDataRoomDatabase, String accountName) {
|
||||
this.mApplication = application;
|
||||
this.mRedditDataRoomDatabase = redditDataRoomDatabase;
|
||||
this.mAccountName = accountName;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public <T extends ViewModel> T create(@NonNull Class<T> modelClass) {
|
||||
return (T) new BlockedCommunityViewModel(mApplication, mRedditDataRoomDatabase, mAccountName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package eu.toldi.infinityforlemmy.blockeduser;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.room.Dao;
|
||||
import androidx.room.Insert;
|
||||
import androidx.room.OnConflictStrategy;
|
||||
import androidx.room.Query;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Dao
|
||||
public interface BlockedUserDao {
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
void insert(BlockedUserData userData);
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
void insertAll(List<BlockedUserData> blockedUserDataDataList);
|
||||
|
||||
@Query("SELECT * FROM blocked_users WHERE account_name = :accountName AND name LIKE '%' || :searchQuery || '%' COLLATE NOCASE ORDER BY name COLLATE NOCASE ASC")
|
||||
LiveData<List<BlockedUserData>> getAllBlockedUsersWithSearchQuery(String accountName, String searchQuery);
|
||||
|
||||
@Query("SELECT * FROM blocked_users WHERE account_name = :accountName COLLATE NOCASE ORDER BY name COLLATE NOCASE ASC")
|
||||
List<BlockedUserData> getAllBlockedUsersList(String accountName);
|
||||
|
||||
@Query("SELECT * FROM blocked_users WHERE name = :name COLLATE NOCASE AND account_name = :accountName COLLATE NOCASE LIMIT 1")
|
||||
BlockedUserData getBlockedUser(String name, String accountName);
|
||||
|
||||
@Query("DELETE FROM blocked_users WHERE qualified_name = :name COLLATE NOCASE AND account_name = :accountName COLLATE NOCASE")
|
||||
void deleteBlockedUser(String name, String accountName);
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package eu.toldi.infinityforlemmy.blockeduser;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.room.ColumnInfo;
|
||||
import androidx.room.Entity;
|
||||
|
||||
import eu.toldi.infinityforlemmy.user.UserData;
|
||||
import eu.toldi.infinityforlemmy.utils.LemmyUtils;
|
||||
|
||||
@Entity(tableName = "blocked_users", primaryKeys = {"id", "account_name"})
|
||||
public class BlockedUserData {
|
||||
|
||||
@ColumnInfo(name = "id")
|
||||
private final int id;
|
||||
|
||||
@ColumnInfo(name = "name")
|
||||
private String name;
|
||||
|
||||
@ColumnInfo(name = "avatar")
|
||||
private String avatar;
|
||||
|
||||
@ColumnInfo(name = "qualified_name")
|
||||
private String qualifiedName;
|
||||
|
||||
@NonNull
|
||||
@ColumnInfo(name = "account_name")
|
||||
private String accountName;
|
||||
|
||||
public BlockedUserData(int id, String name, String avatar, String qualifiedName, String accountName) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.avatar = avatar;
|
||||
this.qualifiedName = qualifiedName;
|
||||
this.accountName = accountName;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getAvatar() {
|
||||
return avatar;
|
||||
}
|
||||
|
||||
public void setAvatar(String avatar) {
|
||||
this.avatar = avatar;
|
||||
}
|
||||
|
||||
public String getQualifiedName() {
|
||||
return qualifiedName;
|
||||
}
|
||||
|
||||
public void setQualifiedName(String qualifiedName) {
|
||||
this.qualifiedName = qualifiedName;
|
||||
}
|
||||
|
||||
public String getAccountName() {
|
||||
return accountName;
|
||||
}
|
||||
|
||||
public void setAccountName(String accountName) {
|
||||
this.accountName = accountName;
|
||||
}
|
||||
|
||||
public BlockedUserData(UserData userData, @NonNull String accountName) {
|
||||
this.id = userData.getId();
|
||||
this.name = userData.getName();
|
||||
this.avatar = userData.getAvatar();
|
||||
this.qualifiedName = LemmyUtils.actorID2FullName(userData.getActorId());
|
||||
this.accountName = accountName;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package eu.toldi.infinityforlemmy.blockeduser;
|
||||
|
||||
import android.os.AsyncTask;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
|
||||
|
||||
public class BlockedUserRepository {
|
||||
|
||||
private BlockedUserDao mBlockedUserDao;
|
||||
private String mAccountName;
|
||||
|
||||
BlockedUserRepository(RedditDataRoomDatabase redditDataRoomDatabase, String accountName) {
|
||||
mBlockedUserDao = redditDataRoomDatabase.blockedUserDao();
|
||||
mAccountName = accountName;
|
||||
}
|
||||
|
||||
LiveData<List<BlockedUserData>> getAllBlockedUsersWithSearchQuery(String searchQuery) {
|
||||
return mBlockedUserDao.getAllBlockedUsersWithSearchQuery(mAccountName, searchQuery);
|
||||
}
|
||||
|
||||
LiveData<List<BlockedUserData>> getAllFavoriteSubscribedUsersWithSearchQuery(String searchQuery) {
|
||||
return mBlockedUserDao.getAllBlockedUsersWithSearchQuery(mAccountName, searchQuery);
|
||||
}
|
||||
|
||||
public void insert(BlockedUserData BlockedUserData) {
|
||||
new BlockedUserRepository.insertAsyncTask(mBlockedUserDao).execute(BlockedUserData);
|
||||
}
|
||||
|
||||
private static class insertAsyncTask extends AsyncTask<BlockedUserData, Void, Void> {
|
||||
|
||||
private BlockedUserDao mAsyncTaskDao;
|
||||
|
||||
insertAsyncTask(BlockedUserDao dao) {
|
||||
mAsyncTaskDao = dao;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(final BlockedUserData... params) {
|
||||
mAsyncTaskDao.insert(params[0]);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package eu.toldi.infinityforlemmy.blockeduser;
|
||||
|
||||
import android.app.Application;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.AndroidViewModel;
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
import androidx.lifecycle.Transformations;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
|
||||
|
||||
public class BlockedUserViewModel extends AndroidViewModel {
|
||||
private BlockedUserRepository blockedUserRepository;
|
||||
private LiveData<List<BlockedUserData>> mAllSubscribedUsers;
|
||||
private MutableLiveData<String> searchQueryLiveData;
|
||||
|
||||
public BlockedUserViewModel(Application application, RedditDataRoomDatabase redditDataRoomDatabase, String accountName) {
|
||||
super(application);
|
||||
blockedUserRepository = new BlockedUserRepository(redditDataRoomDatabase, accountName);
|
||||
searchQueryLiveData = new MutableLiveData<>();
|
||||
searchQueryLiveData.postValue("");
|
||||
|
||||
mAllSubscribedUsers = Transformations.switchMap(searchQueryLiveData, searchQuery -> blockedUserRepository.getAllFavoriteSubscribedUsersWithSearchQuery(searchQuery));
|
||||
}
|
||||
|
||||
public LiveData<List<BlockedUserData>> getAllSubscribedUsers() {
|
||||
return mAllSubscribedUsers;
|
||||
}
|
||||
|
||||
|
||||
public void insert(BlockedUserData BlockedUserData) {
|
||||
blockedUserRepository.insert(BlockedUserData);
|
||||
}
|
||||
|
||||
public void setSearchQuery(String searchQuery) {
|
||||
searchQueryLiveData.postValue(searchQuery);
|
||||
}
|
||||
|
||||
public static class Factory extends ViewModelProvider.NewInstanceFactory {
|
||||
private Application mApplication;
|
||||
private RedditDataRoomDatabase mRedditDataRoomDatabase;
|
||||
private String mAccountName;
|
||||
|
||||
public Factory(Application application, RedditDataRoomDatabase redditDataRoomDatabase, String accountName) {
|
||||
mApplication = application;
|
||||
mRedditDataRoomDatabase = redditDataRoomDatabase;
|
||||
mAccountName = accountName;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public <T extends ViewModel> T create(@NonNull Class<T> modelClass) {
|
||||
return (T) new BlockedUserViewModel(mApplication, mRedditDataRoomDatabase, mAccountName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,31 +4,42 @@ 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;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.core.content.ContextCompat;
|
||||
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;
|
||||
import eu.toldi.infinityforlemmy.Infinity;
|
||||
import eu.toldi.infinityforlemmy.R;
|
||||
import eu.toldi.infinityforlemmy.activities.BaseActivity;
|
||||
import eu.toldi.infinityforlemmy.activities.CommentActivity;
|
||||
import eu.toldi.infinityforlemmy.activities.EditCommentActivity;
|
||||
import eu.toldi.infinityforlemmy.activities.GiveAwardActivity;
|
||||
import eu.toldi.infinityforlemmy.activities.ReportActivity;
|
||||
import eu.toldi.infinityforlemmy.activities.ViewPostDetailActivity;
|
||||
import eu.toldi.infinityforlemmy.activities.ViewUserDetailActivity;
|
||||
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;
|
||||
|
||||
|
||||
@@ -57,8 +68,21 @@ public class CommentMoreBottomSheetFragment extends LandscapeExpandedRoundedBott
|
||||
TextView copyTextView;
|
||||
@BindView(R.id.report_view_comment_more_bottom_sheet_fragment)
|
||||
TextView reportTextView;
|
||||
|
||||
@Inject
|
||||
LemmyCommentAPI lemmyCommentAPI;
|
||||
|
||||
@Inject
|
||||
CustomThemeWrapper mCustomThemeWrapper;
|
||||
|
||||
@Inject
|
||||
@Named("default")
|
||||
SharedPreferences mSharedPreferences;
|
||||
|
||||
private BaseActivity activity;
|
||||
|
||||
private boolean mShareLinksOnLocalInstance;
|
||||
|
||||
public CommentMoreBottomSheetFragment() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
@@ -66,6 +90,7 @@ public class CommentMoreBottomSheetFragment extends LandscapeExpandedRoundedBott
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
((Infinity) activity.getApplication()).getAppComponent().inject(this);
|
||||
View rootView = inflater.inflate(R.layout.fragment_comment_more_bottom_sheet, container, false);
|
||||
ButterKnife.bind(this, rootView);
|
||||
|
||||
@@ -87,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("")) {
|
||||
|
||||
@@ -151,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();
|
||||
@@ -166,7 +192,7 @@ public class CommentMoreBottomSheetFragment extends LandscapeExpandedRoundedBott
|
||||
|
||||
shareTextView.setOnLongClickListener(view -> {
|
||||
dismiss();
|
||||
activity.copyLink(comment.getPermalink());
|
||||
activity.copyLink(link);
|
||||
return true;
|
||||
});
|
||||
|
||||
@@ -177,11 +203,50 @@ public class CommentMoreBottomSheetFragment extends LandscapeExpandedRoundedBott
|
||||
});
|
||||
|
||||
reportTextView.setOnClickListener(view -> {
|
||||
/*Intent intent = new Intent(activity, ReportActivity.class);
|
||||
intent.putExtra(ReportActivity.EXTRA_SUBREDDIT_NAME, comment.getCommunityName());
|
||||
intent.putExtra(ReportActivity.EXTRA_THING_FULLNAME, comment.getFullName());
|
||||
activity.startActivity(intent);*/
|
||||
Toast.makeText(activity, R.string.not_implemented, Toast.LENGTH_SHORT).show();
|
||||
if (accessToken == null) {
|
||||
Toast.makeText(activity, R.string.login_first, Toast.LENGTH_SHORT).show();
|
||||
dismiss();
|
||||
return;
|
||||
}
|
||||
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)
|
||||
.setView(dialog_view)
|
||||
.setNegativeButton(R.string.cancel, (dialogInterface, i) -> dialogInterface.dismiss())
|
||||
.setPositiveButton(R.string.send_report, (dialogInterface, i) -> {
|
||||
String reason = reasonEditText.getText().toString();
|
||||
if (reason.isEmpty()) {
|
||||
Toast.makeText(activity, "A report reason must be provided", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
lemmyCommentAPI.reportComment(comment.getId(), reason, accessToken, new LemmyCommentAPI.ReportCommentCallback() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
Toast.makeText(activity, R.string.report_successful, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure() {
|
||||
Toast.makeText(activity, R.string.report_failed, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
});
|
||||
AlertDialog dialog = builder.create();
|
||||
dialog.show();
|
||||
|
||||
Button positiveButton = dialog.getButton(AlertDialog.BUTTON_POSITIVE);
|
||||
Button negativeButton = dialog.getButton(AlertDialog.BUTTON_NEGATIVE);
|
||||
positiveButton.setTextColor(mCustomThemeWrapper.getSecondaryTextColor());
|
||||
negativeButton.setTextColor(mCustomThemeWrapper.getSecondaryTextColor());
|
||||
dismiss();
|
||||
});
|
||||
|
||||
|
||||
@@ -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;
|
||||
@@ -41,7 +40,8 @@ public class Comment implements Parcelable {
|
||||
|
||||
private String communityQualifiedName;
|
||||
private Integer parentId;
|
||||
private int score;
|
||||
private int downvotes;
|
||||
private int upvotes;
|
||||
private int voteType;
|
||||
private boolean isSubmitter;
|
||||
private String distinguished;
|
||||
@@ -65,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 score,
|
||||
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;
|
||||
@@ -83,7 +81,8 @@ public class Comment implements Parcelable {
|
||||
this.communityName = communityName;
|
||||
this.communityQualifiedName = communityQualifiedName;
|
||||
this.parentId = parentId;
|
||||
this.score = score;
|
||||
this.downvotes = downvotes;
|
||||
this.upvotes = upvotes;
|
||||
this.voteType = voteType;
|
||||
this.isSubmitter = isSubmitter;
|
||||
this.distinguished = distinguished;
|
||||
@@ -120,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();
|
||||
@@ -132,7 +128,8 @@ public class Comment implements Parcelable {
|
||||
communityName = in.readString();
|
||||
communityQualifiedName = in.readString();
|
||||
parentId = in.readInt();
|
||||
score = in.readInt();
|
||||
downvotes = in.readInt();
|
||||
upvotes = in.readInt();
|
||||
voteType = in.readInt();
|
||||
isSubmitter = in.readByte() != 0;
|
||||
distinguished = in.readString();
|
||||
@@ -166,8 +163,8 @@ public class Comment implements Parcelable {
|
||||
return fullName;
|
||||
}
|
||||
|
||||
public String getAuthor() {
|
||||
return author;
|
||||
public String getAuthorName() {
|
||||
return author.getDisplayName();
|
||||
}
|
||||
|
||||
public boolean isAuthorDeleted() {
|
||||
@@ -175,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() {
|
||||
@@ -228,11 +226,23 @@ public class Comment implements Parcelable {
|
||||
}
|
||||
|
||||
public int getScore() {
|
||||
return score;
|
||||
return upvotes-downvotes;
|
||||
}
|
||||
|
||||
public void setScore(int score) {
|
||||
this.score = score;
|
||||
public int getDownvotes() {
|
||||
return downvotes;
|
||||
}
|
||||
|
||||
public void setDownvotes(int downvotes) {
|
||||
this.downvotes = downvotes;
|
||||
}
|
||||
|
||||
public int getUpvotes() {
|
||||
return upvotes;
|
||||
}
|
||||
|
||||
public void setUpvotes(int upvotes) {
|
||||
this.upvotes = upvotes;
|
||||
}
|
||||
|
||||
public boolean isSubmitter() {
|
||||
@@ -420,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);
|
||||
@@ -432,7 +439,8 @@ public class Comment implements Parcelable {
|
||||
parcel.writeString(communityName);
|
||||
parcel.writeString(communityQualifiedName);
|
||||
parcel.writeInt(parentId == null ? 0 : parentId);
|
||||
parcel.writeInt(score);
|
||||
parcel.writeInt(downvotes);
|
||||
parcel.writeInt(upvotes);
|
||||
parcel.writeInt(voteType);
|
||||
parcel.writeByte((byte) (isSubmitter ? 1 : 0));
|
||||
parcel.writeString(distinguished);
|
||||
@@ -470,7 +478,7 @@ public class Comment implements Parcelable {
|
||||
}
|
||||
|
||||
public String getAuthorQualifiedName() {
|
||||
return authorQualifiedName;
|
||||
return author.getQualifiedName();
|
||||
}
|
||||
|
||||
public String getCommunityQualifiedName() {
|
||||
@@ -480,4 +488,8 @@ public class Comment implements Parcelable {
|
||||
public int getPostId() {
|
||||
return postId;
|
||||
}
|
||||
|
||||
public BasicUserInfo getAuthor() {
|
||||
return author;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -316,10 +317,16 @@ public class ParseComment {
|
||||
String communityName = communityObj.getString("name");
|
||||
String communityQualifiedName = LemmyUtils.actorID2FullName(communityObj.getString("actor_id"));
|
||||
|
||||
int score = countsObj.getInt("score");
|
||||
int upvotes = countsObj.getInt("upvotes");
|
||||
int downvotes = countsObj.getInt("downvotes");
|
||||
int voteType = (jsonObject.isNull("my_vote")) ? 0 : jsonObject.getInt("my_vote");
|
||||
if (voteType != 0)
|
||||
score -= 1;
|
||||
if (voteType != 0) {
|
||||
if(voteType == 1) {
|
||||
upvotes--;
|
||||
} else {
|
||||
downvotes--;
|
||||
}
|
||||
}
|
||||
boolean isSubmitter = creatorObj.getInt("id") == postObj.getInt("creator_id");
|
||||
String distinguished = commentObj.getString("distinguished");
|
||||
String permalink = commentObj.getString("ap_id");
|
||||
@@ -334,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,
|
||||
score, 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);
|
||||
|
||||
@@ -54,407 +54,412 @@ public class CustomThemeWrapper {
|
||||
|
||||
public int getColorPrimary() {
|
||||
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.COLOR_PRIMARY,
|
||||
getDefaultColor("#0336FF", "#242424", "#000000"));
|
||||
getDefaultColor("#F2E9E1", "#2B3B51", "#282828"));
|
||||
}
|
||||
|
||||
public int getColorPrimaryDark() {
|
||||
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.COLOR_PRIMARY_DARK,
|
||||
getDefaultColor("#002BF0", "#121212", "#000000"));
|
||||
getDefaultColor("#F2E9E1", "#192330", "#161616"));
|
||||
}
|
||||
|
||||
public int getColorAccent() {
|
||||
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.COLOR_ACCENT,
|
||||
getDefaultColor("#FF1868", "#FF1868", "#FF1868"));
|
||||
getDefaultColor("#3D2B5A", "#CDCECF", "#F2F4F8"));
|
||||
}
|
||||
|
||||
public int getColorPrimaryLightTheme() {
|
||||
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.COLOR_PRIMARY_LIGHT_THEME,
|
||||
getDefaultColor("#0336FF", "#0336FF", "#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", "#979797", "#979797"));
|
||||
getDefaultColor("#352C24", "#738091", "#484848"));
|
||||
}
|
||||
|
||||
public int getReadPostContentColor() {
|
||||
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.READ_POST_CONTENT_COLOR,
|
||||
getDefaultColor("#9D9D9D", "#979797", "#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", "#121212", "#000000"));
|
||||
getDefaultColor("#F6F2EE", "#192330", "#161616"));
|
||||
}
|
||||
|
||||
public int getCardViewBackgroundColor() {
|
||||
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.CARD_VIEW_BACKGROUND_COLOR,
|
||||
getDefaultColor("#FFFFFF", "#242424", "#000000"));
|
||||
getDefaultColor("#F2E9E1", "#2B3B51", "#282828"));
|
||||
}
|
||||
|
||||
public int getReadPostCardViewBackgroundColor() {
|
||||
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.READ_POST_CARD_VIEW_BACKGROUND_COLOR,
|
||||
getDefaultColor("#F5F5F5", "#101010", "#000000"));
|
||||
getDefaultColor("#F2E9E1", "#2B3B51", "#282828"));
|
||||
}
|
||||
|
||||
public int getCommentBackgroundColor() {
|
||||
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.COMMENT_BACKGROUND_COLOR,
|
||||
getDefaultColor("#FFFFFF", "#242424", "#000000"));
|
||||
getDefaultColor("#F6F2EE", "#192330", "#282828"));
|
||||
}
|
||||
|
||||
public int getBottomAppBarBackgroundColor() {
|
||||
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.BOTTOM_APP_BAR_BACKGROUND_COLOR,
|
||||
getDefaultColor("#FFFFFF", "#121212", "#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", "#242424", "#000000"));
|
||||
getDefaultColor("#F6F2EE", "#2B3B51", "#282828"));
|
||||
}
|
||||
|
||||
public int getMediaIndicatorIconColor() {
|
||||
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.MEDIA_INDICATOR_ICON_COLOR,
|
||||
getDefaultColor("#FFFFFF", "#000000", "#000000"));
|
||||
getDefaultColor("#F6F2EE", "#393B44", "#161616"));
|
||||
}
|
||||
|
||||
public int getMediaIndicatorBackgroundColor() {
|
||||
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.MEDIA_INDICATOR_BACKGROUND_COLOR,
|
||||
getDefaultColor("#000000", "#FFFFFF", "#FFFFFF"));
|
||||
getDefaultColor("#3D2B5A", "#CDCECF", "#F2F4F8"));
|
||||
}
|
||||
|
||||
public int getTabLayoutWithExpandedCollapsingToolbarTabBackground() {
|
||||
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.TAB_LAYOUT_WITH_EXPANDED_COLLAPSING_TOOLBAR_TAB_BACKGROUND,
|
||||
getDefaultColor("#FFFFFF", "#242424", "#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", "#242424", "#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", "#FF1868", "#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", "#0336FF", "#0336FF"));
|
||||
getDefaultColor("#4863B6", "#719CD6", "#33B1FF"));
|
||||
}
|
||||
|
||||
public int getNoPreviewPostTypeIconTint() {
|
||||
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.NO_PREVIEW_POST_TYPE_ICON_TINT,
|
||||
getDefaultColor("#808080", "#808080", "#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", "#0336FF", "#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", "#FF1868", "#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", "#123E77", "#123E77"));
|
||||
getDefaultColor("#F2E9E1", "#2B3B51", "#484848"));
|
||||
}
|
||||
|
||||
public int getUnreadMessageBackgroundColor() {
|
||||
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.UNREAD_MESSAGE_BACKGROUND_COLOR,
|
||||
getDefaultColor("#B3E5F9", "#123E77", "#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", "#424242", "#424242"));
|
||||
getDefaultColor("#3D2B5A", "#D16983", "#161616"));
|
||||
}
|
||||
|
||||
public int getVoteAndReplyUnavailableButtonColor() {
|
||||
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.VOTE_AND_REPLY_UNAVAILABLE_BUTTON_COLOR,
|
||||
getDefaultColor("#F0F0F0", "#3C3C3C", "#3C3C3C"));
|
||||
getDefaultColor("#F6F2EE", "#192330", "#484848"));
|
||||
}
|
||||
|
||||
public int getCommentVerticalBarColor1() {
|
||||
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.COMMENT_VERTICAL_BAR_COLOR_1,
|
||||
getDefaultColor("#0336FF", "#0336FF", "#0336FF"));
|
||||
getDefaultColor("#2848A9", "#719CD6", "#33B1FF"));
|
||||
}
|
||||
|
||||
public int getCommentVerticalBarColor2() {
|
||||
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.COMMENT_VERTICAL_BAR_COLOR_2,
|
||||
getDefaultColor("#EE02BE", "#C300B3", "#C300B3"));
|
||||
getDefaultColor("#A440B5", "#D16983", "#C8A5FF"));
|
||||
}
|
||||
|
||||
public int getCommentVerticalBarColor3() {
|
||||
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.COMMENT_VERTICAL_BAR_COLOR_3,
|
||||
getDefaultColor("#02DFEE", "#00B8DA", "#00B8DA"));
|
||||
getDefaultColor("#4863B6", "#86ABDC", "#2DC7C4"));
|
||||
}
|
||||
|
||||
public int getCommentVerticalBarColor4() {
|
||||
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.COMMENT_VERTICAL_BAR_COLOR_4,
|
||||
getDefaultColor("#EED502", "#EDCA00", "#EDCA00"));
|
||||
getDefaultColor("#B86E28", "#DBC074", "#78A9FF"));
|
||||
}
|
||||
|
||||
public int getCommentVerticalBarColor5() {
|
||||
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.COMMENT_VERTICAL_BAR_COLOR_5,
|
||||
getDefaultColor("#EE0220", "#EE0219", "#EE0219"));
|
||||
getDefaultColor("#B3434E", "#C94F6D", "#EE5396"));
|
||||
}
|
||||
|
||||
public int getCommentVerticalBarColor6() {
|
||||
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.COMMENT_VERTICAL_BAR_COLOR_6,
|
||||
getDefaultColor("#02EE6E", "#00B925", "#00B925"));
|
||||
getDefaultColor("#577F63", "#81B27A", "#25BE6A"));
|
||||
}
|
||||
|
||||
public int getCommentVerticalBarColor7() {
|
||||
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.COMMENT_VERTICAL_BAR_COLOR_7,
|
||||
getDefaultColor("#EE4602", "#EE4602", "#EE4602"));
|
||||
getDefaultColor("#955F61", "#D16983", "#FF7EB6"));
|
||||
}
|
||||
|
||||
public int getFABIconColor() {
|
||||
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.FAB_ICON_COLOR,
|
||||
getDefaultColor("#FFFFFF", "#FFFFFF", "#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", "#242424", "#000000"));
|
||||
getDefaultColor("#F6F2EE", "#E0C989", "#282828"));
|
||||
}
|
||||
|
||||
public int getNavBarColor() {
|
||||
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.NAV_BAR_COLOR,
|
||||
getDefaultColor("#FFFFFF", "#121212", "#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;
|
||||
}
|
||||
|
||||
@@ -1536,4 +1550,299 @@ 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);
|
||||
int g = Math.round(Color.green(color) * factor);
|
||||
int b = Math.round(Color.blue(color) * factor);
|
||||
|
||||
return Color.argb(a,
|
||||
Math.min(r, 255),
|
||||
Math.min(g, 255),
|
||||
Math.min(b, 255));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package eu.toldi.infinityforlemmy.events;
|
||||
|
||||
import eu.toldi.infinityforlemmy.message.Message;
|
||||
import eu.toldi.infinityforlemmy.privatemessage.PrivateMessage;
|
||||
|
||||
public class RepliedToPrivateMessageEvent {
|
||||
public Message newReply;
|
||||
public PrivateMessage newReply;
|
||||
public int messagePosition;
|
||||
|
||||
public RepliedToPrivateMessageEvent(Message newReply, int messagePosition) {
|
||||
public RepliedToPrivateMessageEvent(PrivateMessage newReply, int messagePosition) {
|
||||
this.newReply = newReply;
|
||||
this.messagePosition = messagePosition;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,202 @@
|
||||
package eu.toldi.infinityforlemmy.fragments;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.RequestManager;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import eu.toldi.infinityforlemmy.FragmentCommunicator;
|
||||
import eu.toldi.infinityforlemmy.Infinity;
|
||||
import eu.toldi.infinityforlemmy.R;
|
||||
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
|
||||
import eu.toldi.infinityforlemmy.activities.BaseActivity;
|
||||
import eu.toldi.infinityforlemmy.activities.SubscribedThingListingActivity;
|
||||
import eu.toldi.infinityforlemmy.adapters.BlockedCommunitiesRecyclerViewAdapter;
|
||||
import eu.toldi.infinityforlemmy.blockedcommunity.BlockedCommunityViewModel;
|
||||
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||
import eu.toldi.infinityforlemmy.customviews.LinearLayoutManagerBugFixed;
|
||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||
import me.zhanghai.android.fastscroll.FastScrollerBuilder;
|
||||
import retrofit2.Retrofit;
|
||||
|
||||
|
||||
/**
|
||||
* A simple {@link Fragment} subclass.
|
||||
*/
|
||||
public class BlockedCommunitiesListingFragment extends Fragment implements FragmentCommunicator {
|
||||
|
||||
public static final String EXTRA_ACCOUNT_NAME = "EAN";
|
||||
public static final String EXTRA_ACCESS_TOKEN = "EAT";
|
||||
public static final String EXTRA_ACCOUNT_PROFILE_IMAGE_URL = "EAPIU";
|
||||
public static final String EXTRA_IS_SUBREDDIT_SELECTION = "EISS";
|
||||
public static final String EXTRA_EXTRA_CLEAR_SELECTION = "EECS";
|
||||
public static final String EXTRA_ACCOUNT_QUALIFIED_NAME = "EAQN";
|
||||
|
||||
@BindView(R.id.swipe_refresh_layout_subscribed_subreddits_listing_fragment)
|
||||
SwipeRefreshLayout mSwipeRefreshLayout;
|
||||
@BindView(R.id.recycler_view_subscribed_subreddits_listing_fragment)
|
||||
RecyclerView mRecyclerView;
|
||||
@BindView(R.id.no_subscriptions_linear_layout_subreddits_listing_fragment)
|
||||
LinearLayout mLinearLayout;
|
||||
@BindView(R.id.no_subscriptions_image_view_subreddits_listing_fragment)
|
||||
ImageView mImageView;
|
||||
@BindView(R.id.error_text_view_subscribed_subreddits_listing_fragment)
|
||||
TextView mErrorTextView;
|
||||
@Inject
|
||||
@Named("oauth")
|
||||
Retrofit mOauthRetrofit;
|
||||
@Inject
|
||||
@Named("default")
|
||||
SharedPreferences mSharedPreferences;
|
||||
@Inject
|
||||
RedditDataRoomDatabase mRedditDataRoomDatabase;
|
||||
@Inject
|
||||
CustomThemeWrapper mCustomThemeWrapper;
|
||||
@Inject
|
||||
Executor mExecutor;
|
||||
public BlockedCommunityViewModel mSubscribedSubredditViewModel;
|
||||
private BaseActivity mActivity;
|
||||
private RequestManager mGlide;
|
||||
private LinearLayoutManagerBugFixed mLinearLayoutManager;
|
||||
|
||||
public BlockedCommunitiesListingFragment() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
View rootView = inflater.inflate(R.layout.fragment_subscribed_subreddits_listing, container, false);
|
||||
|
||||
ButterKnife.bind(this, rootView);
|
||||
|
||||
((Infinity) mActivity.getApplication()).getAppComponent().inject(this);
|
||||
|
||||
applyTheme();
|
||||
|
||||
if ((mActivity instanceof BaseActivity && ((BaseActivity) mActivity).isImmersiveInterface())) {
|
||||
mRecyclerView.setPadding(0, 0, 0, ((BaseActivity) mActivity).getNavBarHeight());
|
||||
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
|
||||
&& mSharedPreferences.getBoolean(SharedPreferencesUtils.IMMERSIVE_INTERFACE_KEY, true)) {
|
||||
Resources resources = getResources();
|
||||
int navBarResourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
|
||||
if (navBarResourceId > 0) {
|
||||
mRecyclerView.setPadding(0, 0, 0, resources.getDimensionPixelSize(navBarResourceId));
|
||||
}
|
||||
}
|
||||
|
||||
String accountName = getArguments().getString(EXTRA_ACCOUNT_NAME, "-");
|
||||
String accountQualifiedName = getArguments().getString(EXTRA_ACCOUNT_QUALIFIED_NAME, "-");
|
||||
String accessToken = getArguments().getString(EXTRA_ACCESS_TOKEN);
|
||||
|
||||
if (accessToken == null) {
|
||||
mSwipeRefreshLayout.setEnabled(false);
|
||||
}
|
||||
|
||||
mGlide = Glide.with(this);
|
||||
|
||||
mLinearLayoutManager = new LinearLayoutManagerBugFixed(mActivity);
|
||||
mRecyclerView.setLayoutManager(mLinearLayoutManager);
|
||||
|
||||
BlockedCommunitiesRecyclerViewAdapter adapter = new BlockedCommunitiesRecyclerViewAdapter(mActivity, mExecutor, mOauthRetrofit, mRedditDataRoomDatabase,
|
||||
mCustomThemeWrapper, accessToken);
|
||||
|
||||
|
||||
mRecyclerView.setAdapter(adapter);
|
||||
new FastScrollerBuilder(mRecyclerView).useMd2Style().build();
|
||||
|
||||
mSubscribedSubredditViewModel = new ViewModelProvider(this,
|
||||
new BlockedCommunityViewModel.Factory(mActivity.getApplication(), mRedditDataRoomDatabase, accountQualifiedName))
|
||||
.get(BlockedCommunityViewModel.class);
|
||||
mSubscribedSubredditViewModel.getAllBlockedCommunities().observe(getViewLifecycleOwner(), subscribedSubredditData -> {
|
||||
mSwipeRefreshLayout.setRefreshing(false);
|
||||
if (subscribedSubredditData == null || subscribedSubredditData.size() == 0) {
|
||||
mRecyclerView.setVisibility(View.GONE);
|
||||
mLinearLayout.setVisibility(View.VISIBLE);
|
||||
mGlide.load(R.drawable.error_image).into(mImageView);
|
||||
} else {
|
||||
mLinearLayout.setVisibility(View.GONE);
|
||||
mRecyclerView.setVisibility(View.VISIBLE);
|
||||
mGlide.clear(mImageView);
|
||||
}
|
||||
|
||||
if (accessToken != null) {
|
||||
adapter.addUser(accountName, getArguments().getString(EXTRA_ACCOUNT_PROFILE_IMAGE_URL));
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
adapter.setFavoriteSubscribedSubreddits(favoriteSubscribedSubredditData);
|
||||
});*/
|
||||
|
||||
return rootView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(@NonNull Context context) {
|
||||
super.onAttach(context);
|
||||
mActivity = (BaseActivity) context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopRefreshProgressbar() {
|
||||
mSwipeRefreshLayout.setRefreshing(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyTheme() {
|
||||
if (mActivity instanceof SubscribedThingListingActivity) {
|
||||
mSwipeRefreshLayout.setOnRefreshListener(() -> ((SubscribedThingListingActivity) mActivity).loadSubscriptions(true));
|
||||
mSwipeRefreshLayout.setProgressBackgroundColorSchemeColor(mCustomThemeWrapper.getCircularProgressBarBackground());
|
||||
mSwipeRefreshLayout.setColorSchemeColors(mCustomThemeWrapper.getColorAccent());
|
||||
} else {
|
||||
mSwipeRefreshLayout.setEnabled(false);
|
||||
}
|
||||
mErrorTextView.setTextColor(mCustomThemeWrapper.getSecondaryTextColor());
|
||||
if (mActivity.typeface != null) {
|
||||
mErrorTextView.setTypeface(mActivity.contentTypeface);
|
||||
}
|
||||
}
|
||||
|
||||
public void goBackToTop() {
|
||||
if (mLinearLayoutManager != null) {
|
||||
mLinearLayoutManager.scrollToPositionWithOffset(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public void changeSearchQuery(String searchQuery) {
|
||||
mSubscribedSubredditViewModel.setSearchQuery(searchQuery);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
package eu.toldi.infinityforlemmy.fragments;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.RequestManager;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import eu.toldi.infinityforlemmy.FragmentCommunicator;
|
||||
import eu.toldi.infinityforlemmy.Infinity;
|
||||
import eu.toldi.infinityforlemmy.R;
|
||||
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
|
||||
import eu.toldi.infinityforlemmy.activities.BaseActivity;
|
||||
import eu.toldi.infinityforlemmy.activities.BlockedThingListingActivity;
|
||||
import eu.toldi.infinityforlemmy.adapters.BlockedUsersRecyclerViewAdapter;
|
||||
import eu.toldi.infinityforlemmy.blockeduser.BlockedUserViewModel;
|
||||
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||
import eu.toldi.infinityforlemmy.customviews.LinearLayoutManagerBugFixed;
|
||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||
import me.zhanghai.android.fastscroll.FastScrollerBuilder;
|
||||
import retrofit2.Retrofit;
|
||||
|
||||
public class BlockedUsersListingFragment extends Fragment implements FragmentCommunicator {
|
||||
public static final String EXTRA_ACCOUNT_NAME = "EAN";
|
||||
public static final String EXTRA_ACCESS_TOKEN = "EAT";
|
||||
|
||||
@BindView(R.id.swipe_refresh_layout_followed_users_listing_fragment)
|
||||
SwipeRefreshLayout mSwipeRefreshLayout;
|
||||
@BindView(R.id.recycler_view_followed_users_listing_fragment)
|
||||
RecyclerView mRecyclerView;
|
||||
@BindView(R.id.no_subscriptions_linear_layout_followed_users_listing_fragment)
|
||||
LinearLayout mLinearLayout;
|
||||
@BindView(R.id.no_subscriptions_image_view_followed_users_listing_fragment)
|
||||
ImageView mImageView;
|
||||
@BindView(R.id.error_text_view_followed_users_listing_fragment)
|
||||
TextView mErrorTextView;
|
||||
@Inject
|
||||
@Named("oauth")
|
||||
Retrofit mOauthRetrofit;
|
||||
@Inject
|
||||
@Named("default")
|
||||
SharedPreferences mSharedPreferences;
|
||||
@Inject
|
||||
RedditDataRoomDatabase mRedditDataRoomDatabase;
|
||||
@Inject
|
||||
CustomThemeWrapper mCustomThemeWrapper;
|
||||
@Inject
|
||||
Executor mExecutor;
|
||||
BlockedUserViewModel blockedUserViewModel;
|
||||
private BaseActivity mActivity;
|
||||
private RequestManager mGlide;
|
||||
private LinearLayoutManagerBugFixed mLinearLayoutManager;
|
||||
|
||||
public BlockedUsersListingFragment() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
View rootView = inflater.inflate(R.layout.fragment_followed_users_listing, container, false);
|
||||
|
||||
ButterKnife.bind(this, rootView);
|
||||
|
||||
((Infinity) mActivity.getApplication()).getAppComponent().inject(this);
|
||||
|
||||
applyTheme();
|
||||
|
||||
Resources resources = getResources();
|
||||
|
||||
if ((mActivity instanceof BaseActivity && ((BaseActivity) mActivity).isImmersiveInterface())) {
|
||||
mRecyclerView.setPadding(0, 0, 0, ((BaseActivity) mActivity).getNavBarHeight());
|
||||
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
|
||||
&& mSharedPreferences.getBoolean(SharedPreferencesUtils.IMMERSIVE_INTERFACE_KEY, true)) {
|
||||
int navBarResourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
|
||||
if (navBarResourceId > 0) {
|
||||
mRecyclerView.setPadding(0, 0, 0, resources.getDimensionPixelSize(navBarResourceId));
|
||||
}
|
||||
}
|
||||
|
||||
mGlide = Glide.with(this);
|
||||
|
||||
String accessToken = getArguments().getString(EXTRA_ACCESS_TOKEN);
|
||||
if (accessToken == null) {
|
||||
mSwipeRefreshLayout.setEnabled(false);
|
||||
}
|
||||
mLinearLayoutManager = new LinearLayoutManagerBugFixed(mActivity);
|
||||
mRecyclerView.setLayoutManager(mLinearLayoutManager);
|
||||
BlockedUsersRecyclerViewAdapter adapter = new BlockedUsersRecyclerViewAdapter(mActivity,
|
||||
mExecutor, mOauthRetrofit, mRedditDataRoomDatabase, mCustomThemeWrapper, accessToken);
|
||||
mRecyclerView.setAdapter(adapter);
|
||||
new FastScrollerBuilder(mRecyclerView).useMd2Style().build();
|
||||
|
||||
blockedUserViewModel = new ViewModelProvider(this,
|
||||
new BlockedUserViewModel.Factory(mActivity.getApplication(), mRedditDataRoomDatabase, getArguments().getString(EXTRA_ACCOUNT_NAME)))
|
||||
.get(BlockedUserViewModel.class);
|
||||
|
||||
blockedUserViewModel.getAllSubscribedUsers().observe(getViewLifecycleOwner(), subscribedUserData -> {
|
||||
mSwipeRefreshLayout.setRefreshing(false);
|
||||
if (subscribedUserData == null || subscribedUserData.size() == 0) {
|
||||
mRecyclerView.setVisibility(View.GONE);
|
||||
mLinearLayout.setVisibility(View.VISIBLE);
|
||||
mGlide.load(R.drawable.error_image).into(mImageView);
|
||||
} else {
|
||||
mLinearLayout.setVisibility(View.GONE);
|
||||
mRecyclerView.setVisibility(View.VISIBLE);
|
||||
mGlide.clear(mImageView);
|
||||
}
|
||||
adapter.setSubscribedUsers(subscribedUserData);
|
||||
});
|
||||
|
||||
return rootView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(@NonNull Context context) {
|
||||
super.onAttach(context);
|
||||
mActivity = (BaseActivity) context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopRefreshProgressbar() {
|
||||
mSwipeRefreshLayout.setRefreshing(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyTheme() {
|
||||
if (mActivity instanceof BlockedThingListingActivity) {
|
||||
mSwipeRefreshLayout.setOnRefreshListener(() -> ((BlockedThingListingActivity) mActivity).loadBlocks(true));
|
||||
mSwipeRefreshLayout.setProgressBackgroundColorSchemeColor(mCustomThemeWrapper.getCircularProgressBarBackground());
|
||||
mSwipeRefreshLayout.setColorSchemeColors(mCustomThemeWrapper.getColorAccent());
|
||||
} else {
|
||||
mSwipeRefreshLayout.setEnabled(false);
|
||||
}
|
||||
mErrorTextView.setTextColor(mCustomThemeWrapper.getSecondaryTextColor());
|
||||
if (mActivity.typeface != null) {
|
||||
mErrorTextView.setTypeface(mActivity.typeface);
|
||||
}
|
||||
}
|
||||
|
||||
public void goBackToTop() {
|
||||
if (mLinearLayoutManager != null) {
|
||||
mLinearLayoutManager.scrollToPositionWithOffset(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public void changeSearchQuery(String searchQuery) {
|
||||
blockedUserViewModel.setSearchQuery(searchQuery);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
@@ -1033,7 +1028,8 @@ public class HistoryPostFragment extends Fragment implements FragmentCommunicato
|
||||
if (post != null && post.getFullName().equals(event.post.getFullName())) {
|
||||
post.setTitle(event.post.getTitle());
|
||||
post.setVoteType(event.post.getVoteType());
|
||||
post.setScore(event.post.getScore());
|
||||
post.setDownvotes(event.post.getDownvotes());
|
||||
post.setUpvotes(event.post.getUpvotes());
|
||||
post.setNComments(event.post.getNComments());
|
||||
post.setNSFW(event.post.isNSFW());
|
||||
post.setHidden(event.post.isHidden());
|
||||
@@ -1446,4 +1442,4 @@ public class HistoryPostFragment extends Fragment implements FragmentCommunicato
|
||||
public interface LoadIconListener {
|
||||
void loadIconSuccess(String subredditOrUserName, String iconUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,9 +135,9 @@ 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.LemmyUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.Utils;
|
||||
import eu.toldi.infinityforlemmy.videoautoplay.ExoCreator;
|
||||
@@ -223,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;
|
||||
@@ -466,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,
|
||||
@@ -530,20 +532,18 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
||||
|
||||
sort = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_SUBREDDIT_POST_BASE + subredditName,
|
||||
mSharedPreferences.getString(SharedPreferencesUtils.SUBREDDIT_DEFAULT_SORT_TYPE, SortType.Type.HOT.name()));
|
||||
if (sort.equals(sort.equals(SortType.Type.TOP.name()))) {
|
||||
if (sort.equalsIgnoreCase(SortType.Type.TOP.value)) {
|
||||
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.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, displaySubredditName,
|
||||
mSharedPreferences, mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
|
||||
@@ -605,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,
|
||||
@@ -670,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()));
|
||||
if (sort.equals(SortType.Type.TOP.name())) {
|
||||
String sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_USER_POST_BASE + username,
|
||||
String sortTime = null;
|
||||
if (sort.equalsIgnoreCase(SortType.Type.TOP.value)) {
|
||||
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.valueOf(sort), SortType.Time.valueOf(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,
|
||||
@@ -733,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,
|
||||
@@ -793,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,
|
||||
@@ -851,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,
|
||||
@@ -1207,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();
|
||||
@@ -1242,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);
|
||||
}
|
||||
|
||||
@@ -1365,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 {
|
||||
@@ -1393,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();
|
||||
}
|
||||
@@ -1751,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);
|
||||
@@ -1781,7 +1784,8 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
||||
if (post != null && post.getFullName().equals(event.post.getFullName())) {
|
||||
post.setTitle(event.post.getTitle());
|
||||
post.setVoteType(event.post.getVoteType());
|
||||
post.setScore(event.post.getScore());
|
||||
post.setDownvotes(event.post.getDownvotes());
|
||||
post.setUpvotes(event.post.getUpvotes());
|
||||
post.setNComments(event.post.getNComments());
|
||||
post.setNSFW(event.post.isNSFW());
|
||||
post.setHidden(event.post.isHidden());
|
||||
@@ -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;
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user