Compare commits

...

318 Commits

Author SHA1 Message Date
Grishka
7b25628f7a Fix more things 2024-03-06 20:58:59 +03:00
Grishka
e06dd1e465 Google can't stop breaking shit, can it 2024-03-06 20:24:14 +03:00
Grishka
a42ab10aed Merge branch 'l10n_master' 2024-03-06 19:45:58 +03:00
Grishka
cd2ea90006 Prepare a new release 2024-03-06 19:45:37 +03:00
Grishka
f0295edd83 Merge branch 'ci_setup' 2024-03-06 15:59:19 +03:00
Grishka
eee0a40224 Filter posts by account when opening a featured hashtag
closes #786
2024-03-06 15:39:36 +03:00
Grishka
bd189ae322 Why did I put it there 2024-03-06 15:24:27 +03:00
Grishka
714aa7a20b Fix #788 2024-03-06 15:23:20 +03:00
Eugen Rochko
76c6c65018 New translations strings.xml (French) 2024-03-05 22:32:45 +01:00
Eugen Rochko
c511b54de2 New translations strings.xml (French) 2024-03-05 21:19:55 +01:00
Eugen Rochko
16b4a1f1a3 New translations strings.xml (Portuguese, Brazilian) 2024-03-05 19:04:15 +01:00
Eugen Rochko
afb5743d31 New translations strings.xml (Portuguese, Brazilian) 2024-03-05 17:16:06 +01:00
Grishka
7e91c311d4 Crash fix 2024-03-05 05:04:50 +03:00
Eugen Rochko
eef9f61e20 New translations strings.xml (Japanese) 2024-03-03 06:27:26 +01:00
Grishka
0cc55891c1 Specify Java distribution 2024-03-02 01:30:12 +03:00
Grishka
e892eaa3d5 Update action versions & separate artifacts 2024-03-02 01:28:53 +03:00
Grishka
bcdce2a880 Skip changelogs too (fastlane/fastlane#21905) 2024-03-02 01:16:32 +03:00
Eugen Rochko
9f38809730 New translations strings.xml (Turkish) 2024-03-01 18:48:01 +01:00
Eugen Rochko
77b416a52d New translations full_description.txt (Turkish) 2024-03-01 17:08:11 +01:00
Eugen Rochko
0684b0ec79 New translations strings.xml (Portuguese, Brazilian) 2024-03-01 17:08:10 +01:00
Eugen Rochko
20057a55f0 New translations strings.xml (Turkish) 2024-03-01 17:08:09 +01:00
Eugen Rochko
a668dee567 New translations strings.xml (Vietnamese) 2024-03-01 15:22:53 +01:00
Grishka
11bda2fe07 Skip metadata for now 2024-03-01 10:43:48 +03:00
Grishka
a7b83bc058 Yaml is hard 2024-03-01 10:35:14 +03:00
Grishka
19950e5115 And Gradle needs to know where it is 2024-03-01 10:29:12 +03:00
Grishka
11be65c6fe Unsurprisingly, you need Android SDK to build an Android app 2024-03-01 10:23:45 +03:00
Grishka
b30ce84468 Maybe it will run this time? 2024-03-01 09:48:01 +03:00
Grishka
c242c7ec82 please work 2024-03-01 09:41:36 +03:00
Grishka
f128556a49 Add github action 2024-03-01 09:38:31 +03:00
Grishka
3cebc78443 Add Fastlane 2024-03-01 08:09:15 +03:00
Eugen Rochko
c640501430 New translations strings.xml (Basque) 2024-02-29 17:48:30 +01:00
Eugen Rochko
48100a19e1 New translations strings.xml (Thai) 2024-02-29 12:03:06 +01:00
Eugen Rochko
102ca8034a New translations strings.xml (Icelandic) 2024-02-29 12:03:05 +01:00
Eugen Rochko
c1d8f5904b New translations strings.xml (Italian) 2024-02-29 12:03:04 +01:00
Eugen Rochko
361086fc48 New translations strings.xml (French) 2024-02-29 12:03:03 +01:00
Eugen Rochko
10ebacf9cf New translations strings.xml (French) 2024-02-29 09:06:54 +01:00
Grishka
02bfb34665 Android Gradle Plugin can't JUST WORK, can it?! 2024-02-29 10:04:15 +03:00
Eugen Rochko
9f9ba7c367 New translations strings.xml (Chinese Traditional) 2024-02-29 00:40:36 +01:00
Eugen Rochko
4430822768 New translations strings.xml (Slovenian) 2024-02-28 23:33:09 +01:00
Grishka
b4904024c6 Add post pinning
closes #346
2024-02-29 00:57:47 +03:00
Eugen Rochko
0d047e5cf9 New translations strings.xml (Dutch) 2024-02-28 22:33:24 +01:00
Grishka
58259d9fb0 Add QR code scanner button to search tab 2024-02-28 23:48:00 +03:00
Grishka
e9dde114b7 Add haptic effect (AND-150) 2024-02-28 23:30:08 +03:00
Eugen Rochko
03c6f4130b New translations strings.xml (French) 2024-02-28 21:29:54 +01:00
Eugen Rochko
bb94c7fff4 New translations strings.xml (Dutch) 2024-02-28 21:29:53 +01:00
Grishka
217884aaec Increase line spacing 2024-02-28 23:23:42 +03:00
Eugen Rochko
17508e1f36 New translations strings.xml (Icelandic) 2024-02-28 20:34:17 +01:00
Eugen Rochko
95b33b35df New translations strings.xml (Icelandic) 2024-02-28 18:57:19 +01:00
Eugen Rochko
4c0ae74f2d New translations strings.xml (French) 2024-02-28 14:02:26 +01:00
Eugen Rochko
9ef9110297 New translations strings.xml (French) 2024-02-28 12:30:21 +01:00
Eugen Rochko
71e0115cd6 New translations strings.xml (Lithuanian) 2024-02-27 10:10:47 +01:00
Eugen Rochko
ec045abf53 New translations strings.xml (Basque) 2024-02-27 01:11:16 +01:00
Grishka
b8ae79faa1 Remove "www." from more places 2024-02-26 23:58:57 +03:00
Grishka
b51cccf1d7 Fix invite link detection 2024-02-26 23:54:35 +03:00
Eugen Rochko
87b78acd39 New translations strings.xml (Armenian) 2024-02-26 19:12:57 +01:00
Eugen Rochko
a965862c1b New translations strings.xml (Armenian) 2024-02-26 17:25:34 +01:00
Grishka
ce427d2a0b AND-149 2024-02-26 19:09:29 +03:00
Grishka
8ea4c84a29 AND-148 2024-02-26 17:59:41 +03:00
Eugen Rochko
0bb66708c6 New translations strings.xml (Armenian) 2024-02-26 06:58:11 +01:00
Eugen Rochko
bf4b04ef5f New translations strings.xml (Armenian) 2024-02-26 05:58:19 +01:00
Eugen Rochko
eea2f9c0cd New translations strings.xml (Japanese) 2024-02-26 03:36:15 +01:00
Grishka
3cdc27eb94 Remove dependency metadata blob from apks (#777) 2024-02-26 03:50:23 +03:00
Eugen Rochko
75237ab7dc New translations strings.xml (Chinese Traditional) 2024-02-25 22:55:01 +01:00
Eugen Rochko
7601a7de16 New translations strings.xml (Russian) 2024-02-25 19:36:34 +01:00
Eugen Rochko
3745240eea New translations strings.xml (Czech) 2024-02-25 17:36:47 +01:00
Gregory K
963b80cce9 Merge pull request #782 from FineFindus/fix/invisible-menu
fix: disable group divider in ProfileFragment on EMUI
2024-02-25 18:57:37 +03:00
Eugen Rochko
8812500734 New translations strings.xml (Czech) 2024-02-25 16:26:45 +01:00
FineFindus
bd41807f3b fix: disable group divider on EMUI 2024-02-25 16:25:42 +01:00
Eugen Rochko
90ee102eaa New translations strings.xml (Greek) 2024-02-25 13:24:23 +01:00
Eugen Rochko
0bac414151 New translations strings.xml (Greek) 2024-02-25 11:36:04 +01:00
Eugen Rochko
36bd1db67e New translations strings.xml (Hungarian) 2024-02-25 09:17:09 +01:00
Eugen Rochko
d15f3e5daf New translations strings.xml (Hungarian) 2024-02-25 08:21:23 +01:00
Eugen Rochko
4c9c444dfc New translations strings.xml (Thai) 2024-02-25 06:48:54 +01:00
Grishka
0dc23789f5 Merge branch 'l10n_master' 2024-02-24 23:58:29 +03:00
Grishka
3f0ebd4aed Bump version 2024-02-24 23:58:09 +03:00
Grishka
1e501c707c Add labels and animations to the tab bar 2024-02-24 23:03:18 +03:00
Eugen Rochko
d57f97b492 New translations strings.xml (Chinese Traditional) 2024-02-24 17:03:43 +01:00
Eugen Rochko
29f9214869 New translations strings.xml (German) 2024-02-24 14:17:55 +01:00
Eugen Rochko
c6c1fe3595 New translations strings.xml (German) 2024-02-24 12:59:50 +01:00
Eugen Rochko
2ba4c6f443 New translations strings.xml (German) 2024-02-24 11:52:04 +01:00
Eugen Rochko
a9ff948818 New translations full_description.txt (Thai) 2024-02-24 09:44:12 +01:00
Eugen Rochko
7dd9cfa7f0 New translations strings.xml (Thai) 2024-02-24 08:35:56 +01:00
Eugen Rochko
15a415558b New translations strings.xml (Thai) 2024-02-24 07:18:50 +01:00
Grishka
b3e53bc48d AND-133 2024-02-24 03:57:43 +03:00
Grishka
d0e33c8a12 AND-127 2024-02-24 03:48:06 +03:00
Eugen Rochko
060db42e47 New translations strings.xml (Italian) 2024-02-24 01:31:16 +01:00
Grishka
6bcf259de9 AND-129 2024-02-24 03:20:22 +03:00
Grishka
4d0a673209 AND-130 2024-02-24 03:14:41 +03:00
Grishka
be9be6dc35 AND-126 2024-02-24 03:05:21 +03:00
Grishka
3f47497c12 AND-132 2024-02-24 03:04:35 +03:00
Eugen Rochko
268e0af7cb New translations strings.xml (Chinese Traditional) 2024-02-24 00:31:53 +01:00
Eugen Rochko
c611f723b7 New translations strings.xml (Italian) 2024-02-24 00:31:52 +01:00
Eugen Rochko
4c9f500122 New translations strings.xml (Basque) 2024-02-24 00:31:50 +01:00
Eugen Rochko
15147dddf5 New translations strings.xml (Basque) 2024-02-23 23:31:42 +01:00
Eugen Rochko
747c81c269 New translations strings.xml (Thai) 2024-02-23 21:31:03 +01:00
Eugen Rochko
63ad076046 New translations strings.xml (Urdu (India)) 2024-02-23 18:49:13 +01:00
Eugen Rochko
f109033ed2 New translations strings.xml (Kabyle) 2024-02-23 18:49:12 +01:00
Eugen Rochko
9445d3383a New translations strings.xml (Igbo) 2024-02-23 18:49:11 +01:00
Eugen Rochko
5db5537685 New translations strings.xml (Occitan) 2024-02-23 18:49:10 +01:00
Eugen Rochko
1149d1c37f New translations strings.xml (Scottish Gaelic) 2024-02-23 18:49:09 +01:00
Eugen Rochko
e4b77551f7 New translations strings.xml (Sinhala) 2024-02-23 18:49:08 +01:00
Eugen Rochko
401fd298f5 New translations strings.xml (Bosnian) 2024-02-23 18:49:08 +01:00
Eugen Rochko
6a1f7f7238 New translations strings.xml (Filipino) 2024-02-23 18:49:07 +01:00
Eugen Rochko
7c1c0894a8 New translations strings.xml (Burmese) 2024-02-23 18:49:06 +01:00
Eugen Rochko
cb96ae6cbc New translations strings.xml (Croatian) 2024-02-23 18:49:05 +01:00
Eugen Rochko
c15d972359 New translations strings.xml (Thai) 2024-02-23 18:49:04 +01:00
Eugen Rochko
c010e2371c New translations strings.xml (Bengali) 2024-02-23 18:49:03 +01:00
Eugen Rochko
f88a244594 New translations strings.xml (Indonesian) 2024-02-23 18:49:02 +01:00
Eugen Rochko
e2dccda205 New translations strings.xml (Portuguese, Brazilian) 2024-02-23 18:49:01 +01:00
Eugen Rochko
bc6c6bc9a5 New translations strings.xml (Icelandic) 2024-02-23 18:48:59 +01:00
Eugen Rochko
3281eabbe1 New translations strings.xml (Galician) 2024-02-23 18:48:58 +01:00
Eugen Rochko
92de091228 New translations strings.xml (Vietnamese) 2024-02-23 18:48:57 +01:00
Eugen Rochko
94ab8a4e8b New translations strings.xml (Chinese Traditional) 2024-02-23 18:48:56 +01:00
Eugen Rochko
799987205e New translations strings.xml (Chinese Simplified) 2024-02-23 18:48:55 +01:00
Eugen Rochko
f5dfe70ac6 New translations strings.xml (Ukrainian) 2024-02-23 18:48:54 +01:00
Eugen Rochko
69b03e2e59 New translations strings.xml (Turkish) 2024-02-23 18:48:53 +01:00
Eugen Rochko
588ebe11f4 New translations strings.xml (Swedish) 2024-02-23 18:48:52 +01:00
Eugen Rochko
4fe0d6e893 New translations strings.xml (Slovenian) 2024-02-23 18:48:51 +01:00
Eugen Rochko
787c20794f New translations strings.xml (Portuguese) 2024-02-23 18:48:50 +01:00
Eugen Rochko
c462e72279 New translations strings.xml (Norwegian) 2024-02-23 18:48:49 +01:00
Eugen Rochko
be7e6afce2 New translations strings.xml (Lithuanian) 2024-02-23 18:48:48 +01:00
Eugen Rochko
feb9920829 New translations strings.xml (Korean) 2024-02-23 18:48:47 +01:00
Eugen Rochko
4d6a1a705d New translations strings.xml (Georgian) 2024-02-23 18:48:46 +01:00
Eugen Rochko
59d54469dc New translations strings.xml (Japanese) 2024-02-23 18:48:45 +01:00
Eugen Rochko
9cccd28447 New translations strings.xml (Italian) 2024-02-23 18:48:44 +01:00
Eugen Rochko
da13b4602c New translations strings.xml (Armenian) 2024-02-23 18:48:43 +01:00
Eugen Rochko
2084a33192 New translations strings.xml (Hebrew) 2024-02-23 18:48:42 +01:00
Eugen Rochko
542ce40c1a New translations strings.xml (Irish) 2024-02-23 18:48:41 +01:00
Eugen Rochko
ddd4ea329c New translations strings.xml (Finnish) 2024-02-23 18:48:40 +01:00
Eugen Rochko
b5c3875ce9 New translations strings.xml (Basque) 2024-02-23 18:48:39 +01:00
Eugen Rochko
ec8387d9db New translations strings.xml (German) 2024-02-23 18:48:38 +01:00
Eugen Rochko
cf464e8eea New translations strings.xml (Danish) 2024-02-23 18:48:37 +01:00
Eugen Rochko
7b66f1c398 New translations strings.xml (Czech) 2024-02-23 18:48:36 +01:00
Eugen Rochko
814e11c1f4 New translations strings.xml (Arabic) 2024-02-23 18:48:35 +01:00
Eugen Rochko
647277444b New translations strings.xml (Spanish) 2024-02-23 18:48:34 +01:00
Eugen Rochko
bd4ff9c7ec New translations strings.xml (French) 2024-02-23 18:48:33 +01:00
Eugen Rochko
7ed6195cca New translations strings.xml (Romanian) 2024-02-23 18:48:32 +01:00
Eugen Rochko
43397f069a New translations strings.xml (Dutch) 2024-02-23 18:48:31 +01:00
Eugen Rochko
8e34e31b35 New translations strings.xml (Persian) 2024-02-23 18:48:30 +01:00
Eugen Rochko
7ef1bdfc2a New translations strings.xml (Catalan) 2024-02-23 18:48:29 +01:00
Eugen Rochko
726f91ec75 New translations strings.xml (Belarusian) 2024-02-23 18:48:28 +01:00
Eugen Rochko
55a5268a3c New translations strings.xml (Hindi) 2024-02-23 18:48:27 +01:00
Eugen Rochko
4777e3d0b7 New translations strings.xml (Greek) 2024-02-23 18:48:26 +01:00
Eugen Rochko
bfc970abe5 New translations strings.xml (Russian) 2024-02-23 18:48:24 +01:00
Eugen Rochko
d2d35f4f39 New translations strings.xml (Polish) 2024-02-23 18:48:23 +01:00
Eugen Rochko
49cef5ea0a New translations strings.xml (Hungarian) 2024-02-23 18:48:22 +01:00
Grishka
f2fbf55c53 AND-134 2024-02-23 20:45:17 +03:00
Grishka
eacfd2fa4f AND-125 2024-02-23 20:00:35 +03:00
Grishka
51f87848f4 AND-128 2024-02-23 19:36:37 +03:00
Grishka
c3f4637ddc AND-137 2024-02-23 19:31:23 +03:00
Grishka
2361394391 Share sheet previews (AND-139) 2024-02-23 19:25:21 +03:00
Eugen Rochko
38fdf8d53e New translations strings.xml (Italian) 2024-02-23 17:25:02 +01:00
Eugen Rochko
0cd3cab65d New translations strings.xml (Greek) 2024-02-23 15:31:39 +01:00
Eugen Rochko
142c8b55a1 New translations strings.xml (Hungarian) 2024-02-23 09:55:26 +01:00
Eugen Rochko
3274acaba8 New translations strings.xml (Hungarian) 2024-02-23 08:04:37 +01:00
Eugen Rochko
99b7d46ddf New translations full_description.txt (Armenian) 2024-02-23 06:54:22 +01:00
Eugen Rochko
4f7e45211f New translations strings.xml (Chinese Traditional) 2024-02-23 02:02:20 +01:00
Eugen Rochko
221773bf71 New translations strings.xml (Urdu (India)) 2024-02-22 23:36:54 +01:00
Eugen Rochko
305ce2ca42 New translations strings.xml (Kabyle) 2024-02-22 23:36:53 +01:00
Eugen Rochko
7dc2480400 New translations strings.xml (Igbo) 2024-02-22 23:36:52 +01:00
Eugen Rochko
9634ec6616 New translations strings.xml (Occitan) 2024-02-22 23:36:51 +01:00
Eugen Rochko
6f29540170 New translations strings.xml (Scottish Gaelic) 2024-02-22 23:36:50 +01:00
Eugen Rochko
18485c1cf8 New translations strings.xml (Sinhala) 2024-02-22 23:36:49 +01:00
Eugen Rochko
7c36c32e4b New translations strings.xml (Bosnian) 2024-02-22 23:36:48 +01:00
Eugen Rochko
1d0af51813 New translations strings.xml (Filipino) 2024-02-22 23:36:47 +01:00
Eugen Rochko
d50060d602 New translations strings.xml (Burmese) 2024-02-22 23:36:46 +01:00
Eugen Rochko
9d455b2331 New translations strings.xml (Croatian) 2024-02-22 23:36:45 +01:00
Eugen Rochko
5f3b537f7d New translations strings.xml (Thai) 2024-02-22 23:36:44 +01:00
Eugen Rochko
1d43ed4c8a New translations strings.xml (Bengali) 2024-02-22 23:36:43 +01:00
Eugen Rochko
e839323575 New translations strings.xml (Indonesian) 2024-02-22 23:36:42 +01:00
Eugen Rochko
7ee657012e New translations strings.xml (Portuguese, Brazilian) 2024-02-22 23:36:41 +01:00
Eugen Rochko
847fbed956 New translations strings.xml (Icelandic) 2024-02-22 23:36:40 +01:00
Eugen Rochko
a89d5df313 New translations strings.xml (Galician) 2024-02-22 23:36:39 +01:00
Eugen Rochko
5f58789008 New translations strings.xml (Vietnamese) 2024-02-22 23:36:38 +01:00
Eugen Rochko
7b64cad668 New translations strings.xml (Chinese Traditional) 2024-02-22 23:36:37 +01:00
Eugen Rochko
70f60f094d New translations strings.xml (Chinese Simplified) 2024-02-22 23:36:36 +01:00
Eugen Rochko
a5eff14552 New translations strings.xml (Ukrainian) 2024-02-22 23:36:35 +01:00
Eugen Rochko
36fb929387 New translations strings.xml (Turkish) 2024-02-22 23:36:34 +01:00
Eugen Rochko
66aabfb386 New translations strings.xml (Swedish) 2024-02-22 23:36:33 +01:00
Eugen Rochko
f503973db1 New translations strings.xml (Slovenian) 2024-02-22 23:36:32 +01:00
Eugen Rochko
7cec835509 New translations strings.xml (Portuguese) 2024-02-22 23:36:31 +01:00
Eugen Rochko
e300942455 New translations strings.xml (Norwegian) 2024-02-22 23:36:30 +01:00
Eugen Rochko
79476eff85 New translations strings.xml (Lithuanian) 2024-02-22 23:36:29 +01:00
Eugen Rochko
b4ec470691 New translations strings.xml (Korean) 2024-02-22 23:36:28 +01:00
Eugen Rochko
4f72a0c74e New translations strings.xml (Georgian) 2024-02-22 23:36:27 +01:00
Eugen Rochko
bcbb41aa43 New translations strings.xml (Japanese) 2024-02-22 23:36:27 +01:00
Eugen Rochko
5cc38d845a New translations strings.xml (Italian) 2024-02-22 23:36:26 +01:00
Eugen Rochko
36acc1588a New translations strings.xml (Armenian) 2024-02-22 23:36:25 +01:00
Eugen Rochko
349c5200ed New translations strings.xml (Hebrew) 2024-02-22 23:36:24 +01:00
Eugen Rochko
ff71f6a092 New translations strings.xml (Irish) 2024-02-22 23:36:23 +01:00
Eugen Rochko
8863284970 New translations strings.xml (Finnish) 2024-02-22 23:36:22 +01:00
Eugen Rochko
d5feb4e9f9 New translations strings.xml (Basque) 2024-02-22 23:36:21 +01:00
Eugen Rochko
4c284226e5 New translations strings.xml (German) 2024-02-22 23:36:20 +01:00
Eugen Rochko
fef9cf5e64 New translations strings.xml (Danish) 2024-02-22 23:36:19 +01:00
Eugen Rochko
93f3c9a9eb New translations strings.xml (Czech) 2024-02-22 23:36:18 +01:00
Eugen Rochko
5827c77b0c New translations strings.xml (Arabic) 2024-02-22 23:36:17 +01:00
Eugen Rochko
1b36866fba New translations strings.xml (Spanish) 2024-02-22 23:36:16 +01:00
Eugen Rochko
ebc10d5052 New translations strings.xml (French) 2024-02-22 23:36:15 +01:00
Eugen Rochko
8953fa48c7 New translations strings.xml (Romanian) 2024-02-22 23:36:14 +01:00
Eugen Rochko
59e7a296ca New translations strings.xml (Dutch) 2024-02-22 23:36:13 +01:00
Eugen Rochko
86432228a3 New translations strings.xml (Persian) 2024-02-22 23:36:12 +01:00
Eugen Rochko
4518566c37 New translations strings.xml (Catalan) 2024-02-22 23:36:11 +01:00
Eugen Rochko
b392a89350 New translations strings.xml (Belarusian) 2024-02-22 23:36:10 +01:00
Eugen Rochko
225682f35d New translations strings.xml (Hindi) 2024-02-22 23:36:09 +01:00
Eugen Rochko
b41ff2e18f New translations strings.xml (Greek) 2024-02-22 23:36:08 +01:00
Eugen Rochko
6ef76fb5bb New translations strings.xml (Russian) 2024-02-22 23:36:07 +01:00
Eugen Rochko
a36679b032 New translations strings.xml (Polish) 2024-02-22 23:36:06 +01:00
Eugen Rochko
dde91778a2 New translations strings.xml (Hungarian) 2024-02-22 23:36:05 +01:00
Grishka
1cdc6f4fcf Tweaks to QR code and media viewer 2024-02-23 01:20:24 +03:00
Grishka
b8a5346631 Crash fix 2024-02-22 23:15:03 +03:00
Grishka
5cf222379a QR codes for profiles 2024-02-22 21:35:46 +03:00
Eugen Rochko
8f4ff49b32 New translations strings.xml (Basque) 2024-02-21 19:34:39 +01:00
Eugen Rochko
3a68ca3cc0 New translations strings.xml (Basque) 2024-02-21 18:37:46 +01:00
Eugen Rochko
116dc68a38 New translations strings.xml (Basque) 2024-02-21 15:47:30 +01:00
Eugen Rochko
df84b0ac34 New translations strings.xml (Basque) 2024-02-21 14:12:43 +01:00
Eugen Rochko
5ef737766c New translations strings.xml (Lithuanian) 2024-02-21 13:00:51 +01:00
Eugen Rochko
be17ba870b New translations strings.xml (Basque) 2024-02-21 13:00:50 +01:00
Eugen Rochko
747b2d5801 New translations strings.xml (Lithuanian) 2024-02-21 11:13:33 +01:00
Eugen Rochko
b84c9bf948 New translations strings.xml (Icelandic) 2024-02-19 23:55:39 +01:00
Grishka
b1e999cc9c Fix crash in post language selector once again 2024-02-20 00:39:58 +03:00
Eugen Rochko
89951a8547 New translations strings.xml (Icelandic) 2024-02-19 22:29:02 +01:00
Eugen Rochko
1bb0ac1110 New translations strings.xml (Icelandic) 2024-02-19 14:05:01 +01:00
Eugen Rochko
5bb51901f7 New translations strings.xml (Czech) 2024-02-19 14:05:00 +01:00
Eugen Rochko
18562cd3ee New translations strings.xml (Icelandic) 2024-02-19 12:34:48 +01:00
Eugen Rochko
9e01270b1e New translations strings.xml (Persian) 2024-02-19 06:27:29 +01:00
Eugen Rochko
0b1ff9730c New translations strings.xml (Lithuanian) 2024-02-18 00:14:32 +01:00
Eugen Rochko
845cfde58e New translations strings.xml (Dutch) 2024-02-17 22:27:21 +01:00
Eugen Rochko
f81f264b37 New translations strings.xml (Dutch) 2024-02-17 21:28:35 +01:00
Eugen Rochko
5e14270c47 New translations strings.xml (Dutch) 2024-02-17 19:19:32 +01:00
Eugen Rochko
6d2427b336 New translations strings.xml (Dutch) 2024-02-17 18:24:02 +01:00
Eugen Rochko
d89562a4c0 New translations strings.xml (Dutch) 2024-02-17 17:15:00 +01:00
Eugen Rochko
08389b023d New translations strings.xml (Turkish) 2024-02-17 12:50:42 +01:00
Eugen Rochko
797c4d6baa New translations strings.xml (Greek) 2024-02-17 12:50:41 +01:00
Eugen Rochko
9458ddd490 New translations strings.xml (Vietnamese) 2024-02-17 05:24:24 +01:00
Eugen Rochko
8f3a8af35e New translations strings.xml (Vietnamese) 2024-02-17 04:26:46 +01:00
Eugen Rochko
d0f927c8d2 New translations strings.xml (Lithuanian) 2024-02-16 12:54:29 +01:00
Eugen Rochko
2de44c8d7f New translations strings.xml (Slovenian) 2024-02-15 23:54:13 +01:00
Eugen Rochko
9a3ab2f4d2 New translations strings.xml (Slovenian) 2024-02-15 22:29:25 +01:00
Eugen Rochko
7cecd689bb New translations strings.xml (Lithuanian) 2024-02-15 22:29:24 +01:00
Eugen Rochko
b79cf4e087 New translations strings.xml (Lithuanian) 2024-02-15 21:11:35 +01:00
Eugen Rochko
63a9ce6eb6 New translations strings.xml (Hindi) 2024-02-15 13:02:59 +01:00
Eugen Rochko
1f960e8631 New translations strings.xml (Hindi) 2024-02-15 11:34:35 +01:00
Eugen Rochko
6dc059646e New translations strings.xml (Italian) 2024-02-15 00:39:26 +01:00
Eugen Rochko
5b37db0f8e New translations strings.xml (Italian) 2024-02-14 23:35:53 +01:00
Eugen Rochko
2789dd9fd1 New translations strings.xml (Belarusian) 2024-02-14 15:35:06 +01:00
Eugen Rochko
a2a72a4aee New translations strings.xml (Belarusian) 2024-02-14 14:02:19 +01:00
Eugen Rochko
b79fc8132a New translations strings.xml (Japanese) 2024-02-14 06:46:50 +01:00
Eugen Rochko
91b8735a4c New translations strings.xml (Japanese) 2024-02-14 05:28:17 +01:00
Eugen Rochko
313d81ffe1 New translations strings.xml (Japanese) 2024-02-14 01:33:19 +01:00
Eugen Rochko
192b32c1c6 New translations strings.xml (Lithuanian) 2024-02-13 22:53:46 +01:00
Eugen Rochko
2ef8be7c59 New translations strings.xml (Lithuanian) 2024-02-13 21:49:15 +01:00
Eugen Rochko
94e8d5e6d9 New translations strings.xml (Thai) 2024-02-13 20:40:01 +01:00
Eugen Rochko
445600653e New translations strings.xml (Lithuanian) 2024-02-13 20:40:00 +01:00
Eugen Rochko
4349c7a9e7 New translations full_description.txt (Chinese Traditional) 2024-02-13 19:24:53 +01:00
Eugen Rochko
c2b2c39c8a New translations strings.xml (Thai) 2024-02-13 19:24:52 +01:00
Eugen Rochko
9dee6eea24 New translations strings.xml (Chinese Traditional) 2024-02-13 19:24:51 +01:00
Eugen Rochko
53355b31ea New translations strings.xml (Thai) 2024-02-13 17:47:14 +01:00
Eugen Rochko
c2f55675a8 New translations strings.xml (Thai) 2024-02-13 15:07:09 +01:00
Eugen Rochko
42f3c58d02 New translations strings.xml (Swedish) 2024-02-13 09:32:18 +01:00
Eugen Rochko
dac2c413d6 New translations strings.xml (Belarusian) 2024-02-13 09:32:17 +01:00
Eugen Rochko
a539eb3768 New translations strings.xml (Chinese Traditional) 2024-02-13 05:00:33 +01:00
Eugen Rochko
481610cd10 New translations strings.xml (Belarusian) 2024-02-13 02:38:49 +01:00
Eugen Rochko
fa78a0f6ca New translations strings.xml (Chinese Traditional) 2024-02-12 19:39:20 +01:00
Eugen Rochko
bcc96ff329 New translations strings.xml (Slovenian) 2024-02-12 19:39:16 +01:00
Eugen Rochko
bb3028fff6 New translations strings.xml (Japanese) 2024-02-12 19:39:12 +01:00
Eugen Rochko
3e66ce8949 New translations strings.xml (Spanish) 2024-02-12 19:39:04 +01:00
Eugen Rochko
5f89fb1e49 New translations strings.xml (Spanish) 2024-02-12 10:43:18 +01:00
Eugen Rochko
b5b3c2671a New translations strings.xml (Spanish) 2024-02-12 09:04:43 +01:00
Eugen Rochko
6a8c09c113 New translations strings.xml (Slovenian) 2024-02-11 22:10:41 +01:00
Eugen Rochko
9660a2a019 New translations strings.xml (Japanese) 2024-02-11 13:03:46 +01:00
Eugen Rochko
f667b657f6 New translations strings.xml (Japanese) 2024-02-11 11:07:22 +01:00
Eugen Rochko
9db309634e New translations strings.xml (Chinese Traditional) 2024-02-09 10:00:17 +01:00
Eugen Rochko
8a96762bcc New translations strings.xml (Chinese Traditional) 2024-02-09 08:08:32 +01:00
Eugen Rochko
d58b24722e New translations strings.xml (Kabyle) 2024-02-09 01:31:56 +01:00
Eugen Rochko
fe8904b7a5 New translations strings.xml (Scottish Gaelic) 2024-02-09 01:31:54 +01:00
Eugen Rochko
6f3404aac9 New translations strings.xml (Bosnian) 2024-02-09 01:31:52 +01:00
Eugen Rochko
9a81f720c2 New translations strings.xml (Filipino) 2024-02-09 01:31:51 +01:00
Eugen Rochko
3605ad4616 New translations strings.xml (Burmese) 2024-02-09 01:31:50 +01:00
Eugen Rochko
490ecfcb43 New translations strings.xml (Croatian) 2024-02-09 01:31:49 +01:00
Eugen Rochko
02b8ac55d5 New translations strings.xml (Thai) 2024-02-09 01:31:48 +01:00
Eugen Rochko
fd71f04ca5 New translations strings.xml (Bengali) 2024-02-09 01:31:47 +01:00
Eugen Rochko
091953ada8 New translations strings.xml (Indonesian) 2024-02-09 01:31:46 +01:00
Eugen Rochko
8707db891a New translations strings.xml (Portuguese, Brazilian) 2024-02-09 01:31:45 +01:00
Eugen Rochko
1c67cb5edb New translations strings.xml (Icelandic) 2024-02-09 01:31:44 +01:00
Eugen Rochko
a96567c329 New translations strings.xml (Galician) 2024-02-09 01:31:43 +01:00
Eugen Rochko
691372119a New translations strings.xml (Vietnamese) 2024-02-09 01:31:42 +01:00
Eugen Rochko
25734af54e New translations strings.xml (Chinese Traditional) 2024-02-09 01:31:41 +01:00
Eugen Rochko
b37f9abeae New translations strings.xml (Chinese Simplified) 2024-02-09 01:31:40 +01:00
Eugen Rochko
f502374533 New translations strings.xml (Ukrainian) 2024-02-09 01:31:39 +01:00
Eugen Rochko
f10da18272 New translations strings.xml (Turkish) 2024-02-09 01:31:38 +01:00
Eugen Rochko
940f2ca73f New translations strings.xml (Swedish) 2024-02-09 01:31:37 +01:00
Eugen Rochko
db3192e75a New translations strings.xml (Slovenian) 2024-02-09 01:31:36 +01:00
Eugen Rochko
1841568e7e New translations strings.xml (Portuguese) 2024-02-09 01:31:35 +01:00
Eugen Rochko
f4ce0e67ac New translations strings.xml (Norwegian) 2024-02-09 01:31:34 +01:00
Eugen Rochko
92b34f085e New translations strings.xml (Lithuanian) 2024-02-09 01:31:33 +01:00
Eugen Rochko
4e4eb05526 New translations strings.xml (Korean) 2024-02-09 01:31:32 +01:00
Eugen Rochko
4dc707871d New translations strings.xml (Georgian) 2024-02-09 01:31:31 +01:00
Eugen Rochko
e9562378b4 New translations strings.xml (Japanese) 2024-02-09 01:31:30 +01:00
Eugen Rochko
c1b9aa7826 New translations strings.xml (Italian) 2024-02-09 01:31:29 +01:00
Eugen Rochko
e979a348be New translations strings.xml (Armenian) 2024-02-09 01:31:28 +01:00
Eugen Rochko
89c5787ad6 New translations strings.xml (Finnish) 2024-02-09 01:31:26 +01:00
Eugen Rochko
f0b2329656 New translations strings.xml (Basque) 2024-02-09 01:31:25 +01:00
Eugen Rochko
6cf9969220 New translations strings.xml (German) 2024-02-09 01:31:24 +01:00
Eugen Rochko
1f37e7605e New translations strings.xml (Danish) 2024-02-09 01:31:23 +01:00
Eugen Rochko
cf6af6f912 New translations strings.xml (Czech) 2024-02-09 01:31:22 +01:00
Eugen Rochko
2c91adb03e New translations strings.xml (Arabic) 2024-02-09 01:31:21 +01:00
Eugen Rochko
911da90854 New translations strings.xml (Spanish) 2024-02-09 01:31:20 +01:00
Eugen Rochko
27f0235055 New translations strings.xml (French) 2024-02-09 01:31:19 +01:00
Eugen Rochko
f3764222d8 New translations strings.xml (Dutch) 2024-02-09 01:31:17 +01:00
Eugen Rochko
64cb8c4a9a New translations strings.xml (Persian) 2024-02-09 01:31:16 +01:00
Eugen Rochko
de78356f5a New translations strings.xml (Catalan) 2024-02-09 01:31:16 +01:00
Eugen Rochko
8a9d39397c New translations strings.xml (Belarusian) 2024-02-09 01:31:15 +01:00
Eugen Rochko
2d89fd0cf0 New translations strings.xml (Hindi) 2024-02-09 01:31:14 +01:00
Eugen Rochko
402620dbe4 New translations strings.xml (Greek) 2024-02-09 01:31:13 +01:00
Eugen Rochko
32776db395 New translations strings.xml (Russian) 2024-02-09 01:31:12 +01:00
Eugen Rochko
4523ab8a67 New translations strings.xml (Polish) 2024-02-09 01:31:11 +01:00
Eugen Rochko
760106bf5b New translations strings.xml (Hungarian) 2024-02-09 01:31:09 +01:00
Eugen Rochko
f705afcafc New translations strings.xml (Dutch) 2024-02-08 23:16:32 +01:00
180 changed files with 5828 additions and 1597 deletions

79
.github/workflows/build_and_deploy.yml vendored Normal file
View File

@@ -0,0 +1,79 @@
name: Build and deploy
on:
push:
branches:
- 'ci_setup'
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v2
with:
java-version: 21
distribution: temurin
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7.2
bundler-cache: true
- name: Set up Android SDK
uses: android-actions/setup-android@v3
- name: Decode keystore
uses: timheuer/base64-to-file@v1
id: android_keystore
with:
fileName: "release.jks"
encodedString: ${{ secrets.KEYSTORE_FILE }}
- name: Prepare Gradle environment
run: |
echo "apply from: 'ci_signing.gradle'" >> mastodon/build.gradle
echo "sdk.dir=$ANDROID_SDK_ROOT" > local.properties
- name: Build and deploy to Google Play
run: bundle exec fastlane deploy
env:
KEYSTORE_FILE: ${{ steps.android_keystore.outputs.filePath }}
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
SUPPLY_JSON_KEY_DATA: ${{ secrets.GOOGLE_SERVICE_ACCOUNT_KEY }}
SUPPLY_SKIP_UPLOAD_METADATA: true
SUPPLY_SKIP_UPLOAD_CHANGELOGS: true
- name: Build release apk
run: ./gradlew assembleRelease
env:
KEYSTORE_FILE: ${{ steps.android_keystore.outputs.filePath }}
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
- name: Upload release apk
uses: actions/upload-artifact@v4
with:
name: mastodon-release.apk
path: mastodon/build/outputs/apk/release/mastodon-release.apk
- name: Build githubRelease apk
run: ./gradlew assembleGithubRelease
env:
KEYSTORE_FILE: ${{ steps.android_keystore.outputs.filePath }}
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
- name: Upload githubRelease apk
uses: actions/upload-artifact@v4
with:
name: mastodon-githubRelease.apk
path: mastodon/build/outputs/apk/githubRelease/mastodon-githubRelease.apk
- name: Upload mappings
uses: actions/upload-artifact@v4
with:
name: mappings
path: mastodon/build/outputs/mapping/*/mapping.txt

1
.gitignore vendored
View File

@@ -9,3 +9,4 @@
.cxx
local.properties
*.jks
/fastlane/report.xml

3
Gemfile Normal file
View File

@@ -0,0 +1,3 @@
source "https://rubygems.org"
gem "fastlane"

View File

@@ -5,7 +5,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:7.4.2"
classpath "com.android.tools.build:gradle:8.2.2"
classpath "com.google.android.libraries.mapsplatform.secrets-gradle-plugin:secrets-gradle-plugin:2.0.1"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files

2
fastlane/Appfile Normal file
View File

@@ -0,0 +1,2 @@
json_key_file("") # Path to the json secret file - Follow https://docs.fastlane.tools/actions/supply/#setup to get one
package_name("org.joinmastodon.android") # e.g. com.krausefx.app

36
fastlane/Fastfile Normal file
View File

@@ -0,0 +1,36 @@
# This file contains the fastlane.tools configuration
# You can find the documentation at https://docs.fastlane.tools
#
# For a list of all available actions, check out
#
# https://docs.fastlane.tools/actions
#
# For a list of all available plugins, check out
#
# https://docs.fastlane.tools/plugins/available-plugins
#
# Uncomment the line if you want fastlane to automatically update itself
# update_fastlane
default_platform(:android)
platform :android do
desc "Runs all the tests"
lane :test do
gradle(task: "test")
end
desc "Deploy a new version to the Google Play"
lane :deploy do
gradle(
task: "bundle",
build_type: "release",
)
upload_to_play_store(
changes_not_sent_for_review: true,
skip_upload_images: true,
skip_upload_screenshots: true
)
end
end

40
fastlane/README.md Normal file
View File

@@ -0,0 +1,40 @@
fastlane documentation
----
# Installation
Make sure you have the latest version of the Xcode command line tools installed:
```sh
xcode-select --install
```
For _fastlane_ installation instructions, see [Installing _fastlane_](https://docs.fastlane.tools/#installing-fastlane)
# Available Actions
## Android
### android test
```sh
[bundle exec] fastlane android test
```
Runs all the tests
### android deploy
```sh
[bundle exec] fastlane android deploy
```
Deploy a new version to the Google Play
----
This README.md is auto-generated and will be re-generated every time [_fastlane_](https://fastlane.tools) is run.
More information about _fastlane_ can be found on [fastlane.tools](https://fastlane.tools).
The documentation of _fastlane_ can be found on [docs.fastlane.tools](https://docs.fastlane.tools).

View File

@@ -0,0 +1,3 @@
- You can now easily share and scan QR codes to quickly find each other
- We've updated the look of the tab bar to better match current platform guidelines
- Various minor usability improvements

View File

@@ -0,0 +1,3 @@
- QR code scanner can now be accessed from the explore page
- You can now pin posts to your profile
- Fixed featured hashtags on profiles not showing the profile's own posts exclusively

View File

@@ -4,12 +4,12 @@
Mastodon is built with a focus on privacy and safety. Decide whether your posts are shared with your followers, just the people you mention, or the whole world. Զգայուն կամ հրահրող թեմաներով գրառումները կարելի է թաքցնել նախազգուշացումներով։ Each community has its own guidelines and moderators to keep its members safe, and robust blocking and reporting tools help prevent abuse.
Ավելին՝
Ավելին.
• Մուգ տարբերակ՝ կարդացեք գրառումներ մուգ, բաց կամ իսկական սև տարբերակներում
• Հարցումներ՝ իմացեք ձեր հետևորդների կարծիքը և հաշվեք ձայները
• Մուգ տարբերակ. կարդացեք գրառումներ մուգ, բաց կամ իսկական սև տարբերակներում
• Հարցումներ. իմացեք ձեր հետևորդների կարծիքը և հաշվեք ձայները
• Explore: Trending hashtags and accounts are a tap away
Notifications: Get notified about new follows, replies, and reblogs
Հիշեցումներ` ստացեք հիշեցումներ նոր հետևումների, մեկնաբանությունների և կիսումների մասին
• Sharing: Post directly to Mastodon from any share sheet in any app
• Cuteness: Our mascot is an adorable elephant, and you'll see them pop up from time to time

View File

@@ -2,7 +2,7 @@ Mastodon เป็นเครือข่ายสังคมแบบกร
เข้าร่วมชุมชนและสร้างโปรไฟล์ ค้นหาและติดตามผู้คนที่น่าสนใจและอ่านโพสต์ของเขาในเส้นเวลาที่ไม่มีโฆษณาและเรียงตามลำดับเวลา แสดงความรู้สึกของตัวคุณเองด้วยอีโมจิที่กำหนดเอง รูปภาพ GIF วิดีโอ และเสียงในโพสต์ 500 ตัวอักษร ตอบกลับและดันโพสต์จากคนอื่น ๆ เพื่อแชร์สิ่งดี ๆ และค้นหาบัญชีใหม่ ๆ ที่จะติดตามและแฮชแท็กที่เป็นที่นิยมเพื่อขยายเครือข่ายของคุณ
Mastodon สร้างขึ้นโดยเน้นความเป็นส่วนตัวและความปลอดภัยเป็นสำคัญ คุณสามารถตัดสินใจได้ว่าโพสต์ของคุณจะถูกแชร์กับผู้ติดตามของคุณ คนที่คุณกล่าวถึง หรือคนทั้งโลกก็ได้ ฟังก์ชั่นคำเตือนเนื้อหาช่วยให้คุณซ่อนโพสต์ที่มีเนื้อหาที่ละเอียดอ่อนจนกว่าคุณจะพร้อมเห็นเนื้อหานั้น แต่ละชุมชนจะมีหลักเกณฑ์และผู้ควบคุมเป็นของตนเองเพื่อรักษาความปลอดภัยของสมาชิก รวมถึงเครื่องมือการปิดกั้นและรายงานที่มีประสิทธิภาพเพื่อช่วยป้องกันการกระทำผิด
Mastodon สร้างขึ้นโดยเน้นความเป็นส่วนตัวและความปลอดภัยเป็นสำคัญ คุณสามารถตัดสินใจได้ว่าโพสต์ของคุณจะถูกแชร์กับผู้ติดตามของคุณ คนที่คุณกล่าวถึง หรือคนทั้งโลกก็ได้ ฟังก์ชั่นคำเตือนเนื้อหาช่วยให้คุณซ่อนโพสต์ที่มีเนื้อหาที่ละเอียดอ่อนจนกว่าคุณจะพร้อมเห็นเนื้อหานั้น แต่ละชุมชนจะมีหลักเกณฑ์และผู้กลั่นกรองเป็นของตนเองเพื่อรักษาความปลอดภัยของสมาชิก รวมถึงเครื่องมือการปิดกั้นและรายงานที่มีประสิทธิภาพเพื่อช่วยป้องกันการกระทำผิด
คุณสมบัติอื่น ๆ:

View File

@@ -1,4 +1,4 @@
Mastodon, internetteki merkezi olmayan en büyük sosyal ağdır. Tek bir web siteye bağlı kalmaksızın, milyonlarca kullanıcının bağımsız olarak birbiri ile kolayca etkileşebileceği bir ağdır. Hangi konuyla ilgili olduğunuz önemli değil, Mastodon'da onunla ilgili gönderi paylaşan tutkulu insanlarla tanışabilirsiniz!
Mastodon, internetteki merkezi olmayan en büyük sosyal ağdır. Tek bir web siteye bağlı kalmaksızın, milyonlarca kullanıcının bağımsız olarak birbirleriyle kolayca etkileşebileceği bir ağdır. Hangi konuyla ilgili olduğunuz önemli değil, Mastodon'da onunla ilgili gönderi paylaşan tutkulu insanlarla tanışabilirsiniz!
Bir topluluğa katılın ve profilinizi oluşturun. Olağanüstü kişileri bulun ve takip edin; gönderilerini reklamsız ve kronolojik bir zaman çizelgesinde okuyun. Gönderilerinizde şimdilik 500 karakter sınırlamasıyla kendinizi emojiler, görseller, GIFler, videolar ve sesler ile ifade edin. Harika içerikler paylaşmak için başlıklara yanıt yazın, insanların gönderilerini yineleyin. Ağınızı genişletmek için takip edilecek yeni hesaplar ve hashtagler bulun.
@@ -13,4 +13,4 @@ Diğer özellikler:
• Paylaşım: Doğrudan Mastodon'a herhangi bir türde gönderi paylaş
• Sevimlilik: Maskotumuz şirin bir fil ve onu uygulamada zaman zaman göreceksiniz
Mastodon kar amacı gütmeyen bir kuruluştur ve geliştirilmesi doğrudan bağışlarınızla sağlanmaktadır. Reklam yok, para kazanma güdüsü yok, risk sermayesi yok ve bu şekilde devam etmeyi planlıyoruz.
Mastodon kâr amacı gütmeyen bir kuruluştur ve geliştirilmesi doğrudan bağışlarınızla sağlanmaktadır. Reklam yok, para kazanma güdüsü yok, risk sermayesi yok ve bu şekilde devam etmeyi planlıyoruz.

View File

@@ -1,8 +1,8 @@
Mastodon 是網際網路上最大的去中心化社群網路。 它是一個由能無縫互動的獨立社群中,數百萬使用者組成的網路,而非單一網站。 無論您對什麼事情感興趣,您都能 Mastodon 上遇到充滿熱情的人們討論該話題。
Mastodon 是網際網路上最大的去中心化社群網路。 它是一個由能無縫互動的獨立社群中,數百萬使用者組成的網路,而非單一網站。 無論您對什麼事情感興趣,您都能 Mastodon 上遇到充滿熱情的人們討論該話題。
加入社群並建立您的個人檔案。 尋找並跟隨迷人的朋友們,並無廣告、按時間順序排列的時間軸上閱讀他們的嘟文。 500 個字元的嘟文中使用自訂表情符號、GIF、視訊與音訊表達您自己。 回覆任何人的話題與轉發貼文以分享精彩內容。 尋找要跟隨的新帳號與熱門主題標籤拓展您的網路。
加入社群並建立您的個人檔案。 尋找並跟隨迷人的朋友們,並無廣告、按時間順序排列的時間軸上閱讀他們的嘟文。 500 個字元的嘟文中使用自訂表情符號、GIF、視訊與音訊表達您自己。 回覆任何人的話題與轉發貼文以分享精彩內容。 尋找要跟隨的新帳號與熱門主題標籤拓展您的網路。
Mastodon 以隱私與安全為要。 決定您的嘟文要與您的跟隨者分享、只與您提及的人們分享,又或是與全世界分享。 內容警告可讓您隱藏包含敏感或可能觸發強烈情緒反應的嘟文,直到您準備好與它們進行互動。 每個社群都有它們自己的指導方針與管理原來確保其成員安全,強大的封鎖與回報工具有助於防止濫用。
Mastodon 以隱私與安全為要。 決定您的嘟文要與您的跟隨者分享、只與您提及的人們分享,又或是與全世界分享。 內容警告可讓您隱藏包含敏感或可能觸發強烈情緒反應的嘟文,直到您準備好與它們進行互動。 每個社群都有它們自己的指導方針與管理員以確保其成員安全,強大的封鎖與回報工具有助於防止濫用。
更多功能:
@@ -10,7 +10,7 @@ Mastodon 以隱私與安全為要。 決定您的嘟文要與您的跟隨者分
• 投票:詢問跟隨者們的意見並計票
• 探索:僅需輕點一下,即可看到熱門主題標籤與帳號
• 通知:取得關於新跟隨者們、回覆與轉發的通知
• 分享:任何應用程式中的分享表中直接發表嘟文到 Mastodon 中
• 分享:任何應用程式中的分享表中直接發表嘟文到 Mastodon 中
• 可愛:我們的吉祥物是一隻可愛的大象,您會不時看到牠出現
Mastodon 是一家註冊的非營利組織,您的捐款會直接支援開發工作。 沒有廣告、沒有貨幣化、沒有風險投資,我們計畫維持這種狀態。 沒有廣告、沒有貨幣化、沒有風險投資,我們計畫維持這種狀態。

View File

@@ -1,6 +1,6 @@
#Sat Jun 03 23:40:27 MSK 2023
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View File

@@ -9,8 +9,8 @@ android {
applicationId "org.joinmastodon.android"
minSdk 23
targetSdk 33
versionCode 84
versionName "2.3.0"
versionCode 89
versionName "2.4.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
resConfigs "ar-rSA", "be-rBY", "bn-rBD", "bs-rBA", "ca-rES", "cs-rCZ", "da-rDK", "de-rDE", "el-rGR", "es-rES", "eu-rES", "fa-rIR", "fi-rFI", "fil-rPH", "fr-rFR", "ga-rIE", "gd-rGB", "gl-rES", "hi-rIN", "hr-rHR", "hu-rHU", "hy-rAM", "ig-rNG", "in-rID", "is-rIS", "it-rIT", "iw-rIL", "ja-rJP", "ka-rGE", "kab", "ko-rKR", "lt-rLT", "my-rMM", "nl-rNL", "no-rNO", "oc-rFR", "pl-rPL", "pt-rBR", "pt-rPT", "ro-rRO", "ru-rRU", "si-rLK", "sl-rSI", "sv-rSE", "th-rTH", "tr-rTR", "uk-rUA", "ur-rIN", "vi-rVN", "zh-rCN", "zh-rTW"
}
@@ -64,6 +64,17 @@ android {
checkReleaseBuilds false
abortOnError false
}
buildFeatures{
aidl true
buildConfig true
}
dependenciesInfo{
// Disables dependency metadata when building APKs.
includeInApk false
// Disables dependency metadata when building Android App Bundles.
includeInBundle false
}
namespace 'org.joinmastodon.android'
}
dependencies {
@@ -81,6 +92,8 @@ dependencies {
implementation 'org.jsoup:jsoup:1.14.3'
implementation 'com.squareup:otto:1.3.8'
implementation 'de.psdev:async-otto:1.0.3'
implementation 'com.google.zxing:core:3.5.3'
implementation 'org.microg:safe-parcel:1.5.0'
implementation 'org.parceler:parceler-api:1.1.12'
annotationProcessor 'org.parceler:parceler:1.1.12'
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.3'

View File

@@ -0,0 +1,20 @@
// Included into build.gradle when running in a CI pipeline
android{
signingConfigs{
release{
keyAlias "key0"
keyPassword System.getenv("KEYSTORE_PASSWORD")
storeFile file(System.getenv("KEYSTORE_FILE"))
storePassword System.getenv("KEYSTORE_PASSWORD")
}
}
buildTypes{
release{
signingConfig signingConfigs.release
}
githubRelease{
signingConfig signingConfigs.release
}
}
}

View File

@@ -22,7 +22,7 @@
# Keep all model classes as they're used with gson and their names are shown in errors
-keep public class org.joinmastodon.android.model.**{
<fields>;
*;
}
# Inner classes in api requests are used with gson
@@ -50,4 +50,8 @@
-keep class org.joinmastodon.android.AppCenterWrapper { *; }
-keepattributes LineNumberTable
-keepattributes LineNumberTable
-keepattributes Signature
-keep class com.google.gson.reflect.TypeToken { *; }
-keep class * extends com.google.gson.reflect.TypeToken
-keep public class * implements java.lang.reflect.Type

View File

@@ -4,6 +4,7 @@
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="28"/>
<uses-permission android:name="${applicationId}.permission.C2D_MESSAGE"/>
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>
@@ -19,6 +20,10 @@
<intent>
<action android:name="android.intent.action.TRANSLATE" />
</intent>
<intent>
<action android:name="android.intent.action.VIEW"/>
<data android:scheme="http"/>
</intent>
</queries>
<application
@@ -31,6 +36,10 @@
android:theme="@style/Theme.Mastodon.AutoLightDark"
android:largeHeap="true">
<meta-data
android:name="com.google.mlkit.vision.DEPENDENCIES"
android:value="barcode_ui"/>
<activity android:name=".MainActivity" android:exported="true" android:configChanges="orientation|screenSize" android:windowSoftInputMode="adjustResize" android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
@@ -84,6 +93,14 @@
</intent-filter>
</receiver>
<provider
android:authorities="${applicationId}.fileprovider"
android:name=".TweakedFileProvider"
android:grantUriPermissions="true"
android:exported="false">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/fileprovider_paths"/>
</provider>
</application>
</manifest>

View File

@@ -0,0 +1,3 @@
package com.google.android.gms.common.api;
parcelable Status;

View File

@@ -0,0 +1,7 @@
package com.google.android.gms.common.api.internal;
import com.google.android.gms.common.api.Status;
interface IStatusCallback {
void onResult(in Status status);
}

View File

@@ -0,0 +1,7 @@
/*
* SPDX-FileCopyrightText: 2020, microG Project Team
* SPDX-License-Identifier: Apache-2.0
*/
package com.google.android.gms.common.internal;
parcelable ConnectionInfo;

View File

@@ -0,0 +1,3 @@
package com.google.android.gms.common.internal;
parcelable GetServiceRequest;

View File

@@ -0,0 +1,15 @@
/*
* SPDX-FileCopyrightText: 2020, microG Project Team
* SPDX-License-Identifier: Apache-2.0
*/
package com.google.android.gms.common.internal;
import android.os.Bundle;
import com.google.android.gms.common.internal.ConnectionInfo;
interface IGmsCallbacks {
void onPostInitComplete(int statusCode, IBinder binder, in Bundle params);
void onAccountValidationComplete(int statusCode, in Bundle params);
void onPostInitCompleteWithConnectionInfo(int statusCode, IBinder binder, in ConnectionInfo info);
}

View File

@@ -0,0 +1,10 @@
package com.google.android.gms.common.internal;
import android.os.Bundle;
import com.google.android.gms.common.internal.IGmsCallbacks;
import com.google.android.gms.common.internal.GetServiceRequest;
interface IGmsServiceBroker {
void getService(IGmsCallbacks callback, in GetServiceRequest request) = 45;
}

View File

@@ -0,0 +1,3 @@
package com.google.android.gms.common.moduleinstall;
parcelable ModuleAvailabilityResponse;

View File

@@ -0,0 +1,3 @@
package com.google.android.gms.common.moduleinstall;
parcelable ModuleInstallIntentResponse;

View File

@@ -0,0 +1,3 @@
package com.google.android.gms.common.moduleinstall;
parcelable ModuleInstallResponse;

View File

@@ -0,0 +1,3 @@
package com.google.android.gms.common.moduleinstall;
parcelable ModuleInstallStatusUpdate;

View File

@@ -0,0 +1,3 @@
package com.google.android.gms.common.moduleinstall.internal;
parcelable ApiFeatureRequest;

View File

@@ -0,0 +1,13 @@
package com.google.android.gms.common.moduleinstall.internal;
import com.google.android.gms.common.api.Status;
import com.google.android.gms.common.moduleinstall.ModuleAvailabilityResponse;
import com.google.android.gms.common.moduleinstall.ModuleInstallIntentResponse;
import com.google.android.gms.common.moduleinstall.ModuleInstallResponse;
interface IModuleInstallCallbacks {
void onModuleAvailabilityResponse(in Status status, in ModuleAvailabilityResponse response) = 0;
void onModuleInstallResponse(in Status status, in ModuleInstallResponse response) = 1;
void onModuleInstallIntentResponse(in Status status, in ModuleInstallIntentResponse response) = 2;
void onStatus(in Status status) = 3;
}

View File

@@ -0,0 +1,14 @@
package com.google.android.gms.common.moduleinstall.internal;
import com.google.android.gms.common.api.internal.IStatusCallback;
import com.google.android.gms.common.moduleinstall.internal.ApiFeatureRequest;
import com.google.android.gms.common.moduleinstall.internal.IModuleInstallCallbacks;
import com.google.android.gms.common.moduleinstall.internal.IModuleInstallStatusListener;
interface IModuleInstallService {
void areModulesAvailable(IModuleInstallCallbacks callbacks, in ApiFeatureRequest request) = 0;
void installModules(IModuleInstallCallbacks callbacks, in ApiFeatureRequest request, IModuleInstallStatusListener listener) = 1;
void getInstallModulesIntent(IModuleInstallCallbacks callbacks, in ApiFeatureRequest request) = 2;
void releaseModules(IStatusCallback callback, in ApiFeatureRequest request) = 3;
void unregisterListener(IStatusCallback callback, IModuleInstallStatusListener listener) = 5;
}

View File

@@ -0,0 +1,7 @@
package com.google.android.gms.common.moduleinstall.internal;
import com.google.android.gms.common.moduleinstall.ModuleInstallStatusUpdate;
interface IModuleInstallStatusListener {
void onModuleInstallStatusUpdate(in ModuleInstallStatusUpdate statusUpdate) = 0;
}

View File

@@ -0,0 +1,15 @@
package com.google.android.gms.common;
import org.microg.safeparcel.AutoSafeParcelable;
import org.microg.safeparcel.SafeParceled;
public class Feature extends AutoSafeParcelable{
@SafeParceled(1)
public String name;
@SafeParceled(2)
public int oldVersion;
@SafeParceled(3)
public long version=-1;
public static final Creator<Feature> CREATOR=new AutoCreator<>(Feature.class);
}

View File

@@ -0,0 +1,13 @@
package com.google.android.gms.common.api;
import org.microg.safeparcel.AutoSafeParcelable;
import org.microg.safeparcel.SafeParceled;
public class Scope extends AutoSafeParcelable{
@SafeParceled(1)
public int versionCode=1;
@SafeParceled(2)
public String scopeUri;
public static final Creator<Scope> CREATOR=new AutoCreator<>(Scope.class);
}

View File

@@ -0,0 +1,33 @@
package com.google.android.gms.common.api;
import android.app.PendingIntent;
import org.joinmastodon.android.googleservices.ConnectionResult;
import org.microg.safeparcel.AutoSafeParcelable;
import org.microg.safeparcel.SafeParceled;
public class Status extends AutoSafeParcelable{
@SafeParceled(1000)
public int versionCode;
@SafeParceled(1)
public int statusCode;
@SafeParceled(2)
public String statusMessage;
@SafeParceled(3)
public PendingIntent pendingIntent;
@SafeParceled(4)
public ConnectionResult connectionResult;
public static final Creator<Status> CREATOR=new AutoCreator<>(Status.class);
@Override
public String toString(){
return "Status{"+
"versionCode="+versionCode+
", statusCode="+statusCode+
", statusMessage='"+statusMessage+'\''+
", pendingIntent="+pendingIntent+
", connectionResult="+connectionResult+
'}';
}
}

View File

@@ -0,0 +1,19 @@
package com.google.android.gms.common.internal;
import android.os.Bundle;
import com.google.android.gms.common.Feature;
import org.microg.safeparcel.AutoSafeParcelable;
import org.microg.safeparcel.SafeParceled;
public class ConnectionInfo extends AutoSafeParcelable{
@SafeParceled(1)
public Bundle params;
@SafeParceled(2)
public Feature[] features;
@SafeParceled(3)
public int unknown3;
public static final Creator<ConnectionInfo> CREATOR=new AutoCreator<>(ConnectionInfo.class);
}

View File

@@ -0,0 +1,47 @@
package com.google.android.gms.common.internal;
import android.os.Bundle;
import android.os.IBinder;
import android.accounts.Account;
import com.google.android.gms.common.Feature;
import com.google.android.gms.common.api.Scope;
import org.microg.safeparcel.AutoSafeParcelable;
import org.microg.safeparcel.SafeParceled;
public class GetServiceRequest extends AutoSafeParcelable{
@SafeParceled(1)
int versionCode=6;
@SafeParceled(2)
public int serviceId;
@SafeParceled(3)
public int gmsVersion;
@SafeParceled(4)
public String packageName;
@SafeParceled(5)
public IBinder accountAccessor;
@SafeParceled(6)
public Scope[] scopes;
@SafeParceled(7)
public Bundle extras;
@SafeParceled(8)
public Account account;
@SafeParceled(9)
@Deprecated
long field9;
@SafeParceled(10)
public Feature[] defaultFeatures;
@SafeParceled(11)
public Feature[] apiFeatures;
@SafeParceled(12)
boolean supportsConnectionInfo;
@SafeParceled(13)
int field13;
@SafeParceled(14)
boolean field14;
@SafeParceled(15)
String attributionTag;
public static final Creator<GetServiceRequest> CREATOR=new AutoCreator<>(GetServiceRequest.class);
}

View File

@@ -0,0 +1,13 @@
package com.google.android.gms.common.moduleinstall;
import org.microg.safeparcel.AutoSafeParcelable;
import org.microg.safeparcel.SafeParceled;
public class ModuleAvailabilityResponse extends AutoSafeParcelable{
@SafeParceled(1)
public boolean modulesAvailable;
@SafeParceled(2)
public int availabilityStatus;
public static final Creator<ModuleAvailabilityResponse> CREATOR=new AutoCreator<>(ModuleAvailabilityResponse.class);
}

View File

@@ -0,0 +1,13 @@
package com.google.android.gms.common.moduleinstall;
import android.app.PendingIntent;
import org.microg.safeparcel.AutoSafeParcelable;
import org.microg.safeparcel.SafeParceled;
public class ModuleInstallIntentResponse extends AutoSafeParcelable{
@SafeParceled(1)
public PendingIntent pendingIntent;
public static final Creator<ModuleInstallIntentResponse> CREATOR=new AutoCreator<>(ModuleInstallIntentResponse.class);
}

View File

@@ -0,0 +1,21 @@
package com.google.android.gms.common.moduleinstall;
import org.microg.safeparcel.AutoSafeParcelable;
import org.microg.safeparcel.SafeParceled;
public class ModuleInstallResponse extends AutoSafeParcelable{
@SafeParceled(1)
public int sessionID;
@SafeParceled(2)
public boolean shouldUnregisterListener;
public static final Creator<ModuleInstallResponse> CREATOR=new AutoCreator<>(ModuleInstallResponse.class);
@Override
public String toString(){
return "ModuleInstallResponse{"+
"sessionID="+sessionID+
", shouldUnregisterListener="+shouldUnregisterListener+
'}';
}
}

View File

@@ -0,0 +1,63 @@
package com.google.android.gms.common.moduleinstall;
import org.microg.safeparcel.AutoSafeParcelable;
import org.microg.safeparcel.SafeParceled;
public class ModuleInstallStatusUpdate extends AutoSafeParcelable{
public static final int STATE_UNKNOWN = 0;
/**
* The request is pending and will be processed soon.
*/
public static final int STATE_PENDING = 1;
/**
* The optional module download is in progress.
*/
public static final int STATE_DOWNLOADING = 2;
/**
* The optional module download has been canceled.
*/
public static final int STATE_CANCELED = 3;
/**
* Installation is completed; the optional modules are available to the client app.
*/
public static final int STATE_COMPLETED = 4;
/**
* The optional module download or installation has failed.
*/
public static final int STATE_FAILED = 5;
/**
* The optional modules have been downloaded and the installation is in progress.
*/
public static final int STATE_INSTALLING = 6;
/**
* The optional module download has been paused.
* <p>
* This usually happens when connectivity requirements can't be met during download. Once the connectivity requirements
* are met, the download will be resumed automatically.
*/
public static final int STATE_DOWNLOAD_PAUSED = 7;
@SafeParceled(1)
public int sessionID;
@SafeParceled(2)
public int installState;
@SafeParceled(3)
public Long bytesDownloaded;
@SafeParceled(4)
public Long totalBytesToDownload;
@SafeParceled(5)
public int errorCode;
@Override
public String toString(){
return "ModuleInstallStatusUpdate{"+
"sessionID="+sessionID+
", installState="+installState+
", bytesDownloaded="+bytesDownloaded+
", totalBytesToDownload="+totalBytesToDownload+
", errorCode="+errorCode+
'}';
}
public static final Creator<ModuleInstallStatusUpdate> CREATOR=new AutoCreator<>(ModuleInstallStatusUpdate.class);
}

View File

@@ -0,0 +1,21 @@
package com.google.android.gms.common.moduleinstall.internal;
import com.google.android.gms.common.Feature;
import org.microg.safeparcel.AutoSafeParcelable;
import org.microg.safeparcel.SafeParceled;
import java.util.List;
public class ApiFeatureRequest extends AutoSafeParcelable{
@SafeParceled(value=1, subClass=Feature.class)
public List<Feature> features;
@SafeParceled(2)
public boolean urgent;
@SafeParceled(3)
public String sessionId;
@SafeParceled(4)
public String callingPackage;
public static final Creator<ApiFeatureRequest> CREATOR=new AutoCreator<>(ApiFeatureRequest.class);
}

View File

@@ -0,0 +1,841 @@
/*
* Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.joinmastodon.android;
import static org.xmlpull.v1.XmlPullParser.END_DOCUMENT;
import static org.xmlpull.v1.XmlPullParser.START_TAG;
import android.content.ClipData;
import android.content.ContentProvider;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ProviderInfo;
import android.content.res.XmlResourceParser;
import android.database.Cursor;
import android.database.MatrixCursor;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.ParcelFileDescriptor;
import android.provider.OpenableColumns;
import android.text.TextUtils;
import android.webkit.MimeTypeMap;
import androidx.annotation.GuardedBy;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import org.xmlpull.v1.XmlPullParserException;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
/**
* FileProvider is a special subclass of {@link ContentProvider} that facilitates secure sharing
* of files associated with an app by creating a <code>content://</code> {@link Uri} for a file
* instead of a <code>file:///</code> {@link Uri}.
* <p>
* A content URI allows you to grant read and write access using
* temporary access permissions. When you create an {@link Intent} containing
* a content URI, in order to send the content URI
* to a client app, you can also call {@link Intent#setFlags(int) Intent.setFlags()} to add
* permissions. These permissions are available to the client app for as long as the stack for
* a receiving {@link android.app.Activity} is active. For an {@link Intent} going to a
* {@link android.app.Service}, the permissions are available as long as the
* {@link android.app.Service} is running.
* <p>
* In comparison, to control access to a <code>file:///</code> {@link Uri} you have to modify the
* file system permissions of the underlying file. The permissions you provide become available to
* <em>any</em> app, and remain in effect until you change them. This level of access is
* fundamentally insecure.
* <p>
* The increased level of file access security offered by a content URI
* makes FileProvider a key part of Android's security infrastructure.
* <p>
* This overview of FileProvider includes the following topics:
* </p>
* <ol>
* <li><a href="#ProviderDefinition">Defining a FileProvider</a></li>
* <li><a href="#SpecifyFiles">Specifying Available Files</a></li>
* <li><a href="#GetUri">Retrieving the Content URI for a File</li>
* <li><a href="#Permissions">Granting Temporary Permissions to a URI</a></li>
* <li><a href="#ServeUri">Serving a Content URI to Another App</a></li>
* </ol>
* <h3 id="ProviderDefinition">Defining a FileProvider</h3>
* <p>
* Since the default functionality of FileProvider includes content URI generation for files, you
* don't need to define a subclass in code. Instead, you can include a FileProvider in your app
* by specifying it entirely in XML. To specify the FileProvider component itself, add a
* <code><a href="{@docRoot}guide/topics/manifest/provider-element.html">&lt;provider&gt;</a></code>
* element to your app manifest. Set the <code>android:name</code> attribute to
* <code>androidx.core.content.FileProvider</code>. Set the <code>android:authorities</code>
* attribute to a URI authority based on a domain you control; for example, if you control the
* domain <code>mydomain.com</code> you should use the authority
* <code>com.mydomain.fileprovider</code>. Set the <code>android:exported</code> attribute to
* <code>false</code>; the FileProvider does not need to be public. Set the
* <a href="{@docRoot}guide/topics/manifest/provider-element.html#gprmsn"
* >android:grantUriPermissions</a> attribute to <code>true</code>, to allow you
* to grant temporary access to files. For example:
* <pre class="prettyprint">
*&lt;manifest&gt;
* ...
* &lt;application&gt;
* ...
* &lt;provider
* android:name="androidx.core.content.FileProvider"
* android:authorities="com.mydomain.fileprovider"
* android:exported="false"
* android:grantUriPermissions="true"&gt;
* ...
* &lt;/provider&gt;
* ...
* &lt;/application&gt;
*&lt;/manifest&gt;</pre>
* <p>
* If you want to override any of the default behavior of FileProvider methods, extend
* the FileProvider class and use the fully-qualified class name in the <code>android:name</code>
* attribute of the <code>&lt;provider&gt;</code> element.
* <h3 id="SpecifyFiles">Specifying Available Files</h3>
* A FileProvider can only generate a content URI for files in directories that you specify
* beforehand. To specify a directory, specify the its storage area and path in XML, using child
* elements of the <code>&lt;paths&gt;</code> element.
* For example, the following <code>paths</code> element tells FileProvider that you intend to
* request content URIs for the <code>images/</code> subdirectory of your private file area.
* <pre class="prettyprint">
*&lt;paths xmlns:android="http://schemas.android.com/apk/res/android"&gt;
* &lt;files-path name="my_images" path="images/"/&gt;
* ...
*&lt;/paths&gt;
*</pre>
* <p>
* The <code>&lt;paths&gt;</code> element must contain one or more of the following child elements:
* </p>
* <dl>
* <dt>
* <pre class="prettyprint">
*&lt;files-path name="<i>name</i>" path="<i>path</i>" /&gt;
*</pre>
* </dt>
* <dd>
* Represents files in the <code>files/</code> subdirectory of your app's internal storage
* area. This subdirectory is the same as the value returned by {@link Context#getFilesDir()
* Context.getFilesDir()}.
* </dd>
* <dt>
* <pre>
*&lt;cache-path name="<i>name</i>" path="<i>path</i>" /&gt;
*</pre>
* <dt>
* <dd>
* Represents files in the cache subdirectory of your app's internal storage area. The root path
* of this subdirectory is the same as the value returned by {@link Context#getCacheDir()
* getCacheDir()}.
* </dd>
* <dt>
* <pre class="prettyprint">
*&lt;external-path name="<i>name</i>" path="<i>path</i>" /&gt;
*</pre>
* </dt>
* <dd>
* Represents files in the root of the external storage area. The root path of this subdirectory
* is the same as the value returned by
* {@link Environment#getExternalStorageDirectory() Environment.getExternalStorageDirectory()}.
* </dd>
* <dt>
* <pre class="prettyprint">
*&lt;external-files-path name="<i>name</i>" path="<i>path</i>" /&gt;
*</pre>
* </dt>
* <dd>
* Represents files in the root of your app's external storage area. The root path of this
* subdirectory is the same as the value returned by
* {@code Context#getExternalFilesDir(String) Context.getExternalFilesDir(null)}.
* </dd>
* <dt>
* <pre class="prettyprint">
*&lt;external-cache-path name="<i>name</i>" path="<i>path</i>" /&gt;
*</pre>
* </dt>
* <dd>
* Represents files in the root of your app's external cache area. The root path of this
* subdirectory is the same as the value returned by
* {@link Context#getExternalCacheDir() Context.getExternalCacheDir()}.
* </dd>
* <dt>
* <pre class="prettyprint">
*&lt;external-media-path name="<i>name</i>" path="<i>path</i>" /&gt;
*</pre>
* </dt>
* <dd>
* Represents files in the root of your app's external media area. The root path of this
* subdirectory is the same as the value returned by the first result of
* {@link Context#getExternalMediaDirs() Context.getExternalMediaDirs()}.
* <p><strong>Note:</strong> this directory is only available on API 21+ devices.</p>
* </dd>
* </dl>
* <p>
* These child elements all use the same attributes:
* </p>
* <dl>
* <dt>
* <code>name="<i>name</i>"</code>
* </dt>
* <dd>
* A URI path segment. To enforce security, this value hides the name of the subdirectory
* you're sharing. The subdirectory name for this value is contained in the
* <code>path</code> attribute.
* </dd>
* <dt>
* <code>path="<i>path</i>"</code>
* </dt>
* <dd>
* The subdirectory you're sharing. While the <code>name</code> attribute is a URI path
* segment, the <code>path</code> value is an actual subdirectory name. Notice that the
* value refers to a <b>subdirectory</b>, not an individual file or files. You can't
* share a single file by its file name, nor can you specify a subset of files using
* wildcards.
* </dd>
* </dl>
* <p>
* You must specify a child element of <code>&lt;paths&gt;</code> for each directory that contains
* files for which you want content URIs. For example, these XML elements specify two directories:
* <pre class="prettyprint">
*&lt;paths xmlns:android="http://schemas.android.com/apk/res/android"&gt;
* &lt;files-path name="my_images" path="images/"/&gt;
* &lt;files-path name="my_docs" path="docs/"/&gt;
*&lt;/paths&gt;
*</pre>
* <p>
* Put the <code>&lt;paths&gt;</code> element and its children in an XML file in your project.
* For example, you can add them to a new file called <code>res/xml/file_paths.xml</code>.
* To link this file to the FileProvider, add a
* <a href="{@docRoot}guide/topics/manifest/meta-data-element.html">&lt;meta-data&gt;</a> element
* as a child of the <code>&lt;provider&gt;</code> element that defines the FileProvider. Set the
* <code>&lt;meta-data&gt;</code> element's "android:name" attribute to
* <code>android.support.FILE_PROVIDER_PATHS</code>. Set the element's "android:resource" attribute
* to <code>&#64;xml/file_paths</code> (notice that you don't specify the <code>.xml</code>
* extension). For example:
* <pre class="prettyprint">
*&lt;provider
* android:name="androidx.core.content.FileProvider"
* android:authorities="com.mydomain.fileprovider"
* android:exported="false"
* android:grantUriPermissions="true"&gt;
* &lt;meta-data
* android:name="android.support.FILE_PROVIDER_PATHS"
* android:resource="&#64;xml/file_paths" /&gt;
*&lt;/provider&gt;
*</pre>
* <h3 id="GetUri">Generating the Content URI for a File</h3>
* <p>
* To share a file with another app using a content URI, your app has to generate the content URI.
* To generate the content URI, create a new {@link File} for the file, then pass the {@link File}
* to {@link #getUriForFile(Context, String, File) getUriForFile()}. You can send the content URI
* returned by {@link #getUriForFile(Context, String, File) getUriForFile()} to another app in an
* {@link Intent}. The client app that receives the content URI can open the file
* and access its contents by calling
* {@link android.content.ContentResolver#openFileDescriptor(Uri, String)
* ContentResolver.openFileDescriptor} to get a {@link ParcelFileDescriptor}.
* <p>
* For example, suppose your app is offering files to other apps with a FileProvider that has the
* authority <code>com.mydomain.fileprovider</code>. To get a content URI for the file
* <code>default_image.jpg</code> in the <code>images/</code> subdirectory of your internal storage
* add the following code:
* <pre class="prettyprint">
*File imagePath = new File(Context.getFilesDir(), "images");
*File newFile = new File(imagePath, "default_image.jpg");
*Uri contentUri = getUriForFile(getContext(), "com.mydomain.fileprovider", newFile);
*</pre>
* As a result of the previous snippet,
* {@link #getUriForFile(Context, String, File) getUriForFile()} returns the content URI
* <code>content://com.mydomain.fileprovider/my_images/default_image.jpg</code>.
* <h3 id="Permissions">Granting Temporary Permissions to a URI</h3>
* To grant an access permission to a content URI returned from
* {@link #getUriForFile(Context, String, File) getUriForFile()}, do one of the following:
* <ul>
* <li>
* Call the method
* {@link Context#grantUriPermission(String, Uri, int)
* Context.grantUriPermission(package, Uri, mode_flags)} for the <code>content://</code>
* {@link Uri}, using the desired mode flags. This grants temporary access permission for the
* content URI to the specified package, according to the value of the
* the <code>mode_flags</code> parameter, which you can set to
* {@link Intent#FLAG_GRANT_READ_URI_PERMISSION}, {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION}
* or both. The permission remains in effect until you revoke it by calling
* {@link Context#revokeUriPermission(Uri, int) revokeUriPermission()} or until the device
* reboots.
* </li>
* <li>
* Put the content URI in an {@link Intent} by calling {@link Intent#setData(Uri) setData()}.
* </li>
* <li>
* Next, call the method {@link Intent#setFlags(int) Intent.setFlags()} with either
* {@link Intent#FLAG_GRANT_READ_URI_PERMISSION} or
* {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION} or both.
* </li>
* <li>
* Finally, send the {@link Intent} to
* another app. Most often, you do this by calling
* {@link android.app.Activity#setResult(int, Intent) setResult()}.
* <p>
* Permissions granted in an {@link Intent} remain in effect while the stack of the receiving
* {@link android.app.Activity} is active. When the stack finishes, the permissions are
* automatically removed. Permissions granted to one {@link android.app.Activity} in a client
* app are automatically extended to other components of that app.
* </p>
* </li>
* </ul>
* <h3 id="ServeUri">Serving a Content URI to Another App</h3>
* <p>
* There are a variety of ways to serve the content URI for a file to a client app. One common way
* is for the client app to start your app by calling
* {@link android.app.Activity#startActivityForResult(Intent, int, Bundle) startActivityResult()},
* which sends an {@link Intent} to your app to start an {@link android.app.Activity} in your app.
* In response, your app can immediately return a content URI to the client app or present a user
* interface that allows the user to pick a file. In the latter case, once the user picks the file
* your app can return its content URI. In both cases, your app returns the content URI in an
* {@link Intent} sent via {@link android.app.Activity#setResult(int, Intent) setResult()}.
* </p>
* <p>
* You can also put the content URI in a {@link android.content.ClipData} object and then add the
* object to an {@link Intent} you send to a client app. To do this, call
* {@link Intent#setClipData(ClipData) Intent.setClipData()}. When you use this approach, you can
* add multiple {@link android.content.ClipData} objects to the {@link Intent}, each with its own
* content URI. When you call {@link Intent#setFlags(int) Intent.setFlags()} on the {@link Intent}
* to set temporary access permissions, the same permissions are applied to all of the content
* URIs.
* </p>
* <p class="note">
* <strong>Note:</strong> The {@link Intent#setClipData(ClipData) Intent.setClipData()} method is
* only available in platform version 16 (Android 4.1) and later. If you want to maintain
* compatibility with previous versions, you should send one content URI at a time in the
* {@link Intent}. Set the action to {@link Intent#ACTION_SEND} and put the URI in data by calling
* {@link Intent#setData setData()}.
* </p>
* <h3 id="">More Information</h3>
* <p>
* To learn more about FileProvider, see the Android training class
* <a href="{@docRoot}training/secure-file-sharing/index.html">Sharing Files Securely with URIs</a>.
* </p>
*/
public class FileProvider extends ContentProvider {
private static final String[] COLUMNS = {
OpenableColumns.DISPLAY_NAME, OpenableColumns.SIZE };
private static final String
META_DATA_FILE_PROVIDER_PATHS = "android.support.FILE_PROVIDER_PATHS";
private static final String TAG_ROOT_PATH = "root-path";
private static final String TAG_FILES_PATH = "files-path";
private static final String TAG_CACHE_PATH = "cache-path";
private static final String TAG_EXTERNAL = "external-path";
private static final String TAG_EXTERNAL_FILES = "external-files-path";
private static final String TAG_EXTERNAL_CACHE = "external-cache-path";
private static final String TAG_EXTERNAL_MEDIA = "external-media-path";
private static final String ATTR_NAME = "name";
private static final String ATTR_PATH = "path";
private static final File DEVICE_ROOT = new File("/");
@GuardedBy("sCache")
private static HashMap<String, PathStrategy> sCache = new HashMap<String, PathStrategy>();
private PathStrategy mStrategy;
/**
* The default FileProvider implementation does not need to be initialized. If you want to
* override this method, you must provide your own subclass of FileProvider.
*/
@Override
public boolean onCreate() {
return true;
}
/**
* After the FileProvider is instantiated, this method is called to provide the system with
* information about the provider.
*
* @param context A {@link Context} for the current component.
* @param info A {@link ProviderInfo} for the new provider.
*/
@Override
public void attachInfo(@NonNull Context context, @NonNull ProviderInfo info) {
super.attachInfo(context, info);
// Sanity check our security
if (info.exported) {
throw new SecurityException("Provider must not be exported");
}
if (!info.grantUriPermissions) {
throw new SecurityException("Provider must grant uri permissions");
}
mStrategy = getPathStrategy(context, info.authority);
}
/**
* Return a content URI for a given {@link File}. Specific temporary
* permissions for the content URI can be set with
* {@link Context#grantUriPermission(String, Uri, int)}, or added
* to an {@link Intent} by calling {@link Intent#setData(Uri) setData()} and then
* {@link Intent#setFlags(int) setFlags()}; in both cases, the applicable flags are
* {@link Intent#FLAG_GRANT_READ_URI_PERMISSION} and
* {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION}. A FileProvider can only return a
* <code>content</code> {@link Uri} for file paths defined in their <code>&lt;paths&gt;</code>
* meta-data element. See the Class Overview for more information.
*
* @param context A {@link Context} for the current component.
* @param authority The authority of a {@link FileProvider} defined in a
* {@code <provider>} element in your app's manifest.
* @param file A {@link File} pointing to the filename for which you want a
* <code>content</code> {@link Uri}.
* @return A content URI for the file.
* @throws IllegalArgumentException When the given {@link File} is outside
* the paths supported by the provider.
*/
public static Uri getUriForFile(@NonNull Context context, @NonNull String authority,
@NonNull File file) {
final PathStrategy strategy = getPathStrategy(context, authority);
return strategy.getUriForFile(file);
}
/**
* Use a content URI returned by
* {@link #getUriForFile(Context, String, File) getUriForFile()} to get information about a file
* managed by the FileProvider.
* FileProvider reports the column names defined in {@link OpenableColumns}:
* <ul>
* <li>{@link OpenableColumns#DISPLAY_NAME}</li>
* <li>{@link OpenableColumns#SIZE}</li>
* </ul>
* For more information, see
* {@link ContentProvider#query(Uri, String[], String, String[], String)
* ContentProvider.query()}.
*
* @param uri A content URI returned by {@link #getUriForFile}.
* @param projection The list of columns to put into the {@link Cursor}. If null all columns are
* included.
* @param selection Selection criteria to apply. If null then all data that matches the content
* URI is returned.
* @param selectionArgs An array of {@link String}, containing arguments to bind to
* the <i>selection</i> parameter. The <i>query</i> method scans <i>selection</i> from left to
* right and iterates through <i>selectionArgs</i>, replacing the current "?" character in
* <i>selection</i> with the value at the current position in <i>selectionArgs</i>. The
* values are bound to <i>selection</i> as {@link String} values.
* @param sortOrder A {@link String} containing the column name(s) on which to sort
* the resulting {@link Cursor}.
* @return A {@link Cursor} containing the results of the query.
*
*/
@Override
public Cursor query(@NonNull Uri uri, @Nullable String[] projection, @Nullable String selection,
@Nullable String[] selectionArgs,
@Nullable String sortOrder) {
// ContentProvider has already checked granted permissions
final File file = mStrategy.getFileForUri(uri);
if (projection == null) {
projection = COLUMNS;
}
String[] cols = new String[projection.length];
Object[] values = new Object[projection.length];
int i = 0;
for (String col : projection) {
if (OpenableColumns.DISPLAY_NAME.equals(col)) {
cols[i] = OpenableColumns.DISPLAY_NAME;
values[i++] = file.getName();
} else if (OpenableColumns.SIZE.equals(col)) {
cols[i] = OpenableColumns.SIZE;
values[i++] = file.length();
}
}
cols = copyOf(cols, i);
values = copyOf(values, i);
final MatrixCursor cursor = new MatrixCursor(cols, 1);
cursor.addRow(values);
return cursor;
}
/**
* Returns the MIME type of a content URI returned by
* {@link #getUriForFile(Context, String, File) getUriForFile()}.
*
* @param uri A content URI returned by
* {@link #getUriForFile(Context, String, File) getUriForFile()}.
* @return If the associated file has an extension, the MIME type associated with that
* extension; otherwise <code>application/octet-stream</code>.
*/
@Override
public String getType(@NonNull Uri uri) {
// ContentProvider has already checked granted permissions
final File file = mStrategy.getFileForUri(uri);
final int lastDot = file.getName().lastIndexOf('.');
if (lastDot >= 0) {
final String extension = file.getName().substring(lastDot + 1);
final String mime = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension);
if (mime != null) {
return mime;
}
}
return "application/octet-stream";
}
/**
* By default, this method throws an {@link UnsupportedOperationException}. You must
* subclass FileProvider if you want to provide different functionality.
*/
@Override
public Uri insert(@NonNull Uri uri, ContentValues values) {
throw new UnsupportedOperationException("No external inserts");
}
/**
* By default, this method throws an {@link UnsupportedOperationException}. You must
* subclass FileProvider if you want to provide different functionality.
*/
@Override
public int update(@NonNull Uri uri, ContentValues values, @Nullable String selection,
@Nullable String[] selectionArgs) {
throw new UnsupportedOperationException("No external updates");
}
/**
* Deletes the file associated with the specified content URI, as
* returned by {@link #getUriForFile(Context, String, File) getUriForFile()}. Notice that this
* method does <b>not</b> throw an {@link IOException}; you must check its return value.
*
* @param uri A content URI for a file, as returned by
* {@link #getUriForFile(Context, String, File) getUriForFile()}.
* @param selection Ignored. Set to {@code null}.
* @param selectionArgs Ignored. Set to {@code null}.
* @return 1 if the delete succeeds; otherwise, 0.
*/
@Override
public int delete(@NonNull Uri uri, @Nullable String selection,
@Nullable String[] selectionArgs) {
// ContentProvider has already checked granted permissions
final File file = mStrategy.getFileForUri(uri);
return file.delete() ? 1 : 0;
}
/**
* By default, FileProvider automatically returns the
* {@link ParcelFileDescriptor} for a file associated with a <code>content://</code>
* {@link Uri}. To get the {@link ParcelFileDescriptor}, call
* {@link android.content.ContentResolver#openFileDescriptor(Uri, String)
* ContentResolver.openFileDescriptor}.
*
* To override this method, you must provide your own subclass of FileProvider.
*
* @param uri A content URI associated with a file, as returned by
* {@link #getUriForFile(Context, String, File) getUriForFile()}.
* @param mode Access mode for the file. May be "r" for read-only access, "rw" for read and
* write access, or "rwt" for read and write access that truncates any existing file.
* @return A new {@link ParcelFileDescriptor} with which you can access the file.
*/
@Override
public ParcelFileDescriptor openFile(@NonNull Uri uri, @NonNull String mode)
throws FileNotFoundException {
// ContentProvider has already checked granted permissions
final File file = mStrategy.getFileForUri(uri);
final int fileMode = modeToMode(mode);
return ParcelFileDescriptor.open(file, fileMode);
}
/**
* Return {@link PathStrategy} for given authority, either by parsing or
* returning from cache.
*/
private static PathStrategy getPathStrategy(Context context, String authority) {
PathStrategy strat;
synchronized (sCache) {
strat = sCache.get(authority);
if (strat == null) {
try {
strat = parsePathStrategy(context, authority);
} catch (IOException e) {
throw new IllegalArgumentException(
"Failed to parse " + META_DATA_FILE_PROVIDER_PATHS + " meta-data", e);
} catch (XmlPullParserException e) {
throw new IllegalArgumentException(
"Failed to parse " + META_DATA_FILE_PROVIDER_PATHS + " meta-data", e);
}
sCache.put(authority, strat);
}
}
return strat;
}
/**
* Parse and return {@link PathStrategy} for given authority as defined in
* {@link #META_DATA_FILE_PROVIDER_PATHS} {@code <meta-data>}.
*
* @see #getPathStrategy(Context, String)
*/
private static PathStrategy parsePathStrategy(Context context, String authority)
throws IOException, XmlPullParserException {
final SimplePathStrategy strat = new SimplePathStrategy(authority);
final ProviderInfo info = context.getPackageManager()
.resolveContentProvider(authority, PackageManager.GET_META_DATA);
if (info == null) {
throw new IllegalArgumentException(
"Couldn't find meta-data for provider with authority " + authority);
}
final XmlResourceParser in = info.loadXmlMetaData(
context.getPackageManager(), META_DATA_FILE_PROVIDER_PATHS);
if (in == null) {
throw new IllegalArgumentException(
"Missing " + META_DATA_FILE_PROVIDER_PATHS + " meta-data");
}
int type;
while ((type = in.next()) != END_DOCUMENT) {
if (type == START_TAG) {
final String tag = in.getName();
final String name = in.getAttributeValue(null, ATTR_NAME);
String path = in.getAttributeValue(null, ATTR_PATH);
File target = null;
if (TAG_ROOT_PATH.equals(tag)) {
target = DEVICE_ROOT;
} else if (TAG_FILES_PATH.equals(tag)) {
target = context.getFilesDir();
} else if (TAG_CACHE_PATH.equals(tag)) {
target = context.getCacheDir();
} else if (TAG_EXTERNAL.equals(tag)) {
target = Environment.getExternalStorageDirectory();
} else if (TAG_EXTERNAL_FILES.equals(tag)) {
File[] externalFilesDirs = context.getExternalFilesDirs(null);
if (externalFilesDirs.length > 0) {
target = externalFilesDirs[0];
}
} else if (TAG_EXTERNAL_CACHE.equals(tag)) {
File[] externalCacheDirs = context.getExternalCacheDirs();
if (externalCacheDirs.length > 0) {
target = externalCacheDirs[0];
}
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP
&& TAG_EXTERNAL_MEDIA.equals(tag)) {
File[] externalMediaDirs = context.getExternalMediaDirs();
if (externalMediaDirs.length > 0) {
target = externalMediaDirs[0];
}
}
if (target != null) {
strat.addRoot(name, buildPath(target, path));
}
}
}
return strat;
}
/**
* Strategy for mapping between {@link File} and {@link Uri}.
* <p>
* Strategies must be symmetric so that mapping a {@link File} to a
* {@link Uri} and then back to a {@link File} points at the original
* target.
* <p>
* Strategies must remain consistent across app launches, and not rely on
* dynamic state. This ensures that any generated {@link Uri} can still be
* resolved if your process is killed and later restarted.
*
* @see SimplePathStrategy
*/
interface PathStrategy {
/**
* Return a {@link Uri} that represents the given {@link File}.
*/
Uri getUriForFile(File file);
/**
* Return a {@link File} that represents the given {@link Uri}.
*/
File getFileForUri(Uri uri);
}
/**
* Strategy that provides access to files living under a narrow whitelist of
* filesystem roots. It will throw {@link SecurityException} if callers try
* accessing files outside the configured roots.
* <p>
* For example, if configured with
* {@code addRoot("myfiles", context.getFilesDir())}, then
* {@code context.getFileStreamPath("foo.txt")} would map to
* {@code content://myauthority/myfiles/foo.txt}.
*/
static class SimplePathStrategy implements PathStrategy {
private final String mAuthority;
private final HashMap<String, File> mRoots = new HashMap<String, File>();
SimplePathStrategy(String authority) {
mAuthority = authority;
}
/**
* Add a mapping from a name to a filesystem root. The provider only offers
* access to files that live under configured roots.
*/
void addRoot(String name, File root) {
if (TextUtils.isEmpty(name)) {
throw new IllegalArgumentException("Name must not be empty");
}
try {
// Resolve to canonical path to keep path checking fast
root = root.getCanonicalFile();
} catch (IOException e) {
throw new IllegalArgumentException(
"Failed to resolve canonical path for " + root, e);
}
mRoots.put(name, root);
}
@Override
public Uri getUriForFile(File file) {
String path;
try {
path = file.getCanonicalPath();
} catch (IOException e) {
throw new IllegalArgumentException("Failed to resolve canonical path for " + file);
}
// Find the most-specific root path
Map.Entry<String, File> mostSpecific = null;
for (Map.Entry<String, File> root : mRoots.entrySet()) {
final String rootPath = root.getValue().getPath();
if (path.startsWith(rootPath) && (mostSpecific == null
|| rootPath.length() > mostSpecific.getValue().getPath().length())) {
mostSpecific = root;
}
}
if (mostSpecific == null) {
throw new IllegalArgumentException(
"Failed to find configured root that contains " + path);
}
// Start at first char of path under root
final String rootPath = mostSpecific.getValue().getPath();
if (rootPath.endsWith("/")) {
path = path.substring(rootPath.length());
} else {
path = path.substring(rootPath.length() + 1);
}
// Encode the tag and path separately
path = Uri.encode(mostSpecific.getKey()) + '/' + Uri.encode(path, "/");
return new Uri.Builder().scheme("content")
.authority(mAuthority).encodedPath(path).build();
}
@Override
public File getFileForUri(Uri uri) {
String path = uri.getEncodedPath();
final int splitIndex = path.indexOf('/', 1);
final String tag = Uri.decode(path.substring(1, splitIndex));
path = Uri.decode(path.substring(splitIndex + 1));
final File root = mRoots.get(tag);
if (root == null) {
throw new IllegalArgumentException("Unable to find configured root for " + uri);
}
File file = new File(root, path);
try {
file = file.getCanonicalFile();
} catch (IOException e) {
throw new IllegalArgumentException("Failed to resolve canonical path for " + file);
}
if (!file.getPath().startsWith(root.getPath())) {
throw new SecurityException("Resolved path jumped beyond configured root");
}
return file;
}
}
/**
* Copied from ContentResolver.java
*/
private static int modeToMode(String mode) {
int modeBits;
if ("r".equals(mode)) {
modeBits = ParcelFileDescriptor.MODE_READ_ONLY;
} else if ("w".equals(mode) || "wt".equals(mode)) {
modeBits = ParcelFileDescriptor.MODE_WRITE_ONLY
| ParcelFileDescriptor.MODE_CREATE
| ParcelFileDescriptor.MODE_TRUNCATE;
} else if ("wa".equals(mode)) {
modeBits = ParcelFileDescriptor.MODE_WRITE_ONLY
| ParcelFileDescriptor.MODE_CREATE
| ParcelFileDescriptor.MODE_APPEND;
} else if ("rw".equals(mode)) {
modeBits = ParcelFileDescriptor.MODE_READ_WRITE
| ParcelFileDescriptor.MODE_CREATE;
} else if ("rwt".equals(mode)) {
modeBits = ParcelFileDescriptor.MODE_READ_WRITE
| ParcelFileDescriptor.MODE_CREATE
| ParcelFileDescriptor.MODE_TRUNCATE;
} else {
throw new IllegalArgumentException("Invalid mode: " + mode);
}
return modeBits;
}
private static File buildPath(File base, String... segments) {
File cur = base;
for (String segment : segments) {
if (segment != null) {
cur = new File(cur, segment);
}
}
return cur;
}
private static String[] copyOf(String[] original, int newLength) {
final String[] result = new String[newLength];
System.arraycopy(original, 0, result, 0, newLength);
return result;
}
private static Object[] copyOf(Object[] original, int newLength) {
final Object[] result = new Object[newLength];
System.arraycopy(original, 0, result, 0, newLength);
return result;
}
}

View File

@@ -0,0 +1,38 @@
package org.joinmastodon.android;
import android.database.Cursor;
import android.net.Uri;
import android.os.ParcelFileDescriptor;
import android.util.Log;
import java.io.FileNotFoundException;
import java.util.Arrays;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
public class TweakedFileProvider extends FileProvider{
private static final String TAG="TweakedFileProvider";
@Override
public String getType(@NonNull Uri uri){
Log.d(TAG, "getType() called with: uri = ["+uri+"]");
if(uri.getPathSegments().get(0).equals("image_cache")){
Log.i(TAG, "getType: HERE!");
return "image/jpeg"; // might as well be a png but image decoding APIs don't care, needs to be image/* though
}
return super.getType(uri);
}
@Override
public Cursor query(@NonNull Uri uri, @Nullable String[] projection, @Nullable String selection, @Nullable String[] selectionArgs, @Nullable String sortOrder){
Log.d(TAG, "query() called with: uri = ["+uri+"], projection = ["+Arrays.toString(projection)+"], selection = ["+selection+"], selectionArgs = ["+Arrays.toString(selectionArgs)+"], sortOrder = ["+sortOrder+"]");
return super.query(uri, projection, selection, selectionArgs, sortOrder);
}
@Override
public ParcelFileDescriptor openFile(@NonNull Uri uri, @NonNull String mode) throws FileNotFoundException{
Log.d(TAG, "openFile() called with: uri = ["+uri+"], mode = ["+mode+"]");
return super.openFile(uri, mode);
}
}

View File

@@ -1,5 +1,7 @@
package org.joinmastodon.android.api.requests.accounts;
import android.text.TextUtils;
import com.google.gson.reflect.TypeToken;
import org.joinmastodon.android.api.MastodonAPIRequest;
@@ -10,7 +12,7 @@ import java.util.List;
import androidx.annotation.NonNull;
public class GetAccountStatuses extends MastodonAPIRequest<List<Status>>{
public GetAccountStatuses(String id, String maxID, String minID, int limit, @NonNull Filter filter){
public GetAccountStatuses(String id, String maxID, String minID, int limit, @NonNull Filter filter, String hashtag){
super(HttpMethod.GET, "/accounts/"+id+"/statuses", new TypeToken<>(){});
if(maxID!=null)
addQueryParameter("max_id", maxID);
@@ -29,6 +31,8 @@ public class GetAccountStatuses extends MastodonAPIRequest<List<Status>>{
case OWN_POSTS_AND_REPLIES -> addQueryParameter("exclude_reblogs", "true");
case PINNED -> addQueryParameter("pinned", "true");
}
if(!TextUtils.isEmpty(hashtag))
addQueryParameter("tagged", hashtag);
}
public enum Filter{

View File

@@ -0,0 +1,11 @@
package org.joinmastodon.android.api.requests.statuses;
import org.joinmastodon.android.api.MastodonAPIRequest;
import org.joinmastodon.android.model.Status;
public class SetStatusPinned extends MastodonAPIRequest<Status>{
public SetStatusPinned(String id, boolean pinned){
super(HttpMethod.POST, "/statuses/"+id+"/"+(pinned ? "pin" : "unpin"), Status.class);
setRequestBody(new Object());
}
}

View File

@@ -10,7 +10,6 @@ import org.joinmastodon.android.R;
import org.joinmastodon.android.api.requests.accounts.GetAccountStatuses;
import org.joinmastodon.android.api.session.AccountSessionManager;
import org.joinmastodon.android.events.RemoveAccountPostsEvent;
import org.joinmastodon.android.events.StatusCreatedEvent;
import org.joinmastodon.android.model.Account;
import org.joinmastodon.android.model.FilterContext;
import org.joinmastodon.android.model.Status;
@@ -58,7 +57,7 @@ public class AccountTimelineFragment extends StatusListFragment{
@Override
protected void doLoadData(int offset, int count){
currentRequest=new GetAccountStatuses(user.id, offset>0 ? getMaxID() : null, null, count, filter)
currentRequest=new GetAccountStatuses(user.id, offset>0 ? getMaxID() : null, null, count, filter, null)
.setCallback(new SimpleCallback<>(this){
@Override
public void onSuccess(List<Status> result){

View File

@@ -5,6 +5,7 @@ import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.ClipData;
import android.content.Intent;
import android.content.res.Configuration;
@@ -1120,12 +1121,15 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
private void showLanguageAlert(){
Preferences prefs=AccountSessionManager.getInstance().getAccount(accountID).preferences;
ComposeLanguageAlertViewController vc=new ComposeLanguageAlertViewController(getActivity(), prefs!=null ? prefs.postingDefaultLanguage : null, postLang, mainEditText.getText().toString());
new M3AlertDialogBuilder(getActivity())
final AlertDialog dlg=new M3AlertDialogBuilder(getActivity())
.setTitle(R.string.language)
.setView(vc.getView())
.setPositiveButton(R.string.ok, (dialog, which)->setPostLanguage(vc.getSelectedOption()))
.setNegativeButton(R.string.cancel, null)
.setPositiveButton(R.string.cancel, null)
.show();
vc.setSelectionListener(opt->{
setPostLanguage(opt);
dlg.dismiss();
});
}
private void setPostLanguage(ComposeLanguageAlertViewController.SelectedOption language){

View File

@@ -10,7 +10,6 @@ import org.joinmastodon.android.model.Account;
import org.joinmastodon.android.model.Hashtag;
import org.joinmastodon.android.ui.displayitems.HashtagStatusDisplayItem;
import org.joinmastodon.android.ui.displayitems.StatusDisplayItem;
import org.joinmastodon.android.ui.utils.UiUtils;
import org.parceler.Parcels;
import java.util.Collections;
@@ -19,6 +18,7 @@ import java.util.Objects;
import java.util.stream.Collectors;
import androidx.recyclerview.widget.RecyclerView;
import me.grishka.appkit.Nav;
public class FeaturedHashtagsListFragment extends BaseStatusListFragment<Hashtag>{
private Account account;
@@ -45,7 +45,11 @@ public class FeaturedHashtagsListFragment extends BaseStatusListFragment<Hashtag
@Override
public void onItemClick(String id){
UiUtils.openHashtagTimeline(getActivity(), accountID, Objects.requireNonNull(findItemOfType(id, HashtagStatusDisplayItem.class)).tag);
Bundle args=new Bundle();
args.putParcelable("targetAccount", Parcels.wrap(account));
args.putParcelable("hashtag", Parcels.wrap(Objects.requireNonNull(findItemOfType(id, HashtagStatusDisplayItem.class)).tag));
args.putString("account", accountID);
Nav.go(getActivity(), HashtagFeaturedTimelineFragment.class, args);
}
@Override

View File

@@ -0,0 +1,47 @@
package org.joinmastodon.android.fragments;
import android.os.Bundle;
import org.joinmastodon.android.api.requests.accounts.GetAccountStatuses;
import org.joinmastodon.android.api.session.AccountSessionManager;
import org.joinmastodon.android.model.Account;
import org.joinmastodon.android.model.FilterContext;
import org.joinmastodon.android.model.Hashtag;
import org.joinmastodon.android.model.Status;
import org.parceler.Parcels;
import java.util.List;
import me.grishka.appkit.api.SimpleCallback;
// The difference between this and HashtagTimelineFragment is that this opens from the featured hashtags
// and only shows posts by that account.
public class HashtagFeaturedTimelineFragment extends StatusListFragment{
private Account targetAccount;
private Hashtag hashtag;
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
targetAccount=Parcels.unwrap(getArguments().getParcelable("targetAccount"));
hashtag=Parcels.unwrap(getArguments().getParcelable("hashtag"));
setTitle("#"+hashtag.name);
loadData();
}
@Override
protected void doLoadData(int offset, int count){
currentRequest=new GetAccountStatuses(targetAccount.id, offset>0 ? getMaxID() : null, null, count, GetAccountStatuses.Filter.DEFAULT, hashtag.name)
.setCallback(new SimpleCallback<>(this){
@Override
public void onSuccess(List<Status> result){
if(getActivity()==null)
return;
boolean empty=result.isEmpty();
AccountSessionManager.get(accountID).filterStatuses(result, FilterContext.ACCOUNT);
onDataLoaded(result, !empty);
}
})
.exec(accountID);
}
}

View File

@@ -112,7 +112,7 @@ public class HomeFragment extends AppKitFragment implements OnBackPressedListene
content.setOrientation(LinearLayout.VERTICAL);
FrameLayout fragmentContainer=new FrameLayout(getActivity());
fragmentContainer.setId(R.id.fragment_wrap);
fragmentContainer.setId(me.grishka.appkit.R.id.fragment_wrap);
content.addView(fragmentContainer, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0, 1f));
inflater.inflate(R.layout.tab_bar, content);
@@ -131,10 +131,10 @@ public class HomeFragment extends AppKitFragment implements OnBackPressedListene
if(savedInstanceState==null){
getChildFragmentManager().beginTransaction()
.add(R.id.fragment_wrap, homeTimelineFragment)
.add(R.id.fragment_wrap, searchFragment).hide(searchFragment)
.add(R.id.fragment_wrap, notificationsFragment).hide(notificationsFragment)
.add(R.id.fragment_wrap, profileFragment).hide(profileFragment)
.add(me.grishka.appkit.R.id.fragment_wrap, homeTimelineFragment)
.add(me.grishka.appkit.R.id.fragment_wrap, searchFragment).hide(searchFragment)
.add(me.grishka.appkit.R.id.fragment_wrap, notificationsFragment).hide(notificationsFragment)
.add(me.grishka.appkit.R.id.fragment_wrap, profileFragment).hide(profileFragment)
.commit();
String defaultTab=getArguments().getString("tab");

View File

@@ -1,12 +1,17 @@
package org.joinmastodon.android.fragments;
import android.os.Build;
import android.os.Bundle;
import android.view.ActionMode;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowInsets;
import android.view.inputmethod.InputMethodManager;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import com.squareup.otto.Subscribe;
@@ -19,7 +24,7 @@ import org.joinmastodon.android.api.requests.lists.GetListAccounts;
import org.joinmastodon.android.api.requests.lists.RemoveAccountsFromList;
import org.joinmastodon.android.events.AccountAddedToListEvent;
import org.joinmastodon.android.events.AccountRemovedFromListEvent;
import org.joinmastodon.android.fragments.account_list.AddListMembersFragment;
import org.joinmastodon.android.fragments.account_list.AddNewListMembersFragment;
import org.joinmastodon.android.fragments.account_list.PaginatedAccountListFragment;
import org.joinmastodon.android.model.Account;
import org.joinmastodon.android.model.FollowList;
@@ -33,24 +38,31 @@ import org.parceler.Parcels;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import me.grishka.appkit.Nav;
import me.grishka.appkit.api.Callback;
import me.grishka.appkit.api.ErrorResponse;
import me.grishka.appkit.fragments.OnBackPressedListener;
import me.grishka.appkit.utils.CubicBezierInterpolator;
import me.grishka.appkit.utils.V;
import me.grishka.appkit.views.FragmentRootLinearLayout;
public class ListMembersFragment extends PaginatedAccountListFragment{
private static final int ADD_MEMBER_RESULT=600;
public class ListMembersFragment extends PaginatedAccountListFragment implements AddNewListMembersFragment.Listener, OnBackPressedListener{
private ImageButton fab;
private FollowList followList;
private boolean inSelectionMode;
private Set<String> selectedAccounts=new HashSet<>();
private ActionMode actionMode;
private MenuItem deleteItem;
private FrameLayout searchFragmentContainer;
private FrameLayout fragmentContentWrap;
private AddNewListMembersFragment searchFragment;
private FragmentRootLinearLayout rootView;
private WindowInsets lastInsets;
private HashSet<String> accountIDsInList=new HashSet<>();
private boolean dismissingSearchFragment;
public ListMembersFragment(){
setListLayoutId(R.layout.recycler_fragment_with_fab);
@@ -76,6 +88,26 @@ public class ListMembersFragment extends PaginatedAccountListFragment{
return new GetListAccounts(followList.id, maxID, count);
}
@Override
protected void onDataLoaded(List<AccountViewModel> d, boolean more){
if(refreshing)
accountIDsInList.clear();
for(AccountViewModel a:d){
accountIDsInList.add(a.account.id);
}
super.onDataLoaded(d, more);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
View view=super.onCreateView(inflater, container, savedInstanceState);
FrameLayout wrapper=new FrameLayout(getActivity());
wrapper.addView(view);
rootView=(FragmentRootLinearLayout) view;
fragmentContentWrap=wrapper;
return wrapper;
}
@Override
protected void onConfigureViewHolder(AccountViewHolder holder){
super.onConfigureViewHolder(holder);
@@ -132,16 +164,19 @@ public class ListMembersFragment extends PaginatedAccountListFragment{
@Override
public void onApplyWindowInsets(WindowInsets insets){
super.onApplyWindowInsets(insets);
lastInsets=insets;
if(searchFragment!=null)
searchFragment.onApplyWindowInsets(insets);
UiUtils.applyBottomInsetToFAB(fab, insets);
}
@Override
public void onFragmentResult(int reqCode, boolean success, Bundle result){
if(reqCode==ADD_MEMBER_RESULT && success){
Account acc=Objects.requireNonNull(Parcels.unwrap(result.getParcelable("selectedAccount")));
addAccounts(List.of(acc));
if(Build.VERSION.SDK_INT>=29 && insets.getTappableElementInsets().bottom==0){
list.setPadding(0, 0, 0, insets.getSystemWindowInsetBottom());
emptyView.setPadding(0, 0, 0, insets.getSystemWindowInsetBottom());
progress.setPadding(0, 0, 0, insets.getSystemWindowInsetBottom());
insets=insets.inset(0, 0, 0, insets.getSystemWindowInsetBottom());
}else{
list.setPadding(0, 0, 0, 0);
}
rootView.onApplyWindowInsets(insets);
}
@Subscribe
@@ -160,9 +195,25 @@ public class ListMembersFragment extends PaginatedAccountListFragment{
}
private void onFabClick(){
searchFragmentContainer=new FrameLayout(getActivity());
searchFragmentContainer.setId(R.id.search_fragment);
fragmentContentWrap.addView(searchFragmentContainer);
Bundle args=new Bundle();
args.putString("account", accountID);
Nav.goForResult(getActivity(), AddListMembersFragment.class, args, ADD_MEMBER_RESULT, this);
args.putParcelable("list", Parcels.wrap(followList));
args.putBoolean("_can_go_back", true);
searchFragment=new AddNewListMembersFragment(this);
searchFragment.setArguments(args);
getChildFragmentManager().beginTransaction().add(R.id.search_fragment, searchFragment).commit();
getChildFragmentManager().executePendingTransactions();
if(lastInsets!=null)
searchFragment.onApplyWindowInsets(lastInsets);
searchFragmentContainer.setTranslationX(V.dp(100));
searchFragmentContainer.setAlpha(0f);
searchFragmentContainer.animate().translationX(0).alpha(1).setDuration(300).withLayer().setInterpolator(CubicBezierInterpolator.DEFAULT).withEndAction(()->{
rootView.setVisibility(View.GONE);
}).start();
}
private void onItemClick(AccountViewHolder holder){
@@ -198,7 +249,7 @@ public class ListMembersFragment extends PaginatedAccountListFragment{
if(id==R.id.remove_from_list){
new M3AlertDialogBuilder(getActivity())
.setTitle(R.string.confirm_remove_list_member)
.setPositiveButton(R.string.remove, (dlg, which)->removeAccounts(Set.of(holder.getItem().account.id)))
.setPositiveButton(R.string.remove, (dlg, which)->removeAccounts(Set.of(holder.getItem().account.id), null))
.setNegativeButton(R.string.cancel, null)
.show();
}
@@ -229,7 +280,7 @@ public class ListMembersFragment extends PaginatedAccountListFragment{
public boolean onActionItemClicked(ActionMode mode, MenuItem item){
new M3AlertDialogBuilder(getActivity())
.setTitle(R.string.confirm_remove_list_members)
.setPositiveButton(R.string.remove, (dlg, which)->removeAccounts(new HashSet<>(selectedAccounts)))
.setPositiveButton(R.string.remove, (dlg, which)->removeAccounts(new HashSet<>(selectedAccounts), null))
.setNegativeButton(R.string.cancel, null)
.show();
return true;
@@ -251,13 +302,16 @@ public class ListMembersFragment extends PaginatedAccountListFragment{
actionMode.setTitle(getResources().getQuantityString(R.plurals.x_items_selected, selectedAccounts.size(), selectedAccounts.size()));
}
private void removeAccounts(Set<String> ids){
private void removeAccounts(Set<String> ids, Runnable onDone){
new RemoveAccountsFromList(followList.id, ids)
.setCallback(new Callback<>(){
@Override
public void onSuccess(Void result){
if(onDone!=null)
onDone.run();
if(inSelectionMode)
actionMode.finish();
accountIDsInList.removeAll(ids);
removeAccountRows(ids);
}
@@ -270,12 +324,15 @@ public class ListMembersFragment extends PaginatedAccountListFragment{
.exec(accountID);
}
private void addAccounts(Collection<Account> accounts){
private void addAccounts(Collection<Account> accounts, Runnable onDone){
new AddAccountsToList(followList.id, accounts.stream().map(a->a.id).collect(Collectors.toSet()))
.setCallback(new Callback<>(){
@Override
public void onSuccess(Void result){
if(onDone!=null)
onDone.run();
for(Account acc:accounts){
accountIDsInList.add(acc.id);
data.add(new AccountViewModel(acc, accountID));
}
list.getAdapter().notifyItemRangeInserted(data.size()-accounts.size(), accounts.size());
@@ -298,4 +355,54 @@ public class ListMembersFragment extends PaginatedAccountListFragment{
}
}
}
@Override
public boolean isAccountInList(AccountViewModel account){
return accountIDsInList.contains(account.account.id);
}
@Override
public void addAccountToList(AccountViewModel account, Runnable onDone){
addAccounts(Set.of(account.account), onDone);
}
@Override
public void removeAccountAccountFromList(AccountViewModel account, Runnable onDone){
removeAccounts(Set.of(account.account.id), onDone);
}
@Override
public boolean onBackPressed(){
if(searchFragment!=null){
dismissSearchFragment();
return true;
}
return false;
}
private void dismissSearchFragment(){
if(searchFragment==null || dismissingSearchFragment)
return;
dismissingSearchFragment=true;
rootView.setVisibility(View.VISIBLE);
searchFragmentContainer.animate().translationX(V.dp(100)).alpha(0).setDuration(200).withLayer().setInterpolator(CubicBezierInterpolator.DEFAULT).withEndAction(()->{
getChildFragmentManager().beginTransaction().remove(searchFragment).commit();
getChildFragmentManager().executePendingTransactions();
fragmentContentWrap.removeView(searchFragmentContainer);
searchFragmentContainer=null;
searchFragment=null;
dismissingSearchFragment=false;
}).start();
getActivity().getSystemService(InputMethodManager.class).hideSoftInputFromWindow(contentView.getWindowToken(), 0);
}
@Override
protected void setStatusBarColor(int color){
rootView.setStatusBarColor(color);
}
@Override
protected void setNavigationBarColor(int color){
rootView.setNavigationBarColor(color);
}
}

View File

@@ -25,7 +25,7 @@ public class PinnedPostsListFragment extends StatusListFragment{
@Override
protected void doLoadData(int offset, int count){
new GetAccountStatuses(account.id, null, null, 100, GetAccountStatuses.Filter.PINNED)
new GetAccountStatuses(account.id, null, null, 100, GetAccountStatuses.Filter.PINNED, null)
.setCallback(new SimpleCallback<>(this){
@Override
public void onSuccess(List<Status> result){

View File

@@ -310,7 +310,7 @@ public class ProfileAboutFragment extends Fragment implements WindowInsetsAwareF
public void onSelectedChanged(@Nullable RecyclerView.ViewHolder viewHolder, int actionState){
super.onSelectedChanged(viewHolder, actionState);
if(actionState==ItemTouchHelper.ACTION_STATE_DRAG){
viewHolder.itemView.setTag(R.id.item_touch_helper_previous_elevation, viewHolder.itemView.getElevation()); // prevents the default behavior of changing elevation in onDraw()
viewHolder.itemView.setTag(me.grishka.appkit.R.id.item_touch_helper_previous_elevation, viewHolder.itemView.getElevation()); // prevents the default behavior of changing elevation in onDraw()
viewHolder.itemView.animate().translationZ(V.dp(1)).setDuration(200).setInterpolator(CubicBezierInterpolator.DEFAULT).start();
}
}

View File

@@ -18,7 +18,6 @@ import org.joinmastodon.android.ui.displayitems.FooterStatusDisplayItem;
import org.joinmastodon.android.ui.displayitems.HashtagStatusDisplayItem;
import org.joinmastodon.android.ui.displayitems.SectionHeaderStatusDisplayItem;
import org.joinmastodon.android.ui.displayitems.StatusDisplayItem;
import org.joinmastodon.android.ui.utils.UiUtils;
import org.parceler.Parcels;
import java.util.ArrayList;
@@ -93,7 +92,13 @@ public class ProfileFeaturedFragment extends BaseStatusListFragment<SearchResult
args.putParcelable("profileAccount", Parcels.wrap(res.account));
Nav.go(getActivity(), ProfileFragment.class, args);
}
case HASHTAG -> UiUtils.openHashtagTimeline(getActivity(), accountID, res.hashtag);
case HASHTAG -> {
Bundle args=new Bundle();
args.putParcelable("targetAccount", Parcels.wrap(profileAccount));
args.putParcelable("hashtag", Parcels.wrap(res.hashtag));
args.putString("account", accountID);
Nav.go(getActivity(), HashtagFeaturedTimelineFragment.class, args);
}
case STATUS -> {
Status status=res.status.getContentStatus();
Bundle args=new Bundle();
@@ -109,7 +114,7 @@ public class ProfileFeaturedFragment extends BaseStatusListFragment<SearchResult
@Override
protected void doLoadData(int offset, int count){
if(!statusesLoaded){
new GetAccountStatuses(profileAccount.id, null, null, 2, GetAccountStatuses.Filter.PINNED)
new GetAccountStatuses(profileAccount.id, null, null, 2, GetAccountStatuses.Filter.PINNED, null)
.setCallback(new SimpleCallback<>(this){
@Override
public void onSuccess(List<Status> result){

View File

@@ -18,13 +18,18 @@ import android.graphics.drawable.LayerDrawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.text.SpannableString;
import android.text.SpannableStringBuilder;
import android.text.SpannedString;
import android.text.TextUtils;
import android.text.style.ForegroundColorSpan;
import android.text.style.ImageSpan;
import android.transition.ChangeBounds;
import android.transition.Fade;
import android.transition.Transition;
import android.transition.TransitionManager;
import android.transition.TransitionSet;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
@@ -36,6 +41,7 @@ import android.view.ViewTreeObserver;
import android.view.WindowInsets;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
@@ -129,6 +135,7 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
private View tabsDivider;
private View actionButtonWrap;
private CustomDrawingOrderLinearLayout scrollableContent;
private ImageButton qrCodeButton;
private Account account;
private String accountID;
@@ -211,6 +218,7 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
tabsDivider=content.findViewById(R.id.tabs_divider);
actionButtonWrap=content.findViewById(R.id.profile_action_btn_wrap);
scrollableContent=content.findViewById(R.id.scrollable_content);
qrCodeButton=content.findViewById(R.id.qr_code);
avatar.setOutlineProvider(OutlineProviders.roundedRect(24));
avatar.setClipToOutline(true);
@@ -324,6 +332,14 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
bioEdit.addTextChangedListener(new SimpleTextWatcher(e->editDirty=true));
usernameDomain.setOnClickListener(v->new DecentralizationExplainerSheet(getActivity(), accountID, account).show());
qrCodeButton.setOnClickListener(v->{
Bundle args=new Bundle();
args.putString("account", accountID);
args.putParcelable("targetAccount", Parcels.wrap(account));
ProfileQrCodeFragment qf=new ProfileQrCodeFragment();
qf.setArguments(args);
qf.show(getChildFragmentManager(), "qrDialog");
});
return sizeWrapper;
}
@@ -583,6 +599,13 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
}
}
private CharSequence makeRedString(CharSequence s){
int color=UiUtils.getThemeColor(getActivity(), R.attr.colorM3Error);
SpannableString ss=new SpannableString(s);
ss.setSpan(new ForegroundColorSpan(color), 0, ss.length(), 0);
return ss;
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater){
if(isOwnProfile && isInEditMode){
@@ -599,28 +622,29 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
if(isOwnProfile)
return;
menu.findItem(R.id.mute).setTitle(getString(relationship.muting ? R.string.unmute_user : R.string.mute_user, account.displayName));
menu.findItem(R.id.block).setTitle(getString(relationship.blocking ? R.string.unblock_user : R.string.block_user, account.displayName));
menu.findItem(R.id.report).setTitle(getString(R.string.report_user, account.displayName));
menu.findItem(R.id.mute).setTitle(getString(relationship.muting ? R.string.unmute_user : R.string.mute_user, account.getDisplayUsername()));
menu.findItem(R.id.block).setTitle(makeRedString(getString(relationship.blocking ? R.string.unblock_user : R.string.block_user, account.getDisplayUsername())));
menu.findItem(R.id.report).setTitle(makeRedString(getString(R.string.report_user, account.getDisplayUsername())));
if(relationship.following)
menu.findItem(R.id.hide_boosts).setTitle(getString(relationship.showingReblogs ? R.string.hide_boosts_from_user : R.string.show_boosts_from_user, account.displayName));
menu.findItem(R.id.hide_boosts).setTitle(getString(relationship.showingReblogs ? R.string.hide_boosts_from_user : R.string.show_boosts_from_user));
else
menu.findItem(R.id.hide_boosts).setVisible(false);
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(makeRedString(getString(relationship.domainBlocking ? R.string.unblock_domain : R.string.block_domain, account.getDomain())));
else
menu.findItem(R.id.block_domain).setVisible(false);
menu.findItem(R.id.add_to_list).setVisible(relationship.following);
if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.P && !UiUtils.isEMUI()){
menu.setGroupDividerEnabled(true);
}
}
@Override
public boolean onOptionsItemSelected(MenuItem item){
int id=item.getItemId();
if(id==R.id.share){
Intent intent=new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, account.url);
startActivity(Intent.createChooser(intent, item.getTitle()));
UiUtils.openSystemShareSheet(getActivity(), account);
}else if(id==R.id.mute){
confirmToggleMuted();
}else if(id==R.id.block){
@@ -836,17 +860,48 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
toolbar.setNavigationContentDescription(R.string.discard);
ViewGroup parent=contentView.findViewById(R.id.scrollable_content);
Runnable updater=new Runnable(){
@Override
public void run(){
// setPadding() calls nullLayouts() internally, forcing the text layout to update
actionButton.setPadding(actionButton.getPaddingLeft(), 1, actionButton.getPaddingRight(), 0);
actionButton.setPadding(actionButton.getPaddingLeft(), 0, actionButton.getPaddingRight(), 0);
actionButton.measure(actionButton.getWidth()|View.MeasureSpec.EXACTLY, actionButton.getHeight()|View.MeasureSpec.EXACTLY);
actionButton.postOnAnimation(this);
}
};
actionButton.postOnAnimation(updater);
TransitionManager.beginDelayedTransition(parent, new TransitionSet()
.addTransition(new Fade(Fade.IN | Fade.OUT))
.addTransition(new ChangeBounds())
.setDuration(250)
.setInterpolator(CubicBezierInterpolator.DEFAULT)
.addListener(new Transition.TransitionListener(){
@Override
public void onTransitionStart(Transition transition){}
@Override
public void onTransitionEnd(Transition transition){
actionButton.removeCallbacks(updater);
}
@Override
public void onTransitionCancel(Transition transition){}
@Override
public void onTransitionPause(Transition transition){}
@Override
public void onTransitionResume(Transition transition){}
})
);
name.setVisibility(View.GONE);
username.setVisibility(View.GONE);
name.setVisibility(View.INVISIBLE);
username.setVisibility(View.INVISIBLE);
bio.setVisibility(View.GONE);
countersLayout.setVisibility(View.GONE);
qrCodeButton.setVisibility(View.GONE);
usernameDomain.setVisibility(View.INVISIBLE);
nameEditWrap.setVisibility(View.VISIBLE);
nameEdit.setText(account.displayName);
@@ -875,7 +930,7 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
Toolbar toolbar=getToolbar();
if(canGoBack()){
Drawable back=getToolbarContext().getDrawable(R.drawable.ic_arrow_back).mutate();
Drawable back=getToolbarContext().getDrawable(me.grishka.appkit.R.drawable.ic_arrow_back).mutate();
back.setTint(UiUtils.getThemeColor(getToolbarContext(), R.attr.colorM3OnSurfaceVariant));
toolbar.setNavigationIcon(back);
toolbar.setNavigationContentDescription(0);
@@ -885,11 +940,40 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
editSaveMenuItem=null;
ViewGroup parent=contentView.findViewById(R.id.scrollable_content);
Runnable updater=new Runnable(){
@Override
public void run(){
// setPadding() calls nullLayouts() internally, forcing the text layout to update
actionButton.setPadding(actionButton.getPaddingLeft(), 1, actionButton.getPaddingRight(), 0);
actionButton.setPadding(actionButton.getPaddingLeft(), 0, actionButton.getPaddingRight(), 0);
actionButton.measure(actionButton.getWidth()|View.MeasureSpec.EXACTLY, actionButton.getHeight()|View.MeasureSpec.EXACTLY);
actionButton.postOnAnimation(this);
}
};
actionButton.postOnAnimation(updater);
TransitionManager.beginDelayedTransition(parent, new TransitionSet()
.addTransition(new Fade(Fade.IN | Fade.OUT))
.addTransition(new ChangeBounds())
.setDuration(250)
.setInterpolator(CubicBezierInterpolator.DEFAULT)
.addListener(new Transition.TransitionListener(){
@Override
public void onTransitionStart(Transition transition){}
@Override
public void onTransitionEnd(Transition transition){
actionButton.removeCallbacks(updater);
}
@Override
public void onTransitionCancel(Transition transition){}
@Override
public void onTransitionPause(Transition transition){}
@Override
public void onTransitionResume(Transition transition){}
})
);
nameEditWrap.setVisibility(View.GONE);
bioEditWrap.setVisibility(View.GONE);
@@ -898,6 +982,8 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
bio.setVisibility(View.VISIBLE);
countersLayout.setVisibility(View.VISIBLE);
refreshLayout.setEnabled(true);
usernameDomain.setVisibility(View.VISIBLE);
qrCodeButton.setVisibility(View.VISIBLE);
bindHeaderView();
V.setVisibilityAnimated(fab, View.VISIBLE);

View File

@@ -0,0 +1,602 @@
package org.joinmastodon.android.fragments;
import android.Manifest;
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.Dialog;
import android.app.DownloadManager;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.DashPathEffect;
import android.graphics.Paint;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.media.MediaScannerConnection;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.SystemClock;
import android.provider.MediaStore;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.ContextThemeWrapper;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.VelocityTracker;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType;
import com.google.zxing.WriterException;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.QRCodeWriter;
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
import org.joinmastodon.android.MainActivity;
import org.joinmastodon.android.R;
import org.joinmastodon.android.api.MastodonAPIController;
import org.joinmastodon.android.api.session.AccountSessionManager;
import org.joinmastodon.android.googleservices.GmsClient;
import org.joinmastodon.android.googleservices.barcodescanner.Barcode;
import org.joinmastodon.android.googleservices.barcodescanner.BarcodeScanner;
import org.joinmastodon.android.model.Account;
import org.joinmastodon.android.ui.M3AlertDialogBuilder;
import org.joinmastodon.android.ui.Snackbar;
import org.joinmastodon.android.ui.drawables.FancyQrCodeDrawable;
import org.joinmastodon.android.ui.drawables.RadialParticleSystemDrawable;
import org.joinmastodon.android.ui.utils.UiUtils;
import org.joinmastodon.android.ui.views.FixedAspectRatioFrameLayout;
import org.parceler.Parcels;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
import java.util.Map;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.dynamicanimation.animation.DynamicAnimation;
import androidx.dynamicanimation.animation.SpringAnimation;
import androidx.dynamicanimation.animation.SpringForce;
import me.grishka.appkit.fragments.AppKitFragment;
import me.grishka.appkit.imageloader.ViewImageLoader;
import me.grishka.appkit.imageloader.requests.UrlImageLoaderRequest;
import me.grishka.appkit.utils.CubicBezierInterpolator;
import me.grishka.appkit.utils.CustomViewHelper;
import me.grishka.appkit.utils.V;
public class ProfileQrCodeFragment extends AppKitFragment{
private static final String TAG="ProfileQrCodeFragment";
private static final int PERMISSION_RESULT=388;
private static final int SCAN_RESULT=439;
private Context themeWrapper;
private GradientDrawable scrim=new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, new int[]{0xE6000000, 0xD9000000});
private RadialParticleSystemDrawable particles;
private View codeContainer;
private View particleAnimContainer;
private Animator currentTransition;
private View saveBtn;
private TextView saveBtnText;
private View content;
private String accountID;
private Account account;
private String accountDomain;
private Intent scannerIntent;
private boolean dismissing;
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setStyle(STYLE_NO_FRAME, 0);
setHasOptionsMenu(true);
accountID=getArguments().getString("account");
account=Parcels.unwrap(getArguments().getParcelable("targetAccount"));
setCancelable(false);
scannerIntent=BarcodeScanner.createIntent(Barcode.FORMAT_QR_CODE, false, true);
}
@Override
public void onStart(){
super.onStart();
Dialog dlg=getDialog();
dlg.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT);
dlg.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR);
dlg.getWindow().setNavigationBarColor(0);
dlg.getWindow().setStatusBarColor(0);
WindowManager.LayoutParams lp=dlg.getWindow().getAttributes();
if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.P){
lp.layoutInDisplayCutoutMode=WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
}
dlg.getWindow().setAttributes(lp);
if(!isTablet){
getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
dlg.setOnKeyListener((dialog, keyCode, event)->{
if(keyCode==KeyEvent.KEYCODE_BACK && event.getAction()==KeyEvent.ACTION_DOWN){
dismiss();
}
return true;
});
}
@Override
public void onDismiss(DialogInterface dialog){
super.onDismiss(dialog);
Activity activity=getActivity();
if(activity!=null)
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
}
@Override
public void onAttach(Activity activity){
super.onAttach(activity);
themeWrapper=new ContextThemeWrapper(activity, R.style.Theme_Mastodon_Dark);
}
@SuppressLint("ClickableViewAccessibility")
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState){
content=View.inflate(themeWrapper, R.layout.fragment_profile_qr, container);
View decor=getDialog().getWindow().getDecorView();
decor.setOnApplyWindowInsetsListener((v, insets)->{
content.setPadding(insets.getStableInsetLeft(), insets.getStableInsetTop(), insets.getStableInsetRight(), insets.getStableInsetBottom());
return insets.consumeStableInsets();
});
int flags=decor.getSystemUiVisibility() | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
flags&=~(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR | View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
decor.setSystemUiVisibility(flags);
content.setBackground(scrim);
String url=account.url;
QRCodeWriter writer=new QRCodeWriter();
BitMatrix code;
try{
code=writer.encode(url, BarcodeFormat.QR_CODE, 0, 0, Map.of(EncodeHintType.MARGIN, 0, EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H));
}catch(WriterException e){
throw new RuntimeException(e);
}
View codeView=content.findViewById(R.id.code);
ImageView avatar=content.findViewById(R.id.avatar);
TextView username=content.findViewById(R.id.username);
TextView domain=content.findViewById(R.id.domain);
View share=content.findViewById(R.id.share_btn);
saveBtn=content.findViewById(R.id.save_btn);
saveBtnText=content.findViewById(R.id.save_text);
View cornerAnimContainer=content.findViewById(R.id.corner_animation_container);
particleAnimContainer=content.findViewById(R.id.particle_animation_container);
codeContainer=content.findViewById(R.id.code_container);
if(!TextUtils.isEmpty(account.avatar)){
ViewImageLoader.loadWithoutAnimation(avatar, getResources().getDrawable(R.drawable.image_placeholder, getActivity().getTheme()), new UrlImageLoaderRequest(Bitmap.Config.ARGB_8888, V.dp(24), V.dp(24), List.of(), Uri.parse(account.avatarStatic)));
}
username.setText(account.username);
String accDomain=account.getDomain();
domain.setText(accountDomain=TextUtils.isEmpty(accDomain) ? AccountSessionManager.get(accountID).domain : accDomain);
Drawable logo=getResources().getDrawable(R.drawable.ic_ntf_logo, themeWrapper.getTheme()).mutate();
logo.setTint(UiUtils.getThemeColor(themeWrapper, R.attr.colorM3OnPrimary));
codeView.setBackground(new FancyQrCodeDrawable(code, UiUtils.getThemeColor(themeWrapper, R.attr.colorM3OnPrimary), logo));
share.setOnClickListener(v->{
UiUtils.openSystemShareSheet(getActivity(), account);
});
saveBtn.setOnClickListener(v->saveCodeAsFile());
cornerAnimContainer.setBackground(new AnimatedCornersDrawable(themeWrapper));
int particleColor=UiUtils.getThemeColor(themeWrapper, R.attr.colorM3Primary);
particles=new RadialParticleSystemDrawable(5000, 200, (particleColor & 0xFFFFFF) | 0x80000000, particleColor & 0xFFFFFF, V.dp(65), V.dp(50), getResources().getDisplayMetrics().density);
particleAnimContainer.setBackground(particles);
content.setOnTouchListener(new TouchDismissListener());
int buttonExtraWidth=saveBtn.getPaddingLeft()+saveBtn.getPaddingRight()+saveBtnText.getCompoundDrawablesRelative()[0].getIntrinsicWidth()+saveBtnText.getCompoundDrawablePadding();
saveBtn.getLayoutParams().width=(int)Math.max(saveBtnText.getPaint().measureText(getString(R.string.save)), saveBtnText.getPaint().measureText(getString(R.string.saved)))+buttonExtraWidth;
return content;
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState){
super.onViewCreated(view, savedInstanceState);
if(savedInstanceState==null){
AnimatorSet set=new AnimatorSet();
set.playTogether(
ObjectAnimator.ofInt(scrim, "alpha", 0, 255),
ObjectAnimator.ofFloat(particleAnimContainer, View.TRANSLATION_Y, V.dp(50), 0),
ObjectAnimator.ofFloat(particleAnimContainer, View.ALPHA, 0, 1),
ObjectAnimator.ofFloat(getToolbar(), View.ALPHA, 0, 1)
);
set.setInterpolator(CubicBezierInterpolator.DEFAULT);
set.setDuration(350);
set.addListener(new AnimatorListenerAdapter(){
@Override
public void onAnimationEnd(Animator animation){
currentTransition=null;
}
});
currentTransition=set;
set.start();
}
}
@Override
public void dismiss(){
dismissWithAnimation(super::dismiss, true);
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater){
if(GmsClient.isGooglePlayServicesAvailable(getActivity())){
MenuItem item=menu.add(0, 0, 0, R.string.scan_qr_code);
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
item.setIcon(R.drawable.ic_qr_code_scanner_24px);
}
}
@Override
public boolean onOptionsItemSelected(MenuItem item){
if(scannerIntent.resolveActivity(getActivity().getPackageManager())!=null){
startActivityForResult(scannerIntent, SCAN_RESULT);
}else{
BarcodeScanner.installScannerModule(themeWrapper, ()->startActivityForResult(scannerIntent, SCAN_RESULT));
}
return true;
}
@Override
protected boolean canGoBack(){
return true;
}
@Override
public void onToolbarNavigationClick(){
dismiss();
}
@Override
public boolean wantsCustomNavigationIcon(){
return true;
}
@Override
protected int getNavigationIconDrawableResource(){
return R.drawable.ic_baseline_close_24;
}
@Override
protected LayoutInflater getToolbarLayoutInflater(){
return LayoutInflater.from(themeWrapper);
}
@Override
protected int getToolbarResource(){
return R.layout.profile_qr_toolbar;
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults){
if(requestCode==PERMISSION_RESULT){
if(grantResults[0]==PackageManager.PERMISSION_GRANTED){
doSaveCodeAsFile();
}else if(!getActivity().shouldShowRequestPermissionRationale(Manifest.permission.WRITE_EXTERNAL_STORAGE)){
new M3AlertDialogBuilder(getActivity())
.setTitle(R.string.permission_required)
.setMessage(R.string.storage_permission_to_download)
.setPositiveButton(R.string.open_settings, (dialog, which)->getActivity().startActivity(new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS, Uri.fromParts("package", getActivity().getPackageName(), null))))
.setNegativeButton(R.string.cancel, null)
.show();
}
}
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data){
if(requestCode==SCAN_RESULT && resultCode==Activity.RESULT_OK && BarcodeScanner.isValidResult(data)){
Barcode code=BarcodeScanner.getResult(data);
if(code!=null){
if(code.rawValue.startsWith("https:") || code.rawValue.startsWith("http:")){
((MainActivity)getActivity()).handleURL(Uri.parse(code.rawValue), accountID);
dismiss();
}else{
Toast.makeText(themeWrapper, R.string.link_not_supported, Toast.LENGTH_SHORT).show();
}
}
}
}
private void dismissWithAnimation(Runnable onDone, boolean animateTranslationDown){
if(dismissing)
return;
dismissing=true;
content.setOnTouchListener(null);
if(currentTransition!=null)
currentTransition.cancel();
AnimatorSet set=new AnimatorSet();
set.playTogether(
ObjectAnimator.ofInt(scrim, "alpha", 0),
ObjectAnimator.ofFloat(particleAnimContainer, View.TRANSLATION_Y, particleAnimContainer.getTranslationY()+V.dp(animateTranslationDown ? 50 : -50)),
ObjectAnimator.ofFloat(particleAnimContainer, View.ALPHA, 0),
ObjectAnimator.ofFloat(getToolbar(), View.ALPHA, 0)
);
set.setInterpolator(CubicBezierInterpolator.DEFAULT);
set.setDuration(200);
set.addListener(new AnimatorListenerAdapter(){
@Override
public void onAnimationEnd(Animator animation){
onDone.run();
}
});
currentTransition=set;
set.start();
}
private void saveCodeAsFile(){
if(Build.VERSION.SDK_INT>=29){
doSaveCodeAsFile();
}else{
if(getActivity().checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)!=PackageManager.PERMISSION_GRANTED){
requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, PERMISSION_RESULT);
}else{
doSaveCodeAsFile();
}
}
}
private void doSaveCodeAsFile(){
Bitmap bmp=Bitmap.createBitmap(1080, 1080, Bitmap.Config.ARGB_8888);
Canvas c=new Canvas(bmp);
float factor=1080f/codeContainer.getWidth();
c.scale(factor, factor);
codeContainer.draw(c);
Activity activity=getActivity();
MastodonAPIController.runInBackground(()->{
String fileName=account.username+"_"+accountDomain+".png";
try(OutputStream os=destinationStreamForFile(fileName)){
bmp.compress(Bitmap.CompressFormat.PNG, 100, os);
activity.runOnUiThread(()->{
saveBtn.setEnabled(false);
saveBtnText.setText(R.string.saved);
saveBtnText.setCompoundDrawablesRelativeWithIntrinsicBounds(R.drawable.ic_check_20px, 0, 0, 0);
new Snackbar.Builder(activity)
.setText(R.string.image_saved)
.setAction(R.string.view_file, ()->startActivity(new Intent(DownloadManager.ACTION_VIEW_DOWNLOADS)))
.show();
});
if(Build.VERSION.SDK_INT<29){
File dstFile=new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), fileName);
MediaScannerConnection.scanFile(activity, new String[]{dstFile.getAbsolutePath()}, new String[]{"image/png"}, null);
}
}catch(IOException x){
activity.runOnUiThread(()->{
new Snackbar.Builder(activity)
.setText(R.string.error_saving_file)
.show();
});
}
});
}
private OutputStream destinationStreamForFile(String fileName) throws IOException{
if(Build.VERSION.SDK_INT>=29){
ContentValues values=new ContentValues();
values.put(MediaStore.MediaColumns.DISPLAY_NAME, fileName);
values.put(MediaStore.MediaColumns.RELATIVE_PATH, Environment.DIRECTORY_DOWNLOADS);
values.put(MediaStore.MediaColumns.MIME_TYPE, "image/png");
ContentResolver cr=getActivity().getContentResolver();
Uri itemUri=cr.insert(MediaStore.Files.getContentUri(MediaStore.VOLUME_EXTERNAL_PRIMARY), values);
return cr.openOutputStream(itemUri);
}else{
return new FileOutputStream(new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), fileName));
}
}
@Override
public void onConfigurationChanged(Configuration newConfig){
super.onConfigurationChanged(newConfig);
codeContainer.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener(){
@Override
public boolean onPreDraw(){
codeContainer.getViewTreeObserver().removeOnPreDrawListener(this);
updateParticleEmitter();
return true;
}
});
}
private void updateParticleEmitter(){
int[] loc={0, 0};
particleAnimContainer.getLocationInWindow(loc);
int x=loc[0], y=loc[1];
codeContainer.getLocationInWindow(loc);
int cx=loc[0]-x+codeContainer.getWidth()/2;
int cy=loc[1]-y+codeContainer.getHeight()/2;
int r=codeContainer.getWidth()/2-V.dp(10);
particles.setEmitterPosition(cx, cy);
particles.setClipOutBounds(cx-r, cy-r, cx+r, cy+r);
}
public static class CustomizedLinearLayout extends LinearLayout implements CustomViewHelper{
public CustomizedLinearLayout(Context context){
this(context, null);
}
public CustomizedLinearLayout(Context context, AttributeSet attrs){
this(context, attrs, 0);
}
public CustomizedLinearLayout(Context context, AttributeSet attrs, int defStyle){
super(context, attrs, defStyle);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec){
int maxW=dp(400);
FixedAspectRatioFrameLayout aspectLayout=(FixedAspectRatioFrameLayout) getChildAt(0);
if(MeasureSpec.getSize(widthMeasureSpec)>maxW){
widthMeasureSpec=MeasureSpec.getMode(widthMeasureSpec) | maxW;
aspectLayout.setUseHeight(MeasureSpec.getSize(heightMeasureSpec)<dp(464));
}else{
aspectLayout.setUseHeight(false);
}
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
}
private class AnimatedCornersDrawable extends Drawable{
private Paint paint=new Paint(Paint.ANTI_ALIAS_FLAG);
private RectF tmpRect=new RectF();
public AnimatedCornersDrawable(Context context){
paint.setColor(UiUtils.getThemeColor(context, R.attr.colorM3Primary));
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeCap(Paint.Cap.ROUND);
paint.setStrokeWidth(V.dp(4));
}
@Override
public void draw(@NonNull Canvas canvas){
float inset=V.dp(24);
float radius=V.dp(40);
float animProgress=((float)Math.sin(Math.toRadians(SystemClock.uptimeMillis()/16.6%360.0))+1f)/2f;
tmpRect.set(getBounds());
tmpRect.inset(inset, inset);
canvas.save();
float factor=1f+0.025f*animProgress;
paint.setStrokeWidth(V.dp(4)/factor);
canvas.scale(factor, factor, tmpRect.centerX(), tmpRect.centerY());
canvas.drawRoundRect(tmpRect, radius, radius, paint);
canvas.restore();
invalidateSelf();
}
@Override
public void setAlpha(int alpha){
}
@Override
public void setColorFilter(@Nullable ColorFilter colorFilter){
}
@Override
public int getOpacity(){
return PixelFormat.TRANSLUCENT;
}
@Override
protected void onBoundsChange(@NonNull Rect bounds){
super.onBoundsChange(bounds);
float inset=V.dp(24);
float radius=V.dp(40);
float additionalLength=V.dp(40);
tmpRect.set(getBounds());
tmpRect.inset(inset, inset);
float[] intervals=new float[]{3.1415f*radius*0.5f+additionalLength*2f, tmpRect.width()-radius*2f-additionalLength*2f};
paint.setPathEffect(new DashPathEffect(intervals, intervals[0]-additionalLength));
updateParticleEmitter();
}
}
private class TouchDismissListener implements View.OnTouchListener{
private Rect tmpRect=new Rect();
private int[] xy={0, 0};
private boolean dragging;
private float dragDownY;
private VelocityTracker velocityTracker;
private SpringAnimation springBackAnim;
@Override
public boolean onTouch(View v, MotionEvent ev){
if(ev.getAction()==MotionEvent.ACTION_DOWN){
codeContainer.getLocationInWindow(xy);
tmpRect.set(xy[0], xy[1], xy[0]+codeContainer.getWidth(), xy[1]+codeContainer.getHeight());
if(springBackAnim!=null){
springBackAnim.skipToEnd();
}
if(tmpRect.contains((int)ev.getX(), (int)ev.getY())){
dragging=true;
dragDownY=ev.getY();
velocityTracker=VelocityTracker.obtain();
velocityTracker.addMovement(ev);
}else{
dismiss();
}
}else if(dragging){
if(ev.getAction()==MotionEvent.ACTION_MOVE){
float transY=ev.getY()-dragDownY;
particleAnimContainer.setTranslationY(transY);
float alpha=1f-Math.abs(transY)/particleAnimContainer.getHeight();
scrim.setAlpha(Math.round(alpha*255));
getToolbar().setAlpha(alpha);
velocityTracker.addMovement(ev);
}else if(ev.getAction()==MotionEvent.ACTION_UP){
dragging=false;
velocityTracker.addMovement(ev);
velocityTracker.computeCurrentVelocity(1000);
float velocity=velocityTracker.getYVelocity();
if(Math.abs(velocity)>=V.dp(1000) || Math.abs(particleAnimContainer.getTranslationY())>particleAnimContainer.getHeight()/4f){
dismissWithAnimation(ProfileQrCodeFragment.super::dismiss, velocity>0);
}else{
springBack(velocity);
}
velocityTracker.recycle();
velocityTracker=null;
}else if(ev.getAction()==MotionEvent.ACTION_CANCEL){
dragging=false;
springBack(velocityTracker.getYVelocity());
velocityTracker.recycle();
velocityTracker=null;
}
}
return true;
}
private void springBack(float velocityY){
SpringAnimation anim=new SpringAnimation(particleAnimContainer, DynamicAnimation.TRANSLATION_Y, 0);
anim.getSpring().setStiffness(SpringForce.STIFFNESS_LOW).setDampingRatio(SpringForce.DAMPING_RATIO_NO_BOUNCY);
anim.setStartVelocity(velocityY);
anim.addEndListener((animation, canceled, value, velocity)->springBackAnim=null);
anim.addUpdateListener((animation, value, velocity)->{
float alpha=1f-Math.abs(particleAnimContainer.getTranslationY())/particleAnimContainer.getHeight();
scrim.setAlpha(Math.round(alpha*255));
getToolbar().setAlpha(alpha);
});
springBackAnim=anim;
anim.start();
}
}
}

View File

@@ -34,6 +34,7 @@ import org.joinmastodon.android.ui.views.SizeListenerFrameLayout;
import org.parceler.Parcels;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.ThreadLocalRandom;
import androidx.annotation.Nullable;
@@ -260,10 +261,10 @@ public class SplashFragment extends AppKitFragment{
private void loadAndChooseDefaultServer(){
ClipData clipData=getActivity().getSystemService(ClipboardManager.class).getPrimaryClip();
if(clipData!=null && clipData.getItemCount()>0){
CharSequence clipText=clipData.getItemAt(0).coerceToText(getActivity());
if(HtmlParser.INVITE_LINK_PATTERN.matcher(clipText).find()){
currentInviteLink=Uri.parse(clipText.toString());
defaultServerButton.setText(getString(R.string.join_server_x_with_invite, currentInviteLink.getHost()));
String clipText=clipData.getItemAt(0).coerceToText(getActivity()).toString();
if(HtmlParser.isValidInviteUrl(clipText)){
currentInviteLink=Uri.parse(clipText);
defaultServerButton.setText(getString(R.string.join_server_x_with_invite, HtmlParser.normalizeDomain(Objects.requireNonNull(currentInviteLink.getHost()))));
}
}else{
loadingDefaultServer=true;
@@ -315,7 +316,7 @@ public class SplashFragment extends AppKitFragment{
if(defaultServerButton!=null && getActivity()!=null && currentInviteLink==null){
defaultServerButton.setTextVisible(true);
defaultServerProgress.setVisibility(View.GONE);
defaultServerButton.setText(getString(R.string.join_default_server, chosenDefaultServer));
defaultServerButton.setText(getString(R.string.join_default_server, HtmlParser.normalizeDomain(chosenDefaultServer)));
}
}
}

View File

@@ -151,7 +151,7 @@ public class ThreadFragment extends StatusListFragment{
replyButton.setOnClickListener(v->openReply());
Account self=AccountSessionManager.get(accountID).self;
if(!TextUtils.isEmpty(self.avatar)){
ViewImageLoader.loadWithoutAnimation(replyButtonAva, getResources().getDrawable(R.drawable.image_placeholder), new UrlImageLoaderRequest(self.avatar, V.dp(24), V.dp(24)));
ViewImageLoader.loadWithoutAnimation(replyButtonAva, getResources().getDrawable(R.drawable.image_placeholder, getActivity().getTheme()), new UrlImageLoaderRequest(self.avatar, V.dp(24), V.dp(24)));
}
UiUtils.loadCustomEmojiInTextView(toolbarTitleView);
showContent();

View File

@@ -1,37 +0,0 @@
package org.joinmastodon.android.fragments.account_list;
import android.os.Bundle;
import org.joinmastodon.android.R;
import org.joinmastodon.android.api.requests.accounts.SearchAccounts;
import org.joinmastodon.android.model.Account;
import java.util.List;
import me.grishka.appkit.api.SimpleCallback;
public class AddListMembersFragment extends AccountSearchFragment{
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
dataLoaded();
}
@Override
protected void doLoadData(int offset, int count){
refreshing=true;
currentRequest=new SearchAccounts(currentQuery, 0, 0, false, true)
.setCallback(new SimpleCallback<>(this){
@Override
public void onSuccess(List<Account> result){
AddListMembersFragment.this.onSuccess(result);
}
})
.exec(accountID);
}
@Override
protected String getSearchViewPlaceholder(){
return getString(R.string.search_among_people_you_follow);
}
}

View File

@@ -1,6 +1,9 @@
package org.joinmastodon.android.fragments.discover;
import android.app.Activity;
import android.app.Fragment;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.text.TextUtils;
@@ -11,9 +14,14 @@ import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import org.joinmastodon.android.MainActivity;
import org.joinmastodon.android.R;
import org.joinmastodon.android.fragments.ScrollableToTop;
import org.joinmastodon.android.googleservices.GmsClient;
import org.joinmastodon.android.googleservices.barcodescanner.Barcode;
import org.joinmastodon.android.googleservices.barcodescanner.BarcodeScanner;
import org.joinmastodon.android.model.SearchResult;
import org.joinmastodon.android.ui.OutlineProviders;
import org.joinmastodon.android.ui.SimpleViewHolder;
@@ -33,6 +41,7 @@ import me.grishka.appkit.utils.V;
public class DiscoverFragment extends AppKitFragment implements ScrollableToTop, OnBackPressedListener{
private static final int QUERY_RESULT=937;
private static final int SCAN_RESULT=456;
private TabLayout tabLayout;
private ViewPager2 pager;
@@ -40,7 +49,7 @@ public class DiscoverFragment extends AppKitFragment implements ScrollableToTop,
private TabLayoutMediator tabLayoutMediator;
private boolean searchActive;
private FrameLayout searchView;
private ImageButton searchBack;
private ImageButton searchBack, searchScanQR;
private TextView searchText;
private View tabsDivider;
@@ -52,6 +61,7 @@ public class DiscoverFragment extends AppKitFragment implements ScrollableToTop,
private String accountID;
private String currentQuery;
private Intent scannerIntent;
@Override
public void onCreate(Bundle savedInstanceState){
@@ -60,6 +70,7 @@ public class DiscoverFragment extends AppKitFragment implements ScrollableToTop,
setRetainInstance(true);
accountID=getArguments().getString("account");
scannerIntent=BarcodeScanner.createIntent(Barcode.FORMAT_QR_CODE, false, true);
}
@Nullable
@@ -169,11 +180,17 @@ public class DiscoverFragment extends AppKitFragment implements ScrollableToTop,
searchBack.setImportantForAccessibility(searchActive ? View.IMPORTANT_FOR_ACCESSIBILITY_YES : View.IMPORTANT_FOR_ACCESSIBILITY_NO);
searchBack.setOnClickListener(v->exitSearch());
if(searchActive){
searchBack.setImageResource(R.drawable.ic_arrow_back);
searchBack.setImageResource(me.grishka.appkit.R.drawable.ic_arrow_back);
pager.setVisibility(View.GONE);
tabLayout.setVisibility(View.GONE);
searchView.setVisibility(View.VISIBLE);
}
searchScanQR=view.findViewById(R.id.search_scan_qr);
if(!GmsClient.isGooglePlayServicesAvailable(getActivity())){
searchScanQR.setVisibility(View.GONE);
}else{
searchScanQR.setOnClickListener(v->openQrScanner());
}
View searchWrap=view.findViewById(R.id.search_wrap);
searchWrap.setOutlineProvider(OutlineProviders.roundedRect(28));
@@ -211,7 +228,7 @@ public class DiscoverFragment extends AppKitFragment implements ScrollableToTop,
pager.setVisibility(View.GONE);
tabLayout.setVisibility(View.GONE);
searchView.setVisibility(View.VISIBLE);
searchBack.setImageResource(R.drawable.ic_arrow_back);
searchBack.setImageResource(me.grishka.appkit.R.drawable.ic_arrow_back);
searchBack.setEnabled(true);
searchBack.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
tabsDivider.setVisibility(View.GONE);
@@ -268,6 +285,28 @@ public class DiscoverFragment extends AppKitFragment implements ScrollableToTop,
}
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data){
if(requestCode==SCAN_RESULT && resultCode==Activity.RESULT_OK && BarcodeScanner.isValidResult(data)){
Barcode code=BarcodeScanner.getResult(data);
if(code!=null){
if(code.rawValue.startsWith("https:") || code.rawValue.startsWith("http:")){
((MainActivity)getActivity()).handleURL(Uri.parse(code.rawValue), accountID);
}else{
Toast.makeText(getActivity(), R.string.link_not_supported, Toast.LENGTH_SHORT).show();
}
}
}
}
private void openQrScanner(){
if(scannerIntent.resolveActivity(getActivity().getPackageManager())!=null){
startActivityForResult(scannerIntent, SCAN_RESULT);
}else{
BarcodeScanner.installScannerModule(getActivity(), ()->startActivityForResult(scannerIntent, SCAN_RESULT));
}
}
private class DiscoverPagerAdapter extends RecyclerView.Adapter<SimpleViewHolder>{
@NonNull
@Override

View File

@@ -1,5 +1,6 @@
package org.joinmastodon.android.fragments.discover;
import android.annotation.SuppressLint;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
@@ -18,6 +19,7 @@ import org.joinmastodon.android.ui.DividerItemDecoration;
import org.joinmastodon.android.ui.OutlineProviders;
import org.joinmastodon.android.ui.drawables.BlurhashCrossfadeDrawable;
import org.joinmastodon.android.ui.utils.DiscoverInfoBannerHelper;
import org.joinmastodon.android.ui.utils.HorizontalScrollingTouchListener;
import org.joinmastodon.android.ui.utils.UiUtils;
import java.util.ArrayList;
@@ -81,6 +83,7 @@ public class DiscoverNewsFragment extends BaseRecyclerFragment<CardViewModel> im
.exec(accountID);
}
@SuppressLint("ClickableViewAccessibility")
@Override
protected RecyclerView.Adapter getAdapter(){
cardsList=new UsableRecyclerView(getActivity());
@@ -98,6 +101,7 @@ public class DiscoverNewsFragment extends BaseRecyclerFragment<CardViewModel> im
});
cardsList.setSelector(R.drawable.bg_rect_12dp_ripple);
cardsList.setDrawSelectorOnTop(true);
cardsList.setOnTouchListener(new HorizontalScrollingTouchListener(getActivity()));
mergeAdapter=new MergeRecyclerAdapter();
bannerHelper.maybeAddBanner(list, mergeAdapter);

View File

@@ -166,7 +166,7 @@ public class SearchQueryFragment extends MastodonRecyclerFragment<SearchResultVi
navigationIcon=new LayerDrawable(new Drawable[]{
searchIcon=getToolbarContext().getResources().getDrawable(R.drawable.ic_search_24px, getToolbarContext().getTheme()).mutate(),
backIcon=getToolbarContext().getResources().getDrawable(R.drawable.ic_arrow_back, getToolbarContext().getTheme()).mutate()
backIcon=getToolbarContext().getResources().getDrawable(me.grishka.appkit.R.drawable.ic_arrow_back, getToolbarContext().getTheme()).mutate()
}){
@Override
public Drawable mutate(){

View File

@@ -370,7 +370,7 @@ public class InstanceCatalogSignupFragment extends InstanceCatalogFragment imple
protected void proceedWithAuthOrSignup(Instance instance){
if(currentInviteLinkAlert!=null){
currentInviteLinkAlert.dismiss();
}else if(!TextUtils.isEmpty(currentSearchQuery) && HtmlParser.INVITE_LINK_PATTERN.matcher(currentSearchQueryButWithCasePreserved).find()){
}else if(!TextUtils.isEmpty(currentSearchQuery) && HtmlParser.isValidInviteUrl(currentSearchQueryButWithCasePreserved)){
if(TextUtils.isEmpty(inviteCode) || !Objects.equals(instance.uri, inviteCodeHost)){
Uri inviteLink=Uri.parse(currentSearchQueryButWithCasePreserved);
new CheckInviteLink(inviteLink.getPath())
@@ -543,8 +543,8 @@ public class InstanceCatalogSignupFragment extends InstanceCatalogFragment imple
ClipData clipData=getActivity().getSystemService(ClipboardManager.class).getPrimaryClip();
if(clipData!=null && clipData.getItemCount()>0){
CharSequence clipText=clipData.getItemAt(0).coerceToText(getActivity());
if(HtmlParser.INVITE_LINK_PATTERN.matcher(clipText).find()){
String clipText=clipData.getItemAt(0).coerceToText(getActivity()).toString();
if(HtmlParser.isValidInviteUrl(clipText)){
edit.setText(clipText);
supportingText.setText(R.string.invite_link_pasted);
}

View File

@@ -81,7 +81,7 @@ public class ReportAddPostsChoiceFragment extends StatusListFragment{
@Override
protected void doLoadData(int offset, int count){
currentRequest=new GetAccountStatuses(reportAccount.id, offset>0 ? getMaxID() : null, null, count, GetAccountStatuses.Filter.OWN_POSTS_AND_REPLIES)
currentRequest=new GetAccountStatuses(reportAccount.id, offset>0 ? getMaxID() : null, null, count, GetAccountStatuses.Filter.OWN_POSTS_AND_REPLIES, null)
.setCallback(new SimpleCallback<>(this){
@Override
public void onSuccess(List<Status> result){

View File

@@ -125,41 +125,40 @@ public class EditFilterFragment extends BaseSettingsFragment<Void> implements On
ArrayList<String> options=Arrays.stream(durationOptions).mapToObj(d->UiUtils.formatDuration(getActivity(), d)).collect(Collectors.toCollection(ArrayList<String>::new));
options.add(0, getString(R.string.filter_duration_forever));
options.add(getString(R.string.filter_duration_custom));
Instant[] newEnd={null};
boolean[] isCustom={false};
AlertDialog alert=new M3AlertDialogBuilder(getActivity())
.setTitle(R.string.settings_filter_duration_title)
.setSupportingText(endsAt==null ? null : getString(R.string.settings_filter_ends, UiUtils.formatRelativeTimestampAsMinutesAgo(getActivity(), endsAt, false)))
.setSingleChoiceItems(options.toArray(new String[0]), -1, (dlg, item)->{
AlertDialog a=(AlertDialog) dlg;
if(item==options.size()-1){ // custom
showCustomDurationAlert(isCustom[0] ? newEnd[0] : null, date->{
showCustomDurationAlert(null, date->{
if(date==null){
a.getListView().setItemChecked(item, false);
}else{
isCustom[0]=true;
newEnd[0]=date;
a.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(true);
Instant newEnd=date;
if(!Objects.equals(endsAt, newEnd)){
endsAt=newEnd;
updateDurationItem();
dirty=true;
}
a.dismiss();
}
});
}else{
isCustom[0]=false;
Instant newEnd;
if(item==0){
newEnd[0]=null;
newEnd=null;
}else{
newEnd[0]=Instant.now().plusSeconds(durationOptions[item-1]);
newEnd=Instant.now().plusSeconds(durationOptions[item-1]);
}
a.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(true);
if(!Objects.equals(endsAt, newEnd)){
endsAt=newEnd;
updateDurationItem();
dirty=true;
}
a.dismiss();
}
})
.setPositiveButton(R.string.ok, (dlg, item)->{
if(!Objects.equals(endsAt, newEnd[0])){
endsAt=newEnd[0];
updateDurationItem();
dirty=true;
}
})
.setNegativeButton(R.string.cancel, null)
.show();
alert.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false);
}

View File

@@ -37,14 +37,14 @@ import me.grishka.appkit.fragments.OnBackPressedListener;
import me.grishka.appkit.utils.V;
public class FilterWordsFragment extends BaseSettingsFragment<FilterKeyword> implements OnBackPressedListener{
private ImageButton fab;
private Button fab;
private ActionMode actionMode;
private ArrayList<ListItem<FilterKeyword>> selectedItems=new ArrayList<>();
private ArrayList<String> deletedItemIDs=new ArrayList<>();
private MenuItem deleteItem;
public FilterWordsFragment(){
setListLayoutId(R.layout.recycler_fragment_with_fab);
setListLayoutId(R.layout.recycler_fragment_with_text_fab);
}
@Override
@@ -92,18 +92,14 @@ public class FilterWordsFragment extends BaseSettingsFragment<FilterKeyword> imp
public void onViewCreated(View view, Bundle savedInstanceState){
super.onViewCreated(view, savedInstanceState);
fab=view.findViewById(R.id.fab);
fab.setImageResource(R.drawable.ic_add_24px);
fab.setContentDescription(getString(R.string.add_muted_word));
fab.setCompoundDrawablesRelativeWithIntrinsicBounds(R.drawable.ic_add_24px, 0, 0, 0);
fab.setText(R.string.add_muted_word_short);
fab.setOnClickListener(v->onFabClick());
}
@Override
public void onApplyWindowInsets(WindowInsets insets){
int fabInset=0;
if(Build.VERSION.SDK_INT>=29 && insets.getTappableElementInsets().bottom==0){
fabInset=insets.getSystemWindowInsetBottom();
}
((ViewGroup.MarginLayoutParams) fab.getLayoutParams()).bottomMargin=V.dp(16)+fabInset;
UiUtils.applyBottomInsetToFAB(fab, insets);
super.onApplyWindowInsets(insets);
}

View File

@@ -1,6 +1,15 @@
package org.joinmastodon.android.fragments.settings;
import android.app.AlertDialog;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import org.joinmastodon.android.GlobalUserPreferences;
import org.joinmastodon.android.R;
@@ -15,9 +24,12 @@ import org.joinmastodon.android.ui.viewcontrollers.ComposeLanguageAlertViewContr
import java.util.List;
import java.util.Locale;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
public class SettingsBehaviorFragment extends BaseSettingsFragment<Void>{
private ListItem<Void> languageItem;
private CheckableListItem<Void> altTextItem, playGifsItem, customTabsItem, confirmUnfollowItem, confirmBoostItem, confirmDeleteItem;
private ListItem<Void> languageItem, customTabsItem;
private CheckableListItem<Void> altTextItem, playGifsItem, confirmUnfollowItem, confirmBoostItem, confirmDeleteItem;
private Locale postLanguage;
private ComposeLanguageAlertViewController.SelectedOption newPostLanguage;
@@ -33,9 +45,9 @@ public class SettingsBehaviorFragment extends BaseSettingsFragment<Void>{
onDataLoaded(List.of(
languageItem=new ListItem<>(getString(R.string.default_post_language), postLanguage!=null ? postLanguage.getDisplayName(Locale.getDefault()) : null, R.drawable.ic_language_24px, this::onDefaultLanguageClick),
customTabsItem=new ListItem<>(R.string.settings_custom_tabs, GlobalUserPreferences.useCustomTabs ? R.string.in_app_browser : R.string.system_browser, R.drawable.ic_open_in_browser_24px, this::onCustomTabsClick),
altTextItem=new CheckableListItem<>(R.string.settings_alt_text_reminders, 0, CheckableListItem.Style.SWITCH, GlobalUserPreferences.altTextReminders, R.drawable.ic_alt_24px, this::toggleCheckableItem),
playGifsItem=new CheckableListItem<>(R.string.settings_gif, 0, CheckableListItem.Style.SWITCH, GlobalUserPreferences.playGifs, R.drawable.ic_animation_24px, this::toggleCheckableItem),
customTabsItem=new CheckableListItem<>(R.string.settings_custom_tabs, 0, CheckableListItem.Style.SWITCH, GlobalUserPreferences.useCustomTabs, R.drawable.ic_open_in_browser_24px, this::toggleCheckableItem),
confirmUnfollowItem=new CheckableListItem<>(R.string.settings_confirm_unfollow, 0, CheckableListItem.Style.SWITCH, GlobalUserPreferences.confirmUnfollow, R.drawable.ic_person_remove_24px, this::toggleCheckableItem),
confirmBoostItem=new CheckableListItem<>(R.string.settings_confirm_boost, 0, CheckableListItem.Style.SWITCH, GlobalUserPreferences.confirmBoost, R.drawable.ic_repeat_24px, this::toggleCheckableItem),
confirmDeleteItem=new CheckableListItem<>(R.string.settings_confirm_delete_post, 0, CheckableListItem.Style.SWITCH, GlobalUserPreferences.confirmDeletePost, R.drawable.ic_delete_24px, this::toggleCheckableItem)
@@ -46,19 +58,61 @@ public class SettingsBehaviorFragment extends BaseSettingsFragment<Void>{
protected void doLoadData(int offset, int count){}
private void onDefaultLanguageClick(ListItem<?> item){
ComposeLanguageAlertViewController vc=new ComposeLanguageAlertViewController(getActivity(), null, new ComposeLanguageAlertViewController.SelectedOption(-1, postLanguage), null);
new M3AlertDialogBuilder(getActivity())
ComposeLanguageAlertViewController vc=new ComposeLanguageAlertViewController(getActivity(), null, newPostLanguage==null ? new ComposeLanguageAlertViewController.SelectedOption(-1, postLanguage, null) : newPostLanguage, null);
AlertDialog dlg=new M3AlertDialogBuilder(getActivity())
.setTitle(R.string.default_post_language)
.setView(vc.getView())
.setPositiveButton(R.string.ok, (dlg, which)->{
ComposeLanguageAlertViewController.SelectedOption opt=vc.getSelectedOption();
if(!opt.locale.equals(postLanguage)){
newPostLanguage=opt;
languageItem.subtitle=newPostLanguage.locale.getDisplayLanguage(Locale.getDefault());
rebindItem(languageItem);
}
.setPositiveButton(R.string.cancel, null)
.show();
vc.setSelectionListener(opt->{
if(!opt.locale.equals(postLanguage)){
newPostLanguage=opt;
languageItem.subtitle=newPostLanguage.locale.getDisplayLanguage(Locale.getDefault());
rebindItem(languageItem);
}
dlg.dismiss();
});
}
private void onCustomTabsClick(ListItem<?> item){
// GlobalUserPreferences.useCustomTabs=customTabsItem.checked;
Intent intent=new Intent(Intent.ACTION_VIEW, Uri.parse("http://example.com"));
ResolveInfo info=getActivity().getPackageManager().resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY);
final String browserName;
if(info==null){
browserName="??";
}else{
browserName=info.loadLabel(getActivity().getPackageManager()).toString();
}
ArrayAdapter<CharSequence> adapter=new ArrayAdapter<>(getActivity(), R.layout.item_alert_single_choice_2lines_but_different, R.id.text,
new String[]{getString(R.string.in_app_browser), getString(R.string.system_browser)}){
@Override
public boolean hasStableIds(){
return true;
}
@NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent){
View view=super.getView(position, convertView, parent);
TextView subtitle=view.findViewById(R.id.subtitle);
if(position==0){
subtitle.setVisibility(View.GONE);
}else{
subtitle.setVisibility(View.VISIBLE);
subtitle.setText(browserName);
}
return view;
}
};
new M3AlertDialogBuilder(getActivity())
.setTitle(R.string.settings_custom_tabs)
.setSingleChoiceItems(adapter, GlobalUserPreferences.useCustomTabs ? 0 : 1, (dlg, which)->{
GlobalUserPreferences.useCustomTabs=which==0;
customTabsItem.subtitleRes=GlobalUserPreferences.useCustomTabs ? R.string.in_app_browser : R.string.system_browser;
rebindItem(customTabsItem);
dlg.dismiss();
})
.setNegativeButton(R.string.cancel, null)
.show();
}
@@ -66,9 +120,8 @@ public class SettingsBehaviorFragment extends BaseSettingsFragment<Void>{
protected void onHidden(){
super.onHidden();
GlobalUserPreferences.playGifs=playGifsItem.checked;
GlobalUserPreferences.useCustomTabs=customTabsItem.checked;
GlobalUserPreferences.altTextReminders=altTextItem.checked;
GlobalUserPreferences.confirmUnfollow=customTabsItem.checked;
GlobalUserPreferences.confirmUnfollow=confirmUnfollowItem.checked;
GlobalUserPreferences.confirmBoost=confirmBoostItem.checked;
GlobalUserPreferences.confirmDeletePost=confirmDeleteItem.checked;
GlobalUserPreferences.save();

View File

@@ -86,28 +86,26 @@ public class SettingsDisplayFragment extends BaseSettingsFragment<Void>{
case DARK -> 1;
case AUTO -> 2;
};
int[] newSelected={selected};
new M3AlertDialogBuilder(getActivity())
.setTitle(R.string.settings_theme)
.setSingleChoiceItems((String[])IntStream.of(R.string.theme_light, R.string.theme_dark, R.string.theme_auto).mapToObj(this::getString).toArray(String[]::new),
selected, (dlg, item)->newSelected[0]=item)
.setPositiveButton(R.string.ok, (dlg, item)->{
GlobalUserPreferences.ThemePreference pref=switch(newSelected[0]){
case 0 -> GlobalUserPreferences.ThemePreference.LIGHT;
case 1 -> GlobalUserPreferences.ThemePreference.DARK;
case 2 -> GlobalUserPreferences.ThemePreference.AUTO;
default -> throw new IllegalStateException("Unexpected value: "+newSelected[0]);
};
if(pref!=GlobalUserPreferences.theme){
GlobalUserPreferences.ThemePreference prev=GlobalUserPreferences.theme;
GlobalUserPreferences.theme=pref;
GlobalUserPreferences.save();
themeItem.subtitleRes=getAppearanceValue();
rebindItem(themeItem);
maybeApplyNewThemeRightNow(prev);
}
})
.setNegativeButton(R.string.cancel, null)
selected, (dlg, item)->{
GlobalUserPreferences.ThemePreference pref=switch(item){
case 0 -> GlobalUserPreferences.ThemePreference.LIGHT;
case 1 -> GlobalUserPreferences.ThemePreference.DARK;
case 2 -> GlobalUserPreferences.ThemePreference.AUTO;
default -> throw new IllegalStateException("Unexpected value: "+item);
};
if(pref!=GlobalUserPreferences.theme){
GlobalUserPreferences.ThemePreference prev=GlobalUserPreferences.theme;
GlobalUserPreferences.theme=pref;
GlobalUserPreferences.save();
themeItem.subtitleRes=getAppearanceValue();
rebindItem(themeItem);
maybeApplyNewThemeRightNow(prev);
}
dlg.dismiss();
})
.show();
}

View File

@@ -1,6 +1,9 @@
package org.joinmastodon.android.fragments.settings;
import android.os.Bundle;
import android.view.View;
import android.view.WindowInsets;
import android.widget.Button;
import com.squareup.otto.Subscribe;
@@ -12,6 +15,7 @@ import org.joinmastodon.android.events.SettingsFilterDeletedEvent;
import org.joinmastodon.android.model.Filter;
import org.joinmastodon.android.model.viewmodel.ListItem;
import org.joinmastodon.android.ui.adapters.GenericListItemsAdapter;
import org.joinmastodon.android.ui.utils.UiUtils;
import org.parceler.Parcels;
import java.util.Collections;
@@ -24,6 +28,12 @@ import me.grishka.appkit.api.SimpleCallback;
import me.grishka.appkit.utils.MergeRecyclerAdapter;
public class SettingsFiltersFragment extends BaseSettingsFragment<Filter>{
private Button fab;
public SettingsFiltersFragment(){
setListLayoutId(R.layout.recycler_fragment_with_text_fab);
}
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
@@ -44,6 +54,8 @@ public class SettingsFiltersFragment extends BaseSettingsFragment<Filter>{
.setCallback(new SimpleCallback<>(this){
@Override
public void onSuccess(List<Filter> result){
if(getActivity()==null)
return;
onDataLoaded(result.stream().map(f->makeListItem(f)).collect(Collectors.toList()));
}
})
@@ -51,13 +63,12 @@ public class SettingsFiltersFragment extends BaseSettingsFragment<Filter>{
}
@Override
protected RecyclerView.Adapter<?> getAdapter(){
MergeRecyclerAdapter adapter=new MergeRecyclerAdapter();
adapter.addAdapter(super.getAdapter());
adapter.addAdapter(new GenericListItemsAdapter<>(Collections.singletonList(
new ListItem<Void>(R.string.settings_add_filter, 0, R.drawable.ic_add_24px, this::onAddFilterClick)
)));
return adapter;
public void onViewCreated(View view, Bundle savedInstanceState){
super.onViewCreated(view, savedInstanceState);
fab=view.findViewById(R.id.fab);
fab.setText(R.string.settings_add_filter);
fab.setCompoundDrawablesRelativeWithIntrinsicBounds(R.drawable.ic_add_24px, 0, 0, 0);
fab.setOnClickListener(v->onAddFilterClick());
}
private void onFilterClick(ListItem<Filter> filter){
@@ -67,7 +78,7 @@ public class SettingsFiltersFragment extends BaseSettingsFragment<Filter>{
Nav.go(getActivity(), EditFilterFragment.class, args);
}
private void onAddFilterClick(ListItem<?> item){
private void onAddFilterClick(){
Bundle args=new Bundle();
args.putString("account", accountID);
Nav.go(getActivity(), EditFilterFragment.class, args);
@@ -107,4 +118,10 @@ public class SettingsFiltersFragment extends BaseSettingsFragment<Filter>{
data.add(makeListItem(ev.filter));
itemsAdapter.notifyItemInserted(data.size()-1);
}
@Override
public void onApplyWindowInsets(WindowInsets insets){
UiUtils.applyBottomInsetToFAB(fab, insets);
super.onApplyWindowInsets(insets);
}
}

View File

@@ -192,18 +192,13 @@ public class SettingsNotificationsFragment extends BaseSettingsFragment<Void>{
3*24*3600,
7*24*3600
};
int[] selectedOption={0};
AlertDialog alert=new M3AlertDialogBuilder(getActivity())
.setTitle(R.string.pause_all_notifications_title)
.setSupportingText(time>System.currentTimeMillis() ? getString(R.string.pause_notifications_ends, UiUtils.formatRelativeTimestampAsMinutesAgo(getActivity(), Instant.ofEpochMilli(time), false)) : null)
.setSingleChoiceItems((String[])Arrays.stream(durationOptions).mapToObj(d->UiUtils.formatDuration(getActivity(), d)).toArray(String[]::new), -1, (dlg, item)->{
if(selectedOption[0]==0){
((AlertDialog)dlg).getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(true);
}
selectedOption[0]=durationOptions[item];
AccountSessionManager.get(accountID).getLocalPreferences().setNotificationsPauseEndTime(System.currentTimeMillis()+durationOptions[item]*1000L);
dlg.dismiss();
})
.setPositiveButton(R.string.ok, (dlg, item)->AccountSessionManager.get(accountID).getLocalPreferences().setNotificationsPauseEndTime(System.currentTimeMillis()+selectedOption[0]*1000L))
.setNegativeButton(R.string.cancel, null)
.show();
alert.setOnDismissListener(dialog->updatePauseItem());
alert.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false);
@@ -216,20 +211,18 @@ public class SettingsNotificationsFragment extends BaseSettingsFragment<Void>{
R.string.notifications_policy_follower,
R.string.notifications_policy_no_one
).map(this::getString).toArray(String[]::new);
int[] selectedItem={getPushSubscription().policy.ordinal()};
new M3AlertDialogBuilder(getActivity())
.setTitle(R.string.settings_notifications_policy)
.setSingleChoiceItems(items, selectedItem[0], (dlg, which)->selectedItem[0]=which)
.setPositiveButton(R.string.ok, (dlg, which)->{
.setSingleChoiceItems(items, getPushSubscription().policy.ordinal(), (dlg, which)->{
dlg.dismiss();
PushSubscription.Policy prevValue=getPushSubscription().policy;
PushSubscription.Policy newValue=PushSubscription.Policy.values()[selectedItem[0]];
PushSubscription.Policy newValue=PushSubscription.Policy.values()[which];
if(prevValue==newValue)
return;
getPushSubscription().policy=newValue;
updatePolicyItem(prevValue);
needUpdateNotificationSettings=true;
})
.setNegativeButton(R.string.cancel, null)
.show();
}

View File

@@ -0,0 +1,47 @@
package org.joinmastodon.android.googleservices;
import android.app.PendingIntent;
import org.microg.safeparcel.AutoSafeParcelable;
import org.microg.safeparcel.SafeParceled;
public class ConnectionResult extends AutoSafeParcelable{
public static final int UNKNOWN = -1;
public static final int SUCCESS = 0;
public static final int SERVICE_MISSING = 1;
public static final int SERVICE_VERSION_UPDATE_REQUIRED = 2;
public static final int SERVICE_DISABLED = 3;
public static final int SIGN_IN_REQUIRED = 4;
public static final int INVALID_ACCOUNT = 5;
public static final int RESOLUTION_REQUIRED = 6;
public static final int NETWORK_ERROR = 7;
public static final int INTERNAL_ERROR = 8;
public static final int SERVICE_INVALID = 9;
public static final int DEVELOPER_ERROR = 10;
public static final int LICENSE_CHECK_FAILED = 11;
public static final int CANCELED = 13;
public static final int TIMEOUT = 14;
public static final int INTERRUPTED = 15;
public static final int API_UNAVAILABLE = 16;
public static final int SIGN_IN_FAILED = 17;
public static final int SERVICE_UPDATING = 18;
public static final int SERVICE_MISSING_PERMISSION = 19;
public static final int RESTRICTED_PROFILE = 20;
public static final int RESOLUTION_ACTIVITY_NOT_FOUND = 22;
public static final int API_DISABLED = 23;
public static final int API_DISABLED_FOR_CONNECTION = 24;
@Deprecated
public static final int DRIVE_EXTERNAL_STORAGE_REQUIRED = 1500;
@SafeParceled(1)
public int versionCode;
@SafeParceled(2)
public int errorCode;
@SafeParceled(3)
public PendingIntent resolution;
@SafeParceled(4)
public String errorMessage;
public static final Creator<ConnectionResult> CREATOR=new AutoCreator<>(ConnectionResult.class);
}

View File

@@ -0,0 +1,116 @@
package org.joinmastodon.android.googleservices;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
import android.os.IBinder;
import android.os.IInterface;
import android.os.RemoteException;
import android.util.Log;
import android.util.SparseArray;
import com.google.android.gms.common.internal.ConnectionInfo;
import com.google.android.gms.common.internal.GetServiceRequest;
import com.google.android.gms.common.internal.IGmsCallbacks;
import com.google.android.gms.common.internal.IGmsServiceBroker;
import com.google.android.gms.common.moduleinstall.internal.IModuleInstallService;
import java.util.function.Function;
public class GmsClient{
private static final String TAG="GmsClient";
private static final SparseArray<ServiceConnection> currentConnections=new SparseArray<>();
private static int nextConnectionID=0;
public static <I extends IInterface> void connectToService(Context context, String action, int id, boolean useDynamicLookup, ServiceConnectionCallback<I> callback, Function<IBinder, I> asInterface){
Intent intent;
if(useDynamicLookup){
try{
Bundle args=new Bundle();
args.putString("serviceActionBundleKey", action);
Bundle result=context.getContentResolver().call(new Uri.Builder().scheme("content").authority("com.google.android.gms.chimera").build(), "serviceIntentCall", null, args);
if(result==null)
throw new IllegalStateException("Dynamic lookup failed");
intent=result.getParcelable("serviceResponseIntentKey");
if(intent==null)
throw new IllegalStateException("Dynamic lookup returned null");
}catch(Exception x){
callback.onError(x);
return;
}
}else{
intent=new Intent(action);
}
intent.setPackage("com.google.android.gms");
ServiceConnection conn=new ServiceConnection(){
@Override
public void onServiceConnected(ComponentName name, IBinder service){
IGmsServiceBroker broker=IGmsServiceBroker.Stub.asInterface(service);
GetServiceRequest req=new GetServiceRequest();
req.serviceId=id;
req.packageName=context.getPackageName();
ServiceConnection serviceConnectionThis=this;
try{
broker.getService(new IGmsCallbacks.Stub(){
@Override
public void onPostInitComplete(int statusCode, IBinder binder, Bundle params) throws RemoteException{
int connectionID=nextConnectionID++;
currentConnections.put(connectionID, serviceConnectionThis);
callback.onSuccess(asInterface.apply(binder), connectionID);
}
@Override
public void onAccountValidationComplete(int statusCode, Bundle params) throws RemoteException{}
@Override
public void onPostInitCompleteWithConnectionInfo(int statusCode, IBinder binder, ConnectionInfo info) throws RemoteException{
onPostInitComplete(statusCode, binder, info!=null ? info.params : null);
}
}, req);
}catch(Exception x){
callback.onError(x);
context.unbindService(this);
}
}
@Override
public void onServiceDisconnected(ComponentName name){}
};
boolean res=context.bindService(intent, conn, Context.BIND_AUTO_CREATE | Context.BIND_DEBUG_UNBIND | Context.BIND_ADJUST_WITH_ACTIVITY);
if(!res){
context.unbindService(conn);
callback.onError(new IllegalStateException("Service connection failed"));
}
}
public static void disconnectFromService(Context context, int connectionID){
ServiceConnection conn=currentConnections.get(connectionID);
if(conn!=null){
currentConnections.remove(connectionID);
context.unbindService(conn);
}
}
public static boolean isGooglePlayServicesAvailable(Context context){
PackageManager pm=context.getPackageManager();
try{
pm.getPackageInfo("com.google.android.gms", 0);
return true;
}catch(PackageManager.NameNotFoundException e){
return false;
}
}
public static void getModuleInstallerService(Context context, ServiceConnectionCallback<IModuleInstallService> callback){
connectToService(context, "com.google.android.gms.chimera.container.moduleinstall.ModuleInstallService.START", 308, true, callback, IModuleInstallService.Stub::asInterface);
}
public interface ServiceConnectionCallback<I extends IInterface>{
void onSuccess(I service, int connectionID);
void onError(Exception error);
}
}

View File

@@ -0,0 +1,253 @@
package org.joinmastodon.android.googleservices.barcodescanner;
import android.graphics.Point;
import org.microg.safeparcel.AutoSafeParcelable;
import org.microg.safeparcel.SafeParceled;
public class Barcode extends AutoSafeParcelable{
public static final int FORMAT_UNKNOWN = -1;
public static final int FORMAT_ALL_FORMATS = 0;
public static final int FORMAT_CODE_128 = 1;
public static final int FORMAT_CODE_39 = 2;
public static final int FORMAT_CODE_93 = 4;
public static final int FORMAT_CODABAR = 8;
public static final int FORMAT_DATA_MATRIX = 16;
public static final int FORMAT_EAN_13 = 32;
public static final int FORMAT_EAN_8 = 64;
public static final int FORMAT_ITF = 128;
public static final int FORMAT_QR_CODE = 256;
public static final int FORMAT_UPC_A = 512;
public static final int FORMAT_UPC_E = 1024;
public static final int FORMAT_PDF417 = 2048;
public static final int FORMAT_AZTEC = 4096;
public static final int TYPE_UNKNOWN = 0;
public static final int TYPE_CONTACT_INFO = 1;
public static final int TYPE_EMAIL = 2;
public static final int TYPE_ISBN = 3;
public static final int TYPE_PHONE = 4;
public static final int TYPE_PRODUCT = 5;
public static final int TYPE_SMS = 6;
public static final int TYPE_TEXT = 7;
public static final int TYPE_URL = 8;
public static final int TYPE_WIFI = 9;
public static final int TYPE_GEO = 10;
public static final int TYPE_CALENDAR_EVENT = 11;
public static final int TYPE_DRIVER_LICENSE = 12;
@SafeParceled(1)
public int format;
@SafeParceled(2)
public String displayValue;
@SafeParceled(3)
public String rawValue;
@SafeParceled(4)
public byte[] rawBytes;
@SafeParceled(5)
public Point[] cornerPoints;
@SafeParceled(6)
public int valueType;
@SafeParceled(7)
public Email emailValue;
@SafeParceled(8)
public Phone phoneValue;
@SafeParceled(9)
public SMS smsValue;
@SafeParceled(10)
public WiFi wifiValue;
@SafeParceled(11)
public UrlBookmark urlBookmarkValue;
@SafeParceled(12)
public GeoPoint geoPointValue;
@SafeParceled(13)
public CalendarEvent calendarEventValue;
@SafeParceled(14)
public ContactInfo contactInfoValue;
@SafeParceled(15)
public DriverLicense driverLicenseValue;
public static final Creator<Barcode> CREATOR=new AutoCreator<>(Barcode.class);
// None of the following is needed or used in the Mastodon app and its use cases for QR code scanning,
// but I'm putting it out there in case someone else is crazy enough to want to use Google Services without their libraries
public static class Email extends AutoSafeParcelable{
@SafeParceled(1)
public int type;
@SafeParceled(2)
public String address;
@SafeParceled(3)
public String subject;
@SafeParceled(4)
public String body;
public static final Creator<Email> CREATOR=new AutoCreator<>(Email.class);
}
public static class Phone extends AutoSafeParcelable{
@SafeParceled(1)
public int type;
@SafeParceled(2)
public String number;
public static final Creator<Phone> CREATOR=new AutoCreator<>(Phone.class);
}
public static class SMS extends AutoSafeParcelable{
@SafeParceled(1)
public String message;
@SafeParceled(2)
public String phoneNumber;
public static final Creator<SMS> CREATOR=new AutoCreator<>(SMS.class);
}
public static class WiFi extends AutoSafeParcelable{
@SafeParceled(1)
public String ssid;
@SafeParceled(2)
public String password;
@SafeParceled(3)
public int encryptionType;
public static final Creator<WiFi> CREATOR=new AutoCreator<>(WiFi.class);
}
public static class UrlBookmark extends AutoSafeParcelable{
@SafeParceled(1)
public String title;
@SafeParceled(2)
public String url;
public static final Creator<UrlBookmark> CREATOR=new AutoCreator<>(UrlBookmark.class);
}
public static class GeoPoint extends AutoSafeParcelable{
@SafeParceled(1)
public double lat;
@SafeParceled(2)
public double lng;
public static final Creator<GeoPoint> CREATOR=new AutoCreator<>(GeoPoint.class);
}
public static class EventDateTime extends AutoSafeParcelable{
@SafeParceled(1)
public int year;
@SafeParceled(2)
public int month;
@SafeParceled(3)
public int day;
@SafeParceled(4)
public int hours;
@SafeParceled(5)
public int minutes;
@SafeParceled(6)
public int seconds;
@SafeParceled(7)
public boolean isUtc;
@SafeParceled(8)
public String rawValue;
public static final Creator<EventDateTime> CREATOR=new AutoCreator<>(EventDateTime.class);
}
public static class CalendarEvent extends AutoSafeParcelable{
@SafeParceled(1)
public String summary;
@SafeParceled(2)
public String description;
@SafeParceled(3)
public String location;
@SafeParceled(4)
public String organizer;
@SafeParceled(5)
public String status;
@SafeParceled(6)
public EventDateTime start;
@SafeParceled(7)
public EventDateTime end;
public static final Creator<CalendarEvent> CREATOR=new AutoCreator<>(CalendarEvent.class);
}
public static class Address extends AutoSafeParcelable{
@SafeParceled(1)
public int type;
@SafeParceled(2)
public String[] addressLines;
public static final Creator<Address> CREATOR=new AutoCreator<>(Address.class);
}
public static class PersonName extends AutoSafeParcelable{
@SafeParceled(1)
public String formattedName;
@SafeParceled(2)
public String pronunciation;
@SafeParceled(3)
public String prefix;
@SafeParceled(4)
public String first;
@SafeParceled(5)
public String middle;
@SafeParceled(6)
public String last;
@SafeParceled(7)
public String suffix;
public static final Creator<PersonName> CREATOR=new AutoCreator<>(PersonName.class);
}
public static class ContactInfo extends AutoSafeParcelable{
@SafeParceled(1)
public PersonName name;
@SafeParceled(2)
public String organization;
@SafeParceled(3)
public String title;
@SafeParceled(4)
public Phone[] phones;
@SafeParceled(5)
public Email[] emails;
@SafeParceled(6)
public String[] urls;
@SafeParceled(7)
public Address[] addresses;
public static final Creator<ContactInfo> CREATOR=new AutoCreator<>(ContactInfo.class);
}
public static class DriverLicense extends AutoSafeParcelable{
@SafeParceled(1)
public String documentType;
@SafeParceled(2)
public String firstName;
@SafeParceled(3)
public String middleName;
@SafeParceled(4)
public String lastName;
@SafeParceled(5)
public String gender;
@SafeParceled(6)
public String addressStreet;
@SafeParceled(7)
public String addressCity;
@SafeParceled(8)
public String addressState;
@SafeParceled(9)
public String addressZip;
@SafeParceled(10)
public String licenseNumber;
@SafeParceled(11)
public String issueDate;
@SafeParceled(12)
public String expiryDate;
@SafeParceled(13)
public String birthDate;
@SafeParceled(14)
public String issuingCountry;
public static final Creator<DriverLicense> CREATOR=new AutoCreator<>(DriverLicense.class);
}
}

View File

@@ -0,0 +1,136 @@
package org.joinmastodon.android.googleservices.barcodescanner;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.os.Parcel;
import android.os.RemoteException;
import android.util.Log;
import android.widget.Toast;
import com.google.android.gms.common.Feature;
import com.google.android.gms.common.api.Status;
import com.google.android.gms.common.moduleinstall.ModuleAvailabilityResponse;
import com.google.android.gms.common.moduleinstall.ModuleInstallIntentResponse;
import com.google.android.gms.common.moduleinstall.ModuleInstallResponse;
import com.google.android.gms.common.moduleinstall.ModuleInstallStatusUpdate;
import com.google.android.gms.common.moduleinstall.internal.ApiFeatureRequest;
import com.google.android.gms.common.moduleinstall.internal.IModuleInstallCallbacks;
import com.google.android.gms.common.moduleinstall.internal.IModuleInstallService;
import com.google.android.gms.common.moduleinstall.internal.IModuleInstallStatusListener;
import org.joinmastodon.android.MastodonApp;
import org.joinmastodon.android.R;
import org.joinmastodon.android.googleservices.GmsClient;
import org.joinmastodon.android.ui.utils.UiUtils;
import java.util.List;
public class BarcodeScanner{
private static final String TAG="BarcodeScanner";
public static Intent createIntent(int formats, boolean allowManualInout, boolean enableAutoZoom){
Intent intent=new Intent().setPackage("com.google.android.gms").setAction("com.google.android.gms.mlkit.ACTION_SCAN_BARCODE");
String appName;
ApplicationInfo appInfo=MastodonApp.context.getApplicationInfo();
if(appInfo.labelRes!=0)
appName=MastodonApp.context.getString(appInfo.labelRes);
else
appName=MastodonApp.context.getPackageManager().getApplicationLabel(appInfo).toString();
intent.putExtra("extra_calling_app_name", appName);
intent.putExtra("extra_supported_formats", formats);
intent.putExtra("extra_allow_manual_input", allowManualInout);
intent.putExtra("extra_enable_auto_zoom", enableAutoZoom);
return intent;
}
public static boolean isValidResult(Intent intent){
return intent!=null && intent.hasExtra("extra_barcode_result");
}
public static Barcode getResult(Intent intent){
byte[] serialized=intent.getByteArrayExtra("extra_barcode_result");
Parcel parcel=Parcel.obtain();
parcel.unmarshall(serialized, 0, serialized.length);
parcel.setDataPosition(0);
Barcode barcode=Barcode.CREATOR.createFromParcel(parcel);
parcel.recycle();
return barcode;
}
public static void installScannerModule(Context context, Runnable onSuccess){
ProgressDialog progress=new ProgressDialog(context);
progress.setMessage(context.getString(R.string.loading));
progress.setCancelable(false);
progress.show();
GmsClient.getModuleInstallerService(context, new GmsClient.ServiceConnectionCallback<>(){
@Override
public void onSuccess(IModuleInstallService service, int connectionID){
ApiFeatureRequest req=new ApiFeatureRequest();
req.callingPackage=context.getPackageName();
Feature feature=new Feature();
feature.name="mlkit.barcode.ui";
feature.version=1;
feature.oldVersion=-1;
req.features=List.of(feature);
req.urgent=true;
try{
service.installModules(new IModuleInstallCallbacks.Stub(){
@Override
public void onModuleAvailabilityResponse(Status status, ModuleAvailabilityResponse response) throws RemoteException{}
@Override
public void onModuleInstallResponse(Status status, ModuleInstallResponse response) throws RemoteException{}
@Override
public void onModuleInstallIntentResponse(Status status, ModuleInstallIntentResponse response) throws RemoteException{}
@Override
public void onStatus(Status status) throws RemoteException{}
}, req, new IModuleInstallStatusListener.Stub(){
@Override
public void onModuleInstallStatusUpdate(ModuleInstallStatusUpdate statusUpdate) throws RemoteException{
if(statusUpdate.installState==ModuleInstallStatusUpdate.STATE_COMPLETED){
Intent scannerIntent=createIntent(0, false, false);
Runnable r=new Runnable(){
@Override
public void run(){
if(scannerIntent.resolveActivity(context.getPackageManager())!=null){
progress.dismiss();
onSuccess.run();
}else{
UiUtils.runOnUiThread(this, 100);
}
}
};
UiUtils.runOnUiThread(r);
GmsClient.disconnectFromService(context, connectionID);
}else if(statusUpdate.installState==ModuleInstallStatusUpdate.STATE_FAILED || statusUpdate.installState==ModuleInstallStatusUpdate.STATE_CANCELED){
UiUtils.runOnUiThread(()->{
progress.dismiss();
Toast.makeText(context, R.string.error, Toast.LENGTH_SHORT).show();
});
GmsClient.disconnectFromService(context, connectionID);
}
}
});
}catch(RemoteException e){
Log.e(TAG, "onSuccess: ", e);
UiUtils.runOnUiThread(()->{
progress.dismiss();
Toast.makeText(context, R.string.error, Toast.LENGTH_SHORT).show();
});
GmsClient.disconnectFromService(context, connectionID);
}
}
@Override
public void onError(Exception error){
Log.e(TAG, "onError() called with: error = ["+error+"]");
Toast.makeText(context, R.string.error, Toast.LENGTH_SHORT).show();
progress.dismiss();
}
});
}
}

View File

@@ -60,7 +60,7 @@ public class Status extends BaseModel implements DisplayItemsParent{
public boolean reblogged;
public boolean muted;
public boolean bookmarked;
public boolean pinned;
public Boolean pinned;
public transient boolean spoilerRevealed;
public transient boolean hasGapAfter;

View File

@@ -6,6 +6,7 @@ import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;
import org.joinmastodon.android.R;
@@ -59,6 +60,12 @@ public class M3AlertDialogBuilder extends AlertDialog.Builder{
buttonBar.setPadding(V.dp(16), V.dp(16), V.dp(16), V.dp(16));
((View)buttonBar.getParent()).setPadding(0, 0, 0, 0);
}
if(btn==null || btn.getVisibility()==View.GONE){
ListView list=alert.getListView();
if(list!=null){
list.setPadding(list.getPaddingLeft(), list.getPaddingTop(), list.getPaddingRight(), V.dp(24));
}
}
// hacc
int titleID=getContext().getResources().getIdentifier("title_template", "id", "android");
if(titleID!=0){

View File

@@ -0,0 +1,37 @@
package org.joinmastodon.android.ui;
import android.graphics.Typeface;
import android.os.Build;
import android.util.Property;
import android.widget.TextView;
import androidx.annotation.RequiresApi;
public class ViewProperties{
public static final Property<TextView, Integer> FONT_WEIGHT=new Property<>(Integer.class, "fontWeight"){
@RequiresApi(api = Build.VERSION_CODES.P)
@Override
public Integer get(TextView object){
return object.getTypeface().getWeight();
}
@RequiresApi(api = Build.VERSION_CODES.P)
@Override
public void set(TextView object, Integer value){
// typeface objects are cached internally, I looked at AOSP sources to confirm that
object.setTypeface(Typeface.create(null, value, false));
}
};
public static final Property<TextView, Integer> TEXT_COLOR=new Property<>(Integer.class, "textColor"){
@Override
public Integer get(TextView object){
return object.getCurrentTextColor();
}
@Override
public void set(TextView object, Integer value){
object.setTextColor(value);
}
};
}

View File

@@ -169,7 +169,7 @@ public class FooterStatusDisplayItem extends StatusDisplayItem{
}
private void onShareClick(View v){
UiUtils.openSystemShareSheet(v.getContext(), item.status.url);
UiUtils.openSystemShareSheet(v.getContext(), item.status);
}
private int descriptionForId(int id){

View File

@@ -25,6 +25,7 @@ import org.joinmastodon.android.GlobalUserPreferences;
import org.joinmastodon.android.R;
import org.joinmastodon.android.api.requests.accounts.GetAccountRelationships;
import org.joinmastodon.android.api.requests.statuses.GetStatusSourceText;
import org.joinmastodon.android.api.requests.statuses.SetStatusPinned;
import org.joinmastodon.android.api.session.AccountSessionManager;
import org.joinmastodon.android.fragments.AddAccountToListsFragment;
import org.joinmastodon.android.fragments.BaseStatusListFragment;
@@ -36,6 +37,7 @@ import org.joinmastodon.android.model.Attachment;
import org.joinmastodon.android.model.Relationship;
import org.joinmastodon.android.model.Status;
import org.joinmastodon.android.ui.OutlineProviders;
import org.joinmastodon.android.ui.Snackbar;
import org.joinmastodon.android.ui.text.HtmlParser;
import org.joinmastodon.android.ui.utils.CustomEmojiHelper;
import org.joinmastodon.android.ui.utils.UiUtils;
@@ -197,7 +199,7 @@ public class HeaderStatusDisplayItem extends StatusDisplayItem{
}else if(id==R.id.bookmark){
AccountSessionManager.getInstance().getAccount(item.accountID).getStatusInteractionController().setBookmarked(item.status, !item.status.bookmarked);
}else if(id==R.id.share){
UiUtils.openSystemShareSheet(activity, item.status.url);
UiUtils.openSystemShareSheet(activity, item.status);
}else if(id==R.id.translate){
item.parentFragment.togglePostTranslation(item.status, item.parentID);
}else if(id==R.id.add_to_list){
@@ -208,6 +210,24 @@ public class HeaderStatusDisplayItem extends StatusDisplayItem{
}else if(id==R.id.copy_link){
activity.getSystemService(ClipboardManager.class).setPrimaryClip(ClipData.newPlainText(null, item.status.url));
UiUtils.maybeShowTextCopiedToast(activity);
}else if(id==R.id.pin){
new SetStatusPinned(item.status.id, !item.status.pinned)
.setCallback(new Callback<>(){
@Override
public void onSuccess(Status result){
item.status.pinned=!item.status.pinned;
new Snackbar.Builder(activity)
.setText(item.status.pinned ? R.string.post_pinned : R.string.post_unpinned)
.show();
}
@Override
public void onError(ErrorResponse error){
error.showToast(activity);
}
})
.wrapProgress(activity, R.string.loading, true)
.exec(item.accountID);
}
return true;
});
@@ -293,11 +313,17 @@ public class HeaderStatusDisplayItem extends StatusDisplayItem{
MenuItem report=menu.findItem(R.id.report);
MenuItem follow=menu.findItem(R.id.follow);
MenuItem bookmark=menu.findItem(R.id.bookmark);
MenuItem pin=menu.findItem(R.id.pin);
if(item.status!=null){
bookmark.setVisible(true);
bookmark.setTitle(item.status.bookmarked ? R.string.remove_bookmark : R.string.add_bookmark);
pin.setVisible(item.status.pinned!=null);
if(item.status.pinned!=null){
pin.setTitle(item.status.pinned ? R.string.unpin_post : R.string.pin_post);
}
}else{
bookmark.setVisible(false);
pin.setVisible(false);
}
if(isOwnPost){
mute.setVisible(false);

View File

@@ -17,8 +17,11 @@ import org.joinmastodon.android.model.Card;
import org.joinmastodon.android.model.Status;
import org.joinmastodon.android.ui.OutlineProviders;
import org.joinmastodon.android.ui.drawables.BlurhashCrossfadeDrawable;
import org.joinmastodon.android.ui.text.HtmlParser;
import org.joinmastodon.android.ui.utils.UiUtils;
import java.util.Objects;
import me.grishka.appkit.imageloader.ImageLoaderViewHolder;
import me.grishka.appkit.imageloader.requests.ImageLoaderRequest;
import me.grishka.appkit.imageloader.requests.UrlImageLoaderRequest;
@@ -82,7 +85,7 @@ public class LinkCardStatusDisplayItem extends StatusDisplayItem{
description.setText(card.description);
description.setVisibility(TextUtils.isEmpty(card.description) ? View.GONE : View.VISIBLE);
}
String cardDomain=Uri.parse(card.url).getHost();
String cardDomain=HtmlParser.normalizeDomain(Objects.requireNonNull(Uri.parse(card.url).getHost()));
if(isLarge && !TextUtils.isEmpty(card.authorName)){
domain.setText(itemView.getContext().getString(R.string.article_by_author, card.authorName)+" · "+cardDomain);
}else{

View File

@@ -0,0 +1,149 @@
package org.joinmastodon.android.ui.drawables;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import com.google.zxing.common.BitMatrix;
import java.util.Arrays;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
public class FancyQrCodeDrawable extends Drawable{
private Paint paint=new Paint(Paint.ANTI_ALIAS_FLAG);
private Path path=new Path(), scaledPath=new Path();
private int size, logoOffset, logoSize;
private Drawable logo;
public FancyQrCodeDrawable(BitMatrix code, int color, Drawable logo){
paint.setColor(color);
this.logo=logo;
size=code.getWidth();
addMarker(0, 0);
addMarker(size-7, 0);
addMarker(0, size-7);
float[] radii=new float[8];
logoSize=size/3;
if((size-logoSize)%2!=0){
logoSize--;
}
logoOffset=(size-logoSize)/2;
for(int y=0;y<logoSize;y++){
for(int x=0;x<logoSize;x++){
code.unset(x+logoOffset, y+logoOffset);
}
}
for(int y=0;y<size;y++){
for(int x=0;x<size;x++){
// Skip corner markers because they turn out ugly with this algorithm
if((x<7 && y<7) || (x>size-8 && y<7) || (x<7 && y>size-8)){
continue;
}
if(code.get(x, y)){
boolean t=y>0 && code.get(x, y-1);
boolean b=y<size-1 && code.get(x, y+1);
boolean l=x>0 && code.get(x-1, y);
boolean r=x<size-1 && code.get(x+1, y);
int neighborCount=(l ? 1 : 0)+(t ? 1 : 0)+(r ? 1 : 0)+(b ? 1 : 0);
// Special-case optimizations
if(neighborCount>=3 || (neighborCount==2 && ((l && r) || (t && b)))){ // 3 or 4 neighbors, or part of a straight line
path.addRect(x, y, x+1, y+1, Path.Direction.CW);
continue;
}else if(neighborCount==0){ // No neighbors
path.addCircle(x+0.5f, y+0.5f, 0.5f, Path.Direction.CW);
continue;
}
Arrays.fill(radii, 0);
if(l && t){ // round bottom-right corner
radii[4]=radii[5]=1;
}else if(t && r){ // round bottom-left corner
radii[6]=radii[7]=1;
}else if(r && b){ // round top-left corner
radii[0]=radii[1]=1;
}else if(b && l){ // round top-right corner
radii[2]=radii[3]=1;
}else if(l){ // right side
radii[2]=radii[3]=radii[4]=radii[5]=0.5f;
}else if(t){ // bottom side
radii[4]=radii[5]=radii[6]=radii[7]=0.5f;
}else if(r){ // left side
radii[6]=radii[7]=radii[1]=radii[0]=0.5f;
}else{ // top side
radii[0]=radii[1]=radii[2]=radii[3]=0.5f;
}
path.addRoundRect(x, y, x+1, y+1, radii, Path.Direction.CW);
}
}
}
}
private void addMarker(int x, int y){
path.addRoundRect(x, y, x+7, y+7, 2.38f, 2.38f, Path.Direction.CW);
path.addRoundRect(x+1, y+1, x+6, y+6, 1.33f, 1.33f, Path.Direction.CCW);
path.addRoundRect(x+2, y+2, x+5, y+5, 0.8f, 0.8f, Path.Direction.CW);
}
@Override
public void draw(@NonNull Canvas canvas){
Rect bounds=getBounds();
float factor=Math.min(bounds.width(), bounds.height())/(float)size;
float xOff=0, yOff=0;
float bw=bounds.width(), bh=bounds.height();
if(bw>bh){
xOff=bw/2f-bh/2f;
}else if(bw<bh){
yOff=bh/2f-bw/2f;
}
canvas.save();
canvas.translate(-bounds.left+xOff, -bounds.top+yOff);
canvas.drawPath(scaledPath, paint);
int scaledOffset=Math.round((logoOffset+1)*factor);
int scaledSize=Math.round((logoSize-2)*factor);
logo.setBounds(scaledOffset, scaledOffset, scaledOffset+scaledSize, scaledOffset+scaledSize);
logo.draw(canvas);
canvas.restore();
}
@Override
public void setAlpha(int alpha){
}
@Override
public void setColorFilter(@Nullable ColorFilter colorFilter){
}
@Override
public int getOpacity(){
return PixelFormat.TRANSLUCENT;
}
@Override
public int getIntrinsicWidth(){
return size;
}
@Override
public int getIntrinsicHeight(){
return size;
}
@Override
protected void onBoundsChange(@NonNull Rect bounds){
super.onBoundsChange(bounds);
float factor=Math.min(bounds.width(), bounds.height())/(float)size;
scaledPath.rewind();
Matrix matrix=new Matrix();
matrix.setScale(factor, factor);
scaledPath.addPath(path, matrix);
}
}

View File

@@ -0,0 +1,133 @@
package org.joinmastodon.android.ui.drawables;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.Paint;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.SystemClock;
import java.util.ArrayList;
import java.util.Random;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
public class RadialParticleSystemDrawable extends Drawable{
private long particleLifetime;
private int birthRate;
private int startColor, endColor;
private float velocity, velocityVariance;
private float size;
private ArrayList<Particle> activeParticles=new ArrayList<>(), nextActiveParticles=new ArrayList<>(), pool=new ArrayList<>();
private int emitterX, emitterY;
private Paint paint=new Paint(Paint.ANTI_ALIAS_FLAG);
private float[] linearStartColor, linearEndColor;
private long prevFrameTime;
private Random rand=new Random();
private Rect clipOutBounds=new Rect();
public RadialParticleSystemDrawable(long particleLifetime, int birthRate, int startColor, int endColor, float velocity, float velocityVariance, float size){
this.particleLifetime=particleLifetime;
this.birthRate=birthRate;
this.startColor=startColor;
this.endColor=endColor;
this.velocity=velocity;
this.velocityVariance=velocityVariance;
this.size=size;
linearStartColor=new float[]{
((startColor >> 24) & 0xFF)/255f,
(float)Math.pow(((startColor >> 16) & 0xFF)/255f, 2.2),
(float)Math.pow(((startColor >> 8) & 0xFF)/255f, 2.2),
(float)Math.pow((startColor & 0xFF)/255f, 2.2)
};
linearEndColor=new float[]{
((endColor >> 24) & 0xFF)/255f,
(float)Math.pow(((endColor >> 16) & 0xFF)/255f, 2.2),
(float)Math.pow(((endColor >> 8) & 0xFF)/255f, 2.2),
(float)Math.pow((endColor & 0xFF)/255f, 2.2)
};
}
@Override
public void draw(@NonNull Canvas canvas){
long now=SystemClock.uptimeMillis();
nextActiveParticles.clear();
for(Particle p:activeParticles){
int time=(int)(now-p.birthTime);
if(time>particleLifetime){
pool.add(p);
continue;
}
nextActiveParticles.add(p);
float x=emitterX+time/1000f*p.velX;
float y=emitterY+time/1000f*p.velY;
if(clipOutBounds.contains((int)x, (int)y)){
continue;
}
float fraction=time/(float)particleLifetime;
paint.setColor(interpolateColor(fraction));
canvas.drawCircle(x, y, size, paint);
}
long timeDiff=Math.min(100, now-prevFrameTime);
int newParticleCount=Math.round(timeDiff/1000f*birthRate);
for(int i=0;i<newParticleCount;i++){
Particle p;
if(!pool.isEmpty())
p=pool.remove(pool.size()-1);
else
p=new Particle();
p.birthTime=now;
double angle=rand.nextDouble()*Math.PI*2;
float vel=velocity+velocityVariance*(rand.nextFloat()*2-1f);
p.velX=vel*(float)Math.cos(angle);
p.velY=vel*(float)Math.sin(angle);
nextActiveParticles.add(p);
}
ArrayList<Particle> tmp=nextActiveParticles;
nextActiveParticles=activeParticles;
activeParticles=tmp;
invalidateSelf();
prevFrameTime=now;
}
@Override
public void setAlpha(int alpha){
}
@Override
public void setColorFilter(@Nullable ColorFilter colorFilter){
}
@Override
public int getOpacity(){
return PixelFormat.TRANSLUCENT;
}
public void setClipOutBounds(int l, int t, int r, int b){
clipOutBounds.set(l, t, r, b);
}
private int interpolateColor(float fraction){
float a=(linearStartColor[0]+(linearEndColor[0]-linearStartColor[0])*fraction)*255f;
float r=(float)Math.pow(linearStartColor[1]+(linearEndColor[1]-linearStartColor[1])*fraction, 1.0/2.2)*255f;
float g=(float)Math.pow(linearStartColor[2]+(linearEndColor[2]-linearStartColor[2])*fraction, 1.0/2.2)*255f;
float b=(float)Math.pow(linearStartColor[3]+(linearEndColor[3]-linearStartColor[3])*fraction, 1.0/2.2)*255f;
return (Math.round(a) << 24) | (Math.round(r) << 16) | (Math.round(g) << 8) | Math.round(b);
}
public void setEmitterPosition(int x, int y){
emitterX=x;
emitterY=y;
}
private static class Particle{
public long birthTime;
public float velX, velY;
}
}

View File

@@ -8,9 +8,12 @@ import android.animation.ObjectAnimator;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.DownloadManager;
import android.content.BroadcastReceiver;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.content.res.ColorStateList;
import android.graphics.Insets;
@@ -59,6 +62,7 @@ import org.joinmastodon.android.events.StatusCountersUpdatedEvent;
import org.joinmastodon.android.model.Attachment;
import org.joinmastodon.android.model.Status;
import org.joinmastodon.android.ui.M3AlertDialogBuilder;
import org.joinmastodon.android.ui.Snackbar;
import org.joinmastodon.android.ui.utils.UiUtils;
import java.io.File;
@@ -122,6 +126,8 @@ public class PhotoViewer implements ZoomPanView.Listener{
private Runnable videoPositionUpdater=this::updateVideoPosition;
private int videoDuration, videoInitialPosition, videoLastTimeUpdatePosition;
private long videoInitialPositionTime;
private long lastDownloadID;
private boolean receiverRegistered;
private static final Property<FragmentRootLinearLayout, Integer> STATUS_BAR_COLOR_PROPERTY=new Property<>(Integer.class, "Fdsafdsa"){
@Override
@@ -135,6 +141,21 @@ public class PhotoViewer implements ZoomPanView.Listener{
}
};
private final BroadcastReceiver downloadCompletedReceiver=new BroadcastReceiver(){
@Override
public void onReceive(Context context, Intent intent){
long id=intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1);
if(id==lastDownloadID){
new Snackbar.Builder(activity)
.setText(R.string.video_saved)
.setAction(R.string.view_file, ()->activity.startActivity(new Intent(DownloadManager.ACTION_VIEW_DOWNLOADS)))
.show();
activity.unregisterReceiver(this);
receiverRegistered=false;
}
}
};
public PhotoViewer(Activity activity, List<Attachment> attachments, int index, Status status, String accountID, Listener listener){
this.activity=activity;
this.attachments=attachments.stream().filter(a->a.type==Attachment.Type.IMAGE || a.type==Attachment.Type.GIFV || a.type==Attachment.Type.VIDEO).collect(Collectors.toList());
@@ -370,6 +391,9 @@ public class PhotoViewer implements ZoomPanView.Listener{
listener.setPhotoViewVisibility(pager.getCurrentItem(), true);
wm.removeView(windowView);
listener.photoViewerDismissed();
if(receiverRegistered){
activity.unregisterReceiver(downloadCompletedReceiver);
}
}
@Override
@@ -531,7 +555,12 @@ public class PhotoViewer implements ZoomPanView.Listener{
BufferedSink buf=Okio.buffer(sink);
buf.writeAll(src);
buf.flush();
activity.runOnUiThread(()->Toast.makeText(activity, R.string.file_saved, Toast.LENGTH_SHORT).show());
activity.runOnUiThread(()->{
new Snackbar.Builder(activity)
.setText(R.string.image_saved)
.setAction(R.string.view_file, ()->activity.startActivity(new Intent(DownloadManager.ACTION_VIEW_DOWNLOADS)))
.show();
});
if(Build.VERSION.SDK_INT<29){
String fileName=Uri.parse(att.url).getLastPathSegment();
File dstFile=new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), fileName);
@@ -539,12 +568,18 @@ public class PhotoViewer implements ZoomPanView.Listener{
}
}catch(IOException x){
Log.w(TAG, "doSaveCurrentFile: ", x);
activity.runOnUiThread(()->Toast.makeText(activity, R.string.error_saving_file, Toast.LENGTH_SHORT).show());
activity.runOnUiThread(()->{
new Snackbar.Builder(activity)
.setText(R.string.error_saving_file)
.show();
});
}
});
}catch(IOException x){
Log.w(TAG, "doSaveCurrentFile: ", x);
Toast.makeText(activity, R.string.error_saving_file, Toast.LENGTH_SHORT).show();
new Snackbar.Builder(activity)
.setText(R.string.error_saving_file)
.show();
}
}else{
saveViaDownloadManager(att);
@@ -557,8 +592,12 @@ public class PhotoViewer implements ZoomPanView.Listener{
req.allowScanningByMediaScanner();
req.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
req.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, uri.getLastPathSegment());
activity.getSystemService(DownloadManager.class).enqueue(req);
Toast.makeText(activity, R.string.downloading, Toast.LENGTH_SHORT).show();
activity.registerReceiver(downloadCompletedReceiver, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));
receiverRegistered=true;
lastDownloadID=activity.getSystemService(DownloadManager.class).enqueue(req);
new Snackbar.Builder(activity)
.setText(R.string.downloading)
.show();
}
private void onAudioFocusChanged(int change){
@@ -690,7 +729,7 @@ public class PhotoViewer implements ZoomPanView.Listener{
}
}else if(id==R.id.btn_share){
if(status!=null){
UiUtils.openSystemShareSheet(activity, status.url);
UiUtils.openSystemShareSheet(activity, status);
}
}else if(id==R.id.btn_bookmark){
if(status!=null){

View File

@@ -63,7 +63,7 @@ public class PhotoViewerInfoSheet extends BottomSheet{
}
backButton=new ImageButton(context);
backButton.setImageResource(R.drawable.ic_arrow_back);
backButton.setImageResource(me.grishka.appkit.R.drawable.ic_arrow_back);
backButton.setImageTintList(ColorStateList.valueOf(UiUtils.getThemeColor(context, R.attr.colorM3OnSurfaceVariant)));
backButton.setBackgroundResource(R.drawable.bg_button_m3_tonal_icon);
backButton.setOutlineProvider(ViewOutlineProvider.BACKGROUND);

View File

@@ -52,7 +52,7 @@ public class HtmlParser{
")" +
")";
public static final Pattern URL_PATTERN=Pattern.compile(VALID_URL_PATTERN_STRING, Pattern.CASE_INSENSITIVE);
public static final Pattern INVITE_LINK_PATTERN=Pattern.compile("^https://"+Regex.URL_VALID_DOMAIN+"/invite/[a-z\\d]+$", Pattern.CASE_INSENSITIVE);
private static final Pattern INVITE_LINK_PATH=Pattern.compile("/invite/[a-z\\d]+$", Pattern.CASE_INSENSITIVE);
private static Pattern EMOJI_CODE_PATTERN=Pattern.compile(":([\\w]+):");
private HtmlParser(){}
@@ -259,4 +259,14 @@ public class HtmlParser{
}
}
}
public static boolean isValidInviteUrl(String url){
return url.startsWith("https://") && INVITE_LINK_PATH.matcher(url).find();
}
public static String normalizeDomain(String domain){
if(domain.startsWith("www."))
domain=domain.substring(4);
return domain;
}
}

View File

@@ -0,0 +1,36 @@
package org.joinmastodon.android.ui.utils;
import android.content.Context;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
public class HorizontalScrollingTouchListener implements View.OnTouchListener{
private float downX, touchslop;
private boolean didDisallow;
public HorizontalScrollingTouchListener(Context context){
touchslop=ViewConfiguration.get(context).getScaledTouchSlop();
}
@Override
public boolean onTouch(View v, MotionEvent ev){
if(ev.getAction()==MotionEvent.ACTION_DOWN){
if(v.canScrollHorizontally(-1) || v.canScrollHorizontally(1)){
v.getParent().requestDisallowInterceptTouchEvent(true);
didDisallow=true;
}else{
didDisallow=false;
}
downX=ev.getX();
}else if(didDisallow && ev.getAction()==MotionEvent.ACTION_MOVE){
if(Math.abs(downX-ev.getX())>=touchslop){
if(!v.canScrollHorizontally((int) (downX-ev.getX()))){
didDisallow=false;
v.getParent().requestDisallowInterceptTouchEvent(false);
}
}
}
return false;
}
}

View File

@@ -3,6 +3,7 @@ package org.joinmastodon.android.ui.utils;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.ClipData;
import android.content.Context;
import android.content.Intent;
import android.content.res.ColorStateList;
@@ -25,6 +26,8 @@ import android.os.SystemClock;
import android.os.ext.SdkExtensions;
import android.provider.MediaStore;
import android.provider.OpenableColumns;
import android.system.ErrnoException;
import android.system.Os;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.TextUtils;
@@ -34,6 +37,7 @@ import android.transition.ChangeScroll;
import android.transition.Fade;
import android.transition.TransitionManager;
import android.transition.TransitionSet;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.Menu;
@@ -51,6 +55,7 @@ import android.widget.Toast;
import android.widget.Toolbar;
import org.joinmastodon.android.E;
import org.joinmastodon.android.FileProvider;
import org.joinmastodon.android.GlobalUserPreferences;
import org.joinmastodon.android.MainActivity;
import org.joinmastodon.android.MastodonApp;
@@ -84,6 +89,7 @@ import org.joinmastodon.android.ui.text.SpacerSpan;
import org.parceler.Parcels;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Method;
import java.time.Instant;
import java.time.LocalDate;
@@ -107,6 +113,7 @@ import androidx.recyclerview.widget.RecyclerView;
import me.grishka.appkit.Nav;
import me.grishka.appkit.api.Callback;
import me.grishka.appkit.api.ErrorResponse;
import me.grishka.appkit.imageloader.ImageCache;
import me.grishka.appkit.imageloader.ViewImageLoader;
import me.grishka.appkit.imageloader.requests.UrlImageLoaderRequest;
import me.grishka.appkit.utils.CubicBezierInterpolator;
@@ -919,10 +926,48 @@ public class UiUtils{
}
}
public static void openSystemShareSheet(Context context, String url){
public static Uri getFileProviderUri(Context context, File file){
return FileProvider.getUriForFile(context, context.getPackageName()+".fileprovider", file);
}
public static void openSystemShareSheet(Context context, Object obj){
Intent intent=new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
Account account;
String url;
String previewTitle;
if(obj instanceof Account acc){
account=acc;
url=acc.url;
previewTitle=context.getString(R.string.share_sheet_preview_profile, account.displayName);
}else if(obj instanceof Status st){
account=st.account;
url=st.url;
String postText=st.getStrippedText();
if(TextUtils.isEmpty(postText)){
previewTitle=context.getString(R.string.share_sheet_preview_profile, account.displayName);
}else{
if(postText.length()>100)
postText=postText.substring(0, 100)+"...";
previewTitle=context.getString(R.string.share_sheet_preview_post, account.displayName, postText);
}
}else{
throw new IllegalArgumentException("Unsupported share object type");
}
intent.putExtra(Intent.EXTRA_TEXT, url);
intent.putExtra(Intent.EXTRA_TITLE, previewTitle);
ImageCache cache=ImageCache.getInstance(context);
try{
File ava=cache.getFile(new UrlImageLoaderRequest(account.avatarStatic));
if(ava==null || !ava.exists())
ava=cache.getFile(new UrlImageLoaderRequest(account.avatar));
if(ava!=null && ava.exists()){
intent.setClipData(ClipData.newRawUri(null, getFileProviderUri(context, ava)));
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
}
}catch(IOException ignore){}
context.startActivity(Intent.createChooser(intent, context.getString(R.string.share_toot_title)));
}

View File

@@ -28,6 +28,7 @@ import java.util.Comparator;
import java.util.List;
import java.util.Locale;
import java.util.Objects;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import androidx.annotation.NonNull;
@@ -46,6 +47,8 @@ public class ComposeLanguageAlertViewController{
private List<SpecialLocaleInfo> specialLocales=new ArrayList<>();
private int selectedIndex=0;
private Locale selectedLocale;
private Locale detectedLocale;
private Consumer<SelectedOption> selectionListener;
public ComposeLanguageAlertViewController(Context context, String preferred, SelectedOption previouslySelected, String postText){
this.context=context;
@@ -81,15 +84,22 @@ public class ComposeLanguageAlertViewController{
if(Build.VERSION.SDK_INT>=29 && !TextUtils.isEmpty(postText)){
SpecialLocaleInfo detected=new SpecialLocaleInfo();
detected.displayName=context.getString(R.string.language_detecting);
detected.enabled=false;
if(previouslySelected!=null && previouslySelected.detectedLocale!=null){
detectedLocale=previouslySelected.detectedLocale;
detected.locale=detectedLocale;
detected.displayName=capitalizeLanguageName(detectedLocale.getDisplayName(Locale.getDefault()));
detected.title=context.getString(R.string.language_detected);
}else{
detected.displayName=context.getString(R.string.language_detecting);
detected.enabled=false;
}
specialLocales.add(detected);
detectLanguage(detected, postText);
}
if(previouslySelected!=null){
if(previouslySelected.index!=-1 && ((previouslySelected.index<specialLocales.size() && Objects.equals(previouslySelected.locale, specialLocales.get(previouslySelected.index).locale)) ||
(previouslySelected.index<specialLocales.size()+allLocales.size() && previouslySelected.index>-1 && Objects.equals(previouslySelected.locale, allLocales.get(previouslySelected.index-specialLocales.size()).locale)))){
(previouslySelected.index<specialLocales.size()+allLocales.size() && previouslySelected.index>=specialLocales.size() && Objects.equals(previouslySelected.locale, allLocales.get(previouslySelected.index-specialLocales.size()).locale)))){
selectedIndex=previouslySelected.index;
selectedLocale=previouslySelected.locale;
}else{
@@ -174,6 +184,7 @@ public class ComposeLanguageAlertViewController{
info.displayName=context.getString(R.string.language_cant_detect);
}else{
Locale locale=lang.getLocale(0).toLocale();
detectedLocale=locale;
info.locale=locale;
info.displayName=capitalizeLanguageName(locale.getDisplayName(Locale.getDefault()));
info.title=context.getString(R.string.language_detected);
@@ -197,7 +208,7 @@ public class ComposeLanguageAlertViewController{
}
public SelectedOption getSelectedOption(){
return new SelectedOption(selectedIndex, selectedLocale);
return new SelectedOption(selectedIndex, selectedLocale, detectedLocale);
}
private void selectItem(int index){
@@ -212,6 +223,12 @@ public class ComposeLanguageAlertViewController{
if(holder!=null && holder.itemView instanceof Checkable checkable)
checkable.setChecked(true);
selectedIndex=index;
if(selectionListener!=null)
selectionListener.accept(getSelectedOption());
}
public void setSelectionListener(Consumer<SelectedOption> selectionListener){
this.selectionListener=selectionListener;
}
private class AllLocalesAdapter extends RecyclerView.Adapter<SimpleLanguageViewHolder>{
@@ -255,8 +272,8 @@ public class ComposeLanguageAlertViewController{
@Override
public void onClick(){
selectItem(getAbsoluteAdapterPosition());
selectedLocale=item.locale;
selectItem(getAbsoluteAdapterPosition());
}
}
@@ -312,8 +329,8 @@ public class ComposeLanguageAlertViewController{
@Override
public void onClick(){
selectItem(getAbsoluteAdapterPosition());
selectedLocale=item.locale;
selectItem(getAbsoluteAdapterPosition());
}
@Override
@@ -343,12 +360,14 @@ public class ComposeLanguageAlertViewController{
public static class SelectedOption{
public int index;
public Locale locale;
public Locale detectedLocale;
public SelectedOption(){}
public SelectedOption(int index, Locale locale){
public SelectedOption(int index, Locale locale, Locale detectedLocale){
this.index=index;
this.locale=locale;
this.detectedLocale=detectedLocale;
}
}
}

View File

@@ -6,7 +6,10 @@ import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.app.AlertDialog;
import android.graphics.RectF;
import android.os.Build;
import android.os.Bundle;
import android.os.VibrationEffect;
import android.os.Vibrator;
import android.view.HapticFeedbackConstants;
import android.view.LayoutInflater;
import android.view.View;
@@ -190,28 +193,20 @@ public class ComposePollViewController{
if(l==pollDuration)
selectedOption=i;
}
int[] chosenOption={0};
new M3AlertDialogBuilder(fragment.getActivity())
.setSingleChoiceItems(options, selectedOption, (dialog, which)->chosenOption[0]=which)
.setTitle(R.string.poll_length)
.setPositiveButton(R.string.ok, (dialog, which)->{
pollDuration=POLL_LENGTH_OPTIONS[chosenOption[0]];
.setSingleChoiceItems(options, selectedOption, (dialog, which)->{
pollDuration=POLL_LENGTH_OPTIONS[which];
pollDurationValue.setText(UiUtils.formatDuration(fragment.getContext(), pollDuration));
dialog.dismiss();
})
.setNegativeButton(R.string.cancel, null)
.setTitle(R.string.poll_length)
.show();
}
private void showPollStyleAlert(){
final int[] option={pollIsMultipleChoice ? R.id.multiple_choice : R.id.single_choice};
AlertDialog alert=new M3AlertDialogBuilder(fragment.getActivity())
.setView(R.layout.poll_style)
.setTitle(R.string.poll_style_title)
.setPositiveButton(R.string.ok, (dlg, which)->{
pollIsMultipleChoice=option[0]==R.id.multiple_choice;
pollStyleValue.setText(pollIsMultipleChoice ? R.string.compose_poll_multiple_choice : R.string.compose_poll_single_choice);
})
.setNegativeButton(R.string.cancel, null)
.show();
CheckableLinearLayout multiple=alert.findViewById(R.id.multiple_choice);
CheckableLinearLayout single=alert.findViewById(R.id.single_choice);
@@ -219,11 +214,9 @@ public class ComposePollViewController{
multiple.setChecked(pollIsMultipleChoice);
View.OnClickListener listener=v->{
int id=v.getId();
if(id==option[0])
return;
((Checkable) alert.findViewById(option[0])).setChecked(false);
((Checkable) v).setChecked(true);
option[0]=id;
pollIsMultipleChoice=id==R.id.multiple_choice;
pollStyleValue.setText(pollIsMultipleChoice ? R.string.compose_poll_multiple_choice : R.string.compose_poll_single_choice);
alert.dismiss();
};
single.setOnClickListener(listener);
multiple.setOnClickListener(listener);
@@ -356,6 +349,13 @@ public class ComposePollViewController{
pollOptions.remove(dpo);
pollOptionsView.removeView(view);
addPollOptionBtn.setEnabled(pollOptions.size()<maxPollOptions);
if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.R){
Vibrator vibrator=fragment.getActivity().getSystemService(Vibrator.class);
if(vibrator.areAllPrimitivesSupported(VibrationEffect.Composition.PRIMITIVE_QUICK_RISE)){
VibrationEffect effect=VibrationEffect.startComposition().addPrimitive(VibrationEffect.Composition.PRIMITIVE_QUICK_RISE).compose();
vibrator.vibrate(effect);
}
}
return;
}
ReorderableLinearLayout.OnDragListener.super.onDragEnd(view);

View File

@@ -53,7 +53,7 @@ public abstract class DropdownSubmenuController{
backItem=(TextView) dropdownController.getActivity().getLayoutInflater().inflate(R.layout.item_dropdown_menu, contentView, false);
((LinearLayout.LayoutParams) backItem.getLayoutParams()).topMargin=V.dp(8);
backItem.setText(backTitle);
backItem.setCompoundDrawablesRelativeWithIntrinsicBounds(R.drawable.ic_arrow_back, 0, 0, 0);
backItem.setCompoundDrawablesRelativeWithIntrinsicBounds(me.grishka.appkit.R.drawable.ic_arrow_back, 0, 0, 0);
backItem.setBackground(UiUtils.getThemeDrawable(dropdownController.getActivity(), android.R.attr.selectableItemBackground));
backItem.setOnClickListener(v->dropdownController.popSubmenuController());
backItem.setAccessibilityDelegate(new View.AccessibilityDelegate(){

View File

@@ -235,10 +235,7 @@ public class AccountViewHolder extends BindableViewHolder<AccountViewModel> impl
int id=item.getItemId();
if(id==R.id.share){
Intent intent=new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, account.url);
fragment.startActivity(Intent.createChooser(intent, item.getTitle()));
UiUtils.openSystemShareSheet(fragment.getActivity(), account);
}else if(id==R.id.mute){
UiUtils.confirmToggleMuteUser(fragment.getActivity(), accountID, account, relationship.muting, this::updateRelationship);
}else if(id==R.id.block){

View File

@@ -0,0 +1,57 @@
package org.joinmastodon.android.ui.views;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.widget.FrameLayout;
import org.joinmastodon.android.R;
public class FixedAspectRatioFrameLayout extends FrameLayout{
private float aspectRatio;
private boolean useHeight;
public FixedAspectRatioFrameLayout(Context context){
this(context, null);
}
public FixedAspectRatioFrameLayout(Context context, AttributeSet attrs){
this(context, attrs, 0);
}
public FixedAspectRatioFrameLayout(Context context, AttributeSet attrs, int defStyle){
super(context, attrs, defStyle);
TypedArray ta=context.obtainStyledAttributes(attrs, R.styleable.FixedAspectRatioImageView);
aspectRatio=ta.getFloat(R.styleable.FixedAspectRatioImageView_aspectRatio, 1);
useHeight=ta.getBoolean(R.styleable.FixedAspectRatioImageView_useHeight, false);
ta.recycle();
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec){
if(useHeight){
int height=MeasureSpec.getSize(heightMeasureSpec);
widthMeasureSpec=Math.round(height*aspectRatio) | MeasureSpec.EXACTLY;
}else{
int width=MeasureSpec.getSize(widthMeasureSpec);
heightMeasureSpec=Math.round(width/aspectRatio) | MeasureSpec.EXACTLY;
}
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
public float getAspectRatio(){
return aspectRatio;
}
public void setAspectRatio(float aspectRatio){
this.aspectRatio=aspectRatio;
}
public boolean isUseHeight(){
return useHeight;
}
public void setUseHeight(boolean useHeight){
this.useHeight=useHeight;
}
}

View File

@@ -284,7 +284,7 @@ public class ReorderableLinearLayout extends LinearLayout implements CustomViewH
private int getMaxDragScroll(){
if(cachedMaxScrollSpeed==-1){
cachedMaxScrollSpeed=getResources().getDimensionPixelSize(R.dimen.item_touch_helper_max_drag_scroll_per_frame);
cachedMaxScrollSpeed=getResources().getDimensionPixelSize(me.grishka.appkit.R.dimen.item_touch_helper_max_drag_scroll_per_frame);
}
return cachedMaxScrollSpeed;
}

View File

@@ -1,20 +1,35 @@
package org.joinmastodon.android.ui.views;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.graphics.Typeface;
import android.os.Build;
import android.util.AttributeSet;
import android.view.View;
import android.view.animation.AnimationUtils;
import android.widget.LinearLayout;
import android.widget.TextView;
import org.joinmastodon.android.R;
import org.joinmastodon.android.ui.ViewProperties;
import org.joinmastodon.android.ui.utils.UiUtils;
import java.util.ArrayList;
import java.util.function.IntConsumer;
import java.util.function.IntPredicate;
import androidx.annotation.IdRes;
import me.grishka.appkit.utils.CubicBezierInterpolator;
public class TabBar extends LinearLayout{
@IdRes
private int selectedTabID;
private IntConsumer listener;
private IntPredicate longClickListener;
private Typeface mediumFont=Typeface.create("sans-serif-medium", Typeface.NORMAL), boldFont=Typeface.DEFAULT_BOLD;
public TabBar(Context context){
this(context, null);
@@ -32,9 +47,14 @@ public class TabBar extends LinearLayout{
public void onViewAdded(View child){
super.onViewAdded(child);
if(child.getId()!=0){
ViewHolder holder=new ViewHolder();
holder.label=child.findViewById(R.id.label);
child.setTag(holder);
if(selectedTabID==0){
selectedTabID=child.getId();
child.setSelected(true);
setTabSelected(child, true);
}else{
holder.label.setTypeface(mediumFont);
}
child.setOnClickListener(this::onChildClick);
child.setOnLongClickListener(this::onChildLongClick);
@@ -45,8 +65,8 @@ public class TabBar extends LinearLayout{
listener.accept(v.getId());
if(v.getId()==selectedTabID)
return;
findViewById(selectedTabID).setSelected(false);
v.setSelected(true);
setTabSelected(findViewById(selectedTabID), false);
setTabSelected(v, true);
selectedTabID=v.getId();
}
@@ -60,8 +80,40 @@ public class TabBar extends LinearLayout{
}
public void selectTab(int id){
findViewById(selectedTabID).setSelected(false);
setTabSelected(findViewById(selectedTabID), false);
selectedTabID=id;
findViewById(selectedTabID).setSelected(true);
setTabSelected(findViewById(selectedTabID), true);
}
private void setTabSelected(View tab, boolean selected){
tab.setSelected(selected);
ViewHolder holder=(ViewHolder) tab.getTag();
if(holder.currentAnim!=null)
holder.currentAnim.cancel();
ArrayList<Animator> anims=new ArrayList<>();
if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.P){
anims.add(ObjectAnimator.ofInt(holder.label, ViewProperties.FONT_WEIGHT, selected ? 700 : 500));
}else{
holder.label.setTypeface(selected ? boldFont : mediumFont);
}
anims.add(ObjectAnimator.ofArgb(holder.label, ViewProperties.TEXT_COLOR, UiUtils.getThemeColor(getContext(), selected ? R.attr.colorM3OnSurface : R.attr.colorM3OnSurfaceVariant)));
AnimatorSet set=new AnimatorSet();
set.playTogether(anims);
set.setDuration(400);
// set.setInterpolator(AnimationUtils.loadInterpolator(getContext(), R.interpolator.m3_sys_motion_easing_standard));
set.setInterpolator(CubicBezierInterpolator.DEFAULT);
holder.currentAnim=set;
set.addListener(new AnimatorListenerAdapter(){
@Override
public void onAnimationEnd(Animator animation){
holder.currentAnim=null;
}
});
set.start();
}
private static class ViewHolder{
public TextView label;
public Animator currentAnim;
}
}

View File

@@ -0,0 +1,74 @@
package org.joinmastodon.android.ui.wrapstodon;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Outline;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewOutlineProvider;
import android.widget.ImageView;
import org.joinmastodon.android.R;
/**
* Software-rendering-friendly rounded-corners image view. Relies on arcane xrefmode magic.
*/
public class RoundedImageView extends ImageView{
private int cornerRadius;
private boolean roundBottomCorners=true;
private Paint clearPaint=new Paint(Paint.ANTI_ALIAS_FLAG), paint=new Paint(Paint.ANTI_ALIAS_FLAG);
public RoundedImageView(Context context){
this(context, null);
}
public RoundedImageView(Context context, AttributeSet attrs){
this(context, attrs, 0);
}
public RoundedImageView(Context context, AttributeSet attrs, int defStyle){
super(context, attrs, defStyle);
TypedArray ta=context.obtainStyledAttributes(attrs, R.styleable.RoundedImageView);
cornerRadius=ta.getDimensionPixelOffset(R.styleable.RoundedImageView_cornerRadius, 0);
roundBottomCorners=ta.getBoolean(R.styleable.RoundedImageView_roundBottomCorners, true);
ta.recycle();
setOutlineProvider(new ViewOutlineProvider(){
@Override
public void getOutline(View view, Outline outline){
outline.setRoundRect(0, 0, view.getWidth(), view.getHeight()+(roundBottomCorners ? 0 : cornerRadius), cornerRadius);
}
});
setClipToOutline(true);
clearPaint.setColor(0xFFFFFFFF);
clearPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
paint.setColor(0xFF0ff000);
}
public void setCornerRadius(int cornerRadius){
this.cornerRadius=cornerRadius;
invalidateOutline();
}
public void setRoundBottomCorners(boolean roundBottomCorners){
this.roundBottomCorners=roundBottomCorners;
invalidateOutline();
}
@Override
public void draw(Canvas canvas){
if(canvas.isHardwareAccelerated()){
super.draw(canvas);
return;
}
canvas.saveLayer(0, 0, getWidth(), getHeight(), null);
canvas.drawRoundRect(0, 0, getWidth(), getHeight()+(roundBottomCorners ? 0 : cornerRadius), cornerRadius, cornerRadius, paint);
canvas.saveLayer(0, 0, getWidth(), getHeight(), clearPaint);
super.draw(canvas);
canvas.restore();
canvas.restore();
}
}

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="?colorM3OnSecondaryContainer" android:state_selected="true"/>
<item android:color="?colorM3OnSurfaceVariant"/>
</selector>

View File

@@ -1,21 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android" android:color="@color/m3_on_surface_variant_overlay">
<item android:gravity="center">
<selector>
<item android:state_selected="true">
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:gravity="top|center_horizontal" android:top="12dp">
<animated-selector>
<item android:id="@+id/selected" android:state_selected="true">
<shape>
<solid android:color="?colorM3SecondaryContainer"/>
<size android:width="64dp" android:height="32dp"/>
<corners android:radius="16dp"/>
<solid android:color="?colorM3SecondaryContainer"/>
<size android:width="64dp" android:height="32dp"/>
<corners android:radius="16dp"/>
</shape>
</item>
</selector>
<item android:id="@+id/unselected">
<shape/>
</item>
<transition android:fromId="@+id/unselected" android:toId="@+id/selected" android:drawable="@drawable/bg_tabbar_tab_selected_anim"/>
<transition android:fromId="@+id/selected" android:toId="@+id/unselected" android:drawable="@drawable/bg_tabbar_tab_unselected_anim"/>
</animated-selector>
</item>
<item android:id="@android:id/mask" android:gravity="center">
<shape>
<solid android:color="#000"/>
<size android:width="64dp" android:height="32dp"/>
<corners android:radius="16dp"/>
</shape>
</item>
</ripple>
</layer-list>

View File

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:drawable="@drawable/bg_tabbar_tab_vector">
<target
android:name="shape">
<aapt:attr name="android:animation">
<set>
<objectAnimator
android:duration="500"
android:interpolator="@interpolator/m3_sys_motion_easing_standard"
android:propertyName="pathData"
android:valueFrom="M32 0A16 16 0 0 0 16 16A16 16 0 0 0 32 32h0A16 16 0 0 0 48 16A16 16 0 0 0 32 0Z"
android:valueTo="M16 0A16 16 0 0 0 0 16A16 16 0 0 0 16 32h32A16 16 0 0 0 64 16A16 16 0 0 0 48 0Z"
android:valueType="pathType"/>
<objectAnimator
android:duration="250"
android:interpolator="@interpolator/m3_sys_motion_easing_standard"
android:propertyName="fillAlpha"
android:valueFrom="0.0"
android:valueTo="1.0"
android:valueType="floatType"/>
</set>
</aapt:attr>
</target>
</animated-vector>

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:drawable="@drawable/bg_tabbar_tab_vector">
<target
android:name="shape">
<aapt:attr name="android:animation">
<objectAnimator
android:duration="500"
android:interpolator="@interpolator/m3_sys_motion_easing_standard"
android:propertyName="fillAlpha"
android:valueFrom="1.0"
android:valueTo="0.0"
android:valueType="floatType"/>
</aapt:attr>
</target>
</animated-vector>

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