Compare commits
334 Commits
v1.1.5+for
...
feature/sh
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9a0851cb06 | ||
|
|
ea43070e6d | ||
|
|
14cd23c28b | ||
|
|
793668021e | ||
|
|
f0ea6ef43e | ||
|
|
2b2e4845a1 | ||
|
|
2dccec99cc | ||
|
|
b060894a6c | ||
|
|
92872edb58 | ||
|
|
c5fcf49eda | ||
|
|
d66a4c0920 | ||
|
|
e8a31cf867 | ||
|
|
c1f9a88ef4 | ||
|
|
e6200e186b | ||
|
|
5564502125 | ||
|
|
7947e7689c | ||
|
|
b53ada7ea2 | ||
|
|
584f28534a | ||
|
|
770fde7aac | ||
|
|
3d7f918132 | ||
|
|
29b8cedc7c | ||
|
|
33b65c3bf3 | ||
|
|
34ab1bcd9c | ||
|
|
cfdc88174b | ||
|
|
15123d8924 | ||
|
|
20086d76ce | ||
|
|
1ca4fb5c37 | ||
|
|
009016a835 | ||
|
|
33dfb2a30d | ||
|
|
1604c067fd | ||
|
|
0c7419e2b3 | ||
|
|
7cf30ccb98 | ||
|
|
aa2c8c5624 | ||
|
|
875695c239 | ||
|
|
61049a1302 | ||
|
|
28db90aa82 | ||
|
|
f0e7fc5e3b | ||
|
|
2169afa8e7 | ||
|
|
508ec06d93 | ||
|
|
9fb39d9403 | ||
|
|
4879d74f80 | ||
|
|
ba3f6c4f95 | ||
|
|
481241c4f6 | ||
|
|
5798587dc6 | ||
|
|
066e3e08a2 | ||
|
|
16d6c14633 | ||
|
|
80a4a3551c | ||
|
|
74f3bb8708 | ||
|
|
c3e398b3c2 | ||
|
|
dcfa812c83 | ||
|
|
065e65d708 | ||
|
|
bca0dab381 | ||
|
|
4a45c1055e | ||
|
|
7c789746ce | ||
|
|
f46ce5576c | ||
|
|
730e6fc1fa | ||
|
|
cb36cc042c | ||
|
|
5d586418f9 | ||
|
|
44f1d026d6 | ||
|
|
defaa1095c | ||
|
|
c67f2f8027 | ||
|
|
452128565f | ||
|
|
6322d3c984 | ||
|
|
d68c820e58 | ||
|
|
79f37b4813 | ||
|
|
87460a2fb6 | ||
|
|
6774a642d9 | ||
|
|
f0bd9233b7 | ||
|
|
66efe750a8 | ||
|
|
3658fc423b | ||
|
|
3c3ad7447e | ||
|
|
b570064b99 | ||
|
|
d9f6ef69fe | ||
|
|
bdac1d5bb4 | ||
|
|
1eee1ead5e | ||
|
|
0ec51f5b34 | ||
|
|
6c6fb05a7a | ||
|
|
09a0faacba | ||
|
|
d0d1d15de5 | ||
|
|
e4e9516d5d | ||
|
|
05eceecbea | ||
|
|
71ba1bb0d5 | ||
|
|
2160a26648 | ||
|
|
5433eac9c9 | ||
|
|
0a68f86200 | ||
|
|
c91dae0346 | ||
|
|
e1df7e5077 | ||
|
|
0560b54559 | ||
|
|
c78db7e835 | ||
|
|
c837a2d4b6 | ||
|
|
70b91b7a9a | ||
|
|
27079a7ec5 | ||
|
|
9563df0574 | ||
|
|
638209cc13 | ||
|
|
224c731afa | ||
|
|
0bbf937531 | ||
|
|
3556c92c3e | ||
|
|
87c5b23196 | ||
|
|
c83910c885 | ||
|
|
586622e90d | ||
|
|
e5e2430e03 | ||
|
|
04bfdba50e | ||
|
|
7abf15e9e0 | ||
|
|
6b680831b8 | ||
|
|
6cbf100828 | ||
|
|
3e7bbebe7f | ||
|
|
56d344045a | ||
|
|
7ab634cc08 | ||
|
|
9f0db3ebb5 | ||
|
|
6415eb8590 | ||
|
|
87c77b84a4 | ||
|
|
0b7bb16f22 | ||
|
|
5164b5ba78 | ||
|
|
f3c28bc66a | ||
|
|
239f7eb9e7 | ||
|
|
d6daf7a553 | ||
|
|
dfb3b230e6 | ||
|
|
484a5c878f | ||
|
|
3f27cfb13b | ||
|
|
38e2ba6ccd | ||
|
|
3dad38e614 | ||
|
|
0865c9d1bd | ||
|
|
20a8783d84 | ||
|
|
0b96fb05fc | ||
|
|
8767d62de7 | ||
|
|
74fb04e2d4 | ||
|
|
2537460e16 | ||
|
|
be3dfde3be | ||
|
|
42025035ad | ||
|
|
6a667fdf32 | ||
|
|
bfafac3d4f | ||
|
|
0cafbe9f91 | ||
|
|
2fbf172729 | ||
|
|
bb9755f4af | ||
|
|
2a01377a8a | ||
|
|
61cc6d5d07 | ||
|
|
1d74a37f60 | ||
|
|
ef9645f9e7 | ||
|
|
6a103ca3f3 | ||
|
|
c22772121b | ||
|
|
de7bc69d2a | ||
|
|
2eccd572c9 | ||
|
|
824a62024b | ||
|
|
3a3cfda919 | ||
|
|
e29120cc51 | ||
|
|
197d5c6bc3 | ||
|
|
d143cc75db | ||
|
|
1635a06c54 | ||
|
|
76de0d8c70 | ||
|
|
402a995b8f | ||
|
|
f580ba7779 | ||
|
|
bc3869b920 | ||
|
|
020f4a5a1a | ||
|
|
b054caa967 | ||
|
|
82b7633650 | ||
|
|
33497864f2 | ||
|
|
4c9d1544fa | ||
|
|
bce2367cfc | ||
|
|
390ecc48fb | ||
|
|
9ed99edd6e | ||
|
|
4362490539 | ||
|
|
f5d225fc3e | ||
|
|
063e9287fd | ||
|
|
ba376908cd | ||
|
|
caddf0021c | ||
|
|
90645f4d90 | ||
|
|
1316fcae22 | ||
|
|
27dee7297b | ||
|
|
13ecba40ae | ||
|
|
e15dd0d8b3 | ||
|
|
1ab26bc665 | ||
|
|
e6758d8c01 | ||
|
|
4621787e34 | ||
|
|
10ad35a285 | ||
|
|
d10145a6ba | ||
|
|
c9792ced32 | ||
|
|
a3fb09a33c | ||
|
|
6d875fd890 | ||
|
|
5d87fb7b67 | ||
|
|
4cbb59850b | ||
|
|
a2022b25e5 | ||
|
|
0d168f93ed | ||
|
|
94ac5b9bb7 | ||
|
|
024d358213 | ||
|
|
5562c93855 | ||
|
|
98e897d6a8 | ||
|
|
4aac6aa4f4 | ||
|
|
2bb4616e40 | ||
|
|
56e8476d2e | ||
|
|
97d81eb1b2 | ||
|
|
ffa21b26af | ||
|
|
9917712f66 | ||
|
|
11cdce6c90 | ||
|
|
8e82cf1e99 | ||
|
|
9767b11626 | ||
|
|
0f95694083 | ||
|
|
7dfc7dd9ef | ||
|
|
0407e958f1 | ||
|
|
e6a5fa1c3f | ||
|
|
6f48a7c4a4 | ||
|
|
80c56d71cb | ||
|
|
f77d9dcee2 | ||
|
|
f7195c7787 | ||
|
|
ca92cc6dc1 | ||
|
|
cd31b2ae5a | ||
|
|
00bec7174a | ||
|
|
236acab54f | ||
|
|
ba362f4457 | ||
|
|
8ed93baf8d | ||
|
|
bf953e96fa | ||
|
|
6b89a747e2 | ||
|
|
2fa1d54268 | ||
|
|
02ef34b451 | ||
|
|
1701fc71c4 | ||
|
|
fe200996db | ||
|
|
659333342f | ||
|
|
1ca5b6def2 | ||
|
|
4e8e3ee440 | ||
|
|
86dd724222 | ||
|
|
8242995027 | ||
|
|
49962a4734 | ||
|
|
509b16aee1 | ||
|
|
f3f5e4a887 | ||
|
|
7aabc1fa76 | ||
|
|
dcb5e36041 | ||
|
|
e0c072ab9c | ||
|
|
0231903868 | ||
|
|
f63bbeee79 | ||
|
|
db9e427444 | ||
|
|
4474a584df | ||
|
|
ab00ad68f1 | ||
|
|
d1e77efa1c | ||
|
|
de00353864 | ||
|
|
feec459d47 | ||
|
|
ad68d7e4f2 | ||
|
|
cf27c6bbf3 | ||
|
|
0115656d67 | ||
|
|
002687d2b1 | ||
|
|
a3267f6cd3 | ||
|
|
0ca9c536cd | ||
|
|
382a23c0b6 | ||
|
|
1f51331f67 | ||
|
|
cce6ba0746 | ||
|
|
be3c12dfb3 | ||
|
|
bfd87cf94e | ||
|
|
857bb1e483 | ||
|
|
75a131b675 | ||
|
|
d98b1c5ee1 | ||
|
|
1eeab25b7d | ||
|
|
82cc0c3c09 | ||
|
|
e102faff6c | ||
|
|
34369bd7e9 | ||
|
|
c71b620402 | ||
|
|
21b4bf23a1 | ||
|
|
d034311f2d | ||
|
|
2deed69766 | ||
|
|
bfbd21b826 | ||
|
|
ba8683301d | ||
|
|
0ed178167b | ||
|
|
b34e34de51 | ||
|
|
ba38e21e07 | ||
|
|
90bef7fddb | ||
|
|
c1b382ef34 | ||
|
|
028b88aa24 | ||
|
|
9d0ce33f5e | ||
|
|
dbb23d952c | ||
|
|
7fe7e47d53 | ||
|
|
d0c93dfd4d | ||
|
|
acdccaf80a | ||
|
|
769293ce1a | ||
|
|
8d0fe18b70 | ||
|
|
6926432a6c | ||
|
|
83f12b0840 | ||
|
|
290b7db7e4 | ||
|
|
f352c20ed9 | ||
|
|
2ccbffa165 | ||
|
|
06cd80a352 | ||
|
|
de97493e6a | ||
|
|
3a24ff0d15 | ||
|
|
c463a3fc39 | ||
|
|
fc845685cc | ||
|
|
0ef0aa1a44 | ||
|
|
337689aa45 | ||
|
|
f7e3423f9c | ||
|
|
b465c09cc8 | ||
|
|
ac6c0651d6 | ||
|
|
18af6f5a12 | ||
|
|
d11ee3a702 | ||
|
|
6d9f9ce2d2 | ||
|
|
ec1496a4cc | ||
|
|
41e19185e8 | ||
|
|
e15dd6024f | ||
|
|
e52dffeece | ||
|
|
5b85bb427d | ||
|
|
4d62388617 | ||
|
|
04b8055474 | ||
|
|
3c34b6a7d2 | ||
|
|
de4964c2cd | ||
|
|
fbcaa05c03 | ||
|
|
883f28696e | ||
|
|
df52230837 | ||
|
|
a90f26a37a | ||
|
|
8c1f76d7fa | ||
|
|
f384d44f8f | ||
|
|
4ab6ed55f5 | ||
|
|
cf99bf5152 | ||
|
|
10779717cf | ||
|
|
4e5c2a9ecf | ||
|
|
db4c1bfe47 | ||
|
|
27afba1cf2 | ||
|
|
4895425b40 | ||
|
|
004c414fba | ||
|
|
c8e38b134c | ||
|
|
de5a911286 | ||
|
|
606cd7442e | ||
|
|
3ebc972268 | ||
|
|
4e39bb381c | ||
|
|
b6178681b0 | ||
|
|
29abf70cec | ||
|
|
8d63be513d | ||
|
|
e63b9d0dd6 | ||
|
|
b1fda17ac7 | ||
|
|
bad44b145c | ||
|
|
77669cedf6 | ||
|
|
19238c389f | ||
|
|
1747ff98b5 | ||
|
|
8fa5824e3e | ||
|
|
6a674d7a7e | ||
|
|
dad3b8cd6b | ||
|
|
9179d2198d | ||
|
|
d096bef234 | ||
|
|
f2c47a1b84 | ||
|
|
bc2ac4e915 | ||
|
|
ff215412c8 |
142
README.md
142
README.md
@@ -1,25 +1,37 @@
|
|||||||

|

|
||||||
|
|
||||||
# Megalodon
|
# Moshidon, the material you mastodon client!
|
||||||
|
|
||||||
[](https://translate.codeberg.org/engage/megalodon/)
|
> A fork of [megalodon](https://github.com/sk22/megalodon) which is a fork of [official Mastodon Android app](https://github.com/mastodon/mastodon-android) adding important features that are missing in the official app and possibly won’t ever be implemented, such as the federated timeline, unlisted posting, bookmarks and an image description viewer.
|
||||||
|
|
||||||
[](https://github.com/sk22/megalodon/releases/latest/download/megalodon.apk)
|
|
||||||
|
|
||||||
<a href="https://play.google.com/store/apps/details?id=org.joinmastodon.android.sk"><img height="50" alt="Get it on Google Play" src="img/google-play-badge.png"></a>
|
|
||||||
|
|
||||||
<a href="#installation"><img height="50" alt="Get it on IzzyOnDroid" src="img/izzy-badge.png"></a>
|
|
||||||
|
|
||||||
> A fork of the [official Mastodon Android app](https://github.com/mastodon/mastodon-android) adding important features that are missing in the official app and possibly won’t ever be implemented, such as the federated timeline, unlisted posting and an image description viewer.
|
[](https://github.com/LucasGGamerM/moshidon/releases/latest/download/moshidon.apk)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
## Key features
|
## Key features
|
||||||
|
|
||||||
|
### **Material you theme support on Android 12+ devices!**
|
||||||
|
|
||||||
|
### **Translate button**
|
||||||
|
|
||||||
|
**Allows you to translate posts in instances with the translate feature!**
|
||||||
|
|
||||||
|
**Screenshots**
|
||||||
|
|
||||||
|

|
||||||
|

|
||||||
|
|
||||||
|
### **Color themes**
|
||||||
|
|
||||||
|
**Allows you to change theme within the app. Supports Purple, pink, green, blue, orange and yellow!**
|
||||||
|
|
||||||
### **Unlisted posting**
|
### **Unlisted posting**
|
||||||
|
|
||||||
**Allows you to post publicly without having your post show up in trends, hashtags or public timelines (i.e., in the tabs “Community”, “Federated” and “Posts”).**
|
**Allows you to post publicly without having your post show up in trends, hashtags or public timelines (i.e., in the tabs “Local”, “Community” and “Posts”).**
|
||||||
|
|
||||||
When posting with Unlisted visibility, your posts will still be publicly accessible in your profile. They will also be shown in people’s Home timelines, but only if they follow you or someone they follow reblogged/replied to your post.
|
When posting with Unlisted visibility, your posts will still be publicly accessible in your profile. They will also be shown in people’s Home timelines, but only if they follow you or someone they follow reposted/replied to your post.
|
||||||
|
|
||||||
The Mastodon documentation has some more information about [Unlisted posting](https://docs.joinmastodon.org/user/posting/#unlisted) and [Public timelines](https://docs.joinmastodon.org/user/network/#timelines).
|
The Mastodon documentation has some more information about [Unlisted posting](https://docs.joinmastodon.org/user/posting/#unlisted) and [Public timelines](https://docs.joinmastodon.org/user/network/#timelines).
|
||||||
|
|
||||||
@@ -31,12 +43,6 @@ Despite being one of the main features of federated social media, the Federated
|
|||||||
|
|
||||||
That’s one of the reasons why choosing a small, **well-moderated instance is important**. Instance admins and moderators should always make sure to ban abusive users and stop federating with instances who platform them. On well-moderated instances, the Federated timeline can be a welcoming place to meet new people!
|
That’s one of the reasons why choosing a small, **well-moderated instance is important**. Instance admins and moderators should always make sure to ban abusive users and stop federating with instances who platform them. On well-moderated instances, the Federated timeline can be a welcoming place to meet new people!
|
||||||
|
|
||||||
### **Draft and schedule posts**
|
|
||||||
|
|
||||||
**Allows for preparing a post and scheduling it to send it automatically at a specific time.**
|
|
||||||
|
|
||||||
You can create drafts, edit them, send them manually later or set a scheduled date. Drafts are technically saved as scheduled posts, so you can view and edit them from other apps that support scheduled posts. Scheduled posts are handled by your home instance, so they'll work even if you uninstall Megalodon.
|
|
||||||
|
|
||||||
### **Image description viewer**
|
### **Image description viewer**
|
||||||
|
|
||||||
**Allows you to quickly check whether an image or video has an alternative text attached to it.**
|
**Allows you to quickly check whether an image or video has an alternative text attached to it.**
|
||||||
@@ -49,71 +55,29 @@ This is important to **ensure the content you’re sharing is as accessible as p
|
|||||||
|
|
||||||
On the Fediverse, it’s quite common for people to pin posts they want others to read before following them. You can pin/unpin posts yourself by clicking the `⋯` button in the top right corner of your posts.
|
On the Fediverse, it’s quite common for people to pin posts they want others to read before following them. You can pin/unpin posts yourself by clicking the `⋯` button in the top right corner of your posts.
|
||||||
|
|
||||||
|
### **Bookmarks**
|
||||||
|
|
||||||
|
**They allow for quickly saving posts and viewing them through the Bookmarks button on the top right of your profile.**
|
||||||
|
|
||||||
|
To bookmark a post, press the button between the Favorite and Share buttons on the bottom of the post. Bookmarks are saved privately, so the post authors won’t know you saved their post – the list of bookmarked posts is only visible to you.
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
### IzzyOnDroid
|
**Press the download button above to download the APK. Open the downloaded file on your Android device to install it. Moshidon will automatically notify you about new updates inside the app.**
|
||||||
|
|
||||||
[apt.izzysoft.de/fdroid/index/apk/org.joinmastodon.android.sk](https://apt.izzysoft.de/fdroid/index/apk/org.joinmastodon.android.sk)
|
To install this app on your Android device, download the [latest release from GitHub](https://github.com/LucasGGamerM/moshidon/releases/latest/download/moshidon.apk) and open it. You might have to accept installing APK files from your browser when trying to install it. You can also take a look at all releases on the [Releases](https://github.com/LucasGGamerM/moshidon/releases) page.
|
||||||
|
|
||||||
<a href="#installation"><img height="50" alt="Get it on IzzyOnDroid" src="img/izzy-badge.png"></a>
|
Moshidon makes use of [Mastodon for Android](https://github.com/mastodon/mastodon-android)’s automatic update checker. Megalodon will check for new updates available on GitHub and offer to download and install them. You can also manually press “Check for updates” at the bottom of the settings page!
|
||||||
|
|
||||||
Note that you'll need to add Izzy's F-Droid repository to your F-Droid app first:
|
|
||||||
|
|
||||||
[`https://apt.izzysoft.de/fdroid/repo`](https://apt.izzysoft.de/fdroid/repo)
|
|
||||||
|
|
||||||
### Google Play Store
|
|
||||||
|
|
||||||
[play.google.com/store/apps/details?id=org.joinmastodon.android.sk](https://play.google.com/store/apps/details?id=org.joinmastodon.android.sk)
|
|
||||||
|
|
||||||
<a href="https://play.google.com/store/apps/details?id=org.joinmastodon.android.sk"><img height="50" alt="Get it on Google Play" src="img/google-play-badge.png"></a>
|
|
||||||
|
|
||||||
### F-Droid
|
|
||||||
|
|
||||||
**[F-Droid.org?](https://f-droid.org)** Not yet, sorry!
|
|
||||||
|
|
||||||
If you want, you can help me figure out if something's missing in the [Issue #47: F-Droid.org](https://github.com/sk22/megalodon/issues/47)
|
|
||||||
|
|
||||||
### Direct
|
|
||||||
|
|
||||||
Press the download button to download the APK. Open the downloaded file on your Android device to install it. Megalodon will automatically notify you about new updates inside the app.
|
|
||||||
|
|
||||||
[](https://github.com/sk22/megalodon/releases/latest/download/megalodon.apk)
|
|
||||||
|
|
||||||
You might have to accept installing APK files from your browser when trying to install it. You can also take a look at all releases on the [Releases](https://github.com/sk22/megalodon/releases) page.
|
|
||||||
|
|
||||||
Megalodon makes use of [Mastodon for Android](https://github.com/mastodon/mastodon-android)’s automatic update checker. Megalodon will check for new updates available on GitHub and offer to download and install them. You can also manually press “Check for updates” at the bottom of the settings page!
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
|
|
||||||
## Release variants
|
## Release variants
|
||||||
|
|
||||||
All downloads can be found on the [Releases](https://github.com/sk22/megalodon/releases) page.
|
All downloads can be found on the [Releases](https://github.com/LucasGGamerM/moshidon/releases) page.
|
||||||
|
|
||||||
**`megalodon.apk`**
|
**`moshidon.apk`**
|
||||||
|
|
||||||
Variant with an integrated updater. If you download Megalodon from here (and not from an app store), just download the regular `megalodon.apk`.
|
|
||||||
|
|
||||||
**`upstream-1234abc.apk`**
|
|
||||||
|
|
||||||
This is an **unmodified version** of the official [Mastodon for Android](https://github.com/mastodon/mastodon-android) app the respective Megalodon release is based on. Should you find any bugs in Megalodon (which you will), try to see if it occurs with this variant, too. The last 7 digits of the file name are important to know which version of the official app you're using.
|
|
||||||
|
|
||||||
<!-- **`megalodon-fdroid.apk`**
|
|
||||||
|
|
||||||
Variant without the integrated updater. This is the variant to be published to F-Droid.org where an integrated updater is not necessary. -->
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Contribution
|
|
||||||
|
|
||||||
### Translation
|
|
||||||
|
|
||||||
As with the source code, the translation is sourced from the official project, which you can contribute to on the official “**Mastodon for Android**” Crowdin project: https://crowdin.com/project/mastodon-for-android
|
|
||||||
|
|
||||||
There's also a handful of custom strings exclusive to this projects that would need to be translated. You can help translate **Megalodon** on Weblate: https://translate.codeberg.org/projects/megalodon/
|
|
||||||
|
|
||||||
[](https://translate.codeberg.org/engage/megalodon/)
|
|
||||||
|
|
||||||
|
Variant with an integrated updater. If you download Moshidon from here (and not from an app store), just download the regular `moshidon.apk`.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -131,7 +95,7 @@ There's also a handful of custom strings exclusive to this projects that would n
|
|||||||
* [Implement a bookmark button and list](https://github.com/mastodon/mastodon-android/compare/master...sk22:megalodon:feature/bookmarks) ([Closes issue](https://github.com/mastodon/mastodon-android/issues/22))
|
* [Implement a bookmark button and list](https://github.com/mastodon/mastodon-android/compare/master...sk22:megalodon:feature/bookmarks) ([Closes issue](https://github.com/mastodon/mastodon-android/issues/22))
|
||||||
* [Add “Check for update” button in addition to integrated update checker](https://github.com/mastodon/mastodon-android/compare/master...sk22:megalodon:feature/check-for-update-button)
|
* [Add “Check for update” button in addition to integrated update checker](https://github.com/mastodon/mastodon-android/compare/master...sk22:megalodon:feature/check-for-update-button)
|
||||||
* [Add “Mark media as sensitive” option](https://github.com/mastodon/mastodon-android/compare/master...sk22:megalodon:feature/mark-media-as-sensitive)
|
* [Add “Mark media as sensitive” option](https://github.com/mastodon/mastodon-android/compare/master...sk22:megalodon:feature/mark-media-as-sensitive)
|
||||||
* [Add settings to hide replies and reblogs from the timeline](https://github.com/mastodon/mastodon-android/compare/master...sk22:megalodon:feature/filter-home-timeline) ([Pull request](https://github.com/mastodon/mastodon-android/pull/317))
|
* [Add settings to hide replies and reposts from the timeline](https://github.com/mastodon/mastodon-android/compare/master...sk22:megalodon:feature/filter-home-timeline) ([Pull request](https://github.com/mastodon/mastodon-android/pull/317))
|
||||||
* [Follow and unfollow hashtags](https://github.com/sk22/megalodon/commit/7d38f031f197aa6cefaf53e39d929538689c1e4e) ([Closes issue](https://github.com/mastodon/mastodon-android/issues/233))
|
* [Follow and unfollow hashtags](https://github.com/sk22/megalodon/commit/7d38f031f197aa6cefaf53e39d929538689c1e4e) ([Closes issue](https://github.com/mastodon/mastodon-android/issues/233))
|
||||||
* [Notification bell for posts](https://github.com/sk22/megalodon/commit/b166ca705eb9169025ef32bbe6315b42491b57ea) ([Closes issue](https://github.com/mastodon/mastodon-android/issues/81))
|
* [Notification bell for posts](https://github.com/sk22/megalodon/commit/b166ca705eb9169025ef32bbe6315b42491b57ea) ([Closes issue](https://github.com/mastodon/mastodon-android/issues/81))
|
||||||
* [Viewing lists and adding/removing users from lists](https://github.com/mastodon/mastodon-android/compare/master...sk22:megalodon:list-timeline-views) based on [@obstsalatschuessel](https://github.com/obstsalatschuessel)'s [Pull request](https://github.com/mastodon/mastodon-android/pull/286)
|
* [Viewing lists and adding/removing users from lists](https://github.com/mastodon/mastodon-android/compare/master...sk22:megalodon:list-timeline-views) based on [@obstsalatschuessel](https://github.com/obstsalatschuessel)'s [Pull request](https://github.com/mastodon/mastodon-android/pull/286)
|
||||||
@@ -141,17 +105,7 @@ There's also a handful of custom strings exclusive to this projects that would n
|
|||||||
* [Add notifications tab for posts](https://github.com/mastodon/mastodon-android/compare/master...sk22:megalodon:feature/posts-notifications-tab)
|
* [Add notifications tab for posts](https://github.com/mastodon/mastodon-android/compare/master...sk22:megalodon:feature/posts-notifications-tab)
|
||||||
* [Show visibility of original post when replying](https://github.com/mastodon/mastodon-android/compare/master...sk22:megalodon:feature/display-reply-visibility)
|
* [Show visibility of original post when replying](https://github.com/mastodon/mastodon-android/compare/master...sk22:megalodon:feature/display-reply-visibility)
|
||||||
* [Clickable reply/boost line above posts](https://github.com/mastodon/mastodon-android/compare/master...sk22:megalodon:clickable-boost-reply-line)
|
* [Clickable reply/boost line above posts](https://github.com/mastodon/mastodon-android/compare/master...sk22:megalodon:clickable-boost-reply-line)
|
||||||
* [Add push notification setting for post notifications](https://github.com/sk22/megalodon/commit/b190480d7739be47f23543d9e7644660f9b4b4ee)
|
* [Clickable reply line while replying to open original post](https://github.com/mastodon/mastodon-android/compare/master...sk22:megalodon:feature/clickable-reply-line-compose)
|
||||||
* [Add option to allow voting for multiple options on polls](https://github.com/sk22/megalodon/commit/5b28468efd49387b4f8b83f142f3adf3104ca60c)
|
|
||||||
* [Add translate function](https://github.com/mastodon/mastodon-android/compare/master...sk22:megalodon:feature/translate-button)
|
|
||||||
* [Add language selector](https://github.com/mastodon/mastodon-android/compare/master...sk22:megalodon:feature/language-selector)
|
|
||||||
* [Implement deleting notifications](https://github.com/sk22/megalodon/commit/b0f9ce081f69f29ad59658fc00ca41372cd2677d) (disabled by default)
|
|
||||||
* [Long-click boost button to "quote" a post](https://github.com/sk22/megalodon/commit/b25a237c20c6a924ed4d9b357999867c3a32b32b)
|
|
||||||
* [Draft and schedule posts](https://github.com/sk22/megalodon/pull/217)
|
|
||||||
* [Display original post when replying](https://github.com/sk22/megalodon/commit/375f8ceb2747705fedf43686681cc0e0b812f899)
|
|
||||||
* [Display server announcements](https://github.com/sk22/megalodon/commit/84179bc207d6b69cc2a770a3c28fa0a39b0b54e8)
|
|
||||||
* [Create](https://github.com/sk22/megalodon/commit/294595513a45037359b31377aafc25ae5b58d8e7), [edit](https://github.com/sk22/megalodon/commit/d47797bf7ac8cff3f9ba1cfee219a1bb2af21da6) and [delete](https://github.com/sk22/megalodon/commit/54c29fd787fc2cd0dfd2787ad796b8190f795973) lists
|
|
||||||
* [Soft-blocking (by blocking and immediately unblocking)](https://github.com/sk22/megalodon/commit/e75d350b7a2709259e9fc5138e0e1f361bdb0972)
|
|
||||||
|
|
||||||
|
|
||||||
### Behavior
|
### Behavior
|
||||||
@@ -163,18 +117,6 @@ There's also a handful of custom strings exclusive to this projects that would n
|
|||||||
* [Option to hide interaction numbers](https://github.com/mastodon/mastodon-android/compare/master...sk22:megalodon:settings/hide-interaction-numbers)
|
* [Option to hide interaction numbers](https://github.com/mastodon/mastodon-android/compare/master...sk22:megalodon:settings/hide-interaction-numbers)
|
||||||
* [Option to always reveal content warnings](https://github.com/mastodon/mastodon-android/compare/master...sk22:megalodon:feature/cw-above-text)
|
* [Option to always reveal content warnings](https://github.com/mastodon/mastodon-android/compare/master...sk22:megalodon:feature/cw-above-text)
|
||||||
* [Option to disable scrolling title bars](https://github.com/mastodon/mastodon-android/compare/master...sk22:megalodon:settings/disable-marquee)
|
* [Option to disable scrolling title bars](https://github.com/mastodon/mastodon-android/compare/master...sk22:megalodon:settings/disable-marquee)
|
||||||
* [No ellipsis for long poll answers](https://github.com/mastodon/mastodon-android/commit/c9aae828e2518adccdc092e41f8d1f0489636271)
|
|
||||||
* [Show poll vote button for multiple and single answer polls](https://github.com/mastodon/mastodon-android/commit/e14dfda2fdf32f0fa3043504ac5831683a87559a)
|
|
||||||
* [Show own vote after voting](https://github.com/mastodon/mastodon-android/commit/4ab9e25fec4fd9c10b7a8ddd1be522b3cc12cf28) ([Closes issue](https://github.com/mastodon/mastodon-android/commit/4ab9e25fec4fd9c10b7a8ddd1be522b3cc12cf28))
|
|
||||||
* [Make inline emoji search case-insensitive and don't only search from start of emoji names](https://github.com/mastodon/mastodon-android/compare/master...sk22:megalodon:better-inline-emoji-search) ([Pull request](https://github.com/mastodon/mastodon-android/pull/445))
|
|
||||||
* [Include subject line when sharing e.g. a website to Megalodon](https://github.com/mastodon/mastodon-android/compare/master...sk22:megalodon:external-share-include-subject)
|
|
||||||
* [Improve semantics for voting on polls (radio buttons and checkboxes)](https://github.com/sk22/megalodon/commit/6fd58c96827cb1d2da329cebdc170a1425dd18d7)
|
|
||||||
* [Copy post URL when long-pressing share button](https://github.com/sk22/megalodon/commit/ba36347f03278763ecec617b1ce57ba89db7be72)
|
|
||||||
* [Add option to disable swiping between tabs](https://github.com/sk22/megalodon/commit/1f20b21fc84bf006c1ec14bd2229cbfad5215ec8)
|
|
||||||
* [Resolve Fediverse links in the app](https://github.com/mastodon/mastodon-android/compare/master...sk22:megalodon:feature/open-urls-in-app)
|
|
||||||
* [Preserve whitespaces in HTML](https://github.com/sk22/megalodon/commit/7d876bddc7a07d98f0fecbf62b13bdb9fcce3412)
|
|
||||||
* [Long-click to copy links](https://github.com/sk22/megalodon/commit/b32e32274923a94742a9926ef38785f746d41405)
|
|
||||||
* Improved filtering using Mastodon 4.0 API: [#202](https://github.com/sk22/megalodon/pull/202), [#212](https://github.com/sk22/megalodon/pull/212), [#255](https://github.com/sk22/megalodon/pull/255) by [@thiagojedi](https://github.com/thiagojedi)
|
|
||||||
|
|
||||||
|
|
||||||
### Visual
|
### Visual
|
||||||
@@ -182,14 +124,6 @@ There's also a handful of custom strings exclusive to this projects that would n
|
|||||||
* [Custom extended footer redesign](https://github.com/mastodon/mastodon-android/compare/master...sk22:megalodon:compact-extended-footer)
|
* [Custom extended footer redesign](https://github.com/mastodon/mastodon-android/compare/master...sk22:megalodon:compact-extended-footer)
|
||||||
* [Improvements to the true black mode](https://github.com/mastodon/mastodon-android/compare/master...sk22:megalodon:true-black-improvements)
|
* [Improvements to the true black mode](https://github.com/mastodon/mastodon-android/compare/master...sk22:megalodon:true-black-improvements)
|
||||||
* [Profile header tweaks](https://github.com/mastodon/mastodon-android/compare/master...sk22:megalodon:ui/profile-header-tweaks)
|
* [Profile header tweaks](https://github.com/mastodon/mastodon-android/compare/master...sk22:megalodon:ui/profile-header-tweaks)
|
||||||
* [Custom color themes](https://github.com/sk22/megalodon/pull/124) by [@LucasGGamerM](https://github.com/LucasGGamerM)
|
|
||||||
* [Custom "megalodon" text logo](https://github.com/sk22/megalodon/commit/563afd487ca5c608cfbb00fa3909d3c27384acc0) by [@LucasGGamerM](https://github.com/LucasGGamerM)
|
|
||||||
* [Custom login screen](https://github.com/sk22/megalodon/commit/9bbf8c4618dbe13accaeb3b5482bf3fe88cac4c0)
|
|
||||||
* [More distinct filled boost icon](https://github.com/sk22/megalodon/commits/more-distinct-filled-boost-icon)
|
|
||||||
* Material You color theme by [@LucasGGamerM](https://github.com/LucasGGamerM)
|
|
||||||
* [Animations for interaction buttons](https://github.com/mastodon/mastodon-android/compare/master...sk22:megalodon:feature/animate-buttons)
|
|
||||||
* [Dedicated icons for different notification types](https://github.com/sk22/megalodon/pull/178) by [@florian-obernberger](https://github.com/florian-obernberger)
|
|
||||||
* Scale text according to system settings
|
|
||||||
|
|
||||||
|
|
||||||
## Building
|
## Building
|
||||||
@@ -206,4 +140,4 @@ This project is released under the [GPL-3 License](./LICENSE).
|
|||||||
|
|
||||||
## Links
|
## Links
|
||||||
|
|
||||||
<a rel="me" href="https://floss.social/@megalodon">@megalodon<wbr>@floss.social</a>
|
<a rel="me" href="https://floss.social/@moshidon">@moshidon<wbr>@floss.social</a>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>Megalodon</title>
|
<title>Moshidon</title>
|
||||||
<link rel="icon" href="mastodon/src/main/res/mipmap-mdpi/ic_launcher_round.png">
|
<link rel="icon" href="mastodon/src/main/res/mipmap-mdpi/ic_launcher_round.png">
|
||||||
<link rel="me" href="https://floss.social/@mastodon">
|
<link rel="me" href="https://floss.social/@mastodon">
|
||||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/github-markdown-css/5.1.0/github-markdown.min.css">
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/github-markdown-css/5.1.0/github-markdown.min.css">
|
||||||
@@ -14,4 +14,4 @@
|
|||||||
{{ content }}
|
{{ content }}
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
find metadata -name '*.txt' -exec sed -Ei 's/^[–—─•·*]\s+/- /' {} \;
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 20 KiB |
@@ -5,12 +5,12 @@ plugins {
|
|||||||
android {
|
android {
|
||||||
compileSdk 33
|
compileSdk 33
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
archivesBaseName = "megalodon"
|
archivesBaseName = "moshidon"
|
||||||
applicationId "org.joinmastodon.android.sk"
|
applicationId "org.joinmastodon.android.moshinda"
|
||||||
minSdk 23
|
minSdk 23
|
||||||
targetSdk 33
|
targetSdk 33
|
||||||
versionCode 69
|
versionCode 75
|
||||||
versionName "1.1.5+fork.69"
|
versionName "1.1.4+fork.75.moshinda"
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
resConfigs "ar-rSA", "be-rBY", "bn-rBD", "bs-rBA", "ca-rES", "cs-rCZ", "de-rDE", "el-rGR", "es-rES", "eu-rES", "fi-rFI", "fil-rPH", "fr-rFR", "ga-rIE", "gd-rGB", "gl-rES", "hi-rIN", "hr-rHR", "hu-rHU", "hy-rAM", "in-rID", "is-rIS", "it-rIT", "iw-rIL", "ja-rJP", "kab", "ko-rKR", "nl-rNL", "oc-rFR", "pl-rPL", "pt-rBR", "pt-rPT", "ro-rRO", "ru-rRU", "si-rLK", "sl-rSI", "sv-rSE", "th-rTH", "tr-rTR", "uk-rUA", "vi-rVN", "zh-rCN", "zh-rTW"
|
resConfigs "ar-rSA", "be-rBY", "bn-rBD", "bs-rBA", "ca-rES", "cs-rCZ", "de-rDE", "el-rGR", "es-rES", "eu-rES", "fi-rFI", "fil-rPH", "fr-rFR", "ga-rIE", "gd-rGB", "gl-rES", "hi-rIN", "hr-rHR", "hu-rHU", "hy-rAM", "in-rID", "is-rIS", "it-rIT", "iw-rIL", "ja-rJP", "kab", "ko-rKR", "nl-rNL", "oc-rFR", "pl-rPL", "pt-rBR", "pt-rPT", "ro-rRO", "ru-rRU", "si-rLK", "sl-rSI", "sv-rSE", "th-rTH", "tr-rTR", "uk-rUA", "vi-rVN", "zh-rCN", "zh-rTW"
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
mastodon/src/github/ic_launcher-playstore.png
Normal file
BIN
mastodon/src/github/ic_launcher-playstore.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
@@ -113,13 +113,13 @@ public class GithubSelfUpdaterImpl extends GithubSelfUpdater{
|
|||||||
|
|
||||||
private void actuallyCheckForUpdates(){
|
private void actuallyCheckForUpdates(){
|
||||||
Request req=new Request.Builder()
|
Request req=new Request.Builder()
|
||||||
.url("https://api.github.com/repos/sk22/megalodon/releases/latest")
|
.url("https://api.github.com/repos/LucasGGamerM/moshidon/releases/latest")
|
||||||
.build();
|
.build();
|
||||||
Call call=MastodonAPIController.getHttpClient().newCall(req);
|
Call call=MastodonAPIController.getHttpClient().newCall(req);
|
||||||
try(Response resp=call.execute()){
|
try(Response resp=call.execute()){
|
||||||
JsonObject obj=JsonParser.parseReader(resp.body().charStream()).getAsJsonObject();
|
JsonObject obj=JsonParser.parseReader(resp.body().charStream()).getAsJsonObject();
|
||||||
String tag=obj.get("tag_name").getAsString();
|
|
||||||
String changelog=obj.get("body").getAsString();
|
String changelog=obj.get("body").getAsString();
|
||||||
|
String tag=obj.get("tag_name").getAsString();
|
||||||
Pattern pattern=Pattern.compile("v?(\\d+)\\.(\\d+)\\.(\\d+)\\+fork\\.(\\d+)");
|
Pattern pattern=Pattern.compile("v?(\\d+)\\.(\\d+)\\.(\\d+)\\+fork\\.(\\d+)");
|
||||||
Matcher matcher=pattern.matcher(tag);
|
Matcher matcher=pattern.matcher(tag);
|
||||||
if(!matcher.find()){
|
if(!matcher.find()){
|
||||||
@@ -147,7 +147,7 @@ public class GithubSelfUpdaterImpl extends GithubSelfUpdater{
|
|||||||
Log.d(TAG, "actuallyCheckForUpdates: new version: "+version);
|
Log.d(TAG, "actuallyCheckForUpdates: new version: "+version);
|
||||||
for(JsonElement el:obj.getAsJsonArray("assets")){
|
for(JsonElement el:obj.getAsJsonArray("assets")){
|
||||||
JsonObject asset=el.getAsJsonObject();
|
JsonObject asset=el.getAsJsonObject();
|
||||||
if("megalodon.apk".equals(asset.get("name").getAsString()) && "application/vnd.android.package-archive".equals(asset.get("content_type").getAsString()) && "uploaded".equals(asset.get("state").getAsString())){
|
if("moshidon.apk".equals(asset.get("name").getAsString()) && "application/vnd.android.package-archive".equals(asset.get("content_type").getAsString()) && "uploaded".equals(asset.get("state").getAsString())){
|
||||||
long size=asset.get("size").getAsLong();
|
long size=asset.get("size").getAsLong();
|
||||||
String url=asset.get("browser_download_url").getAsString();
|
String url=asset.get("browser_download_url").getAsString();
|
||||||
|
|
||||||
@@ -161,8 +161,8 @@ public class GithubSelfUpdaterImpl extends GithubSelfUpdater{
|
|||||||
.putLong("apkSize", size)
|
.putLong("apkSize", size)
|
||||||
.putString("version", version)
|
.putString("version", version)
|
||||||
.putString("apkURL", url)
|
.putString("apkURL", url)
|
||||||
.putString("changelog", changelog)
|
|
||||||
.putInt("checkedByBuild", BuildConfig.VERSION_CODE)
|
.putInt("checkedByBuild", BuildConfig.VERSION_CODE)
|
||||||
|
.putString("changelog", changelog)
|
||||||
.remove("downloadID")
|
.remove("downloadID")
|
||||||
.apply();
|
.apply();
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
<application
|
<application
|
||||||
android:name=".MastodonApp"
|
android:name=".MastodonApp"
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
android:label="@string/sk_app_name"
|
android:label="@string/app_name"
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:localeConfig="@xml/locales_config"
|
android:localeConfig="@xml/locales_config"
|
||||||
android:icon="@mipmap/ic_launcher"
|
android:icon="@mipmap/ic_launcher"
|
||||||
@@ -34,7 +34,7 @@
|
|||||||
<action android:name="android.intent.action.VIEW"/>
|
<action android:name="android.intent.action.VIEW"/>
|
||||||
<category android:name="android.intent.category.BROWSABLE"/>
|
<category android:name="android.intent.category.BROWSABLE"/>
|
||||||
<category android:name="android.intent.category.DEFAULT"/>
|
<category android:name="android.intent.category.DEFAULT"/>
|
||||||
<data android:scheme="megalodon-android-auth" android:host="callback"/>
|
<data android:scheme="moshidon-android-auth" android:host="callback"/>
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<activity android:name=".ExternalShareActivity" android:exported="true" android:configChanges="orientation|screenSize" android:windowSoftInputMode="adjustResize">
|
<activity android:name=".ExternalShareActivity" android:exported="true" android:configChanges="orientation|screenSize" android:windowSoftInputMode="adjustResize">
|
||||||
|
|||||||
@@ -1,85 +0,0 @@
|
|||||||
# lists.d Mastodon Blocklist (c) 2022 Greyhat Academy LICENSED UNDER: CC-BY-NC-SA 4.0
|
|
||||||
# https://raw.githubusercontent.com/greyhat-academy/lists.d/main/mastodon.domains.block.list.tsv
|
|
||||||
# This list contains domains of toxic mastodon instances
|
|
||||||
# Last-Modified: 1672044500
|
|
||||||
|
|
||||||
# gab - a neonazi social network
|
|
||||||
gab.ai
|
|
||||||
gab.com
|
|
||||||
gab.protohype.net
|
|
||||||
|
|
||||||
# consequence-free speech
|
|
||||||
social.unzensiert.to
|
|
||||||
freeatlantis.com
|
|
||||||
|
|
||||||
# reactionary bigotry and hatespeech against magrinalized groups
|
|
||||||
poa.st
|
|
||||||
freespeechextremist.com
|
|
||||||
rdrama.cc
|
|
||||||
outpoa.st
|
|
||||||
anime.website
|
|
||||||
gameliberty.club
|
|
||||||
social.byoblu.com
|
|
||||||
yggdrasil.social
|
|
||||||
smuglo.li
|
|
||||||
dogeposting.social
|
|
||||||
unsafe.space
|
|
||||||
freezepeach.xyz
|
|
||||||
|
|
||||||
# + CSAM
|
|
||||||
rojogato.com
|
|
||||||
|
|
||||||
# antivaxxer shitposting & fearmongering
|
|
||||||
shadowsocial.org
|
|
||||||
|
|
||||||
# Kiwifarms
|
|
||||||
kiwifarms.net
|
|
||||||
kiwifarms.cc
|
|
||||||
kiwifarms.is
|
|
||||||
kiwifarms.pleroma.net
|
|
||||||
|
|
||||||
|
|
||||||
# https://mastodon.art/@Curator/109649354849593592
|
|
||||||
|
|
||||||
poa.st antisemitic racist homophobic
|
|
||||||
nicecrew.digital antisemitic
|
|
||||||
beefyboys.win antisemitic racist homophobic harassment
|
|
||||||
cawfee.club antisemitic racist homophobic
|
|
||||||
comfyboy.club antisemitic racist homophobic
|
|
||||||
freespeechextremist.com racist homophobic
|
|
||||||
cum.salon racist misogynist
|
|
||||||
bae.st racist
|
|
||||||
natehiggers.online racist
|
|
||||||
rapemeat.solutions misogynist
|
|
||||||
rapist.town misogynist
|
|
||||||
rapefeminists.network misogynist
|
|
||||||
kiwifarms.cc harassment
|
|
||||||
noagendasocial.com noagenda
|
|
||||||
posting.lolicon.rocks underage
|
|
||||||
urchan.org harassment homophobic racist
|
|
||||||
ryona.agency harassment
|
|
||||||
yggdrasil.social antisemitic homophobic racist
|
|
||||||
genderheretics.xyz transphobic
|
|
||||||
baraag.net underage
|
|
||||||
lolison.top underage
|
|
||||||
shota.house underage
|
|
||||||
shota.social underage
|
|
||||||
aethy.com underage
|
|
||||||
taullo.social underage
|
|
||||||
childpawn.shop underage
|
|
||||||
posting.lolicon.rocks underage
|
|
||||||
loli.best underage
|
|
||||||
gothloli.club underage
|
|
||||||
smuglo.li underage
|
|
||||||
youjo.love underage
|
|
||||||
pedo.school underage
|
|
||||||
lolison.network underage
|
|
||||||
freak.university underage
|
|
||||||
mirr0r.city underage
|
|
||||||
xhais.love underage
|
|
||||||
refusal.biz underage
|
|
||||||
refusal.llc underage
|
|
||||||
mirr0r.city underage
|
|
||||||
nnia.space underage
|
|
||||||
ignorelist.com malicious
|
|
||||||
repl.co malicious
|
|
||||||
|
Binary file not shown.
|
Before Width: | Height: | Size: 358 KiB After Width: | Height: | Size: 15 KiB |
@@ -12,6 +12,7 @@ import android.widget.Toast;
|
|||||||
import org.joinmastodon.android.api.session.AccountSession;
|
import org.joinmastodon.android.api.session.AccountSession;
|
||||||
import org.joinmastodon.android.api.session.AccountSessionManager;
|
import org.joinmastodon.android.api.session.AccountSessionManager;
|
||||||
import org.joinmastodon.android.fragments.ComposeFragment;
|
import org.joinmastodon.android.fragments.ComposeFragment;
|
||||||
|
import org.joinmastodon.android.ui.M3AlertDialogBuilder;
|
||||||
import org.joinmastodon.android.ui.utils.UiUtils;
|
import org.joinmastodon.android.ui.utils.UiUtils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -35,10 +36,13 @@ public class ExternalShareActivity extends FragmentStackActivity{
|
|||||||
openComposeFragment(sessions.get(0).getID());
|
openComposeFragment(sessions.get(0).getID());
|
||||||
}else{
|
}else{
|
||||||
getWindow().setBackgroundDrawable(new ColorDrawable(0xff000000));
|
getWindow().setBackgroundDrawable(new ColorDrawable(0xff000000));
|
||||||
UiUtils.pickAccount(this, null, R.string.choose_account, 0,
|
new M3AlertDialogBuilder(this)
|
||||||
session -> openComposeFragment(session.getID()),
|
.setItems(sessions.stream().map(as->"@"+as.self.username+"@"+as.domain).toArray(String[]::new), (dialog, which)->{
|
||||||
b -> b.setOnCancelListener(d -> finish())
|
openComposeFragment(sessions.get(which).getID());
|
||||||
);
|
})
|
||||||
|
.setTitle(R.string.choose_account)
|
||||||
|
.setOnCancelListener(dialog -> finish())
|
||||||
|
.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -49,10 +53,7 @@ public class ExternalShareActivity extends FragmentStackActivity{
|
|||||||
Intent intent=getIntent();
|
Intent intent=getIntent();
|
||||||
StringBuilder builder=new StringBuilder();
|
StringBuilder builder=new StringBuilder();
|
||||||
String subject = "";
|
String subject = "";
|
||||||
if (intent.hasExtra(Intent.EXTRA_SUBJECT)) {
|
if (intent.hasExtra(Intent.EXTRA_SUBJECT)) builder.append(subject = intent.getStringExtra(Intent.EXTRA_SUBJECT)).append("\n\n");
|
||||||
subject = intent.getStringExtra(Intent.EXTRA_SUBJECT);
|
|
||||||
if (!subject.isBlank()) builder.append(subject).append("\n\n");
|
|
||||||
}
|
|
||||||
if (intent.hasExtra(Intent.EXTRA_TEXT)) builder.append(intent.getStringExtra(Intent.EXTRA_TEXT)).append("\n");
|
if (intent.hasExtra(Intent.EXTRA_TEXT)) builder.append(intent.getStringExtra(Intent.EXTRA_TEXT)).append("\n");
|
||||||
String text=builder.toString();
|
String text=builder.toString();
|
||||||
List<Uri> mediaUris;
|
List<Uri> mediaUris;
|
||||||
|
|||||||
@@ -4,12 +4,11 @@ import static org.joinmastodon.android.api.MastodonAPIController.gson;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.os.Build;
|
||||||
|
|
||||||
import com.google.gson.JsonSyntaxException;
|
import com.google.gson.JsonSyntaxException;
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
|
||||||
import org.joinmastodon.android.model.TimelineDefinition;
|
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -22,32 +21,24 @@ public class GlobalUserPreferences{
|
|||||||
public static boolean showReplies;
|
public static boolean showReplies;
|
||||||
public static boolean showBoosts;
|
public static boolean showBoosts;
|
||||||
public static boolean loadNewPosts;
|
public static boolean loadNewPosts;
|
||||||
|
public static boolean showFederatedTimeline;
|
||||||
public static boolean showInteractionCounts;
|
public static boolean showInteractionCounts;
|
||||||
public static boolean alwaysExpandContentWarnings;
|
public static boolean alwaysExpandContentWarnings;
|
||||||
public static boolean disableMarquee;
|
public static boolean disableMarquee;
|
||||||
public static boolean disableSwipe;
|
public static boolean disableSwipe;
|
||||||
public static boolean voteButtonForSingleChoice;
|
public static boolean voteButtonForSingleChoice;
|
||||||
public static boolean enableDeleteNotifications;
|
public static boolean showDifferentiatedPushNoticationIcons;
|
||||||
public static boolean translateButtonOpenedOnly;
|
|
||||||
public static boolean uniformNotificationIcon;
|
|
||||||
public static boolean reduceMotion;
|
|
||||||
public static boolean keepOnlyLatestNotification;
|
|
||||||
public static boolean disableAltTextReminder;
|
|
||||||
public static String publishButtonText;
|
|
||||||
public static ThemePreference theme;
|
public static ThemePreference theme;
|
||||||
public static ColorPreference color;
|
public static ColorPreference color;
|
||||||
|
|
||||||
private final static Type recentLanguagesType = new TypeToken<Map<String, List<String>>>() {}.getType();
|
private final static Type recentLanguagesType = new TypeToken<Map<String, List<String>>>() {}.getType();
|
||||||
private final static Type pinnedTimelinesType = new TypeToken<Map<String, List<TimelineDefinition>>>() {}.getType();
|
|
||||||
public static Map<String, List<String>> recentLanguages;
|
public static Map<String, List<String>> recentLanguages;
|
||||||
public static Map<String, List<TimelineDefinition>> pinnedTimelines;
|
|
||||||
|
|
||||||
private static SharedPreferences getPrefs(){
|
private static SharedPreferences getPrefs(){
|
||||||
return MastodonApp.context.getSharedPreferences("global", Context.MODE_PRIVATE);
|
return MastodonApp.context.getSharedPreferences("global", Context.MODE_PRIVATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <T> T fromJson(String json, Type type, T orElse) {
|
private static <T> T fromJson(String json, Type type, T orElse) {
|
||||||
if (json == null) return orElse;
|
|
||||||
try { return gson.fromJson(json, type); }
|
try { return gson.fromJson(json, type); }
|
||||||
catch (JsonSyntaxException ignored) { return orElse; }
|
catch (JsonSyntaxException ignored) { return orElse; }
|
||||||
}
|
}
|
||||||
@@ -60,27 +51,25 @@ public class GlobalUserPreferences{
|
|||||||
showReplies=prefs.getBoolean("showReplies", true);
|
showReplies=prefs.getBoolean("showReplies", true);
|
||||||
showBoosts=prefs.getBoolean("showBoosts", true);
|
showBoosts=prefs.getBoolean("showBoosts", true);
|
||||||
loadNewPosts=prefs.getBoolean("loadNewPosts", true);
|
loadNewPosts=prefs.getBoolean("loadNewPosts", true);
|
||||||
|
showDifferentiatedPushNoticationIcons=prefs.getBoolean("showDifferentiatedPushNoticationIcons", false);
|
||||||
|
showFederatedTimeline=prefs.getBoolean("showFederatedTimeline", !BuildConfig.BUILD_TYPE.equals("playRelease"));
|
||||||
showInteractionCounts=prefs.getBoolean("showInteractionCounts", false);
|
showInteractionCounts=prefs.getBoolean("showInteractionCounts", false);
|
||||||
alwaysExpandContentWarnings=prefs.getBoolean("alwaysExpandContentWarnings", false);
|
alwaysExpandContentWarnings=prefs.getBoolean("alwaysExpandContentWarnings", false);
|
||||||
disableMarquee=prefs.getBoolean("disableMarquee", false);
|
disableMarquee=prefs.getBoolean("disableMarquee", false);
|
||||||
disableSwipe=prefs.getBoolean("disableSwipe", false);
|
disableSwipe=prefs.getBoolean("disableSwipe", false);
|
||||||
voteButtonForSingleChoice=prefs.getBoolean("voteButtonForSingleChoice", true);
|
voteButtonForSingleChoice=prefs.getBoolean("voteButtonForSingleChoice", true);
|
||||||
enableDeleteNotifications=prefs.getBoolean("enableDeleteNotifications", false);
|
|
||||||
translateButtonOpenedOnly=prefs.getBoolean("translateButtonOpenedOnly", false);
|
|
||||||
uniformNotificationIcon=prefs.getBoolean("uniformNotificationIcon", false);
|
|
||||||
reduceMotion=prefs.getBoolean("reduceMotion", false);
|
|
||||||
keepOnlyLatestNotification=prefs.getBoolean("keepOnlyLatestNotification", false);
|
|
||||||
disableAltTextReminder=prefs.getBoolean("disableAltTextReminder", false);
|
|
||||||
publishButtonText=prefs.getString("publishButtonText", "");
|
|
||||||
theme=ThemePreference.values()[prefs.getInt("theme", 0)];
|
theme=ThemePreference.values()[prefs.getInt("theme", 0)];
|
||||||
recentLanguages=fromJson(prefs.getString("recentLanguages", null), recentLanguagesType, new HashMap<>());
|
recentLanguages=fromJson(prefs.getString("recentLanguages", "{}"), recentLanguagesType, new HashMap<>());
|
||||||
pinnedTimelines=fromJson(prefs.getString("pinnedTimelines", null), pinnedTimelinesType, new HashMap<>());
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
color=ColorPreference.valueOf(prefs.getString("color", ColorPreference.PINK.name()));
|
if(android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.S){
|
||||||
|
color=ColorPreference.valueOf(prefs.getString("color", ColorPreference.MATERIAL3.name()));
|
||||||
|
}else{
|
||||||
|
color=ColorPreference.valueOf(prefs.getString("color", ColorPreference.PURPLE.name()));
|
||||||
|
}
|
||||||
} catch (IllegalArgumentException|ClassCastException ignored) {
|
} catch (IllegalArgumentException|ClassCastException ignored) {
|
||||||
// invalid color name or color was previously saved as integer
|
// invalid color name or color was previously saved as integer
|
||||||
color=ColorPreference.PINK;
|
color=ColorPreference.PURPLE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,22 +80,16 @@ public class GlobalUserPreferences{
|
|||||||
.putBoolean("showReplies", showReplies)
|
.putBoolean("showReplies", showReplies)
|
||||||
.putBoolean("showBoosts", showBoosts)
|
.putBoolean("showBoosts", showBoosts)
|
||||||
.putBoolean("loadNewPosts", loadNewPosts)
|
.putBoolean("loadNewPosts", loadNewPosts)
|
||||||
|
.putBoolean("showFederatedTimeline", showFederatedTimeline)
|
||||||
.putBoolean("trueBlackTheme", trueBlackTheme)
|
.putBoolean("trueBlackTheme", trueBlackTheme)
|
||||||
.putBoolean("showInteractionCounts", showInteractionCounts)
|
.putBoolean("showInteractionCounts", showInteractionCounts)
|
||||||
.putBoolean("alwaysExpandContentWarnings", alwaysExpandContentWarnings)
|
.putBoolean("alwaysExpandContentWarnings", alwaysExpandContentWarnings)
|
||||||
.putBoolean("disableMarquee", disableMarquee)
|
.putBoolean("disableMarquee", disableMarquee)
|
||||||
.putBoolean("disableSwipe", disableSwipe)
|
.putBoolean("disableSwipe", disableSwipe)
|
||||||
.putBoolean("enableDeleteNotifications", enableDeleteNotifications)
|
.putBoolean("showDifferentiatedPushNoticationIcons", showDifferentiatedPushNoticationIcons)
|
||||||
.putBoolean("translateButtonOpenedOnly", translateButtonOpenedOnly)
|
|
||||||
.putBoolean("uniformNotificationIcon", uniformNotificationIcon)
|
|
||||||
.putBoolean("reduceMotion", reduceMotion)
|
|
||||||
.putBoolean("keepOnlyLatestNotification", keepOnlyLatestNotification)
|
|
||||||
.putBoolean("disableAltTextReminder", disableAltTextReminder)
|
|
||||||
.putString("publishButtonText", publishButtonText)
|
|
||||||
.putInt("theme", theme.ordinal())
|
.putInt("theme", theme.ordinal())
|
||||||
.putString("color", color.name())
|
.putString("color", color.name())
|
||||||
.putString("recentLanguages", gson.toJson(recentLanguages))
|
.putString("recentLanguages", gson.toJson(recentLanguages))
|
||||||
.putString("pinnedTimelines", gson.toJson(pinnedTimelines))
|
|
||||||
.apply();
|
.apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,7 +101,8 @@ public class GlobalUserPreferences{
|
|||||||
BLUE,
|
BLUE,
|
||||||
BROWN,
|
BROWN,
|
||||||
RED,
|
RED,
|
||||||
YELLOW
|
YELLOW,
|
||||||
|
NORD
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum ThemePreference{
|
public enum ThemePreference{
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import org.joinmastodon.android.fragments.HomeFragment;
|
|||||||
import org.joinmastodon.android.fragments.ProfileFragment;
|
import org.joinmastodon.android.fragments.ProfileFragment;
|
||||||
import org.joinmastodon.android.fragments.ThreadFragment;
|
import org.joinmastodon.android.fragments.ThreadFragment;
|
||||||
import org.joinmastodon.android.fragments.onboarding.AccountActivationFragment;
|
import org.joinmastodon.android.fragments.onboarding.AccountActivationFragment;
|
||||||
import org.joinmastodon.android.fragments.onboarding.CustomWelcomeFragment;
|
import org.joinmastodon.android.fragments.onboarding.CustomLoginFragment;
|
||||||
import org.joinmastodon.android.model.Notification;
|
import org.joinmastodon.android.model.Notification;
|
||||||
import org.joinmastodon.android.ui.utils.UiUtils;
|
import org.joinmastodon.android.ui.utils.UiUtils;
|
||||||
import org.joinmastodon.android.updater.GithubSelfUpdater;
|
import org.joinmastodon.android.updater.GithubSelfUpdater;
|
||||||
@@ -33,7 +33,7 @@ public class MainActivity extends FragmentStackActivity{
|
|||||||
|
|
||||||
if(savedInstanceState==null){
|
if(savedInstanceState==null){
|
||||||
if(AccountSessionManager.getInstance().getLoggedInAccounts().isEmpty()){
|
if(AccountSessionManager.getInstance().getLoggedInAccounts().isEmpty()){
|
||||||
showFragmentClearingBackStack(new CustomWelcomeFragment());
|
showFragmentClearingBackStack(new CustomLoginFragment());
|
||||||
}else{
|
}else{
|
||||||
AccountSessionManager.getInstance().maybeUpdateLocalInfo();
|
AccountSessionManager.getInstance().maybeUpdateLocalInfo();
|
||||||
AccountSession session;
|
AccountSession session;
|
||||||
|
|||||||
@@ -8,7 +8,9 @@ import android.app.PendingIntent;
|
|||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.graphics.drawable.Icon;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
@@ -37,7 +39,6 @@ public class PushNotificationReceiver extends BroadcastReceiver{
|
|||||||
private static final String TAG="PushNotificationReceive";
|
private static final String TAG="PushNotificationReceive";
|
||||||
|
|
||||||
public static final int NOTIFICATION_ID=178;
|
public static final int NOTIFICATION_ID=178;
|
||||||
private static int notificationId = 0;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent){
|
public void onReceive(Context context, Intent intent){
|
||||||
@@ -136,20 +137,23 @@ public class PushNotificationReceiver extends BroadcastReceiver{
|
|||||||
builder.setContentTitle(pn.title)
|
builder.setContentTitle(pn.title)
|
||||||
.setContentText(pn.body)
|
.setContentText(pn.body)
|
||||||
.setStyle(new Notification.BigTextStyle().bigText(pn.body))
|
.setStyle(new Notification.BigTextStyle().bigText(pn.body))
|
||||||
.setSmallIcon(R.drawable.ic_ntf_logo)
|
.setContentIntent(PendingIntent.getActivity(context, accountID.hashCode() & 0xFFFF, contentIntent, PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT))
|
||||||
.setContentIntent(PendingIntent.getActivity(context, notificationId, contentIntent, PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT))
|
|
||||||
.setWhen(notification==null ? System.currentTimeMillis() : notification.createdAt.toEpochMilli())
|
.setWhen(notification==null ? System.currentTimeMillis() : notification.createdAt.toEpochMilli())
|
||||||
.setShowWhen(true)
|
.setShowWhen(true)
|
||||||
.setCategory(Notification.CATEGORY_SOCIAL)
|
.setCategory(Notification.CATEGORY_SOCIAL)
|
||||||
.setAutoCancel(true)
|
.setAutoCancel(true)
|
||||||
.setColor(context.getColor(R.color.primary_700));
|
.setColor(context.getColor(R.color.shortcut_icon_background));
|
||||||
|
if(GlobalUserPreferences.showDifferentiatedPushNoticationIcons){
|
||||||
if (!GlobalUserPreferences.uniformNotificationIcon) switch (pn.notificationType) {
|
switch (pn.notificationType) {
|
||||||
case FAVORITE -> builder.setSmallIcon(R.drawable.ic_fluent_star_24_filled);
|
case FAVORITE -> builder.setSmallIcon(R.drawable.ic_fluent_star_24_filled);
|
||||||
case REBLOG -> builder.setSmallIcon(R.drawable.ic_fluent_arrow_repeat_all_24_filled);
|
case REBLOG -> builder.setSmallIcon(R.drawable.ic_fluent_arrow_repeat_all_24_filled);
|
||||||
case FOLLOW -> builder.setSmallIcon(R.drawable.ic_fluent_person_add_24_filled);
|
case FOLLOW -> builder.setSmallIcon(R.drawable.ic_fluent_person_add_24_filled);
|
||||||
case MENTION -> builder.setSmallIcon(R.drawable.ic_fluent_mention_24_filled);
|
case MENTION -> builder.setSmallIcon(R.drawable.ic_fluent_mention_24_filled);
|
||||||
case POLL -> builder.setSmallIcon(R.drawable.ic_fluent_poll_24_filled);
|
case POLL -> builder.setSmallIcon(R.drawable.ic_fluent_poll_24_filled);
|
||||||
|
default -> builder.setSmallIcon(R.drawable.ic_ntf_logo);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
builder.setSmallIcon(R.drawable.ic_ntf_logo);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(avatar!=null){
|
if(avatar!=null){
|
||||||
@@ -158,6 +162,6 @@ public class PushNotificationReceiver extends BroadcastReceiver{
|
|||||||
if(AccountSessionManager.getInstance().getLoggedInAccounts().size()>1){
|
if(AccountSessionManager.getInstance().getLoggedInAccounts().size()>1){
|
||||||
builder.setSubText(accountName);
|
builder.setSubText(accountName);
|
||||||
}
|
}
|
||||||
nm.notify(accountID, GlobalUserPreferences.keepOnlyLatestNotification ? NOTIFICATION_ID : notificationId++, builder.build());
|
nm.notify(accountID, NOTIFICATION_ID, builder.build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,14 +12,11 @@ import com.google.gson.JsonParser;
|
|||||||
import com.google.gson.JsonSyntaxException;
|
import com.google.gson.JsonSyntaxException;
|
||||||
|
|
||||||
import org.joinmastodon.android.BuildConfig;
|
import org.joinmastodon.android.BuildConfig;
|
||||||
import org.joinmastodon.android.MastodonApp;
|
|
||||||
import org.joinmastodon.android.api.gson.IsoInstantTypeAdapter;
|
import org.joinmastodon.android.api.gson.IsoInstantTypeAdapter;
|
||||||
import org.joinmastodon.android.api.gson.IsoLocalDateTypeAdapter;
|
import org.joinmastodon.android.api.gson.IsoLocalDateTypeAdapter;
|
||||||
import org.joinmastodon.android.api.session.AccountSession;
|
import org.joinmastodon.android.api.session.AccountSession;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
@@ -50,26 +47,9 @@ public class MastodonAPIController{
|
|||||||
private static OkHttpClient httpClient=new OkHttpClient.Builder().build();
|
private static OkHttpClient httpClient=new OkHttpClient.Builder().build();
|
||||||
|
|
||||||
private AccountSession session;
|
private AccountSession session;
|
||||||
private static List<String> badDomains = new ArrayList<>();
|
|
||||||
|
|
||||||
static{
|
static{
|
||||||
thread.start();
|
thread.start();
|
||||||
try {
|
|
||||||
final BufferedReader reader = new BufferedReader(new InputStreamReader(
|
|
||||||
MastodonApp.context.getAssets().open("blocks.tsv")
|
|
||||||
));
|
|
||||||
String line;
|
|
||||||
while ((line = reader.readLine()) != null) {
|
|
||||||
if (line.isBlank() || line.startsWith("#")) continue;
|
|
||||||
String[] parts = line.replaceAll("\"", "").split("[\s,;]");
|
|
||||||
if (parts.length == 0) continue;
|
|
||||||
String domain = parts[0].toLowerCase().trim();
|
|
||||||
if (domain.isBlank()) continue;
|
|
||||||
badDomains.add(domain);
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public MastodonAPIController(@Nullable AccountSession session){
|
public MastodonAPIController(@Nullable AccountSession session){
|
||||||
@@ -77,11 +57,8 @@ public class MastodonAPIController{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public <T> void submitRequest(final MastodonAPIRequest<T> req){
|
public <T> void submitRequest(final MastodonAPIRequest<T> req){
|
||||||
final String host = req.getURL().getHost();
|
|
||||||
final boolean isBad = host == null || badDomains.stream().anyMatch(h -> h.equalsIgnoreCase(host) || host.toLowerCase().endsWith("." + h));
|
|
||||||
thread.postRunnable(()->{
|
thread.postRunnable(()->{
|
||||||
try{
|
try{
|
||||||
if (isBad) throw new IllegalArgumentException();
|
|
||||||
if(req.canceled)
|
if(req.canceled)
|
||||||
return;
|
return;
|
||||||
Request.Builder builder=new Request.Builder()
|
Request.Builder builder=new Request.Builder()
|
||||||
|
|||||||
@@ -162,8 +162,6 @@ public class PushSubscriptionManager{
|
|||||||
@Override
|
@Override
|
||||||
public void onSuccess(PushSubscription result){
|
public void onSuccess(PushSubscription result){
|
||||||
MastodonAPIController.runInBackground(()->{
|
MastodonAPIController.runInBackground(()->{
|
||||||
result.serverKey=result.serverKey.replace('/','_');
|
|
||||||
result.serverKey=result.serverKey.replace('+','-');
|
|
||||||
serverKey=deserializeRawPublicKey(Base64.decode(result.serverKey, Base64.URL_SAFE));
|
serverKey=deserializeRawPublicKey(Base64.decode(result.serverKey, Base64.URL_SAFE));
|
||||||
|
|
||||||
AccountSession session=AccountSessionManager.getInstance().tryGetAccount(accountID);
|
AccountSession session=AccountSessionManager.getInstance().tryGetAccount(accountID);
|
||||||
@@ -372,7 +370,7 @@ public class PushSubscriptionManager{
|
|||||||
for(AccountSession session:AccountSessionManager.getInstance().getLoggedInAccounts()){
|
for(AccountSession session:AccountSessionManager.getInstance().getLoggedInAccounts()){
|
||||||
if(session.pushSubscription==null || forceReRegister)
|
if(session.pushSubscription==null || forceReRegister)
|
||||||
session.getPushSubscriptionManager().registerAccountForPush(session.pushSubscription);
|
session.getPushSubscriptionManager().registerAccountForPush(session.pushSubscription);
|
||||||
else
|
else if(session.needUpdatePushSettings)
|
||||||
session.getPushSubscriptionManager().updatePushSettings(session.pushSubscription);
|
session.getPushSubscriptionManager().updatePushSettings(session.pushSubscription);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import org.joinmastodon.android.api.requests.statuses.SetStatusFavorited;
|
|||||||
import org.joinmastodon.android.api.requests.statuses.SetStatusReblogged;
|
import org.joinmastodon.android.api.requests.statuses.SetStatusReblogged;
|
||||||
import org.joinmastodon.android.events.StatusCountersUpdatedEvent;
|
import org.joinmastodon.android.events.StatusCountersUpdatedEvent;
|
||||||
import org.joinmastodon.android.model.Status;
|
import org.joinmastodon.android.model.Status;
|
||||||
import org.joinmastodon.android.model.StatusPrivacy;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
@@ -19,18 +18,12 @@ import me.grishka.appkit.api.ErrorResponse;
|
|||||||
|
|
||||||
public class StatusInteractionController{
|
public class StatusInteractionController{
|
||||||
private final String accountID;
|
private final String accountID;
|
||||||
private final boolean updateCounters;
|
|
||||||
private final HashMap<String, SetStatusFavorited> runningFavoriteRequests=new HashMap<>();
|
private final HashMap<String, SetStatusFavorited> runningFavoriteRequests=new HashMap<>();
|
||||||
private final HashMap<String, SetStatusReblogged> runningReblogRequests=new HashMap<>();
|
private final HashMap<String, SetStatusReblogged> runningReblogRequests=new HashMap<>();
|
||||||
private final HashMap<String, SetStatusBookmarked> runningBookmarkRequests=new HashMap<>();
|
private final HashMap<String, SetStatusBookmarked> runningBookmarkRequests=new HashMap<>();
|
||||||
|
|
||||||
public StatusInteractionController(String accountID, boolean updateCounters) {
|
|
||||||
this.accountID=accountID;
|
|
||||||
this.updateCounters=updateCounters;
|
|
||||||
}
|
|
||||||
|
|
||||||
public StatusInteractionController(String accountID){
|
public StatusInteractionController(String accountID){
|
||||||
this(accountID, true);
|
this.accountID=accountID;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFavorited(Status status, boolean favorited, Consumer<Status> cb){
|
public void setFavorited(Status status, boolean favorited, Consumer<Status> cb){
|
||||||
@@ -48,7 +41,7 @@ public class StatusInteractionController{
|
|||||||
runningFavoriteRequests.remove(status.id);
|
runningFavoriteRequests.remove(status.id);
|
||||||
result.favouritesCount = Math.max(0, status.favouritesCount) + (favorited ? 1 : -1);
|
result.favouritesCount = Math.max(0, status.favouritesCount) + (favorited ? 1 : -1);
|
||||||
cb.accept(result);
|
cb.accept(result);
|
||||||
if (updateCounters) E.post(new StatusCountersUpdatedEvent(result));
|
E.post(new StatusCountersUpdatedEvent(result));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -57,16 +50,16 @@ public class StatusInteractionController{
|
|||||||
error.showToast(MastodonApp.context);
|
error.showToast(MastodonApp.context);
|
||||||
status.favourited=!favorited;
|
status.favourited=!favorited;
|
||||||
cb.accept(status);
|
cb.accept(status);
|
||||||
if (updateCounters) E.post(new StatusCountersUpdatedEvent(status));
|
E.post(new StatusCountersUpdatedEvent(status));
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.exec(accountID);
|
.exec(accountID);
|
||||||
runningFavoriteRequests.put(status.id, req);
|
runningFavoriteRequests.put(status.id, req);
|
||||||
status.favourited=favorited;
|
status.favourited=favorited;
|
||||||
if (updateCounters) E.post(new StatusCountersUpdatedEvent(status));
|
E.post(new StatusCountersUpdatedEvent(status));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setReblogged(Status status, boolean reblogged, StatusPrivacy visibility, Consumer<Status> cb){
|
public void setReblogged(Status status, boolean reblogged, Consumer<Status> cb){
|
||||||
if(!Looper.getMainLooper().isCurrentThread())
|
if(!Looper.getMainLooper().isCurrentThread())
|
||||||
throw new IllegalStateException("Can only be called from main thread");
|
throw new IllegalStateException("Can only be called from main thread");
|
||||||
|
|
||||||
@@ -74,7 +67,7 @@ public class StatusInteractionController{
|
|||||||
if(current!=null){
|
if(current!=null){
|
||||||
current.cancel();
|
current.cancel();
|
||||||
}
|
}
|
||||||
SetStatusReblogged req=(SetStatusReblogged) new SetStatusReblogged(status.id, reblogged, visibility)
|
SetStatusReblogged req=(SetStatusReblogged) new SetStatusReblogged(status.id, reblogged)
|
||||||
.setCallback(new Callback<>(){
|
.setCallback(new Callback<>(){
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Status reblog){
|
public void onSuccess(Status reblog){
|
||||||
@@ -82,7 +75,7 @@ public class StatusInteractionController{
|
|||||||
runningReblogRequests.remove(status.id);
|
runningReblogRequests.remove(status.id);
|
||||||
result.reblogsCount = Math.max(0, status.reblogsCount) + (reblogged ? 1 : -1);
|
result.reblogsCount = Math.max(0, status.reblogsCount) + (reblogged ? 1 : -1);
|
||||||
cb.accept(result);
|
cb.accept(result);
|
||||||
if (updateCounters) E.post(new StatusCountersUpdatedEvent(result));
|
E.post(new StatusCountersUpdatedEvent(result));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -91,13 +84,13 @@ public class StatusInteractionController{
|
|||||||
error.showToast(MastodonApp.context);
|
error.showToast(MastodonApp.context);
|
||||||
status.reblogged=!reblogged;
|
status.reblogged=!reblogged;
|
||||||
cb.accept(status);
|
cb.accept(status);
|
||||||
if (updateCounters) E.post(new StatusCountersUpdatedEvent(status));
|
E.post(new StatusCountersUpdatedEvent(status));
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.exec(accountID);
|
.exec(accountID);
|
||||||
runningReblogRequests.put(status.id, req);
|
runningReblogRequests.put(status.id, req);
|
||||||
status.reblogged=reblogged;
|
status.reblogged=reblogged;
|
||||||
if (updateCounters) E.post(new StatusCountersUpdatedEvent(status));
|
E.post(new StatusCountersUpdatedEvent(status));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBookmarked(Status status, boolean bookmarked){
|
public void setBookmarked(Status status, boolean bookmarked){
|
||||||
@@ -118,7 +111,7 @@ public class StatusInteractionController{
|
|||||||
public void onSuccess(Status result){
|
public void onSuccess(Status result){
|
||||||
runningBookmarkRequests.remove(status.id);
|
runningBookmarkRequests.remove(status.id);
|
||||||
cb.accept(result);
|
cb.accept(result);
|
||||||
if (updateCounters) E.post(new StatusCountersUpdatedEvent(result));
|
E.post(new StatusCountersUpdatedEvent(result));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -127,12 +120,12 @@ public class StatusInteractionController{
|
|||||||
error.showToast(MastodonApp.context);
|
error.showToast(MastodonApp.context);
|
||||||
status.bookmarked=!bookmarked;
|
status.bookmarked=!bookmarked;
|
||||||
cb.accept(status);
|
cb.accept(status);
|
||||||
if (updateCounters) E.post(new StatusCountersUpdatedEvent(status));
|
E.post(new StatusCountersUpdatedEvent(status));
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.exec(accountID);
|
.exec(accountID);
|
||||||
runningBookmarkRequests.put(status.id, req);
|
runningBookmarkRequests.put(status.id, req);
|
||||||
status.bookmarked=bookmarked;
|
status.bookmarked=bookmarked;
|
||||||
if (updateCounters) E.post(new StatusCountersUpdatedEvent(status));
|
E.post(new StatusCountersUpdatedEvent(status));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
package org.joinmastodon.android.api.requests.announcements;
|
|
||||||
|
|
||||||
import org.joinmastodon.android.api.MastodonAPIRequest;
|
|
||||||
|
|
||||||
public class DismissAnnouncement extends MastodonAPIRequest<Object>{
|
|
||||||
public DismissAnnouncement(String id){
|
|
||||||
super(HttpMethod.POST, "/announcements/" + id + "/dismiss", Object.class);
|
|
||||||
setRequestBody(new Object());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
package org.joinmastodon.android.api.requests.announcements;
|
|
||||||
|
|
||||||
import com.google.gson.reflect.TypeToken;
|
|
||||||
|
|
||||||
import org.joinmastodon.android.api.MastodonAPIRequest;
|
|
||||||
import org.joinmastodon.android.model.Announcement;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class GetAnnouncements extends MastodonAPIRequest<List<Announcement>> {
|
|
||||||
public GetAnnouncements(boolean withDismissed) {
|
|
||||||
super(MastodonAPIRequest.HttpMethod.GET, "/announcements", new TypeToken<>(){});
|
|
||||||
addQueryParameter("with_dismissed", withDismissed ? "true" : "false");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package org.joinmastodon.android.api.requests.lists;
|
||||||
|
|
||||||
|
import org.joinmastodon.android.api.MastodonAPIRequest;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class AddList extends MastodonAPIRequest<Object> {
|
||||||
|
public AddList(String listName){
|
||||||
|
super(HttpMethod.POST, "/lists", Object.class);
|
||||||
|
Request req = new Request();
|
||||||
|
req.title = listName;
|
||||||
|
setRequestBody(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Request{
|
||||||
|
public String title;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
package org.joinmastodon.android.api.requests.lists;
|
|
||||||
|
|
||||||
import org.joinmastodon.android.api.MastodonAPIRequest;
|
|
||||||
import org.joinmastodon.android.model.ListTimeline;
|
|
||||||
|
|
||||||
public class CreateList extends MastodonAPIRequest<ListTimeline> {
|
|
||||||
public CreateList(String title, ListTimeline.RepliesPolicy repliesPolicy) {
|
|
||||||
super(HttpMethod.POST, "/lists", ListTimeline.class);
|
|
||||||
Request req = new Request();
|
|
||||||
req.title = title;
|
|
||||||
req.repliesPolicy = repliesPolicy;
|
|
||||||
setRequestBody(req);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Request {
|
|
||||||
public String title;
|
|
||||||
public ListTimeline.RepliesPolicy repliesPolicy;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
package org.joinmastodon.android.api.requests.lists;
|
|
||||||
|
|
||||||
import org.joinmastodon.android.api.MastodonAPIRequest;
|
|
||||||
import org.joinmastodon.android.model.ListTimeline;
|
|
||||||
|
|
||||||
public class DeleteList extends MastodonAPIRequest<Object> {
|
|
||||||
public DeleteList(String id) {
|
|
||||||
super(HttpMethod.DELETE, "/lists/" + id, Object.class);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package org.joinmastodon.android.api.requests.lists;
|
||||||
|
|
||||||
|
import org.joinmastodon.android.api.MastodonAPIRequest;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class EditListName extends MastodonAPIRequest<Object> {
|
||||||
|
public EditListName(String newListName, String listId){
|
||||||
|
super(HttpMethod.PUT, "/lists/"+listId, Object.class);
|
||||||
|
Request req = new Request();
|
||||||
|
req.title = newListName;
|
||||||
|
setRequestBody(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Request{
|
||||||
|
public String title;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
package org.joinmastodon.android.api.requests.lists;
|
|
||||||
|
|
||||||
import org.joinmastodon.android.api.MastodonAPIRequest;
|
|
||||||
import org.joinmastodon.android.model.ListTimeline;
|
|
||||||
|
|
||||||
public class GetList extends MastodonAPIRequest<ListTimeline> {
|
|
||||||
public GetList(String id) {
|
|
||||||
super(HttpMethod.GET, "/lists/" + id, ListTimeline.class);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package org.joinmastodon.android.api.requests.lists;
|
||||||
|
|
||||||
|
import org.joinmastodon.android.api.MastodonAPIRequest;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class RemoveList extends MastodonAPIRequest<Object> {
|
||||||
|
public RemoveList(String listId){
|
||||||
|
super(HttpMethod.DELETE, "/lists/"+listId, Object.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
package org.joinmastodon.android.api.requests.lists;
|
|
||||||
|
|
||||||
import org.joinmastodon.android.api.MastodonAPIRequest;
|
|
||||||
import org.joinmastodon.android.model.ListTimeline;
|
|
||||||
|
|
||||||
public class UpdateList extends MastodonAPIRequest<ListTimeline> {
|
|
||||||
public UpdateList(String id, String title, ListTimeline.RepliesPolicy repliesPolicy) {
|
|
||||||
super(HttpMethod.PUT, "/lists/" + id, ListTimeline.class);
|
|
||||||
CreateList.Request req = new CreateList.Request();
|
|
||||||
req.title = title;
|
|
||||||
req.repliesPolicy = repliesPolicy;
|
|
||||||
setRequestBody(req);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
package org.joinmastodon.android.api.requests.notifications;
|
|
||||||
|
|
||||||
import com.google.gson.reflect.TypeToken;
|
|
||||||
|
|
||||||
import org.joinmastodon.android.api.ApiUtils;
|
|
||||||
import org.joinmastodon.android.api.MastodonAPIRequest;
|
|
||||||
import org.joinmastodon.android.model.Notification;
|
|
||||||
|
|
||||||
import java.util.EnumSet;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class DismissNotification extends MastodonAPIRequest<Object>{
|
|
||||||
public DismissNotification(String id){
|
|
||||||
super(HttpMethod.POST, "/notifications/" + (id != null ? id + "/dismiss" : "clear"), Object.class);
|
|
||||||
setRequestBody(new Object());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -9,7 +9,7 @@ public class RegisterForPushNotifications extends MastodonAPIRequest<PushSubscri
|
|||||||
Request r=new Request();
|
Request r=new Request();
|
||||||
r.subscription.endpoint="https://app.joinmastodon.org/relay-to/fcm/"+deviceToken+"/"+accountID;
|
r.subscription.endpoint="https://app.joinmastodon.org/relay-to/fcm/"+deviceToken+"/"+accountID;
|
||||||
r.data.alerts=alerts;
|
r.data.alerts=alerts;
|
||||||
r.policy=policy;
|
r.data.policy=policy;
|
||||||
r.subscription.keys.p256dh=encryptionKey;
|
r.subscription.keys.p256dh=encryptionKey;
|
||||||
r.subscription.keys.auth=authKey;
|
r.subscription.keys.auth=authKey;
|
||||||
setRequestBody(r);
|
setRequestBody(r);
|
||||||
@@ -18,7 +18,6 @@ public class RegisterForPushNotifications extends MastodonAPIRequest<PushSubscri
|
|||||||
private static class Request{
|
private static class Request{
|
||||||
public Subscription subscription=new Subscription();
|
public Subscription subscription=new Subscription();
|
||||||
public Data data=new Data();
|
public Data data=new Data();
|
||||||
public PushSubscription.Policy policy;
|
|
||||||
|
|
||||||
private static class Keys{
|
private static class Keys{
|
||||||
public String p256dh;
|
public String p256dh;
|
||||||
@@ -32,6 +31,7 @@ public class RegisterForPushNotifications extends MastodonAPIRequest<PushSubscri
|
|||||||
|
|
||||||
private static class Data{
|
private static class Data{
|
||||||
public PushSubscription.Alerts alerts;
|
public PushSubscription.Alerts alerts;
|
||||||
|
public PushSubscription.Policy policy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,36 +3,23 @@ package org.joinmastodon.android.api.requests.notifications;
|
|||||||
import org.joinmastodon.android.api.MastodonAPIRequest;
|
import org.joinmastodon.android.api.MastodonAPIRequest;
|
||||||
import org.joinmastodon.android.model.PushSubscription;
|
import org.joinmastodon.android.model.PushSubscription;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import okhttp3.Response;
|
|
||||||
|
|
||||||
public class UpdatePushSettings extends MastodonAPIRequest<PushSubscription>{
|
public class UpdatePushSettings extends MastodonAPIRequest<PushSubscription>{
|
||||||
private final PushSubscription.Policy policy;
|
|
||||||
|
|
||||||
public UpdatePushSettings(PushSubscription.Alerts alerts, PushSubscription.Policy policy){
|
public UpdatePushSettings(PushSubscription.Alerts alerts, PushSubscription.Policy policy){
|
||||||
super(HttpMethod.PUT, "/push/subscription", PushSubscription.class);
|
super(HttpMethod.PUT, "/push/subscription", PushSubscription.class);
|
||||||
setRequestBody(new Request(alerts, policy));
|
setRequestBody(new Request(alerts, policy));
|
||||||
this.policy=policy;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void validateAndPostprocessResponse(PushSubscription respObj, Response httpResponse) throws IOException{
|
|
||||||
super.validateAndPostprocessResponse(respObj, httpResponse);
|
|
||||||
respObj.policy=policy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Request{
|
private static class Request{
|
||||||
public Data data=new Data();
|
public Data data=new Data();
|
||||||
public PushSubscription.Policy policy;
|
|
||||||
|
|
||||||
public Request(PushSubscription.Alerts alerts, PushSubscription.Policy policy){
|
public Request(PushSubscription.Alerts alerts, PushSubscription.Policy policy){
|
||||||
this.data.alerts=alerts;
|
this.data.alerts=alerts;
|
||||||
this.policy=policy;
|
this.data.policy=policy;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Data{
|
private static class Data{
|
||||||
public PushSubscription.Alerts alerts;
|
public PushSubscription.Alerts alerts;
|
||||||
|
public PushSubscription.Policy policy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ public class CreateOAuthApp extends MastodonAPIRequest<Application>{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static class Request{
|
private static class Request{
|
||||||
public String clientName="Megalodon";
|
public String clientName="Moshidon";
|
||||||
public String redirectUris=AccountSessionManager.REDIRECT_URI;
|
public String redirectUris=AccountSessionManager.REDIRECT_URI;
|
||||||
public String scopes=AccountSessionManager.SCOPE;
|
public String scopes=AccountSessionManager.SCOPE;
|
||||||
public String website="https://sk22.github.io/megalodon";
|
public String website="https://github.com/LucasGGamerM/moshidon";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package org.joinmastodon.android.api.requests.statuses;
|
package org.joinmastodon.android.api.requests.statuses;
|
||||||
|
|
||||||
import org.joinmastodon.android.api.MastodonAPIRequest;
|
import org.joinmastodon.android.api.MastodonAPIRequest;
|
||||||
import org.joinmastodon.android.model.ScheduledStatus;
|
|
||||||
import org.joinmastodon.android.model.Status;
|
import org.joinmastodon.android.model.Status;
|
||||||
import org.joinmastodon.android.model.StatusPrivacy;
|
import org.joinmastodon.android.model.StatusPrivacy;
|
||||||
|
|
||||||
@@ -10,29 +9,12 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class CreateStatus extends MastodonAPIRequest<Status>{
|
public class CreateStatus extends MastodonAPIRequest<Status>{
|
||||||
public static final Instant DRAFTS_AFTER_INSTANT = Instant.ofEpochMilli(253370764799999L) /* end of 9998 */;
|
|
||||||
private static final float draftFactor = 31536000000f /* one year */ / 253370764799999f /* end of 9998 */;
|
|
||||||
|
|
||||||
public static Instant getDraftInstant() {
|
|
||||||
// returns an instant between 9999-01-01 00:00:00 and 9999-12-31 23:59:59
|
|
||||||
// yes, this is a weird implementation for something that hardly matters
|
|
||||||
return DRAFTS_AFTER_INSTANT.plusMillis(1 + (long) (System.currentTimeMillis() * draftFactor));
|
|
||||||
}
|
|
||||||
|
|
||||||
public CreateStatus(CreateStatus.Request req, String uuid){
|
public CreateStatus(CreateStatus.Request req, String uuid){
|
||||||
super(HttpMethod.POST, "/statuses", Status.class);
|
super(HttpMethod.POST, "/statuses", Status.class);
|
||||||
setRequestBody(req);
|
setRequestBody(req);
|
||||||
addHeader("Idempotency-Key", uuid);
|
addHeader("Idempotency-Key", uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Scheduled extends MastodonAPIRequest<ScheduledStatus>{
|
|
||||||
public Scheduled(CreateStatus.Request req, String uuid){
|
|
||||||
super(HttpMethod.POST, "/statuses", ScheduledStatus.class);
|
|
||||||
setRequestBody(req);
|
|
||||||
addHeader("Idempotency-Key", uuid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Request{
|
public static class Request{
|
||||||
public String status;
|
public String status;
|
||||||
public List<String> mediaIds;
|
public List<String> mediaIds;
|
||||||
|
|||||||
@@ -7,10 +7,4 @@ public class DeleteStatus extends MastodonAPIRequest<Status>{
|
|||||||
public DeleteStatus(String id){
|
public DeleteStatus(String id){
|
||||||
super(HttpMethod.DELETE, "/statuses/"+id, Status.class);
|
super(HttpMethod.DELETE, "/statuses/"+id, Status.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Scheduled extends MastodonAPIRequest<Object> {
|
|
||||||
public Scheduled(String id) {
|
|
||||||
super(HttpMethod.DELETE, "/scheduled_statuses/"+id, Object.class);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
package org.joinmastodon.android.api.requests.statuses;
|
|
||||||
|
|
||||||
import com.google.gson.reflect.TypeToken;
|
|
||||||
|
|
||||||
import org.joinmastodon.android.api.requests.HeaderPaginationRequest;
|
|
||||||
import org.joinmastodon.android.model.ScheduledStatus;
|
|
||||||
|
|
||||||
public class GetScheduledStatuses extends HeaderPaginationRequest<ScheduledStatus>{
|
|
||||||
public GetScheduledStatuses(String maxID, int limit){
|
|
||||||
super(HttpMethod.GET, "/scheduled_statuses", new TypeToken<>(){});
|
|
||||||
if(maxID!=null)
|
|
||||||
addQueryParameter("max_id", maxID);
|
|
||||||
if(limit>0)
|
|
||||||
addQueryParameter("limit", limit+"");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2,17 +2,10 @@ package org.joinmastodon.android.api.requests.statuses;
|
|||||||
|
|
||||||
import org.joinmastodon.android.api.MastodonAPIRequest;
|
import org.joinmastodon.android.api.MastodonAPIRequest;
|
||||||
import org.joinmastodon.android.model.Status;
|
import org.joinmastodon.android.model.Status;
|
||||||
import org.joinmastodon.android.model.StatusPrivacy;
|
|
||||||
|
|
||||||
public class SetStatusReblogged extends MastodonAPIRequest<Status>{
|
public class SetStatusReblogged extends MastodonAPIRequest<Status>{
|
||||||
public SetStatusReblogged(String id, boolean reblogged, StatusPrivacy visibility){
|
public SetStatusReblogged(String id, boolean reblogged){
|
||||||
super(HttpMethod.POST, "/statuses/"+id+"/"+(reblogged ? "reblog" : "unreblog"), Status.class);
|
super(HttpMethod.POST, "/statuses/"+id+"/"+(reblogged ? "reblog" : "unreblog"), Status.class);
|
||||||
Request req = new Request();
|
setRequestBody(new Object());
|
||||||
req.visibility = visibility;
|
|
||||||
setRequestBody(req);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Request {
|
|
||||||
public StatusPrivacy visibility;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,10 +9,6 @@ import org.joinmastodon.android.model.Hashtag;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class GetFollowedHashtags extends HeaderPaginationRequest<Hashtag> {
|
public class GetFollowedHashtags extends HeaderPaginationRequest<Hashtag> {
|
||||||
public GetFollowedHashtags() {
|
|
||||||
this(null, null, -1, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public GetFollowedHashtags(String maxID, String minID, int limit, String sinceID){
|
public GetFollowedHashtags(String maxID, String minID, int limit, String sinceID){
|
||||||
super(HttpMethod.GET, "/followed_tags", new TypeToken<>(){});
|
super(HttpMethod.GET, "/followed_tags", new TypeToken<>(){});
|
||||||
if(maxID!=null)
|
if(maxID!=null)
|
||||||
|
|||||||
@@ -8,11 +8,9 @@ import org.joinmastodon.android.model.Status;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class GetTrendingStatuses extends MastodonAPIRequest<List<Status>>{
|
public class GetTrendingStatuses extends MastodonAPIRequest<List<Status>>{
|
||||||
public GetTrendingStatuses(int offset, int limit){
|
public GetTrendingStatuses(int limit){
|
||||||
super(HttpMethod.GET, "/trends/statuses", new TypeToken<>(){});
|
super(HttpMethod.GET, "/trends/statuses", new TypeToken<>(){});
|
||||||
if(limit>0)
|
if(limit>0)
|
||||||
addQueryParameter("limit", ""+limit);
|
addQueryParameter("limit", ""+limit);
|
||||||
if(offset>0)
|
|
||||||
addQueryParameter("offset", ""+offset);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ public class AccountSession{
|
|||||||
public Preferences preferences;
|
public Preferences preferences;
|
||||||
public AccountActivationInfo activationInfo;
|
public AccountActivationInfo activationInfo;
|
||||||
private transient MastodonAPIController apiController;
|
private transient MastodonAPIController apiController;
|
||||||
private transient StatusInteractionController statusInteractionController, remoteStatusInteractionController;
|
private transient StatusInteractionController statusInteractionController;
|
||||||
private transient CacheController cacheController;
|
private transient CacheController cacheController;
|
||||||
private transient PushSubscriptionManager pushSubscriptionManager;
|
private transient PushSubscriptionManager pushSubscriptionManager;
|
||||||
|
|
||||||
@@ -52,10 +52,6 @@ public class AccountSession{
|
|||||||
return domain+"_"+self.id;
|
return domain+"_"+self.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFullUsername() {
|
|
||||||
return "@"+self.username+"@"+domain;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MastodonAPIController getApiController(){
|
public MastodonAPIController getApiController(){
|
||||||
if(apiController==null)
|
if(apiController==null)
|
||||||
apiController=new MastodonAPIController(this);
|
apiController=new MastodonAPIController(this);
|
||||||
@@ -68,12 +64,6 @@ public class AccountSession{
|
|||||||
return statusInteractionController;
|
return statusInteractionController;
|
||||||
}
|
}
|
||||||
|
|
||||||
public StatusInteractionController getRemoteStatusInteractionController(){
|
|
||||||
if(remoteStatusInteractionController==null)
|
|
||||||
remoteStatusInteractionController=new StatusInteractionController(getID(), false);
|
|
||||||
return remoteStatusInteractionController;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CacheController getCacheController(){
|
public CacheController getCacheController(){
|
||||||
if(cacheController==null)
|
if(cacheController==null)
|
||||||
cacheController=new CacheController(getID());
|
cacheController=new CacheController(getID());
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ import android.net.Uri;
|
|||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import com.google.gson.JsonParseException;
|
||||||
|
|
||||||
import org.joinmastodon.android.BuildConfig;
|
import org.joinmastodon.android.BuildConfig;
|
||||||
import org.joinmastodon.android.E;
|
import org.joinmastodon.android.E;
|
||||||
import org.joinmastodon.android.MainActivity;
|
import org.joinmastodon.android.MainActivity;
|
||||||
@@ -61,7 +63,7 @@ import me.grishka.appkit.api.ErrorResponse;
|
|||||||
public class AccountSessionManager{
|
public class AccountSessionManager{
|
||||||
private static final String TAG="AccountSessionManager";
|
private static final String TAG="AccountSessionManager";
|
||||||
public static final String SCOPE="read write follow push";
|
public static final String SCOPE="read write follow push";
|
||||||
public static final String REDIRECT_URI="megalodon-android-auth://callback";
|
public static final String REDIRECT_URI="moshidon-android-auth://callback";
|
||||||
|
|
||||||
private static final AccountSessionManager instance=new AccountSessionManager();
|
private static final AccountSessionManager instance=new AccountSessionManager();
|
||||||
|
|
||||||
@@ -102,11 +104,12 @@ public class AccountSessionManager{
|
|||||||
|
|
||||||
public void addAccount(Instance instance, Token token, Account self, Application app, AccountActivationInfo activationInfo){
|
public void addAccount(Instance instance, Token token, Account self, Application app, AccountActivationInfo activationInfo){
|
||||||
instances.put(instance.uri, instance);
|
instances.put(instance.uri, instance);
|
||||||
|
updateInstanceInfoV2(instance);
|
||||||
AccountSession session=new AccountSession(token, self, app, instance.uri, activationInfo==null, activationInfo);
|
AccountSession session=new AccountSession(token, self, app, instance.uri, activationInfo==null, activationInfo);
|
||||||
sessions.put(session.getID(), session);
|
sessions.put(session.getID(), session);
|
||||||
lastActiveAccountID=session.getID();
|
lastActiveAccountID=session.getID();
|
||||||
writeAccountsFile();
|
writeAccountsFile();
|
||||||
updateMoreInstanceInfo(instance, instance.uri);
|
updateInstanceEmojis(instance, instance.uri);
|
||||||
if(PushSubscriptionManager.arePushNotificationsAvailable()){
|
if(PushSubscriptionManager.arePushNotificationsAvailable()){
|
||||||
session.getPushSubscriptionManager().registerAccountForPush(null);
|
session.getPushSubscriptionManager().registerAccountForPush(null);
|
||||||
}
|
}
|
||||||
@@ -211,7 +214,7 @@ public class AccountSessionManager{
|
|||||||
.path("/oauth/authorize")
|
.path("/oauth/authorize")
|
||||||
.appendQueryParameter("response_type", "code")
|
.appendQueryParameter("response_type", "code")
|
||||||
.appendQueryParameter("client_id", result.clientId)
|
.appendQueryParameter("client_id", result.clientId)
|
||||||
.appendQueryParameter("redirect_uri", "megalodon-android-auth://callback")
|
.appendQueryParameter("redirect_uri", "moshidon-android-auth://callback")
|
||||||
.appendQueryParameter("scope", SCOPE)
|
.appendQueryParameter("scope", SCOPE)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
@@ -325,7 +328,10 @@ public class AccountSessionManager{
|
|||||||
@Override
|
@Override
|
||||||
public void onSuccess(Instance instance){
|
public void onSuccess(Instance instance){
|
||||||
instances.put(domain, instance);
|
instances.put(domain, instance);
|
||||||
updateMoreInstanceInfo(instance, domain);
|
updateInstanceEmojis(instance, domain);
|
||||||
|
try {
|
||||||
|
updateInstanceInfoV2(instance);
|
||||||
|
} catch (Exception ignored) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -336,18 +342,16 @@ public class AccountSessionManager{
|
|||||||
.execNoAuth(domain);
|
.execNoAuth(domain);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateMoreInstanceInfo(Instance instance, String domain) {
|
public void updateInstanceInfoV2(Instance instance) {
|
||||||
new GetInstance.V2().setCallback(new Callback<>() {
|
new GetInstance.V2().setCallback(new Callback<>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Instance.V2 v2) {
|
public void onSuccess(Instance.V2 v2) {
|
||||||
if (instance != null) instance.v2 = v2;
|
if (instance != null) instance.v2 = v2;
|
||||||
updateInstanceEmojis(instance, domain);
|
writeAccountsFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(ErrorResponse errorResponse) {
|
public void onError(ErrorResponse errorResponse) {}
|
||||||
updateInstanceEmojis(instance, domain);
|
|
||||||
}
|
|
||||||
}).execNoAuth(instance.uri);
|
}).execNoAuth(instance.uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
package org.joinmastodon.android.events;
|
|
||||||
|
|
||||||
import org.joinmastodon.android.model.ScheduledStatus;
|
|
||||||
|
|
||||||
public class ScheduledStatusCreatedEvent {
|
|
||||||
public final ScheduledStatus scheduledStatus;
|
|
||||||
public final String accountID;
|
|
||||||
|
|
||||||
public ScheduledStatusCreatedEvent(ScheduledStatus scheduledStatus, String accountID){
|
|
||||||
this.scheduledStatus = scheduledStatus;
|
|
||||||
this.accountID=accountID;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package org.joinmastodon.android.events;
|
|
||||||
|
|
||||||
import org.joinmastodon.android.model.ScheduledStatus;
|
|
||||||
|
|
||||||
public class ScheduledStatusDeletedEvent{
|
|
||||||
public final String id;
|
|
||||||
public final String accountID;
|
|
||||||
|
|
||||||
public ScheduledStatusDeletedEvent(String id, String accountID){
|
|
||||||
this.id=id;
|
|
||||||
this.accountID=accountID;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,109 +0,0 @@
|
|||||||
package org.joinmastodon.android.fragments;
|
|
||||||
|
|
||||||
import static java.util.stream.Collectors.toList;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.text.TextUtils;
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.ImageButton;
|
|
||||||
|
|
||||||
import com.squareup.otto.Subscribe;
|
|
||||||
|
|
||||||
import org.joinmastodon.android.E;
|
|
||||||
import org.joinmastodon.android.R;
|
|
||||||
import org.joinmastodon.android.api.requests.announcements.GetAnnouncements;
|
|
||||||
import org.joinmastodon.android.api.requests.statuses.CreateStatus;
|
|
||||||
import org.joinmastodon.android.api.requests.statuses.GetScheduledStatuses;
|
|
||||||
import org.joinmastodon.android.api.session.AccountSession;
|
|
||||||
import org.joinmastodon.android.api.session.AccountSessionManager;
|
|
||||||
import org.joinmastodon.android.events.ScheduledStatusCreatedEvent;
|
|
||||||
import org.joinmastodon.android.events.ScheduledStatusDeletedEvent;
|
|
||||||
import org.joinmastodon.android.model.Account;
|
|
||||||
import org.joinmastodon.android.model.Announcement;
|
|
||||||
import org.joinmastodon.android.model.HeaderPaginationList;
|
|
||||||
import org.joinmastodon.android.model.Instance;
|
|
||||||
import org.joinmastodon.android.model.ScheduledStatus;
|
|
||||||
import org.joinmastodon.android.model.Status;
|
|
||||||
import org.joinmastodon.android.ui.displayitems.HeaderStatusDisplayItem;
|
|
||||||
import org.joinmastodon.android.ui.displayitems.StatusDisplayItem;
|
|
||||||
import org.joinmastodon.android.ui.displayitems.TextStatusDisplayItem;
|
|
||||||
import org.joinmastodon.android.ui.text.HtmlParser;
|
|
||||||
import org.joinmastodon.android.ui.utils.UiUtils;
|
|
||||||
import org.parceler.Parcels;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
import me.grishka.appkit.Nav;
|
|
||||||
import me.grishka.appkit.api.PaginatedList;
|
|
||||||
import me.grishka.appkit.api.SimpleCallback;
|
|
||||||
|
|
||||||
public class AnnouncementsFragment extends BaseStatusListFragment<Announcement> {
|
|
||||||
private Instance instance;
|
|
||||||
private AccountSession session;
|
|
||||||
private List<String> unreadIDs = null;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAttach(Activity activity){
|
|
||||||
super.onAttach(activity);
|
|
||||||
setTitle(R.string.sk_announcements);
|
|
||||||
session = AccountSessionManager.getInstance().getAccount(accountID);
|
|
||||||
instance = AccountSessionManager.getInstance().getInstanceInfo(session.domain);
|
|
||||||
loadData();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected List<StatusDisplayItem> buildDisplayItems(Announcement a) {
|
|
||||||
if(TextUtils.isEmpty(a.content)) return List.of();
|
|
||||||
Account instanceUser = new Account();
|
|
||||||
instanceUser.id = instanceUser.acct = instanceUser.username = session.domain;
|
|
||||||
instanceUser.displayName = instance.title;
|
|
||||||
instanceUser.url = "https://"+session.domain+"/about";
|
|
||||||
instanceUser.avatar = instanceUser.avatarStatic = instance.thumbnail;
|
|
||||||
instanceUser.emojis = List.of();
|
|
||||||
Status fakeStatus = a.toStatus();
|
|
||||||
TextStatusDisplayItem textItem = new TextStatusDisplayItem(a.id, HtmlParser.parse(a.content, a.emojis, a.mentions, a.tags, accountID), this, fakeStatus, true);
|
|
||||||
textItem.textSelectable = true;
|
|
||||||
return List.of(
|
|
||||||
HeaderStatusDisplayItem.fromAnnouncement(a, fakeStatus, instanceUser, this, accountID, this::onMarkAsRead),
|
|
||||||
textItem
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onMarkAsRead(String id) {
|
|
||||||
if (unreadIDs == null) return;
|
|
||||||
unreadIDs.remove(id);
|
|
||||||
if (unreadIDs.size() == 0) setResult(true, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDestroy() {
|
|
||||||
super.onDestroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void addAccountToKnown(Announcement s) {}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onItemClick(String id) {}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void doLoadData(int offset, int count){
|
|
||||||
currentRequest=new GetAnnouncements(true)
|
|
||||||
.setCallback(new SimpleCallback<>(this){
|
|
||||||
@Override
|
|
||||||
public void onSuccess(List<Announcement> result){
|
|
||||||
List<Announcement> unread = result.stream().filter(a -> !a.read).collect(toList());
|
|
||||||
List<Announcement> read = result.stream().filter(a -> a.read).collect(toList());
|
|
||||||
onDataLoaded(unread, true);
|
|
||||||
onDataLoaded(read, false);
|
|
||||||
unreadIDs = unread.stream().map(a -> a.id).collect(toList());
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.exec(accountID);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,17 +1,12 @@
|
|||||||
package org.joinmastodon.android.fragments;
|
package org.joinmastodon.android.fragments;
|
||||||
|
|
||||||
import static org.joinmastodon.android.GlobalUserPreferences.recentLanguages;
|
import static org.joinmastodon.android.GlobalUserPreferences.recentLanguages;
|
||||||
import static org.joinmastodon.android.api.requests.statuses.CreateStatus.DRAFTS_AFTER_INSTANT;
|
|
||||||
import static org.joinmastodon.android.api.requests.statuses.CreateStatus.getDraftInstant;
|
|
||||||
import static org.joinmastodon.android.utils.MastodonLanguage.allLanguages;
|
import static org.joinmastodon.android.utils.MastodonLanguage.allLanguages;
|
||||||
import static org.joinmastodon.android.utils.MastodonLanguage.defaultRecentLanguages;
|
import static org.joinmastodon.android.utils.MastodonLanguage.defaultRecentLanguages;
|
||||||
import static android.os.ext.SdkExtensions.getExtensionVersion;
|
|
||||||
|
|
||||||
import android.animation.ObjectAnimator;
|
import android.animation.ObjectAnimator;
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.DatePickerDialog;
|
|
||||||
import android.app.TimePickerDialog;
|
|
||||||
import android.content.ClipData;
|
import android.content.ClipData;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@@ -30,17 +25,15 @@ import android.net.Uri;
|
|||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
import android.provider.MediaStore;
|
|
||||||
import android.provider.OpenableColumns;
|
import android.provider.OpenableColumns;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
import android.text.InputFilter;
|
import android.text.InputFilter;
|
||||||
import android.text.Layout;
|
import android.text.Layout;
|
||||||
import android.text.SpannableStringBuilder;
|
|
||||||
import android.text.Spanned;
|
import android.text.Spanned;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
import android.text.format.DateFormat;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.util.TypedValue;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
@@ -62,7 +55,6 @@ import android.widget.ImageView;
|
|||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.PopupMenu;
|
import android.widget.PopupMenu;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.ScrollView;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
@@ -75,15 +67,13 @@ import org.joinmastodon.android.R;
|
|||||||
import org.joinmastodon.android.api.MastodonAPIController;
|
import org.joinmastodon.android.api.MastodonAPIController;
|
||||||
import org.joinmastodon.android.api.MastodonErrorResponse;
|
import org.joinmastodon.android.api.MastodonErrorResponse;
|
||||||
import org.joinmastodon.android.api.ProgressListener;
|
import org.joinmastodon.android.api.ProgressListener;
|
||||||
|
import org.joinmastodon.android.api.requests.accounts.GetPreferences;
|
||||||
import org.joinmastodon.android.api.requests.statuses.CreateStatus;
|
import org.joinmastodon.android.api.requests.statuses.CreateStatus;
|
||||||
import org.joinmastodon.android.api.requests.statuses.DeleteStatus;
|
|
||||||
import org.joinmastodon.android.api.requests.statuses.EditStatus;
|
import org.joinmastodon.android.api.requests.statuses.EditStatus;
|
||||||
import org.joinmastodon.android.api.requests.statuses.GetAttachmentByID;
|
import org.joinmastodon.android.api.requests.statuses.GetAttachmentByID;
|
||||||
import org.joinmastodon.android.api.requests.statuses.UploadAttachment;
|
import org.joinmastodon.android.api.requests.statuses.UploadAttachment;
|
||||||
import org.joinmastodon.android.api.session.AccountSession;
|
import org.joinmastodon.android.api.session.AccountSession;
|
||||||
import org.joinmastodon.android.api.session.AccountSessionManager;
|
import org.joinmastodon.android.api.session.AccountSessionManager;
|
||||||
import org.joinmastodon.android.events.ScheduledStatusCreatedEvent;
|
|
||||||
import org.joinmastodon.android.events.ScheduledStatusDeletedEvent;
|
|
||||||
import org.joinmastodon.android.events.StatusCountersUpdatedEvent;
|
import org.joinmastodon.android.events.StatusCountersUpdatedEvent;
|
||||||
import org.joinmastodon.android.events.StatusCreatedEvent;
|
import org.joinmastodon.android.events.StatusCreatedEvent;
|
||||||
import org.joinmastodon.android.events.StatusUpdatedEvent;
|
import org.joinmastodon.android.events.StatusUpdatedEvent;
|
||||||
@@ -95,7 +85,6 @@ import org.joinmastodon.android.model.Instance;
|
|||||||
import org.joinmastodon.android.model.Mention;
|
import org.joinmastodon.android.model.Mention;
|
||||||
import org.joinmastodon.android.model.Poll;
|
import org.joinmastodon.android.model.Poll;
|
||||||
import org.joinmastodon.android.model.Preferences;
|
import org.joinmastodon.android.model.Preferences;
|
||||||
import org.joinmastodon.android.model.ScheduledStatus;
|
|
||||||
import org.joinmastodon.android.model.Status;
|
import org.joinmastodon.android.model.Status;
|
||||||
import org.joinmastodon.android.model.StatusPrivacy;
|
import org.joinmastodon.android.model.StatusPrivacy;
|
||||||
import org.joinmastodon.android.ui.ComposeAutocompleteViewController;
|
import org.joinmastodon.android.ui.ComposeAutocompleteViewController;
|
||||||
@@ -111,7 +100,6 @@ import org.joinmastodon.android.ui.utils.TransferSpeedTracker;
|
|||||||
import org.joinmastodon.android.ui.utils.UiUtils;
|
import org.joinmastodon.android.ui.utils.UiUtils;
|
||||||
import org.joinmastodon.android.ui.views.ComposeEditText;
|
import org.joinmastodon.android.ui.views.ComposeEditText;
|
||||||
import org.joinmastodon.android.ui.views.ComposeMediaLayout;
|
import org.joinmastodon.android.ui.views.ComposeMediaLayout;
|
||||||
import org.joinmastodon.android.ui.views.LinkedTextView;
|
|
||||||
import org.joinmastodon.android.ui.views.ReorderableLinearLayout;
|
import org.joinmastodon.android.ui.views.ReorderableLinearLayout;
|
||||||
import org.joinmastodon.android.ui.views.SizeListenerLinearLayout;
|
import org.joinmastodon.android.ui.views.SizeListenerLinearLayout;
|
||||||
import org.joinmastodon.android.utils.MastodonLanguage;
|
import org.joinmastodon.android.utils.MastodonLanguage;
|
||||||
@@ -121,12 +109,6 @@ import org.parceler.Parcels;
|
|||||||
import java.io.InterruptedIOException;
|
import java.io.InterruptedIOException;
|
||||||
import java.net.SocketException;
|
import java.net.SocketException;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.time.Instant;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.time.OffsetDateTime;
|
|
||||||
import java.time.ZoneId;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
import java.time.format.FormatStyle;
|
|
||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -149,7 +131,6 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
|
|||||||
|
|
||||||
private static final int MEDIA_RESULT=717;
|
private static final int MEDIA_RESULT=717;
|
||||||
private static final int IMAGE_DESCRIPTION_RESULT=363;
|
private static final int IMAGE_DESCRIPTION_RESULT=363;
|
||||||
private static final int SCHEDULED_STATUS_OPENED_RESULT=161;
|
|
||||||
private static final int MAX_ATTACHMENTS=4;
|
private static final int MAX_ATTACHMENTS=4;
|
||||||
private static final String TAG="ComposeFragment";
|
private static final String TAG="ComposeFragment";
|
||||||
|
|
||||||
@@ -173,9 +154,9 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
|
|||||||
private String accountID;
|
private String accountID;
|
||||||
private int charCount, charLimit, trimmedCharCount;
|
private int charCount, charLimit, trimmedCharCount;
|
||||||
|
|
||||||
private Button publishButton, languageButton, scheduleTimeBtn, draftsBtn;
|
private Button publishButton, languageButton;
|
||||||
private PopupMenu languagePopup, visibilityPopup, draftOptionsPopup;
|
private PopupMenu languagePopup, visibilityPopup;
|
||||||
private ImageButton mediaBtn, pollBtn, emojiBtn, spoilerBtn, visibilityBtn, scheduleDraftDismiss;
|
private ImageButton mediaBtn, pollBtn, emojiBtn, spoilerBtn, visibilityBtn;
|
||||||
private ImageView sensitiveIcon;
|
private ImageView sensitiveIcon;
|
||||||
private ComposeMediaLayout attachmentsView;
|
private ComposeMediaLayout attachmentsView;
|
||||||
private TextView replyText;
|
private TextView replyText;
|
||||||
@@ -184,13 +165,8 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
|
|||||||
private View addPollOptionBtn;
|
private View addPollOptionBtn;
|
||||||
private View sensitiveItem;
|
private View sensitiveItem;
|
||||||
private View pollAllowMultipleItem;
|
private View pollAllowMultipleItem;
|
||||||
private View scheduleDraftView;
|
|
||||||
private ScrollView scrollView;
|
|
||||||
private boolean initiallyScrolled = false;
|
|
||||||
private TextView scheduleDraftText;
|
|
||||||
private CheckBox pollAllowMultipleCheckbox;
|
private CheckBox pollAllowMultipleCheckbox;
|
||||||
private TextView pollDurationView;
|
private TextView pollDurationView;
|
||||||
private MenuItem draftMenuItem, undraftMenuItem, scheduleMenuItem, unscheduleMenuItem;
|
|
||||||
|
|
||||||
private ArrayList<DraftPollOption> pollOptions=new ArrayList<>();
|
private ArrayList<DraftPollOption> pollOptions=new ArrayList<>();
|
||||||
|
|
||||||
@@ -206,7 +182,6 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
|
|||||||
private EditText spoilerEdit;
|
private EditText spoilerEdit;
|
||||||
private boolean hasSpoiler;
|
private boolean hasSpoiler;
|
||||||
private boolean sensitive;
|
private boolean sensitive;
|
||||||
private Instant scheduledAt = null;
|
|
||||||
private ProgressBar sendProgress;
|
private ProgressBar sendProgress;
|
||||||
private ImageView sendError;
|
private ImageView sendError;
|
||||||
private View sendingOverlay;
|
private View sendingOverlay;
|
||||||
@@ -219,7 +194,6 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
|
|||||||
private boolean attachmentsErrorShowing;
|
private boolean attachmentsErrorShowing;
|
||||||
|
|
||||||
private Status editingStatus;
|
private Status editingStatus;
|
||||||
private ScheduledStatus scheduledStatus;
|
|
||||||
private boolean redraftStatus;
|
private boolean redraftStatus;
|
||||||
private boolean pollChanged;
|
private boolean pollChanged;
|
||||||
private boolean creatingView;
|
private boolean creatingView;
|
||||||
@@ -229,10 +203,14 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
|
|||||||
private String language;
|
private String language;
|
||||||
private MastodonLanguage.LanguageResolver languageResolver;
|
private MastodonLanguage.LanguageResolver languageResolver;
|
||||||
|
|
||||||
|
private int navigationBarColorBefore;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState){
|
public void onCreate(Bundle savedInstanceState){
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setRetainInstance(true);
|
setRetainInstance(true);
|
||||||
|
navigationBarColorBefore = getActivity().getWindow().getNavigationBarColor();
|
||||||
|
getActivity().getWindow().setNavigationBarColor(UiUtils.getThemeColor(getActivity(), R.attr.colorBackgroundLightest));
|
||||||
|
|
||||||
accountID=getArguments().getString("account");
|
accountID=getArguments().getString("account");
|
||||||
AccountSession session=AccountSessionManager.getInstance().getAccount(accountID);
|
AccountSession session=AccountSessionManager.getInstance().getAccount(accountID);
|
||||||
@@ -241,9 +219,9 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
|
|||||||
customEmojis=AccountSessionManager.getInstance().getCustomEmojis(instanceDomain);
|
customEmojis=AccountSessionManager.getInstance().getCustomEmojis(instanceDomain);
|
||||||
instance=AccountSessionManager.getInstance().getInstanceInfo(instanceDomain);
|
instance=AccountSessionManager.getInstance().getInstanceInfo(instanceDomain);
|
||||||
languageResolver=new MastodonLanguage.LanguageResolver(instance);
|
languageResolver=new MastodonLanguage.LanguageResolver(instance);
|
||||||
redraftStatus=getArguments().getBoolean("redraftStatus", false);
|
|
||||||
if(getArguments().containsKey("editStatus")){
|
if(getArguments().containsKey("editStatus")){
|
||||||
editingStatus=Parcels.unwrap(getArguments().getParcelable("editStatus"));
|
editingStatus=Parcels.unwrap(getArguments().getParcelable("editStatus"));
|
||||||
|
redraftStatus=getArguments().getBoolean("redraftStatus");
|
||||||
}
|
}
|
||||||
if(instance==null){
|
if(instance==null){
|
||||||
Nav.finish(this);
|
Nav.finish(this);
|
||||||
@@ -253,16 +231,14 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
|
|||||||
AccountSessionManager.getInstance().updateInstanceInfo(instanceDomain);
|
AccountSessionManager.getInstance().updateInstanceInfo(instanceDomain);
|
||||||
}
|
}
|
||||||
|
|
||||||
Bundle bundle = savedInstanceState != null ? savedInstanceState : getArguments();
|
|
||||||
if (bundle.containsKey("scheduledStatus")) scheduledStatus=Parcels.unwrap(bundle.getParcelable("scheduledStatus"));
|
|
||||||
if (bundle.containsKey("scheduledAt")) scheduledAt=(Instant) bundle.getSerializable("scheduledAt");
|
|
||||||
|
|
||||||
if(instance.maxTootChars>0)
|
if(instance.maxTootChars>0)
|
||||||
charLimit=instance.maxTootChars;
|
charLimit=instance.maxTootChars;
|
||||||
else if(instance.configuration!=null && instance.configuration.statuses!=null && instance.configuration.statuses.maxCharacters>0)
|
else if(instance.configuration!=null && instance.configuration.statuses!=null && instance.configuration.statuses.maxCharacters>0)
|
||||||
charLimit=instance.configuration.statuses.maxCharacters;
|
charLimit=instance.configuration.statuses.maxCharacters;
|
||||||
else
|
else
|
||||||
charLimit=500;
|
charLimit=500;
|
||||||
|
|
||||||
|
if (editingStatus == null) loadDefaultStatusVisibility(savedInstanceState);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -276,6 +252,7 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
|
|||||||
UiUtils.removeCallbacks(updateUploadEtaRunnable);
|
UiUtils.removeCallbacks(updateUploadEtaRunnable);
|
||||||
updateUploadEtaRunnable=null;
|
updateUploadEtaRunnable=null;
|
||||||
}
|
}
|
||||||
|
getActivity().getWindow().setNavigationBarColor(navigationBarColorBefore);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -297,11 +274,10 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
|
|||||||
mainEditTextWrap=view.findViewById(R.id.toot_text_wrap);
|
mainEditTextWrap=view.findViewById(R.id.toot_text_wrap);
|
||||||
charCounter=view.findViewById(R.id.char_counter);
|
charCounter=view.findViewById(R.id.char_counter);
|
||||||
charCounter.setText(String.valueOf(charLimit));
|
charCounter.setText(String.valueOf(charLimit));
|
||||||
scrollView=view.findViewById(R.id.scroll_view);
|
|
||||||
|
|
||||||
selfName=view.findViewById(R.id.self_name);
|
selfName=view.findViewById(R.id.name);
|
||||||
selfUsername=view.findViewById(R.id.self_username);
|
selfUsername=view.findViewById(R.id.username);
|
||||||
selfAvatar=view.findViewById(R.id.self_avatar);
|
selfAvatar=view.findViewById(R.id.avatar);
|
||||||
HtmlParser.setTextWithCustomEmoji(selfName, self.displayName, self.emojis);
|
HtmlParser.setTextWithCustomEmoji(selfName, self.displayName, self.emojis);
|
||||||
selfUsername.setText('@'+self.username+'@'+instanceDomain);
|
selfUsername.setText('@'+self.username+'@'+instanceDomain);
|
||||||
ViewImageLoader.load(selfAvatar, null, new UrlImageLoaderRequest(self.avatar));
|
ViewImageLoader.load(selfAvatar, null, new UrlImageLoaderRequest(self.avatar));
|
||||||
@@ -319,10 +295,6 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
|
|||||||
emojiBtn=view.findViewById(R.id.btn_emoji);
|
emojiBtn=view.findViewById(R.id.btn_emoji);
|
||||||
spoilerBtn=view.findViewById(R.id.btn_spoiler);
|
spoilerBtn=view.findViewById(R.id.btn_spoiler);
|
||||||
visibilityBtn=view.findViewById(R.id.btn_visibility);
|
visibilityBtn=view.findViewById(R.id.btn_visibility);
|
||||||
scheduleDraftView=view.findViewById(R.id.schedule_draft_view);
|
|
||||||
scheduleDraftText=view.findViewById(R.id.schedule_draft_text);
|
|
||||||
scheduleDraftDismiss=view.findViewById(R.id.schedule_draft_dismiss);
|
|
||||||
scheduleTimeBtn=view.findViewById(R.id.scheduled_time_btn);
|
|
||||||
sensitiveIcon=view.findViewById(R.id.sensitive_icon);
|
sensitiveIcon=view.findViewById(R.id.sensitive_icon);
|
||||||
sensitiveItem=view.findViewById(R.id.sensitive_item);
|
sensitiveItem=view.findViewById(R.id.sensitive_item);
|
||||||
replyText=view.findViewById(R.id.reply_text);
|
replyText=view.findViewById(R.id.reply_text);
|
||||||
@@ -334,10 +306,6 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
|
|||||||
buildVisibilityPopup(visibilityBtn);
|
buildVisibilityPopup(visibilityBtn);
|
||||||
visibilityBtn.setOnClickListener(v->visibilityPopup.show());
|
visibilityBtn.setOnClickListener(v->visibilityPopup.show());
|
||||||
visibilityBtn.setOnTouchListener(visibilityPopup.getDragToOpenListener());
|
visibilityBtn.setOnTouchListener(visibilityPopup.getDragToOpenListener());
|
||||||
|
|
||||||
scheduleDraftDismiss.setOnClickListener(v->updateScheduledAt(null));
|
|
||||||
scheduleTimeBtn.setOnClickListener(v->pickScheduledDateTime());
|
|
||||||
|
|
||||||
sensitiveItem.setOnClickListener(v->toggleSensitive());
|
sensitiveItem.setOnClickListener(v->toggleSensitive());
|
||||||
emojiKeyboard.setOnIconChangedListener(new PopupKeyboard.OnIconChangeListener(){
|
emojiKeyboard.setOnIconChangedListener(new PopupKeyboard.OnIconChangeListener(){
|
||||||
@Override
|
@Override
|
||||||
@@ -387,12 +355,8 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
|
|||||||
DraftPollOption opt=createDraftPollOption();
|
DraftPollOption opt=createDraftPollOption();
|
||||||
opt.edit.setText(eopt.title);
|
opt.edit.setText(eopt.title);
|
||||||
}
|
}
|
||||||
pollDuration=scheduledStatus == null
|
pollDuration=(int)editingStatus.poll.expiresAt.minus(System.currentTimeMillis(), ChronoUnit.MILLIS).getEpochSecond();
|
||||||
? (int)editingStatus.poll.expiresAt.minus(System.currentTimeMillis(), ChronoUnit.MILLIS).getEpochSecond()
|
pollDurationStr=UiUtils.formatTimeLeft(getActivity(), editingStatus.poll.expiresAt);
|
||||||
: Integer.parseInt(scheduledStatus.params.poll.expiresIn);
|
|
||||||
pollDurationStr=UiUtils.formatTimeLeft(getActivity(), scheduledStatus == null
|
|
||||||
? editingStatus.poll.expiresAt
|
|
||||||
: Instant.now().plus(pollDuration, ChronoUnit.SECONDS));
|
|
||||||
updatePollOptionHints();
|
updatePollOptionHints();
|
||||||
pollDurationView.setText(getString(R.string.compose_poll_duration, pollDurationStr));
|
pollDurationView.setText(getString(R.string.compose_poll_duration, pollDurationStr));
|
||||||
}else{
|
}else{
|
||||||
@@ -414,13 +378,6 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
|
|||||||
spoilerBtn.setSelected(true);
|
spoilerBtn.setSelected(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
sensitive = savedInstanceState==null && editingStatus != null ? editingStatus.sensitive
|
|
||||||
: savedInstanceState!=null && savedInstanceState.getBoolean("sensitive", false);
|
|
||||||
if (sensitive) {
|
|
||||||
sensitiveItem.setVisibility(View.VISIBLE);
|
|
||||||
sensitiveIcon.setSelected(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(savedInstanceState!=null && savedInstanceState.containsKey("attachments")){
|
if(savedInstanceState!=null && savedInstanceState.containsKey("attachments")){
|
||||||
ArrayList<Parcelable> serializedAttachments=savedInstanceState.getParcelableArrayList("attachments");
|
ArrayList<Parcelable> serializedAttachments=savedInstanceState.getParcelableArrayList("attachments");
|
||||||
for(Parcelable a:serializedAttachments){
|
for(Parcelable a:serializedAttachments){
|
||||||
@@ -438,10 +395,9 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
|
|||||||
|
|
||||||
if(editingStatus!=null && editingStatus.visibility!=null) {
|
if(editingStatus!=null && editingStatus.visibility!=null) {
|
||||||
statusVisibility=editingStatus.visibility;
|
statusVisibility=editingStatus.visibility;
|
||||||
} else {
|
|
||||||
loadDefaultStatusVisibility(savedInstanceState);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
loadDefaultStatusVisibility(savedInstanceState);
|
||||||
updateVisibilityIcon();
|
updateVisibilityIcon();
|
||||||
visibilityPopup.getMenu().findItem(switch(statusVisibility){
|
visibilityPopup.getMenu().findItem(switch(statusVisibility){
|
||||||
case PUBLIC -> R.id.vis_public;
|
case PUBLIC -> R.id.vis_public;
|
||||||
@@ -485,8 +441,6 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
|
|||||||
outState.putParcelableArrayList("attachments", serializedAttachments);
|
outState.putParcelableArrayList("attachments", serializedAttachments);
|
||||||
}
|
}
|
||||||
outState.putSerializable("visibility", statusVisibility);
|
outState.putSerializable("visibility", statusVisibility);
|
||||||
if (scheduledAt != null) outState.putSerializable("scheduledAt", scheduledAt);
|
|
||||||
if (scheduledStatus != null) outState.putParcelable("scheduledStatus", Parcels.wrap(scheduledStatus));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -506,8 +460,6 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
|
|||||||
|
|
||||||
mainEditText.setSelectionListener(this);
|
mainEditText.setSelectionListener(this);
|
||||||
mainEditText.addTextChangedListener(new TextWatcher(){
|
mainEditText.addTextChangedListener(new TextWatcher(){
|
||||||
private int lastChangeStart, lastChangeCount;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void beforeTextChanged(CharSequence s, int start, int count, int after){
|
public void beforeTextChanged(CharSequence s, int start, int count, int after){
|
||||||
|
|
||||||
@@ -517,16 +469,6 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
|
|||||||
public void onTextChanged(CharSequence s, int start, int before, int count){
|
public void onTextChanged(CharSequence s, int start, int before, int count){
|
||||||
if(s.length()==0)
|
if(s.length()==0)
|
||||||
return;
|
return;
|
||||||
lastChangeStart=start;
|
|
||||||
lastChangeCount=count;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void afterTextChanged(Editable s){
|
|
||||||
if(s.length()==0)
|
|
||||||
return;
|
|
||||||
int start=lastChangeStart;
|
|
||||||
int count=lastChangeCount;
|
|
||||||
// offset one char back to catch an already typed '@' or '#' or ':'
|
// offset one char back to catch an already typed '@' or '#' or ':'
|
||||||
int realStart=start;
|
int realStart=start;
|
||||||
start=Math.max(0, start-1);
|
start=Math.max(0, start-1);
|
||||||
@@ -572,84 +514,15 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
|
|||||||
editable.removeSpan(span);
|
editable.removeSpan(span);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterTextChanged(Editable s){
|
||||||
updateCharCounter();
|
updateCharCounter();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
spoilerEdit.addTextChangedListener(new SimpleTextWatcher(e->updateCharCounter()));
|
spoilerEdit.addTextChangedListener(new SimpleTextWatcher(e->updateCharCounter()));
|
||||||
if(replyTo!=null){
|
if(replyTo!=null){
|
||||||
View replyWrap = view.findViewById(R.id.reply_wrap);
|
|
||||||
scrollView.getViewTreeObserver().addOnGlobalLayoutListener(() -> {
|
|
||||||
int scrollHeight = scrollView.getHeight();
|
|
||||||
if (replyWrap.getMinimumHeight() != scrollHeight) {
|
|
||||||
replyWrap.setMinimumHeight(scrollHeight);
|
|
||||||
if (!initiallyScrolled) {
|
|
||||||
initiallyScrolled = true;
|
|
||||||
scrollView.post(() -> {
|
|
||||||
int bottom = scrollView.getChildAt(0).getBottom();
|
|
||||||
int delta = bottom - (scrollView.getScrollY() + scrollView.getHeight());
|
|
||||||
int space = GlobalUserPreferences.reduceMotion ? 0 : Math.min(V.dp(70), delta);
|
|
||||||
scrollView.scrollBy(0, delta - space);
|
|
||||||
if (!GlobalUserPreferences.reduceMotion) {
|
|
||||||
scrollView.postDelayed(() -> scrollView.smoothScrollBy(0, space), 130);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
View originalPost = view.findViewById(R.id.original_post);
|
|
||||||
originalPost.setVisibility(View.VISIBLE);
|
|
||||||
originalPost.setOnClickListener(v->{
|
|
||||||
Bundle args=new Bundle();
|
|
||||||
args.putString("account", accountID);
|
|
||||||
args.putParcelable("status", Parcels.wrap(replyTo));
|
|
||||||
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
|
|
||||||
Nav.go(getActivity(), ThreadFragment.class, args);
|
|
||||||
});
|
|
||||||
|
|
||||||
ImageView avatar = view.findViewById(R.id.avatar);
|
|
||||||
ViewImageLoader.load(avatar, null, new UrlImageLoaderRequest(replyTo.account.avatar));
|
|
||||||
ViewOutlineProvider roundCornersOutline=new ViewOutlineProvider(){
|
|
||||||
@Override
|
|
||||||
public void getOutline(View view, Outline outline){
|
|
||||||
outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), V.dp(12));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
avatar.setOutlineProvider(roundCornersOutline);
|
|
||||||
avatar.setClipToOutline(true);
|
|
||||||
avatar.setOnClickListener(v->{
|
|
||||||
Bundle args=new Bundle();
|
|
||||||
args.putString("account", accountID);
|
|
||||||
args.putParcelable("profileAccount", Parcels.wrap(replyTo.account));
|
|
||||||
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
|
|
||||||
Nav.go(getActivity(), ProfileFragment.class, args);
|
|
||||||
});
|
|
||||||
|
|
||||||
((TextView) view.findViewById(R.id.name)).setText(replyTo.account.displayName);
|
|
||||||
((TextView) view.findViewById(R.id.username)).setText(replyTo.account.getDisplayUsername());
|
|
||||||
view.findViewById(R.id.visibility).setVisibility(View.GONE);
|
|
||||||
Drawable visibilityIcon = getActivity().getDrawable(switch(replyTo.visibility){
|
|
||||||
case PUBLIC -> R.drawable.ic_fluent_earth_20_regular;
|
|
||||||
case UNLISTED -> R.drawable.ic_fluent_people_community_20_regular;
|
|
||||||
case PRIVATE -> R.drawable.ic_fluent_people_checkmark_20_regular;
|
|
||||||
case DIRECT -> R.drawable.ic_fluent_mention_20_regular;
|
|
||||||
});
|
|
||||||
ImageView moreBtn = view.findViewById(R.id.more);
|
|
||||||
moreBtn.setImageDrawable(visibilityIcon);
|
|
||||||
moreBtn.setBackground(null);
|
|
||||||
TextView timestamp = view.findViewById(R.id.timestamp);
|
|
||||||
if (replyTo.editedAt==null) timestamp.setText(UiUtils.formatRelativeTimestamp(getContext(), replyTo.createdAt));
|
|
||||||
else timestamp.setText(getString(R.string.edited_timestamp, UiUtils.formatRelativeTimestamp(getContext(), replyTo.editedAt)));
|
|
||||||
if (replyTo.spoilerText != null && !replyTo.spoilerText.isBlank()) {
|
|
||||||
view.findViewById(R.id.spoiler_header).setVisibility(View.VISIBLE);
|
|
||||||
((TextView) view.findViewById(R.id.spoiler_title_inline)).setText(replyTo.spoilerText);
|
|
||||||
}
|
|
||||||
|
|
||||||
SpannableStringBuilder content = HtmlParser.parse(replyTo.content, replyTo.emojis, replyTo.mentions, replyTo.tags, accountID);
|
|
||||||
LinkedTextView text = view.findViewById(R.id.text);
|
|
||||||
if (content.length() > 0) text.setText(content);
|
|
||||||
else view.findViewById(R.id.display_item_text).setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, V.dp(16)));
|
|
||||||
|
|
||||||
replyText.setText(getString(R.string.in_reply_to, replyTo.account.displayName));
|
replyText.setText(getString(R.string.in_reply_to, replyTo.account.displayName));
|
||||||
int visibilityNameRes = switch (replyTo.visibility) {
|
int visibilityNameRes = switch (replyTo.visibility) {
|
||||||
case PUBLIC -> R.string.visibility_public;
|
case PUBLIC -> R.string.visibility_public;
|
||||||
@@ -658,10 +531,24 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
|
|||||||
case DIRECT -> R.string.visibility_private;
|
case DIRECT -> R.string.visibility_private;
|
||||||
};
|
};
|
||||||
replyText.setContentDescription(getString(R.string.in_reply_to, replyTo.account.displayName) + ". " + getString(R.string.post_visibility) + ": " + getString(visibilityNameRes));
|
replyText.setContentDescription(getString(R.string.in_reply_to, replyTo.account.displayName) + ". " + getString(R.string.post_visibility) + ": " + getString(visibilityNameRes));
|
||||||
replyText.setOnClickListener(v->{
|
Drawable visibilityIcon = getActivity().getDrawable(switch(replyTo.visibility){
|
||||||
scrollView.smoothScrollTo(0, 0);
|
case PUBLIC -> R.drawable.ic_fluent_earth_20_regular;
|
||||||
|
case UNLISTED -> R.drawable.ic_fluent_people_community_20_regular;
|
||||||
|
case PRIVATE -> R.drawable.ic_fluent_people_checkmark_20_regular;
|
||||||
|
case DIRECT -> R.drawable.ic_at_symbol;
|
||||||
});
|
});
|
||||||
|
visibilityIcon.setBounds(0, 0, V.dp(20), V.dp(20));
|
||||||
|
Drawable replyArrow = getActivity().getDrawable(R.drawable.ic_fluent_arrow_reply_20_filled);
|
||||||
|
replyArrow.setBounds(0, 0, V.dp(20), V.dp(20));
|
||||||
|
replyText.setCompoundDrawables(replyArrow, null, visibilityIcon, null);
|
||||||
|
|
||||||
|
replyText.setOnClickListener(v->{
|
||||||
|
Bundle args=new Bundle();
|
||||||
|
args.putString("account", accountID);
|
||||||
|
args.putParcelable("status", Parcels.wrap(replyTo));
|
||||||
|
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
|
||||||
|
Nav.go(getActivity(), ThreadFragment.class, args);
|
||||||
|
});
|
||||||
ArrayList<String> mentions=new ArrayList<>();
|
ArrayList<String> mentions=new ArrayList<>();
|
||||||
String ownID=AccountSessionManager.getInstance().getAccount(accountID).self.id;
|
String ownID=AccountSessionManager.getInstance().getAccount(accountID).self.id;
|
||||||
if(!replyTo.account.id.equals(ownID))
|
if(!replyTo.account.id.equals(ownID))
|
||||||
@@ -705,7 +592,7 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
|
|||||||
DraftMediaAttachment da=new DraftMediaAttachment();
|
DraftMediaAttachment da=new DraftMediaAttachment();
|
||||||
da.serverAttachment=att;
|
da.serverAttachment=att;
|
||||||
da.description=att.description;
|
da.description=att.description;
|
||||||
da.uri=att.previewUrl!=null ? Uri.parse(att.previewUrl) : null;
|
da.uri=Uri.parse(att.previewUrl);
|
||||||
da.state=AttachmentUploadState.DONE;
|
da.state=AttachmentUploadState.DONE;
|
||||||
attachmentsView.addView(createMediaAttachmentView(da));
|
attachmentsView.addView(createMediaAttachmentView(da));
|
||||||
attachments.add(da);
|
attachments.add(da);
|
||||||
@@ -745,59 +632,42 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater){
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater){
|
||||||
MenuItem item=menu.add(editingStatus==null ? R.string.publish : R.string.save);
|
publishButton=new Button(getActivity());
|
||||||
|
publishButton.setText(editingStatus==null || redraftStatus ? R.string.publish : R.string.save);
|
||||||
|
publishButton.setOnClickListener(this::onPublishClick);
|
||||||
LinearLayout wrap=new LinearLayout(getActivity());
|
LinearLayout wrap=new LinearLayout(getActivity());
|
||||||
getActivity().getLayoutInflater().inflate(R.layout.compose_action, wrap);
|
wrap.setOrientation(LinearLayout.HORIZONTAL);
|
||||||
|
|
||||||
|
sendProgress=new ProgressBar(getActivity());
|
||||||
|
LinearLayout.LayoutParams progressLP=new LinearLayout.LayoutParams(V.dp(24), V.dp(24));
|
||||||
|
progressLP.setMarginEnd(V.dp(16));
|
||||||
|
progressLP.gravity=Gravity.CENTER_VERTICAL;
|
||||||
|
wrap.addView(sendProgress, progressLP);
|
||||||
|
|
||||||
|
sendError=new ImageView(getActivity());
|
||||||
|
sendError.setImageResource(R.drawable.ic_fluent_error_circle_24_regular);
|
||||||
|
sendError.setImageTintList(getResources().getColorStateList(R.color.error_600));
|
||||||
|
sendError.setScaleType(ImageView.ScaleType.CENTER);
|
||||||
|
wrap.addView(sendError, progressLP);
|
||||||
|
|
||||||
|
sendError.setVisibility(View.GONE);
|
||||||
|
sendProgress.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
LinearLayout.LayoutParams langParams=new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||||
|
langParams.setMarginEnd(V.dp(8));
|
||||||
|
wrap.addView(buildLanguageSelector(), langParams);
|
||||||
|
|
||||||
|
wrap.addView(publishButton, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
|
||||||
|
wrap.setPadding(V.dp(16), V.dp(4), V.dp(16), V.dp(8));
|
||||||
|
wrap.setClipToPadding(false);
|
||||||
|
MenuItem item=menu.add(editingStatus==null ? R.string.publish : R.string.save);
|
||||||
item.setActionView(wrap);
|
item.setActionView(wrap);
|
||||||
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
|
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
|
||||||
|
updatePublishButtonState();
|
||||||
draftsBtn = wrap.findViewById(R.id.drafts_btn);
|
|
||||||
draftOptionsPopup = new PopupMenu(getContext(), draftsBtn);
|
|
||||||
draftOptionsPopup.inflate(R.menu.compose_more);
|
|
||||||
draftMenuItem = draftOptionsPopup.getMenu().findItem(R.id.draft);
|
|
||||||
undraftMenuItem = draftOptionsPopup.getMenu().findItem(R.id.undraft);
|
|
||||||
scheduleMenuItem = draftOptionsPopup.getMenu().findItem(R.id.schedule);
|
|
||||||
unscheduleMenuItem = draftOptionsPopup.getMenu().findItem(R.id.unschedule);
|
|
||||||
draftOptionsPopup.setOnMenuItemClickListener(i->{
|
|
||||||
int id = i.getItemId();
|
|
||||||
if (id == R.id.draft) updateScheduledAt(getDraftInstant());
|
|
||||||
else if (id == R.id.schedule) pickScheduledDateTime();
|
|
||||||
else if (id == R.id.unschedule || id == R.id.undraft) updateScheduledAt(null);
|
|
||||||
else navigateToUnsentPosts();
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
UiUtils.enablePopupMenuIcons(getContext(), draftOptionsPopup);
|
|
||||||
|
|
||||||
publishButton = wrap.findViewById(R.id.publish_btn);
|
|
||||||
languageButton = wrap.findViewById(R.id.language_btn);
|
|
||||||
sendProgress = wrap.findViewById(R.id.send_progress);
|
|
||||||
sendError = wrap.findViewById(R.id.send_error);
|
|
||||||
|
|
||||||
publishButton.setOnClickListener(this::onPublishClick);
|
|
||||||
draftsBtn.setOnClickListener(v-> draftOptionsPopup.show());
|
|
||||||
draftsBtn.setOnTouchListener(draftOptionsPopup.getDragToOpenListener());
|
|
||||||
updateScheduledAt(scheduledAt != null ? scheduledAt : scheduledStatus != null ? scheduledStatus.scheduledAt : null);
|
|
||||||
buildLanguageSelector(languageButton);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void navigateToUnsentPosts() {
|
|
||||||
Bundle args=new Bundle();
|
|
||||||
args.putString("account", accountID);
|
|
||||||
args.putBoolean("hide_fab", true);
|
|
||||||
InputMethodManager imm=getActivity().getSystemService(InputMethodManager.class);
|
|
||||||
imm.hideSoftInputFromWindow(draftsBtn.getWindowToken(), 0);
|
|
||||||
if (hasDraft()) {
|
|
||||||
Nav.go(getActivity(), ScheduledStatusListFragment.class, args);
|
|
||||||
} else {
|
|
||||||
// result for the previous ScheduledStatusList
|
|
||||||
setResult(true, null);
|
|
||||||
// finishing fragment in "onFragmentResult"
|
|
||||||
Nav.goForResult(getActivity(), ScheduledStatusListFragment.class, args, SCHEDULED_STATUS_OPENED_RESULT, this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateLanguage(String lang) {
|
private void updateLanguage(String lang) {
|
||||||
updateLanguage(lang == null ? languageResolver.getDefault() : languageResolver.from(lang));
|
updateLanguage(languageResolver.from(lang));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateLanguage(MastodonLanguage loc) {
|
private void updateLanguage(MastodonLanguage loc) {
|
||||||
@@ -807,10 +677,21 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("ClickableViewAccessibility")
|
@SuppressLint("ClickableViewAccessibility")
|
||||||
private void buildLanguageSelector(Button btn) {
|
private Button buildLanguageSelector() {
|
||||||
|
TypedValue typedValue = new TypedValue();
|
||||||
|
getActivity().getTheme().resolveAttribute(android.R.attr.textColorSecondary, typedValue, true);
|
||||||
|
|
||||||
|
languageButton=new Button(getActivity());
|
||||||
|
languageButton.setTextColor(typedValue.data);
|
||||||
|
languageButton.setBackground(getActivity().getDrawable(R.drawable.bg_text_button));
|
||||||
|
languageButton.setPadding(V.dp(8), 0, V.dp(8), 0);
|
||||||
|
languageButton.setCompoundDrawablesRelativeWithIntrinsicBounds(getActivity().getDrawable(R.drawable.ic_fluent_local_language_16_regular), null, null, null);
|
||||||
|
languageButton.setCompoundDrawableTintList(languageButton.getTextColors());
|
||||||
|
languageButton.setCompoundDrawablePadding(V.dp(6));
|
||||||
|
|
||||||
languagePopup=new PopupMenu(getActivity(), languageButton);
|
languagePopup=new PopupMenu(getActivity(), languageButton);
|
||||||
btn.setOnTouchListener(languagePopup.getDragToOpenListener());
|
languageButton.setOnTouchListener(languagePopup.getDragToOpenListener());
|
||||||
btn.setOnClickListener(v->languagePopup.show());
|
languageButton.setOnClickListener(v->languagePopup.show());
|
||||||
|
|
||||||
Preferences prefs = AccountSessionManager.getInstance().getAccount(accountID).preferences;
|
Preferences prefs = AccountSessionManager.getInstance().getAccount(accountID).preferences;
|
||||||
updateLanguage(prefs != null && prefs.postingDefaultLanguage != null && prefs.postingDefaultLanguage.length() > 0
|
updateLanguage(prefs != null && prefs.postingDefaultLanguage != null && prefs.postingDefaultLanguage.length() > 0
|
||||||
@@ -834,6 +715,8 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
|
|||||||
updateLanguage(allLanguages.get(i.getItemId()));
|
updateLanguage(allLanguages.get(i.getItemId()));
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return languageButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -870,15 +753,6 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
|
|||||||
updatePublishButtonState();
|
updatePublishButtonState();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resetPublishButtonText() {
|
|
||||||
int publishText = editingStatus==null || redraftStatus ? R.string.publish : R.string.save;
|
|
||||||
if (publishText == R.string.publish && !GlobalUserPreferences.publishButtonText.isEmpty()) {
|
|
||||||
publishButton.setText(GlobalUserPreferences.publishButtonText);
|
|
||||||
} else {
|
|
||||||
publishButton.setText(publishText);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updatePublishButtonState(){
|
private void updatePublishButtonState(){
|
||||||
uuid=null;
|
uuid=null;
|
||||||
int nonEmptyPollOptionsCount=0;
|
int nonEmptyPollOptionsCount=0;
|
||||||
@@ -894,7 +768,6 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
|
|||||||
nonDoneAttachmentCount++;
|
nonDoneAttachmentCount++;
|
||||||
}
|
}
|
||||||
publishButton.setEnabled((trimmedCharCount>0 || !attachments.isEmpty()) && charCount<=charLimit && nonDoneAttachmentCount==0 && (pollOptions.isEmpty() || nonEmptyPollOptionsCount>1));
|
publishButton.setEnabled((trimmedCharCount>0 || !attachments.isEmpty()) && charCount<=charLimit && nonDoneAttachmentCount==0 && (pollOptions.isEmpty() || nonEmptyPollOptionsCount>1));
|
||||||
sendError.setVisibility(View.GONE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onCustomEmojiClick(Emoji emoji){
|
private void onCustomEmojiClick(Emoji emoji){
|
||||||
@@ -913,68 +786,15 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
|
|||||||
publish();
|
publish();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void publishErrorCallback(ErrorResponse error) {
|
|
||||||
wm.removeView(sendingOverlay);
|
|
||||||
sendingOverlay=null;
|
|
||||||
sendProgress.setVisibility(View.GONE);
|
|
||||||
sendError.setVisibility(View.VISIBLE);
|
|
||||||
publishButton.setEnabled(true);
|
|
||||||
if (error != null) error.showToast(getActivity());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createScheduledStatusFinish(ScheduledStatus result) {
|
|
||||||
wm.removeView(sendingOverlay);
|
|
||||||
sendingOverlay=null;
|
|
||||||
Toast.makeText(getContext(), scheduledAt.isAfter(DRAFTS_AFTER_INSTANT) ?
|
|
||||||
R.string.sk_draft_saved : R.string.sk_post_scheduled, Toast.LENGTH_SHORT).show();
|
|
||||||
Nav.finish(ComposeFragment.this);
|
|
||||||
E.post(new ScheduledStatusCreatedEvent(result, accountID));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void maybeDeleteScheduledPost(Runnable callback) {
|
|
||||||
if (scheduledStatus != null) {
|
|
||||||
new DeleteStatus.Scheduled(scheduledStatus.id).setCallback(new Callback<>() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(Object o) {
|
|
||||||
E.post(new ScheduledStatusDeletedEvent(scheduledStatus.id, accountID));
|
|
||||||
callback.run();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onError(ErrorResponse error) {
|
|
||||||
publishErrorCallback(error);
|
|
||||||
}
|
|
||||||
}).exec(accountID);
|
|
||||||
} else {
|
|
||||||
callback.run();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void publish(){
|
private void publish(){
|
||||||
publish(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void publish(boolean forceWithoutAltTexts){
|
|
||||||
String text=mainEditText.getText().toString();
|
String text=mainEditText.getText().toString();
|
||||||
CreateStatus.Request req=new CreateStatus.Request();
|
CreateStatus.Request req=new CreateStatus.Request();
|
||||||
req.status=text;
|
req.status=text;
|
||||||
req.visibility=statusVisibility;
|
req.visibility=statusVisibility;
|
||||||
req.sensitive=sensitive;
|
req.sensitive=sensitive;
|
||||||
req.language=language;
|
req.language=language;
|
||||||
req.scheduledAt = scheduledAt;
|
|
||||||
if(!attachments.isEmpty()){
|
if(!attachments.isEmpty()){
|
||||||
req.mediaIds=attachments.stream().map(a->a.serverAttachment.id).collect(Collectors.toList());
|
req.mediaIds=attachments.stream().map(a->a.serverAttachment.id).collect(Collectors.toList());
|
||||||
Optional<DraftMediaAttachment> withoutAltText = attachments.stream().filter(a -> a.description == null || a.description.isBlank()).findFirst();
|
|
||||||
boolean isDraft = scheduledAt != null && scheduledAt.isAfter(DRAFTS_AFTER_INSTANT);
|
|
||||||
if (!forceWithoutAltTexts && !GlobalUserPreferences.disableAltTextReminder && !isDraft && withoutAltText.isPresent()) {
|
|
||||||
new M3AlertDialogBuilder(getActivity())
|
|
||||||
.setTitle(R.string.sk_alt_text_missing_title)
|
|
||||||
.setMessage(R.string.sk_alt_text_missing)
|
|
||||||
.setPositiveButton(R.string.add_alt_text, (d, w) -> editMediaDescription(withoutAltText.get()))
|
|
||||||
.setNegativeButton(R.string.sk_publish_anyway, (d, w) -> publish(true))
|
|
||||||
.show();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if(replyTo!=null || (editingStatus != null && editingStatus.inReplyToId!=null)){
|
if(replyTo!=null || (editingStatus != null && editingStatus.inReplyToId!=null)){
|
||||||
req.inReplyToId=editingStatus!=null ? editingStatus.inReplyToId : replyTo.id;
|
req.inReplyToId=editingStatus!=null ? editingStatus.inReplyToId : replyTo.id;
|
||||||
@@ -1009,32 +829,35 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
|
|||||||
Callback<Status> resCallback=new Callback<>(){
|
Callback<Status> resCallback=new Callback<>(){
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Status result){
|
public void onSuccess(Status result){
|
||||||
maybeDeleteScheduledPost(() -> {
|
wm.removeView(sendingOverlay);
|
||||||
wm.removeView(sendingOverlay);
|
sendingOverlay=null;
|
||||||
sendingOverlay=null;
|
if(editingStatus==null){
|
||||||
if(editingStatus==null){
|
E.post(new StatusCreatedEvent(result, accountID));
|
||||||
E.post(new StatusCreatedEvent(result, accountID));
|
if(replyTo!=null){
|
||||||
if(replyTo!=null){
|
replyTo.repliesCount++;
|
||||||
replyTo.repliesCount++;
|
E.post(new StatusCountersUpdatedEvent(replyTo));
|
||||||
E.post(new StatusCountersUpdatedEvent(replyTo));
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
E.post(new StatusUpdatedEvent(result));
|
|
||||||
}
|
}
|
||||||
Nav.finish(ComposeFragment.this);
|
}else{
|
||||||
if (getArguments().getBoolean("navigateToStatus", false)) {
|
E.post(new StatusUpdatedEvent(result));
|
||||||
Bundle args=new Bundle();
|
}
|
||||||
args.putString("account", accountID);
|
Nav.finish(ComposeFragment.this);
|
||||||
args.putParcelable("status", Parcels.wrap(result));
|
if (getArguments().getBoolean("navigateToStatus", false)) {
|
||||||
if(replyTo!=null) args.putParcelable("inReplyToAccount", Parcels.wrap(replyTo));
|
Bundle args=new Bundle();
|
||||||
Nav.go(getActivity(), ThreadFragment.class, args);
|
args.putString("account", accountID);
|
||||||
}
|
args.putParcelable("status", Parcels.wrap(result));
|
||||||
});
|
if(replyTo!=null) args.putParcelable("inReplyToAccount", Parcels.wrap(replyTo));
|
||||||
|
Nav.go(getActivity(), ThreadFragment.class, args);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(ErrorResponse error){
|
public void onError(ErrorResponse error){
|
||||||
publishErrorCallback(error);
|
wm.removeView(sendingOverlay);
|
||||||
|
sendingOverlay=null;
|
||||||
|
sendProgress.setVisibility(View.GONE);
|
||||||
|
sendError.setVisibility(View.VISIBLE);
|
||||||
|
publishButton.setEnabled(true);
|
||||||
|
error.showToast(getActivity());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1042,37 +865,10 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
|
|||||||
new EditStatus(req, editingStatus.id)
|
new EditStatus(req, editingStatus.id)
|
||||||
.setCallback(resCallback)
|
.setCallback(resCallback)
|
||||||
.exec(accountID);
|
.exec(accountID);
|
||||||
}else if(req.scheduledAt == null){
|
}else{
|
||||||
new CreateStatus(req, uuid)
|
new CreateStatus(req, uuid)
|
||||||
.setCallback(resCallback)
|
.setCallback(resCallback)
|
||||||
.exec(accountID);
|
.exec(accountID);
|
||||||
}else if(req.scheduledAt.isAfter(Instant.now().plus(10, ChronoUnit.MINUTES))){
|
|
||||||
// checking for 10 instead of 5 minutes (as per mastodon) because i really don't want
|
|
||||||
// bugs to occur because the client's clock is wrong by a minute or two - the api
|
|
||||||
// returns a status instead of a scheduled status if scheduled time is less than 5
|
|
||||||
// minutes into the future and this is 1. unexpected for the user and 2. hard to handle
|
|
||||||
new CreateStatus.Scheduled(req, uuid)
|
|
||||||
.setCallback(new Callback<>() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(ScheduledStatus result) {
|
|
||||||
maybeDeleteScheduledPost(() -> {
|
|
||||||
createScheduledStatusFinish(result);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onError(ErrorResponse error) {
|
|
||||||
publishErrorCallback(error);
|
|
||||||
}
|
|
||||||
}).exec(accountID);
|
|
||||||
}else{
|
|
||||||
new M3AlertDialogBuilder(getActivity())
|
|
||||||
.setTitle(R.string.sk_scheduled_too_soon_title)
|
|
||||||
.setMessage(R.string.sk_scheduled_too_soon)
|
|
||||||
.setPositiveButton(R.string.ok, (a, b)->{})
|
|
||||||
.show();
|
|
||||||
publishErrorCallback(null);
|
|
||||||
publishButton.setEnabled(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (replyTo == null) {
|
if (replyTo == null) {
|
||||||
@@ -1092,8 +888,6 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
|
|||||||
List<String> existingMediaIDs=editingStatus.mediaAttachments.stream().map(a->a.id).collect(Collectors.toList());
|
List<String> existingMediaIDs=editingStatus.mediaAttachments.stream().map(a->a.id).collect(Collectors.toList());
|
||||||
if(!existingMediaIDs.equals(attachments.stream().map(a->a.serverAttachment.id).collect(Collectors.toList())))
|
if(!existingMediaIDs.equals(attachments.stream().map(a->a.serverAttachment.id).collect(Collectors.toList())))
|
||||||
return true;
|
return true;
|
||||||
if(!statusVisibility.equals(editingStatus.visibility)) return true;
|
|
||||||
if(scheduledStatus != null && !scheduledStatus.scheduledAt.equals(scheduledAt)) return true;
|
|
||||||
return pollChanged;
|
return pollChanged;
|
||||||
}
|
}
|
||||||
boolean pollFieldsHaveContent=false;
|
boolean pollFieldsHaveContent=false;
|
||||||
@@ -1138,66 +932,25 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (reqCode == SCHEDULED_STATUS_OPENED_RESULT && success && getActivity() != null) {
|
|
||||||
Nav.finish(this);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void confirmDiscardDraftAndFinish(){
|
private void confirmDiscardDraftAndFinish(){
|
||||||
new M3AlertDialogBuilder(getActivity())
|
new M3AlertDialogBuilder(getActivity())
|
||||||
.setTitle(editingStatus != null ? R.string.sk_confirm_save_changes : R.string.sk_confirm_save_draft)
|
.setTitle(editingStatus==null ? R.string.discard_draft : R.string.discard_changes)
|
||||||
.setPositiveButton(R.string.save, (d, w) -> {
|
.setPositiveButton(R.string.discard, (dialog, which)->Nav.finish(this))
|
||||||
updateScheduledAt(scheduledAt == null ? getDraftInstant() : scheduledAt);
|
.setNegativeButton(R.string.cancel, null)
|
||||||
publish();
|
|
||||||
})
|
|
||||||
.setNegativeButton(R.string.discard, (d, w) -> Nav.finish(this))
|
|
||||||
.show();
|
.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Check to see if Android platform photopicker is available on the device\
|
|
||||||
* @return whether the device supports photopicker intents.
|
|
||||||
*/
|
|
||||||
private boolean isPhotoPickerAvailable() {
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
|
||||||
return true;
|
|
||||||
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
|
||||||
return getExtensionVersion(Build.VERSION_CODES.R) >= 2;
|
|
||||||
} else
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Builds the correct intent for the device version to select media.
|
|
||||||
*
|
|
||||||
* <p>For Device version > T or R_SDK_v2, use the android platform photopicker via
|
|
||||||
* {@link MediaStore#ACTION_PICK_IMAGES}
|
|
||||||
*
|
|
||||||
* <p>For earlier versions use the built in docs ui via {@link Intent#ACTION_GET_CONTENT}
|
|
||||||
*/
|
|
||||||
private void openFilePicker(){
|
private void openFilePicker(){
|
||||||
Intent intent;
|
Intent intent=new Intent(Intent.ACTION_GET_CONTENT);
|
||||||
boolean usePhotoPicker = isPhotoPickerAvailable();
|
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||||
if (usePhotoPicker) {
|
intent.setType("*/*");
|
||||||
intent = new Intent(MediaStore.ACTION_PICK_IMAGES);
|
if(instance.configuration!=null && instance.configuration.mediaAttachments!=null && instance.configuration.mediaAttachments.supportedMimeTypes!=null && !instance.configuration.mediaAttachments.supportedMimeTypes.isEmpty()){
|
||||||
intent.putExtra(MediaStore.EXTRA_PICK_IMAGES_MAX, MediaStore.getPickImagesMaxLimit());
|
intent.putExtra(Intent.EXTRA_MIME_TYPES, instance.configuration.mediaAttachments.supportedMimeTypes.toArray(new String[0]));
|
||||||
} else {
|
}else{
|
||||||
intent = new Intent(Intent.ACTION_GET_CONTENT);
|
intent.putExtra(Intent.EXTRA_MIME_TYPES, new String[]{"image/*", "video/*"});
|
||||||
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
|
||||||
intent.setType("*/*");
|
|
||||||
}
|
|
||||||
if (!usePhotoPicker && instance.configuration != null &&
|
|
||||||
instance.configuration.mediaAttachments != null &&
|
|
||||||
instance.configuration.mediaAttachments.supportedMimeTypes != null &&
|
|
||||||
!instance.configuration.mediaAttachments.supportedMimeTypes.isEmpty()) {
|
|
||||||
intent.putExtra(Intent.EXTRA_MIME_TYPES,
|
|
||||||
instance.configuration.mediaAttachments.supportedMimeTypes.toArray(
|
|
||||||
new String[0]));
|
|
||||||
} else {
|
|
||||||
if (!usePhotoPicker) {
|
|
||||||
// If photo picker is being used these are the default mimetypes.
|
|
||||||
intent.putExtra(Intent.EXTRA_MIME_TYPES, new String[]{"image/*", "video/*"});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
|
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
|
||||||
startActivityForResult(intent, MEDIA_RESULT);
|
startActivityForResult(intent, MEDIA_RESULT);
|
||||||
@@ -1280,8 +1033,7 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
|
|||||||
View thumb=getActivity().getLayoutInflater().inflate(R.layout.compose_media_thumb, attachmentsView, false);
|
View thumb=getActivity().getLayoutInflater().inflate(R.layout.compose_media_thumb, attachmentsView, false);
|
||||||
ImageView img=thumb.findViewById(R.id.thumb);
|
ImageView img=thumb.findViewById(R.id.thumb);
|
||||||
if(draft.serverAttachment!=null){
|
if(draft.serverAttachment!=null){
|
||||||
if(draft.serverAttachment.previewUrl!=null)
|
ViewImageLoader.load(img, draft.serverAttachment.blurhashPlaceholder, new UrlImageLoaderRequest(draft.serverAttachment.previewUrl, V.dp(250), V.dp(250)));
|
||||||
ViewImageLoader.load(img, draft.serverAttachment.blurhashPlaceholder, new UrlImageLoaderRequest(draft.serverAttachment.previewUrl, V.dp(250), V.dp(250)));
|
|
||||||
}else{
|
}else{
|
||||||
if(draft.mimeType.startsWith("image/")){
|
if(draft.mimeType.startsWith("image/")){
|
||||||
ViewImageLoader.load(img, null, new UrlImageLoaderRequest(draft.uri, V.dp(250), V.dp(250)));
|
ViewImageLoader.load(img, null, new UrlImageLoaderRequest(draft.uri, V.dp(250), V.dp(250)));
|
||||||
@@ -1366,10 +1118,7 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
|
|||||||
@Override
|
@Override
|
||||||
public void onProgress(long transferred, long total){
|
public void onProgress(long transferred, long total){
|
||||||
if(updateUploadEtaRunnable==null){
|
if(updateUploadEtaRunnable==null){
|
||||||
// getting a NoSuchMethodError: No static method -$$Nest$mupdateUploadETAs(ComposeFragment;)V in class ComposeFragment
|
UiUtils.runOnUiThread(updateUploadEtaRunnable=ComposeFragment.this::updateUploadETAs, 100);
|
||||||
// when using method reference out of nowhere after changing code elsewhere. no idea. programming is awful, actually
|
|
||||||
// noinspection Convert2MethodRef
|
|
||||||
UiUtils.runOnUiThread(updateUploadEtaRunnable=()->ComposeFragment.this.updateUploadETAs(), 50);
|
|
||||||
}
|
}
|
||||||
int progress=Math.round(transferred/(float)total*attachment.progressBar.getMax());
|
int progress=Math.round(transferred/(float)total*attachment.progressBar.getMax());
|
||||||
if(Build.VERSION.SDK_INT>=24)
|
if(Build.VERSION.SDK_INT>=24)
|
||||||
@@ -1532,17 +1281,13 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
|
|||||||
att.uploadStateText.setText(getString(R.string.file_upload_time_remaining, time));
|
att.uploadStateText.setText(getString(R.string.file_upload_time_remaining, time));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
UiUtils.runOnUiThread(updateUploadEtaRunnable, 50);
|
UiUtils.runOnUiThread(updateUploadEtaRunnable, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onEditMediaDescriptionClick(View v){
|
private void onEditMediaDescriptionClick(View v){
|
||||||
DraftMediaAttachment att=(DraftMediaAttachment) v.getTag();
|
DraftMediaAttachment att=(DraftMediaAttachment) v.getTag();
|
||||||
if(att.serverAttachment==null)
|
if(att.serverAttachment==null)
|
||||||
return;
|
return;
|
||||||
editMediaDescription(att);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void editMediaDescription(DraftMediaAttachment att) {
|
|
||||||
Bundle args=new Bundle();
|
Bundle args=new Bundle();
|
||||||
args.putString("account", accountID);
|
args.putString("account", accountID);
|
||||||
args.putString("attachment", att.serverAttachment.id);
|
args.putString("attachment", att.serverAttachment.id);
|
||||||
@@ -1668,58 +1413,6 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
|
|||||||
if (attachments.isEmpty()) sensitive = false;
|
if (attachments.isEmpty()) sensitive = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void pickScheduledDateTime() {
|
|
||||||
LocalDateTime soon = LocalDateTime.now()
|
|
||||||
.plus(15, ChronoUnit.MINUTES) // so 14:59 doesn't get rounded up to…
|
|
||||||
.plus(1, ChronoUnit.HOURS) // …15:00, but rather 16:00
|
|
||||||
.withMinute(0);
|
|
||||||
new DatePickerDialog(getActivity(), (datePicker, year, arrayMonth, dayOfMonth) -> {
|
|
||||||
new TimePickerDialog(getActivity(), (timePicker, hour, minute) -> {
|
|
||||||
updateScheduledAt(LocalDateTime.of(year, arrayMonth + 1, dayOfMonth, hour, minute)
|
|
||||||
.toInstant(OffsetDateTime.now().getOffset()));
|
|
||||||
}, soon.getHour(), soon.getMinute(), DateFormat.is24HourFormat(getActivity())).show();
|
|
||||||
}, soon.getYear(), soon.getMonthValue() - 1, soon.getDayOfMonth()).show();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateScheduledAt(Instant scheduledAt) {
|
|
||||||
this.scheduledAt = scheduledAt;
|
|
||||||
updatePublishButtonState();
|
|
||||||
scheduleDraftView.setVisibility(scheduledAt == null ? View.GONE : View.VISIBLE);
|
|
||||||
draftMenuItem.setVisible(true);
|
|
||||||
scheduleMenuItem.setVisible(true);
|
|
||||||
undraftMenuItem.setVisible(false);
|
|
||||||
unscheduleMenuItem.setVisible(false);
|
|
||||||
if (scheduledAt != null) {
|
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM).withLocale(Locale.getDefault());
|
|
||||||
if (scheduledAt.isAfter(DRAFTS_AFTER_INSTANT)) {
|
|
||||||
draftMenuItem.setVisible(false);
|
|
||||||
undraftMenuItem.setVisible(true);
|
|
||||||
scheduleTimeBtn.setVisibility(View.GONE);
|
|
||||||
scheduleDraftText.setText(R.string.sk_compose_draft);
|
|
||||||
scheduleDraftText.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_fluent_drafts_20_regular, 0, 0, 0);
|
|
||||||
scheduleDraftDismiss.setContentDescription(getString(R.string.sk_compose_no_draft));
|
|
||||||
draftsBtn.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_fluent_drafts_20_filled, 0, 0, 0);
|
|
||||||
publishButton.setText(scheduledStatus != null && scheduledStatus.scheduledAt.isAfter(DRAFTS_AFTER_INSTANT)
|
|
||||||
? R.string.save : R.string.sk_draft);
|
|
||||||
} else {
|
|
||||||
scheduleMenuItem.setVisible(false);
|
|
||||||
unscheduleMenuItem.setVisible(true);
|
|
||||||
String at = scheduledAt.atZone(ZoneId.systemDefault()).format(formatter);
|
|
||||||
scheduleTimeBtn.setVisibility(View.VISIBLE);
|
|
||||||
scheduleTimeBtn.setText(at);
|
|
||||||
scheduleDraftText.setText(R.string.sk_compose_scheduled);
|
|
||||||
scheduleDraftText.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
|
|
||||||
scheduleDraftDismiss.setContentDescription(getString(R.string.sk_compose_no_schedule));
|
|
||||||
draftsBtn.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_fluent_clock_20_filled, 0, 0, 0);
|
|
||||||
publishButton.setText(scheduledStatus != null && scheduledStatus.scheduledAt.equals(scheduledAt)
|
|
||||||
? R.string.save : R.string.sk_schedule);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
draftsBtn.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_fluent_clock_20_regular, 0, 0, 0);
|
|
||||||
resetPublishButtonText();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getMediaAttachmentsCount(){
|
private int getMediaAttachmentsCount(){
|
||||||
return attachments.size();
|
return attachments.size();
|
||||||
}
|
}
|
||||||
@@ -1788,7 +1481,7 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
|
|||||||
case PUBLIC -> R.drawable.ic_fluent_earth_24_regular;
|
case PUBLIC -> R.drawable.ic_fluent_earth_24_regular;
|
||||||
case UNLISTED -> R.drawable.ic_fluent_people_community_24_regular;
|
case UNLISTED -> R.drawable.ic_fluent_people_community_24_regular;
|
||||||
case PRIVATE -> R.drawable.ic_fluent_people_checkmark_24_regular;
|
case PRIVATE -> R.drawable.ic_fluent_people_checkmark_24_regular;
|
||||||
case DIRECT -> R.drawable.ic_fluent_mention_24_regular;
|
case DIRECT -> R.drawable.ic_at_symbol;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,351 +0,0 @@
|
|||||||
package org.joinmastodon.android.fragments;
|
|
||||||
|
|
||||||
import static android.view.Menu.NONE;
|
|
||||||
|
|
||||||
import static org.joinmastodon.android.ui.utils.UiUtils.makeBackItem;
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuInflater;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.view.MotionEvent;
|
|
||||||
import android.view.SubMenu;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.EditText;
|
|
||||||
import android.widget.ImageButton;
|
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.PopupMenu;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import androidx.recyclerview.widget.ItemTouchHelper;
|
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
|
||||||
|
|
||||||
import org.joinmastodon.android.GlobalUserPreferences;
|
|
||||||
import org.joinmastodon.android.R;
|
|
||||||
import org.joinmastodon.android.api.requests.lists.GetLists;
|
|
||||||
import org.joinmastodon.android.api.requests.tags.GetFollowedHashtags;
|
|
||||||
import org.joinmastodon.android.model.Hashtag;
|
|
||||||
import org.joinmastodon.android.model.HeaderPaginationList;
|
|
||||||
import org.joinmastodon.android.model.ListTimeline;
|
|
||||||
import org.joinmastodon.android.model.TimelineDefinition;
|
|
||||||
import org.joinmastodon.android.ui.DividerItemDecoration;
|
|
||||||
import org.joinmastodon.android.ui.M3AlertDialogBuilder;
|
|
||||||
import org.joinmastodon.android.ui.utils.UiUtils;
|
|
||||||
import org.joinmastodon.android.ui.views.TextInputFrameLayout;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import me.grishka.appkit.api.Callback;
|
|
||||||
import me.grishka.appkit.api.ErrorResponse;
|
|
||||||
import me.grishka.appkit.fragments.BaseRecyclerFragment;
|
|
||||||
import me.grishka.appkit.utils.BindableViewHolder;
|
|
||||||
import me.grishka.appkit.views.UsableRecyclerView;
|
|
||||||
|
|
||||||
public class EditTimelinesFragment extends BaseRecyclerFragment<TimelineDefinition> implements ScrollableToTop {
|
|
||||||
private String accountID;
|
|
||||||
private TimelinesAdapter adapter;
|
|
||||||
private final ItemTouchHelper itemTouchHelper;
|
|
||||||
private Menu optionsMenu;
|
|
||||||
private boolean updated;
|
|
||||||
private final Map<MenuItem, TimelineDefinition> timelineByMenuItem = new HashMap<>();
|
|
||||||
private final List<ListTimeline> listTimelines = new ArrayList<>();
|
|
||||||
private final List<Hashtag> hashtags = new ArrayList<>();
|
|
||||||
|
|
||||||
public EditTimelinesFragment() {
|
|
||||||
super(10);
|
|
||||||
ItemTouchHelper.SimpleCallback itemTouchCallback = new ItemTouchHelperCallback() ;
|
|
||||||
itemTouchHelper = new ItemTouchHelper(itemTouchCallback);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
setHasOptionsMenu(true);
|
|
||||||
setTitle(R.string.sk_timelines);
|
|
||||||
accountID = getArguments().getString("account");
|
|
||||||
|
|
||||||
new GetLists().setCallback(new Callback<>() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(List<ListTimeline> result) {
|
|
||||||
listTimelines.addAll(result);
|
|
||||||
updateOptionsMenu();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onError(ErrorResponse error) {
|
|
||||||
error.showToast(getContext());
|
|
||||||
}
|
|
||||||
}).exec(accountID);
|
|
||||||
|
|
||||||
new GetFollowedHashtags().setCallback(new Callback<>() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(HeaderPaginationList<Hashtag> result) {
|
|
||||||
hashtags.addAll(result);
|
|
||||||
updateOptionsMenu();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onError(ErrorResponse error) {
|
|
||||||
error.showToast(getContext());
|
|
||||||
}
|
|
||||||
}).exec(accountID);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onShown(){
|
|
||||||
super.onShown();
|
|
||||||
if(!getArguments().getBoolean("noAutoLoad") && !loaded && !dataLoading) loadData();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
|
||||||
super.onViewCreated(view, savedInstanceState);
|
|
||||||
itemTouchHelper.attachToRecyclerView(list);
|
|
||||||
refreshLayout.setEnabled(false);
|
|
||||||
list.addItemDecoration(new DividerItemDecoration(getActivity(), R.attr.colorPollVoted, 0.5f, 56, 16));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
|
||||||
this.optionsMenu = menu;
|
|
||||||
updateOptionsMenu();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
|
||||||
if (item.getItemId() == R.id.menu_back) {
|
|
||||||
updateOptionsMenu();
|
|
||||||
optionsMenu.performIdentifierAction(R.id.menu_add_timeline, 0);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
TimelineDefinition tl = timelineByMenuItem.get(item);
|
|
||||||
if (tl != null) {
|
|
||||||
data.add(tl.copy());
|
|
||||||
adapter.notifyItemInserted(data.size());
|
|
||||||
saveTimelines();
|
|
||||||
updateOptionsMenu();
|
|
||||||
};
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addTimelineToOptions(TimelineDefinition tl, Menu menu) {
|
|
||||||
if (data.contains(tl)) return;
|
|
||||||
MenuItem item = menu.add(0, View.generateViewId(), Menu.NONE, tl.getTitle(getContext()));
|
|
||||||
item.setIcon(tl.getIcon().iconRes);
|
|
||||||
timelineByMenuItem.put(item, tl);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateOptionsMenu() {
|
|
||||||
optionsMenu.clear();
|
|
||||||
timelineByMenuItem.clear();
|
|
||||||
|
|
||||||
SubMenu menu = optionsMenu.addSubMenu(0, R.id.menu_add_timeline, NONE, R.string.sk_timelines_add);
|
|
||||||
menu.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
|
|
||||||
menu.getItem().setIcon(R.drawable.ic_fluent_add_24_regular);
|
|
||||||
|
|
||||||
SubMenu timelinesMenu = menu.addSubMenu(R.string.sk_timeline);
|
|
||||||
timelinesMenu.getItem().setIcon(R.drawable.ic_fluent_timeline_24_regular);
|
|
||||||
SubMenu listsMenu = menu.addSubMenu(R.string.sk_list);
|
|
||||||
listsMenu.getItem().setIcon(R.drawable.ic_fluent_people_list_24_regular);
|
|
||||||
SubMenu hashtagsMenu = menu.addSubMenu(R.string.sk_hashtag);
|
|
||||||
hashtagsMenu.getItem().setIcon(R.drawable.ic_fluent_number_symbol_24_regular);
|
|
||||||
|
|
||||||
makeBackItem(timelinesMenu);
|
|
||||||
makeBackItem(listsMenu);
|
|
||||||
makeBackItem(hashtagsMenu);
|
|
||||||
|
|
||||||
TimelineDefinition.ALL_TIMELINES.forEach(tl -> addTimelineToOptions(tl, timelinesMenu));
|
|
||||||
listTimelines.stream().map(TimelineDefinition::ofList).forEach(tl -> addTimelineToOptions(tl, listsMenu));
|
|
||||||
hashtags.stream().map(TimelineDefinition::ofHashtag).forEach(tl -> addTimelineToOptions(tl, hashtagsMenu));
|
|
||||||
|
|
||||||
timelinesMenu.getItem().setVisible(timelinesMenu.size() > 0);
|
|
||||||
listsMenu.getItem().setVisible(listsMenu.size() > 0);
|
|
||||||
hashtagsMenu.getItem().setVisible(hashtagsMenu.size() > 0);
|
|
||||||
|
|
||||||
UiUtils.enableOptionsMenuIcons(getContext(), optionsMenu, R.id.menu_add_timeline);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void saveTimelines() {
|
|
||||||
updated = true;
|
|
||||||
GlobalUserPreferences.pinnedTimelines.put(accountID, data.size() > 0 ? data : List.of(TimelineDefinition.HOME_TIMELINE));
|
|
||||||
GlobalUserPreferences.save();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void removeTimeline(int position) {
|
|
||||||
data.remove(position);
|
|
||||||
adapter.notifyItemRemoved(position);
|
|
||||||
saveTimelines();
|
|
||||||
updateOptionsMenu();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void doLoadData(int offset, int count){
|
|
||||||
onDataLoaded(GlobalUserPreferences.pinnedTimelines.getOrDefault(accountID, TimelineDefinition.DEFAULT_TIMELINES), false);
|
|
||||||
updateOptionsMenu();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected RecyclerView.Adapter<TimelineViewHolder> getAdapter() {
|
|
||||||
return adapter = new TimelinesAdapter();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void scrollToTop() {
|
|
||||||
smoothScrollRecyclerViewToTop(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDestroy() {
|
|
||||||
super.onDestroy();
|
|
||||||
if (updated) UiUtils.restartApp();
|
|
||||||
}
|
|
||||||
|
|
||||||
private class TimelinesAdapter extends RecyclerView.Adapter<TimelineViewHolder>{
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public TimelineViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType){
|
|
||||||
return new TimelineViewHolder();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBindViewHolder(@NonNull TimelineViewHolder holder, int position) {
|
|
||||||
holder.bind(data.get(position));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getItemCount() {
|
|
||||||
return data.size();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class TimelineViewHolder extends BindableViewHolder<TimelineDefinition> implements UsableRecyclerView.Clickable{
|
|
||||||
private final TextView title;
|
|
||||||
private final ImageView dragger;
|
|
||||||
|
|
||||||
public TimelineViewHolder(){
|
|
||||||
super(getActivity(), R.layout.item_text, list);
|
|
||||||
title=findViewById(R.id.title);
|
|
||||||
dragger=findViewById(R.id.dragger_thingy);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint("ClickableViewAccessibility")
|
|
||||||
@Override
|
|
||||||
public void onBind(TimelineDefinition item) {
|
|
||||||
title.setText(item.getTitle(getContext()));
|
|
||||||
title.setCompoundDrawablesRelativeWithIntrinsicBounds(itemView.getContext().getDrawable(item.getIcon().iconRes), null, null, null);
|
|
||||||
dragger.setVisibility(View.VISIBLE);
|
|
||||||
dragger.setOnTouchListener((View v, MotionEvent event) -> {
|
|
||||||
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
|
||||||
itemTouchHelper.startDrag(this);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint("ClickableViewAccessibility")
|
|
||||||
@Override
|
|
||||||
public void onClick() {
|
|
||||||
Context ctx = getContext();
|
|
||||||
LinearLayout view = (LinearLayout) getActivity().getLayoutInflater()
|
|
||||||
.inflate(R.layout.edit_timeline, (ViewGroup) itemView, false);
|
|
||||||
|
|
||||||
TextInputFrameLayout inputLayout = view.findViewById(R.id.input);
|
|
||||||
EditText editText = inputLayout.getEditText();
|
|
||||||
editText.setText(item.getCustomTitle());
|
|
||||||
editText.setHint(item.getDefaultTitle(ctx));
|
|
||||||
|
|
||||||
ImageButton btn = view.findViewById(R.id.button);
|
|
||||||
PopupMenu popup = new PopupMenu(ctx, btn);
|
|
||||||
TimelineDefinition.Icon currentIcon = item.getIcon();
|
|
||||||
btn.setImageResource(currentIcon.iconRes);
|
|
||||||
btn.setContentDescription(ctx.getString(currentIcon.nameRes));
|
|
||||||
btn.setOnTouchListener(popup.getDragToOpenListener());
|
|
||||||
btn.setOnClickListener(l -> popup.show());
|
|
||||||
|
|
||||||
Menu menu = popup.getMenu();
|
|
||||||
TimelineDefinition.Icon defaultIcon = item.getDefaultIcon();
|
|
||||||
menu.add(0, currentIcon.ordinal(), NONE, currentIcon.nameRes).setIcon(currentIcon.iconRes);
|
|
||||||
if (!currentIcon.equals(defaultIcon)) {
|
|
||||||
menu.add(0, defaultIcon.ordinal(), NONE, defaultIcon.nameRes).setIcon(defaultIcon.iconRes);
|
|
||||||
}
|
|
||||||
for (TimelineDefinition.Icon icon : TimelineDefinition.Icon.values()) {
|
|
||||||
if (icon.hidden || icon.equals(item.getIcon())) continue;
|
|
||||||
menu.add(0, icon.ordinal(), NONE, icon.nameRes).setIcon(icon.iconRes);
|
|
||||||
}
|
|
||||||
UiUtils.enablePopupMenuIcons(ctx, popup);
|
|
||||||
|
|
||||||
popup.setOnMenuItemClickListener(menuItem -> {
|
|
||||||
TimelineDefinition.Icon icon = TimelineDefinition.Icon.values()[menuItem.getItemId()];
|
|
||||||
btn.setImageResource(icon.iconRes);
|
|
||||||
btn.setContentDescription(ctx.getString(icon.nameRes));
|
|
||||||
item.setIcon(icon);
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
|
|
||||||
new M3AlertDialogBuilder(ctx)
|
|
||||||
.setTitle(R.string.sk_edit_timeline)
|
|
||||||
.setView(view)
|
|
||||||
.setPositiveButton(R.string.save, (d, which) -> {
|
|
||||||
item.setTitle(editText.getText().toString().trim());
|
|
||||||
rebind();
|
|
||||||
saveTimelines();
|
|
||||||
})
|
|
||||||
.setNeutralButton(R.string.sk_remove, (d, which) ->
|
|
||||||
removeTimeline(getAbsoluteAdapterPosition()))
|
|
||||||
.setNegativeButton(R.string.cancel, (d, which) -> {})
|
|
||||||
.show();
|
|
||||||
|
|
||||||
editText.requestFocus();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class ItemTouchHelperCallback extends ItemTouchHelper.SimpleCallback {
|
|
||||||
public ItemTouchHelperCallback() {
|
|
||||||
super(ItemTouchHelper.UP | ItemTouchHelper.DOWN, ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onMove(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder, @NonNull RecyclerView.ViewHolder target) {
|
|
||||||
int fromPosition = viewHolder.getAbsoluteAdapterPosition();
|
|
||||||
int toPosition = target.getAbsoluteAdapterPosition();
|
|
||||||
if (Math.max(fromPosition, toPosition) >= data.size() || Math.min(fromPosition, toPosition) < 0) {
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
Collections.swap(data, fromPosition, toPosition);
|
|
||||||
adapter.notifyItemMoved(fromPosition, toPosition);
|
|
||||||
saveTimelines();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSelectedChanged(@Nullable RecyclerView.ViewHolder viewHolder, int actionState) {
|
|
||||||
if (actionState == ItemTouchHelper.ACTION_STATE_DRAG && viewHolder != null) {
|
|
||||||
viewHolder.itemView.animate().alpha(0.65f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clearView(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) {
|
|
||||||
super.clearView(recyclerView, viewHolder);
|
|
||||||
viewHolder.itemView.animate().alpha(1f);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) {
|
|
||||||
int position = viewHolder.getAbsoluteAdapterPosition();
|
|
||||||
removeTimeline(position);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
package org.joinmastodon.android.fragments;
|
|
||||||
|
|
||||||
import android.content.res.Configuration;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.ImageButton;
|
|
||||||
|
|
||||||
import org.joinmastodon.android.R;
|
|
||||||
import org.joinmastodon.android.ui.utils.UiUtils;
|
|
||||||
|
|
||||||
import me.grishka.appkit.Nav;
|
|
||||||
|
|
||||||
public abstract class FabStatusListFragment extends StatusListFragment {
|
|
||||||
protected ImageButton fab;
|
|
||||||
|
|
||||||
public FabStatusListFragment() {
|
|
||||||
setListLayoutId(R.layout.recycler_fragment_with_fab);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
|
||||||
super.onViewCreated(view, savedInstanceState);
|
|
||||||
fab = view.findViewById(R.id.fab);
|
|
||||||
fab.setOnClickListener(this::onFabClick);
|
|
||||||
fab.setOnLongClickListener(this::onFabLongClick);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void onFabClick(View v){
|
|
||||||
Bundle args=new Bundle();
|
|
||||||
args.putString("account", accountID);
|
|
||||||
Nav.go(getActivity(), ComposeFragment.class, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected boolean onFabLongClick(View v) {
|
|
||||||
return UiUtils.pickAccountForCompose(getActivity(), accountID);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
package org.joinmastodon.android.fragments;
|
package org.joinmastodon.android.fragments;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
@@ -12,7 +11,6 @@ import org.joinmastodon.android.R;
|
|||||||
import org.joinmastodon.android.api.requests.tags.GetFollowedHashtags;
|
import org.joinmastodon.android.api.requests.tags.GetFollowedHashtags;
|
||||||
import org.joinmastodon.android.model.Hashtag;
|
import org.joinmastodon.android.model.Hashtag;
|
||||||
import org.joinmastodon.android.model.HeaderPaginationList;
|
import org.joinmastodon.android.model.HeaderPaginationList;
|
||||||
import org.joinmastodon.android.ui.DividerItemDecoration;
|
|
||||||
import org.joinmastodon.android.ui.utils.UiUtils;
|
import org.joinmastodon.android.ui.utils.UiUtils;
|
||||||
|
|
||||||
import me.grishka.appkit.api.SimpleCallback;
|
import me.grishka.appkit.api.SimpleCallback;
|
||||||
@@ -43,12 +41,6 @@ public class FollowedHashtagsFragment extends BaseRecyclerFragment<Hashtag> impl
|
|||||||
loadData();
|
loadData();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
|
||||||
super.onViewCreated(view, savedInstanceState);
|
|
||||||
list.addItemDecoration(new DividerItemDecoration(getActivity(), R.attr.colorPollVoted, 0.5f, 56, 16));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doLoadData(int offset, int count){
|
protected void doLoadData(int offset, int count){
|
||||||
currentRequest=new GetFollowedHashtags(offset==0 ? null : nextMaxID, null, count, null)
|
currentRequest=new GetFollowedHashtags(offset==0 ? null : nextMaxID, null, count, null)
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package org.joinmastodon.android.fragments;
|
|||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.HapticFeedbackConstants;
|
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuInflater;
|
import android.view.MenuInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
@@ -17,8 +16,6 @@ import org.joinmastodon.android.api.requests.tags.SetHashtagFollowed;
|
|||||||
import org.joinmastodon.android.api.requests.timelines.GetHashtagTimeline;
|
import org.joinmastodon.android.api.requests.timelines.GetHashtagTimeline;
|
||||||
import org.joinmastodon.android.model.Hashtag;
|
import org.joinmastodon.android.model.Hashtag;
|
||||||
import org.joinmastodon.android.model.Status;
|
import org.joinmastodon.android.model.Status;
|
||||||
import org.joinmastodon.android.model.TimelineDefinition;
|
|
||||||
import org.joinmastodon.android.ui.utils.UiUtils;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -28,7 +25,7 @@ import me.grishka.appkit.api.ErrorResponse;
|
|||||||
import me.grishka.appkit.api.SimpleCallback;
|
import me.grishka.appkit.api.SimpleCallback;
|
||||||
import me.grishka.appkit.utils.V;
|
import me.grishka.appkit.utils.V;
|
||||||
|
|
||||||
public class HashtagTimelineFragment extends PinnableStatusListFragment {
|
public class HashtagTimelineFragment extends StatusListFragment{
|
||||||
private String hashtag;
|
private String hashtag;
|
||||||
private boolean following;
|
private boolean following;
|
||||||
private ImageButton fab;
|
private ImageButton fab;
|
||||||
@@ -43,6 +40,7 @@ public class HashtagTimelineFragment extends PinnableStatusListFragment {
|
|||||||
super.onAttach(activity);
|
super.onAttach(activity);
|
||||||
updateTitle(getArguments().getString("hashtag"));
|
updateTitle(getArguments().getString("hashtag"));
|
||||||
following=getArguments().getBoolean("following", false);
|
following=getArguments().getBoolean("following", false);
|
||||||
|
|
||||||
setHasOptionsMenu(true);
|
setHasOptionsMenu(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,31 +58,11 @@ public class HashtagTimelineFragment extends PinnableStatusListFragment {
|
|||||||
@Override
|
@Override
|
||||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||||
inflater.inflate(R.menu.hashtag_timeline, menu);
|
inflater.inflate(R.menu.hashtag_timeline, menu);
|
||||||
super.onCreateOptionsMenu(menu, inflater);
|
|
||||||
followButton = menu.findItem(R.id.follow_hashtag);
|
followButton = menu.findItem(R.id.follow_hashtag);
|
||||||
updateFollowingState(following);
|
updateFollowingState(following);
|
||||||
|
|
||||||
new GetHashtag(hashtag).setCallback(new Callback<>() {
|
followButton.setOnMenuItemClickListener(i -> {
|
||||||
@Override
|
|
||||||
public void onSuccess(Hashtag hashtag) {
|
|
||||||
updateTitle(hashtag.name);
|
|
||||||
updateFollowingState(hashtag.following);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onError(ErrorResponse error) {
|
|
||||||
error.showToast(getActivity());
|
|
||||||
}
|
|
||||||
}).exec(accountID);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
|
||||||
if (super.onOptionsItemSelected(item)) return true;
|
|
||||||
if (item.getItemId() == R.id.follow_hashtag) {
|
|
||||||
updateFollowingState(!following);
|
updateFollowingState(!following);
|
||||||
getToolbar().performHapticFeedback(HapticFeedbackConstants.CONTEXT_CLICK);
|
|
||||||
new SetHashtagFollowed(hashtag, following).setCallback(new Callback<>() {
|
new SetHashtagFollowed(hashtag, following).setCallback(new Callback<>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Hashtag i) {
|
public void onSuccess(Hashtag i) {
|
||||||
@@ -99,13 +77,20 @@ public class HashtagTimelineFragment extends PinnableStatusListFragment {
|
|||||||
}
|
}
|
||||||
}).exec(accountID);
|
}).exec(accountID);
|
||||||
return true;
|
return true;
|
||||||
}
|
});
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
new GetHashtag(hashtag).setCallback(new Callback<>() {
|
||||||
protected TimelineDefinition makeTimelineDefinition() {
|
@Override
|
||||||
return TimelineDefinition.ofHashtag(hashtag);
|
public void onSuccess(Hashtag hashtag) {
|
||||||
|
updateTitle(hashtag.name);
|
||||||
|
updateFollowingState(hashtag.following);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(ErrorResponse error) {
|
||||||
|
error.showToast(getActivity());
|
||||||
|
}
|
||||||
|
}).exec(accountID);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -132,7 +117,6 @@ public class HashtagTimelineFragment extends PinnableStatusListFragment {
|
|||||||
super.onViewCreated(view, savedInstanceState);
|
super.onViewCreated(view, savedInstanceState);
|
||||||
fab=view.findViewById(R.id.fab);
|
fab=view.findViewById(R.id.fab);
|
||||||
fab.setOnClickListener(this::onFabClick);
|
fab.setOnClickListener(this::onFabClick);
|
||||||
fab.setOnLongClickListener(v -> UiUtils.pickAccountForCompose(getActivity(), accountID, '#'+hashtag+' '));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onFabClick(View v){
|
private void onFabClick(View v){
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import android.app.NotificationManager;
|
|||||||
import android.graphics.Outline;
|
import android.graphics.Outline;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.service.notification.StatusBarNotification;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@@ -21,7 +20,6 @@ import org.joinmastodon.android.R;
|
|||||||
import org.joinmastodon.android.api.session.AccountSession;
|
import org.joinmastodon.android.api.session.AccountSession;
|
||||||
import org.joinmastodon.android.api.session.AccountSessionManager;
|
import org.joinmastodon.android.api.session.AccountSessionManager;
|
||||||
import org.joinmastodon.android.fragments.discover.DiscoverFragment;
|
import org.joinmastodon.android.fragments.discover.DiscoverFragment;
|
||||||
import org.joinmastodon.android.fragments.discover.SearchFragment;
|
|
||||||
import org.joinmastodon.android.model.Account;
|
import org.joinmastodon.android.model.Account;
|
||||||
import org.joinmastodon.android.ui.AccountSwitcherSheet;
|
import org.joinmastodon.android.ui.AccountSwitcherSheet;
|
||||||
import org.joinmastodon.android.ui.utils.UiUtils;
|
import org.joinmastodon.android.ui.utils.UiUtils;
|
||||||
@@ -43,7 +41,7 @@ import me.grishka.appkit.views.FragmentRootLinearLayout;
|
|||||||
|
|
||||||
public class HomeFragment extends AppKitFragment implements OnBackPressedListener{
|
public class HomeFragment extends AppKitFragment implements OnBackPressedListener{
|
||||||
private FragmentRootLinearLayout content;
|
private FragmentRootLinearLayout content;
|
||||||
private HomeTabFragment homeTabFragment;
|
private HomeTimelineFragment homeTimelineFragment;
|
||||||
private NotificationsFragment notificationsFragment;
|
private NotificationsFragment notificationsFragment;
|
||||||
private DiscoverFragment searchFragment;
|
private DiscoverFragment searchFragment;
|
||||||
private ProfileFragment profileFragment;
|
private ProfileFragment profileFragment;
|
||||||
@@ -67,8 +65,8 @@ public class HomeFragment extends AppKitFragment implements OnBackPressedListene
|
|||||||
if(savedInstanceState==null){
|
if(savedInstanceState==null){
|
||||||
Bundle args=new Bundle();
|
Bundle args=new Bundle();
|
||||||
args.putString("account", accountID);
|
args.putString("account", accountID);
|
||||||
homeTabFragment=new HomeTabFragment();
|
homeTimelineFragment=new HomeTimelineFragment();
|
||||||
homeTabFragment.setArguments(args);
|
homeTimelineFragment.setArguments(args);
|
||||||
args=new Bundle(args);
|
args=new Bundle(args);
|
||||||
args.putBoolean("noAutoLoad", true);
|
args.putBoolean("noAutoLoad", true);
|
||||||
searchFragment=new DiscoverFragment();
|
searchFragment=new DiscoverFragment();
|
||||||
@@ -112,7 +110,7 @@ public class HomeFragment extends AppKitFragment implements OnBackPressedListene
|
|||||||
|
|
||||||
if(savedInstanceState==null){
|
if(savedInstanceState==null){
|
||||||
getChildFragmentManager().beginTransaction()
|
getChildFragmentManager().beginTransaction()
|
||||||
.add(R.id.fragment_wrap, homeTabFragment)
|
.add(R.id.fragment_wrap, homeTimelineFragment)
|
||||||
.add(R.id.fragment_wrap, searchFragment).hide(searchFragment)
|
.add(R.id.fragment_wrap, searchFragment).hide(searchFragment)
|
||||||
.add(R.id.fragment_wrap, notificationsFragment).hide(notificationsFragment)
|
.add(R.id.fragment_wrap, notificationsFragment).hide(notificationsFragment)
|
||||||
.add(R.id.fragment_wrap, profileFragment).hide(profileFragment)
|
.add(R.id.fragment_wrap, profileFragment).hide(profileFragment)
|
||||||
@@ -138,15 +136,16 @@ public class HomeFragment extends AppKitFragment implements OnBackPressedListene
|
|||||||
@Override
|
@Override
|
||||||
public void onViewStateRestored(Bundle savedInstanceState){
|
public void onViewStateRestored(Bundle savedInstanceState){
|
||||||
super.onViewStateRestored(savedInstanceState);
|
super.onViewStateRestored(savedInstanceState);
|
||||||
if(savedInstanceState==null) return;
|
if(savedInstanceState==null || homeTimelineFragment!=null)
|
||||||
homeTabFragment=(HomeTabFragment) getChildFragmentManager().getFragment(savedInstanceState, "homeTabFragment");
|
return;
|
||||||
|
homeTimelineFragment=(HomeTimelineFragment) getChildFragmentManager().getFragment(savedInstanceState, "homeTimelineFragment");
|
||||||
searchFragment=(DiscoverFragment) getChildFragmentManager().getFragment(savedInstanceState, "searchFragment");
|
searchFragment=(DiscoverFragment) getChildFragmentManager().getFragment(savedInstanceState, "searchFragment");
|
||||||
notificationsFragment=(NotificationsFragment) getChildFragmentManager().getFragment(savedInstanceState, "notificationsFragment");
|
notificationsFragment=(NotificationsFragment) getChildFragmentManager().getFragment(savedInstanceState, "notificationsFragment");
|
||||||
profileFragment=(ProfileFragment) getChildFragmentManager().getFragment(savedInstanceState, "profileFragment");
|
profileFragment=(ProfileFragment) getChildFragmentManager().getFragment(savedInstanceState, "profileFragment");
|
||||||
currentTab=savedInstanceState.getInt("selectedTab");
|
currentTab=savedInstanceState.getInt("selectedTab");
|
||||||
Fragment current=fragmentForTab(currentTab);
|
Fragment current=fragmentForTab(currentTab);
|
||||||
getChildFragmentManager().beginTransaction()
|
getChildFragmentManager().beginTransaction()
|
||||||
.hide(homeTabFragment)
|
.hide(homeTimelineFragment)
|
||||||
.hide(searchFragment)
|
.hide(searchFragment)
|
||||||
.hide(notificationsFragment)
|
.hide(notificationsFragment)
|
||||||
.hide(profileFragment)
|
.hide(profileFragment)
|
||||||
@@ -181,7 +180,7 @@ public class HomeFragment extends AppKitFragment implements OnBackPressedListene
|
|||||||
super.onApplyWindowInsets(insets.replaceSystemWindowInsets(insets.getSystemWindowInsetLeft(), 0, insets.getSystemWindowInsetRight(), insets.getSystemWindowInsetBottom()));
|
super.onApplyWindowInsets(insets.replaceSystemWindowInsets(insets.getSystemWindowInsetLeft(), 0, insets.getSystemWindowInsetRight(), insets.getSystemWindowInsetBottom()));
|
||||||
}
|
}
|
||||||
WindowInsets topOnlyInsets=insets.replaceSystemWindowInsets(0, insets.getSystemWindowInsetTop(), 0, 0);
|
WindowInsets topOnlyInsets=insets.replaceSystemWindowInsets(0, insets.getSystemWindowInsetTop(), 0, 0);
|
||||||
homeTabFragment.onApplyWindowInsets(topOnlyInsets);
|
homeTimelineFragment.onApplyWindowInsets(topOnlyInsets);
|
||||||
searchFragment.onApplyWindowInsets(topOnlyInsets);
|
searchFragment.onApplyWindowInsets(topOnlyInsets);
|
||||||
notificationsFragment.onApplyWindowInsets(topOnlyInsets);
|
notificationsFragment.onApplyWindowInsets(topOnlyInsets);
|
||||||
profileFragment.onApplyWindowInsets(topOnlyInsets);
|
profileFragment.onApplyWindowInsets(topOnlyInsets);
|
||||||
@@ -189,7 +188,7 @@ public class HomeFragment extends AppKitFragment implements OnBackPressedListene
|
|||||||
|
|
||||||
private Fragment fragmentForTab(@IdRes int tab){
|
private Fragment fragmentForTab(@IdRes int tab){
|
||||||
if(tab==R.id.tab_home){
|
if(tab==R.id.tab_home){
|
||||||
return homeTabFragment;
|
return homeTimelineFragment;
|
||||||
}else if(tab==R.id.tab_search){
|
}else if(tab==R.id.tab_search){
|
||||||
return searchFragment;
|
return searchFragment;
|
||||||
}else if(tab==R.id.tab_notifications){
|
}else if(tab==R.id.tab_notifications){
|
||||||
@@ -203,9 +202,7 @@ public class HomeFragment extends AppKitFragment implements OnBackPressedListene
|
|||||||
private void onTabSelected(@IdRes int tab){
|
private void onTabSelected(@IdRes int tab){
|
||||||
Fragment newFragment=fragmentForTab(tab);
|
Fragment newFragment=fragmentForTab(tab);
|
||||||
if(tab==currentTab){
|
if(tab==currentTab){
|
||||||
if (tab == R.id.tab_search)
|
if(newFragment instanceof ScrollableToTop scrollable)
|
||||||
searchFragment.onSelect();
|
|
||||||
else if(newFragment instanceof ScrollableToTop scrollable)
|
|
||||||
scrollable.scrollToTop();
|
scrollable.scrollToTop();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -225,11 +222,7 @@ public class HomeFragment extends AppKitFragment implements OnBackPressedListene
|
|||||||
((NotificationsFragment) newFragment).loadData();
|
((NotificationsFragment) newFragment).loadData();
|
||||||
// TODO make an interface?
|
// TODO make an interface?
|
||||||
NotificationManager nm=getActivity().getSystemService(NotificationManager.class);
|
NotificationManager nm=getActivity().getSystemService(NotificationManager.class);
|
||||||
for (StatusBarNotification notification : nm.getActiveNotifications()) {
|
nm.cancel(accountID, PushNotificationReceiver.NOTIFICATION_ID);
|
||||||
if (accountID.equals(notification.getTag())) {
|
|
||||||
nm.cancel(accountID, notification.getId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -255,18 +248,17 @@ public class HomeFragment extends AppKitFragment implements OnBackPressedListene
|
|||||||
tabBar.selectTab(R.id.tab_home);
|
tabBar.selectTab(R.id.tab_home);
|
||||||
onTabSelected(R.id.tab_home);
|
onTabSelected(R.id.tab_home);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
|
||||||
return homeTabFragment.onBackPressed();
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSaveInstanceState(Bundle outState){
|
public void onSaveInstanceState(Bundle outState){
|
||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
outState.putInt("selectedTab", currentTab);
|
outState.putInt("selectedTab", currentTab);
|
||||||
if (homeTabFragment.isAdded()) getChildFragmentManager().putFragment(outState, "homeTabFragment", homeTabFragment);
|
getChildFragmentManager().putFragment(outState, "homeTimelineFragment", homeTimelineFragment);
|
||||||
if (searchFragment.isAdded()) getChildFragmentManager().putFragment(outState, "searchFragment", searchFragment);
|
getChildFragmentManager().putFragment(outState, "searchFragment", searchFragment);
|
||||||
if (notificationsFragment.isAdded()) getChildFragmentManager().putFragment(outState, "notificationsFragment", notificationsFragment);
|
getChildFragmentManager().putFragment(outState, "notificationsFragment", notificationsFragment);
|
||||||
if (profileFragment.isAdded()) getChildFragmentManager().putFragment(outState, "profileFragment", profileFragment);
|
getChildFragmentManager().putFragment(outState, "profileFragment", profileFragment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,587 +0,0 @@
|
|||||||
package org.joinmastodon.android.fragments;
|
|
||||||
|
|
||||||
import android.animation.Animator;
|
|
||||||
import android.animation.AnimatorListenerAdapter;
|
|
||||||
import android.animation.AnimatorSet;
|
|
||||||
import android.animation.ObjectAnimator;
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.app.Fragment;
|
|
||||||
import android.app.FragmentTransaction;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuInflater;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.view.SubMenu;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.view.ViewParent;
|
|
||||||
import android.view.ViewTreeObserver;
|
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.FrameLayout;
|
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.PopupMenu;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import android.widget.Toolbar;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
|
||||||
import androidx.viewpager2.widget.ViewPager2;
|
|
||||||
|
|
||||||
import com.squareup.otto.Subscribe;
|
|
||||||
|
|
||||||
import org.joinmastodon.android.E;
|
|
||||||
import org.joinmastodon.android.GlobalUserPreferences;
|
|
||||||
import org.joinmastodon.android.R;
|
|
||||||
import org.joinmastodon.android.api.requests.announcements.GetAnnouncements;
|
|
||||||
import org.joinmastodon.android.api.requests.lists.GetLists;
|
|
||||||
import org.joinmastodon.android.api.requests.tags.GetFollowedHashtags;
|
|
||||||
import org.joinmastodon.android.events.SelfUpdateStateChangedEvent;
|
|
||||||
import org.joinmastodon.android.model.Announcement;
|
|
||||||
import org.joinmastodon.android.model.Hashtag;
|
|
||||||
import org.joinmastodon.android.model.HeaderPaginationList;
|
|
||||||
import org.joinmastodon.android.model.ListTimeline;
|
|
||||||
import org.joinmastodon.android.model.TimelineDefinition;
|
|
||||||
import org.joinmastodon.android.ui.SimpleViewHolder;
|
|
||||||
import org.joinmastodon.android.ui.utils.UiUtils;
|
|
||||||
import org.joinmastodon.android.updater.GithubSelfUpdater;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import me.grishka.appkit.Nav;
|
|
||||||
import me.grishka.appkit.api.Callback;
|
|
||||||
import me.grishka.appkit.api.ErrorResponse;
|
|
||||||
import me.grishka.appkit.fragments.BaseRecyclerFragment;
|
|
||||||
import me.grishka.appkit.fragments.OnBackPressedListener;
|
|
||||||
import me.grishka.appkit.utils.CubicBezierInterpolator;
|
|
||||||
import me.grishka.appkit.utils.V;
|
|
||||||
|
|
||||||
public class HomeTabFragment extends MastodonToolbarFragment implements ScrollableToTop, OnBackPressedListener {
|
|
||||||
private static final int ANNOUNCEMENTS_RESULT = 654;
|
|
||||||
private static final int PINNED_UPDATED_RESULT = 523;
|
|
||||||
|
|
||||||
private String accountID;
|
|
||||||
private MenuItem announcements;
|
|
||||||
// private ImageView toolbarLogo;
|
|
||||||
private Button toolbarShowNewPostsBtn;
|
|
||||||
private boolean newPostsBtnShown;
|
|
||||||
private AnimatorSet currentNewPostsAnim;
|
|
||||||
private ViewPager2 pager;
|
|
||||||
private View switcher;
|
|
||||||
private FrameLayout toolbarFrame;
|
|
||||||
private ImageView timelineIcon;
|
|
||||||
private ImageView collapsedChevron;
|
|
||||||
private TextView timelineTitle;
|
|
||||||
private PopupMenu switcherPopup;
|
|
||||||
private final Map<Integer, ListTimeline> listItems = new HashMap<>();
|
|
||||||
private final Map<Integer, Hashtag> hashtagsItems = new HashMap<>();
|
|
||||||
private List<TimelineDefinition> timelineDefinitions;
|
|
||||||
private int count;
|
|
||||||
private Fragment[] fragments;
|
|
||||||
private FrameLayout[] tabViews;
|
|
||||||
private TimelineDefinition[] timelines;
|
|
||||||
private Map<Integer, TimelineDefinition> timelinesByMenuItem = new HashMap<>();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
accountID = getArguments().getString("account");
|
|
||||||
timelineDefinitions = GlobalUserPreferences.pinnedTimelines.getOrDefault(accountID, TimelineDefinition.DEFAULT_TIMELINES);
|
|
||||||
assert timelineDefinitions != null;
|
|
||||||
if (timelineDefinitions.size() == 0) timelineDefinitions = List.of(TimelineDefinition.HOME_TIMELINE);
|
|
||||||
count = timelineDefinitions.size();
|
|
||||||
fragments = new Fragment[count];
|
|
||||||
tabViews = new FrameLayout[count];
|
|
||||||
timelines = new TimelineDefinition[count];
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAttach(Activity activity) {
|
|
||||||
super.onAttach(activity);
|
|
||||||
setHasOptionsMenu(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View onCreateContentView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
|
|
||||||
FrameLayout view = new FrameLayout(getContext());
|
|
||||||
pager = new ViewPager2(getContext());
|
|
||||||
toolbarFrame = (FrameLayout) LayoutInflater.from(getContext()).inflate(R.layout.home_toolbar, getToolbar(), false);
|
|
||||||
|
|
||||||
if (fragments[0] == null) {
|
|
||||||
Bundle args = new Bundle();
|
|
||||||
args.putString("account", accountID);
|
|
||||||
args.putBoolean("__is_tab", true);
|
|
||||||
args.putBoolean("onlyPosts", true);
|
|
||||||
|
|
||||||
for (int i = 0; i < timelineDefinitions.size(); i++) {
|
|
||||||
TimelineDefinition tl = timelineDefinitions.get(i);
|
|
||||||
fragments[i] = tl.getFragment();
|
|
||||||
timelines[i] = tl;
|
|
||||||
}
|
|
||||||
|
|
||||||
FragmentTransaction transaction = getChildFragmentManager().beginTransaction();
|
|
||||||
for (int i = 0; i < count; i++) {
|
|
||||||
fragments[i].setArguments(timelines[i].populateArguments(new Bundle(args)));
|
|
||||||
FrameLayout tabView = new FrameLayout(getActivity());
|
|
||||||
tabView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
|
||||||
tabView.setVisibility(View.GONE);
|
|
||||||
tabView.setId(i + 1);
|
|
||||||
transaction.add(i + 1, fragments[i]);
|
|
||||||
view.addView(tabView);
|
|
||||||
tabViews[i] = tabView;
|
|
||||||
}
|
|
||||||
transaction.commit();
|
|
||||||
}
|
|
||||||
|
|
||||||
view.addView(pager, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
|
||||||
|
|
||||||
return view;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint("ClickableViewAccessibility")
|
|
||||||
@Override
|
|
||||||
public void onViewCreated(View view, Bundle savedInstanceState){
|
|
||||||
super.onViewCreated(view, savedInstanceState);
|
|
||||||
|
|
||||||
timelineIcon = toolbarFrame.findViewById(R.id.timeline_icon);
|
|
||||||
timelineTitle = toolbarFrame.findViewById(R.id.timeline_title);
|
|
||||||
collapsedChevron = toolbarFrame.findViewById(R.id.collapsed_chevron);
|
|
||||||
switcher = toolbarFrame.findViewById(R.id.switcher_btn);
|
|
||||||
switcherPopup = new PopupMenu(getContext(), switcher);
|
|
||||||
switcherPopup.setOnMenuItemClickListener(this::onSwitcherItemSelected);
|
|
||||||
UiUtils.enablePopupMenuIcons(getContext(), switcherPopup);
|
|
||||||
switcher.setOnClickListener(v->{
|
|
||||||
updateSwitcherMenu();
|
|
||||||
switcherPopup.show();
|
|
||||||
});
|
|
||||||
View.OnTouchListener listener = switcherPopup.getDragToOpenListener();
|
|
||||||
switcher.setOnTouchListener((v, m)-> {
|
|
||||||
updateSwitcherMenu();
|
|
||||||
return listener.onTouch(v, m);
|
|
||||||
});
|
|
||||||
|
|
||||||
UiUtils.reduceSwipeSensitivity(pager);
|
|
||||||
pager.setUserInputEnabled(!GlobalUserPreferences.disableSwipe);
|
|
||||||
pager.setAdapter(new HomePagerAdapter());
|
|
||||||
pager.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback(){
|
|
||||||
@Override
|
|
||||||
public void onPageSelected(int position){
|
|
||||||
updateSwitcherIcon(position);
|
|
||||||
if (!timelines[position].equals(TimelineDefinition.HOME_TIMELINE)) hideNewPostsButton();
|
|
||||||
if (fragments[position] instanceof BaseRecyclerFragment<?> page){
|
|
||||||
if(!page.loaded && !page.isDataLoading()) page.loadData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!GlobalUserPreferences.reduceMotion) {
|
|
||||||
pager.setPageTransformer((v, pos) -> {
|
|
||||||
if (tabViews[pager.getCurrentItem()] != v) return;
|
|
||||||
float scaleFactor = Math.max(0.85f, 1 - Math.abs(pos) * 0.06f);
|
|
||||||
switcher.setScaleY(scaleFactor);
|
|
||||||
switcher.setScaleX(scaleFactor);
|
|
||||||
switcher.setAlpha(Math.max(0.65f, 1 - Math.abs(pos)));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
updateToolbarLogo();
|
|
||||||
|
|
||||||
if(GithubSelfUpdater.needSelfUpdating()){
|
|
||||||
E.register(this);
|
|
||||||
updateUpdateState(GithubSelfUpdater.getInstance().getState());
|
|
||||||
}
|
|
||||||
|
|
||||||
new GetLists().setCallback(new Callback<>() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(List<ListTimeline> lists) {
|
|
||||||
addItemsToMap(lists, listItems);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onError(ErrorResponse error) {
|
|
||||||
error.showToast(getContext());
|
|
||||||
}
|
|
||||||
}).exec(accountID);
|
|
||||||
|
|
||||||
new GetFollowedHashtags().setCallback(new Callback<>() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(HeaderPaginationList<Hashtag> hashtags) {
|
|
||||||
addItemsToMap(hashtags, hashtagsItems);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onError(ErrorResponse error) {
|
|
||||||
error.showToast(getContext());
|
|
||||||
}
|
|
||||||
}).exec(accountID);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateToolbarLogo(){
|
|
||||||
Toolbar toolbar = getToolbar();
|
|
||||||
ViewParent parentView = toolbarFrame.getParent();
|
|
||||||
if (parentView == toolbar) return;
|
|
||||||
if (parentView instanceof Toolbar parentToolbar) parentToolbar.removeView(toolbarFrame);
|
|
||||||
toolbar.addView(toolbarFrame, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
|
||||||
toolbar.setOnClickListener(v->scrollToTop());
|
|
||||||
toolbar.setNavigationContentDescription(R.string.back);
|
|
||||||
toolbar.setContentInsetsAbsolute(0, toolbar.getContentInsetRight());
|
|
||||||
|
|
||||||
updateSwitcherIcon(pager.getCurrentItem());
|
|
||||||
|
|
||||||
// toolbarLogo=new ImageView(getActivity());
|
|
||||||
// toolbarLogo.setScaleType(ImageView.ScaleType.CENTER);
|
|
||||||
// toolbarLogo.setImageResource(R.drawable.logo);
|
|
||||||
// toolbarLogo.setImageTintList(ColorStateList.valueOf(UiUtils.getThemeColor(getActivity(), android.R.attr.textColorPrimary)));
|
|
||||||
|
|
||||||
toolbarShowNewPostsBtn=toolbarFrame.findViewById(R.id.show_new_posts_btn);
|
|
||||||
toolbarShowNewPostsBtn.setCompoundDrawableTintList(toolbarShowNewPostsBtn.getTextColors());
|
|
||||||
if(Build.VERSION.SDK_INT<Build.VERSION_CODES.N) UiUtils.fixCompoundDrawableTintOnAndroid6(toolbarShowNewPostsBtn);
|
|
||||||
toolbarShowNewPostsBtn.setOnClickListener(this::onNewPostsBtnClick);
|
|
||||||
|
|
||||||
if(newPostsBtnShown){
|
|
||||||
toolbarShowNewPostsBtn.setVisibility(View.VISIBLE);
|
|
||||||
collapsedChevron.setVisibility(View.VISIBLE);
|
|
||||||
collapsedChevron.setAlpha(1f);
|
|
||||||
timelineTitle.setVisibility(View.GONE);
|
|
||||||
timelineTitle.setAlpha(0f);
|
|
||||||
}else{
|
|
||||||
toolbarShowNewPostsBtn.setVisibility(View.INVISIBLE);
|
|
||||||
toolbarShowNewPostsBtn.setAlpha(0f);
|
|
||||||
collapsedChevron.setVisibility(View.GONE);
|
|
||||||
collapsedChevron.setAlpha(0f);
|
|
||||||
toolbarShowNewPostsBtn.setScaleX(.8f);
|
|
||||||
toolbarShowNewPostsBtn.setScaleY(.8f);
|
|
||||||
timelineTitle.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
ViewTreeObserver vto = toolbar.getViewTreeObserver();
|
|
||||||
if (vto.isAlive()) {
|
|
||||||
vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
|
||||||
@Override
|
|
||||||
public void onGlobalLayout() {
|
|
||||||
Toolbar t = getToolbar();
|
|
||||||
if (t == null) return;
|
|
||||||
int toolbarWidth = t.getWidth();
|
|
||||||
if (toolbarWidth == 0) return;
|
|
||||||
t.getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
|
||||||
|
|
||||||
int toolbarFrameWidth = toolbarFrame.getWidth();
|
|
||||||
int padding = toolbarWidth - toolbarFrameWidth;
|
|
||||||
// toolbar frame goes from screen edge to beginning of right-aligned option buttons.
|
|
||||||
// centering button by applying the same space on the left
|
|
||||||
((FrameLayout) toolbarShowNewPostsBtn.getParent()).setPaddingRelative(padding, 0, 0, 0);
|
|
||||||
toolbarShowNewPostsBtn.setMaxWidth(toolbarWidth - padding * 2);
|
|
||||||
|
|
||||||
switcher.setPivotX(V.dp(28)); // padding + half of icon
|
|
||||||
switcher.setPivotY(switcher.getHeight() / 2f);
|
|
||||||
timelineTitle.setPivotX(timelineTitle.getWidth() - V.dp(8));
|
|
||||||
timelineTitle.setPivotY(timelineTitle.getHeight() / 2f);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater){
|
|
||||||
inflater.inflate(R.menu.home, menu);
|
|
||||||
announcements = menu.findItem(R.id.announcements);
|
|
||||||
|
|
||||||
new GetAnnouncements(false).setCallback(new Callback<>() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(List<Announcement> result) {
|
|
||||||
boolean hasUnread = result.stream().anyMatch(a -> !a.read);
|
|
||||||
announcements.setIcon(hasUnread ? R.drawable.ic_announcements_24_badged : R.drawable.ic_fluent_megaphone_24_regular);
|
|
||||||
updateBadgedOptionsItem(announcements, hasUnread);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onError(ErrorResponse error) {
|
|
||||||
error.showToast(getActivity());
|
|
||||||
}
|
|
||||||
}).exec(accountID);
|
|
||||||
|
|
||||||
UiUtils.enableOptionsMenuIcons(getContext(), menu);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateBadgedOptionsItem(MenuItem item, boolean asAction) {
|
|
||||||
item.setShowAsAction(asAction ? MenuItem.SHOW_AS_ACTION_ALWAYS : MenuItem.SHOW_AS_ACTION_NEVER);
|
|
||||||
if (asAction) {
|
|
||||||
UiUtils.resetPopupItemTint(item);
|
|
||||||
} else {
|
|
||||||
UiUtils.insetPopupMenuIcon(getContext(), item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private <T> void addItemsToMap(List<T> addItems, Map<Integer, T> items) {
|
|
||||||
if (addItems.size() == 0) return;
|
|
||||||
for (int i = 0; i < addItems.size(); i++) items.put(View.generateViewId(), addItems.get(i));
|
|
||||||
updateSwitcherMenu();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateSwitcherMenu() {
|
|
||||||
Context context = getContext();
|
|
||||||
Menu switcherMenu = switcherPopup.getMenu();
|
|
||||||
switcherMenu.clear();
|
|
||||||
timelinesByMenuItem.clear();
|
|
||||||
|
|
||||||
for (TimelineDefinition tl : timelines) {
|
|
||||||
int menuItemId = View.generateViewId();
|
|
||||||
timelinesByMenuItem.put(menuItemId, tl);
|
|
||||||
MenuItem item = switcherMenu.add(0, menuItemId, 0, tl.getTitle(getContext()));
|
|
||||||
item.setIcon(tl.getIcon().iconRes);
|
|
||||||
UiUtils.insetPopupMenuIcon(getContext(), item);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!listItems.isEmpty()) {
|
|
||||||
SubMenu listsMenu = switcherMenu.addSubMenu(R.string.sk_list_timelines);
|
|
||||||
UiUtils.insetPopupMenuIcon(context, listsMenu.getItem().setVisible(true)
|
|
||||||
.setIcon(R.drawable.ic_fluent_people_list_24_regular));
|
|
||||||
listsMenu.clear();
|
|
||||||
UiUtils.insetPopupMenuIcon(context, UiUtils.makeBackItem(listsMenu));
|
|
||||||
listItems.forEach((id, list) -> {
|
|
||||||
MenuItem item = listsMenu.add(Menu.NONE, id, Menu.NONE, list.title);
|
|
||||||
item.setIcon(R.drawable.ic_fluent_people_list_24_regular);
|
|
||||||
UiUtils.insetPopupMenuIcon(context, item);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!hashtagsItems.isEmpty()) {
|
|
||||||
SubMenu hashtagsMenu = switcherMenu.addSubMenu(R.string.sk_hashtags_you_follow);
|
|
||||||
UiUtils.insetPopupMenuIcon(context, hashtagsMenu.getItem().setVisible(true)
|
|
||||||
.setIcon(R.drawable.ic_fluent_number_symbol_24_regular));
|
|
||||||
hashtagsMenu.clear();
|
|
||||||
UiUtils.insetPopupMenuIcon(context, UiUtils.makeBackItem(hashtagsMenu));
|
|
||||||
hashtagsItems.forEach((id, hashtag) -> {
|
|
||||||
MenuItem item = hashtagsMenu.add(Menu.NONE, id, Menu.NONE, hashtag.name);
|
|
||||||
item.setIcon(R.drawable.ic_fluent_number_symbol_24_regular);
|
|
||||||
UiUtils.insetPopupMenuIcon(context, item);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean onSwitcherItemSelected(MenuItem item) {
|
|
||||||
int id = item.getItemId();
|
|
||||||
ListTimeline list;
|
|
||||||
Hashtag hashtag;
|
|
||||||
|
|
||||||
Bundle args = new Bundle();
|
|
||||||
args.putString("account", accountID);
|
|
||||||
|
|
||||||
if (id == R.id.menu_back) {
|
|
||||||
switcher.post(() -> switcherPopup.show());
|
|
||||||
return true;
|
|
||||||
} else if ((list = listItems.get(id)) != null) {
|
|
||||||
args.putString("listID", list.id);
|
|
||||||
args.putString("listTitle", list.title);
|
|
||||||
args.putInt("repliesPolicy", list.repliesPolicy.ordinal());
|
|
||||||
Nav.goForResult(getActivity(), ListTimelineFragment.class, args, PINNED_UPDATED_RESULT, this);
|
|
||||||
} else if ((hashtag = hashtagsItems.get(id)) != null) {
|
|
||||||
args.putString("hashtag", hashtag.name);
|
|
||||||
args.putBoolean("following", hashtag.following);
|
|
||||||
Nav.goForResult(getActivity(), HashtagTimelineFragment.class, args, PINNED_UPDATED_RESULT, this);
|
|
||||||
} else {
|
|
||||||
TimelineDefinition tl = timelinesByMenuItem.get(id);
|
|
||||||
if (tl != null) {
|
|
||||||
for (int i = 0; i < timelines.length; i++) {
|
|
||||||
if (timelines[i] == tl) {
|
|
||||||
navigateTo(i);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
private void navigateTo(int i) {
|
|
||||||
navigateTo(i, !GlobalUserPreferences.reduceMotion);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void navigateTo(int i, boolean smooth) {
|
|
||||||
pager.setCurrentItem(i, smooth);
|
|
||||||
updateSwitcherIcon(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateSwitcherIcon(int i) {
|
|
||||||
timelineIcon.setImageResource(timelines[i].getIcon().iconRes);
|
|
||||||
timelineTitle.setText(timelines[i].getTitle(getContext()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onOptionsItemSelected(MenuItem item){
|
|
||||||
Bundle args=new Bundle();
|
|
||||||
args.putString("account", accountID);
|
|
||||||
int id = item.getItemId();
|
|
||||||
if (id == R.id.settings) {
|
|
||||||
Nav.go(getActivity(), SettingsFragment.class, args);
|
|
||||||
} else if (id == R.id.announcements) {
|
|
||||||
Nav.goForResult(getActivity(), AnnouncementsFragment.class, args, ANNOUNCEMENTS_RESULT, this);
|
|
||||||
} else if (id == R.id.edit_timelines) {
|
|
||||||
Nav.go(getActivity(), EditTimelinesFragment.class, args);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void scrollToTop(){
|
|
||||||
((ScrollableToTop) fragments[pager.getCurrentItem()]).scrollToTop();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void hideNewPostsButton(){
|
|
||||||
if(!newPostsBtnShown)
|
|
||||||
return;
|
|
||||||
newPostsBtnShown=false;
|
|
||||||
if(currentNewPostsAnim!=null){
|
|
||||||
currentNewPostsAnim.cancel();
|
|
||||||
}
|
|
||||||
timelineTitle.setVisibility(View.VISIBLE);
|
|
||||||
AnimatorSet set=new AnimatorSet();
|
|
||||||
set.playTogether(
|
|
||||||
ObjectAnimator.ofFloat(timelineTitle, View.ALPHA, 1f),
|
|
||||||
ObjectAnimator.ofFloat(timelineTitle, View.SCALE_X, 1f),
|
|
||||||
ObjectAnimator.ofFloat(timelineTitle, View.SCALE_Y, 1f),
|
|
||||||
ObjectAnimator.ofFloat(toolbarShowNewPostsBtn, View.ALPHA, 0f),
|
|
||||||
ObjectAnimator.ofFloat(toolbarShowNewPostsBtn, View.SCALE_X, .8f),
|
|
||||||
ObjectAnimator.ofFloat(toolbarShowNewPostsBtn, View.SCALE_Y, .8f),
|
|
||||||
ObjectAnimator.ofFloat(collapsedChevron, View.ALPHA, 0f)
|
|
||||||
);
|
|
||||||
set.setDuration(GlobalUserPreferences.reduceMotion ? 0 : 300);
|
|
||||||
set.setInterpolator(CubicBezierInterpolator.DEFAULT);
|
|
||||||
set.addListener(new AnimatorListenerAdapter(){
|
|
||||||
@Override
|
|
||||||
public void onAnimationEnd(Animator animation){
|
|
||||||
toolbarShowNewPostsBtn.setVisibility(View.INVISIBLE);
|
|
||||||
collapsedChevron.setVisibility(View.GONE);
|
|
||||||
currentNewPostsAnim=null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
currentNewPostsAnim=set;
|
|
||||||
set.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void showNewPostsButton(){
|
|
||||||
if(newPostsBtnShown || pager == null || !timelines[pager.getCurrentItem()].equals(TimelineDefinition.HOME_TIMELINE))
|
|
||||||
return;
|
|
||||||
newPostsBtnShown=true;
|
|
||||||
if(currentNewPostsAnim!=null){
|
|
||||||
currentNewPostsAnim.cancel();
|
|
||||||
}
|
|
||||||
toolbarShowNewPostsBtn.setVisibility(View.VISIBLE);
|
|
||||||
collapsedChevron.setVisibility(View.VISIBLE);
|
|
||||||
AnimatorSet set=new AnimatorSet();
|
|
||||||
set.playTogether(
|
|
||||||
ObjectAnimator.ofFloat(timelineTitle, View.ALPHA, 0f),
|
|
||||||
ObjectAnimator.ofFloat(timelineTitle, View.SCALE_X, .8f),
|
|
||||||
ObjectAnimator.ofFloat(timelineTitle, View.SCALE_Y, .8f),
|
|
||||||
ObjectAnimator.ofFloat(toolbarShowNewPostsBtn, View.ALPHA, 1f),
|
|
||||||
ObjectAnimator.ofFloat(toolbarShowNewPostsBtn, View.SCALE_X, 1f),
|
|
||||||
ObjectAnimator.ofFloat(toolbarShowNewPostsBtn, View.SCALE_Y, 1f),
|
|
||||||
ObjectAnimator.ofFloat(collapsedChevron, View.ALPHA, 1f)
|
|
||||||
);
|
|
||||||
set.setDuration(GlobalUserPreferences.reduceMotion ? 0 : 300);
|
|
||||||
set.setInterpolator(CubicBezierInterpolator.DEFAULT);
|
|
||||||
set.addListener(new AnimatorListenerAdapter(){
|
|
||||||
@Override
|
|
||||||
public void onAnimationEnd(Animator animation){
|
|
||||||
timelineTitle.setVisibility(View.GONE);
|
|
||||||
currentNewPostsAnim=null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
currentNewPostsAnim=set;
|
|
||||||
set.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isNewPostsBtnShown() {
|
|
||||||
return newPostsBtnShown;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onNewPostsBtnClick(View view) {
|
|
||||||
if(newPostsBtnShown){
|
|
||||||
hideNewPostsButton();
|
|
||||||
scrollToTop();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFragmentResult(int reqCode, boolean success, Bundle result){
|
|
||||||
if (reqCode == ANNOUNCEMENTS_RESULT && success) {
|
|
||||||
announcements.setIcon(R.drawable.ic_fluent_megaphone_24_regular);
|
|
||||||
announcements.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
|
|
||||||
UiUtils.insetPopupMenuIcon(getContext(), announcements);
|
|
||||||
} else if (reqCode == PINNED_UPDATED_RESULT && result != null && result.getBoolean("pinnedUpdated", false)) {
|
|
||||||
UiUtils.restartApp();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateUpdateState(GithubSelfUpdater.UpdateState state){
|
|
||||||
if(state!=GithubSelfUpdater.UpdateState.NO_UPDATE && state!=GithubSelfUpdater.UpdateState.CHECKING) {
|
|
||||||
MenuItem settings = getToolbar().getMenu().findItem(R.id.settings);
|
|
||||||
settings.setIcon(R.drawable.ic_settings_24_badged);
|
|
||||||
updateBadgedOptionsItem(settings, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onSelfUpdateStateChanged(SelfUpdateStateChangedEvent ev){
|
|
||||||
updateUpdateState(ev.state);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onBackPressed(){
|
|
||||||
if(pager.getCurrentItem() > 0){
|
|
||||||
navigateTo(0);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDestroyView(){
|
|
||||||
super.onDestroyView();
|
|
||||||
if(GithubSelfUpdater.needSelfUpdating()){
|
|
||||||
E.unregister(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onViewStateRestored(Bundle savedInstanceState) {
|
|
||||||
super.onViewStateRestored(savedInstanceState);
|
|
||||||
if (savedInstanceState == null) return;
|
|
||||||
navigateTo(savedInstanceState.getInt("selectedTab"), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSaveInstanceState(Bundle outState) {
|
|
||||||
super.onSaveInstanceState(outState);
|
|
||||||
outState.putInt("selectedTab", pager.getCurrentItem());
|
|
||||||
}
|
|
||||||
|
|
||||||
private class HomePagerAdapter extends RecyclerView.Adapter<SimpleViewHolder> {
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public SimpleViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
|
||||||
FrameLayout tabView = tabViews[viewType % getItemCount()];
|
|
||||||
((ViewGroup)tabView.getParent()).removeView(tabView);
|
|
||||||
tabView.setVisibility(View.VISIBLE);
|
|
||||||
return new SimpleViewHolder(tabView);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBindViewHolder(@NonNull SimpleViewHolder holder, int position){}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getItemCount(){
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getItemViewType(int position){
|
|
||||||
return position;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,46 +1,78 @@
|
|||||||
package org.joinmastodon.android.fragments;
|
package org.joinmastodon.android.fragments;
|
||||||
|
|
||||||
|
import android.animation.Animator;
|
||||||
|
import android.animation.AnimatorListenerAdapter;
|
||||||
|
import android.animation.AnimatorSet;
|
||||||
|
import android.animation.ObjectAnimator;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.content.res.ColorStateList;
|
||||||
|
import android.content.res.Configuration;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.view.Gravity;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuInflater;
|
||||||
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
|
import android.widget.ImageButton;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toolbar;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import com.squareup.otto.Subscribe;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
|
||||||
|
|
||||||
import org.joinmastodon.android.GlobalUserPreferences;
|
|
||||||
import org.joinmastodon.android.E;
|
import org.joinmastodon.android.E;
|
||||||
|
import org.joinmastodon.android.GlobalUserPreferences;
|
||||||
import org.joinmastodon.android.R;
|
import org.joinmastodon.android.R;
|
||||||
import org.joinmastodon.android.api.requests.markers.SaveMarkers;
|
|
||||||
import org.joinmastodon.android.api.requests.timelines.GetHomeTimeline;
|
import org.joinmastodon.android.api.requests.timelines.GetHomeTimeline;
|
||||||
import org.joinmastodon.android.api.session.AccountSessionManager;
|
import org.joinmastodon.android.api.session.AccountSessionManager;
|
||||||
|
import org.joinmastodon.android.events.SelfUpdateStateChangedEvent;
|
||||||
import org.joinmastodon.android.events.StatusCreatedEvent;
|
import org.joinmastodon.android.events.StatusCreatedEvent;
|
||||||
import org.joinmastodon.android.model.CacheablePaginatedResponse;
|
import org.joinmastodon.android.model.CacheablePaginatedResponse;
|
||||||
import org.joinmastodon.android.model.Filter;
|
import org.joinmastodon.android.model.Filter;
|
||||||
import org.joinmastodon.android.model.Status;
|
import org.joinmastodon.android.model.Status;
|
||||||
import org.joinmastodon.android.ui.displayitems.GapStatusDisplayItem;
|
import org.joinmastodon.android.ui.displayitems.GapStatusDisplayItem;
|
||||||
import org.joinmastodon.android.ui.displayitems.StatusDisplayItem;
|
import org.joinmastodon.android.ui.displayitems.StatusDisplayItem;
|
||||||
|
import org.joinmastodon.android.ui.utils.UiUtils;
|
||||||
|
import org.joinmastodon.android.updater.GithubSelfUpdater;
|
||||||
import org.joinmastodon.android.utils.StatusFilterPredicate;
|
import org.joinmastodon.android.utils.StatusFilterPredicate;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
import me.grishka.appkit.Nav;
|
||||||
import me.grishka.appkit.api.Callback;
|
import me.grishka.appkit.api.Callback;
|
||||||
import me.grishka.appkit.api.ErrorResponse;
|
import me.grishka.appkit.api.ErrorResponse;
|
||||||
import me.grishka.appkit.api.SimpleCallback;
|
import me.grishka.appkit.api.SimpleCallback;
|
||||||
|
import me.grishka.appkit.utils.CubicBezierInterpolator;
|
||||||
import me.grishka.appkit.utils.V;
|
import me.grishka.appkit.utils.V;
|
||||||
|
|
||||||
public class HomeTimelineFragment extends FabStatusListFragment {
|
public class HomeTimelineFragment extends StatusListFragment{
|
||||||
private HomeTabFragment parent;
|
private ImageButton fab;
|
||||||
|
private ImageView toolbarLogo;
|
||||||
|
private Button toolbarShowNewPostsBtn;
|
||||||
|
private boolean newPostsBtnShown;
|
||||||
|
private AnimatorSet currentNewPostsAnim;
|
||||||
|
|
||||||
private String maxID;
|
private String maxID;
|
||||||
private String lastSavedMarkerID;
|
|
||||||
|
public HomeTimelineFragment(){
|
||||||
|
setListLayoutId(R.layout.recycler_fragment_with_fab);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAttach(Activity activity){
|
public void onAttach(Activity activity){
|
||||||
super.onAttach(activity);
|
super.onAttach(activity);
|
||||||
if (getParentFragment() instanceof HomeTabFragment home) parent = home;
|
setHasOptionsMenu(true);
|
||||||
loadData();
|
loadData();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,15 +104,41 @@ public class HomeTimelineFragment extends FabStatusListFragment {
|
|||||||
@Override
|
@Override
|
||||||
public void onViewCreated(View view, Bundle savedInstanceState){
|
public void onViewCreated(View view, Bundle savedInstanceState){
|
||||||
super.onViewCreated(view, savedInstanceState);
|
super.onViewCreated(view, savedInstanceState);
|
||||||
|
fab=view.findViewById(R.id.fab);
|
||||||
|
fab.setOnClickListener(this::onFabClick);
|
||||||
|
updateToolbarLogo();
|
||||||
list.addOnScrollListener(new RecyclerView.OnScrollListener(){
|
list.addOnScrollListener(new RecyclerView.OnScrollListener(){
|
||||||
@Override
|
@Override
|
||||||
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy){
|
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy){
|
||||||
if(parent != null && parent.isNewPostsBtnShown() && list.getChildAdapterPosition(list.getChildAt(0))<=getMainAdapterOffset()){
|
if(newPostsBtnShown && list.getChildAdapterPosition(list.getChildAt(0))<=getMainAdapterOffset()){
|
||||||
parent.hideNewPostsButton();
|
hideNewPostsButton();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if(GithubSelfUpdater.needSelfUpdating()){
|
||||||
|
E.register(this);
|
||||||
|
updateUpdateState(GithubSelfUpdater.getInstance().getState());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater){
|
||||||
|
inflater.inflate(R.menu.home, menu);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item){
|
||||||
|
Bundle args=new Bundle();
|
||||||
|
args.putString("account", accountID);
|
||||||
|
Nav.go(getActivity(), SettingsFragment.class, args);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onConfigurationChanged(Configuration newConfig){
|
||||||
|
super.onConfigurationChanged(newConfig);
|
||||||
|
updateToolbarLogo();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -95,33 +153,16 @@ public class HomeTimelineFragment extends FabStatusListFragment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onHidden(){
|
|
||||||
super.onHidden();
|
|
||||||
if(!data.isEmpty()){
|
|
||||||
String topPostID=displayItems.get(list.getChildAdapterPosition(list.getChildAt(0))-getMainAdapterOffset()).parentID;
|
|
||||||
if(!topPostID.equals(lastSavedMarkerID)){
|
|
||||||
lastSavedMarkerID=topPostID;
|
|
||||||
new SaveMarkers(topPostID, null)
|
|
||||||
.setCallback(new Callback<>(){
|
|
||||||
@Override
|
|
||||||
public void onSuccess(SaveMarkers.Response result){
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onError(ErrorResponse error){
|
|
||||||
lastSavedMarkerID=null;
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.exec(accountID);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onStatusCreated(StatusCreatedEvent ev){
|
public void onStatusCreated(StatusCreatedEvent ev){
|
||||||
prependItems(Collections.singletonList(ev.status), true);
|
prependItems(Collections.singletonList(ev.status), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void onFabClick(View v){
|
||||||
|
Bundle args=new Bundle();
|
||||||
|
args.putString("account", accountID);
|
||||||
|
Nav.go(getActivity(), ComposeFragment.class, args);
|
||||||
|
}
|
||||||
|
|
||||||
private void loadNewPosts(){
|
private void loadNewPosts(){
|
||||||
if (!GlobalUserPreferences.loadNewPosts) return;
|
if (!GlobalUserPreferences.loadNewPosts) return;
|
||||||
dataLoading=true;
|
dataLoading=true;
|
||||||
@@ -146,11 +187,13 @@ public class HomeTimelineFragment extends FabStatusListFragment {
|
|||||||
result.get(result.size()-1).hasGapAfter=true;
|
result.get(result.size()-1).hasGapAfter=true;
|
||||||
toAdd=result;
|
toAdd=result;
|
||||||
}
|
}
|
||||||
StatusFilterPredicate filterPredicate=new StatusFilterPredicate(accountID, Filter.FilterContext.HOME);
|
List<Filter> filters=AccountSessionManager.getInstance().getAccount(accountID).wordFilters.stream().filter(f->f.context.contains(Filter.FilterContext.HOME)).collect(Collectors.toList());
|
||||||
toAdd=toAdd.stream().filter(filterPredicate).collect(Collectors.toList());
|
if(!filters.isEmpty()){
|
||||||
|
toAdd=toAdd.stream().filter(new StatusFilterPredicate(filters)).collect(Collectors.toList());
|
||||||
|
}
|
||||||
if(!toAdd.isEmpty()){
|
if(!toAdd.isEmpty()){
|
||||||
prependItems(toAdd, true);
|
prependItems(toAdd, true);
|
||||||
if (parent != null) parent.showNewPostsButton();
|
showNewPostsButton();
|
||||||
AccountSessionManager.getInstance().getAccount(accountID).getCacheController().putHomeTimeline(toAdd, false);
|
AccountSessionManager.getInstance().getAccount(accountID).getCacheController().putHomeTimeline(toAdd, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -221,14 +264,18 @@ public class HomeTimelineFragment extends FabStatusListFragment {
|
|||||||
List<StatusDisplayItem> targetList=displayItems.subList(gapPos, gapPos+1);
|
List<StatusDisplayItem> targetList=displayItems.subList(gapPos, gapPos+1);
|
||||||
targetList.clear();
|
targetList.clear();
|
||||||
List<Status> insertedPosts=data.subList(gapPostIndex+1, gapPostIndex+1);
|
List<Status> insertedPosts=data.subList(gapPostIndex+1, gapPostIndex+1);
|
||||||
StatusFilterPredicate filterPredicate=new StatusFilterPredicate(accountID, Filter.FilterContext.HOME);
|
List<Filter> filters=AccountSessionManager.getInstance().getAccount(accountID).wordFilters.stream().filter(f->f.context.contains(Filter.FilterContext.HOME)).collect(Collectors.toList());
|
||||||
|
outer:
|
||||||
for(Status s:result){
|
for(Status s:result){
|
||||||
if(idsBelowGap.contains(s.id))
|
if(idsBelowGap.contains(s.id))
|
||||||
break;
|
break;
|
||||||
if(filterPredicate.test(s)){
|
for(Filter filter:filters){
|
||||||
targetList.addAll(buildDisplayItems(s));
|
if(filter.matches(s)){
|
||||||
insertedPosts.add(s);
|
continue outer;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
targetList.addAll(buildDisplayItems(s));
|
||||||
|
insertedPosts.add(s);
|
||||||
}
|
}
|
||||||
if(targetList.isEmpty()){
|
if(targetList.isEmpty()){
|
||||||
// oops. We didn't add new posts, but at least we know there are none.
|
// oops. We didn't add new posts, but at least we know there are none.
|
||||||
@@ -266,10 +313,132 @@ public class HomeTimelineFragment extends FabStatusListFragment {
|
|||||||
currentRequest=null;
|
currentRequest=null;
|
||||||
dataLoading=false;
|
dataLoading=false;
|
||||||
}
|
}
|
||||||
if (parent != null) parent.hideNewPostsButton();
|
|
||||||
super.onRefresh();
|
super.onRefresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateToolbarLogo(){
|
||||||
|
toolbarLogo=new ImageView(getActivity());
|
||||||
|
toolbarLogo.setScaleType(ImageView.ScaleType.CENTER);
|
||||||
|
toolbarLogo.setImageResource(R.drawable.logo);
|
||||||
|
toolbarLogo.setImageTintList(ColorStateList.valueOf(UiUtils.getThemeColor(getActivity(), android.R.attr.textColorPrimary)));
|
||||||
|
// toolbarLogo =new TextView(getActivity());
|
||||||
|
// toolbarLogo.setText(getString(R.string.app_name).toLowerCase(Locale.getDefault()));
|
||||||
|
// toolbarLogo.setTextAppearance(R.style.app_title);
|
||||||
|
|
||||||
|
toolbarShowNewPostsBtn=new Button(getActivity());
|
||||||
|
toolbarShowNewPostsBtn.setTextAppearance(R.style.m3_title_medium);
|
||||||
|
toolbarShowNewPostsBtn.setTextColor(0xffffffff);
|
||||||
|
toolbarShowNewPostsBtn.setStateListAnimator(null);
|
||||||
|
toolbarShowNewPostsBtn.setBackgroundResource(R.drawable.bg_button_new_posts);
|
||||||
|
toolbarShowNewPostsBtn.setText(R.string.see_new_posts);
|
||||||
|
toolbarShowNewPostsBtn.setCompoundDrawablesRelativeWithIntrinsicBounds(R.drawable.ic_fluent_arrow_up_16_filled, 0, 0, 0);
|
||||||
|
toolbarShowNewPostsBtn.setCompoundDrawableTintList(toolbarShowNewPostsBtn.getTextColors());
|
||||||
|
toolbarShowNewPostsBtn.setCompoundDrawablePadding(V.dp(8));
|
||||||
|
if(Build.VERSION.SDK_INT<Build.VERSION_CODES.N)
|
||||||
|
UiUtils.fixCompoundDrawableTintOnAndroid6(toolbarShowNewPostsBtn);
|
||||||
|
toolbarShowNewPostsBtn.setOnClickListener(this::onNewPostsBtnClick);
|
||||||
|
|
||||||
|
if(newPostsBtnShown){
|
||||||
|
toolbarShowNewPostsBtn.setVisibility(View.VISIBLE);
|
||||||
|
toolbarLogo.setVisibility(View.INVISIBLE);
|
||||||
|
toolbarLogo.setAlpha(0f);
|
||||||
|
}else{
|
||||||
|
toolbarShowNewPostsBtn.setVisibility(View.INVISIBLE);
|
||||||
|
toolbarShowNewPostsBtn.setAlpha(0f);
|
||||||
|
toolbarShowNewPostsBtn.setScaleX(.8f);
|
||||||
|
toolbarShowNewPostsBtn.setScaleY(.8f);
|
||||||
|
toolbarLogo.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
FrameLayout logoWrap=new FrameLayout(getActivity());
|
||||||
|
logoWrap.addView(toolbarLogo, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.CENTER));
|
||||||
|
logoWrap.addView(toolbarShowNewPostsBtn, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, V.dp(32), Gravity.CENTER));
|
||||||
|
|
||||||
|
Toolbar toolbar=getToolbar();
|
||||||
|
toolbar.addView(logoWrap, new Toolbar.LayoutParams(Gravity.CENTER));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showNewPostsButton(){
|
||||||
|
if(newPostsBtnShown)
|
||||||
|
return;
|
||||||
|
newPostsBtnShown=true;
|
||||||
|
if(currentNewPostsAnim!=null){
|
||||||
|
currentNewPostsAnim.cancel();
|
||||||
|
}
|
||||||
|
toolbarShowNewPostsBtn.setVisibility(View.VISIBLE);
|
||||||
|
AnimatorSet set=new AnimatorSet();
|
||||||
|
set.playTogether(
|
||||||
|
ObjectAnimator.ofFloat(toolbarLogo, View.ALPHA, 0f),
|
||||||
|
ObjectAnimator.ofFloat(toolbarShowNewPostsBtn, View.ALPHA, 1f),
|
||||||
|
ObjectAnimator.ofFloat(toolbarShowNewPostsBtn, View.SCALE_X, 1f),
|
||||||
|
ObjectAnimator.ofFloat(toolbarShowNewPostsBtn, View.SCALE_Y, 1f)
|
||||||
|
);
|
||||||
|
set.setDuration(300);
|
||||||
|
set.setInterpolator(CubicBezierInterpolator.DEFAULT);
|
||||||
|
set.addListener(new AnimatorListenerAdapter(){
|
||||||
|
@Override
|
||||||
|
public void onAnimationEnd(Animator animation){
|
||||||
|
toolbarLogo.setVisibility(View.INVISIBLE);
|
||||||
|
currentNewPostsAnim=null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
currentNewPostsAnim=set;
|
||||||
|
set.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void hideNewPostsButton(){
|
||||||
|
if(!newPostsBtnShown)
|
||||||
|
return;
|
||||||
|
newPostsBtnShown=false;
|
||||||
|
if(currentNewPostsAnim!=null){
|
||||||
|
currentNewPostsAnim.cancel();
|
||||||
|
}
|
||||||
|
toolbarLogo.setVisibility(View.VISIBLE);
|
||||||
|
AnimatorSet set=new AnimatorSet();
|
||||||
|
set.playTogether(
|
||||||
|
ObjectAnimator.ofFloat(toolbarLogo, View.ALPHA, 1f),
|
||||||
|
ObjectAnimator.ofFloat(toolbarShowNewPostsBtn, View.ALPHA, 0f),
|
||||||
|
ObjectAnimator.ofFloat(toolbarShowNewPostsBtn, View.SCALE_X, .8f),
|
||||||
|
ObjectAnimator.ofFloat(toolbarShowNewPostsBtn, View.SCALE_Y, .8f)
|
||||||
|
);
|
||||||
|
set.setDuration(300);
|
||||||
|
set.setInterpolator(CubicBezierInterpolator.DEFAULT);
|
||||||
|
set.addListener(new AnimatorListenerAdapter(){
|
||||||
|
@Override
|
||||||
|
public void onAnimationEnd(Animator animation){
|
||||||
|
toolbarShowNewPostsBtn.setVisibility(View.INVISIBLE);
|
||||||
|
currentNewPostsAnim=null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
currentNewPostsAnim=set;
|
||||||
|
set.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onNewPostsBtnClick(View v){
|
||||||
|
if(newPostsBtnShown){
|
||||||
|
hideNewPostsButton();
|
||||||
|
scrollToTop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroyView(){
|
||||||
|
super.onDestroyView();
|
||||||
|
if(GithubSelfUpdater.needSelfUpdating()){
|
||||||
|
E.unregister(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateUpdateState(GithubSelfUpdater.UpdateState state){
|
||||||
|
if(state!=GithubSelfUpdater.UpdateState.NO_UPDATE && state!=GithubSelfUpdater.UpdateState.CHECKING)
|
||||||
|
getToolbar().getMenu().findItem(R.id.settings).setIcon(R.drawable.ic_settings_24_badged);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onSelfUpdateStateChanged(SelfUpdateStateChangedEvent ev){
|
||||||
|
updateUpdateState(ev.state);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean shouldRemoveAccountPostsWhenUnfollowing(){
|
protected boolean shouldRemoveAccountPostsWhenUnfollowing(){
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
package org.joinmastodon.android.fragments;
|
|
||||||
|
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
|
||||||
|
|
||||||
public interface IsOnTop {
|
|
||||||
boolean isOnTop();
|
|
||||||
|
|
||||||
default boolean isRecyclerViewOnTop(RecyclerView list) {
|
|
||||||
return !list.canScrollVertically(-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,44 +1,29 @@
|
|||||||
package org.joinmastodon.android.fragments;
|
package org.joinmastodon.android.fragments;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.media.MediaRouter;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.HapticFeedbackConstants;
|
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuInflater;
|
import android.view.MenuInflater;
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import org.joinmastodon.android.GlobalUserPreferences;
|
|
||||||
import org.joinmastodon.android.R;
|
import org.joinmastodon.android.R;
|
||||||
import org.joinmastodon.android.api.requests.lists.GetList;
|
|
||||||
import org.joinmastodon.android.api.requests.lists.UpdateList;
|
|
||||||
import org.joinmastodon.android.api.requests.timelines.GetListTimeline;
|
import org.joinmastodon.android.api.requests.timelines.GetListTimeline;
|
||||||
import org.joinmastodon.android.model.ListTimeline;
|
|
||||||
import org.joinmastodon.android.model.Status;
|
import org.joinmastodon.android.model.Status;
|
||||||
import org.joinmastodon.android.model.TimelineDefinition;
|
|
||||||
import org.joinmastodon.android.ui.M3AlertDialogBuilder;
|
|
||||||
import org.joinmastodon.android.ui.utils.UiUtils;
|
|
||||||
import org.joinmastodon.android.ui.views.ListTimelineEditor;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import me.grishka.appkit.Nav;
|
import me.grishka.appkit.Nav;
|
||||||
import me.grishka.appkit.api.Callback;
|
|
||||||
import me.grishka.appkit.api.ErrorResponse;
|
|
||||||
import me.grishka.appkit.api.SimpleCallback;
|
import me.grishka.appkit.api.SimpleCallback;
|
||||||
import me.grishka.appkit.utils.V;
|
import me.grishka.appkit.utils.V;
|
||||||
|
|
||||||
|
|
||||||
public class ListTimelineFragment extends PinnableStatusListFragment {
|
public class ListTimelineFragment extends StatusListFragment {
|
||||||
private String listID;
|
private String listID;
|
||||||
private String listTitle;
|
private String listTitle;
|
||||||
private ListTimeline.RepliesPolicy repliesPolicy;
|
|
||||||
private ImageButton fab;
|
private ImageButton fab;
|
||||||
private Bundle resultArgs = new Bundle();
|
|
||||||
|
|
||||||
public ListTimelineFragment() {
|
public ListTimelineFragment() {
|
||||||
setListLayoutId(R.layout.recycler_fragment_with_fab);
|
setListLayoutId(R.layout.recycler_fragment_with_fab);
|
||||||
@@ -47,85 +32,17 @@ public class ListTimelineFragment extends PinnableStatusListFragment {
|
|||||||
@Override
|
@Override
|
||||||
public void onAttach(Activity activity){
|
public void onAttach(Activity activity){
|
||||||
super.onAttach(activity);
|
super.onAttach(activity);
|
||||||
Bundle args = getArguments();
|
listID=getArguments().getString("listID");
|
||||||
listID = args.getString("listID");
|
listTitle=getArguments().getString("listTitle");
|
||||||
listTitle = args.getString("listTitle");
|
|
||||||
repliesPolicy = ListTimeline.RepliesPolicy.values()[args.getInt("repliesPolicy", 0)];
|
|
||||||
resultArgs.putString("listID", listID);
|
|
||||||
|
|
||||||
setTitle(listTitle);
|
setTitle(listTitle);
|
||||||
setHasOptionsMenu(true);
|
setHasOptionsMenu(true);
|
||||||
|
|
||||||
new GetList(listID).setCallback(new Callback<>() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(ListTimeline listTimeline) {
|
|
||||||
// TODO: save updated info
|
|
||||||
if (!listTimeline.title.equals(listTitle)) setTitle(listTimeline.title);
|
|
||||||
if (!listTimeline.repliesPolicy.equals(repliesPolicy)) repliesPolicy = listTimeline.repliesPolicy;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onError(ErrorResponse error) {
|
|
||||||
error.showToast(getContext());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||||
inflater.inflate(R.menu.list, menu);
|
|
||||||
super.onCreateOptionsMenu(menu, inflater);
|
super.onCreateOptionsMenu(menu, inflater);
|
||||||
UiUtils.enableOptionsMenuIcons(getContext(), menu, R.id.pin);
|
// TODO: implement edit, delete
|
||||||
}
|
// inflater.inflate(R.menu.list, menu);
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
|
||||||
if (super.onOptionsItemSelected(item)) return true;
|
|
||||||
if (item.getItemId() == R.id.edit) {
|
|
||||||
ListTimelineEditor editor = new ListTimelineEditor(getContext());
|
|
||||||
editor.applyList(listTitle, repliesPolicy);
|
|
||||||
new M3AlertDialogBuilder(getActivity())
|
|
||||||
.setTitle(R.string.sk_edit_list_title)
|
|
||||||
.setIcon(R.drawable.ic_fluent_people_list_28_regular)
|
|
||||||
.setView(editor)
|
|
||||||
.setPositiveButton(R.string.save, (d, which) -> {
|
|
||||||
new UpdateList(listID, editor.getTitle(), editor.getRepliesPolicy()).setCallback(new Callback<>() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(ListTimeline list) {
|
|
||||||
setTitle(list.title);
|
|
||||||
listTitle = list.title;
|
|
||||||
repliesPolicy = list.repliesPolicy;
|
|
||||||
resultArgs.putString("listTitle", listTitle);
|
|
||||||
resultArgs.putInt("repliesPolicy", repliesPolicy.ordinal());
|
|
||||||
setResult(true, resultArgs);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onError(ErrorResponse error) {
|
|
||||||
error.showToast(getContext());
|
|
||||||
}
|
|
||||||
}).exec(accountID);
|
|
||||||
})
|
|
||||||
.setNegativeButton(R.string.cancel, (d, which) -> {})
|
|
||||||
.show();
|
|
||||||
} else if (item.getItemId() == R.id.delete) {
|
|
||||||
UiUtils.confirmDeleteList(getActivity(), accountID, listID, listTitle, () -> {
|
|
||||||
resultArgs.putBoolean("deleted", true);
|
|
||||||
setResult(true, resultArgs);
|
|
||||||
Nav.finish(this);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Bundle getResultArgs() {
|
|
||||||
return resultArgs;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TimelineDefinition makeTimelineDefinition() {
|
|
||||||
return TimelineDefinition.ofList(listID, listTitle);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -152,7 +69,6 @@ public class ListTimelineFragment extends PinnableStatusListFragment {
|
|||||||
super.onViewCreated(view, savedInstanceState);
|
super.onViewCreated(view, savedInstanceState);
|
||||||
fab=view.findViewById(R.id.fab);
|
fab=view.findViewById(R.id.fab);
|
||||||
fab.setOnClickListener(this::onFabClick);
|
fab.setOnClickListener(this::onFabClick);
|
||||||
fab.setOnLongClickListener(v -> UiUtils.pickAccountForCompose(getActivity(), accountID));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onFabClick(View v){
|
private void onFabClick(View v){
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
package org.joinmastodon.android.fragments;
|
package org.joinmastodon.android.fragments;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuInflater;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
@@ -15,39 +12,28 @@ import androidx.recyclerview.widget.RecyclerView;
|
|||||||
import org.joinmastodon.android.R;
|
import org.joinmastodon.android.R;
|
||||||
import org.joinmastodon.android.api.MastodonAPIRequest;
|
import org.joinmastodon.android.api.MastodonAPIRequest;
|
||||||
import org.joinmastodon.android.api.requests.lists.AddAccountsToList;
|
import org.joinmastodon.android.api.requests.lists.AddAccountsToList;
|
||||||
import org.joinmastodon.android.api.requests.lists.CreateList;
|
|
||||||
import org.joinmastodon.android.api.requests.lists.GetLists;
|
import org.joinmastodon.android.api.requests.lists.GetLists;
|
||||||
import org.joinmastodon.android.api.requests.lists.RemoveAccountsFromList;
|
import org.joinmastodon.android.api.requests.lists.RemoveAccountsFromList;
|
||||||
import org.joinmastodon.android.model.ListTimeline;
|
import org.joinmastodon.android.model.ListTimeline;
|
||||||
import org.joinmastodon.android.ui.DividerItemDecoration;
|
|
||||||
import org.joinmastodon.android.ui.M3AlertDialogBuilder;
|
|
||||||
import org.joinmastodon.android.ui.utils.UiUtils;
|
import org.joinmastodon.android.ui.utils.UiUtils;
|
||||||
import org.joinmastodon.android.ui.views.ListTimelineEditor;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import me.grishka.appkit.Nav;
|
|
||||||
import me.grishka.appkit.api.Callback;
|
|
||||||
import me.grishka.appkit.api.ErrorResponse;
|
|
||||||
import me.grishka.appkit.api.SimpleCallback;
|
import me.grishka.appkit.api.SimpleCallback;
|
||||||
import me.grishka.appkit.fragments.BaseRecyclerFragment;
|
import me.grishka.appkit.fragments.BaseRecyclerFragment;
|
||||||
import me.grishka.appkit.utils.BindableViewHolder;
|
import me.grishka.appkit.utils.BindableViewHolder;
|
||||||
import me.grishka.appkit.views.UsableRecyclerView;
|
import me.grishka.appkit.views.UsableRecyclerView;
|
||||||
|
|
||||||
public class ListTimelinesFragment extends BaseRecyclerFragment<ListTimeline> implements ScrollableToTop {
|
public class ListTimelinesFragment extends BaseRecyclerFragment<ListTimeline> implements ScrollableToTop {
|
||||||
private static final int LIST_CHANGED_RESULT = 987;
|
|
||||||
|
|
||||||
private String accountId;
|
private String accountId;
|
||||||
private String profileAccountId;
|
private String profileAccountId;
|
||||||
private String profileDisplayUsername;
|
private String profileDisplayUsername;
|
||||||
private HashMap<String, Boolean> userInListBefore = new HashMap<>();
|
private HashMap<String, Boolean> userInListBefore = new HashMap<>();
|
||||||
private HashMap<String, Boolean> userInList = new HashMap<>();
|
private HashMap<String, Boolean> userInList = new HashMap<>();
|
||||||
private int inProgress = 0;
|
private int inProgress = 0;
|
||||||
private ListsAdapter adapter;
|
|
||||||
private boolean pinnedUpdated;
|
|
||||||
|
|
||||||
public ListTimelinesFragment() {
|
public ListTimelinesFragment() {
|
||||||
super(10);
|
super(10);
|
||||||
@@ -58,14 +44,12 @@ public class ListTimelinesFragment extends BaseRecyclerFragment<ListTimeline> im
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
Bundle args=getArguments();
|
Bundle args=getArguments();
|
||||||
accountId=args.getString("account");
|
accountId=args.getString("account");
|
||||||
setHasOptionsMenu(true);
|
|
||||||
|
|
||||||
if(args.containsKey("profileAccount")){
|
if(args.containsKey("profileAccount")){
|
||||||
profileAccountId=args.getString("profileAccount");
|
profileAccountId=args.getString("profileAccount");
|
||||||
profileDisplayUsername=args.getString("profileDisplayUsername");
|
profileDisplayUsername=args.getString("profileDisplayUsername");
|
||||||
setTitle(getString(R.string.sk_lists_with_user, profileDisplayUsername));
|
setTitle(getString(R.string.sk_lists_with_user, profileDisplayUsername));
|
||||||
} else {
|
// setHasOptionsMenu(true);
|
||||||
setTitle(R.string.sk_your_lists);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,51 +60,20 @@ public class ListTimelinesFragment extends BaseRecyclerFragment<ListTimeline> im
|
|||||||
loadData();
|
loadData();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
// @Override
|
||||||
public void onDestroy() {
|
// public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||||
super.onDestroy();
|
// Button saveButton=new Button(getActivity());
|
||||||
if (pinnedUpdated) UiUtils.restartApp();
|
// saveButton.setText(R.string.save);
|
||||||
}
|
// saveButton.setOnClickListener(this::onSaveClick);
|
||||||
|
// LinearLayout wrap=new LinearLayout(getActivity());
|
||||||
@Override
|
// wrap.setOrientation(LinearLayout.HORIZONTAL);
|
||||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
// wrap.addView(saveButton, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
|
||||||
super.onViewCreated(view, savedInstanceState);
|
// wrap.setPadding(V.dp(16), V.dp(4), V.dp(16), V.dp(8));
|
||||||
list.addItemDecoration(new DividerItemDecoration(getActivity(), R.attr.colorPollVoted, 0.5f, 56, 16));
|
// wrap.setClipToPadding(false);
|
||||||
}
|
// MenuItem item=menu.add(R.string.save);
|
||||||
|
// item.setActionView(wrap);
|
||||||
@Override
|
// item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
|
||||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
// }
|
||||||
inflater.inflate(R.menu.menu_list, menu);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
|
||||||
if (item.getItemId() == R.id.create) {
|
|
||||||
ListTimelineEditor editor = new ListTimelineEditor(getContext());
|
|
||||||
new M3AlertDialogBuilder(getActivity())
|
|
||||||
.setTitle(R.string.sk_create_list_title)
|
|
||||||
.setIcon(R.drawable.ic_fluent_people_add_28_regular)
|
|
||||||
.setView(editor)
|
|
||||||
.setPositiveButton(R.string.sk_create, (d, which) -> {
|
|
||||||
new CreateList(editor.getTitle(), editor.getRepliesPolicy()).setCallback(new Callback<>() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(ListTimeline list) {
|
|
||||||
saveListMembership(list.id, true);
|
|
||||||
data.add(0, list);
|
|
||||||
adapter.notifyItemRangeInserted(0, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onError(ErrorResponse error) {
|
|
||||||
error.showToast(getContext());
|
|
||||||
}
|
|
||||||
}).exec(accountId);
|
|
||||||
})
|
|
||||||
.setNegativeButton(R.string.cancel, (d, which) -> {})
|
|
||||||
.show();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void saveListMembership(String listId, boolean isMember) {
|
private void saveListMembership(String listId, boolean isMember) {
|
||||||
userInList.put(listId, isMember);
|
userInList.put(listId, isMember);
|
||||||
@@ -165,30 +118,8 @@ public class ListTimelinesFragment extends BaseRecyclerFragment<ListTimeline> im
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFragmentResult(int reqCode, boolean listChanged, Bundle result){
|
protected RecyclerView.Adapter getAdapter() {
|
||||||
if (reqCode == LIST_CHANGED_RESULT && listChanged) {
|
return new ListsAdapter();
|
||||||
if (result.getBoolean("pinnedUpdated")) pinnedUpdated = true;
|
|
||||||
String listID = result.getString("listID");
|
|
||||||
for (int i = 0; i < data.size(); i++) {
|
|
||||||
ListTimeline item = data.get(i);
|
|
||||||
if (item.id.equals(listID)) {
|
|
||||||
if (result.getBoolean("deleted")) {
|
|
||||||
data.remove(i);
|
|
||||||
adapter.notifyItemRemoved(i);
|
|
||||||
} else {
|
|
||||||
item.title = result.getString("listTitle", item.title);
|
|
||||||
item.repliesPolicy = ListTimeline.RepliesPolicy.values()[result.getInt("repliesPolicy")];
|
|
||||||
adapter.notifyItemChanged(i);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected RecyclerView.Adapter<ListViewHolder> getAdapter() {
|
|
||||||
return adapter = new ListsAdapter();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -227,7 +158,7 @@ public class ListTimelinesFragment extends BaseRecyclerFragment<ListTimeline> im
|
|||||||
@Override
|
@Override
|
||||||
public void onBind(ListTimeline item) {
|
public void onBind(ListTimeline item) {
|
||||||
title.setText(item.title);
|
title.setText(item.title);
|
||||||
title.setCompoundDrawablesRelativeWithIntrinsicBounds(itemView.getContext().getDrawable(R.drawable.ic_fluent_people_list_24_regular), null, null, null);
|
title.setCompoundDrawablesRelativeWithIntrinsicBounds(itemView.getContext().getDrawable(R.drawable.ic_fluent_people_community_24_regular), null, null, null);
|
||||||
if (profileAccountId != null) {
|
if (profileAccountId != null) {
|
||||||
Boolean checked = userInList.get(item.id);
|
Boolean checked = userInList.get(item.id);
|
||||||
listToggle.setVisibility(View.VISIBLE);
|
listToggle.setVisibility(View.VISIBLE);
|
||||||
@@ -244,12 +175,7 @@ public class ListTimelinesFragment extends BaseRecyclerFragment<ListTimeline> im
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick() {
|
public void onClick() {
|
||||||
Bundle args=new Bundle();
|
UiUtils.openListTimeline(getActivity(), accountId, item);
|
||||||
args.putString("account", accountId);
|
|
||||||
args.putString("listID", item.id);
|
|
||||||
args.putString("listTitle", item.title);
|
|
||||||
args.putInt("repliesPolicy", item.repliesPolicy.ordinal());
|
|
||||||
Nav.goForResult(getActivity(), ListTimelineFragment.class, args, LIST_CHANGED_RESULT, ListTimelinesFragment.this);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public class NotificationsFragment extends MastodonToolbarFragment implements Sc
|
|||||||
private FrameLayout[] tabViews;
|
private FrameLayout[] tabViews;
|
||||||
private TabLayoutMediator tabLayoutMediator;
|
private TabLayoutMediator tabLayoutMediator;
|
||||||
|
|
||||||
private NotificationsListFragment allNotificationsFragment, mentionsFragment;
|
private NotificationsListFragment allNotificationsFragment, mentionsFragment, postsFragment;
|
||||||
|
|
||||||
private String accountID;
|
private String accountID;
|
||||||
|
|
||||||
@@ -74,26 +74,15 @@ public class NotificationsFragment extends MastodonToolbarFragment implements Sc
|
|||||||
@Override
|
@Override
|
||||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater){
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater){
|
||||||
inflater.inflate(R.menu.notifications, menu);
|
inflater.inflate(R.menu.notifications, menu);
|
||||||
menu.findItem(R.id.clear_notifications).setVisible(GlobalUserPreferences.enableDeleteNotifications);
|
|
||||||
UiUtils.enableOptionsMenuIcons(getActivity(), menu, R.id.follow_requests);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
if (item.getItemId() == R.id.follow_requests) {
|
if (item.getItemId() != R.id.follow_requests) return false;
|
||||||
Bundle args=new Bundle();
|
Bundle args=new Bundle();
|
||||||
args.putString("account", accountID);
|
args.putString("account", accountID);
|
||||||
Nav.go(getActivity(), FollowRequestsListFragment.class, args);
|
Nav.go(getActivity(), FollowRequestsListFragment.class, args);
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getItemId() == R.id.clear_notifications) {
|
|
||||||
UiUtils.confirmDeleteNotification(getActivity(), accountID, null, ()->{
|
|
||||||
for (int i = 0; i < tabViews.length; i++) {
|
|
||||||
getFragmentForPage(i).reload();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -102,14 +91,14 @@ public class NotificationsFragment extends MastodonToolbarFragment implements Sc
|
|||||||
|
|
||||||
tabLayout=view.findViewById(R.id.tabbar);
|
tabLayout=view.findViewById(R.id.tabbar);
|
||||||
pager=view.findViewById(R.id.pager);
|
pager=view.findViewById(R.id.pager);
|
||||||
UiUtils.reduceSwipeSensitivity(pager);
|
|
||||||
|
|
||||||
tabViews=new FrameLayout[2];
|
tabViews=new FrameLayout[3];
|
||||||
for(int i=0;i<tabViews.length;i++){
|
for(int i=0;i<tabViews.length;i++){
|
||||||
FrameLayout tabView=new FrameLayout(getActivity());
|
FrameLayout tabView=new FrameLayout(getActivity());
|
||||||
tabView.setId(switch(i){
|
tabView.setId(switch(i){
|
||||||
case 0 -> R.id.notifications_all;
|
case 0 -> R.id.notifications_all;
|
||||||
case 1 -> R.id.notifications_mentions;
|
case 1 -> R.id.notifications_mentions;
|
||||||
|
case 2 -> R.id.notifications_posts;
|
||||||
default -> throw new IllegalStateException("Unexpected value: "+i);
|
default -> throw new IllegalStateException("Unexpected value: "+i);
|
||||||
});
|
});
|
||||||
tabView.setVisibility(View.GONE);
|
tabView.setVisibility(View.GONE);
|
||||||
@@ -149,9 +138,15 @@ public class NotificationsFragment extends MastodonToolbarFragment implements Sc
|
|||||||
mentionsFragment=new NotificationsListFragment();
|
mentionsFragment=new NotificationsListFragment();
|
||||||
mentionsFragment.setArguments(args);
|
mentionsFragment.setArguments(args);
|
||||||
|
|
||||||
|
args=new Bundle(args);
|
||||||
|
args.putBoolean("onlyPosts", true);
|
||||||
|
postsFragment=new NotificationsListFragment();
|
||||||
|
postsFragment.setArguments(args);
|
||||||
|
|
||||||
getChildFragmentManager().beginTransaction()
|
getChildFragmentManager().beginTransaction()
|
||||||
.add(R.id.notifications_all, allNotificationsFragment)
|
.add(R.id.notifications_all, allNotificationsFragment)
|
||||||
.add(R.id.notifications_mentions, mentionsFragment)
|
.add(R.id.notifications_mentions, mentionsFragment)
|
||||||
|
.add(R.id.notifications_posts, postsFragment)
|
||||||
.commit();
|
.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,6 +156,7 @@ public class NotificationsFragment extends MastodonToolbarFragment implements Sc
|
|||||||
tab.setText(switch(position){
|
tab.setText(switch(position){
|
||||||
case 0 -> R.string.all_notifications;
|
case 0 -> R.string.all_notifications;
|
||||||
case 1 -> R.string.mentions;
|
case 1 -> R.string.mentions;
|
||||||
|
case 2 -> R.string.posts;
|
||||||
default -> throw new IllegalStateException("Unexpected value: "+position);
|
default -> throw new IllegalStateException("Unexpected value: "+position);
|
||||||
});
|
});
|
||||||
tab.view.textView.setAllCaps(true);
|
tab.view.textView.setAllCaps(true);
|
||||||
@@ -209,6 +205,7 @@ public class NotificationsFragment extends MastodonToolbarFragment implements Sc
|
|||||||
return switch(page){
|
return switch(page){
|
||||||
case 0 -> allNotificationsFragment;
|
case 0 -> allNotificationsFragment;
|
||||||
case 1 -> mentionsFragment;
|
case 1 -> mentionsFragment;
|
||||||
|
case 2 -> postsFragment;
|
||||||
default -> throw new IllegalStateException("Unexpected value: "+page);
|
default -> throw new IllegalStateException("Unexpected value: "+page);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -229,7 +226,7 @@ public class NotificationsFragment extends MastodonToolbarFragment implements Sc
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getItemCount(){
|
public int getItemCount(){
|
||||||
return 2;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ package org.joinmastodon.android.fragments;
|
|||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuInflater;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import com.squareup.otto.Subscribe;
|
import com.squareup.otto.Subscribe;
|
||||||
@@ -12,6 +10,7 @@ import org.joinmastodon.android.E;
|
|||||||
import org.joinmastodon.android.R;
|
import org.joinmastodon.android.R;
|
||||||
import org.joinmastodon.android.api.requests.markers.SaveMarkers;
|
import org.joinmastodon.android.api.requests.markers.SaveMarkers;
|
||||||
import org.joinmastodon.android.api.session.AccountSessionManager;
|
import org.joinmastodon.android.api.session.AccountSessionManager;
|
||||||
|
import org.joinmastodon.android.events.NotificationDeletedEvent;
|
||||||
import org.joinmastodon.android.events.PollUpdatedEvent;
|
import org.joinmastodon.android.events.PollUpdatedEvent;
|
||||||
import org.joinmastodon.android.events.RemoveAccountPostsEvent;
|
import org.joinmastodon.android.events.RemoveAccountPostsEvent;
|
||||||
import org.joinmastodon.android.model.Notification;
|
import org.joinmastodon.android.model.Notification;
|
||||||
@@ -21,7 +20,6 @@ import org.joinmastodon.android.ui.displayitems.AccountCardStatusDisplayItem;
|
|||||||
import org.joinmastodon.android.ui.displayitems.HeaderStatusDisplayItem;
|
import org.joinmastodon.android.ui.displayitems.HeaderStatusDisplayItem;
|
||||||
import org.joinmastodon.android.ui.displayitems.ImageStatusDisplayItem;
|
import org.joinmastodon.android.ui.displayitems.ImageStatusDisplayItem;
|
||||||
import org.joinmastodon.android.ui.displayitems.StatusDisplayItem;
|
import org.joinmastodon.android.ui.displayitems.StatusDisplayItem;
|
||||||
import org.joinmastodon.android.ui.utils.DiscoverInfoBannerHelper;
|
|
||||||
import org.joinmastodon.android.ui.utils.InsetStatusItemDecoration;
|
import org.joinmastodon.android.ui.utils.InsetStatusItemDecoration;
|
||||||
import org.parceler.Parcels;
|
import org.parceler.Parcels;
|
||||||
|
|
||||||
@@ -42,7 +40,6 @@ public class NotificationsListFragment extends BaseStatusListFragment<Notificati
|
|||||||
private boolean onlyMentions;
|
private boolean onlyMentions;
|
||||||
private boolean onlyPosts;
|
private boolean onlyPosts;
|
||||||
private String maxID;
|
private String maxID;
|
||||||
private final DiscoverInfoBannerHelper bannerHelper = new DiscoverInfoBannerHelper(DiscoverInfoBannerHelper.BannerType.POST_NOTIFICATIONS);
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState){
|
public void onCreate(Bundle savedInstanceState){
|
||||||
@@ -81,9 +78,9 @@ public class NotificationsListFragment extends BaseStatusListFragment<Notificati
|
|||||||
case FAVORITE -> getString(R.string.user_favorited);
|
case FAVORITE -> getString(R.string.user_favorited);
|
||||||
case POLL -> getString(R.string.poll_ended);
|
case POLL -> getString(R.string.poll_ended);
|
||||||
};
|
};
|
||||||
HeaderStatusDisplayItem titleItem=extraText!=null ? new HeaderStatusDisplayItem(n.id, n.account, n.createdAt, this, accountID, null, extraText, n, null) : null;
|
HeaderStatusDisplayItem titleItem=extraText!=null ? new HeaderStatusDisplayItem(n.id, n.account, n.createdAt, this, accountID, null, extraText) : null;
|
||||||
if(n.status!=null){
|
if(n.status!=null){
|
||||||
ArrayList<StatusDisplayItem> items=StatusDisplayItem.buildItems(this, n.status, accountID, n, knownAccounts, titleItem!=null, titleItem==null, n);
|
ArrayList<StatusDisplayItem> items=StatusDisplayItem.buildItems(this, n.status, accountID, n, knownAccounts, titleItem!=null, titleItem==null);
|
||||||
if(titleItem!=null){
|
if(titleItem!=null){
|
||||||
for(StatusDisplayItem item:items){
|
for(StatusDisplayItem item:items){
|
||||||
if(item instanceof ImageStatusDisplayItem imgItem){
|
if(item instanceof ImageStatusDisplayItem imgItem){
|
||||||
@@ -177,7 +174,6 @@ public class NotificationsListFragment extends BaseStatusListFragment<Notificati
|
|||||||
public void onViewCreated(View view, Bundle savedInstanceState){
|
public void onViewCreated(View view, Bundle savedInstanceState){
|
||||||
super.onViewCreated(view, savedInstanceState);
|
super.onViewCreated(view, savedInstanceState);
|
||||||
list.addItemDecoration(new InsetStatusItemDecoration(this));
|
list.addItemDecoration(new InsetStatusItemDecoration(this));
|
||||||
if (onlyPosts) bannerHelper.maybeAddBanner(contentWrap);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Notification getNotificationByID(String id){
|
private Notification getNotificationByID(String id){
|
||||||
@@ -214,7 +210,7 @@ public class NotificationsListFragment extends BaseStatusListFragment<Notificati
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeNotification(Notification n){
|
private void removeNotification(Notification n){
|
||||||
data.remove(n);
|
data.remove(n);
|
||||||
preloadedData.remove(n);
|
preloadedData.remove(n);
|
||||||
int index=-1;
|
int index=-1;
|
||||||
|
|||||||
@@ -1,82 +0,0 @@
|
|||||||
package org.joinmastodon.android.fragments;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.view.HapticFeedbackConstants;
|
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuInflater;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import org.joinmastodon.android.GlobalUserPreferences;
|
|
||||||
import org.joinmastodon.android.R;
|
|
||||||
import org.joinmastodon.android.model.TimelineDefinition;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public abstract class PinnableStatusListFragment extends StatusListFragment {
|
|
||||||
protected boolean pinnedUpdated;
|
|
||||||
protected List<TimelineDefinition> pinnedTimelines;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
pinnedTimelines = new ArrayList<>(GlobalUserPreferences.pinnedTimelines.getOrDefault(accountID, TimelineDefinition.DEFAULT_TIMELINES));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
|
||||||
super.onCreateOptionsMenu(menu, inflater);
|
|
||||||
updatePinButton(menu.findItem(R.id.pin));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected boolean isPinned() {
|
|
||||||
return pinnedTimelines.contains(makeTimelineDefinition());
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void updatePinButton(MenuItem pin) {
|
|
||||||
boolean pinned = isPinned();
|
|
||||||
pin.setIcon(pinned ?
|
|
||||||
R.drawable.ic_fluent_pin_24_filled :
|
|
||||||
R.drawable.ic_fluent_pin_24_regular);
|
|
||||||
pin.setTitle(pinned ? R.string.sk_unpin_timeline : R.string.sk_pin_timeline);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract TimelineDefinition makeTimelineDefinition();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
|
||||||
if (item.getItemId() == R.id.pin) {
|
|
||||||
togglePin(item);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return super.onOptionsItemSelected(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void togglePin(MenuItem pin) {
|
|
||||||
pinnedUpdated = true;
|
|
||||||
getToolbar().performHapticFeedback(HapticFeedbackConstants.CONTEXT_CLICK);
|
|
||||||
TimelineDefinition def = makeTimelineDefinition();
|
|
||||||
boolean pinned = isPinned();
|
|
||||||
if (pinned) pinnedTimelines.remove(def);
|
|
||||||
else pinnedTimelines.add(def);
|
|
||||||
Toast.makeText(getContext(), pinned ? R.string.sk_unpinned_timeline : R.string.sk_pinned_timeline, Toast.LENGTH_SHORT).show();
|
|
||||||
GlobalUserPreferences.pinnedTimelines.put(accountID, pinnedTimelines);
|
|
||||||
GlobalUserPreferences.save();
|
|
||||||
updatePinButton(pin);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Bundle getResultArgs() {
|
|
||||||
return new Bundle();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDestroy() {
|
|
||||||
super.onDestroy();
|
|
||||||
Bundle resultArgs = getResultArgs();
|
|
||||||
if (pinnedUpdated) {
|
|
||||||
resultArgs.putBoolean("pinnedUpdated", true);
|
|
||||||
setResult(true, resultArgs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -164,11 +164,6 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getPrefilledText() {
|
|
||||||
return account == null || AccountSessionManager.getInstance().isSelf(accountID, account)
|
|
||||||
? null : '@'+account.acct+' ';
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAttach(Activity activity){
|
public void onAttach(Activity activity){
|
||||||
super.onAttach(activity);
|
super.onAttach(activity);
|
||||||
@@ -241,7 +236,6 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
|
|||||||
tabViews[i]=tabView;
|
tabViews[i]=tabView;
|
||||||
}
|
}
|
||||||
|
|
||||||
UiUtils.reduceSwipeSensitivity(pager);
|
|
||||||
pager.setOffscreenPageLimit(5);
|
pager.setOffscreenPageLimit(5);
|
||||||
pager.setUserInputEnabled(!GlobalUserPreferences.disableSwipe);
|
pager.setUserInputEnabled(!GlobalUserPreferences.disableSwipe);
|
||||||
pager.setAdapter(new ProfilePagerAdapter());
|
pager.setAdapter(new ProfilePagerAdapter());
|
||||||
@@ -281,7 +275,6 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
|
|||||||
cover.setOnClickListener(this::onCoverClick);
|
cover.setOnClickListener(this::onCoverClick);
|
||||||
refreshLayout.setOnRefreshListener(this);
|
refreshLayout.setOnRefreshListener(this);
|
||||||
fab.setOnClickListener(this::onFabClick);
|
fab.setOnClickListener(this::onFabClick);
|
||||||
fab.setOnLongClickListener(v->UiUtils.pickAccountForCompose(getActivity(), accountID, getPrefilledText()));
|
|
||||||
|
|
||||||
if(loaded){
|
if(loaded){
|
||||||
bindHeaderView();
|
bindHeaderView();
|
||||||
@@ -295,11 +288,11 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
|
|||||||
followingBtn.setOnClickListener(this::onFollowersOrFollowingClick);
|
followingBtn.setOnClickListener(this::onFollowersOrFollowingClick);
|
||||||
|
|
||||||
username.setOnLongClickListener(v->{
|
username.setOnLongClickListener(v->{
|
||||||
String usernameString=account.acct;
|
String username=account.acct;
|
||||||
if(!usernameString.contains("@")){
|
if(!username.contains("@")){
|
||||||
usernameString+="@"+AccountSessionManager.getInstance().getAccount(accountID).domain;
|
username+="@"+AccountSessionManager.getInstance().getAccount(accountID).domain;
|
||||||
}
|
}
|
||||||
UiUtils.copyText(username, '@'+usernameString);
|
UiUtils.copyText(getActivity(), '@'+username);
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -556,28 +549,21 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
|
|||||||
if(relationship==null && !isOwnProfile)
|
if(relationship==null && !isOwnProfile)
|
||||||
return;
|
return;
|
||||||
inflater.inflate(isOwnProfile ? R.menu.profile_own : R.menu.profile, menu);
|
inflater.inflate(isOwnProfile ? R.menu.profile_own : R.menu.profile, menu);
|
||||||
UiUtils.enableOptionsMenuIcons(getActivity(), menu, R.id.bookmarks, R.id.followed_hashtags);
|
menu.findItem(R.id.share).setTitle(getString(R.string.share_user, account.getDisplayUsername()));
|
||||||
menu.findItem(R.id.share).setTitle(getString(R.string.share_user, account.getShortUsername()));
|
|
||||||
if(isOwnProfile)
|
if(isOwnProfile)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
MenuItem mute = menu.findItem(R.id.mute);
|
menu.findItem(R.id.mute).setTitle(getString(relationship.muting ? R.string.unmute_user : R.string.mute_user, account.getDisplayUsername()));
|
||||||
mute.setTitle(getString(relationship.muting ? R.string.unmute_user : R.string.mute_user, account.getShortUsername()));
|
menu.findItem(R.id.block).setTitle(getString(relationship.blocking ? R.string.unblock_user : R.string.block_user, account.getDisplayUsername()));
|
||||||
mute.setIcon(relationship.muting ? R.drawable.ic_fluent_speaker_0_24_regular : R.drawable.ic_fluent_speaker_off_24_regular);
|
menu.findItem(R.id.report).setTitle(getString(R.string.report_user, account.getDisplayUsername()));
|
||||||
UiUtils.insetPopupMenuIcon(getContext(), mute);
|
MenuItem manageUserLists=menu.findItem(R.id.manage_user_lists);
|
||||||
|
|
||||||
menu.findItem(R.id.block).setTitle(getString(relationship.blocking ? R.string.unblock_user : R.string.block_user, account.getShortUsername()));
|
|
||||||
menu.findItem(R.id.report).setTitle(getString(R.string.report_user, account.getShortUsername()));
|
|
||||||
menu.findItem(R.id.manage_user_lists).setVisible(relationship.following);
|
|
||||||
menu.findItem(R.id.soft_block).setVisible(relationship.followedBy && !relationship.following);
|
|
||||||
if(relationship.following) {
|
if(relationship.following) {
|
||||||
MenuItem hideBoosts = menu.findItem(R.id.hide_boosts);
|
menu.findItem(R.id.hide_boosts).setTitle(getString(relationship.showingReblogs ? R.string.hide_boosts_from_user : R.string.show_boosts_from_user, account.getDisplayUsername()));
|
||||||
hideBoosts.setTitle(getString(relationship.showingReblogs ? R.string.hide_boosts_from_user : R.string.show_boosts_from_user, account.getShortUsername()));
|
manageUserLists.setTitle(getString(R.string.sk_lists_with_user, account.getDisplayUsername()));
|
||||||
hideBoosts.setIcon(relationship.showingReblogs ? R.drawable.ic_fluent_arrow_repeat_all_off_24_regular : R.drawable.ic_fluent_arrow_repeat_all_24_regular);
|
manageUserLists.setVisible(true);
|
||||||
UiUtils.insetPopupMenuIcon(getContext(), hideBoosts);
|
|
||||||
menu.findItem(R.id.manage_user_lists).setTitle(getString(R.string.sk_lists_with_user, account.getShortUsername()));
|
|
||||||
}else {
|
}else {
|
||||||
menu.findItem(R.id.hide_boosts).setVisible(false);
|
menu.findItem(R.id.hide_boosts).setVisible(false);
|
||||||
|
manageUserLists.setVisible(false);
|
||||||
}
|
}
|
||||||
if(!account.isLocal())
|
if(!account.isLocal())
|
||||||
menu.findItem(R.id.block_domain).setTitle(getString(relationship.domainBlocking ? R.string.unblock_domain : R.string.block_domain, account.getDomain()));
|
menu.findItem(R.id.block_domain).setTitle(getString(relationship.domainBlocking ? R.string.unblock_domain : R.string.block_domain, account.getDomain()));
|
||||||
@@ -597,8 +583,6 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
|
|||||||
confirmToggleMuted();
|
confirmToggleMuted();
|
||||||
}else if(id==R.id.block){
|
}else if(id==R.id.block){
|
||||||
confirmToggleBlocked();
|
confirmToggleBlocked();
|
||||||
}else if(id==R.id.soft_block){
|
|
||||||
confirmSoftBlockUser();
|
|
||||||
}else if(id==R.id.report){
|
}else if(id==R.id.report){
|
||||||
Bundle args=new Bundle();
|
Bundle args=new Bundle();
|
||||||
args.putString("account", accountID);
|
args.putString("account", accountID);
|
||||||
@@ -637,19 +621,13 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
|
|||||||
}else if(id==R.id.manage_user_lists){
|
}else if(id==R.id.manage_user_lists){
|
||||||
final Bundle args=new Bundle();
|
final Bundle args=new Bundle();
|
||||||
args.putString("account", accountID);
|
args.putString("account", accountID);
|
||||||
if (!isOwnProfile) {
|
args.putString("profileAccount", profileAccountID);
|
||||||
args.putString("profileAccount", profileAccountID);
|
args.putString("profileDisplayUsername", account.getDisplayUsername());
|
||||||
args.putString("profileDisplayUsername", account.getDisplayUsername());
|
|
||||||
}
|
|
||||||
Nav.go(getActivity(), ListTimelinesFragment.class, args);
|
Nav.go(getActivity(), ListTimelinesFragment.class, args);
|
||||||
}else if(id==R.id.followed_hashtags){
|
}else if(id==R.id.followed_hashtags){
|
||||||
Bundle args=new Bundle();
|
Bundle args=new Bundle();
|
||||||
args.putString("account", accountID);
|
args.putString("account", accountID);
|
||||||
Nav.go(getActivity(), FollowedHashtagsFragment.class, args);
|
Nav.go(getActivity(), FollowedHashtagsFragment.class, args);
|
||||||
}else if(id==R.id.scheduled){
|
|
||||||
Bundle args=new Bundle();
|
|
||||||
args.putString("account", accountID);
|
|
||||||
Nav.go(getActivity(), ScheduledStatusListFragment.class, args);
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -905,10 +883,6 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
|
|||||||
UiUtils.confirmToggleBlockUser(getActivity(), accountID, account, relationship.blocking, this::updateRelationship);
|
UiUtils.confirmToggleBlockUser(getActivity(), accountID, account, relationship.blocking, this::updateRelationship);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void confirmSoftBlockUser(){
|
|
||||||
UiUtils.confirmSoftBlockUser(getActivity(), accountID, account, this::updateRelationship);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateRelationship(Relationship r){
|
private void updateRelationship(Relationship r){
|
||||||
relationship=r;
|
relationship=r;
|
||||||
updateRelationship();
|
updateRelationship();
|
||||||
@@ -965,7 +939,9 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
|
|||||||
private void onFabClick(View v){
|
private void onFabClick(View v){
|
||||||
Bundle args=new Bundle();
|
Bundle args=new Bundle();
|
||||||
args.putString("account", accountID);
|
args.putString("account", accountID);
|
||||||
if(getPrefilledText() != null) args.putString("prefilledText", getPrefilledText());
|
if(!AccountSessionManager.getInstance().isSelf(accountID, account)){
|
||||||
|
args.putString("prefilledText", '@'+account.acct+' ');
|
||||||
|
}
|
||||||
Nav.go(getActivity(), ComposeFragment.class, args);
|
Nav.go(getActivity(), ComposeFragment.class, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,171 +0,0 @@
|
|||||||
package org.joinmastodon.android.fragments;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.ImageButton;
|
|
||||||
|
|
||||||
import com.squareup.otto.Subscribe;
|
|
||||||
|
|
||||||
import org.joinmastodon.android.E;
|
|
||||||
import org.joinmastodon.android.R;
|
|
||||||
import org.joinmastodon.android.api.requests.statuses.CreateStatus;
|
|
||||||
import org.joinmastodon.android.api.requests.statuses.GetScheduledStatuses;
|
|
||||||
import org.joinmastodon.android.events.ScheduledStatusCreatedEvent;
|
|
||||||
import org.joinmastodon.android.events.ScheduledStatusDeletedEvent;
|
|
||||||
import org.joinmastodon.android.model.HeaderPaginationList;
|
|
||||||
import org.joinmastodon.android.model.ScheduledStatus;
|
|
||||||
import org.joinmastodon.android.model.Status;
|
|
||||||
import org.joinmastodon.android.ui.displayitems.StatusDisplayItem;
|
|
||||||
import org.joinmastodon.android.ui.utils.UiUtils;
|
|
||||||
import org.parceler.Parcels;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import me.grishka.appkit.Nav;
|
|
||||||
import me.grishka.appkit.api.SimpleCallback;
|
|
||||||
|
|
||||||
public class ScheduledStatusListFragment extends BaseStatusListFragment<ScheduledStatus> {
|
|
||||||
private String nextMaxID;
|
|
||||||
private ImageButton fab;
|
|
||||||
private static final int SCHEDULED_STATUS_LIST_OPENED = 161;
|
|
||||||
|
|
||||||
public ScheduledStatusListFragment() {
|
|
||||||
setListLayoutId(R.layout.recycler_fragment_with_fab);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate(Bundle savedInstanceState){
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
E.register(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDestroy(){
|
|
||||||
super.onDestroy();
|
|
||||||
E.unregister(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAttach(Activity activity){
|
|
||||||
super.onAttach(activity);
|
|
||||||
setTitle(R.string.sk_unsent_posts);
|
|
||||||
loadData();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
|
||||||
super.onViewCreated(view, savedInstanceState);
|
|
||||||
fab=view.findViewById(R.id.fab);
|
|
||||||
Bundle args=new Bundle();
|
|
||||||
args.putString("account", accountID);
|
|
||||||
args.putSerializable("scheduledAt", CreateStatus.getDraftInstant());
|
|
||||||
fab.setOnClickListener(v -> Nav.go(getActivity(), ComposeFragment.class, args));
|
|
||||||
fab.setOnLongClickListener(v -> UiUtils.pickAccountForCompose(getActivity(), accountID, args));
|
|
||||||
if (getArguments().getBoolean("hide_fab", false)) fab.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected List<StatusDisplayItem> buildDisplayItems(ScheduledStatus s) {
|
|
||||||
return StatusDisplayItem.buildItems(this, s.toStatus(), accountID, s, knownAccounts, false, false, null, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void addAccountToKnown(ScheduledStatus s) {}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onItemClick(String id) {
|
|
||||||
final Bundle args=new Bundle();
|
|
||||||
args.putString("account", accountID);
|
|
||||||
ScheduledStatus scheduledStatus = getStatusByID(id);
|
|
||||||
Status status = scheduledStatus.toStatus();
|
|
||||||
args.putParcelable("scheduledStatus", Parcels.wrap(scheduledStatus));
|
|
||||||
args.putParcelable("editStatus", Parcels.wrap(status));
|
|
||||||
args.putString("sourceText", status.text);
|
|
||||||
args.putString("sourceSpoiler", status.spoilerText);
|
|
||||||
args.putBoolean("redraftStatus", true);
|
|
||||||
setResult(true, null);
|
|
||||||
|
|
||||||
// closing this scheduled status list if another status list is opened from compose fragment
|
|
||||||
Nav.goForResult(getActivity(), ComposeFragment.class, args, SCHEDULED_STATUS_LIST_OPENED, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFragmentResult(int reqCode, boolean success, Bundle result) {
|
|
||||||
if (reqCode == SCHEDULED_STATUS_LIST_OPENED && success && getActivity() != null) {
|
|
||||||
Nav.finish(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void doLoadData(int offset, int count){
|
|
||||||
currentRequest=new GetScheduledStatuses(offset==0 ? null : nextMaxID, count)
|
|
||||||
.setCallback(new SimpleCallback<>(this){
|
|
||||||
@Override
|
|
||||||
public void onSuccess(HeaderPaginationList<ScheduledStatus> result){
|
|
||||||
if(result.nextPageUri!=null)
|
|
||||||
nextMaxID=result.nextPageUri.getQueryParameter("max_id");
|
|
||||||
else
|
|
||||||
nextMaxID=null;
|
|
||||||
onDataLoaded(result, nextMaxID!=null);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.exec(accountID);
|
|
||||||
}
|
|
||||||
|
|
||||||
// copied from StatusListFragment.java
|
|
||||||
@Subscribe
|
|
||||||
public void onScheduledStatusDeleted(ScheduledStatusDeletedEvent ev){
|
|
||||||
if(!ev.accountID.equals(accountID)) return;
|
|
||||||
ScheduledStatus status=getStatusByID(ev.id);
|
|
||||||
if(status==null) return;
|
|
||||||
removeStatus(status);
|
|
||||||
}
|
|
||||||
|
|
||||||
// copied from StatusListFragment.java
|
|
||||||
@Subscribe
|
|
||||||
public void onScheduledStatusCreated(ScheduledStatusCreatedEvent ev){
|
|
||||||
if(!ev.accountID.equals(accountID)) return;
|
|
||||||
prependItems(Collections.singletonList(ev.scheduledStatus), true);
|
|
||||||
scrollToTop();
|
|
||||||
}
|
|
||||||
|
|
||||||
// copied from StatusListFragment.java
|
|
||||||
protected void removeStatus(ScheduledStatus status){
|
|
||||||
data.remove(status);
|
|
||||||
preloadedData.remove(status);
|
|
||||||
int index=-1;
|
|
||||||
for(int i=0;i<displayItems.size();i++){
|
|
||||||
if(status.id.equals(displayItems.get(i).parentID)){
|
|
||||||
index=i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(index==-1)
|
|
||||||
return;
|
|
||||||
int lastIndex;
|
|
||||||
for(lastIndex=index;lastIndex<displayItems.size();lastIndex++){
|
|
||||||
if(!displayItems.get(lastIndex).parentID.equals(status.id))
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
displayItems.subList(index, lastIndex).clear();
|
|
||||||
adapter.notifyItemRangeRemoved(index, lastIndex-index);
|
|
||||||
}
|
|
||||||
|
|
||||||
// copied from StatusListFragment.java
|
|
||||||
protected ScheduledStatus getStatusByID(String id){
|
|
||||||
for(ScheduledStatus s:data){
|
|
||||||
if(s.id.equals(id)){
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for(ScheduledStatus s:preloadedData){
|
|
||||||
if(s.id.equals(id)){
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -9,7 +9,7 @@ import android.graphics.Canvas;
|
|||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.TypedValue;
|
import android.provider.Settings;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
@@ -21,7 +21,6 @@ import android.view.animation.LinearInterpolator;
|
|||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.PopupMenu;
|
import android.widget.PopupMenu;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.RadioButton;
|
import android.widget.RadioButton;
|
||||||
@@ -44,16 +43,12 @@ import org.joinmastodon.android.api.requests.oauth.RevokeOauthToken;
|
|||||||
import org.joinmastodon.android.api.session.AccountSession;
|
import org.joinmastodon.android.api.session.AccountSession;
|
||||||
import org.joinmastodon.android.api.session.AccountSessionManager;
|
import org.joinmastodon.android.api.session.AccountSessionManager;
|
||||||
import org.joinmastodon.android.events.SelfUpdateStateChangedEvent;
|
import org.joinmastodon.android.events.SelfUpdateStateChangedEvent;
|
||||||
import org.joinmastodon.android.fragments.onboarding.InstanceRulesFragment;
|
|
||||||
import org.joinmastodon.android.model.Instance;
|
|
||||||
import org.joinmastodon.android.model.PushNotification;
|
import org.joinmastodon.android.model.PushNotification;
|
||||||
import org.joinmastodon.android.model.PushSubscription;
|
import org.joinmastodon.android.model.PushSubscription;
|
||||||
import org.joinmastodon.android.ui.M3AlertDialogBuilder;
|
import org.joinmastodon.android.ui.M3AlertDialogBuilder;
|
||||||
import org.joinmastodon.android.ui.OutlineProviders;
|
import org.joinmastodon.android.ui.OutlineProviders;
|
||||||
import org.joinmastodon.android.ui.utils.UiUtils;
|
import org.joinmastodon.android.ui.utils.UiUtils;
|
||||||
import org.joinmastodon.android.ui.views.TextInputFrameLayout;
|
|
||||||
import org.joinmastodon.android.updater.GithubSelfUpdater;
|
import org.joinmastodon.android.updater.GithubSelfUpdater;
|
||||||
import org.parceler.Parcels;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
@@ -63,8 +58,6 @@ import androidx.annotation.NonNull;
|
|||||||
import androidx.annotation.StringRes;
|
import androidx.annotation.StringRes;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import me.grishka.appkit.Nav;
|
|
||||||
import me.grishka.appkit.api.Callback;
|
import me.grishka.appkit.api.Callback;
|
||||||
import me.grishka.appkit.api.ErrorResponse;
|
import me.grishka.appkit.api.ErrorResponse;
|
||||||
import me.grishka.appkit.imageloader.ImageCache;
|
import me.grishka.appkit.imageloader.ImageCache;
|
||||||
@@ -83,8 +76,7 @@ public class SettingsFragment extends MastodonToolbarFragment{
|
|||||||
private PushSubscription pushSubscription;
|
private PushSubscription pushSubscription;
|
||||||
|
|
||||||
private ImageView themeTransitionWindowView;
|
private ImageView themeTransitionWindowView;
|
||||||
private TextItem checkForUpdateItem, clearImageCacheItem;
|
private TextItem checkForUpdateItem;
|
||||||
private ImageCache imageCache;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState){
|
public void onCreate(Bundle savedInstanceState){
|
||||||
@@ -92,11 +84,8 @@ public class SettingsFragment extends MastodonToolbarFragment{
|
|||||||
if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.N)
|
if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.N)
|
||||||
setRetainInstance(true);
|
setRetainInstance(true);
|
||||||
setTitle(R.string.settings);
|
setTitle(R.string.settings);
|
||||||
imageCache = ImageCache.getInstance(getActivity());
|
|
||||||
accountID=getArguments().getString("account");
|
accountID=getArguments().getString("account");
|
||||||
AccountSession session=AccountSessionManager.getInstance().getAccount(accountID);
|
AccountSession session=AccountSessionManager.getInstance().getAccount(accountID);
|
||||||
Instance instance = AccountSessionManager.getInstance().getInstanceInfo(session.domain);
|
|
||||||
String instanceName = UiUtils.getInstanceName(accountID);
|
|
||||||
|
|
||||||
if(GithubSelfUpdater.needSelfUpdating()){
|
if(GithubSelfUpdater.needSelfUpdating()){
|
||||||
GithubSelfUpdater updater=GithubSelfUpdater.getInstance();
|
GithubSelfUpdater updater=GithubSelfUpdater.getInstance();
|
||||||
@@ -109,6 +98,10 @@ public class SettingsFragment extends MastodonToolbarFragment{
|
|||||||
items.add(new HeaderItem(R.string.settings_theme));
|
items.add(new HeaderItem(R.string.settings_theme));
|
||||||
items.add(themeItem=new ThemeItem());
|
items.add(themeItem=new ThemeItem());
|
||||||
items.add(new SwitchItem(R.string.theme_true_black, R.drawable.ic_fluent_dark_theme_24_regular, GlobalUserPreferences.trueBlackTheme, this::onTrueBlackThemeChanged));
|
items.add(new SwitchItem(R.string.theme_true_black, R.drawable.ic_fluent_dark_theme_24_regular, GlobalUserPreferences.trueBlackTheme, this::onTrueBlackThemeChanged));
|
||||||
|
items.add(new SwitchItem(R.string.sk_disable_marquee, R.drawable.ic_fluent_text_more_24_regular, GlobalUserPreferences.disableMarquee, i->{
|
||||||
|
GlobalUserPreferences.disableMarquee=i.checked;
|
||||||
|
GlobalUserPreferences.save();
|
||||||
|
}));
|
||||||
items.add(new ButtonItem(R.string.sk_settings_color_palette, R.drawable.ic_fluent_color_24_regular, b->{
|
items.add(new ButtonItem(R.string.sk_settings_color_palette, R.drawable.ic_fluent_color_24_regular, b->{
|
||||||
PopupMenu popupMenu=new PopupMenu(getActivity(), b, Gravity.CENTER_HORIZONTAL);
|
PopupMenu popupMenu=new PopupMenu(getActivity(), b, Gravity.CENTER_HORIZONTAL);
|
||||||
popupMenu.inflate(R.menu.color_palettes);
|
popupMenu.inflate(R.menu.color_palettes);
|
||||||
@@ -125,44 +118,9 @@ public class SettingsFragment extends MastodonToolbarFragment{
|
|||||||
case BROWN -> R.string.sk_color_palette_brown;
|
case BROWN -> R.string.sk_color_palette_brown;
|
||||||
case RED -> R.string.sk_color_palette_red;
|
case RED -> R.string.sk_color_palette_red;
|
||||||
case YELLOW -> R.string.sk_color_palette_yellow;
|
case YELLOW -> R.string.sk_color_palette_yellow;
|
||||||
|
case NORD -> R.string.sk_color_palette_nord;
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
items.add(new ButtonItem(R.string.sk_settings_publish_button_text, R.drawable.ic_fluent_send_24_regular, b->{
|
|
||||||
updatePublishText(b);
|
|
||||||
|
|
||||||
b.setOnClickListener(l->{
|
|
||||||
TextInputFrameLayout input = new TextInputFrameLayout(
|
|
||||||
getContext(),
|
|
||||||
getString(R.string.publish),
|
|
||||||
GlobalUserPreferences.publishButtonText.trim()
|
|
||||||
);
|
|
||||||
new M3AlertDialogBuilder(getContext()).setTitle(R.string.sk_settings_publish_button_text_title).setView(input)
|
|
||||||
.setPositiveButton(R.string.save, (d, which) -> {
|
|
||||||
GlobalUserPreferences.publishButtonText = input.getEditText().getText().toString().trim();
|
|
||||||
GlobalUserPreferences.save();
|
|
||||||
updatePublishText(b);
|
|
||||||
})
|
|
||||||
.setNeutralButton(R.string.clear, (d, which) -> {
|
|
||||||
GlobalUserPreferences.publishButtonText = "";
|
|
||||||
GlobalUserPreferences.save();
|
|
||||||
updatePublishText(b);
|
|
||||||
})
|
|
||||||
.setNegativeButton(R.string.cancel, (d, which) -> {})
|
|
||||||
.show();
|
|
||||||
});
|
|
||||||
}));
|
|
||||||
items.add(new SwitchItem(R.string.sk_settings_uniform_icon_for_notifications, R.drawable.ic_ntf_logo, GlobalUserPreferences.uniformNotificationIcon, i->{
|
|
||||||
GlobalUserPreferences.uniformNotificationIcon=i.checked;
|
|
||||||
GlobalUserPreferences.save();
|
|
||||||
}));
|
|
||||||
items.add(new SwitchItem(R.string.sk_disable_marquee, R.drawable.ic_fluent_text_more_24_regular, GlobalUserPreferences.disableMarquee, i->{
|
|
||||||
GlobalUserPreferences.disableMarquee=i.checked;
|
|
||||||
GlobalUserPreferences.save();
|
|
||||||
}));
|
|
||||||
items.add(new SwitchItem(R.string.sk_settings_reduce_motion, R.drawable.ic_fluent_star_emphasis_24_regular, GlobalUserPreferences.reduceMotion, i->{
|
|
||||||
GlobalUserPreferences.reduceMotion=i.checked;
|
|
||||||
GlobalUserPreferences.save();
|
|
||||||
}));
|
|
||||||
|
|
||||||
items.add(new HeaderItem(R.string.settings_behavior));
|
items.add(new HeaderItem(R.string.settings_behavior));
|
||||||
items.add(new SwitchItem(R.string.settings_gif, R.drawable.ic_fluent_gif_24_regular, GlobalUserPreferences.playGifs, i->{
|
items.add(new SwitchItem(R.string.settings_gif, R.drawable.ic_fluent_gif_24_regular, GlobalUserPreferences.playGifs, i->{
|
||||||
@@ -186,24 +144,8 @@ public class SettingsFragment extends MastodonToolbarFragment{
|
|||||||
GlobalUserPreferences.save();
|
GlobalUserPreferences.save();
|
||||||
needAppRestart=true;
|
needAppRestart=true;
|
||||||
}));
|
}));
|
||||||
items.add(new SwitchItem(R.string.sk_enable_delete_notifications, R.drawable.ic_fluent_mail_inbox_dismiss_24_regular, GlobalUserPreferences.enableDeleteNotifications, i->{
|
items.add(new SwitchItem(R.string.sk_settings_show_differentiated_notification_icons, R.drawable.ic_fluent_earth_24_regular, GlobalUserPreferences.showDifferentiatedPushNoticationIcons, this::onNotificationStyleChanged));
|
||||||
GlobalUserPreferences.enableDeleteNotifications=i.checked;
|
|
||||||
GlobalUserPreferences.save();
|
|
||||||
needAppRestart=true;
|
|
||||||
}));
|
|
||||||
items.add(new SwitchItem(R.string.sk_settings_disable_alt_text_reminder, R.drawable.ic_fluent_image_alt_text_24_regular, GlobalUserPreferences.disableAltTextReminder, i->{
|
|
||||||
GlobalUserPreferences.disableAltTextReminder=i.checked;
|
|
||||||
GlobalUserPreferences.save();
|
|
||||||
}));
|
|
||||||
items.add(new SwitchItem(R.string.sk_settings_translate_only_opened, R.drawable.ic_fluent_translate_24_regular, GlobalUserPreferences.translateButtonOpenedOnly, i->{
|
|
||||||
GlobalUserPreferences.translateButtonOpenedOnly=i.checked;
|
|
||||||
GlobalUserPreferences.save();
|
|
||||||
needAppRestart=true;
|
|
||||||
}));
|
|
||||||
boolean translationAvailable = instance.v2 != null && instance.v2.configuration.translation != null && instance.v2.configuration.translation.enabled;
|
|
||||||
items.add(new SmallTextItem(getString(translationAvailable ?
|
|
||||||
R.string.sk_settings_translation_availability_note_available :
|
|
||||||
R.string.sk_settings_translation_availability_note_unavailable, instanceName)));
|
|
||||||
|
|
||||||
items.add(new HeaderItem(R.string.home_timeline));
|
items.add(new HeaderItem(R.string.home_timeline));
|
||||||
items.add(new SwitchItem(R.string.sk_settings_show_replies, R.drawable.ic_fluent_chat_multiple_24_regular, GlobalUserPreferences.showReplies, i->{
|
items.add(new SwitchItem(R.string.sk_settings_show_replies, R.drawable.ic_fluent_chat_multiple_24_regular, GlobalUserPreferences.showReplies, i->{
|
||||||
@@ -218,6 +160,11 @@ public class SettingsFragment extends MastodonToolbarFragment{
|
|||||||
GlobalUserPreferences.loadNewPosts=i.checked;
|
GlobalUserPreferences.loadNewPosts=i.checked;
|
||||||
GlobalUserPreferences.save();
|
GlobalUserPreferences.save();
|
||||||
}));
|
}));
|
||||||
|
items.add(new SwitchItem(R.string.sk_settings_show_federated_timeline, R.drawable.ic_fluent_earth_24_regular, GlobalUserPreferences.showFederatedTimeline, i->{
|
||||||
|
GlobalUserPreferences.showFederatedTimeline=i.checked;
|
||||||
|
GlobalUserPreferences.save();
|
||||||
|
needAppRestart=true;
|
||||||
|
}));
|
||||||
|
|
||||||
items.add(new HeaderItem(R.string.settings_notifications));
|
items.add(new HeaderItem(R.string.settings_notifications));
|
||||||
items.add(notificationPolicyItem=new NotificationPolicyItem());
|
items.add(notificationPolicyItem=new NotificationPolicyItem());
|
||||||
@@ -225,52 +172,30 @@ public class SettingsFragment extends MastodonToolbarFragment{
|
|||||||
items.add(new SwitchItem(R.string.notify_favorites, R.drawable.ic_fluent_star_24_regular, pushSubscription.alerts.favourite, i->onNotificationsChanged(PushNotification.Type.FAVORITE, i.checked)));
|
items.add(new SwitchItem(R.string.notify_favorites, R.drawable.ic_fluent_star_24_regular, pushSubscription.alerts.favourite, i->onNotificationsChanged(PushNotification.Type.FAVORITE, i.checked)));
|
||||||
items.add(new SwitchItem(R.string.notify_follow, R.drawable.ic_fluent_person_add_24_regular, pushSubscription.alerts.follow, i->onNotificationsChanged(PushNotification.Type.FOLLOW, i.checked)));
|
items.add(new SwitchItem(R.string.notify_follow, R.drawable.ic_fluent_person_add_24_regular, pushSubscription.alerts.follow, i->onNotificationsChanged(PushNotification.Type.FOLLOW, i.checked)));
|
||||||
items.add(new SwitchItem(R.string.notify_reblog, R.drawable.ic_fluent_arrow_repeat_all_24_regular, pushSubscription.alerts.reblog, i->onNotificationsChanged(PushNotification.Type.REBLOG, i.checked)));
|
items.add(new SwitchItem(R.string.notify_reblog, R.drawable.ic_fluent_arrow_repeat_all_24_regular, pushSubscription.alerts.reblog, i->onNotificationsChanged(PushNotification.Type.REBLOG, i.checked)));
|
||||||
items.add(new SwitchItem(R.string.notify_mention, R.drawable.ic_fluent_mention_24_regular, pushSubscription.alerts.mention, i->onNotificationsChanged(PushNotification.Type.MENTION, i.checked)));
|
items.add(new SwitchItem(R.string.notify_mention, R.drawable.ic_at_symbol, pushSubscription.alerts.mention, i->onNotificationsChanged(PushNotification.Type.MENTION, i.checked)));
|
||||||
items.add(new SwitchItem(R.string.sk_notify_posts, R.drawable.ic_fluent_alert_24_regular, pushSubscription.alerts.status, i->onNotificationsChanged(PushNotification.Type.STATUS, i.checked)));
|
items.add(new SwitchItem(R.string.sk_notify_posts, R.drawable.ic_fluent_alert_24_regular, pushSubscription.alerts.status, i->onNotificationsChanged(PushNotification.Type.STATUS, i.checked)));
|
||||||
items.add(new SwitchItem(R.string.sk_settings_single_notification, R.drawable.ic_fluent_convert_range_24_regular, GlobalUserPreferences.keepOnlyLatestNotification, i->{
|
|
||||||
GlobalUserPreferences.keepOnlyLatestNotification=i.checked;
|
|
||||||
GlobalUserPreferences.save();
|
|
||||||
}));
|
|
||||||
|
|
||||||
items.add(new HeaderItem(R.string.settings_account));
|
items.add(new HeaderItem(R.string.settings_boring));
|
||||||
items.add(new TextItem(R.string.sk_settings_profile, ()->UiUtils.launchWebBrowser(getActivity(), "https://"+session.domain+"/settings/profile"), R.drawable.ic_fluent_open_24_regular));
|
items.add(new TextItem(R.string.settings_account, ()->UiUtils.launchWebBrowser(getActivity(), "https://"+session.domain+"/auth/edit")));
|
||||||
items.add(new TextItem(R.string.sk_settings_posting, ()->UiUtils.launchWebBrowser(getActivity(), "https://"+session.domain+"/settings/preferences/other"), R.drawable.ic_fluent_open_24_regular));
|
items.add(new TextItem(R.string.settings_tos, ()->UiUtils.launchWebBrowser(getActivity(), "https://"+session.domain+"/terms")));
|
||||||
items.add(new TextItem(R.string.sk_settings_filters, ()->UiUtils.launchWebBrowser(getActivity(), "https://"+session.domain+"/filters"), R.drawable.ic_fluent_open_24_regular));
|
items.add(new TextItem(R.string.settings_privacy_policy, ()->UiUtils.launchWebBrowser(getActivity(), "https://"+session.domain+"/terms")));
|
||||||
items.add(new TextItem(R.string.sk_settings_auth, ()->UiUtils.launchWebBrowser(getActivity(), "https://"+session.domain+"/auth/edit"), R.drawable.ic_fluent_open_24_regular));
|
|
||||||
|
|
||||||
items.add(new HeaderItem(instanceName));
|
items.add(new RedHeaderItem(R.string.settings_spicy));
|
||||||
items.add(new TextItem(R.string.sk_settings_rules, ()->{
|
|
||||||
Bundle args=new Bundle();
|
|
||||||
args.putParcelable("instance", Parcels.wrap(instance));
|
|
||||||
Nav.go(getActivity(), InstanceRulesFragment.class, args);
|
|
||||||
}, R.drawable.ic_fluent_task_list_ltr_24_regular));
|
|
||||||
items.add(new TextItem(R.string.sk_settings_about_instance , ()->UiUtils.launchWebBrowser(getActivity(), "https://"+session.domain+"/about"), R.drawable.ic_fluent_info_24_regular));
|
|
||||||
items.add(new TextItem(R.string.settings_tos, ()->UiUtils.launchWebBrowser(getActivity(), "https://"+session.domain+"/terms"), R.drawable.ic_fluent_open_24_regular));
|
|
||||||
items.add(new TextItem(R.string.settings_privacy_policy, ()->UiUtils.launchWebBrowser(getActivity(), "https://"+session.domain+"/terms"), R.drawable.ic_fluent_open_24_regular));
|
|
||||||
items.add(new TextItem(R.string.log_out, this::confirmLogOut, R.drawable.ic_fluent_sign_out_24_regular));
|
|
||||||
|
|
||||||
items.add(new HeaderItem(R.string.sk_settings_about));
|
|
||||||
items.add(new TextItem(R.string.sk_settings_contribute, ()->UiUtils.launchWebBrowser(getActivity(), "https://github.com/sk22/megalodon"), R.drawable.ic_fluent_open_24_regular));
|
|
||||||
items.add(new TextItem(R.string.sk_settings_donate, ()->UiUtils.launchWebBrowser(getActivity(), "https://ko-fi.com/xsk22"), R.drawable.ic_fluent_heart_24_regular));
|
|
||||||
if (GithubSelfUpdater.needSelfUpdating()) {
|
if (GithubSelfUpdater.needSelfUpdating()) {
|
||||||
checkForUpdateItem = new TextItem(R.string.sk_check_for_update, GithubSelfUpdater.getInstance()::checkForUpdates);
|
checkForUpdateItem = new TextItem(R.string.sk_check_for_update, GithubSelfUpdater.getInstance()::checkForUpdates);
|
||||||
items.add(checkForUpdateItem);
|
items.add(checkForUpdateItem);
|
||||||
}
|
}
|
||||||
clearImageCacheItem = new TextItem(R.string.settings_clear_cache, UiUtils.formatFileSize(getContext(), imageCache.getDiskCache().size(), true), this::clearImageCache, 0);
|
items.add(new TextItem(R.string.sk_settings_contribute, ()->UiUtils.launchWebBrowser(getActivity(), "https://github.com/LucasGGamerM/moshidon")));
|
||||||
items.add(clearImageCacheItem);
|
items.add(new TextItem(R.string.settings_clear_cache, this::clearImageCache));
|
||||||
items.add(new TextItem(R.string.sk_clear_recent_languages, ()->UiUtils.showConfirmationAlert(getActivity(), R.string.sk_clear_recent_languages, R.string.sk_confirm_clear_recent_languages, R.string.clear, ()->{
|
items.add(new TextItem(R.string.sk_clear_recent_languages, ()->UiUtils.showConfirmationAlert(getActivity(), R.string.sk_clear_recent_languages, R.string.sk_confirm_clear_recent_languages, R.string.clear, ()->{
|
||||||
GlobalUserPreferences.recentLanguages.remove(accountID);
|
GlobalUserPreferences.recentLanguages.remove(accountID);
|
||||||
GlobalUserPreferences.save();
|
GlobalUserPreferences.save();
|
||||||
})));
|
})));
|
||||||
|
items.add(new TextItem(R.string.log_out, this::confirmLogOut));
|
||||||
|
|
||||||
items.add(new FooterItem(getString(R.string.sk_settings_app_version, BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE)));
|
items.add(new FooterItem(getString(R.string.sk_settings_app_version, BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updatePublishText(Button btn) {
|
|
||||||
if (GlobalUserPreferences.publishButtonText.isBlank()) btn.setText(R.string.publish);
|
|
||||||
else btn.setText(GlobalUserPreferences.publishButtonText);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAttach(Activity activity){
|
public void onAttach(Activity activity){
|
||||||
super.onAttach(activity);
|
super.onAttach(activity);
|
||||||
@@ -316,7 +241,11 @@ public class SettingsFragment extends MastodonToolbarFragment{
|
|||||||
if(needUpdateNotificationSettings && PushSubscriptionManager.arePushNotificationsAvailable()){
|
if(needUpdateNotificationSettings && PushSubscriptionManager.arePushNotificationsAvailable()){
|
||||||
AccountSessionManager.getInstance().getAccount(accountID).getPushSubscriptionManager().updatePushSettings(pushSubscription);
|
AccountSessionManager.getInstance().getAccount(accountID).getPushSubscriptionManager().updatePushSettings(pushSubscription);
|
||||||
}
|
}
|
||||||
if(needAppRestart) UiUtils.restartApp();
|
if(needAppRestart){
|
||||||
|
Intent intent = Intent.makeRestartActivityTask(MastodonApp.context.getPackageManager().getLaunchIntentForPackage(MastodonApp.context.getPackageName()).getComponent());
|
||||||
|
MastodonApp.context.startActivity(intent);
|
||||||
|
Runtime.getRuntime().exit(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -351,6 +280,7 @@ public class SettingsFragment extends MastodonToolbarFragment{
|
|||||||
else if (id == R.id.brown_color) pref = ColorPreference.BROWN;
|
else if (id == R.id.brown_color) pref = ColorPreference.BROWN;
|
||||||
else if (id == R.id.red_color) pref = ColorPreference.RED;
|
else if (id == R.id.red_color) pref = ColorPreference.RED;
|
||||||
else if (id == R.id.yellow_color) pref = ColorPreference.YELLOW;
|
else if (id == R.id.yellow_color) pref = ColorPreference.YELLOW;
|
||||||
|
else if (id == R.id.nord_color) pref = ColorPreference.NORD;
|
||||||
|
|
||||||
if (pref == null) return false;
|
if (pref == null) return false;
|
||||||
|
|
||||||
@@ -360,6 +290,7 @@ public class SettingsFragment extends MastodonToolbarFragment{
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void onTrueBlackThemeChanged(SwitchItem item){
|
private void onTrueBlackThemeChanged(SwitchItem item){
|
||||||
GlobalUserPreferences.trueBlackTheme=item.checked;
|
GlobalUserPreferences.trueBlackTheme=item.checked;
|
||||||
GlobalUserPreferences.save();
|
GlobalUserPreferences.save();
|
||||||
@@ -424,6 +355,12 @@ public class SettingsFragment extends MastodonToolbarFragment{
|
|||||||
needUpdateNotificationSettings=true;
|
needUpdateNotificationSettings=true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void onNotificationStyleChanged(SwitchItem item){
|
||||||
|
GlobalUserPreferences.showDifferentiatedPushNoticationIcons=item.checked;
|
||||||
|
GlobalUserPreferences.save();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void onNotificationsPolicyChanged(PushSubscription.Policy policy){
|
private void onNotificationsPolicyChanged(PushSubscription.Policy policy){
|
||||||
PushSubscription subscription=getPushSubscription();
|
PushSubscription subscription=getPushSubscription();
|
||||||
PushSubscription.Policy prevPolicy=subscription.policy;
|
PushSubscription.Policy prevPolicy=subscription.policy;
|
||||||
@@ -489,13 +426,9 @@ public class SettingsFragment extends MastodonToolbarFragment{
|
|||||||
private void clearImageCache(){
|
private void clearImageCache(){
|
||||||
MastodonAPIController.runInBackground(()->{
|
MastodonAPIController.runInBackground(()->{
|
||||||
Activity activity=getActivity();
|
Activity activity=getActivity();
|
||||||
imageCache.clear();
|
ImageCache.getInstance(getActivity()).clear();
|
||||||
Toast.makeText(activity, R.string.media_cache_cleared, Toast.LENGTH_SHORT).show();
|
Toast.makeText(activity, R.string.media_cache_cleared, Toast.LENGTH_SHORT).show();
|
||||||
});
|
});
|
||||||
if (list.findViewHolderForAdapterPosition(items.indexOf(clearImageCacheItem)) instanceof TextViewHolder tvh) {
|
|
||||||
clearImageCacheItem.secondaryText = UiUtils.formatFileSize(getContext(), 0, true);
|
|
||||||
tvh.rebind();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
@@ -533,10 +466,6 @@ public class SettingsFragment extends MastodonToolbarFragment{
|
|||||||
this.text=getString(text);
|
this.text=getString(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
public HeaderItem(String text) {
|
|
||||||
this.text=text;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getViewType(){
|
public int getViewType(){
|
||||||
return 0;
|
return 0;
|
||||||
@@ -588,6 +517,13 @@ public class SettingsFragment extends MastodonToolbarFragment{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class ColorPicker extends Item{
|
||||||
|
@Override
|
||||||
|
public int getViewType(){
|
||||||
|
return 8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static class ThemeItem extends Item{
|
private static class ThemeItem extends Item{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -604,44 +540,19 @@ public class SettingsFragment extends MastodonToolbarFragment{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SmallTextItem extends Item {
|
|
||||||
private String text;
|
|
||||||
|
|
||||||
public SmallTextItem(String text) {
|
|
||||||
this.text = text;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getViewType() {
|
|
||||||
return 9;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class TextItem extends Item{
|
private class TextItem extends Item{
|
||||||
private String text;
|
private String text;
|
||||||
private String secondaryText;
|
|
||||||
private Runnable onClick;
|
private Runnable onClick;
|
||||||
private boolean loading;
|
private boolean loading;
|
||||||
private int icon;
|
|
||||||
|
|
||||||
public TextItem(@StringRes int text, Runnable onClick) {
|
public TextItem(@StringRes int text, Runnable onClick) {
|
||||||
this(text, null, onClick, false, 0);
|
this(text, onClick, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TextItem(@StringRes int text, Runnable onClick, @DrawableRes int icon) {
|
public TextItem(@StringRes int text, Runnable onClick, boolean loading){
|
||||||
this(text, null, onClick, false, icon);
|
|
||||||
}
|
|
||||||
|
|
||||||
public TextItem(@StringRes int text, String secondaryText, Runnable onClick, @DrawableRes int icon) {
|
|
||||||
this(text, secondaryText, onClick, false, icon);
|
|
||||||
}
|
|
||||||
|
|
||||||
public TextItem(@StringRes int text, String secondaryText, Runnable onClick, boolean loading, @DrawableRes int icon){
|
|
||||||
this.text=getString(text);
|
this.text=getString(text);
|
||||||
this.onClick=onClick;
|
this.onClick=onClick;
|
||||||
this.loading=loading;
|
this.loading=loading;
|
||||||
this.icon=icon;
|
|
||||||
this.secondaryText = secondaryText;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -698,7 +609,6 @@ public class SettingsFragment extends MastodonToolbarFragment{
|
|||||||
case 6 -> new FooterViewHolder();
|
case 6 -> new FooterViewHolder();
|
||||||
case 7 -> new UpdateViewHolder();
|
case 7 -> new UpdateViewHolder();
|
||||||
case 8 -> new ButtonViewHolder();
|
case 8 -> new ButtonViewHolder();
|
||||||
case 9 -> new SmallTextViewHolder();
|
|
||||||
default -> throw new IllegalStateException("Unexpected value: "+viewType);
|
default -> throw new IllegalStateException("Unexpected value: "+viewType);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -827,6 +737,7 @@ public class SettingsFragment extends MastodonToolbarFragment{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ButtonViewHolder extends BindableViewHolder<ButtonItem>{
|
private class ButtonViewHolder extends BindableViewHolder<ButtonItem>{
|
||||||
private final Button button;
|
private final Button button;
|
||||||
private final ImageView icon;
|
private final ImageView icon;
|
||||||
@@ -892,27 +803,19 @@ public class SettingsFragment extends MastodonToolbarFragment{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class TextViewHolder extends BindableViewHolder<TextItem> implements UsableRecyclerView.Clickable{
|
private class TextViewHolder extends BindableViewHolder<TextItem> implements UsableRecyclerView.Clickable{
|
||||||
private final TextView text, secondaryText;
|
private final TextView text;
|
||||||
private final ProgressBar progress;
|
private final ProgressBar progress;
|
||||||
private final ImageView icon;
|
|
||||||
|
|
||||||
public TextViewHolder(){
|
public TextViewHolder(){
|
||||||
super(getActivity(), R.layout.item_settings_text, list);
|
super(getActivity(), R.layout.item_settings_text, list);
|
||||||
text = itemView.findViewById(R.id.text);
|
text = itemView.findViewById(R.id.text);
|
||||||
secondaryText = itemView.findViewById(R.id.secondary_text);
|
|
||||||
progress = itemView.findViewById(R.id.progress);
|
progress = itemView.findViewById(R.id.progress);
|
||||||
icon = itemView.findViewById(R.id.icon);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBind(TextItem item){
|
public void onBind(TextItem item){
|
||||||
icon.setVisibility(item.icon != 0 ? View.VISIBLE : View.GONE);
|
|
||||||
secondaryText.setVisibility(item.secondaryText != null ? View.VISIBLE : View.GONE);
|
|
||||||
|
|
||||||
text.setText(item.text);
|
text.setText(item.text);
|
||||||
progress.animate().alpha(item.loading ? 1 : 0);
|
progress.animate().alpha(item.loading ? 1 : 0);
|
||||||
icon.setImageResource(item.icon);
|
|
||||||
secondaryText.setText(item.secondaryText);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -921,24 +824,6 @@ public class SettingsFragment extends MastodonToolbarFragment{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SmallTextViewHolder extends BindableViewHolder<SmallTextItem> {
|
|
||||||
private final TextView text;
|
|
||||||
;
|
|
||||||
|
|
||||||
public SmallTextViewHolder(){
|
|
||||||
super(getActivity(), R.layout.item_settings_text, list);
|
|
||||||
text = itemView.findViewById(R.id.text);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBind(SmallTextItem item){
|
|
||||||
text.setText(item.text);
|
|
||||||
text.setTextColor(UiUtils.getThemeColor(getActivity(), android.R.attr.textColorSecondary));
|
|
||||||
text.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT));
|
|
||||||
text.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class FooterViewHolder extends BindableViewHolder<FooterItem>{
|
private class FooterViewHolder extends BindableViewHolder<FooterItem>{
|
||||||
private final TextView text;
|
private final TextView text;
|
||||||
public FooterViewHolder(){
|
public FooterViewHolder(){
|
||||||
@@ -1010,6 +895,7 @@ public class SettingsFragment extends MastodonToolbarFragment{
|
|||||||
progress.removeCallbacks(progressUpdater);
|
progress.removeCallbacks(progressUpdater);
|
||||||
}
|
}
|
||||||
changelog.setText(info.changelog);
|
changelog.setText(info.changelog);
|
||||||
|
// changelog.setText(getString(R.string.sk_changelog, info.changelog));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateProgress(){
|
private void updateProgress(){
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ public class StatusEditHistoryFragment extends StatusListFragment{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<StatusDisplayItem> buildDisplayItems(Status s){
|
protected List<StatusDisplayItem> buildDisplayItems(Status s){
|
||||||
List<StatusDisplayItem> items=StatusDisplayItem.buildItems(this, s, accountID, s, knownAccounts, true, false, null);
|
List<StatusDisplayItem> items=StatusDisplayItem.buildItems(this, s, accountID, s, knownAccounts, true, false);
|
||||||
int idx=data.indexOf(s);
|
int idx=data.indexOf(s);
|
||||||
if(idx>=0){
|
if(idx>=0){
|
||||||
String date=UiUtils.DATE_TIME_FORMATTER.format(s.createdAt.atZone(ZoneId.systemDefault()));
|
String date=UiUtils.DATE_TIME_FORMATTER.format(s.createdAt.atZone(ZoneId.systemDefault()));
|
||||||
@@ -139,7 +139,7 @@ public class StatusEditHistoryFragment extends StatusListFragment{
|
|||||||
action=getString(R.string.edit_multiple_changed);
|
action=getString(R.string.edit_multiple_changed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
items.add(0, new ReblogOrReplyLineStatusDisplayItem(s.id, this, action+" · "+date, Collections.emptyList(), 0, null, null));
|
items.add(0, new ReblogOrReplyLineStatusDisplayItem(s.id, this, action+" · "+date, Collections.emptyList(), 0, null));
|
||||||
}
|
}
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package org.joinmastodon.android.fragments;
|
package org.joinmastodon.android.fragments;
|
||||||
|
|
||||||
import android.content.res.Configuration;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
import com.squareup.otto.Subscribe;
|
import com.squareup.otto.Subscribe;
|
||||||
@@ -30,7 +29,7 @@ public abstract class StatusListFragment extends BaseStatusListFragment<Status>{
|
|||||||
protected EventListener eventListener=new EventListener();
|
protected EventListener eventListener=new EventListener();
|
||||||
|
|
||||||
protected List<StatusDisplayItem> buildDisplayItems(Status s){
|
protected List<StatusDisplayItem> buildDisplayItems(Status s){
|
||||||
return StatusDisplayItem.buildItems(this, s, accountID, s, knownAccounts, false, true, null);
|
return StatusDisplayItem.buildItems(this, s, accountID, s, knownAccounts, false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -172,12 +171,6 @@ public abstract class StatusListFragment extends BaseStatusListFragment<Status>{
|
|||||||
adapter.notifyItemRangeRemoved(index, lastIndex-index);
|
adapter.notifyItemRangeRemoved(index, lastIndex-index);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onConfigurationChanged(Configuration newConfig){
|
|
||||||
super.onConfigurationChanged(newConfig);
|
|
||||||
if (getParentFragment() instanceof HomeTabFragment home) home.updateToolbarLogo();
|
|
||||||
}
|
|
||||||
|
|
||||||
public class EventListener{
|
public class EventListener{
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import android.view.View;
|
|||||||
|
|
||||||
import org.joinmastodon.android.R;
|
import org.joinmastodon.android.R;
|
||||||
import org.joinmastodon.android.api.requests.statuses.GetStatusContext;
|
import org.joinmastodon.android.api.requests.statuses.GetStatusContext;
|
||||||
|
import org.joinmastodon.android.api.session.AccountSessionManager;
|
||||||
import org.joinmastodon.android.events.StatusCreatedEvent;
|
import org.joinmastodon.android.events.StatusCreatedEvent;
|
||||||
import org.joinmastodon.android.model.Account;
|
import org.joinmastodon.android.model.Account;
|
||||||
import org.joinmastodon.android.model.Filter;
|
import org.joinmastodon.android.model.Filter;
|
||||||
@@ -16,7 +17,6 @@ import org.joinmastodon.android.ui.displayitems.StatusDisplayItem;
|
|||||||
import org.joinmastodon.android.ui.displayitems.TextStatusDisplayItem;
|
import org.joinmastodon.android.ui.displayitems.TextStatusDisplayItem;
|
||||||
import org.joinmastodon.android.ui.text.HtmlParser;
|
import org.joinmastodon.android.ui.text.HtmlParser;
|
||||||
import org.joinmastodon.android.ui.utils.UiUtils;
|
import org.joinmastodon.android.ui.utils.UiUtils;
|
||||||
import org.joinmastodon.android.utils.StatusFilterPredicate;
|
|
||||||
import org.parceler.Parcels;
|
import org.parceler.Parcels;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -92,10 +92,16 @@ public class ThreadFragment extends StatusListFragment{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<Status> filterStatuses(List<Status> statuses){
|
private List<Status> filterStatuses(List<Status> statuses){
|
||||||
StatusFilterPredicate statusFilterPredicate=new StatusFilterPredicate(accountID,Filter.FilterContext.THREAD);
|
List<Filter> filters=AccountSessionManager.getInstance().getAccount(accountID).wordFilters.stream().filter(f->f.context.contains(Filter.FilterContext.THREAD)).collect(Collectors.toList());
|
||||||
return statuses.stream()
|
if(filters.isEmpty())
|
||||||
.filter(statusFilterPredicate)
|
return statuses;
|
||||||
.collect(Collectors.toList());
|
return statuses.stream().filter(status->{
|
||||||
|
for(Filter filter:filters){
|
||||||
|
if(filter.matches(status))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -225,7 +225,6 @@ public abstract class BaseAccountListFragment extends BaseRecyclerFragment<BaseA
|
|||||||
contextMenu=new PopupMenu(getActivity(), menuAnchor);
|
contextMenu=new PopupMenu(getActivity(), menuAnchor);
|
||||||
contextMenu.inflate(R.menu.profile);
|
contextMenu.inflate(R.menu.profile);
|
||||||
contextMenu.setOnMenuItemClickListener(this::onContextMenuItemSelected);
|
contextMenu.setOnMenuItemClickListener(this::onContextMenuItemSelected);
|
||||||
UiUtils.enablePopupMenuIcons(getActivity(), contextMenu);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -284,32 +283,29 @@ public abstract class BaseAccountListFragment extends BaseRecyclerFragment<BaseA
|
|||||||
Menu menu=contextMenu.getMenu();
|
Menu menu=contextMenu.getMenu();
|
||||||
Account account=item.account;
|
Account account=item.account;
|
||||||
|
|
||||||
menu.findItem(R.id.share).setTitle(getString(R.string.share_user, account.getShortUsername()));
|
menu.findItem(R.id.share).setTitle(getString(R.string.share_user, account.getDisplayUsername()));
|
||||||
|
menu.findItem(R.id.mute).setTitle(getString(relationship.muting ? R.string.unmute_user : R.string.mute_user, account.getDisplayUsername()));
|
||||||
MenuItem mute = menu.findItem(R.id.mute);
|
menu.findItem(R.id.block).setTitle(getString(relationship.blocking ? R.string.unblock_user : R.string.block_user, account.getDisplayUsername()));
|
||||||
mute.setTitle(getString(relationship.muting ? R.string.unmute_user : R.string.mute_user, account.getShortUsername()));
|
menu.findItem(R.id.report).setTitle(getString(R.string.report_user, account.getDisplayUsername()));
|
||||||
mute.setIcon(relationship.muting ? R.drawable.ic_fluent_speaker_0_24_regular : R.drawable.ic_fluent_speaker_off_24_regular);
|
menu.findItem(R.id.manage_user_lists).setTitle(getString(R.string.sk_lists_with_user, account.getDisplayUsername())).setVisible(relationship.following);
|
||||||
UiUtils.insetPopupMenuIcon(getContext(), mute);
|
|
||||||
|
|
||||||
menu.findItem(R.id.block).setTitle(getString(relationship.blocking ? R.string.unblock_user : R.string.block_user, account.getShortUsername()));
|
|
||||||
menu.findItem(R.id.report).setTitle(getString(R.string.report_user, account.getShortUsername()));
|
|
||||||
menu.findItem(R.id.manage_user_lists).setTitle(getString(R.string.sk_lists_with_user, account.getShortUsername())).setVisible(relationship.following);
|
|
||||||
menu.findItem(R.id.soft_block).setVisible(relationship.followedBy && !relationship.following);
|
|
||||||
MenuItem hideBoosts=menu.findItem(R.id.hide_boosts);
|
MenuItem hideBoosts=menu.findItem(R.id.hide_boosts);
|
||||||
MenuItem manageUserLists=menu.findItem(R.id.manage_user_lists);
|
MenuItem manageUserLists=menu.findItem(R.id.manage_user_lists);
|
||||||
if(relationship.following){
|
if(relationship.following){
|
||||||
hideBoosts.setTitle(getString(relationship.showingReblogs ? R.string.hide_boosts_from_user : R.string.show_boosts_from_user, account.getShortUsername()));
|
hideBoosts.setTitle(getString(relationship.showingReblogs ? R.string.hide_boosts_from_user : R.string.show_boosts_from_user, account.getDisplayUsername()));
|
||||||
hideBoosts.setIcon(relationship.showingReblogs ? R.drawable.ic_fluent_arrow_repeat_all_off_24_regular : R.drawable.ic_fluent_arrow_repeat_all_24_regular);
|
|
||||||
hideBoosts.setVisible(true);
|
hideBoosts.setVisible(true);
|
||||||
UiUtils.insetPopupMenuIcon(getContext(), hideBoosts);
|
manageUserLists.setTitle(getString(R.string.sk_lists_with_user, account.getDisplayUsername()));
|
||||||
|
|
||||||
manageUserLists.setTitle(getString(R.string.sk_lists_with_user, account.getShortUsername()));
|
|
||||||
manageUserLists.setVisible(true);
|
manageUserLists.setVisible(true);
|
||||||
}else{
|
}else{
|
||||||
hideBoosts.setVisible(false);
|
hideBoosts.setVisible(false);
|
||||||
manageUserLists.setVisible(true);
|
manageUserLists.setVisible(true);
|
||||||
}
|
}
|
||||||
menu.findItem(R.id.block_domain).setVisible(false);
|
MenuItem blockDomain=menu.findItem(R.id.block_domain);
|
||||||
|
if(!account.isLocal()){
|
||||||
|
blockDomain.setTitle(getString(relationship.domainBlocking ? R.string.unblock_domain : R.string.block_domain, account.getDomain()));
|
||||||
|
blockDomain.setVisible(true);
|
||||||
|
}else{
|
||||||
|
blockDomain.setVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
menuAnchor.setTranslationX(x);
|
menuAnchor.setTranslationX(x);
|
||||||
menuAnchor.setTranslationY(y);
|
menuAnchor.setTranslationY(y);
|
||||||
@@ -350,8 +346,6 @@ public abstract class BaseAccountListFragment extends BaseRecyclerFragment<BaseA
|
|||||||
UiUtils.confirmToggleMuteUser(getActivity(), accountID, account, relationship.muting, this::updateRelationship);
|
UiUtils.confirmToggleMuteUser(getActivity(), accountID, account, relationship.muting, this::updateRelationship);
|
||||||
}else if(id==R.id.block){
|
}else if(id==R.id.block){
|
||||||
UiUtils.confirmToggleBlockUser(getActivity(), accountID, account, relationship.blocking, this::updateRelationship);
|
UiUtils.confirmToggleBlockUser(getActivity(), accountID, account, relationship.blocking, this::updateRelationship);
|
||||||
}else if(id==R.id.soft_block){
|
|
||||||
UiUtils.confirmSoftBlockUser(getActivity(), accountID, account, this::updateRelationship);
|
|
||||||
}else if(id==R.id.report){
|
}else if(id==R.id.report){
|
||||||
Bundle args=new Bundle();
|
Bundle args=new Bundle();
|
||||||
args.putString("account", accountID);
|
args.putString("account", accountID);
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import android.widget.TextView;
|
|||||||
import org.joinmastodon.android.R;
|
import org.joinmastodon.android.R;
|
||||||
import org.joinmastodon.android.api.requests.accounts.GetAccountRelationships;
|
import org.joinmastodon.android.api.requests.accounts.GetAccountRelationships;
|
||||||
import org.joinmastodon.android.api.requests.accounts.GetFollowSuggestions;
|
import org.joinmastodon.android.api.requests.accounts.GetFollowSuggestions;
|
||||||
import org.joinmastodon.android.fragments.IsOnTop;
|
|
||||||
import org.joinmastodon.android.fragments.ProfileFragment;
|
import org.joinmastodon.android.fragments.ProfileFragment;
|
||||||
import org.joinmastodon.android.fragments.ScrollableToTop;
|
import org.joinmastodon.android.fragments.ScrollableToTop;
|
||||||
import org.joinmastodon.android.model.Account;
|
import org.joinmastodon.android.model.Account;
|
||||||
@@ -49,7 +48,7 @@ import me.grishka.appkit.utils.BindableViewHolder;
|
|||||||
import me.grishka.appkit.utils.V;
|
import me.grishka.appkit.utils.V;
|
||||||
import me.grishka.appkit.views.UsableRecyclerView;
|
import me.grishka.appkit.views.UsableRecyclerView;
|
||||||
|
|
||||||
public class DiscoverAccountsFragment extends BaseRecyclerFragment<DiscoverAccountsFragment.AccountWrapper> implements ScrollableToTop, IsOnTop {
|
public class DiscoverAccountsFragment extends BaseRecyclerFragment<DiscoverAccountsFragment.AccountWrapper> implements ScrollableToTop{
|
||||||
private String accountID;
|
private String accountID;
|
||||||
private Map<String, Relationship> relationships=Collections.emptyMap();
|
private Map<String, Relationship> relationships=Collections.emptyMap();
|
||||||
private GetAccountRelationships relationshipsRequest;
|
private GetAccountRelationships relationshipsRequest;
|
||||||
@@ -138,11 +137,6 @@ public class DiscoverAccountsFragment extends BaseRecyclerFragment<DiscoverAccou
|
|||||||
smoothScrollRecyclerViewToTop(list);
|
smoothScrollRecyclerViewToTop(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isOnTop() {
|
|
||||||
return isRecyclerViewOnTop(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
private class AccountsAdapter extends UsableRecyclerView.Adapter<AccountViewHolder> implements ImageLoaderRecyclerAdapter{
|
private class AccountsAdapter extends UsableRecyclerView.Adapter<AccountViewHolder> implements ImageLoaderRecyclerAdapter{
|
||||||
|
|
||||||
public AccountsAdapter(){
|
public AccountsAdapter(){
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package org.joinmastodon.android.fragments.discover;
|
package org.joinmastodon.android.fragments.discover;
|
||||||
|
|
||||||
import android.app.Fragment;
|
import android.app.Fragment;
|
||||||
|
import android.app.FragmentTransaction;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
@@ -17,10 +18,11 @@ import android.widget.LinearLayout;
|
|||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import org.joinmastodon.android.BuildConfig;
|
||||||
import org.joinmastodon.android.GlobalUserPreferences;
|
import org.joinmastodon.android.GlobalUserPreferences;
|
||||||
import org.joinmastodon.android.R;
|
import org.joinmastodon.android.R;
|
||||||
import org.joinmastodon.android.fragments.IsOnTop;
|
|
||||||
import org.joinmastodon.android.fragments.ScrollableToTop;
|
import org.joinmastodon.android.fragments.ScrollableToTop;
|
||||||
|
import org.joinmastodon.android.fragments.ListTimelinesFragment;
|
||||||
import org.joinmastodon.android.ui.SimpleViewHolder;
|
import org.joinmastodon.android.ui.SimpleViewHolder;
|
||||||
import org.joinmastodon.android.ui.tabs.TabLayout;
|
import org.joinmastodon.android.ui.tabs.TabLayout;
|
||||||
import org.joinmastodon.android.ui.tabs.TabLayoutMediator;
|
import org.joinmastodon.android.ui.tabs.TabLayoutMediator;
|
||||||
@@ -36,7 +38,7 @@ import me.grishka.appkit.fragments.BaseRecyclerFragment;
|
|||||||
import me.grishka.appkit.fragments.OnBackPressedListener;
|
import me.grishka.appkit.fragments.OnBackPressedListener;
|
||||||
import me.grishka.appkit.utils.V;
|
import me.grishka.appkit.utils.V;
|
||||||
|
|
||||||
public class DiscoverFragment extends AppKitFragment implements ScrollableToTop, OnBackPressedListener, IsOnTop {
|
public class DiscoverFragment extends AppKitFragment implements ScrollableToTop, OnBackPressedListener{
|
||||||
|
|
||||||
private TabLayout tabLayout;
|
private TabLayout tabLayout;
|
||||||
private ViewPager2 pager;
|
private ViewPager2 pager;
|
||||||
@@ -53,10 +55,15 @@ public class DiscoverFragment extends AppKitFragment implements ScrollableToTop,
|
|||||||
private DiscoverNewsFragment newsFragment;
|
private DiscoverNewsFragment newsFragment;
|
||||||
private DiscoverAccountsFragment accountsFragment;
|
private DiscoverAccountsFragment accountsFragment;
|
||||||
private SearchFragment searchFragment;
|
private SearchFragment searchFragment;
|
||||||
|
private LocalTimelineFragment localTimelineFragment;
|
||||||
|
private FederatedTimelineFragment federatedTimelineFragment;
|
||||||
|
private ListTimelinesFragment listTimelinesFragment;
|
||||||
|
|
||||||
private String accountID;
|
private String accountID;
|
||||||
private Runnable searchDebouncer=this::onSearchChangedDebounced;
|
private Runnable searchDebouncer=this::onSearchChangedDebounced;
|
||||||
|
|
||||||
|
private final boolean noFederated = !GlobalUserPreferences.showFederatedTimeline;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState){
|
public void onCreate(Bundle savedInstanceState){
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@@ -74,15 +81,19 @@ public class DiscoverFragment extends AppKitFragment implements ScrollableToTop,
|
|||||||
tabLayout=view.findViewById(R.id.tabbar);
|
tabLayout=view.findViewById(R.id.tabbar);
|
||||||
pager=view.findViewById(R.id.pager);
|
pager=view.findViewById(R.id.pager);
|
||||||
|
|
||||||
tabViews=new FrameLayout[4];
|
tabViews=new FrameLayout[noFederated ? 6 : 7];
|
||||||
for(int i=0;i<tabViews.length;i++){
|
for(int i=0;i<tabViews.length;i++){
|
||||||
FrameLayout tabView=new FrameLayout(getActivity());
|
FrameLayout tabView=new FrameLayout(getActivity());
|
||||||
tabView.setId(switch(i){
|
int switchIndex = noFederated && i > 0 ? i + 1 : i;
|
||||||
case 0 -> R.id.discover_hashtags;
|
tabView.setId(switch(switchIndex){
|
||||||
case 1 -> R.id.discover_posts;
|
case 0 -> R.id.discover_local_timeline;
|
||||||
case 2 -> R.id.discover_news;
|
case 1 -> R.id.discover_federated_timeline;
|
||||||
case 3 -> R.id.discover_users;
|
case 2 -> R.id.discover_lists;
|
||||||
default -> throw new IllegalStateException("Unexpected value: "+i);
|
case 3 -> R.id.discover_hashtags;
|
||||||
|
case 4 -> R.id.discover_posts;
|
||||||
|
case 5 -> R.id.discover_news;
|
||||||
|
case 6 -> R.id.discover_users;
|
||||||
|
default -> throw new IllegalStateException("Unexpected value: "+switchIndex);
|
||||||
});
|
});
|
||||||
tabView.setVisibility(View.GONE);
|
tabView.setVisibility(View.GONE);
|
||||||
view.addView(tabView); // needed so the fragment manager will have somewhere to restore the tab fragment
|
view.addView(tabView); // needed so the fragment manager will have somewhere to restore the tab fragment
|
||||||
@@ -92,7 +103,6 @@ public class DiscoverFragment extends AppKitFragment implements ScrollableToTop,
|
|||||||
tabLayout.setTabTextSize(V.dp(16));
|
tabLayout.setTabTextSize(V.dp(16));
|
||||||
tabLayout.setTabTextColors(UiUtils.getThemeColor(getActivity(), R.attr.colorTabInactive), UiUtils.getThemeColor(getActivity(), android.R.attr.textColorPrimary));
|
tabLayout.setTabTextColors(UiUtils.getThemeColor(getActivity(), R.attr.colorTabInactive), UiUtils.getThemeColor(getActivity(), android.R.attr.textColorPrimary));
|
||||||
|
|
||||||
UiUtils.reduceSwipeSensitivity(pager);
|
|
||||||
pager.setOffscreenPageLimit(4);
|
pager.setOffscreenPageLimit(4);
|
||||||
pager.setUserInputEnabled(!GlobalUserPreferences.disableSwipe);
|
pager.setUserInputEnabled(!GlobalUserPreferences.disableSwipe);
|
||||||
pager.setAdapter(new DiscoverPagerAdapter());
|
pager.setAdapter(new DiscoverPagerAdapter());
|
||||||
@@ -109,7 +119,7 @@ public class DiscoverFragment extends AppKitFragment implements ScrollableToTop,
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if(hashtagsFragment==null){
|
if(localTimelineFragment==null){
|
||||||
Bundle args=new Bundle();
|
Bundle args=new Bundle();
|
||||||
args.putString("account", accountID);
|
args.putString("account", accountID);
|
||||||
args.putBoolean("__is_tab", true);
|
args.putBoolean("__is_tab", true);
|
||||||
@@ -126,23 +136,42 @@ public class DiscoverFragment extends AppKitFragment implements ScrollableToTop,
|
|||||||
accountsFragment=new DiscoverAccountsFragment();
|
accountsFragment=new DiscoverAccountsFragment();
|
||||||
accountsFragment.setArguments(args);
|
accountsFragment.setArguments(args);
|
||||||
|
|
||||||
|
localTimelineFragment=new LocalTimelineFragment();
|
||||||
|
localTimelineFragment.setArguments(args);
|
||||||
|
|
||||||
getChildFragmentManager().beginTransaction()
|
listTimelinesFragment=new ListTimelinesFragment();
|
||||||
|
listTimelinesFragment.setArguments(args);
|
||||||
|
|
||||||
|
FragmentTransaction transaction = getChildFragmentManager().beginTransaction()
|
||||||
.add(R.id.discover_posts, postsFragment)
|
.add(R.id.discover_posts, postsFragment)
|
||||||
|
.add(R.id.discover_local_timeline, localTimelineFragment)
|
||||||
.add(R.id.discover_hashtags, hashtagsFragment)
|
.add(R.id.discover_hashtags, hashtagsFragment)
|
||||||
.add(R.id.discover_news, newsFragment)
|
.add(R.id.discover_news, newsFragment)
|
||||||
.add(R.id.discover_users, accountsFragment)
|
.add(R.id.discover_users, accountsFragment)
|
||||||
.commit();
|
.add(R.id.discover_lists, listTimelinesFragment);
|
||||||
|
|
||||||
|
if (!noFederated) {
|
||||||
|
federatedTimelineFragment=new FederatedTimelineFragment();
|
||||||
|
federatedTimelineFragment.setArguments(args);
|
||||||
|
transaction.add(R.id.discover_federated_timeline, federatedTimelineFragment);
|
||||||
|
}
|
||||||
|
|
||||||
|
transaction.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
tabLayoutMediator=new TabLayoutMediator(tabLayout, pager, new TabLayoutMediator.TabConfigurationStrategy(){
|
tabLayoutMediator=new TabLayoutMediator(tabLayout, pager, new TabLayoutMediator.TabConfigurationStrategy(){
|
||||||
@Override
|
@Override
|
||||||
public void onConfigureTab(@NonNull TabLayout.Tab tab, int position){
|
public void onConfigureTab(@NonNull TabLayout.Tab tab, int position){
|
||||||
|
if (noFederated && position > 0) position++;
|
||||||
tab.setText(switch(position){
|
tab.setText(switch(position){
|
||||||
case 0 -> R.string.hashtags;
|
case 0 -> R.string.local_timeline;
|
||||||
case 1 -> R.string.posts;
|
case 1 -> R.string.sk_federated_timeline;
|
||||||
case 2 -> R.string.news;
|
case 2 -> R.string.sk_list_timelines;
|
||||||
case 3 -> R.string.for_you;
|
case 3 -> R.string.hashtags;
|
||||||
|
case 4 -> R.string.posts;
|
||||||
|
case 5 -> R.string.news;
|
||||||
|
case 6 -> R.string.for_you;
|
||||||
|
|
||||||
default -> throw new IllegalStateException("Unexpected value: "+position);
|
default -> throw new IllegalStateException("Unexpected value: "+position);
|
||||||
});
|
});
|
||||||
tab.view.textView.setAllCaps(true);
|
tab.view.textView.setAllCaps(true);
|
||||||
@@ -227,26 +256,9 @@ public class DiscoverFragment extends AppKitFragment implements ScrollableToTop,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isOnTop() {
|
|
||||||
return searchActive ? searchFragment.isOnTop()
|
|
||||||
: ((IsOnTop)getFragmentForPage(pager.getCurrentItem())).isOnTop();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onSelect() {
|
|
||||||
if (isOnTop()) selectSearch();
|
|
||||||
else scrollToTop();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void selectSearch() {
|
|
||||||
searchEdit.requestFocus();
|
|
||||||
onSearchEditFocusChanged(searchEdit, true);
|
|
||||||
getActivity().getSystemService(InputMethodManager.class).showSoftInput(searchEdit, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void loadData(){
|
public void loadData(){
|
||||||
if(hashtagsFragment!=null && !hashtagsFragment.loaded && !hashtagsFragment.dataLoading)
|
if(localTimelineFragment!=null && !localTimelineFragment.loaded && !localTimelineFragment.dataLoading)
|
||||||
hashtagsFragment.loadData();
|
localTimelineFragment.loadData();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onSearchEditFocusChanged(View v, boolean hasFocus){
|
private void onSearchEditFocusChanged(View v, boolean hasFocus){
|
||||||
@@ -281,11 +293,15 @@ public class DiscoverFragment extends AppKitFragment implements ScrollableToTop,
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Fragment getFragmentForPage(int page){
|
private Fragment getFragmentForPage(int page){
|
||||||
|
if (noFederated && page > 0) page++;
|
||||||
return switch(page){
|
return switch(page){
|
||||||
case 0 -> hashtagsFragment;
|
case 0 -> localTimelineFragment;
|
||||||
case 1 -> postsFragment;
|
case 1 -> federatedTimelineFragment;
|
||||||
case 2 -> newsFragment;
|
case 2 -> hashtagsFragment;
|
||||||
case 3 -> accountsFragment;
|
case 3 -> postsFragment;
|
||||||
|
case 4 -> newsFragment;
|
||||||
|
case 5 -> accountsFragment;
|
||||||
|
case 6 -> listTimelinesFragment;
|
||||||
default -> throw new IllegalStateException("Unexpected value: "+page);
|
default -> throw new IllegalStateException("Unexpected value: "+page);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import android.widget.TextView;
|
|||||||
|
|
||||||
import org.joinmastodon.android.R;
|
import org.joinmastodon.android.R;
|
||||||
import org.joinmastodon.android.api.requests.trends.GetTrendingLinks;
|
import org.joinmastodon.android.api.requests.trends.GetTrendingLinks;
|
||||||
import org.joinmastodon.android.fragments.IsOnTop;
|
|
||||||
import org.joinmastodon.android.fragments.ScrollableToTop;
|
import org.joinmastodon.android.fragments.ScrollableToTop;
|
||||||
import org.joinmastodon.android.model.Card;
|
import org.joinmastodon.android.model.Card;
|
||||||
import org.joinmastodon.android.ui.DividerItemDecoration;
|
import org.joinmastodon.android.ui.DividerItemDecoration;
|
||||||
@@ -35,7 +34,7 @@ import me.grishka.appkit.utils.BindableViewHolder;
|
|||||||
import me.grishka.appkit.utils.V;
|
import me.grishka.appkit.utils.V;
|
||||||
import me.grishka.appkit.views.UsableRecyclerView;
|
import me.grishka.appkit.views.UsableRecyclerView;
|
||||||
|
|
||||||
public class DiscoverNewsFragment extends BaseRecyclerFragment<Card> implements ScrollableToTop, IsOnTop {
|
public class DiscoverNewsFragment extends BaseRecyclerFragment<Card> implements ScrollableToTop{
|
||||||
private String accountID;
|
private String accountID;
|
||||||
private List<ImageLoaderRequest> imageRequests=Collections.emptyList();
|
private List<ImageLoaderRequest> imageRequests=Collections.emptyList();
|
||||||
private DiscoverInfoBannerHelper bannerHelper=new DiscoverInfoBannerHelper(DiscoverInfoBannerHelper.BannerType.TRENDING_LINKS);
|
private DiscoverInfoBannerHelper bannerHelper=new DiscoverInfoBannerHelper(DiscoverInfoBannerHelper.BannerType.TRENDING_LINKS);
|
||||||
@@ -82,11 +81,6 @@ public class DiscoverNewsFragment extends BaseRecyclerFragment<Card> implements
|
|||||||
smoothScrollRecyclerViewToTop(list);
|
smoothScrollRecyclerViewToTop(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isOnTop() {
|
|
||||||
return isRecyclerViewOnTop(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
private class LinksAdapter extends UsableRecyclerView.Adapter<LinkViewHolder> implements ImageLoaderRecyclerAdapter{
|
private class LinksAdapter extends UsableRecyclerView.Adapter<LinkViewHolder> implements ImageLoaderRecyclerAdapter{
|
||||||
public LinksAdapter(){
|
public LinksAdapter(){
|
||||||
super(imgLoader);
|
super(imgLoader);
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import android.os.Bundle;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import org.joinmastodon.android.api.requests.trends.GetTrendingStatuses;
|
import org.joinmastodon.android.api.requests.trends.GetTrendingStatuses;
|
||||||
import org.joinmastodon.android.fragments.IsOnTop;
|
|
||||||
import org.joinmastodon.android.fragments.StatusListFragment;
|
import org.joinmastodon.android.fragments.StatusListFragment;
|
||||||
import org.joinmastodon.android.model.Status;
|
import org.joinmastodon.android.model.Status;
|
||||||
import org.joinmastodon.android.ui.utils.DiscoverInfoBannerHelper;
|
import org.joinmastodon.android.ui.utils.DiscoverInfoBannerHelper;
|
||||||
@@ -13,16 +12,16 @@ import java.util.List;
|
|||||||
|
|
||||||
import me.grishka.appkit.api.SimpleCallback;
|
import me.grishka.appkit.api.SimpleCallback;
|
||||||
|
|
||||||
public class DiscoverPostsFragment extends StatusListFragment implements IsOnTop {
|
public class DiscoverPostsFragment extends StatusListFragment{
|
||||||
private DiscoverInfoBannerHelper bannerHelper=new DiscoverInfoBannerHelper(DiscoverInfoBannerHelper.BannerType.TRENDING_POSTS);
|
private DiscoverInfoBannerHelper bannerHelper=new DiscoverInfoBannerHelper(DiscoverInfoBannerHelper.BannerType.TRENDING_POSTS);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doLoadData(int offset, int count){
|
protected void doLoadData(int offset, int count){
|
||||||
currentRequest=new GetTrendingStatuses(offset, count)
|
currentRequest=new GetTrendingStatuses(count)
|
||||||
.setCallback(new SimpleCallback<>(this){
|
.setCallback(new SimpleCallback<>(this){
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(List<Status> result){
|
public void onSuccess(List<Status> result){
|
||||||
onDataLoaded(result, !result.isEmpty());
|
onDataLoaded(result, false);
|
||||||
}
|
}
|
||||||
}).exec(accountID);
|
}).exec(accountID);
|
||||||
}
|
}
|
||||||
@@ -32,9 +31,4 @@ public class DiscoverPostsFragment extends StatusListFragment implements IsOnTop
|
|||||||
super.onViewCreated(view, savedInstanceState);
|
super.onViewCreated(view, savedInstanceState);
|
||||||
bannerHelper.maybeAddBanner(contentWrap);
|
bannerHelper.maybeAddBanner(contentWrap);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isOnTop() {
|
|
||||||
return isRecyclerViewOnTop(list);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,9 +3,7 @@ package org.joinmastodon.android.fragments.discover;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import org.joinmastodon.android.R;
|
|
||||||
import org.joinmastodon.android.api.requests.timelines.GetPublicTimeline;
|
import org.joinmastodon.android.api.requests.timelines.GetPublicTimeline;
|
||||||
import org.joinmastodon.android.fragments.FabStatusListFragment;
|
|
||||||
import org.joinmastodon.android.fragments.StatusListFragment;
|
import org.joinmastodon.android.fragments.StatusListFragment;
|
||||||
import org.joinmastodon.android.model.Filter;
|
import org.joinmastodon.android.model.Filter;
|
||||||
import org.joinmastodon.android.model.Status;
|
import org.joinmastodon.android.model.Status;
|
||||||
@@ -17,7 +15,7 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
import me.grishka.appkit.api.SimpleCallback;
|
import me.grishka.appkit.api.SimpleCallback;
|
||||||
|
|
||||||
public class FederatedTimelineFragment extends FabStatusListFragment {
|
public class FederatedTimelineFragment extends StatusListFragment{
|
||||||
private DiscoverInfoBannerHelper bannerHelper=new DiscoverInfoBannerHelper(DiscoverInfoBannerHelper.BannerType.FEDERATED_TIMELINE);
|
private DiscoverInfoBannerHelper bannerHelper=new DiscoverInfoBannerHelper(DiscoverInfoBannerHelper.BannerType.FEDERATED_TIMELINE);
|
||||||
private String maxID;
|
private String maxID;
|
||||||
|
|
||||||
|
|||||||
@@ -3,9 +3,7 @@ package org.joinmastodon.android.fragments.discover;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import org.joinmastodon.android.R;
|
|
||||||
import org.joinmastodon.android.api.requests.timelines.GetPublicTimeline;
|
import org.joinmastodon.android.api.requests.timelines.GetPublicTimeline;
|
||||||
import org.joinmastodon.android.fragments.FabStatusListFragment;
|
|
||||||
import org.joinmastodon.android.fragments.StatusListFragment;
|
import org.joinmastodon.android.fragments.StatusListFragment;
|
||||||
import org.joinmastodon.android.model.Filter;
|
import org.joinmastodon.android.model.Filter;
|
||||||
import org.joinmastodon.android.model.Status;
|
import org.joinmastodon.android.model.Status;
|
||||||
@@ -17,7 +15,7 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
import me.grishka.appkit.api.SimpleCallback;
|
import me.grishka.appkit.api.SimpleCallback;
|
||||||
|
|
||||||
public class LocalTimelineFragment extends FabStatusListFragment {
|
public class LocalTimelineFragment extends StatusListFragment{
|
||||||
private DiscoverInfoBannerHelper bannerHelper=new DiscoverInfoBannerHelper(DiscoverInfoBannerHelper.BannerType.LOCAL_TIMELINE);
|
private DiscoverInfoBannerHelper bannerHelper=new DiscoverInfoBannerHelper(DiscoverInfoBannerHelper.BannerType.LOCAL_TIMELINE);
|
||||||
private String maxID;
|
private String maxID;
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import org.joinmastodon.android.R;
|
|||||||
import org.joinmastodon.android.api.requests.search.GetSearchResults;
|
import org.joinmastodon.android.api.requests.search.GetSearchResults;
|
||||||
import org.joinmastodon.android.api.session.AccountSessionManager;
|
import org.joinmastodon.android.api.session.AccountSessionManager;
|
||||||
import org.joinmastodon.android.fragments.BaseStatusListFragment;
|
import org.joinmastodon.android.fragments.BaseStatusListFragment;
|
||||||
import org.joinmastodon.android.fragments.IsOnTop;
|
|
||||||
import org.joinmastodon.android.fragments.ProfileFragment;
|
import org.joinmastodon.android.fragments.ProfileFragment;
|
||||||
import org.joinmastodon.android.fragments.ThreadFragment;
|
import org.joinmastodon.android.fragments.ThreadFragment;
|
||||||
import org.joinmastodon.android.model.Account;
|
import org.joinmastodon.android.model.Account;
|
||||||
@@ -38,10 +37,11 @@ import androidx.recyclerview.widget.RecyclerView;
|
|||||||
import me.grishka.appkit.Nav;
|
import me.grishka.appkit.Nav;
|
||||||
import me.grishka.appkit.api.Callback;
|
import me.grishka.appkit.api.Callback;
|
||||||
import me.grishka.appkit.api.ErrorResponse;
|
import me.grishka.appkit.api.ErrorResponse;
|
||||||
|
import me.grishka.appkit.api.SimpleCallback;
|
||||||
import me.grishka.appkit.utils.MergeRecyclerAdapter;
|
import me.grishka.appkit.utils.MergeRecyclerAdapter;
|
||||||
import me.grishka.appkit.utils.V;
|
import me.grishka.appkit.utils.V;
|
||||||
|
|
||||||
public class SearchFragment extends BaseStatusListFragment<SearchResult> implements IsOnTop {
|
public class SearchFragment extends BaseStatusListFragment<SearchResult>{
|
||||||
private String currentQuery;
|
private String currentQuery;
|
||||||
private List<StatusDisplayItem> prevDisplayItems;
|
private List<StatusDisplayItem> prevDisplayItems;
|
||||||
private EnumSet<SearchResult.Type> currentFilter=EnumSet.allOf(SearchResult.Type.class);
|
private EnumSet<SearchResult.Type> currentFilter=EnumSet.allOf(SearchResult.Type.class);
|
||||||
@@ -62,7 +62,6 @@ public class SearchFragment extends BaseStatusListFragment<SearchResult> impleme
|
|||||||
if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.N)
|
if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.N)
|
||||||
setRetainInstance(true);
|
setRetainInstance(true);
|
||||||
loadData();
|
loadData();
|
||||||
setEmptyText(R.string.sk_recent_searches_placeholder);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -76,7 +75,7 @@ public class SearchFragment extends BaseStatusListFragment<SearchResult> impleme
|
|||||||
return switch(s.type){
|
return switch(s.type){
|
||||||
case ACCOUNT -> Collections.singletonList(new AccountStatusDisplayItem(s.id, this, s.account));
|
case ACCOUNT -> Collections.singletonList(new AccountStatusDisplayItem(s.id, this, s.account));
|
||||||
case HASHTAG -> Collections.singletonList(new HashtagStatusDisplayItem(s.id, this, s.hashtag));
|
case HASHTAG -> Collections.singletonList(new HashtagStatusDisplayItem(s.id, this, s.hashtag));
|
||||||
case STATUS -> StatusDisplayItem.buildItems(this, s.status, accountID, s, knownAccounts, false, true, null);
|
case STATUS -> StatusDisplayItem.buildItems(this, s.status, accountID, s, knownAccounts, false, true);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -174,7 +173,7 @@ public class SearchFragment extends BaseStatusListFragment<SearchResult> impleme
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
UiUtils.updateList(prevDisplayItems, displayItems, list, adapter, (i1, i2)->i1.parentID.equals(i2.parentID) && i1.index==i2.index && i1.getType()==i2.getType());
|
UiUtils.updateList(prevDisplayItems, displayItems, list, adapter, (i1, i2)->i1.parentID.equals(i2.parentID) && i1.index==i2.index && i1.getType()==i2.getType());
|
||||||
boolean recent=isInRecentMode() && !displayItems.isEmpty();
|
boolean recent=isInRecentMode();
|
||||||
if(recent!=headerAdapter.isVisible())
|
if(recent!=headerAdapter.isVisible())
|
||||||
headerAdapter.setVisible(recent);
|
headerAdapter.setVisible(recent);
|
||||||
imgLoader.forceUpdateImages();
|
imgLoader.forceUpdateImages();
|
||||||
@@ -300,11 +299,6 @@ public class SearchFragment extends BaseStatusListFragment<SearchResult> impleme
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isOnTop() {
|
|
||||||
return isRecyclerViewOnTop(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
public interface ProgressVisibilityListener{
|
public interface ProgressVisibilityListener{
|
||||||
void onProgressVisibilityChanged(boolean visible);
|
void onProgressVisibilityChanged(boolean visible);
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import android.widget.TextView;
|
|||||||
|
|
||||||
import org.joinmastodon.android.R;
|
import org.joinmastodon.android.R;
|
||||||
import org.joinmastodon.android.api.requests.trends.GetTrendingHashtags;
|
import org.joinmastodon.android.api.requests.trends.GetTrendingHashtags;
|
||||||
import org.joinmastodon.android.fragments.IsOnTop;
|
|
||||||
import org.joinmastodon.android.fragments.ScrollableToTop;
|
import org.joinmastodon.android.fragments.ScrollableToTop;
|
||||||
import org.joinmastodon.android.model.Hashtag;
|
import org.joinmastodon.android.model.Hashtag;
|
||||||
import org.joinmastodon.android.ui.DividerItemDecoration;
|
import org.joinmastodon.android.ui.DividerItemDecoration;
|
||||||
@@ -24,7 +23,7 @@ import me.grishka.appkit.fragments.BaseRecyclerFragment;
|
|||||||
import me.grishka.appkit.utils.BindableViewHolder;
|
import me.grishka.appkit.utils.BindableViewHolder;
|
||||||
import me.grishka.appkit.views.UsableRecyclerView;
|
import me.grishka.appkit.views.UsableRecyclerView;
|
||||||
|
|
||||||
public class TrendingHashtagsFragment extends BaseRecyclerFragment<Hashtag> implements ScrollableToTop, IsOnTop {
|
public class TrendingHashtagsFragment extends BaseRecyclerFragment<Hashtag> implements ScrollableToTop{
|
||||||
private String accountID;
|
private String accountID;
|
||||||
private DiscoverInfoBannerHelper bannerHelper=new DiscoverInfoBannerHelper(DiscoverInfoBannerHelper.BannerType.TRENDING_HASHTAGS);
|
private DiscoverInfoBannerHelper bannerHelper=new DiscoverInfoBannerHelper(DiscoverInfoBannerHelper.BannerType.TRENDING_HASHTAGS);
|
||||||
|
|
||||||
@@ -67,11 +66,6 @@ public class TrendingHashtagsFragment extends BaseRecyclerFragment<Hashtag> impl
|
|||||||
smoothScrollRecyclerViewToTop(list);
|
smoothScrollRecyclerViewToTop(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isOnTop() {
|
|
||||||
return isRecyclerViewOnTop(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
private class HashtagsAdapter extends RecyclerView.Adapter<HashtagViewHolder>{
|
private class HashtagsAdapter extends RecyclerView.Adapter<HashtagViewHolder>{
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -96,9 +96,9 @@ public class AccountActivationFragment extends ToolbarFragment{
|
|||||||
view.setBackgroundColor(UiUtils.getThemeColor(getActivity(), R.attr.colorM3Background));
|
view.setBackgroundColor(UiUtils.getThemeColor(getActivity(), R.attr.colorM3Background));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
// @Override
|
||||||
protected void onUpdateToolbar(){
|
protected void onUpdateToolbar(){
|
||||||
super.onUpdateToolbar();
|
// super.onUpdateToolbar();
|
||||||
getToolbar().setBackground(null);
|
getToolbar().setBackground(null);
|
||||||
getToolbar().setElevation(0);
|
getToolbar().setElevation(0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,10 +36,10 @@ import me.grishka.appkit.utils.SingleViewRecyclerAdapter;
|
|||||||
import me.grishka.appkit.utils.V;
|
import me.grishka.appkit.utils.V;
|
||||||
import me.grishka.appkit.views.UsableRecyclerView;
|
import me.grishka.appkit.views.UsableRecyclerView;
|
||||||
|
|
||||||
public class CustomWelcomeFragment extends InstanceCatalogFragment {
|
public class CustomLoginFragment extends InstanceCatalogFragment {
|
||||||
private View headerView;
|
private View headerView;
|
||||||
|
|
||||||
public CustomWelcomeFragment() {
|
public CustomLoginFragment() {
|
||||||
super(R.layout.fragment_welcome_custom, 1);
|
super(R.layout.fragment_welcome_custom, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,9 +55,9 @@ public class CustomWelcomeFragment extends InstanceCatalogFragment {
|
|||||||
dataLoaded();
|
dataLoaded();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
// @Override
|
||||||
protected void onUpdateToolbar(){
|
protected void onUpdateToolbar(){
|
||||||
super.onUpdateToolbar();
|
// super.onUpdateToolbar();
|
||||||
|
|
||||||
if (!canGoBack()) {
|
if (!canGoBack()) {
|
||||||
ImageView toolbarLogo=new ImageView(getActivity());
|
ImageView toolbarLogo=new ImageView(getActivity());
|
||||||
@@ -137,11 +137,9 @@ public class CustomWelcomeFragment extends InstanceCatalogFragment {
|
|||||||
|
|
||||||
headerView.findViewById(R.id.more).setVisibility(View.GONE);
|
headerView.findViewById(R.id.more).setVisibility(View.GONE);
|
||||||
headerView.findViewById(R.id.visibility).setVisibility(View.GONE);
|
headerView.findViewById(R.id.visibility).setVisibility(View.GONE);
|
||||||
headerView.findViewById(R.id.separator).setVisibility(View.GONE);
|
((TextView) headerView.findViewById(R.id.username)).setText("@moshidon");
|
||||||
headerView.findViewById(R.id.timestamp).setVisibility(View.GONE);
|
|
||||||
headerView.findViewById(R.id.unread_indicator).setVisibility(View.GONE);
|
|
||||||
((TextView) headerView.findViewById(R.id.username)).setText(R.string.sk_app_username);
|
|
||||||
((TextView) headerView.findViewById(R.id.name)).setText(R.string.sk_app_name);
|
((TextView) headerView.findViewById(R.id.name)).setText(R.string.sk_app_name);
|
||||||
|
((TextView) headerView.findViewById(R.id.timestamp)).setText(R.string.time_now);
|
||||||
((ImageView) headerView.findViewById(R.id.avatar)).setImageDrawable(getActivity().getDrawable(R.mipmap.ic_launcher));
|
((ImageView) headerView.findViewById(R.id.avatar)).setImageDrawable(getActivity().getDrawable(R.mipmap.ic_launcher));
|
||||||
((FragmentStackActivity) getActivity()).invalidateSystemBarColors(this);
|
((FragmentStackActivity) getActivity()).invalidateSystemBarColors(this);
|
||||||
|
|
||||||
@@ -170,7 +168,7 @@ public class CustomWelcomeFragment extends InstanceCatalogFragment {
|
|||||||
return mergeAdapter;
|
return mergeAdapter;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class InstancesAdapter extends UsableRecyclerView.Adapter<InstanceViewHolder> {
|
private class InstancesAdapter extends UsableRecyclerView.Adapter<InstanceViewHolder>{
|
||||||
public InstancesAdapter(){
|
public InstancesAdapter(){
|
||||||
super(imgLoader);
|
super(imgLoader);
|
||||||
}
|
}
|
||||||
@@ -206,6 +204,11 @@ public class CustomWelcomeFragment extends InstanceCatalogFragment {
|
|||||||
|
|
||||||
public InstanceViewHolder(){
|
public InstanceViewHolder(){
|
||||||
super(getActivity(), R.layout.item_instance_custom, list);
|
super(getActivity(), R.layout.item_instance_custom, list);
|
||||||
|
|
||||||
|
// itemView.setPadding(V.dp(16), V.dp(16), V.dp(16), V.dp(16));
|
||||||
|
// TypedValue value = new TypedValue();
|
||||||
|
// getActivity().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, value, true);
|
||||||
|
// itemView.setBackground(getActivity().getTheme().getDrawable(R.drawable.bg_search_field));
|
||||||
title=findViewById(R.id.title);
|
title=findViewById(R.id.title);
|
||||||
description=findViewById(R.id.description);
|
description=findViewById(R.id.description);
|
||||||
userCount=findViewById(R.id.user_count);
|
userCount=findViewById(R.id.user_count);
|
||||||
@@ -115,9 +115,9 @@ public class GoogleMadeMeAddThisFragment extends ToolbarFragment{
|
|||||||
view.setBackgroundColor(UiUtils.getThemeColor(getActivity(), R.attr.colorM3Background));
|
view.setBackgroundColor(UiUtils.getThemeColor(getActivity(), R.attr.colorM3Background));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
// @Override
|
||||||
protected void onUpdateToolbar(){
|
protected void onUpdateToolbar(){
|
||||||
super.onUpdateToolbar();
|
// super.onUpdateToolbar();
|
||||||
getToolbar().setBackground(null);
|
getToolbar().setBackground(null);
|
||||||
getToolbar().setElevation(0);
|
getToolbar().setElevation(0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,7 +80,6 @@ public class InstanceCatalogSignupFragment extends InstanceCatalogFragment imple
|
|||||||
private LinearLayout filtersWrap;
|
private LinearLayout filtersWrap;
|
||||||
private HorizontalScrollView filtersScroll;
|
private HorizontalScrollView filtersScroll;
|
||||||
private ImageButton backBtn, clearSearchBtn;
|
private ImageButton backBtn, clearSearchBtn;
|
||||||
private View focusThing;
|
|
||||||
|
|
||||||
private FilterChipView categoryGeneral, categorySpecialInterests;
|
private FilterChipView categoryGeneral, categorySpecialInterests;
|
||||||
private List<FilterChipView> regionalFilters;
|
private List<FilterChipView> regionalFilters;
|
||||||
@@ -286,13 +285,7 @@ public class InstanceCatalogSignupFragment extends InstanceCatalogFragment imple
|
|||||||
|
|
||||||
FilterChipView langFilter=new FilterChipView(getActivity());
|
FilterChipView langFilter=new FilterChipView(getActivity());
|
||||||
langFilter.setDrawableEnd(R.drawable.ic_baseline_arrow_drop_down_18);
|
langFilter.setDrawableEnd(R.drawable.ic_baseline_arrow_drop_down_18);
|
||||||
if(currentLanguage==null){
|
langFilter.setText(R.string.server_filter_any_language);
|
||||||
langFilter.setText(R.string.server_filter_any_language);
|
|
||||||
}else{
|
|
||||||
Locale locale=Locale.forLanguageTag(currentLanguage);
|
|
||||||
langFilter.setText(locale.getDisplayLanguage(locale));
|
|
||||||
langFilter.setSelected(true);
|
|
||||||
}
|
|
||||||
langFilterMenu=new PopupMenu(getContext(), langFilter);
|
langFilterMenu=new PopupMenu(getContext(), langFilter);
|
||||||
langFilter.setOnTouchListener(langFilterMenu.getDragToOpenListener());
|
langFilter.setOnTouchListener(langFilterMenu.getDragToOpenListener());
|
||||||
langFilter.setOnClickListener(v->langFilterMenu.show());
|
langFilter.setOnClickListener(v->langFilterMenu.show());
|
||||||
@@ -308,12 +301,8 @@ public class InstanceCatalogSignupFragment extends InstanceCatalogFragment imple
|
|||||||
speedFilterMenu.getMenu().add(0, 2, 0, R.string.server_filter_manual_review);
|
speedFilterMenu.getMenu().add(0, 2, 0, R.string.server_filter_manual_review);
|
||||||
speedFilter.setOnTouchListener(speedFilterMenu.getDragToOpenListener());
|
speedFilter.setOnTouchListener(speedFilterMenu.getDragToOpenListener());
|
||||||
speedFilter.setOnClickListener(v->speedFilterMenu.show());
|
speedFilter.setOnClickListener(v->speedFilterMenu.show());
|
||||||
speedFilter.setText(switch(currentSignupSpeedFilter){
|
speedFilter.setText(R.string.server_filter_instant_signup);
|
||||||
case ANY -> R.string.server_filter_any_signup_speed;
|
speedFilter.setSelected(true);
|
||||||
case INSTANT -> R.string.server_filter_instant_signup;
|
|
||||||
case REVIEWED -> R.string.server_filter_manual_review;
|
|
||||||
});
|
|
||||||
speedFilter.setSelected(currentSignupSpeedFilter!=SignupSpeedFilter.ANY);
|
|
||||||
filtersWrap.addView(speedFilter, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
|
filtersWrap.addView(speedFilter, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
|
||||||
|
|
||||||
speedFilterMenu.setOnMenuItemClickListener(item->{
|
speedFilterMenu.setOnMenuItemClickListener(item->{
|
||||||
@@ -339,13 +328,11 @@ public class InstanceCatalogSignupFragment extends InstanceCatalogFragment imple
|
|||||||
categoryGeneral.setText(R.string.category_general);
|
categoryGeneral.setText(R.string.category_general);
|
||||||
categoryGeneral.setTag(CategoryChoice.GENERAL);
|
categoryGeneral.setTag(CategoryChoice.GENERAL);
|
||||||
categoryGeneral.setOnClickListener(this::onCategoryFilterClick);
|
categoryGeneral.setOnClickListener(this::onCategoryFilterClick);
|
||||||
categoryGeneral.setSelected(categoryChoice==CategoryChoice.GENERAL);
|
|
||||||
filtersWrap.addView(categoryGeneral, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
|
filtersWrap.addView(categoryGeneral, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
|
||||||
categorySpecialInterests=new FilterChipView(getActivity());
|
categorySpecialInterests=new FilterChipView(getActivity());
|
||||||
categorySpecialInterests.setText(R.string.category_special_interests);
|
categorySpecialInterests.setText(R.string.category_special_interests);
|
||||||
categorySpecialInterests.setTag(CategoryChoice.SPECIAL);
|
categorySpecialInterests.setTag(CategoryChoice.SPECIAL);
|
||||||
categorySpecialInterests.setOnClickListener(this::onCategoryFilterClick);
|
categorySpecialInterests.setOnClickListener(this::onCategoryFilterClick);
|
||||||
categorySpecialInterests.setSelected(categoryChoice==CategoryChoice.SPECIAL);
|
|
||||||
filtersWrap.addView(categorySpecialInterests, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
|
filtersWrap.addView(categorySpecialInterests, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
|
||||||
|
|
||||||
regionalFilters=Arrays.stream(CatalogInstance.Region.values()).map(r->{
|
regionalFilters=Arrays.stream(CatalogInstance.Region.values()).map(r->{
|
||||||
@@ -364,8 +351,6 @@ public class InstanceCatalogSignupFragment extends InstanceCatalogFragment imple
|
|||||||
filtersWrap.addView(fv, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
|
filtersWrap.addView(fv, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
|
||||||
return fv;
|
return fv;
|
||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
focusThing=view.findViewById(R.id.focus_thing);
|
|
||||||
focusThing.requestFocus();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onRegionFilterClick(View v){
|
private void onRegionFilterClick(View v){
|
||||||
@@ -565,7 +550,7 @@ public class InstanceCatalogSignupFragment extends InstanceCatalogFragment imple
|
|||||||
searchEdit.setCompoundDrawableTintList(ColorStateList.valueOf(0));
|
searchEdit.setCompoundDrawableTintList(ColorStateList.valueOf(0));
|
||||||
}else{
|
}else{
|
||||||
filtersScroll.setVisibility(View.VISIBLE);
|
filtersScroll.setVisibility(View.VISIBLE);
|
||||||
focusThing.requestFocus();
|
searchEdit.clearFocus();
|
||||||
searchEdit.setText("");
|
searchEdit.setText("");
|
||||||
lp.addRule(RelativeLayout.END_OF, R.id.btn_back);
|
lp.addRule(RelativeLayout.END_OF, R.id.btn_back);
|
||||||
getActivity().getSystemService(InputMethodManager.class).hideSoftInputFromWindow(searchEdit.getWindowToken(), 0);
|
getActivity().getSystemService(InputMethodManager.class).hideSoftInputFromWindow(searchEdit.getWindowToken(), 0);
|
||||||
|
|||||||
@@ -106,13 +106,13 @@ public class InstanceChooserLoginFragment extends InstanceCatalogFragment{
|
|||||||
.execNoAuth("");
|
.execNoAuth("");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
// @Override
|
||||||
protected void onUpdateToolbar(){
|
// protected void onUpdateToolbar(){
|
||||||
super.onUpdateToolbar();
|
// super.onUpdateToolbar();
|
||||||
Toolbar toolbar=getToolbar();
|
// Toolbar toolbar=getToolbar();
|
||||||
toolbar.setElevation(0);
|
// toolbar.setElevation(0);
|
||||||
toolbar.setBackground(null);
|
// toolbar.setBackground(null);
|
||||||
}
|
// }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected RecyclerView.Adapter getAdapter(){
|
protected RecyclerView.Adapter getAdapter(){
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ public class InstanceRulesFragment extends ToolbarFragment{
|
|||||||
adapter.addAdapter(new SingleViewRecyclerAdapter(headerView));
|
adapter.addAdapter(new SingleViewRecyclerAdapter(headerView));
|
||||||
adapter.addAdapter(new ItemsAdapter());
|
adapter.addAdapter(new ItemsAdapter());
|
||||||
list.setAdapter(adapter);
|
list.setAdapter(adapter);
|
||||||
list.addItemDecoration(new DividerItemDecoration(getActivity(), R.attr.colorPollVoted, 1, 56, 0, DividerItemDecoration.NOT_FIRST));
|
list.addItemDecoration(new DividerItemDecoration(getActivity(), R.attr.colorM3SurfaceVariant, 1, 56, 0, DividerItemDecoration.NOT_FIRST));
|
||||||
|
|
||||||
btn=view.findViewById(R.id.btn_next);
|
btn=view.findViewById(R.id.btn_next);
|
||||||
btn.setOnClickListener(v->onButtonClick());
|
btn.setOnClickListener(v->onButtonClick());
|
||||||
@@ -77,13 +77,13 @@ public class InstanceRulesFragment extends ToolbarFragment{
|
|||||||
@Override
|
@Override
|
||||||
public void onViewCreated(View view, Bundle savedInstanceState){
|
public void onViewCreated(View view, Bundle savedInstanceState){
|
||||||
super.onViewCreated(view, savedInstanceState);
|
super.onViewCreated(view, savedInstanceState);
|
||||||
// setStatusBarColor(UiUtils.getThemeColor(getActivity(), R.attr.colorM3Background));
|
setStatusBarColor(UiUtils.getThemeColor(getActivity(), R.attr.colorM3Background));
|
||||||
// view.setBackgroundColor(UiUtils.getThemeColor(getActivity(), R.attr.colorM3Background));
|
view.setBackgroundColor(UiUtils.getThemeColor(getActivity(), R.attr.colorM3Background));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
// @Override
|
||||||
protected void onUpdateToolbar(){
|
protected void onUpdateToolbar(){
|
||||||
super.onUpdateToolbar();
|
// super.onUpdateToolbar();
|
||||||
getToolbar().setBackground(null);
|
getToolbar().setBackground(null);
|
||||||
getToolbar().setElevation(0);
|
getToolbar().setElevation(0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -147,9 +147,9 @@ public class SignupFragment extends ToolbarFragment{
|
|||||||
view.setBackgroundColor(UiUtils.getThemeColor(getActivity(), R.attr.colorM3Background));
|
view.setBackgroundColor(UiUtils.getThemeColor(getActivity(), R.attr.colorM3Background));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
// @Override
|
||||||
protected void onUpdateToolbar(){
|
protected void onUpdateToolbar(){
|
||||||
super.onUpdateToolbar();
|
// super.onUpdateToolbar();
|
||||||
getToolbar().setBackground(null);
|
getToolbar().setBackground(null);
|
||||||
getToolbar().setElevation(0);
|
getToolbar().setElevation(0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -237,7 +237,7 @@ public class ReportAddPostsChoiceFragment extends StatusListFragment{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<StatusDisplayItem> buildDisplayItems(Status s){
|
protected List<StatusDisplayItem> buildDisplayItems(Status s){
|
||||||
List<StatusDisplayItem> items=StatusDisplayItem.buildItems(this, s, accountID, s, knownAccounts, true, false, null);
|
List<StatusDisplayItem> items=StatusDisplayItem.buildItems(this, s, accountID, s, knownAccounts, true, false);
|
||||||
for(StatusDisplayItem item:items){
|
for(StatusDisplayItem item:items){
|
||||||
if(item instanceof ImageStatusDisplayItem isdi){
|
if(item instanceof ImageStatusDisplayItem isdi){
|
||||||
isdi.horizontalInset=V.dp(40+32);
|
isdi.horizontalInset=V.dp(40+32);
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import android.view.ViewGroup;
|
|||||||
import android.view.WindowInsets;
|
import android.view.WindowInsets;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.Switch;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.squareup.otto.Subscribe;
|
import com.squareup.otto.Subscribe;
|
||||||
@@ -29,17 +28,15 @@ import java.util.ArrayList;
|
|||||||
import me.grishka.appkit.Nav;
|
import me.grishka.appkit.Nav;
|
||||||
import me.grishka.appkit.api.Callback;
|
import me.grishka.appkit.api.Callback;
|
||||||
import me.grishka.appkit.api.ErrorResponse;
|
import me.grishka.appkit.api.ErrorResponse;
|
||||||
|
import me.grishka.appkit.fragments.ToolbarFragment;
|
||||||
import me.grishka.appkit.utils.V;
|
import me.grishka.appkit.utils.V;
|
||||||
|
|
||||||
public class ReportCommentFragment extends MastodonToolbarFragment{
|
public class ReportCommentFragment extends MastodonToolbarFragment{
|
||||||
private String accountID;
|
private String accountID;
|
||||||
private Account reportAccount;
|
private Account reportAccount;
|
||||||
private Button btn;
|
private Button btn;
|
||||||
private View buttonBar, forwardReportItem;
|
private View buttonBar;
|
||||||
private TextView forwardReportText;
|
|
||||||
private Switch forwardReportSwitch;
|
|
||||||
private EditText commentEdit;
|
private EditText commentEdit;
|
||||||
private boolean forwardReport;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState){
|
public void onCreate(Bundle savedInstanceState){
|
||||||
@@ -80,17 +77,7 @@ public class ReportCommentFragment extends MastodonToolbarFragment{
|
|||||||
view.findViewById(R.id.btn_back).setOnClickListener(this::onButtonClick);
|
view.findViewById(R.id.btn_back).setOnClickListener(this::onButtonClick);
|
||||||
buttonBar=view.findViewById(R.id.button_bar);
|
buttonBar=view.findViewById(R.id.button_bar);
|
||||||
commentEdit=view.findViewById(R.id.text);
|
commentEdit=view.findViewById(R.id.text);
|
||||||
forwardReportSwitch = view.findViewById(R.id.forward_report_switch);
|
|
||||||
forwardReportItem = view.findViewById(R.id.forward_report);
|
|
||||||
forwardReportText = view.findViewById(R.id.forward_report_text);
|
|
||||||
String domain = reportAccount.getDomain();
|
|
||||||
if (domain == null) {
|
|
||||||
forwardReportItem.setVisibility(View.GONE);
|
|
||||||
} else {
|
|
||||||
forwardReportItem.setOnClickListener(this::onForwardReportClick);
|
|
||||||
forwardReportText.setText(getActivity().getString(R.string.sk_forward_report_to, domain));
|
|
||||||
forwardReportSwitch.setChecked(forwardReport = true);
|
|
||||||
}
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,7 +102,7 @@ public class ReportCommentFragment extends MastodonToolbarFragment{
|
|||||||
ReportReason reason=ReportReason.valueOf(getArguments().getString("reason"));
|
ReportReason reason=ReportReason.valueOf(getArguments().getString("reason"));
|
||||||
ArrayList<String> statusIDs=getArguments().getStringArrayList("statusIDs");
|
ArrayList<String> statusIDs=getArguments().getStringArrayList("statusIDs");
|
||||||
ArrayList<String> ruleIDs=getArguments().getStringArrayList("ruleIDs");
|
ArrayList<String> ruleIDs=getArguments().getStringArrayList("ruleIDs");
|
||||||
new SendReport(reportAccount.id, reason, statusIDs, ruleIDs, v.getId()==R.id.btn_back ? null : commentEdit.getText().toString(), forwardReport)
|
new SendReport(reportAccount.id, reason, statusIDs, ruleIDs, v.getId()==R.id.btn_back ? null : commentEdit.getText().toString(), true)
|
||||||
.setCallback(new Callback<>(){
|
.setCallback(new Callback<>(){
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Object result){
|
public void onSuccess(Object result){
|
||||||
@@ -136,11 +123,6 @@ public class ReportCommentFragment extends MastodonToolbarFragment{
|
|||||||
.exec(accountID);
|
.exec(accountID);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onForwardReportClick(View v) {
|
|
||||||
forwardReport = !forwardReport;
|
|
||||||
forwardReportSwitch.setChecked(forwardReport);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onFinishReportFragments(FinishReportFragmentsEvent ev){
|
public void onFinishReportFragments(FinishReportFragmentsEvent ev){
|
||||||
if(ev.reportAccountID.equals(reportAccount.id))
|
if(ev.reportAccountID.equals(reportAccount.id))
|
||||||
|
|||||||
@@ -164,10 +164,6 @@ public class Account extends BaseModel{
|
|||||||
return '@'+acct;
|
return '@'+acct;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getShortUsername() {
|
|
||||||
return '@'+acct.split("@")[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString(){
|
public String toString(){
|
||||||
return "Account{"+
|
return "Account{"+
|
||||||
|
|||||||
@@ -1,63 +0,0 @@
|
|||||||
package org.joinmastodon.android.model;
|
|
||||||
|
|
||||||
import org.joinmastodon.android.api.RequiredField;
|
|
||||||
import org.parceler.Parcel;
|
|
||||||
|
|
||||||
import java.time.Instant;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Parcel
|
|
||||||
public class Announcement extends BaseModel implements DisplayItemsParent {
|
|
||||||
@RequiredField
|
|
||||||
public String id;
|
|
||||||
@RequiredField
|
|
||||||
public String content;
|
|
||||||
public Instant startsAt;
|
|
||||||
public Instant endsAt;
|
|
||||||
public boolean published;
|
|
||||||
public boolean allDay;
|
|
||||||
public Instant publishedAt;
|
|
||||||
public Instant updatedAt;
|
|
||||||
public boolean read;
|
|
||||||
public List<Emoji> emojis;
|
|
||||||
public List<Mention> mentions;
|
|
||||||
public List<Hashtag> tags;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "Announcement{" +
|
|
||||||
"id='" + id + '\'' +
|
|
||||||
", content='" + content + '\'' +
|
|
||||||
", startsAt=" + startsAt +
|
|
||||||
", endsAt=" + endsAt +
|
|
||||||
", published=" + published +
|
|
||||||
", allDay=" + allDay +
|
|
||||||
", publishedAt=" + publishedAt +
|
|
||||||
", updatedAt=" + updatedAt +
|
|
||||||
", read=" + read +
|
|
||||||
", emojis=" + emojis +
|
|
||||||
", mentions=" + mentions +
|
|
||||||
", tags=" + tags +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
|
|
||||||
public Status toStatus() {
|
|
||||||
Status s = new Status();
|
|
||||||
s.id = id;
|
|
||||||
s.mediaAttachments = List.of();
|
|
||||||
s.createdAt = startsAt != null ? startsAt : publishedAt;
|
|
||||||
if (updatedAt != null) s.editedAt = updatedAt;
|
|
||||||
s.content = s.text = content;
|
|
||||||
s.spoilerText = "";
|
|
||||||
s.visibility = StatusPrivacy.PUBLIC;
|
|
||||||
s.mentions = List.of();
|
|
||||||
s.tags = List.of();
|
|
||||||
s.emojis = List.of();
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getID() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -14,11 +14,9 @@ import org.parceler.Parcel;
|
|||||||
import org.parceler.ParcelConstructor;
|
import org.parceler.ParcelConstructor;
|
||||||
import org.parceler.ParcelProperty;
|
import org.parceler.ParcelProperty;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
@Parcel
|
@Parcel
|
||||||
public class Attachment extends BaseModel{
|
public class Attachment extends BaseModel{
|
||||||
// @RequiredField
|
@RequiredField
|
||||||
public String id;
|
public String id;
|
||||||
@RequiredField
|
@RequiredField
|
||||||
public Type type;
|
public Type type;
|
||||||
@@ -87,12 +85,6 @@ public class Attachment extends BaseModel{
|
|||||||
if(placeholder!=null)
|
if(placeholder!=null)
|
||||||
blurhashPlaceholder=new BlurHashDrawable(placeholder, getWidth(), getHeight());
|
blurhashPlaceholder=new BlurHashDrawable(placeholder, getWidth(), getHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (id == null) {
|
|
||||||
// akkoma servers doesn't provide IDs for attachments,
|
|
||||||
// but IDs are needed by the AudioPlayerService
|
|
||||||
id = "" + this.hashCode();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -6,14 +6,12 @@ import com.google.gson.annotations.SerializedName;
|
|||||||
|
|
||||||
import org.joinmastodon.android.api.ObjectValidationException;
|
import org.joinmastodon.android.api.ObjectValidationException;
|
||||||
import org.joinmastodon.android.api.RequiredField;
|
import org.joinmastodon.android.api.RequiredField;
|
||||||
import org.parceler.Parcel;
|
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
@Parcel
|
|
||||||
public class Filter extends BaseModel{
|
public class Filter extends BaseModel{
|
||||||
@RequiredField
|
@RequiredField
|
||||||
public String id;
|
public String id;
|
||||||
@@ -23,7 +21,6 @@ public class Filter extends BaseModel{
|
|||||||
public Instant expiresAt;
|
public Instant expiresAt;
|
||||||
public boolean irreversible;
|
public boolean irreversible;
|
||||||
public boolean wholeWord;
|
public boolean wholeWord;
|
||||||
public FilterAction filterAction;
|
|
||||||
|
|
||||||
@SerializedName("context")
|
@SerializedName("context")
|
||||||
private List<FilterContext> _context;
|
private List<FilterContext> _context;
|
||||||
@@ -79,11 +76,4 @@ public class Filter extends BaseModel{
|
|||||||
@SerializedName("thread")
|
@SerializedName("thread")
|
||||||
THREAD
|
THREAD
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum FilterAction{
|
|
||||||
@SerializedName("hide")
|
|
||||||
HIDE,
|
|
||||||
@SerializedName("warn")
|
|
||||||
WARN
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
package org.joinmastodon.android.model;
|
|
||||||
|
|
||||||
import org.parceler.Parcel;
|
|
||||||
|
|
||||||
@Parcel
|
|
||||||
public class FilterResult extends BaseModel {
|
|
||||||
public Filter filter;
|
|
||||||
}
|
|
||||||
@@ -27,7 +27,7 @@ public class Instance extends BaseModel{
|
|||||||
/**
|
/**
|
||||||
* Admin-defined description of the Mastodon site.
|
* Admin-defined description of the Mastodon site.
|
||||||
*/
|
*/
|
||||||
// @RequiredField
|
@RequiredField
|
||||||
public String description;
|
public String description;
|
||||||
/**
|
/**
|
||||||
* A shorter description defined by the admin.
|
* A shorter description defined by the admin.
|
||||||
@@ -37,7 +37,7 @@ public class Instance extends BaseModel{
|
|||||||
/**
|
/**
|
||||||
* An email that may be contacted for any inquiries.
|
* An email that may be contacted for any inquiries.
|
||||||
*/
|
*/
|
||||||
// @RequiredField
|
@RequiredField
|
||||||
public String email;
|
public String email;
|
||||||
/**
|
/**
|
||||||
* The version of Mastodon installed on the instance.
|
* The version of Mastodon installed on the instance.
|
||||||
|
|||||||
@@ -57,11 +57,6 @@ public class Poll extends BaseModel{
|
|||||||
public String title;
|
public String title;
|
||||||
public Integer votesCount;
|
public Integer votesCount;
|
||||||
|
|
||||||
public Option() {}
|
|
||||||
public Option(String title) {
|
|
||||||
this.title = title;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString(){
|
public String toString(){
|
||||||
return "Option{"+
|
return "Option{"+
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ public class PushSubscription extends BaseModel implements Cloneable{
|
|||||||
", endpoint='"+endpoint+'\''+
|
", endpoint='"+endpoint+'\''+
|
||||||
", alerts="+alerts+
|
", alerts="+alerts+
|
||||||
", serverKey='"+serverKey+'\''+
|
", serverKey='"+serverKey+'\''+
|
||||||
", policy="+policy+
|
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,81 +0,0 @@
|
|||||||
package org.joinmastodon.android.model;
|
|
||||||
|
|
||||||
import org.joinmastodon.android.api.RequiredField;
|
|
||||||
import org.joinmastodon.android.model.Poll.Option;
|
|
||||||
import org.parceler.Parcel;
|
|
||||||
|
|
||||||
import java.time.Instant;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@Parcel
|
|
||||||
public class ScheduledStatus extends BaseModel implements DisplayItemsParent{
|
|
||||||
@RequiredField
|
|
||||||
public String id;
|
|
||||||
@RequiredField
|
|
||||||
public Instant scheduledAt;
|
|
||||||
@RequiredField
|
|
||||||
public Params params;
|
|
||||||
@RequiredField
|
|
||||||
public List<Attachment> mediaAttachments;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getID() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Parcel
|
|
||||||
public static class Params {
|
|
||||||
@RequiredField
|
|
||||||
public String text;
|
|
||||||
public String spoilerText;
|
|
||||||
@RequiredField
|
|
||||||
public StatusPrivacy visibility;
|
|
||||||
public long inReplyToId;
|
|
||||||
public ScheduledPoll poll;
|
|
||||||
public boolean sensitive;
|
|
||||||
public boolean withRateLimit;
|
|
||||||
public String language;
|
|
||||||
public String idempotency;
|
|
||||||
public String applicationId;
|
|
||||||
public List<String> mediaIds;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Parcel
|
|
||||||
public static class ScheduledPoll {
|
|
||||||
@RequiredField
|
|
||||||
public String expiresIn;
|
|
||||||
@RequiredField
|
|
||||||
public List<String> options;
|
|
||||||
public boolean multiple;
|
|
||||||
public boolean hideTotals;
|
|
||||||
|
|
||||||
public Poll toPoll() {
|
|
||||||
Poll p = new Poll();
|
|
||||||
p.voted = true;
|
|
||||||
p.emojis = List.of();
|
|
||||||
p.ownVotes = List.of();
|
|
||||||
p.multiple = multiple;
|
|
||||||
p.options = options.stream().map(Option::new).collect(Collectors.toList());
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Status toStatus() {
|
|
||||||
Status s = new Status();
|
|
||||||
s.id = id;
|
|
||||||
s.mediaAttachments = mediaAttachments;
|
|
||||||
s.createdAt = scheduledAt;
|
|
||||||
s.inReplyToId = params.inReplyToId > 0 ? "" + params.inReplyToId : null;
|
|
||||||
s.content = s.text = params.text;
|
|
||||||
s.spoilerText = params.spoilerText;
|
|
||||||
s.visibility = params.visibility;
|
|
||||||
s.language = params.language;
|
|
||||||
s.sensitive = params.sensitive;
|
|
||||||
s.mentions = List.of();
|
|
||||||
s.tags = List.of();
|
|
||||||
s.emojis = List.of();
|
|
||||||
if (params.poll != null) s.poll = params.poll.toPoll();
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -40,7 +40,7 @@ public class Status extends BaseModel implements DisplayItemsParent{
|
|||||||
public long favouritesCount;
|
public long favouritesCount;
|
||||||
public long repliesCount;
|
public long repliesCount;
|
||||||
public Instant editedAt;
|
public Instant editedAt;
|
||||||
public List<FilterResult> filtered;
|
public boolean wantsTranslation;
|
||||||
|
|
||||||
public String url;
|
public String url;
|
||||||
public String inReplyToId;
|
public String inReplyToId;
|
||||||
@@ -50,6 +50,7 @@ public class Status extends BaseModel implements DisplayItemsParent{
|
|||||||
public Card card;
|
public Card card;
|
||||||
public String language;
|
public String language;
|
||||||
public String text;
|
public String text;
|
||||||
|
public String translation;
|
||||||
|
|
||||||
public boolean favourited;
|
public boolean favourited;
|
||||||
public boolean reblogged;
|
public boolean reblogged;
|
||||||
|
|||||||
@@ -1,204 +0,0 @@
|
|||||||
package org.joinmastodon.android.model;
|
|
||||||
|
|
||||||
import android.app.Fragment;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Bundle;
|
|
||||||
|
|
||||||
import androidx.annotation.DrawableRes;
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import androidx.annotation.StringRes;
|
|
||||||
|
|
||||||
import org.joinmastodon.android.BuildConfig;
|
|
||||||
import org.joinmastodon.android.R;
|
|
||||||
import org.joinmastodon.android.fragments.HashtagTimelineFragment;
|
|
||||||
import org.joinmastodon.android.fragments.HomeTimelineFragment;
|
|
||||||
import org.joinmastodon.android.fragments.ListTimelineFragment;
|
|
||||||
import org.joinmastodon.android.fragments.NotificationsListFragment;
|
|
||||||
import org.joinmastodon.android.fragments.discover.FederatedTimelineFragment;
|
|
||||||
import org.joinmastodon.android.fragments.discover.LocalTimelineFragment;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
public class TimelineDefinition {
|
|
||||||
private TimelineType type;
|
|
||||||
private String title;
|
|
||||||
private @Nullable Icon icon;
|
|
||||||
|
|
||||||
private @Nullable String listId;
|
|
||||||
private @Nullable String listTitle;
|
|
||||||
|
|
||||||
private @Nullable String hashtagName;
|
|
||||||
|
|
||||||
public static TimelineDefinition ofList(String listId, String listTitle) {
|
|
||||||
TimelineDefinition def = new TimelineDefinition(TimelineType.LIST, listTitle);
|
|
||||||
def.listId = listId;
|
|
||||||
def.listTitle = listTitle;
|
|
||||||
return def;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static TimelineDefinition ofList(ListTimeline list) {
|
|
||||||
return ofList(list.id, list.title);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static TimelineDefinition ofHashtag(String hashtag) {
|
|
||||||
TimelineDefinition def = new TimelineDefinition(TimelineType.HASHTAG, hashtag);
|
|
||||||
def.hashtagName = hashtag;
|
|
||||||
return def;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static TimelineDefinition ofHashtag(Hashtag hashtag) {
|
|
||||||
return ofHashtag(hashtag.name);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
public TimelineDefinition() {}
|
|
||||||
|
|
||||||
public TimelineDefinition(TimelineType type) {
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TimelineDefinition(TimelineType type, String title) {
|
|
||||||
this.type = type;
|
|
||||||
this.title = title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTitle(Context ctx) {
|
|
||||||
return title != null ? title : getDefaultTitle(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getCustomTitle() {
|
|
||||||
return title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTitle(String title) {
|
|
||||||
this.title = title == null || title.isBlank() ? null : title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDefaultTitle(Context ctx) {
|
|
||||||
return switch (type) {
|
|
||||||
case HOME -> ctx.getString(R.string.sk_timeline_home);
|
|
||||||
case LOCAL -> ctx.getString(R.string.sk_timeline_local);
|
|
||||||
case FEDERATED -> ctx.getString(R.string.sk_timeline_federated);
|
|
||||||
case POST_NOTIFICATIONS -> ctx.getString(R.string.sk_timeline_posts);
|
|
||||||
case LIST -> listTitle;
|
|
||||||
case HASHTAG -> hashtagName;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public Icon getDefaultIcon() {
|
|
||||||
return switch (type) {
|
|
||||||
case HOME -> Icon.HOME;
|
|
||||||
case LOCAL -> Icon.LOCAL;
|
|
||||||
case FEDERATED -> Icon.FEDERATED;
|
|
||||||
case POST_NOTIFICATIONS -> Icon.POST_NOTIFICATIONS;
|
|
||||||
case LIST -> Icon.LIST;
|
|
||||||
case HASHTAG -> Icon.HASHTAG;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public Fragment getFragment() {
|
|
||||||
return switch (type) {
|
|
||||||
case HOME -> new HomeTimelineFragment();
|
|
||||||
case LOCAL -> new LocalTimelineFragment();
|
|
||||||
case FEDERATED -> new FederatedTimelineFragment();
|
|
||||||
case LIST -> new ListTimelineFragment();
|
|
||||||
case HASHTAG -> new HashtagTimelineFragment();
|
|
||||||
case POST_NOTIFICATIONS -> new NotificationsListFragment();
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public Icon getIcon() {
|
|
||||||
return icon == null ? getDefaultIcon() : icon;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIcon(@Nullable Icon icon) {
|
|
||||||
this.icon = icon;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TimelineType getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) return true;
|
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
|
||||||
|
|
||||||
TimelineDefinition that = (TimelineDefinition) o;
|
|
||||||
if (type != that.type) return false;
|
|
||||||
if (type == TimelineType.LIST) return Objects.equals(listId, that.listId);
|
|
||||||
if (type == TimelineType.HASHTAG) return Objects.equals(hashtagName.toLowerCase(), that.hashtagName.toLowerCase());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
int result = type.ordinal();
|
|
||||||
result = 31 * result + (listId != null ? listId.hashCode() : 0);
|
|
||||||
result = 31 * result + (hashtagName.toLowerCase() != null ? hashtagName.toLowerCase().hashCode() : 0);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TimelineDefinition copy() {
|
|
||||||
TimelineDefinition def = new TimelineDefinition(type, title);
|
|
||||||
def.listId = listId;
|
|
||||||
def.listTitle = listTitle;
|
|
||||||
def.hashtagName = hashtagName;
|
|
||||||
def.icon = icon == null ? null : Icon.values()[icon.ordinal()];
|
|
||||||
return def;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Bundle populateArguments(Bundle args) {
|
|
||||||
if (type == TimelineType.LIST) {
|
|
||||||
args.putString("listTitle", title);
|
|
||||||
args.putString("listID", listId);
|
|
||||||
} else if (type == TimelineType.HASHTAG) {
|
|
||||||
args.putString("hashtag", hashtagName);
|
|
||||||
}
|
|
||||||
return args;
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum TimelineType { HOME, LOCAL, FEDERATED, POST_NOTIFICATIONS, LIST, HASHTAG }
|
|
||||||
|
|
||||||
public enum Icon {
|
|
||||||
HEART(R.drawable.ic_fluent_heart_24_regular, R.string.sk_icon_heart),
|
|
||||||
STAR(R.drawable.ic_fluent_star_24_regular, R.string.sk_icon_star),
|
|
||||||
|
|
||||||
HOME(R.drawable.ic_fluent_home_24_regular, R.string.sk_timeline_home, true),
|
|
||||||
LOCAL(R.drawable.ic_fluent_people_community_24_regular, R.string.sk_timeline_local, true),
|
|
||||||
FEDERATED(R.drawable.ic_fluent_earth_24_regular, R.string.sk_timeline_federated, true),
|
|
||||||
POST_NOTIFICATIONS(R.drawable.ic_fluent_alert_24_regular, R.string.sk_timeline_posts, true),
|
|
||||||
LIST(R.drawable.ic_fluent_people_list_24_regular, R.string.sk_list, true),
|
|
||||||
HASHTAG(R.drawable.ic_fluent_number_symbol_24_regular, R.string.sk_hashtag, true);
|
|
||||||
|
|
||||||
public final int iconRes, nameRes;
|
|
||||||
public final boolean hidden;
|
|
||||||
|
|
||||||
Icon(@DrawableRes int iconRes, @StringRes int nameRes) {
|
|
||||||
this(iconRes, nameRes, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
Icon(@DrawableRes int iconRes, @StringRes int nameRes, boolean hidden) {
|
|
||||||
this.iconRes = iconRes;
|
|
||||||
this.nameRes = nameRes;
|
|
||||||
this.hidden = hidden;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final TimelineDefinition HOME_TIMELINE = new TimelineDefinition(TimelineType.HOME);
|
|
||||||
public static final TimelineDefinition LOCAL_TIMELINE = new TimelineDefinition(TimelineType.LOCAL);
|
|
||||||
public static final TimelineDefinition FEDERATED_TIMELINE = new TimelineDefinition(TimelineType.FEDERATED);
|
|
||||||
public static final TimelineDefinition POSTS_TIMELINE = new TimelineDefinition(TimelineType.POST_NOTIFICATIONS);
|
|
||||||
|
|
||||||
public static final List<TimelineDefinition> DEFAULT_TIMELINES = BuildConfig.BUILD_TYPE.equals("playRelease")
|
|
||||||
? List.of(HOME_TIMELINE.copy(), LOCAL_TIMELINE.copy())
|
|
||||||
: List.of(HOME_TIMELINE.copy(), LOCAL_TIMELINE.copy(), FEDERATED_TIMELINE.copy());
|
|
||||||
public static final List<TimelineDefinition> ALL_TIMELINES = List.of(
|
|
||||||
HOME_TIMELINE.copy(),
|
|
||||||
LOCAL_TIMELINE.copy(),
|
|
||||||
FEDERATED_TIMELINE.copy(),
|
|
||||||
POSTS_TIMELINE.copy()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package org.joinmastodon.android.model;
|
package org.joinmastodon.android.model;
|
||||||
|
|
||||||
public class TranslatedStatus extends BaseModel {
|
public class TranslatedStatus extends BaseModel {
|
||||||
public String content;
|
public String content;
|
||||||
public String detectedSourceLanguage;
|
public String detectedSourceLanguage;
|
||||||
public String provider;
|
public String provider;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import org.joinmastodon.android.R;
|
|||||||
import org.joinmastodon.android.api.requests.oauth.RevokeOauthToken;
|
import org.joinmastodon.android.api.requests.oauth.RevokeOauthToken;
|
||||||
import org.joinmastodon.android.api.session.AccountSession;
|
import org.joinmastodon.android.api.session.AccountSession;
|
||||||
import org.joinmastodon.android.api.session.AccountSessionManager;
|
import org.joinmastodon.android.api.session.AccountSessionManager;
|
||||||
import org.joinmastodon.android.fragments.onboarding.CustomWelcomeFragment;
|
import org.joinmastodon.android.fragments.onboarding.CustomLoginFragment;
|
||||||
import org.joinmastodon.android.ui.utils.UiUtils;
|
import org.joinmastodon.android.ui.utils.UiUtils;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -77,7 +77,7 @@ public class AccountSwitcherSheet extends BottomSheet{
|
|||||||
holder.avatar.setImageResource(R.drawable.ic_fluent_add_circle_24_filled);
|
holder.avatar.setImageResource(R.drawable.ic_fluent_add_circle_24_filled);
|
||||||
holder.avatar.setImageTintList(ColorStateList.valueOf(UiUtils.getThemeColor(activity, android.R.attr.textColorPrimary)));
|
holder.avatar.setImageTintList(ColorStateList.valueOf(UiUtils.getThemeColor(activity, android.R.attr.textColorPrimary)));
|
||||||
adapter.addAdapter(new ClickableSingleViewRecyclerAdapter(holder.itemView, ()->{
|
adapter.addAdapter(new ClickableSingleViewRecyclerAdapter(holder.itemView, ()->{
|
||||||
Nav.go(activity, CustomWelcomeFragment.class, null);
|
Nav.go(activity, CustomLoginFragment.class, null);
|
||||||
dismiss();
|
dismiss();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import android.app.AlertDialog;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.ImageView;
|
|
||||||
|
|
||||||
import me.grishka.appkit.utils.V;
|
import me.grishka.appkit.utils.V;
|
||||||
|
|
||||||
@@ -32,16 +31,8 @@ public class M3AlertDialogBuilder extends AlertDialog.Builder{
|
|||||||
if(titleID!=0){
|
if(titleID!=0){
|
||||||
View title=alert.findViewById(titleID);
|
View title=alert.findViewById(titleID);
|
||||||
if(title!=null){
|
if(title!=null){
|
||||||
int iconID=getContext().getResources().getIdentifier("icon", "id", "android");
|
|
||||||
int alertTitleID=getContext().getResources().getIdentifier("alertTitle", "id", "android");
|
|
||||||
if (alertTitleID != 0 && iconID != 0) {
|
|
||||||
ImageView icon = title.findViewById(iconID);
|
|
||||||
if (icon.getDrawable() != null) {
|
|
||||||
title.findViewById(alertTitleID).setPadding(V.dp(8), 0, 0, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
int pad=V.dp(24);
|
int pad=V.dp(24);
|
||||||
title.setPadding(pad, pad, pad, V.dp(12));
|
title.setPadding(pad, pad, pad, pad);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int titleDividerID=getContext().getResources().getIdentifier("titleDividerNoCustom", "id", "android");
|
int titleDividerID=getContext().getResources().getIdentifier("titleDividerNoCustom", "id", "android");
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ public class ExtendedFooterStatusDisplayItem extends StatusDisplayItem{
|
|||||||
case PUBLIC -> R.drawable.ic_fluent_earth_20_regular;
|
case PUBLIC -> R.drawable.ic_fluent_earth_20_regular;
|
||||||
case UNLISTED -> R.drawable.ic_fluent_people_community_20_regular;
|
case UNLISTED -> R.drawable.ic_fluent_people_community_20_regular;
|
||||||
case PRIVATE -> R.drawable.ic_fluent_people_checkmark_20_regular;
|
case PRIVATE -> R.drawable.ic_fluent_people_checkmark_20_regular;
|
||||||
case DIRECT -> R.drawable.ic_fluent_mention_20_regular;
|
case DIRECT -> R.drawable.ic_at_symbol;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,9 @@
|
|||||||
package org.joinmastodon.android.ui.displayitems;
|
package org.joinmastodon.android.ui.displayitems;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.Dialog;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.drawable.Drawable;
|
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewConfiguration;
|
import android.view.ViewConfiguration;
|
||||||
@@ -22,18 +18,14 @@ import android.widget.TextView;
|
|||||||
|
|
||||||
import org.joinmastodon.android.GlobalUserPreferences;
|
import org.joinmastodon.android.GlobalUserPreferences;
|
||||||
import org.joinmastodon.android.R;
|
import org.joinmastodon.android.R;
|
||||||
import org.joinmastodon.android.api.session.AccountSession;
|
|
||||||
import org.joinmastodon.android.api.session.AccountSessionManager;
|
import org.joinmastodon.android.api.session.AccountSessionManager;
|
||||||
import org.joinmastodon.android.fragments.BaseStatusListFragment;
|
import org.joinmastodon.android.fragments.BaseStatusListFragment;
|
||||||
import org.joinmastodon.android.fragments.ComposeFragment;
|
import org.joinmastodon.android.fragments.ComposeFragment;
|
||||||
import org.joinmastodon.android.model.Status;
|
import org.joinmastodon.android.model.Status;
|
||||||
import org.joinmastodon.android.model.StatusPrivacy;
|
import org.joinmastodon.android.model.StatusPrivacy;
|
||||||
import org.joinmastodon.android.ui.M3AlertDialogBuilder;
|
|
||||||
import org.joinmastodon.android.ui.utils.UiUtils;
|
import org.joinmastodon.android.ui.utils.UiUtils;
|
||||||
import org.parceler.Parcels;
|
import org.parceler.Parcels;
|
||||||
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
|
|
||||||
import me.grishka.appkit.Nav;
|
import me.grishka.appkit.Nav;
|
||||||
import me.grishka.appkit.utils.CubicBezierInterpolator;
|
import me.grishka.appkit.utils.CubicBezierInterpolator;
|
||||||
import me.grishka.appkit.utils.V;
|
import me.grishka.appkit.utils.V;
|
||||||
@@ -60,14 +52,7 @@ public class FooterStatusDisplayItem extends StatusDisplayItem{
|
|||||||
private static final Animation opacityOut, opacityIn;
|
private static final Animation opacityOut, opacityIn;
|
||||||
|
|
||||||
private View touchingView = null;
|
private View touchingView = null;
|
||||||
private boolean longClickPerformed = false;
|
private final Runnable longClickRunnable = () -> { if (touchingView != null) touchingView.performLongClick(); };
|
||||||
private final Runnable longClickRunnable = () -> {
|
|
||||||
longClickPerformed = touchingView != null && touchingView.performLongClick();
|
|
||||||
if (longClickPerformed && touchingView != null) {
|
|
||||||
touchingView.startAnimation(opacityIn);
|
|
||||||
touchingView.animate().scaleX(1).scaleY(1).setInterpolator(CubicBezierInterpolator.DEFAULT).setDuration(150).start();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private final View.AccessibilityDelegate buttonAccessibilityDelegate=new View.AccessibilityDelegate(){
|
private final View.AccessibilityDelegate buttonAccessibilityDelegate=new View.AccessibilityDelegate(){
|
||||||
@Override
|
@Override
|
||||||
@@ -79,12 +64,12 @@ public class FooterStatusDisplayItem extends StatusDisplayItem{
|
|||||||
};
|
};
|
||||||
|
|
||||||
static {
|
static {
|
||||||
opacityOut = new AlphaAnimation(1, 0.55f);
|
opacityOut = new AlphaAnimation(1, 0.7f);
|
||||||
opacityOut.setDuration(300);
|
opacityOut.setDuration(200);
|
||||||
opacityOut.setInterpolator(CubicBezierInterpolator.DEFAULT);
|
opacityOut.setInterpolator(CubicBezierInterpolator.DEFAULT);
|
||||||
opacityOut.setFillAfter(true);
|
opacityOut.setFillAfter(true);
|
||||||
opacityIn = new AlphaAnimation(0.55f, 1);
|
opacityIn = new AlphaAnimation(0.7f, 1);
|
||||||
opacityIn.setDuration(400);
|
opacityIn.setDuration(300);
|
||||||
opacityIn.setInterpolator(CubicBezierInterpolator.DEFAULT);
|
opacityIn.setInterpolator(CubicBezierInterpolator.DEFAULT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,7 +93,6 @@ public class FooterStatusDisplayItem extends StatusDisplayItem{
|
|||||||
View bookmark=findViewById(R.id.bookmark_btn);
|
View bookmark=findViewById(R.id.bookmark_btn);
|
||||||
reply.setOnTouchListener(this::onButtonTouch);
|
reply.setOnTouchListener(this::onButtonTouch);
|
||||||
reply.setOnClickListener(this::onReplyClick);
|
reply.setOnClickListener(this::onReplyClick);
|
||||||
reply.setOnLongClickListener(this::onReplyLongClick);
|
|
||||||
reply.setAccessibilityDelegate(buttonAccessibilityDelegate);
|
reply.setAccessibilityDelegate(buttonAccessibilityDelegate);
|
||||||
boost.setOnTouchListener(this::onButtonTouch);
|
boost.setOnTouchListener(this::onButtonTouch);
|
||||||
boost.setOnClickListener(this::onBoostClick);
|
boost.setOnClickListener(this::onBoostClick);
|
||||||
@@ -116,11 +100,9 @@ public class FooterStatusDisplayItem extends StatusDisplayItem{
|
|||||||
boost.setAccessibilityDelegate(buttonAccessibilityDelegate);
|
boost.setAccessibilityDelegate(buttonAccessibilityDelegate);
|
||||||
favorite.setOnTouchListener(this::onButtonTouch);
|
favorite.setOnTouchListener(this::onButtonTouch);
|
||||||
favorite.setOnClickListener(this::onFavoriteClick);
|
favorite.setOnClickListener(this::onFavoriteClick);
|
||||||
favorite.setOnLongClickListener(this::onFavoriteLongClick);
|
|
||||||
favorite.setAccessibilityDelegate(buttonAccessibilityDelegate);
|
favorite.setAccessibilityDelegate(buttonAccessibilityDelegate);
|
||||||
bookmark.setOnTouchListener(this::onButtonTouch);
|
bookmark.setOnTouchListener(this::onButtonTouch);
|
||||||
bookmark.setOnClickListener(this::onBookmarkClick);
|
bookmark.setOnClickListener(this::onBookmarkClick);
|
||||||
bookmark.setOnLongClickListener(this::onBookmarkLongClick);
|
|
||||||
bookmark.setAccessibilityDelegate(buttonAccessibilityDelegate);
|
bookmark.setAccessibilityDelegate(buttonAccessibilityDelegate);
|
||||||
share.setOnTouchListener(this::onButtonTouch);
|
share.setOnTouchListener(this::onButtonTouch);
|
||||||
share.setOnClickListener(this::onShareClick);
|
share.setOnClickListener(this::onShareClick);
|
||||||
@@ -133,7 +115,6 @@ public class FooterStatusDisplayItem extends StatusDisplayItem{
|
|||||||
bindButton(reply, item.status.repliesCount);
|
bindButton(reply, item.status.repliesCount);
|
||||||
bindButton(boost, item.status.reblogsCount);
|
bindButton(boost, item.status.reblogsCount);
|
||||||
bindButton(favorite, item.status.favouritesCount);
|
bindButton(favorite, item.status.favouritesCount);
|
||||||
reply.setSelected(item.status.repliesCount > 0);
|
|
||||||
boost.setSelected(item.status.reblogged);
|
boost.setSelected(item.status.reblogged);
|
||||||
favorite.setSelected(item.status.favourited);
|
favorite.setSelected(item.status.favourited);
|
||||||
bookmark.setSelected(item.status.bookmarked);
|
bookmark.setSelected(item.status.bookmarked);
|
||||||
@@ -155,15 +136,15 @@ public class FooterStatusDisplayItem extends StatusDisplayItem{
|
|||||||
boolean disabled = !v.isEnabled() || (v instanceof FrameLayout parentFrame &&
|
boolean disabled = !v.isEnabled() || (v instanceof FrameLayout parentFrame &&
|
||||||
parentFrame.getChildCount() > 0 && !parentFrame.getChildAt(0).isEnabled());
|
parentFrame.getChildCount() > 0 && !parentFrame.getChildAt(0).isEnabled());
|
||||||
int action = event.getAction();
|
int action = event.getAction();
|
||||||
|
long eventDuration = event.getEventTime() - event.getDownTime();
|
||||||
if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) {
|
if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) {
|
||||||
touchingView = null;
|
touchingView = null;
|
||||||
v.removeCallbacks(longClickRunnable);
|
v.removeCallbacks(longClickRunnable);
|
||||||
if (!longClickPerformed) v.animate().scaleX(1).scaleY(1).setInterpolator(CubicBezierInterpolator.DEFAULT).setDuration(150).start();
|
v.animate().scaleX(1).scaleY(1).setInterpolator(CubicBezierInterpolator.DEFAULT).setDuration(150).start();
|
||||||
if (disabled) return true;
|
if (disabled) return true;
|
||||||
if (action == MotionEvent.ACTION_UP && !longClickPerformed) v.performClick();
|
if (action == MotionEvent.ACTION_UP && eventDuration < ViewConfiguration.getLongPressTimeout()) v.performClick();
|
||||||
else if (!longClickPerformed) v.startAnimation(opacityIn);
|
else v.startAnimation(opacityIn);
|
||||||
} else if (action == MotionEvent.ACTION_DOWN) {
|
} else if (action == MotionEvent.ACTION_DOWN) {
|
||||||
longClickPerformed = false;
|
|
||||||
touchingView = v;
|
touchingView = v;
|
||||||
// 20dp to center in middle of icon, because: (icon width = 24dp) / 2 + (paddingStart = 8dp)
|
// 20dp to center in middle of icon, because: (icon width = 24dp) / 2 + (paddingStart = 8dp)
|
||||||
v.setPivotX(V.dp(20));
|
v.setPivotX(V.dp(20));
|
||||||
@@ -183,113 +164,23 @@ public class FooterStatusDisplayItem extends StatusDisplayItem{
|
|||||||
Nav.go(item.parentFragment.getActivity(), ComposeFragment.class, args);
|
Nav.go(item.parentFragment.getActivity(), ComposeFragment.class, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean onReplyLongClick(View v) {
|
|
||||||
if (AccountSessionManager.getInstance().getLoggedInAccounts().size() < 2) return false;
|
|
||||||
UiUtils.pickAccount(v.getContext(), item.accountID, R.string.sk_reply_as, R.drawable.ic_fluent_arrow_reply_28_regular, session -> {
|
|
||||||
Bundle args=new Bundle();
|
|
||||||
String accountID = session.getID();
|
|
||||||
args.putString("account", accountID);
|
|
||||||
UiUtils.lookupStatus(v.getContext(), item.status, accountID, item.accountID, status -> {
|
|
||||||
args.putParcelable("replyTo", Parcels.wrap(status));
|
|
||||||
Nav.go(item.parentFragment.getActivity(), ComposeFragment.class, args);
|
|
||||||
});
|
|
||||||
}, null);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onBoostClick(View v){
|
private void onBoostClick(View v){
|
||||||
boost.setSelected(!item.status.reblogged);
|
boost.setSelected(!item.status.reblogged);
|
||||||
AccountSessionManager.getInstance().getAccount(item.accountID).getStatusInteractionController().setReblogged(item.status, !item.status.reblogged, null, r->boostConsumer(v, r));
|
AccountSessionManager.getInstance().getAccount(item.accountID).getStatusInteractionController().setReblogged(item.status, !item.status.reblogged, r->{
|
||||||
}
|
v.startAnimation(opacityIn);
|
||||||
|
bindButton(boost, r.reblogsCount);
|
||||||
private void boostConsumer(View v, Status r) {
|
});
|
||||||
v.startAnimation(opacityIn);
|
|
||||||
bindButton(boost, r.reblogsCount);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean onBoostLongClick(View v){
|
private boolean onBoostLongClick(View v){
|
||||||
Context ctx = itemView.getContext();
|
v.setAlpha(1);
|
||||||
View menu = LayoutInflater.from(ctx).inflate(R.layout.item_boost_menu, null);
|
v.setScaleX(1);
|
||||||
Dialog dialog = new M3AlertDialogBuilder(ctx).setView(menu).create();
|
v.setScaleY(1);
|
||||||
AccountSession session = AccountSessionManager.getInstance().getAccount(item.accountID);
|
Bundle args=new Bundle();
|
||||||
|
args.putString("account", item.accountID);
|
||||||
Consumer<StatusPrivacy> doReblog = (visibility) -> {
|
args.putString("prefilledText", "\n\n" + item.status.url);
|
||||||
v.startAnimation(opacityOut);
|
args.putInt("selectionStart", 0);
|
||||||
session.getStatusInteractionController()
|
Nav.go(item.parentFragment.getActivity(), ComposeFragment.class, args);
|
||||||
.setReblogged(item.status, !item.status.reblogged, visibility, r->boostConsumer(v, r));
|
|
||||||
dialog.dismiss();
|
|
||||||
};
|
|
||||||
|
|
||||||
View separator = menu.findViewById(R.id.separator);
|
|
||||||
TextView reblogHeader = menu.findViewById(R.id.reblog_header);
|
|
||||||
TextView undoReblog = menu.findViewById(R.id.delete_reblog);
|
|
||||||
TextView reblogAs = menu.findViewById(R.id.reblog_as);
|
|
||||||
TextView itemPublic = menu.findViewById(R.id.vis_public);
|
|
||||||
TextView itemUnlisted = menu.findViewById(R.id.vis_unlisted);
|
|
||||||
TextView itemFollowers = menu.findViewById(R.id.vis_followers);
|
|
||||||
|
|
||||||
undoReblog.setVisibility(item.status.reblogged ? View.VISIBLE : View.GONE);
|
|
||||||
separator.setVisibility(item.status.reblogged ? View.GONE : View.VISIBLE);
|
|
||||||
reblogHeader.setVisibility(item.status.reblogged ? View.GONE : View.VISIBLE);
|
|
||||||
reblogAs.setVisibility(AccountSessionManager.getInstance().getLoggedInAccounts().size() > 1 ? View.VISIBLE : View.GONE);
|
|
||||||
|
|
||||||
itemPublic.setVisibility(item.status.reblogged || item.status.visibility.isLessVisibleThan(StatusPrivacy.PUBLIC) ? View.GONE : View.VISIBLE);
|
|
||||||
itemUnlisted.setVisibility(item.status.reblogged || item.status.visibility.isLessVisibleThan(StatusPrivacy.UNLISTED) ? View.GONE : View.VISIBLE);
|
|
||||||
itemFollowers.setVisibility(item.status.reblogged || item.status.visibility.isLessVisibleThan(StatusPrivacy.PRIVATE) ? View.GONE : View.VISIBLE);
|
|
||||||
|
|
||||||
Drawable checkMark = ctx.getDrawable(R.drawable.ic_fluent_checkmark_circle_20_regular);
|
|
||||||
Drawable publicDrawable = ctx.getDrawable(R.drawable.ic_fluent_earth_24_regular);
|
|
||||||
Drawable unlistedDrawable = ctx.getDrawable(R.drawable.ic_fluent_people_community_24_regular);
|
|
||||||
Drawable followersDrawable = ctx.getDrawable(R.drawable.ic_fluent_people_checkmark_24_regular);
|
|
||||||
|
|
||||||
StatusPrivacy defaultVisibility = session.preferences != null ? session.preferences.postingDefaultVisibility : null;
|
|
||||||
// e.g. post visibility is unlisted, but default is public
|
|
||||||
// in this case, we want to display the check mark on the most visible visibility
|
|
||||||
if (defaultVisibility != null && item.status.visibility.isLessVisibleThan(defaultVisibility)) {
|
|
||||||
for (StatusPrivacy vis : StatusPrivacy.values()) {
|
|
||||||
if (vis.equals(item.status.visibility)) {
|
|
||||||
defaultVisibility = vis;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
itemPublic.setCompoundDrawablesWithIntrinsicBounds(publicDrawable, null, StatusPrivacy.PUBLIC.equals(defaultVisibility) ? checkMark : null, null);
|
|
||||||
itemUnlisted.setCompoundDrawablesWithIntrinsicBounds(unlistedDrawable, null, StatusPrivacy.UNLISTED.equals(defaultVisibility) ? checkMark : null, null);
|
|
||||||
itemFollowers.setCompoundDrawablesWithIntrinsicBounds(followersDrawable, null, StatusPrivacy.PRIVATE.equals(defaultVisibility) ? checkMark : null, null);
|
|
||||||
|
|
||||||
undoReblog.setOnClickListener(c->doReblog.accept(null));
|
|
||||||
itemPublic.setOnClickListener(c->doReblog.accept(StatusPrivacy.PUBLIC));
|
|
||||||
itemUnlisted.setOnClickListener(c->doReblog.accept(StatusPrivacy.UNLISTED));
|
|
||||||
itemFollowers.setOnClickListener(c->doReblog.accept(StatusPrivacy.PRIVATE));
|
|
||||||
reblogAs.setOnClickListener(c->{
|
|
||||||
dialog.dismiss();
|
|
||||||
UiUtils.pickInteractAs(v.getContext(),
|
|
||||||
item.accountID, item.status,
|
|
||||||
s -> s.reblogged,
|
|
||||||
(ic, status, consumer) -> ic.setReblogged(status, true, null, consumer),
|
|
||||||
R.string.sk_reblog_as,
|
|
||||||
R.string.sk_reblogged_as,
|
|
||||||
R.string.sk_already_reblogged,
|
|
||||||
// TODO: replace once available: https://raw.githubusercontent.com/microsoft/fluentui-system-icons/main/android/library/src/main/res/drawable/ic_fluent_arrow_repeat_all_28_regular.xml
|
|
||||||
R.drawable.ic_fluent_arrow_repeat_all_24_regular
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
menu.findViewById(R.id.quote).setOnClickListener(c->{
|
|
||||||
dialog.dismiss();
|
|
||||||
v.startAnimation(opacityIn);
|
|
||||||
Bundle args=new Bundle();
|
|
||||||
args.putString("account", item.accountID);
|
|
||||||
StringBuilder prefilledText = new StringBuilder().append("\n\n");
|
|
||||||
String ownID = AccountSessionManager.getInstance().getAccount(item.accountID).self.id;
|
|
||||||
if (!item.status.account.id.equals(ownID)) prefilledText.append('@').append(item.status.account.acct).append(' ');
|
|
||||||
prefilledText.append(item.status.url);
|
|
||||||
args.putString("prefilledText", prefilledText.toString());
|
|
||||||
args.putInt("selectionStart", 0);
|
|
||||||
Nav.go(item.parentFragment.getActivity(), ComposeFragment.class, args);
|
|
||||||
});
|
|
||||||
|
|
||||||
dialog.show();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -301,41 +192,13 @@ public class FooterStatusDisplayItem extends StatusDisplayItem{
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean onFavoriteLongClick(View v) {
|
|
||||||
if (AccountSessionManager.getInstance().getLoggedInAccounts().size() < 2) return false;
|
|
||||||
UiUtils.pickInteractAs(v.getContext(),
|
|
||||||
item.accountID, item.status,
|
|
||||||
s -> s.favourited,
|
|
||||||
(ic, status, consumer) -> ic.setFavorited(status, true, consumer),
|
|
||||||
R.string.sk_favorite_as,
|
|
||||||
R.string.sk_favorited_as,
|
|
||||||
R.string.sk_already_favorited,
|
|
||||||
R.drawable.ic_fluent_star_28_regular
|
|
||||||
);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onBookmarkClick(View v){
|
private void onBookmarkClick(View v){
|
||||||
bookmark.setSelected(!item.status.bookmarked);
|
bookmark.setSelected(item.status.bookmarked);
|
||||||
AccountSessionManager.getInstance().getAccount(item.accountID).getStatusInteractionController().setBookmarked(item.status, !item.status.bookmarked, r->{
|
AccountSessionManager.getInstance().getAccount(item.accountID).getStatusInteractionController().setBookmarked(item.status, !item.status.bookmarked, r->{
|
||||||
v.startAnimation(opacityIn);
|
v.startAnimation(opacityIn);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean onBookmarkLongClick(View v) {
|
|
||||||
if (AccountSessionManager.getInstance().getLoggedInAccounts().size() < 2) return false;
|
|
||||||
UiUtils.pickInteractAs(v.getContext(),
|
|
||||||
item.accountID, item.status,
|
|
||||||
s -> s.bookmarked,
|
|
||||||
(ic, status, consumer) -> ic.setBookmarked(status, true, consumer),
|
|
||||||
R.string.sk_bookmark_as,
|
|
||||||
R.string.sk_bookmarked_as,
|
|
||||||
R.string.sk_already_bookmarked,
|
|
||||||
R.drawable.ic_fluent_bookmark_28_regular
|
|
||||||
);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onShareClick(View v){
|
private void onShareClick(View v){
|
||||||
v.startAnimation(opacityIn);
|
v.startAnimation(opacityIn);
|
||||||
Intent intent=new Intent(Intent.ACTION_SEND);
|
Intent intent=new Intent(Intent.ACTION_SEND);
|
||||||
@@ -345,7 +208,7 @@ public class FooterStatusDisplayItem extends StatusDisplayItem{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean onShareLongClick(View v){
|
private boolean onShareLongClick(View v){
|
||||||
UiUtils.copyText(v, item.status.url);
|
UiUtils.copyText(v.getContext(), item.status.url);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,10 +9,8 @@ import android.os.Build;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.SpannableStringBuilder;
|
import android.text.SpannableStringBuilder;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.TypedValue;
|
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.SubMenu;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.ViewOutlineProvider;
|
import android.view.ViewOutlineProvider;
|
||||||
@@ -24,37 +22,28 @@ import android.widget.Toast;
|
|||||||
import org.joinmastodon.android.GlobalUserPreferences;
|
import org.joinmastodon.android.GlobalUserPreferences;
|
||||||
import org.joinmastodon.android.R;
|
import org.joinmastodon.android.R;
|
||||||
import org.joinmastodon.android.api.requests.accounts.GetAccountRelationships;
|
import org.joinmastodon.android.api.requests.accounts.GetAccountRelationships;
|
||||||
import org.joinmastodon.android.api.requests.announcements.DismissAnnouncement;
|
|
||||||
import org.joinmastodon.android.api.requests.statuses.CreateStatus;
|
|
||||||
import org.joinmastodon.android.api.requests.statuses.GetStatusSourceText;
|
import org.joinmastodon.android.api.requests.statuses.GetStatusSourceText;
|
||||||
import org.joinmastodon.android.api.session.AccountSession;
|
|
||||||
import org.joinmastodon.android.api.session.AccountSessionManager;
|
import org.joinmastodon.android.api.session.AccountSessionManager;
|
||||||
import org.joinmastodon.android.fragments.BaseStatusListFragment;
|
import org.joinmastodon.android.fragments.BaseStatusListFragment;
|
||||||
import org.joinmastodon.android.fragments.ComposeFragment;
|
import org.joinmastodon.android.fragments.ComposeFragment;
|
||||||
import org.joinmastodon.android.fragments.NotificationsListFragment;
|
|
||||||
import org.joinmastodon.android.fragments.ProfileFragment;
|
import org.joinmastodon.android.fragments.ProfileFragment;
|
||||||
import org.joinmastodon.android.fragments.ThreadFragment;
|
import org.joinmastodon.android.fragments.ThreadFragment;
|
||||||
import org.joinmastodon.android.fragments.report.ReportReasonChoiceFragment;
|
import org.joinmastodon.android.fragments.report.ReportReasonChoiceFragment;
|
||||||
import org.joinmastodon.android.model.Account;
|
import org.joinmastodon.android.model.Account;
|
||||||
import org.joinmastodon.android.model.Announcement;
|
|
||||||
import org.joinmastodon.android.model.Attachment;
|
import org.joinmastodon.android.model.Attachment;
|
||||||
import org.joinmastodon.android.model.Notification;
|
import org.joinmastodon.android.model.Preferences;
|
||||||
import org.joinmastodon.android.model.Relationship;
|
import org.joinmastodon.android.model.Relationship;
|
||||||
import org.joinmastodon.android.model.ScheduledStatus;
|
|
||||||
import org.joinmastodon.android.model.Status;
|
import org.joinmastodon.android.model.Status;
|
||||||
|
import org.joinmastodon.android.model.StatusPrivacy;
|
||||||
import org.joinmastodon.android.ui.text.HtmlParser;
|
import org.joinmastodon.android.ui.text.HtmlParser;
|
||||||
import org.joinmastodon.android.ui.utils.CustomEmojiHelper;
|
import org.joinmastodon.android.ui.utils.CustomEmojiHelper;
|
||||||
import org.joinmastodon.android.ui.utils.UiUtils;
|
import org.joinmastodon.android.ui.utils.UiUtils;
|
||||||
import org.parceler.Parcels;
|
import org.parceler.Parcels;
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.time.ZoneId;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
import java.time.format.FormatStyle;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Objects;
|
||||||
import java.util.function.Consumer;
|
|
||||||
|
|
||||||
import me.grishka.appkit.Nav;
|
import me.grishka.appkit.Nav;
|
||||||
import me.grishka.appkit.api.APIRequest;
|
import me.grishka.appkit.api.APIRequest;
|
||||||
@@ -76,22 +65,15 @@ public class HeaderStatusDisplayItem extends StatusDisplayItem{
|
|||||||
private boolean hasVisibilityToggle;
|
private boolean hasVisibilityToggle;
|
||||||
boolean needBottomPadding;
|
boolean needBottomPadding;
|
||||||
private String extraText;
|
private String extraText;
|
||||||
private Notification notification;
|
|
||||||
private ScheduledStatus scheduledStatus;
|
|
||||||
private Announcement announcement;
|
|
||||||
private Consumer<String> consumeReadAnnouncement;
|
|
||||||
|
|
||||||
public HeaderStatusDisplayItem(String parentID, Account user, Instant createdAt, BaseStatusListFragment parentFragment, String accountID, Status status, String extraText, Notification notification, ScheduledStatus scheduledStatus){
|
public HeaderStatusDisplayItem(String parentID, Account user, Instant createdAt, BaseStatusListFragment parentFragment, String accountID, Status status, String extraText){
|
||||||
super(parentID, parentFragment);
|
super(parentID, parentFragment);
|
||||||
user=scheduledStatus != null ? AccountSessionManager.getInstance().getAccount(accountID).self : user;
|
|
||||||
this.user=user;
|
this.user=user;
|
||||||
this.createdAt=createdAt;
|
this.createdAt=createdAt;
|
||||||
avaRequest=new UrlImageLoaderRequest(GlobalUserPreferences.playGifs ? user.avatar : user.avatarStatic, V.dp(50), V.dp(50));
|
avaRequest=new UrlImageLoaderRequest(GlobalUserPreferences.playGifs ? user.avatar : user.avatarStatic, V.dp(50), V.dp(50));
|
||||||
this.accountID=accountID;
|
this.accountID=accountID;
|
||||||
parsedName=new SpannableStringBuilder(user.displayName);
|
parsedName=new SpannableStringBuilder(user.displayName);
|
||||||
this.status=status;
|
this.status=status;
|
||||||
this.notification=notification;
|
|
||||||
this.scheduledStatus=scheduledStatus;
|
|
||||||
HtmlParser.parseCustomEmoji(parsedName, user.emojis);
|
HtmlParser.parseCustomEmoji(parsedName, user.emojis);
|
||||||
emojiHelper.setText(parsedName);
|
emojiHelper.setText(parsedName);
|
||||||
if(status!=null){
|
if(status!=null){
|
||||||
@@ -108,13 +90,6 @@ public class HeaderStatusDisplayItem extends StatusDisplayItem{
|
|||||||
this.extraText=extraText;
|
this.extraText=extraText;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HeaderStatusDisplayItem fromAnnouncement(Announcement a, Status fakeStatus, Account instanceUser, BaseStatusListFragment parentFragment, String accountID, Consumer<String> consumeReadID) {
|
|
||||||
HeaderStatusDisplayItem item = new HeaderStatusDisplayItem(a.id, instanceUser, a.startsAt, parentFragment, accountID, fakeStatus, null, null, null);
|
|
||||||
item.announcement = a;
|
|
||||||
item.consumeReadAnnouncement = consumeReadID;
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Type getType(){
|
public Type getType(){
|
||||||
return Type.HEADER;
|
return Type.HEADER;
|
||||||
@@ -134,8 +109,8 @@ public class HeaderStatusDisplayItem extends StatusDisplayItem{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class Holder extends StatusDisplayItem.Holder<HeaderStatusDisplayItem> implements ImageLoaderViewHolder{
|
public static class Holder extends StatusDisplayItem.Holder<HeaderStatusDisplayItem> implements ImageLoaderViewHolder{
|
||||||
private final TextView name, username, timestamp, extraText, separator;
|
private final TextView name, username, timestamp, extraText;
|
||||||
private final ImageView avatar, more, visibility, deleteNotification, unreadIndicator;
|
private final ImageView avatar, more, visibility;
|
||||||
private final PopupMenu optionsMenu;
|
private final PopupMenu optionsMenu;
|
||||||
private Relationship relationship;
|
private Relationship relationship;
|
||||||
private APIRequest<?> currentRelationshipRequest;
|
private APIRequest<?> currentRelationshipRequest;
|
||||||
@@ -151,31 +126,22 @@ public class HeaderStatusDisplayItem extends StatusDisplayItem{
|
|||||||
super(activity, R.layout.display_item_header, parent);
|
super(activity, R.layout.display_item_header, parent);
|
||||||
name=findViewById(R.id.name);
|
name=findViewById(R.id.name);
|
||||||
username=findViewById(R.id.username);
|
username=findViewById(R.id.username);
|
||||||
separator=findViewById(R.id.separator);
|
|
||||||
timestamp=findViewById(R.id.timestamp);
|
timestamp=findViewById(R.id.timestamp);
|
||||||
avatar=findViewById(R.id.avatar);
|
avatar=findViewById(R.id.avatar);
|
||||||
more=findViewById(R.id.more);
|
more=findViewById(R.id.more);
|
||||||
visibility=findViewById(R.id.visibility);
|
visibility=findViewById(R.id.visibility);
|
||||||
deleteNotification=findViewById(R.id.delete_notification);
|
|
||||||
unreadIndicator=findViewById(R.id.unread_indicator);
|
|
||||||
extraText=findViewById(R.id.extra_text);
|
extraText=findViewById(R.id.extra_text);
|
||||||
avatar.setOnClickListener(this::onAvaClick);
|
avatar.setOnClickListener(this::onAvaClick);
|
||||||
avatar.setOutlineProvider(roundCornersOutline);
|
avatar.setOutlineProvider(roundCornersOutline);
|
||||||
avatar.setClipToOutline(true);
|
avatar.setClipToOutline(true);
|
||||||
more.setOnClickListener(this::onMoreClick);
|
more.setOnClickListener(this::onMoreClick);
|
||||||
visibility.setOnClickListener(v->item.parentFragment.onVisibilityIconClick(this));
|
visibility.setOnClickListener(v->item.parentFragment.onVisibilityIconClick(this));
|
||||||
deleteNotification.setOnClickListener(v->UiUtils.confirmDeleteNotification(activity, item.parentFragment.getAccountID(), item.notification, ()->{
|
|
||||||
if (item.parentFragment instanceof NotificationsListFragment fragment) {
|
|
||||||
fragment.removeNotification(item.notification);
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
|
|
||||||
optionsMenu=new PopupMenu(activity, more);
|
optionsMenu=new PopupMenu(activity, more);
|
||||||
optionsMenu.inflate(R.menu.post);
|
optionsMenu.inflate(R.menu.post);
|
||||||
optionsMenu.setOnMenuItemClickListener(menuItem->{
|
optionsMenu.setOnMenuItemClickListener(menuItem->{
|
||||||
Account account=item.user;
|
Account account=item.user;
|
||||||
int id=menuItem.getItemId();
|
int id=menuItem.getItemId();
|
||||||
|
|
||||||
if(id==R.id.edit || id==R.id.delete_and_redraft) {
|
if(id==R.id.edit || id==R.id.delete_and_redraft) {
|
||||||
final Bundle args=new Bundle();
|
final Bundle args=new Bundle();
|
||||||
args.putString("account", item.parentFragment.getAccountID());
|
args.putString("account", item.parentFragment.getAccountID());
|
||||||
@@ -190,12 +156,6 @@ public class HeaderStatusDisplayItem extends StatusDisplayItem{
|
|||||||
}
|
}
|
||||||
if(TextUtils.isEmpty(item.status.content) && TextUtils.isEmpty(item.status.spoilerText)){
|
if(TextUtils.isEmpty(item.status.content) && TextUtils.isEmpty(item.status.spoilerText)){
|
||||||
Nav.go(item.parentFragment.getActivity(), ComposeFragment.class, args);
|
Nav.go(item.parentFragment.getActivity(), ComposeFragment.class, args);
|
||||||
}else if(item.scheduledStatus!=null){
|
|
||||||
args.putString("sourceText", item.status.text);
|
|
||||||
args.putString("sourceSpoiler", item.status.spoilerText);
|
|
||||||
args.putBoolean("redraftStatus", true);
|
|
||||||
args.putParcelable("scheduledStatus", Parcels.wrap(item.scheduledStatus));
|
|
||||||
Nav.go(item.parentFragment.getActivity(), ComposeFragment.class, args);
|
|
||||||
}else{
|
}else{
|
||||||
new GetStatusSourceText(item.status.id)
|
new GetStatusSourceText(item.status.id)
|
||||||
.setCallback(new Callback<>(){
|
.setCallback(new Callback<>(){
|
||||||
@@ -221,12 +181,8 @@ public class HeaderStatusDisplayItem extends StatusDisplayItem{
|
|||||||
.exec(item.parentFragment.getAccountID());
|
.exec(item.parentFragment.getAccountID());
|
||||||
}
|
}
|
||||||
}else if(id==R.id.delete){
|
}else if(id==R.id.delete){
|
||||||
if (item.scheduledStatus != null) {
|
UiUtils.confirmDeletePost(item.parentFragment.getActivity(), item.parentFragment.getAccountID(), item.status, s->{});
|
||||||
UiUtils.confirmDeleteScheduledPost(item.parentFragment.getActivity(), item.parentFragment.getAccountID(), item.scheduledStatus, ()->{});
|
}else if(id==R.id.pin || id==R.id.unpin){
|
||||||
} else {
|
|
||||||
UiUtils.confirmDeletePost(item.parentFragment.getActivity(), item.parentFragment.getAccountID(), item.status, s->{});
|
|
||||||
}
|
|
||||||
}else if(id==R.id.pin || id==R.id.unpin) {
|
|
||||||
UiUtils.confirmPinPost(item.parentFragment.getActivity(), item.parentFragment.getAccountID(), item.status, !item.status.pinned, s->{});
|
UiUtils.confirmPinPost(item.parentFragment.getActivity(), item.parentFragment.getAccountID(), item.status, !item.status.pinned, s->{});
|
||||||
}else if(id==R.id.mute){
|
}else if(id==R.id.mute){
|
||||||
UiUtils.confirmToggleMuteUser(item.parentFragment.getActivity(), item.parentFragment.getAccountID(), account, relationship!=null && relationship.muting, r->{});
|
UiUtils.confirmToggleMuteUser(item.parentFragment.getActivity(), item.parentFragment.getAccountID(), account, relationship!=null && relationship.muting, r->{});
|
||||||
@@ -238,10 +194,8 @@ public class HeaderStatusDisplayItem extends StatusDisplayItem{
|
|||||||
args.putParcelable("status", Parcels.wrap(item.status));
|
args.putParcelable("status", Parcels.wrap(item.status));
|
||||||
args.putParcelable("reportAccount", Parcels.wrap(item.status.account));
|
args.putParcelable("reportAccount", Parcels.wrap(item.status.account));
|
||||||
Nav.go(item.parentFragment.getActivity(), ReportReasonChoiceFragment.class, args);
|
Nav.go(item.parentFragment.getActivity(), ReportReasonChoiceFragment.class, args);
|
||||||
}else if(id==R.id.open_in_browser) {
|
}else if(id==R.id.open_in_browser){
|
||||||
UiUtils.launchWebBrowser(activity, item.status.url);
|
UiUtils.launchWebBrowser(activity, item.status.url);
|
||||||
}else if(id==R.id.copy_link){
|
|
||||||
UiUtils.copyText(parent, item.status.url);
|
|
||||||
}else if(id==R.id.follow){
|
}else if(id==R.id.follow){
|
||||||
if(relationship==null)
|
if(relationship==null)
|
||||||
return true;
|
return true;
|
||||||
@@ -255,7 +209,7 @@ public class HeaderStatusDisplayItem extends StatusDisplayItem{
|
|||||||
progress.dismiss();
|
progress.dismiss();
|
||||||
}, rel->{
|
}, rel->{
|
||||||
relationship=rel;
|
relationship=rel;
|
||||||
Toast.makeText(activity, activity.getString(rel.following ? R.string.followed_user : R.string.unfollowed_user, account.getShortUsername()), Toast.LENGTH_SHORT).show();
|
Toast.makeText(activity, activity.getString(rel.following ? R.string.followed_user : R.string.unfollowed_user, account.getDisplayUsername()), Toast.LENGTH_SHORT).show();
|
||||||
});
|
});
|
||||||
}else if(id==R.id.block_domain){
|
}else if(id==R.id.block_domain){
|
||||||
UiUtils.confirmToggleBlockDomain(activity, item.parentFragment.getAccountID(), account.getDomain(), relationship!=null && relationship.domainBlocking, ()->{});
|
UiUtils.confirmToggleBlockDomain(activity, item.parentFragment.getAccountID(), account.getDomain(), relationship!=null && relationship.domainBlocking, ()->{});
|
||||||
@@ -264,43 +218,17 @@ public class HeaderStatusDisplayItem extends StatusDisplayItem{
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
UiUtils.enablePopupMenuIcons(activity, optionsMenu);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void populateAccountsMenu(Menu menu) {
|
|
||||||
List<AccountSession> sessions=AccountSessionManager.getInstance().getLoggedInAccounts();
|
|
||||||
sessions.stream().filter(s -> !s.getID().equals(item.accountID)).forEach(s -> {
|
|
||||||
String username = "@"+s.self.username+"@"+s.domain;
|
|
||||||
menu.add(username).setOnMenuItemClickListener(c->{
|
|
||||||
UiUtils.openURL(item.parentFragment.getActivity(), s.getID(), item.status.url, false);
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBind(HeaderStatusDisplayItem item){
|
public void onBind(HeaderStatusDisplayItem item){
|
||||||
name.setText(item.parsedName);
|
name.setText(item.parsedName);
|
||||||
username.setText('@'+item.user.acct);
|
username.setText('@'+item.user.acct);
|
||||||
separator.setVisibility(View.VISIBLE);
|
if(item.status==null || item.status.editedAt==null)
|
||||||
|
|
||||||
if (item.scheduledStatus!=null)
|
|
||||||
if (item.scheduledStatus.scheduledAt.isAfter(CreateStatus.DRAFTS_AFTER_INSTANT)) {
|
|
||||||
timestamp.setText(R.string.sk_draft);
|
|
||||||
} else {
|
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM).withLocale(Locale.getDefault());
|
|
||||||
timestamp.setText(item.scheduledStatus.scheduledAt.atZone(ZoneId.systemDefault()).format(formatter));
|
|
||||||
}
|
|
||||||
else if ((item.status==null || item.status.editedAt==null) && item.createdAt != null)
|
|
||||||
timestamp.setText(UiUtils.formatRelativeTimestamp(itemView.getContext(), item.createdAt));
|
timestamp.setText(UiUtils.formatRelativeTimestamp(itemView.getContext(), item.createdAt));
|
||||||
else if (item.status != null && item.status.editedAt != null)
|
else
|
||||||
timestamp.setText(item.parentFragment.getString(R.string.edited_timestamp, UiUtils.formatRelativeTimestamp(itemView.getContext(), item.status.editedAt)));
|
timestamp.setText(item.parentFragment.getString(R.string.edited_timestamp, UiUtils.formatRelativeTimestamp(itemView.getContext(), item.status.editedAt)));
|
||||||
else {
|
|
||||||
separator.setVisibility(View.GONE);
|
|
||||||
timestamp.setText("");
|
|
||||||
}
|
|
||||||
visibility.setVisibility(item.hasVisibilityToggle && !item.inset ? View.VISIBLE : View.GONE);
|
visibility.setVisibility(item.hasVisibilityToggle && !item.inset ? View.VISIBLE : View.GONE);
|
||||||
deleteNotification.setVisibility(GlobalUserPreferences.enableDeleteNotifications && item.notification!=null && !item.inset ? View.VISIBLE : View.GONE);
|
|
||||||
if(item.hasVisibilityToggle){
|
if(item.hasVisibilityToggle){
|
||||||
visibility.setImageResource(item.status.spoilerRevealed ? R.drawable.ic_visibility_off : R.drawable.ic_visibility);
|
visibility.setImageResource(item.status.spoilerRevealed ? R.drawable.ic_visibility_off : R.drawable.ic_visibility);
|
||||||
visibility.setContentDescription(item.parentFragment.getString(item.status.spoilerRevealed ? R.string.hide_content : R.string.reveal_content));
|
visibility.setContentDescription(item.parentFragment.getString(item.status.spoilerRevealed ? R.string.hide_content : R.string.reveal_content));
|
||||||
@@ -322,44 +250,6 @@ public class HeaderStatusDisplayItem extends StatusDisplayItem{
|
|||||||
currentRelationshipRequest.cancel();
|
currentRelationshipRequest.cancel();
|
||||||
}
|
}
|
||||||
relationship=null;
|
relationship=null;
|
||||||
|
|
||||||
String desc;
|
|
||||||
if (item.announcement != null) {
|
|
||||||
if (unreadIndicator.getVisibility() == View.GONE) {
|
|
||||||
more.setAlpha(0f);
|
|
||||||
unreadIndicator.setAlpha(0f);
|
|
||||||
unreadIndicator.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
float alpha = item.announcement.read ? 0 : 1;
|
|
||||||
more.setImageResource(R.drawable.ic_fluent_checkmark_20_filled);
|
|
||||||
desc = item.parentFragment.getString(R.string.sk_mark_as_read);
|
|
||||||
more.animate().alpha(alpha);
|
|
||||||
unreadIndicator.animate().alpha(alpha);
|
|
||||||
more.setEnabled(!item.announcement.read);
|
|
||||||
more.setOnClickListener(v -> {
|
|
||||||
if (item.announcement.read) return;
|
|
||||||
new DismissAnnouncement(item.announcement.id).setCallback(new Callback<>() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(Object o) {
|
|
||||||
item.consumeReadAnnouncement.accept(item.announcement.id);
|
|
||||||
item.announcement.read = true;
|
|
||||||
rebind();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onError(ErrorResponse error) {
|
|
||||||
error.showToast(item.parentFragment.getActivity());
|
|
||||||
}
|
|
||||||
}).exec(item.accountID);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
more.setImageResource(R.drawable.ic_fluent_more_vertical_20_filled);
|
|
||||||
desc = item.parentFragment.getString(R.string.more_options);
|
|
||||||
more.setOnClickListener(this::onMoreClick);
|
|
||||||
}
|
|
||||||
|
|
||||||
more.setContentDescription(desc);
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) more.setTooltipText(desc);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -380,10 +270,6 @@ public class HeaderStatusDisplayItem extends StatusDisplayItem{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void onAvaClick(View v){
|
private void onAvaClick(View v){
|
||||||
if (item.announcement != null) {
|
|
||||||
UiUtils.openURL(item.parentFragment.getActivity(), item.parentFragment.getAccountID(), item.user.url);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Bundle args=new Bundle();
|
Bundle args=new Bundle();
|
||||||
args.putString("account", item.accountID);
|
args.putString("account", item.accountID);
|
||||||
args.putParcelable("profileAccount", Parcels.wrap(item.user));
|
args.putParcelable("profileAccount", Parcels.wrap(item.user));
|
||||||
@@ -415,31 +301,15 @@ public class HeaderStatusDisplayItem extends StatusDisplayItem{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateOptionsMenu(){
|
private void updateOptionsMenu(){
|
||||||
if (item.announcement != null) return;
|
|
||||||
boolean hasMultipleAccounts = AccountSessionManager.getInstance().getLoggedInAccounts().size() > 1;
|
|
||||||
Menu menu=optionsMenu.getMenu();
|
|
||||||
|
|
||||||
MenuItem openWithAccounts = menu.findItem(R.id.open_with_account);
|
|
||||||
SubMenu accountsMenu = openWithAccounts != null ? openWithAccounts.getSubMenu() : null;
|
|
||||||
if (hasMultipleAccounts && accountsMenu != null) {
|
|
||||||
openWithAccounts.setVisible(true);
|
|
||||||
accountsMenu.clear();
|
|
||||||
populateAccountsMenu(accountsMenu);
|
|
||||||
} else if (openWithAccounts != null) {
|
|
||||||
openWithAccounts.setVisible(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
Account account=item.user;
|
Account account=item.user;
|
||||||
|
Menu menu=optionsMenu.getMenu();
|
||||||
boolean isOwnPost=AccountSessionManager.getInstance().isSelf(item.parentFragment.getAccountID(), account);
|
boolean isOwnPost=AccountSessionManager.getInstance().isSelf(item.parentFragment.getAccountID(), account);
|
||||||
boolean isPostScheduled=item.scheduledStatus!=null;
|
|
||||||
menu.findItem(R.id.open_with_account).setVisible(!isPostScheduled && hasMultipleAccounts);
|
|
||||||
menu.findItem(R.id.edit).setVisible(item.status!=null && isOwnPost);
|
menu.findItem(R.id.edit).setVisible(item.status!=null && isOwnPost);
|
||||||
menu.findItem(R.id.delete).setVisible(item.status!=null && isOwnPost);
|
menu.findItem(R.id.delete).setVisible(item.status!=null && isOwnPost);
|
||||||
menu.findItem(R.id.delete_and_redraft).setVisible(!isPostScheduled && item.status!=null && isOwnPost);
|
menu.findItem(R.id.delete_and_redraft).setVisible(item.status!=null && isOwnPost);
|
||||||
menu.findItem(R.id.pin).setVisible(!isPostScheduled && item.status!=null && isOwnPost && !item.status.pinned);
|
menu.findItem(R.id.pin).setVisible(item.status!=null && isOwnPost && !item.status.pinned);
|
||||||
menu.findItem(R.id.unpin).setVisible(!isPostScheduled && item.status!=null && isOwnPost && item.status.pinned);
|
menu.findItem(R.id.unpin).setVisible(item.status!=null && isOwnPost && item.status.pinned);
|
||||||
menu.findItem(R.id.open_in_browser).setVisible(!isPostScheduled && item.status!=null);
|
menu.findItem(R.id.open_in_browser).setVisible(item.status!=null);
|
||||||
menu.findItem(R.id.copy_link).setVisible(!isPostScheduled && item.status!=null);
|
|
||||||
MenuItem blockDomain=menu.findItem(R.id.block_domain);
|
MenuItem blockDomain=menu.findItem(R.id.block_domain);
|
||||||
MenuItem mute=menu.findItem(R.id.mute);
|
MenuItem mute=menu.findItem(R.id.mute);
|
||||||
MenuItem block=menu.findItem(R.id.block);
|
MenuItem block=menu.findItem(R.id.block);
|
||||||
@@ -455,7 +325,7 @@ public class HeaderStatusDisplayItem extends StatusDisplayItem{
|
|||||||
bookmark.setVisible(false);
|
bookmark.setVisible(false);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
if(isPostScheduled || isOwnPost){
|
if(isOwnPost){
|
||||||
mute.setVisible(false);
|
mute.setVisible(false);
|
||||||
block.setVisible(false);
|
block.setVisible(false);
|
||||||
report.setVisible(false);
|
report.setVisible(false);
|
||||||
@@ -466,22 +336,16 @@ public class HeaderStatusDisplayItem extends StatusDisplayItem{
|
|||||||
block.setVisible(true);
|
block.setVisible(true);
|
||||||
report.setVisible(true);
|
report.setVisible(true);
|
||||||
follow.setVisible(relationship==null || relationship.following || (!relationship.blocking && !relationship.blockedBy && !relationship.domainBlocking && !relationship.muting));
|
follow.setVisible(relationship==null || relationship.following || (!relationship.blocking && !relationship.blockedBy && !relationship.domainBlocking && !relationship.muting));
|
||||||
mute.setTitle(item.parentFragment.getString(relationship!=null && relationship.muting ? R.string.unmute_user : R.string.mute_user, account.getShortUsername()));
|
mute.setTitle(item.parentFragment.getString(relationship!=null && relationship.muting ? R.string.unmute_user : R.string.mute_user, account.getDisplayUsername()));
|
||||||
mute.setIcon(relationship!=null && relationship.muting ? R.drawable.ic_fluent_speaker_0_24_regular : R.drawable.ic_fluent_speaker_off_24_regular);
|
block.setTitle(item.parentFragment.getString(relationship!=null && relationship.blocking ? R.string.unblock_user : R.string.block_user, account.getDisplayUsername()));
|
||||||
UiUtils.insetPopupMenuIcon(item.parentFragment.getContext(), mute);
|
report.setTitle(item.parentFragment.getString(R.string.report_user, account.getDisplayUsername()));
|
||||||
block.setTitle(item.parentFragment.getString(relationship!=null && relationship.blocking ? R.string.unblock_user : R.string.block_user, account.getShortUsername()));
|
if(!account.isLocal()){
|
||||||
report.setTitle(item.parentFragment.getString(R.string.report_user, account.getShortUsername()));
|
blockDomain.setVisible(true);
|
||||||
// disabled in megalodon. domain blocks from a post clutters the context menu and looks out of place
|
blockDomain.setTitle(item.parentFragment.getString(relationship!=null && relationship.domainBlocking ? R.string.unblock_domain : R.string.block_domain, account.getDomain()));
|
||||||
// if(!account.isLocal()){
|
}else{
|
||||||
// blockDomain.setVisible(true);
|
|
||||||
// blockDomain.setTitle(item.parentFragment.getString(relationship!=null && relationship.domainBlocking ? R.string.unblock_domain : R.string.block_domain, account.getDomain()));
|
|
||||||
// }else{
|
|
||||||
blockDomain.setVisible(false);
|
blockDomain.setVisible(false);
|
||||||
// }
|
}
|
||||||
boolean following = relationship!=null && relationship.following;
|
follow.setTitle(item.parentFragment.getString(relationship!=null && relationship.following ? R.string.unfollow_user : R.string.follow_user, account.getDisplayUsername()));
|
||||||
follow.setTitle(item.parentFragment.getString(following ? R.string.unfollow_user : R.string.follow_user, account.getShortUsername()));
|
|
||||||
follow.setIcon(following ? R.drawable.ic_fluent_person_delete_24_regular : R.drawable.ic_fluent_person_add_24_regular);
|
|
||||||
UiUtils.insetPopupMenuIcon(item.parentFragment.getContext(), follow);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,12 +73,7 @@ public class LinkCardStatusDisplayItem extends StatusDisplayItem{
|
|||||||
|
|
||||||
photo.setImageDrawable(null);
|
photo.setImageDrawable(null);
|
||||||
if(item.imgRequest!=null){
|
if(item.imgRequest!=null){
|
||||||
if (card.width > 0) {
|
crossfadeDrawable.setSize(card.width, card.height);
|
||||||
// akkoma servers don't provide width and height
|
|
||||||
crossfadeDrawable.setSize(card.width, card.height);
|
|
||||||
} else {
|
|
||||||
crossfadeDrawable.setSize(itemView.getWidth(), itemView.getHeight());
|
|
||||||
}
|
|
||||||
crossfadeDrawable.setBlurhashDrawable(card.blurhashPlaceholder);
|
crossfadeDrawable.setBlurhashDrawable(card.blurhashPlaceholder);
|
||||||
crossfadeDrawable.setCrossfadeAlpha(item.status.spoilerRevealed ? 0f : 1f);
|
crossfadeDrawable.setCrossfadeAlpha(item.status.spoilerRevealed ? 0f : 1f);
|
||||||
photo.setImageDrawable(crossfadeDrawable);
|
photo.setImageDrawable(crossfadeDrawable);
|
||||||
|
|||||||
@@ -1,18 +1,7 @@
|
|||||||
package org.joinmastodon.android.ui.displayitems;
|
package org.joinmastodon.android.ui.displayitems;
|
||||||
|
|
||||||
import android.animation.Animator;
|
|
||||||
import android.animation.AnimatorListenerAdapter;
|
|
||||||
import android.animation.AnimatorSet;
|
|
||||||
import android.animation.ObjectAnimator;
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.text.TextUtils;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.ViewTreeObserver;
|
|
||||||
import android.widget.FrameLayout;
|
|
||||||
import android.widget.ImageButton;
|
|
||||||
import android.widget.ScrollView;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import org.joinmastodon.android.R;
|
import org.joinmastodon.android.R;
|
||||||
import org.joinmastodon.android.fragments.BaseStatusListFragment;
|
import org.joinmastodon.android.fragments.BaseStatusListFragment;
|
||||||
@@ -21,7 +10,6 @@ import org.joinmastodon.android.model.Status;
|
|||||||
import org.joinmastodon.android.ui.PhotoLayoutHelper;
|
import org.joinmastodon.android.ui.PhotoLayoutHelper;
|
||||||
|
|
||||||
import me.grishka.appkit.imageloader.requests.UrlImageLoaderRequest;
|
import me.grishka.appkit.imageloader.requests.UrlImageLoaderRequest;
|
||||||
import me.grishka.appkit.utils.CubicBezierInterpolator;
|
|
||||||
|
|
||||||
public class PhotoStatusDisplayItem extends ImageStatusDisplayItem{
|
public class PhotoStatusDisplayItem extends ImageStatusDisplayItem{
|
||||||
public PhotoStatusDisplayItem(String parentID, Status status, Attachment photo, BaseStatusListFragment parentFragment, int index, int totalPhotos, PhotoLayoutHelper.TiledLayoutResult tiledLayout, PhotoLayoutHelper.TiledLayoutResult.Tile thisTile){
|
public PhotoStatusDisplayItem(String parentID, Status status, Attachment photo, BaseStatusListFragment parentFragment, int index, int totalPhotos, PhotoLayoutHelper.TiledLayoutResult tiledLayout, PhotoLayoutHelper.TiledLayoutResult.Tile thisTile){
|
||||||
@@ -35,109 +23,9 @@ public class PhotoStatusDisplayItem extends ImageStatusDisplayItem{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class Holder extends ImageStatusDisplayItem.Holder<PhotoStatusDisplayItem>{
|
public static class Holder extends ImageStatusDisplayItem.Holder<PhotoStatusDisplayItem>{
|
||||||
private final FrameLayout altTextWrapper;
|
|
||||||
private final TextView altTextButton;
|
|
||||||
private final View altTextScroller;
|
|
||||||
private final ImageButton altTextClose;
|
|
||||||
private final TextView altText;
|
|
||||||
|
|
||||||
private boolean altTextShown;
|
|
||||||
private AnimatorSet currentAnim;
|
|
||||||
|
|
||||||
public Holder(Activity activity, ViewGroup parent){
|
public Holder(Activity activity, ViewGroup parent){
|
||||||
super(activity, R.layout.display_item_photo, parent);
|
super(activity, R.layout.display_item_photo, parent);
|
||||||
altTextWrapper=findViewById(R.id.alt_text_wrapper);
|
|
||||||
altTextButton=findViewById(R.id.alt_button);
|
|
||||||
altTextScroller=findViewById(R.id.alt_text_scroller);
|
|
||||||
altTextClose=findViewById(R.id.alt_text_close);
|
|
||||||
altText=findViewById(R.id.alt_text);
|
|
||||||
|
|
||||||
altTextButton.setOnClickListener(this::onShowHideClick);
|
|
||||||
altTextClose.setOnClickListener(this::onShowHideClick);
|
|
||||||
// altTextScroller.setNestedScrollingEnabled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBind(ImageStatusDisplayItem item){
|
|
||||||
super.onBind(item);
|
|
||||||
altTextShown=false;
|
|
||||||
if(currentAnim!=null)
|
|
||||||
currentAnim.cancel();
|
|
||||||
altTextScroller.setVisibility(View.GONE);
|
|
||||||
altTextClose.setVisibility(View.GONE);
|
|
||||||
altTextButton.setVisibility(View.VISIBLE);
|
|
||||||
if(TextUtils.isEmpty(item.attachment.description)){
|
|
||||||
altTextWrapper.setVisibility(View.GONE);
|
|
||||||
}else{
|
|
||||||
altTextWrapper.setVisibility(View.VISIBLE);
|
|
||||||
altText.setText(item.attachment.description);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onShowHideClick(View v){
|
|
||||||
boolean show=v.getId()==R.id.alt_button;
|
|
||||||
|
|
||||||
if(altTextShown==show)
|
|
||||||
return;
|
|
||||||
if(currentAnim!=null)
|
|
||||||
currentAnim.cancel();
|
|
||||||
|
|
||||||
altTextShown=show;
|
|
||||||
if(show){
|
|
||||||
altTextScroller.setVisibility(View.VISIBLE);
|
|
||||||
altTextClose.setVisibility(View.VISIBLE);
|
|
||||||
}else{
|
|
||||||
altTextButton.setVisibility(View.VISIBLE);
|
|
||||||
// Hide these views temporarily so FrameLayout measures correctly
|
|
||||||
altTextScroller.setVisibility(View.GONE);
|
|
||||||
altTextClose.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
// This is the current size...
|
|
||||||
int prevLeft=altTextWrapper.getLeft();
|
|
||||||
int prevRight=altTextWrapper.getRight();
|
|
||||||
int prevTop=altTextWrapper.getTop();
|
|
||||||
altTextWrapper.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener(){
|
|
||||||
@Override
|
|
||||||
public boolean onPreDraw(){
|
|
||||||
altTextWrapper.getViewTreeObserver().removeOnPreDrawListener(this);
|
|
||||||
|
|
||||||
// ...and this is after the layout pass, right now the FrameLayout has its final size, but we animate that change
|
|
||||||
if(!show){
|
|
||||||
// Show these views again so they're visible for the duration of the animation.
|
|
||||||
// No one would notice they were missing during measure/layout.
|
|
||||||
altTextScroller.setVisibility(View.VISIBLE);
|
|
||||||
altTextClose.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
AnimatorSet set=new AnimatorSet();
|
|
||||||
set.playTogether(
|
|
||||||
ObjectAnimator.ofInt(altTextWrapper, "left", prevLeft, altTextWrapper.getLeft()),
|
|
||||||
ObjectAnimator.ofInt(altTextWrapper, "right", prevRight, altTextWrapper.getRight()),
|
|
||||||
ObjectAnimator.ofInt(altTextWrapper, "top", prevTop, altTextWrapper.getTop()),
|
|
||||||
ObjectAnimator.ofFloat(altTextButton, View.ALPHA, show ? 1f : 0f, show ? 0f : 1f),
|
|
||||||
ObjectAnimator.ofFloat(altTextScroller, View.ALPHA, show ? 0f : 1f, show ? 1f : 0f),
|
|
||||||
ObjectAnimator.ofFloat(altTextClose, View.ALPHA, show ? 0f : 1f, show ? 1f : 0f)
|
|
||||||
);
|
|
||||||
set.setDuration(300);
|
|
||||||
set.setInterpolator(CubicBezierInterpolator.DEFAULT);
|
|
||||||
set.addListener(new AnimatorListenerAdapter(){
|
|
||||||
@Override
|
|
||||||
public void onAnimationEnd(Animator animation){
|
|
||||||
if(show){
|
|
||||||
altTextButton.setVisibility(View.GONE);
|
|
||||||
}else{
|
|
||||||
altTextScroller.setVisibility(View.GONE);
|
|
||||||
altTextClose.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
currentAnim=null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
set.start();
|
|
||||||
currentAnim=set;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,13 +89,10 @@ public class PollOptionStatusDisplayItem extends StatusDisplayItem{
|
|||||||
button.setBackground(progressBg);
|
button.setBackground(progressBg);
|
||||||
itemView.setSelected(item.isMostVoted);
|
itemView.setSelected(item.isMostVoted);
|
||||||
icon.setSelected(item.poll.ownVotes.contains(item.poll.options.indexOf(item.option)));
|
icon.setSelected(item.poll.ownVotes.contains(item.poll.options.indexOf(item.option)));
|
||||||
icon.setVisibility(item.poll.voted && item.poll.ownVotes.isEmpty() ? View.GONE : View.VISIBLE);
|
|
||||||
percent.setText(String.format(Locale.getDefault(), "%d%%", Math.round(item.votesFraction*100f)));
|
percent.setText(String.format(Locale.getDefault(), "%d%%", Math.round(item.votesFraction*100f)));
|
||||||
}else{
|
}else{
|
||||||
itemView.setSelected(item.poll.selectedOptions!=null && item.poll.selectedOptions.contains(item.option));
|
itemView.setSelected(item.poll.selectedOptions!=null && item.poll.selectedOptions.contains(item.option));
|
||||||
button.setBackgroundResource(R.drawable.bg_poll_option_clickable);
|
button.setBackgroundResource(R.drawable.bg_poll_option_clickable);
|
||||||
icon.setSelected(itemView.isSelected());
|
|
||||||
icon.setVisibility(View.VISIBLE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package org.joinmastodon.android.ui.displayitems;
|
|||||||
import static org.joinmastodon.android.MastodonApp.context;
|
import static org.joinmastodon.android.MastodonApp.context;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.text.SpannableStringBuilder;
|
import android.text.SpannableStringBuilder;
|
||||||
@@ -15,7 +14,6 @@ import android.widget.TextView;
|
|||||||
import org.joinmastodon.android.R;
|
import org.joinmastodon.android.R;
|
||||||
import org.joinmastodon.android.fragments.BaseStatusListFragment;
|
import org.joinmastodon.android.fragments.BaseStatusListFragment;
|
||||||
import org.joinmastodon.android.model.Emoji;
|
import org.joinmastodon.android.model.Emoji;
|
||||||
import org.joinmastodon.android.model.StatusPrivacy;
|
|
||||||
import org.joinmastodon.android.ui.text.HtmlParser;
|
import org.joinmastodon.android.ui.text.HtmlParser;
|
||||||
import org.joinmastodon.android.ui.utils.CustomEmojiHelper;
|
import org.joinmastodon.android.ui.utils.CustomEmojiHelper;
|
||||||
import org.joinmastodon.android.ui.utils.UiUtils;
|
import org.joinmastodon.android.ui.utils.UiUtils;
|
||||||
@@ -32,13 +30,10 @@ public class ReblogOrReplyLineStatusDisplayItem extends StatusDisplayItem{
|
|||||||
private CharSequence text;
|
private CharSequence text;
|
||||||
@DrawableRes
|
@DrawableRes
|
||||||
private int icon;
|
private int icon;
|
||||||
private StatusPrivacy visibility;
|
|
||||||
@DrawableRes
|
|
||||||
private int iconEnd;
|
|
||||||
private CustomEmojiHelper emojiHelper=new CustomEmojiHelper();
|
private CustomEmojiHelper emojiHelper=new CustomEmojiHelper();
|
||||||
private View.OnClickListener handleClick;
|
private View.OnClickListener handleClick;
|
||||||
|
|
||||||
public ReblogOrReplyLineStatusDisplayItem(String parentID, BaseStatusListFragment parentFragment, CharSequence text, List<Emoji> emojis, @DrawableRes int icon, StatusPrivacy visibility, @Nullable View.OnClickListener handleClick){
|
public ReblogOrReplyLineStatusDisplayItem(String parentID, BaseStatusListFragment parentFragment, CharSequence text, List<Emoji> emojis, @DrawableRes int icon, @Nullable View.OnClickListener handleClick){
|
||||||
super(parentID, parentFragment);
|
super(parentID, parentFragment);
|
||||||
SpannableStringBuilder ssb=new SpannableStringBuilder(text);
|
SpannableStringBuilder ssb=new SpannableStringBuilder(text);
|
||||||
HtmlParser.parseCustomEmoji(ssb, emojis);
|
HtmlParser.parseCustomEmoji(ssb, emojis);
|
||||||
@@ -48,17 +43,6 @@ public class ReblogOrReplyLineStatusDisplayItem extends StatusDisplayItem{
|
|||||||
this.handleClick=handleClick;
|
this.handleClick=handleClick;
|
||||||
TypedValue outValue = new TypedValue();
|
TypedValue outValue = new TypedValue();
|
||||||
context.getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
|
context.getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
|
||||||
updateVisibility(visibility);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateVisibility(StatusPrivacy visibility) {
|
|
||||||
this.visibility = visibility;
|
|
||||||
this.iconEnd = visibility != null ? switch (visibility) {
|
|
||||||
case PUBLIC -> R.drawable.ic_fluent_earth_20_regular;
|
|
||||||
case UNLISTED -> R.drawable.ic_fluent_people_community_20_regular;
|
|
||||||
case PRIVATE -> R.drawable.ic_fluent_people_checkmark_20_regular;
|
|
||||||
default -> 0;
|
|
||||||
} : 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -86,18 +70,10 @@ public class ReblogOrReplyLineStatusDisplayItem extends StatusDisplayItem{
|
|||||||
@Override
|
@Override
|
||||||
public void onBind(ReblogOrReplyLineStatusDisplayItem item){
|
public void onBind(ReblogOrReplyLineStatusDisplayItem item){
|
||||||
text.setText(item.text);
|
text.setText(item.text);
|
||||||
text.setCompoundDrawablesRelativeWithIntrinsicBounds(item.icon, 0, item.iconEnd, 0);
|
text.setCompoundDrawablesRelativeWithIntrinsicBounds(item.icon, 0, 0, 0);
|
||||||
if(item.handleClick!=null) text.setOnClickListener(item.handleClick);
|
if(item.handleClick!=null) text.setOnClickListener(item.handleClick);
|
||||||
text.setEnabled(!item.inset);
|
text.setEnabled(!item.inset);
|
||||||
text.setClickable(!item.inset);
|
text.setClickable(!item.inset);
|
||||||
Context ctx = itemView.getContext();
|
|
||||||
int visibilityText = item.visibility != null ? switch (item.visibility) {
|
|
||||||
case PUBLIC -> R.string.visibility_public;
|
|
||||||
case UNLISTED -> R.string.sk_visibility_unlisted;
|
|
||||||
case PRIVATE -> R.string.visibility_followers_only;
|
|
||||||
default -> 0;
|
|
||||||
} : 0;
|
|
||||||
if (visibilityText != 0) text.setContentDescription(item.text + " (" + ctx.getString(visibilityText) + ")");
|
|
||||||
if(Build.VERSION.SDK_INT<Build.VERSION_CODES.N)
|
if(Build.VERSION.SDK_INT<Build.VERSION_CODES.N)
|
||||||
UiUtils.fixCompoundDrawableTintOnAndroid6(text);
|
UiUtils.fixCompoundDrawableTintOnAndroid6(text);
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user