Compare commits

..
Author SHA1 Message Date
gdlbo eba6c43d4c dockbar and superapp editor moved 2023-01-06 18:48:49 +03:00
gdlbo 6667dc0be8 added manual verif data update 2023-01-06 16:32:14 +03:00
gdlbo 26e59629aa some settings refactoring 2023-01-06 16:25:58 +03:00
gdlbo 14f9f6dcf8 fixed msg preview 2023-01-06 16:10:41 +03:00
gdlbo 0a8ecd8b0a Update FeedFragment.java 2023-01-06 14:47:23 +03:00
gdlbo a4113ba6d5 auto refactor xmls 2023-01-06 14:47:16 +03:00
gdlbo 4f5193f170 Update Preferences.java 2023-01-06 14:28:52 +03:00
gdlbo 81a62d5400 some code updates 2023-01-03 13:59:39 +03:00
gdlbo 1a7031ead1 fixed init filters 2023-01-01 18:43:05 +03:00
Vologhat 40a1ab64cb add generateRjava task to gradle script 2023-01-01 18:30:48 +03:00
gdlbo 78f0eae9c3 fix #1001 2023-01-01 18:23:32 +03:00
Vologhat b5de88a370 update R.java 2023-01-01 18:19:32 +03:00
Vologhat 1e9a6c6840 fix shell script 2023-01-01 18:12:46 +03:00
gdlbo eb8939021d Update styles.xml 2023-01-01 18:04:34 +03:00
Vologhat a53f90367e fix item swipe disappearance 2023-01-01 17:45:01 +03:00
gdlbo f19aae542e fixed dialog stats from dialogs list 2023-01-01 16:15:38 +03:00
gdlbo f34b895485 added some photo quality magic 2023-01-01 16:13:48 +03:00
gdlbo 5c194891ba disabled more stats 2023-01-01 15:45:25 +03:00
Vologhat e7c08406a5 replace tags with ids 2023-01-01 15:29:42 +03:00
Vologhat c3a08ea7a8 change item width to match_parent 2023-01-01 15:23:25 +03:00
Vologhat 69ea193771 refactor CategorizedAdapter, DockBarEditor, SuperAppEditor 2023-01-01 15:08:32 +03:00
gdlbo 562bfc0ed0 added webview wrapper 2023-01-01 15:08:22 +03:00
Vologhat 919d7cb19d refactor CategorizedAdapter, DockBarEditor, SuperAppEditor 2023-01-01 15:06:55 +03:00
gdlbo 0a766038da updated icon for dialog stats 2022-12-31 23:04:26 +03:00
gdlbo dabc79cdb2 chat stats 2022-12-31 21:42:42 +03:00
gdlbo 4cb73d669a Update StickerPackAdapter.java 2022-12-30 17:50:03 +03:00
gdlbo dfddb13d2d Update CatalogJsonInjector.java 2022-12-30 17:45:39 +03:00
Vologhat f17c57bac2 add tgs stickers preview in settings 2022-12-30 17:32:14 +03:00
Vologhat a6c4c376c3 fix tgs stickers updating on keyboard stickers panel 2022-12-30 17:12:16 +03:00
gdlbo 3e4f14678e fixed nonmilk profile hide 2022-12-30 16:35:20 +03:00
gdlbo f860eb2cc0 Merge pull request #995 from psamur/main
New icons in profile buttons
2022-12-30 16:01:46 +03:00
gdlbo 2a6b9da4ef ImBanner cleanup code 2022-12-30 15:58:10 +03:00
Pavel 6224a4afdf new icons in profile buttons 2022-12-30 15:54:12 +03:00
gdlbo 8650124860 refactored ssfs utils 2022-12-30 15:35:55 +03:00
gdlbo 5e35a61473 refactored profile buttons injector 2022-12-30 14:52:29 +03:00
Vologhat 578f1a2221 add launch task 2022-12-30 14:28:30 +03:00
gdlbo 0fb3ff6c53 deleted useless logs 2022-12-30 02:38:28 +03:00
abslike 7fbfbd1e1e Fix Monet on nonmilkshake (#991) 2022-12-30 02:35:08 +03:00
gdlbo 71de558e5c ssfs update
added support for im banners
2022-12-30 02:31:09 +03:00
gdlbo 606b89a4ec ssfs update
added profile hide
2022-12-30 01:34:15 +03:00
Vologhat b4bdb3070a fix tgs preference summary 2022-12-29 20:53:01 +03:00
Vologhat 9f4b5990b7 refactor PreferencesUtil.java to PreferenceFragmentUtils.java 2022-12-29 19:08:15 +03:00
Vologhat 93b28b0a8f add non-null annotation 2022-12-29 19:04:11 +03:00
gdlbo ed0587b9b6 Merge pull request #988 from psamur/main
"View all..." normal translation
2022-12-29 10:43:16 +03:00
Pavel 6ce72dfc8b - bad translate + normal translate requested in VKTCH 2022-12-29 01:21:10 +03:00
gdlbo 65f44d32ca Update ThemesUtils.java 2022-12-28 23:41:45 +03:00
k1zn 8e57d5ab44 fix crash notf name and translate
crash
2022-12-29 00:52:17 +05:00
gdlbo c2b6bffb17 added articles colors inj 2022-12-28 22:17:43 +03:00
gdlbo 550fbf8f6c Merge pull request #982 from abslike/patch-2
Fix monet in messages(nomilkshake)
2022-12-28 22:01:49 +03:00
gdlbo 79d3287143 fixed #969 again for muted accent 2022-12-28 21:56:34 +03:00
gdlbo 2242e37315 fixed outgoing msg highlighted status 2022-12-28 21:50:21 +03:00
gdlbo 7099da0387 fixed searchDialog 2022-12-28 21:39:56 +03:00
k1zn 9b29288351 fix #986 2022-12-28 22:07:03 +05:00
abslike e000bd7971 Fix monet in messages(nomilkshake) 2022-12-28 00:40:24 +05:00
gdlbo 8eb725148f added search engine selection 2022-12-27 18:05:54 +03:00
gdlbo af1d175415 fix #969 2022-12-27 16:28:19 +03:00
Vologhat 92edbd4686 add keyaboard popup 2022-12-27 16:20:31 +03:00
gdlbo 8d9812ebe0 fix #978 2022-12-27 15:54:55 +03:00
gdlbo 33477e809c fixed #974 2022-12-27 15:22:10 +03:00
Vologhat 04f4f7d2ad fix #972 2022-12-27 11:54:08 +03:00
gdlbo 80b8399cb8 added link to bot in tg stickers info 2022-12-27 01:05:51 +03:00
gdlbo 483c9eda4d added more anime pic search engine 2022-12-27 00:38:38 +03:00
gdlbo c76a7a5332 fixed crash SYSTEM_UI_FLAG_LIGHT_STATUS_BAR 2022-12-26 23:20:07 +03:00
gdlbo c470062d70 fixed crash getColor 2022-12-26 23:11:42 +03:00
gdlbo 52f69c792d fixed google pic search for Ukraine users 2022-12-26 21:51:45 +03:00
Vologhat 33f150eb43 uncomment and refactor ota code 2022-12-26 21:49:48 +03:00
gdlbo e165f388f5 fixed google pic search 2022-12-26 21:39:24 +03:00
Vologhat 761ff263be fix qualities list sorting 2022-12-26 20:46:47 +03:00
gdlbo 8918f203fc disabled accent for nonmilk 2022-12-26 19:29:46 +03:00
gdlbo 6039d0cf43 fixed msgs 2022-12-26 13:32:30 +03:00
gdlbo af902f945e Update styles.xml 2022-12-26 13:12:44 +03:00
gdlbo a90d96b00f disabled accents in nonmilk + enabled monet for nonmilk 2022-12-26 12:14:25 +03:00
gdlbo 550d3dadd8 some themesutils code fixes 2022-12-26 11:58:53 +03:00
gdlbo 82720adb61 fixed statusbar in audioplayer 2022-12-26 11:29:41 +03:00
gdlbo 2a3e12b39a fixed borders in monet 2022-12-26 11:06:43 +03:00
gdlbo 87407b0007 fixed accent hardcode in search 2022-12-26 10:50:44 +03:00
gdlbo ff2e33d9a2 fixed header text in monet nonmilk 2022-12-25 19:02:05 +03:00
Vologhat 61b6b0a1ec replace qualified name with import 2022-12-25 18:43:36 +03:00
gdlbo 9db18f526a Update ThemesCore.java 2022-12-25 18:31:10 +03:00
gdlbo 043253ffff disabled outgoing msg accenting in dark theme 2022-12-25 18:02:56 +03:00
gdlbo 756ab2b7c0 fixed muted colors on nonmilk 2022-12-25 17:56:59 +03:00
gdlbo 2ba5aef993 fixed accents exceptions 2022-12-25 17:54:08 +03:00
gdlbo ab3bd09ab7 fixed colors exceptions 2022-12-25 17:35:58 +03:00
gdlbo 7990d269aa refactored icon manager 2022-12-25 16:58:13 +03:00
gdlbo fffda61a83 fixup! disabled monet for nonmilk 2022-12-25 16:04:25 +03:00
gdlbo d817ccd292 disabled monet for nonmilk 2022-12-25 16:03:31 +03:00
gdlbo 02de3699cc fixed fix separator
dead fix xd
2022-12-24 13:53:53 +03:00
aliveoutside 81b214bcff fix vkui BottomConfirmButton 2022-12-24 13:24:17 +03:00
gdlbo 5dcf50fdc2 some sharing dialog fixes 2022-12-24 12:46:38 +03:00
gdlbo 81d4f9ec99 fixed search bar tint 2022-12-23 17:19:30 +03:00
gdlbo 29596b5dd1 fixed menu items coloring with monet theme 2022-12-23 17:10:30 +03:00
gdlbo b789840498 fixed control_foreground + control_background 2022-12-23 16:18:40 +03:00
gdlbo fce6c2b14f fixed vkim unread dot text 2022-12-23 16:05:54 +03:00
aliveoutside f2ac2c6a37 [monet] impl disabled buttons color 2022-12-23 15:45:40 +03:00
aliveoutside 61881f4e9d [monet] improve vkui buttons 2022-12-23 15:31:54 +03:00
aliveoutside 92f74aa5fb [monet] fix friends recom card background 2022-12-23 15:13:48 +03:00
aliveoutside 0c968de977 [monet] fix buttons tint in friends list 2022-12-23 14:51:50 +03:00
gdlbo 51efc8f4c6 disabled alpha picker 2022-12-21 19:41:33 +03:00
aliveoutside 4dbf1756e1 [monet] fix icon placeholder color on amoled theme 2022-12-21 19:16:24 +03:00
aliveoutside 8d4d88e099 [monet] fix icon placeholder color on dark theme 2022-12-21 19:10:28 +03:00
aliveoutside dd953d39e7 [monet] fix icon placeholder color 2022-12-21 18:52:26 +03:00
aliveoutside 4902938016 [monet] add a small accent to background_content 2022-12-21 18:36:16 +03:00
gdlbo 54de4fd060 Update styles.xml 2022-12-21 18:33:08 +03:00
gdlbo 6d9f3029d3 Update styles.xml 2022-12-19 14:23:52 +03:00
gdlbo 332fe678b9 Update styles.xml 2022-12-19 13:49:55 +03:00
gdlbo 04eee5cc26 Update JsonInjectors.java 2022-12-19 13:33:35 +03:00
Vologhat bc94f1ac77 reduce redundant reflection usage 2022-12-17 14:51:39 +03:00
gdlbo fc423d5ccd fixed cards colors 2022-12-16 20:31:28 +03:00
gdlbo f0993bee15 Update HomeFragment.smali 2022-12-16 19:58:28 +03:00
k1zn 22ef4bd646 Update strings.xml 2022-12-16 19:24:16 +05:00
k1zn c4cc678c82 add summary to themes 2022-12-16 19:22:47 +05:00
k1zn 350c25faff translate 2022-12-16 19:08:41 +05:00
aliveoutside 89ea35dd82 [monet] make newsfeed less ugly 2022-12-16 17:04:46 +03:00
aliveoutside cd858266a8 fix highlight monet color by @absl1ke 2022-12-16 16:42:11 +03:00
gdlbo 0549b07c49 Update stickers_keyboard_navigation.xml 2022-12-14 17:22:46 +03:00
gdlbo a7fd5536f6 fixed writebar issues 2022-12-14 17:11:29 +03:00
gdlbo 1397653b55 disabled NOTIFICATION_ANIM toggle 2022-12-14 15:57:59 +03:00
gdlbo ec1a0fc2d5 separator fixes 2022-12-14 15:57:47 +03:00
gdlbo b75dca5515 disabled shadow in milk news 2022-12-14 15:57:36 +03:00
gdlbo f31fade75a disabled clipdata ddos 2022-12-14 15:57:24 +03:00
gdlbo 347e0fb9c4 some monet fixes 2022-12-14 15:01:07 +03:00
gdlbo bf1a73f606 Update build.gradle 2022-12-13 22:10:23 +03:00
gdlbo 82e268ffa7 Update styles.xml 2022-12-13 22:10:11 +03:00
gdlbo f3acbf74a8 Update ThemesUtils.java 2022-12-13 20:37:22 +03:00
gdlbo 7126af6240 Update styles.xml 2022-12-13 20:20:29 +03:00
gdlbo ef2946a700 Update PhotoViewer.java 2022-12-13 20:08:09 +03:00
gdlbo 8821574412 fix 2022-12-13 19:59:20 +03:00
gdlbo 8257a374da monet separator fixes 2022-12-13 19:46:47 +03:00
gdlbo 3985593842 Update build.gradle 2022-12-13 18:54:23 +03:00
gdlbo 92d8c9a90d Update styles.xml 2022-12-12 22:41:56 +03:00
gdlbo 6f9c325b0d Update styles.xml 2022-12-12 22:37:02 +03:00
gdlbo 1010821cf4 Revert "add CompoundButton hook"
This reverts commit 04488314b5.
2022-12-12 22:16:08 +03:00
gdlbo 012dfa7063 fixed cards in monet style 2022-12-12 21:56:49 +03:00
gdlbo 01adf656e2 added support for monet light style 2022-12-12 17:04:37 +03:00
gdlbo bb64ed8d2a monet prefs imp 2022-12-12 16:47:08 +03:00
gdlbo 1ec78a8fbd some theme upgrades
monet theme disabled
amoled theme switch
some fixes with vkui inj
2022-12-12 16:34:52 +03:00
k1zn f1436ebbde fix music downloading with proxy 2022-12-11 23:32:13 +05:00
k1zn c4efb751c9 miui checks fix 2022-12-11 18:23:40 +05:00
Vologhat 6e902d4bca add miui checks 2022-12-11 15:54:03 +03:00
Vologhat 07b49a4a74 Merge branch 'main' of https://github.com/vtosters/lite 2022-12-11 15:51:22 +03:00
gdlbo c6fdf65137 fixed btns color 2022-12-11 15:50:59 +03:00
gdlbo 18e2554d5e fixed btns color 2022-12-11 14:17:03 +03:00
Vologhat 04488314b5 add CompoundButton hook 2022-12-11 14:12:29 +03:00
gdlbo 3eec52db3b fixed null crash csl in BottomNavigationItemView 2022-12-11 14:00:25 +03:00
gdlbo 132df6080e added useful feature 2022-12-11 13:33:55 +03:00
gdlbo d8f91bc730 fixed vologhat's best code reviewing 2022-12-11 13:32:44 +03:00
Vologhat 270c2af5c1 small messages downloader refactoring 2022-12-10 22:41:31 +03:00
Vologhat 99c500ed69 load placeholder image firstly 2022-12-10 22:21:40 +03:00
gdlbo 8174be1768 updated monet theme 2022-12-10 12:51:14 +03:00
Vologhat a88f59bac1 load user avatar image asynchronously 2022-12-09 21:03:50 +03:00
aliveoutside 1eaa3748c4 Merge remote-tracking branch 'origin/main' 2022-12-09 18:39:18 +03:00
aliveoutside 27836f72f5 Merge branch 'accents' 2022-12-09 18:35:03 +03:00
Saoqqandsaoq 70e048a1ad Add zipalign to CI and build.sh (#928)
* Add zipalign to CI and build.sh

* Revert accidentally removed cleanup

Co-authored-by: saoq <wfmfe@ya.ru>
2022-12-09 18:33:44 +03:00
aliveoutside e915b26918 fix incorrect downloaded tracks length
closes #868
2022-12-09 18:07:40 +03:00
gdlbo 8a6a92f77b upgraded color refs 2022-12-08 14:36:33 +03:00
gdlbo cb492b5949 handle color + highlight color fix 2022-12-08 13:43:57 +03:00
gdlbo f15e4c004d color handles 2022-12-08 13:28:50 +03:00
gdlbo f7f2cf3e58 color cursor 2022-12-08 13:01:22 +03:00
gdlbo 578fa86f19 Update ThemesUtils.java 2022-12-07 18:46:23 +03:00
gdlbo a9bcb19ebf Update StandartFilter.txt 2022-12-07 18:40:07 +03:00
gdlbo cf6b993172 Update EditTextExt.smali 2022-12-07 18:32:34 +03:00
gdlbo 145a6a668b Update date_picker_selector.xml 2022-12-07 18:08:37 +03:00
gdlbo 6b2752db67 Update ColorReferences.java 2022-12-07 18:03:51 +03:00
gdlbo 58fb6224f4 color imp 2022-12-07 17:51:53 +03:00
gdlbo b6406bcebf fixed some coloring 2022-12-07 17:33:21 +03:00
gdlbo 6c7733f1a0 updated code 2022-12-07 17:17:04 +03:00
gdlbo 5373002666 some mbsh updates 2022-12-07 16:49:58 +03:00
gdlbo 4005ac2ef1 Update ColorReferences.java 2022-12-07 10:26:47 +03:00
gdlbo 30de30cf64 fixed many colors 2022-12-07 01:41:22 +03:00
gdlbo 0feeacb533 Update ColorReferences.java 2022-12-06 22:03:17 +03:00
gdlbo de511d15a6 some code upgrades 2022-12-06 18:45:33 +03:00
aliveoutside dc1be1434a Merge pull request #931 from rekayno/patch-1
Update build.yml
2022-12-06 18:32:45 +03:00
gdlbo 6b88996962 fixed ssfs 2022-12-06 16:59:22 +03:00
gdlbo bb35b2b252 Update styles.xml 2022-12-05 17:14:51 +03:00
gdlbo b2f1cfea5e Update ThemesUtils.java 2022-12-05 16:38:44 +03:00
gdlbo 2748ec6902 added muted coloring 2022-12-05 16:19:05 +03:00
gdlbo 17b9c7075e muted accent 2022-12-05 15:20:28 +03:00
gdlbo fd070323b0 Update TextViewHook.java 2022-12-05 14:49:26 +03:00
gdlbo 03a43326b7 tablayout color fix 2022-12-05 14:34:02 +03:00
gdlbo a0b28b6c12 fixed crash 2022-12-05 13:34:48 +03:00
gdlbo 5d46edb91a Update TogglesHook.java 2022-12-05 13:32:41 +03:00
gdlbo 0e751533b5 fixed crashes 2022-12-05 12:53:58 +03:00
gdlbo 32d5ba792a Update PhotoListFragment.smali 2022-12-05 12:47:45 +03:00
gdlbo eb96137c3a ultra upgraded theming csl 2022-12-05 01:20:02 +03:00
gdlbo 09f7a07226 Update SuperAppEditorFragment.java 2022-12-05 00:52:56 +03:00
gdlbo 251f9935aa fixed toolbar 2022-12-05 00:43:20 +03:00
gdlbo a75070f8d3 Update ToolbarHook.java 2022-12-05 00:04:04 +03:00
gdlbo 972921a05c OverlayTextView hooked 2022-12-04 23:31:38 +03:00
gdlbo 3b2586ade5 some hooks update 2022-12-04 23:11:07 +03:00
gdlbo 58ea05cc9d updated toolbar icons hook 2022-12-04 22:33:13 +03:00
gdlbo 441baac671 Update ViewInjector.java 2022-12-04 22:23:34 +03:00
Vologhat a1efd38048 add toolbar icons hook 2022-12-04 22:21:40 +03:00
gdlbo d8be2fe7b7 some hooks updates 2022-12-04 22:14:29 +03:00
k1zn 27fdbf2407 [accents] translate colorpickers 2022-12-04 17:27:31 +05:00
k1zn fd954f5bab [accents] translate 2022-12-04 01:21:48 +05:00
gdlbo 3295e40231 Update vkim_bg_dialog_bar_button_primary.xml 2022-12-03 16:15:54 +03:00
gdlbo f88596025f fixed sending icon im msgs 2022-12-03 15:22:34 +03:00
gdlbo 9c5f584d1b disabled calls button 2022-12-03 15:19:20 +03:00
gdlbo 537a3759d0 fixed accent resetting 2022-12-03 14:57:12 +03:00
gdlbo f2fcc5f4d1 some hardcode color fixes 2022-12-02 19:58:09 +03:00
gdlbo db651c462a Update ThemesFragment.java 2022-12-02 19:27:13 +03:00
gdlbo 4f06fda96d Update styles.xml 2022-12-02 19:19:22 +03:00
gdlbo 1344e88b95 added alpha dark/amoled theme monet on sdk 31
todo light theme
2022-12-02 18:53:20 +03:00
Vologhat 23dd5a71e0 add new accent choices 2022-12-02 18:48:47 +03:00
Vologhat 810e5c72c1 add palettes 2022-12-02 18:48:22 +03:00
Vologhat 045daeea47 update ModalBottomSheetWrapper 2022-12-02 18:45:40 +03:00
Vologhat f45de44c75 add color picker by Martin Stone
Add own modification of HSV-Alpha Color Picker for Android https://github.com/martin-stone/hsv-alpha-color-picker-android
2022-12-02 18:37:12 +03:00
gdlbo d2911e5b6b updated msg colors 2022-12-02 14:52:54 +03:00
gdlbo 576890189c fixed accent fragment and color resetting 2022-12-02 13:44:08 +03:00
gdlbo 5ce6ab3aa8 removed global context from adding prefs 2022-12-02 13:43:50 +03:00
Vologhat 1451e2d3ac downgrade buildToolsVersion 2022-12-02 11:53:39 +03:00
Vologhat 95958a85e9 Update IOUtils.java 2022-12-02 11:52:49 +03:00
Vologhat 9f2b3edbe8 Update IOUtils.java 2022-12-01 23:23:55 +03:00
gdlbo ee4249c688 Revert "Update IOUtils.java"
This reverts commit 2f46c193dd.
2022-12-01 23:17:40 +03:00
Vologhat 2f46c193dd Update IOUtils.java 2022-12-01 23:08:29 +03:00
Vologhat 09807a2954 coloring outgoing messages in accent 2022-12-01 22:52:21 +03:00
gdlbo 163cd44dcc getAccenedColorStateList 2022-12-01 21:45:40 +03:00
gdlbo 2bdff722d4 Updated default accent color 2022-12-01 20:46:49 +03:00
gdlbo e206e85324 updated color hooks 2022-12-01 20:34:48 +03:00
rekayno 40159a2a9f Update build.yml
update actions
2022-11-30 17:00:49 +03:00
Denis 54d59e1f2f Update README.md 2022-11-30 15:01:33 +05:00
Vologhat 1b797325f0 Update MessagesPreviewAdapter.java 2022-11-30 11:49:02 +03:00
Vologhat 63c3c0ee32 refactoring 2022-11-30 00:26:58 +03:00
Vologhat 4b6a7aeb84 invalidate color state of dockbar tab titles 2022-11-29 23:16:36 +03:00
Vologhat 38f65997a6 add input format for color string, and reset button 2022-11-29 22:13:30 +03:00
Vologhat d718851d0c fix accent color resetting 2022-11-29 16:00:31 +03:00
gdlbo b30ad26f54 fixed vk cringe bg color in volume control 2022-11-28 12:23:26 +03:00
gdlbo 5f5fb650f2 fixed volume control color 2022-11-28 12:06:05 +03:00
gdlbo 76260981c5 disabled useless hide button 2022-11-28 12:01:29 +03:00
gdlbo ceb84ed6f6 reply bar fix 2022-11-28 11:51:47 +03:00
gdlbo e8a2c3af56 ssfs update 2022-11-27 15:20:27 +03:00
gdlbo 80e78fa2c1 some music coloring 2022-11-27 02:34:22 +03:00
gdlbo 7b35501461 coloring playlists icons 2022-11-27 02:13:40 +03:00
gdlbo c9cfc5e749 updated msg recoloring 2022-11-27 00:36:39 +03:00
gdlbo f0a915be05 Merge pull request #920 from Saoqq/r/sh-build-script
Refactor buildscripts
2022-11-26 18:19:26 +03:00
saoq f2b8624cc4 Update README.md 2022-11-26 01:38:33 +03:00
saoq ccaa10d224 Extract dex move to gradle task, apply to CI .yml 2022-11-26 01:38:22 +03:00
saoqq 6325d8fe68 Remove complication for Win script call, fix sh script invocation 2022-11-25 23:04:37 +03:00
saoqq e243522f95 Ensure Win buildscript works 2022-11-25 21:52:22 +03:00
saoq d87a59bcb0 Refactor build scripts 2022-11-25 08:56:52 +03:00
saoq 724fafc3fd Make build.sh dir independent 2022-11-25 06:13:31 +03:00
gdlbo 8c03ab60fc updated attrs and some swipe coloring 2022-11-24 15:00:02 +03:00
gdlbo 985ced6e3c deleted useless hook 2022-11-24 11:57:49 +03:00
aliveoutside 88339feb12 [accents] create a separate fragment for accents 2022-11-23 23:29:01 +03:00
aliveoutside 2bcf5d1c2d [accents] highlight edittext field 2022-11-23 23:08:01 +03:00
aliveoutside 77f9c60be7 [accents] replace AlertDialog with VkAlertDialog 2022-11-23 23:06:31 +03:00
aliveoutside 76468d8863 [WIP] Accent picker in settings 2022-11-23 22:24:25 +03:00
gdlbo c17e604db6 fixed cringe code + coloring bug 2022-11-22 22:31:32 +03:00
gdlbo 1a96f77aa1 some crash fixes 2022-11-22 21:34:48 +03:00
gdlbo 3fd0757fd4 Update DialogActionsListView.smali 2022-11-22 21:06:26 +03:00
gdlbo 989075a3d2 Update DrawableExt.smali 2022-11-22 20:21:29 +03:00
aliveoutside 802d88cad7 fix AppCompatResources 2022-11-22 20:09:12 +03:00
gdlbo 95a0451c6b fixed dw coloring 2022-11-22 20:06:56 +03:00
aliveoutside 3b83f05bf0 init ThemesCore 2022-11-22 19:08:47 +03:00
aliveoutside c7d350f5b1 remove logger from TextViewHook 2022-11-22 19:08:39 +03:00
gdlbo d3eeaf5f23 removed some hardcode 2022-11-22 19:06:06 +03:00
aliveoutside 4dcea46be7 recolor CSL where it is possible 2022-11-22 18:06:32 +03:00
aliveoutside 96de61fd15 move some stuff from ThemesUtils 2022-11-22 18:00:12 +03:00
aliveoutside 47f4c5c911 Init 2022-11-22 16:58:09 +03:00
aliveoutside fcbf9238cf wait for the pfp loaded in settings
fixes #912
2022-11-21 10:51:05 +03:00
gdlbo 4a8a2adb4e Update MediaFragment.java 2022-11-14 21:06:03 +03:00
352 changed files with 14128 additions and 6085 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 545 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 819 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 730 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

+9 -5
View File
@@ -22,32 +22,36 @@ jobs:
steps:
- name: Set up JDK 11
uses: actions/setup-java@v2
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Download tools
run: |
sudo apt update
sudo apt install default-jre
sudo apt install python3
sudo apt install zipalign
chmod +x scripts/apktool.jar
chmod +x scripts/apksigner.jar
- name: Build VTLite
run: |
bash scripts/buildworkflow.sh
gradle prepareDexForMerge
java -jar scripts/apktool.jar b smali -o smali/VTLite.apk --use-aapt2 -p scripts/framework/
zipalign -p -f 4 smali/VTLite.apk smali/VTLite.apk_aligned
mv smali/VTLite.apk_aligned smali/VTLite.apk
- name: Sign and verify the apk
run: |
java -jar scripts/apksigner.jar sign --ks scripts/debug.keystore --ks-key-alias androiddebugkey --ks-pass pass:android smali/VTLite.apk
java -jar scripts/apksigner.jar verify smali/VTLite.apk
- name: Upload apk to artifact
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: VTLite.apk
path: smali/VTLite.apk
+1
View File
@@ -30,3 +30,4 @@ smali/build/resources.zip
smali/assets/version.properties
*.keystore
gradle.properties
scripts/build.sh
+6 -9
View File
@@ -46,8 +46,7 @@
- [Разработка](#разработка)
- [Всё необходимое для сборки и компиляции](#всё-необходимое-для-сборки-и-компиляции)
- [Необходимые зависимости](#необходимые-зависимости)
- [Linux/macOS](#linuxmacos)
- [Windows](#windows)
- [Linux/MacOS/Windows](#LinuxmacOSWindows)
## Функциональность
@@ -122,12 +121,10 @@
<a href="https://developer.android.com/studio"><img src="https://i.imgur.com/cPvvFDP.png" align="center" width="20" height="23"/> **Android Studio**</a>
### Linux/macOS
Для сборки используется файл `./build.sh`
### Linux/macOS/Windows
<img src="https://i.imgur.com/8BMX8lG.png" width="550" height="368"/>
Для сборки необходимо вызвать одну из следующих gradle tasks:
### Windows
Для сборки используется файл `build.bat`
<img src="https://i.imgur.com/iZSUKJ6.png" width="550" height="368"/>
+ `./gradlew buildVTL` - соберет и подпишет APK
+ `./gradlew buildAndInstallVTL` - соберет, подпишет и попытается установить через ADB
+ [FOR DEVS] `./gradlew prepareDexForMerge` - соберет все необходимое для сборки в `smali/`
+77 -3
View File
@@ -1,3 +1,5 @@
import org.apache.tools.ant.taskdefs.condition.Os
import java.util.zip.ZipEntry
import java.util.zip.ZipFile
import java.util.zip.ZipInputStream
@@ -7,9 +9,15 @@ plugins {
id 'net.nemerosa.versioning' version '2.15.1'
}
def smaliFolder = projectDir.toPath().resolve("../smali").normalize()
def scriptsFolder = projectDir.toPath().resolve("../scripts").normalize()
versionFile {
File moduleDir = projectDir
file = new File(moduleDir.getAbsolutePath() + "/src/main/assets/version.properties")
file = projectDir.toPath().resolve("src/main/assets/version.properties").toFile()
}
task cleanVersionFile {
projectDir.toPath().resolve("src/main/assets/version.properties").toFile().delete()
}
task exportDex {
@@ -69,7 +77,13 @@ task exportDex {
android {
compileSdkVersion 32
buildToolsVersion '33.0.0'
buildToolsVersion '32.0.0'
sourceSets {
main {
java.srcDirs += 'build/generated/aidl_source_output_dir/release/out'
}
}
defaultConfig {
applicationId "ru.vtosters.lite.utils.lite"
@@ -94,3 +108,63 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.aar'])
compileOnly fileTree(dir: 'libs', include: ['*.jar'])
}
task prepareDexForMerge(type: Copy) {
dependsOn('exportDex')
into smaliFolder.toString()
from(projectDir) {
include 'classes6.dex'
include 'classes7.dex'
}
from(projectDir) {
include 'version.properties'
into("assets")
}
doLast {
new File(projectDir, "classes6.dex").delete()
new File(projectDir, "classes7.dex").delete()
new File(projectDir, "version.properties").delete()
}
}
task buildVTL(type: Exec) {
dependsOn('prepareDexForMerge')
workingDir(projectDir.parentFile)
if (Os.isFamily("unix") || Os.isFamily("mac")) {
commandLine 'bash', '-c', './scripts/build.sh'
} else {
commandLine 'cmd', '/C', '.\\scripts\\build.bat'
}
}
task buildAndInstallVTL(type: Exec) {
dependsOn('buildVTL')
workingDir(scriptsFolder.toString())
ignoreExitValue true
if (Os.isFamily("unix") || Os.isFamily("mac")) {
commandLine 'bash', '-c', 'adb install VTLite.apk'
} else {
commandLine 'adb', 'install', 'VTLite.apk'
}
}
task buildAndLaunchVTL(type: Exec) {
dependsOn('buildAndInstallVTL')
if (Os.isFamily("unix") || Os.isFamily("mac"))
commandLine 'bash', '-c', 'adb shell monkey -p com.vtosters.lite -c android.intent.category.LAUNCHER 1'
else
commandLine 'adb', 'shell', 'monkey', '-p', 'com.vtosters.lite', '-c', 'android.intent.category.LAUNCHER', '1'
}
task generateRjava(type: Exec) {
workingDir(projectDir.parentFile)
if (Os.isFamily("unix") || Os.isFamily("mac"))
commandLine "bash", "-c", "./scripts/rclass_regenerator.sh"
else
commandLine "cmd", "/C", ".\\scripts\\rclass_regenerator.sh"
}
exportDex.dependsOn('assembleRelease')
clean.dependsOn('cleanVersionFile')
versionFile.dependsOn('cleanVersionFile')
preBuild.dependsOn('versionFile')
@@ -1,16 +1,14 @@
package com.aefyr.tsg.g2;
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import com.aefyr.tsg.g2.sql.TelegramStickersDbHelper;
import com.aefyr.tsg.g2.stickersgrabber.TelegramStickersGrabber;
import com.aefyr.tsg.g2.stickersgrabber.TelegramStickersPackInfo;
import ru.vtosters.lite.ui.fragments.tgstickers.StickersFragment;
import java.io.File;
import java.util.ArrayList;
@@ -19,7 +17,7 @@ import java.util.List;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
import ru.vtosters.lite.ui.fragments.tgstickers.StickersFragment;
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
/**
* Created by Aefyr on 19.05.2018.
@@ -227,6 +225,7 @@ public class TelegramStickersService {
currentlyDownloading.add(id.toLowerCase());
notificationsHelper.packStartedDownloading(newPack);
grabber.enableProxy();
grabber.grabPack(id, packFolder, pack.version, new TelegramStickersGrabber.PackDownloadListener() {
@Override
@@ -383,7 +382,7 @@ public class TelegramStickersService {
getPacksListReference().set(li1, p2);
}
interface StickersEventsListener {
public interface StickersEventsListener {
void onPackAdded(TelegramStickersPack pack, int atIndex);
void onPackRemoved(TelegramStickersPack pack, int atIndex);
@@ -0,0 +1,132 @@
package com.vk.core.drawable;
import android.content.res.ColorStateList;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import androidx.annotation.NonNull;
import ru.vtosters.lite.themes.utils.RecolorUtils;
public class RecoloredDrawable extends Drawable implements Drawable.Callback {
private Drawable drawable;
private ColorStateList colorStateList;
private int c;
private int d;
public RecoloredDrawable(Drawable drawable, ColorStateList colorStateList) {
this.c = 255;
this.d = 255;
try {
this.drawable = drawable.mutate();
} catch (Exception e) {
e.printStackTrace();
}
this.drawable.setCallback(this);
this.colorStateList = RecolorUtils.themeCSL(colorStateList);
onStateChange(new int[0]);
}
public void a(int i) {
a(new ColorStateList(new int[][]{new int[0]}, new int[]{i}));
}
@Override
public void draw(@NonNull Canvas canvas) {
this.drawable.draw(canvas);
}
@Override
public int getIntrinsicHeight() {
return this.drawable.getIntrinsicHeight();
}
@Override
public int getIntrinsicWidth() {
return this.drawable.getIntrinsicWidth();
}
@Override
public int getOpacity() {
return this.drawable.getOpacity();
}
@Override
public void invalidateDrawable(@NonNull Drawable drawable) {
invalidateSelf();
}
@Override
public boolean isStateful() {
return this.colorStateList.isStateful();
}
@Override
protected boolean onStateChange(int[] iArr) {
super.onStateChange(iArr);
ColorStateList colorStateList = this.colorStateList;
this.drawable.setColorFilter(colorStateList.getColorForState(iArr, colorStateList.getDefaultColor()), PorterDuff.Mode.SRC_IN);
int length = iArr.length;
boolean z = false;
int i = 0;
while (true) {
if (i >= length) {
break;
} else if (iArr[i] == 0x010100a1) {
z = true;
break;
} else {
i++;
}
}
this.drawable.setState(iArr);
this.drawable.setAlpha(z ? this.c : this.d);
return true;
}
@Override
public void scheduleDrawable(@NonNull Drawable drawable, @NonNull Runnable runnable, long j) {
scheduleSelf(runnable, j);
}
@Override
public void setAlpha(int i) {
this.c = i;
this.d = i;
this.drawable.setAlpha(i);
}
@Override
public void setBounds(int i, int i2, int i3, int i4) {
super.setBounds(i, i2, i3, i4);
this.drawable.setBounds(i, i2, i3, i4);
}
@Override
public void setColorFilter(ColorFilter colorFilter) {
}
@Override
public void unscheduleDrawable(@NonNull Drawable drawable, @NonNull Runnable runnable) {
unscheduleSelf(runnable);
}
public void a(ColorStateList colorStateList) {
this.colorStateList = colorStateList;
onStateChange(getState());
invalidateSelf();
}
public Drawable a() {
return this.drawable;
}
public RecoloredDrawable(Drawable drawable, int i) {
this(drawable, new ColorStateList(new int[][]{new int[0]}, new int[]{i}));
}
public RecoloredDrawable() {
this.c = 255;
this.d = 255;
}
}
@@ -191,7 +191,7 @@ public class DownloadUtils {
if (!file.exists()) {
return false;
}
Intent intent = new Intent("android.intent.action.VIEW");
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
var mimeType = FileUtils.f(file);
var uri = FileUtils.uriFromFile(file);
@@ -222,7 +222,7 @@ public class DownloadUtils {
var mimeType = FileUtils.f(file);
var uri = FileUtils.uriFromFile(file);
Intent intent = new Intent("android.intent.action.VIEW");
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(uri, mimeType);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Log.d("DownloadUtils", "openFile: " + file.getAbsolutePath() + "| mimetype " + mimeType + "| uri " + uri);
@@ -36,5 +36,6 @@ public enum DialogAction {
unpinmsg,
ENCRYPT_SETT,
ENCRYPT,
DOWNLOAD
DOWNLOAD,
STAT
}
@@ -0,0 +1,179 @@
package com.vk.stickers.details;
import android.graphics.drawable.ColorDrawable;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.vk.core.ui.themes.VKThemeHelper;
import com.vk.core.util.Screen;
import com.vk.dto.stickers.StickerItem;
import com.vk.dto.stickers.StickerStockItem;
import com.vk.extensions.ViewExtKt;
import com.vk.imageloader.view.VKImageView;
import com.vk.stickers.views.VKStickerImageView;
import com.vtosters.lite.R;
import java.util.List;
public final class StickerDetailsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private final List<StickerItem> mItems;
private final StickerStockItem mItem;
private boolean mIsTelegramPack = false;
public StickerDetailsAdapter(StickerStockItem stickerStockItem) {
this.mItem = stickerStockItem;
this.mItems = this.mItem.T1();
}
public void setTelegramPack(boolean state) {
mIsTelegramPack = state;
}
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
switch (i) {
case 0:
return new c(viewGroup);
case 1:
return new d(viewGroup);
case 2:
return new b(viewGroup);
default:
throw new IllegalArgumentException("Unknown viewType: " + i);
}
}
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int i) {
switch(getItemViewType(i)) {
case 0:
((c) viewHolder).a(this.mItem);
break;
case 1:
((d) viewHolder).a(this.mItems.get(H(i)));
break;
}
}
@Override
public int getItemCount() {
return mIsTelegramPack ? mItems.size() : this.mItems.size() + 2;
}
@Override
public int getItemViewType(int i) {
if (mIsTelegramPack) return 1;
if (i == 0) {
return 0;
}
return i == k() ? 2 : 1;
}
public int H(int i) {
return mIsTelegramPack ? i : i - j();
}
public boolean I(int i) {
return getItemViewType(i) == 1;
}
public int j() {
return 1;
}
public int k() {
return l() + 1;
}
public int l() {
return (this.mItems.size() + j()) - 1;
}
public int m() {
return 0;
}
public List<StickerItem> n() {
return this.mItems;
}
public boolean v() {
return false;
}
private static final class b extends RecyclerView.ViewHolder {
public b(ViewGroup viewGroup) {
super(ViewExtKt.a(viewGroup, R.layout.sticker_details_hold_to_view_item, false));
}
}
private final class c extends RecyclerView.ViewHolder {
private final VKImageView mImageBg;
private final VKImageView mPackImage;
private final ImageView mAnimPack;
private final TextView mPackTitle;
private final TextView mPackAuthor;
private final TextView mPackSubtitle;
private final TextView mDescription;
public c(ViewGroup viewGroup) {
super(LayoutInflater.from(VKThemeHelper.u()).inflate(R.layout.sticker_details_info_item, viewGroup, false));
this.mImageBg = this.itemView.findViewById(R.id.pack_image_bg);
this.mPackImage = this.itemView.findViewById(R.id.pack_image);
this.mAnimPack = this.itemView.findViewById(R.id.anim_pack);
this.mPackTitle = this.itemView.findViewById(R.id.pack_title);
this.mPackAuthor = this.itemView.findViewById(R.id.pack_author);
this.mPackSubtitle = this.itemView.findViewById(R.id.pack_subtitle);
this.mDescription = this.itemView.findViewById(R.id.description);
}
public void a(StickerStockItem stickerStockItem) {
this.mImageBg.a(stickerStockItem.R1());
this.mImageBg.getHierarchy().a().setVisible(true, true);
this.mImageBg.getHierarchy().a(0);
this.mImageBg.getHierarchy().e(new ColorDrawable(VKThemeHelper.d(R.attr.placeholder_icon_background)));
this.mPackImage.a(stickerStockItem.h(Screen.a(68)));
this.mPackImage.getHierarchy().a().setVisible(true, true);
this.mPackImage.getHierarchy().a(0);
if (stickerStockItem.E1()) {
ViewExtKt.r(this.mAnimPack);
} else {
ViewExtKt.p(this.mAnimPack);
}
this.mPackTitle.setText(stickerStockItem.getTitle());
this.mPackAuthor.setText(stickerStockItem.v1());
ViewExtKt.p(this.mPackSubtitle);
this.mDescription.setText(stickerStockItem.C1());
}
}
private static final class d extends RecyclerView.ViewHolder {
private final VKStickerImageView mImage;
public d(ViewGroup viewGroup) {
super(new VKStickerImageView(viewGroup.getContext()));
this.mImage = (VKStickerImageView) itemView;
this.mImage.setAspectRatio(1.0f);
this.mImage.setClickable(true);
this.mImage.getHierarchy().a().setVisible(true, true);
this.mImage.getHierarchy().a(0);
this.mImage.setContentDescription(this.mImage.getContext().getString(R.string.stickers_accessibility_sticker));
}
public void a(StickerItem stickerItem) {
this.mImage.a(stickerItem.h(Screen.a(80)));
this.mImage.setTag(R.id.id, stickerItem.getId());
}
}
}
+62 -13
View File
@@ -221,8 +221,9 @@ public final class R {
public static final int targetlang_value = 0x7f030074; // 2130903156
public static final int undel_value = 0x7f030075; // 2130903157
public static final int wallpaper_change_dialog = 0x7f030076; // 2130903158
public static final int theme_type_name = 0x7f030077; // 2130903159
public static final int theme_type_name_checkbox = 0x7f030078; // 2130903160
public static final int accent_select_type = 0x7f030077; // 2130903159
public static final int theme_type_name = 0x7f030078; // 2130903160
public static final int theme_type_name_checkbox = 0x7f030079; // 2130903161
}
public static final class attr {
@@ -2136,6 +2137,7 @@ public final class R {
public static final int zOrderOnTop = 0x7f040773; // 2130970483
public static final int im_ic_msgdl = 0x7f040774; // 2130970484
public static final int im_ic_msgreload = 0x7f040775; // 2130970485
public static final int im_ic_stats = 0x7f040776; // 2130970486
}
public static final class bool {
@@ -2964,6 +2966,7 @@ public final class R {
public static final int yellow_sunflower = 0x7f060324; // 2131100452
public static final int iclauncher = 0x7f060325; // 2131100453
public static final int abc_color_highlight_material = 0x7f060004; // 2131099652
public static final int alpha05 = 0x7f060326; // 2131100454
}
public static final class dimen {
@@ -4974,6 +4977,7 @@ public final class R {
public static final int roundmsg = 0x7f080bd3; // 2131233747
public static final int tgs_entry_background = 0x7f080bd4; // 2131233748
public static final int yandex = 0x7f080bd7; // 2131233751
public static final int checker_background = 0x7f080bd8; // 2131233752
public static final int abc_control_background_material = 0x7f080032; // 2131230770
public static final int ic_action_close = 0x7f080322; // 2131231522
public static final int ic_camera_outline_28_new = 0x7f0803a0; // 2131231648
@@ -11028,6 +11032,10 @@ public final class R {
public static final int savedmsg = 0x7f0a101e; // 2131365918
public static final int search_photo = 0x7f0a101f; // 2131365919
public static final int text_hex_wrapper = 0x7f0a1020; // 2131365920
public static final int color_preview = 0x7f0a1021; // 2131365921
public static final int color_name = 0x7f0a1022; // 2131365922
public static final int color_value = 0x7f0a1023; // 2131365923
public static final int color_preview_border = 0x7f0a1024; // 2131365924
}
public static final class integer {
@@ -12848,6 +12856,7 @@ public final class R {
public static final int tgs_entry = 0x7f0d06de; // 2131560158
public static final int wppreview = 0x7f0d06df; // 2131560159
public static final int write_bar_i = 0x7f0d06e0; // 2131560160
public static final int color_picker_item = 0x7f0d06e1; // 2131560161
}
public static final class menu {
@@ -19517,17 +19526,39 @@ public final class R {
public static final int whitelisted_filters_groups_title = 0x7f121838; // 2131892280
public static final int why_news_not_updated_summ = 0x7f121839; // 2131892281
public static final int why_news_not_updated_title = 0x7f12183a; // 2131892282
public static final int blockminiapps_summ = 0x7f12183b; // 2131892283
public static final int blockminiapps_title = 0x7f12183c; // 2131892284
public static final int current_theme = 0x7f12183d; // 2131892285
public static final int invalid_pack_link = 0x7f12183e; // 2131892286
public static final int maxquality_summ = 0x7f12183f; // 2131892287
public static final int maxquality_title = 0x7f121840; // 2131892288
public static final int newsfeed_notif_summ = 0x7f121841; // 2131892289
public static final int newsfeed_notif_title = 0x7f121842; // 2131892290
public static final int promotedstickers_title = 0x7f121843; // 2131892291
public static final int vkx_integration_enabled_info = 0x7f121844; // 2131892292
public static final int writebar_ios_title = 0x7f121845; // 2131892293
public static final int accent_color_summ = 0x7f12183b; // 2131892283
public static final int accent_color_title = 0x7f12183c; // 2131892284
public static final int accents = 0x7f12183d; // 2131892285
public static final int amoledtheme_summ = 0x7f12183e; // 2131892286
public static final int amoledtheme_title = 0x7f12183f; // 2131892287
public static final int audio_deleted_from_cache = 0x7f121840; // 2131892288
public static final int blockminiapps_summ = 0x7f121841; // 2131892289
public static final int blockminiapps_title = 0x7f121842; // 2131892290
public static final int businessDisabler_title = 0x7f121843; // 2131892291
public static final int cannot_write = 0x7f121844; // 2131892292
public static final int change_accent_color = 0x7f121845; // 2131892293
public static final int copyownlink_summ = 0x7f121846; // 2131892294
public static final int copyownlink_title = 0x7f121847; // 2131892295
public static final int crash_service_name = 0x7f121848; // 2131892296
public static final int current_theme = 0x7f121849; // 2131892297
public static final int dialogstats = 0x7f12184a; // 2131892298
public static final int downloading_update = 0x7f12184b; // 2131892299
public static final int invalid_pack_link = 0x7f12184c; // 2131892300
public static final int maxquality_summ = 0x7f12184d; // 2131892301
public static final int maxquality_title = 0x7f12184e; // 2131892302
public static final int monettheme_summ = 0x7f12184f; // 2131892303
public static final int monettheme_title = 0x7f121850; // 2131892304
public static final int newsfeed_notif_summ = 0x7f121851; // 2131892305
public static final int newsfeed_notif_title = 0x7f121852; // 2131892306
public static final int open_bot = 0x7f121853; // 2131892307
public static final int promotedstickers_title = 0x7f121854; // 2131892308
public static final int select_color = 0x7f121855; // 2131892309
public static final int select_palette = 0x7f121856; // 2131892310
public static final int sources = 0x7f121857; // 2131892311
public static final int useOldAppVer_summ = 0x7f121858; // 2131892312
public static final int useOldAppVer_title = 0x7f121859; // 2131892313
public static final int vkx_integration_enabled_info = 0x7f12185a; // 2131892314
public static final int writebar_ios_title = 0x7f12185b; // 2131892315
}
public static final class style {
@@ -20672,6 +20703,24 @@ public final class R {
public static final int Base_V26_Widget_AppCompat_Toolbar = 0x7f1300a1; // 2131951777
public static final int Base_V28_Theme_AppCompat = 0x7f1300a2; // 2131951778
public static final int Base_V28_Theme_AppCompat_Light = 0x7f1300a3; // 2131951779
public static final int Vk_Theme_VkApp_amoled_monet_generated = 0x7f130475; // 2131952757
public static final int Vk_Theme_VkApp_amoled_monet_old_generated = 0x7f130476; // 2131952758
public static final int Vk_Theme_VkApp_bright_light_monet_generated = 0x7f130477; // 2131952759
public static final int Vk_Theme_VkApp_client_dark_monet_generated = 0x7f130478; // 2131952760
public static final int Vk_Theme_VkApp_client_light_monet_generated = 0x7f130479; // 2131952761
public static final int Vk_Theme_VkApp_space_gray_monet_generated = 0x7f13047a; // 2131952762
public static final int VkAmoledMonetStyle = 0x7f13047b; // 2131952763
public static final int VkAmoledMonetTheme = 0x7f13047c; // 2131952764
public static final int VkDarkMonetStyle = 0x7f13047d; // 2131952765
public static final int VkDarkMonetTheme = 0x7f13047e; // 2131952766
public static final int VkLightMonetStyle = 0x7f13047f; // 2131952767
public static final int VkLightMonetTheme = 0x7f130480; // 2131952768
public static final int VkMilkAmoledMonetStyle = 0x7f130481; // 2131952769
public static final int VkMilkAmoledMonetTheme = 0x7f130482; // 2131952770
public static final int VkMilkDarkMonetStyle = 0x7f130483; // 2131952771
public static final int VkMilkDarkMonetTheme = 0x7f130484; // 2131952772
public static final int VkMilkLightMonetStyle = 0x7f130485; // 2131952773
public static final int VkMilkLightMonetTheme = 0x7f130486; // 2131952774
}
public static final class xml {
@@ -71,12 +71,11 @@ public class BottomNavigationItemView extends FrameLayout implements MenuView.It
this.mIcon.getLayoutParams().width = V.a(28.0F);
this.mIcon.getLayoutParams().height = V.a(28.0F);
var colorStateList = getCSTDock();
this.mSmallLabel = this.findViewById(R.id.smallLabel);
mSmallLabel.setTextColor(colorStateList);
mSmallLabel.setTextColor(getCSTDock());
this.mLargeLabel = this.findViewById(R.id.largeLabel);
mLargeLabel.setTextColor(colorStateList);
mLargeLabel.setTextColor(getCSTDock());
LayoutInflater.from(this.getContext()).inflate(R.layout.navigation_bottom_counter, this, true);
this.mCounterContainer = this.findViewById(R.id.counter_container);
@@ -280,12 +279,13 @@ public class BottomNavigationItemView extends FrameLayout implements MenuView.It
@SuppressLint("RestrictedApi")
public void setIcon(Drawable drawable) {
if (drawable != null) {
var csl = this.mColorStateList;
if (drawable != null && csl != null) {
if (drawable.getConstantState() != null)
drawable = drawable.getConstantState().newDrawable();
drawable = DrawableCompat.wrap(drawable).mutate();
DrawableCompat.setTintList(drawable, this.mColorStateList);
DrawableCompat.setTintList(drawable, csl);
}
this.mIcon.setImageDrawable(drawable);
@@ -326,6 +326,8 @@ public class BottomNavigationItemView extends FrameLayout implements MenuView.It
}
public void setTextColor(ColorStateList colorStateList) {
this.mSmallLabel.setTextColor(colorStateList);
this.mLargeLabel.setTextColor(colorStateList);
}
@SuppressLint("RestrictedApi")
@@ -1,20 +1,9 @@
package ru.vtosters.lite.dnr;
import static ru.vtosters.lite.dnr.DNRModule.hookDNR;
import static ru.vtosters.lite.dnr.DNRModule.hookDNT;
import static ru.vtosters.lite.dnr.DNRModule.isDnrEnabledFor;
import static ru.vtosters.lite.dnr.DNRModule.isDntEnabledFor;
import static ru.vtosters.lite.encryption.EncryptProvider.decryptMessage;
import static ru.vtosters.lite.proxy.ProxyUtils.getApi;
import static ru.vtosters.lite.utils.AccountManagerUtils.getUserToken;
import static ru.vtosters.lite.utils.AndroidUtils.isTablet;
import static ru.vtosters.lite.utils.AndroidUtils.sendToast;
import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Environment;
import android.util.Log;
import com.vk.core.network.Network;
import com.vk.im.engine.ImEngine1;
import com.vk.im.engine.events.OnDialogUpdateEvent;
@@ -27,6 +16,16 @@ import com.vk.im.ui.components.common.MsgAction;
import com.vk.im.ui.components.viewcontrollers.popup.DelegateMsg;
import com.vk.im.ui.views.dialog_actions.DialogActionsListView;
import com.vtosters.lite.R;
import okhttp3.Headers;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import ru.vtosters.lite.downloaders.messages.HtmlDialogDownloaderFormatProvider;
import ru.vtosters.lite.downloaders.messages.MessagesDownloader;
import ru.vtosters.lite.encryption.EncryptProvider;
import ru.vtosters.lite.encryption.base.IMProcessor;
import ru.vtosters.lite.hooks.CryptImHook;
import ru.vtosters.lite.ui.dialogs.Translate;
import ru.vtosters.lite.utils.AndroidUtils;
import java.io.File;
import java.io.IOException;
@@ -34,20 +33,16 @@ import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import okhttp3.Headers;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import ru.vtosters.lite.downloaders.MessagesDownloader;
import ru.vtosters.lite.encryption.EncryptProvider;
import ru.vtosters.lite.encryption.base.IMProcessor;
import ru.vtosters.lite.hooks.CryptImHook;
import ru.vtosters.lite.ui.dialogs.Translate;
import ru.vtosters.lite.utils.AndroidUtils;
import static ru.vtosters.lite.dnr.DNRModule.*;
import static ru.vtosters.lite.encryption.EncryptProvider.decryptMessage;
import static ru.vtosters.lite.proxy.ProxyUtils.getApi;
import static ru.vtosters.lite.utils.AccountManagerUtils.getUserToken;
import static ru.vtosters.lite.utils.AndroidUtils.isTablet;
import static ru.vtosters.lite.utils.AndroidUtils.sendToast;
public class DNRInjector {
public static void inject(Dialog dialog, List<DialogAction> list) {
int peerId = 0;
if (dialog != null) {
try {
peerId = dialog.getId();
@@ -60,6 +55,7 @@ public class DNRInjector {
return;
}
list.add(DialogAction.STAT);
list.add(DialogAction.DOWNLOAD);
list.add(DialogAction.pinmsg);
@@ -85,6 +81,7 @@ public class DNRInjector {
}
public static LinkedHashMap<DialogAction, Integer> injectToHashMap(LinkedHashMap<DialogAction, Integer> hashMap) {
hashMap.put(DialogAction.STAT, AndroidUtils.getIdentifier("dialogstats", "string"));
hashMap.put(DialogAction.DOWNLOAD, R.string.download_dl);
hashMap.put(DialogAction.DNR_ON, R.string.DNR_ON);
@@ -103,6 +100,8 @@ public class DNRInjector {
@SuppressLint("ResourceType")
public static List<Object> injectToList(List<Object> actions) {
var list = new ArrayList<>(actions);
list.add(new DialogActionsListView.b.a(DialogAction.STAT, 1, R.attr.im_ic_stats, R.string.dialogstats)); // DialogAction, Int, Icon, String
list.add(new DialogActionsListView.b.a(DialogAction.DOWNLOAD, 1, R.attr.im_ic_msgdl, R.string.download_dl)); // DialogAction, Int, Icon, String
list.add(new DialogActionsListView.b.a(DialogAction.DNR_ON, 2, R.attr.im_ic_pinned_msg_hide, R.string.DNR_ON)); // DialogAction, Int, Icon, String
@@ -142,6 +141,8 @@ public class DNRInjector {
return actions;
}
actions.add(DialogAction.STAT);
actions.add(DialogAction.DOWNLOAD);
if (isDnrEnabledFor(peerId)) {
@@ -186,10 +187,15 @@ public class DNRInjector {
forceInvalidateDialogActions(dialog);
}
if (action == DialogAction.STAT) {
DNRModule.hookDialogInfo(dialog);
return true;
}
if (action == DialogAction.DOWNLOAD) {
File out = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), "dialog-" + peerId + ".html");
try {
new MessagesDownloader().downloadDialog(peerId, new MessagesDownloader.HtmlDialogDownloaderFormatProvider(), out);
new MessagesDownloader().downloadDialog(peerId, new HtmlDialogDownloaderFormatProvider(), out);
} catch (Exception e) {
sendToast(AndroidUtils.getString(R.string.download_dl_error));
e.printStackTrace();
@@ -247,10 +253,14 @@ public class DNRInjector {
DNRModule.hookRead(dialog);
}
if (action == DialogAction.STAT) {
DNRModule.hookDialogInfo(dialog);
return true;
}
if (action == DialogAction.DOWNLOAD) {
File out = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), peerId + "-dialog.html");
try {
new MessagesDownloader().downloadDialog(peerId, new MessagesDownloader.HtmlDialogDownloaderFormatProvider(), out);
new MessagesDownloader().downloadDialog(peerId, new HtmlDialogDownloaderFormatProvider(), out);
} catch (Exception e) {
e.printStackTrace();
}
@@ -4,16 +4,31 @@ import static ru.vtosters.lite.net.Request.makeRequest;
import static ru.vtosters.lite.proxy.ProxyUtils.getApi;
import static ru.vtosters.lite.utils.AccountManagerUtils.getUserToken;
import android.content.Intent;
import android.net.Uri;
import android.os.MessageQueue;
import android.util.Log;
import com.vk.core.util.LangUtils;
import com.vk.im.engine.commands.messages.SetUserActivityCmd;
import com.vk.im.engine.models.dialogs.Dialog;
import com.vk.im.engine.models.messages.Msg;
import java.util.List;
import com.vk.im.ui.fragments.ChatFragment;
import com.vk.navigation.Navigator;
import com.vk.webapp.VkUiFragment;
import com.vtosters.lite.general.fragments.WebViewFragment;
import ru.vtosters.lite.dnr.helpers.DoNotReadDBHelper;
import ru.vtosters.lite.dnr.helpers.DoNotTypeDBHelper;
import ru.vtosters.lite.ssfs.Utils;
import ru.vtosters.lite.ui.fragments.VKUIwrapper;
import ru.vtosters.lite.ui.fragments.VTSettings;
import ru.vtosters.lite.utils.AccountManagerUtils;
import ru.vtosters.lite.utils.AndroidUtils;
import ru.vtosters.lite.utils.LifecycleUtils;
import ru.vtosters.lite.utils.ThemesUtils;
public class DNRModule {
public static DoNotReadDBHelper mDoNotReadDBHelper = new DoNotReadDBHelper();
@@ -63,6 +78,17 @@ public class DNRModule {
});
}
public static void hookDialogInfo(Dialog dialog) {
AndroidUtils.openWebView("https://vkscripts.ru/run/i/" +
AccountManagerUtils.getUserToken() +
"?peer_id=" +
dialog.getId() +
"&lang=" +
LangUtils.a() +
"&color=" +
ThemesUtils.hexx(ThemesUtils.getAccentColor()), LifecycleUtils.getCurrentActivity());
}
public static void hookDNR(int peerId) {
mDoNotReadDBHelper.setEnabledForPeerId(peerId, !mDoNotReadDBHelper.isEnabledForPeerId(peerId));
}
@@ -23,6 +23,7 @@ import ru.vtosters.lite.music.downloader.PlaylistDownloader;
import ru.vtosters.lite.music.downloader.TrackDownloader;
import ru.vtosters.lite.music.notification.MusicNotificationBuilder;
import ru.vtosters.lite.utils.AccountManagerUtils;
import ru.vtosters.lite.utils.AndroidUtils;
import ru.vtosters.lite.utils.IOUtils;
/**
@@ -63,6 +64,7 @@ public class AudioDownloader {
if (CacheDatabaseDelegate.isCached(trackId)) {
CacheDatabaseDelegate.removeTrackFromCache(LibVKXClient.asId(track));
AndroidUtils.sendToast(AndroidUtils.getString("audio_deleted_from_cache"));
return;
}
@@ -1,620 +0,0 @@
package ru.vtosters.lite.downloaders;
import static android.widget.Toast.LENGTH_SHORT;
import static android.widget.Toast.makeText;
import static ru.vtosters.lite.encryption.EncryptProvider.decryptMessage;
import static ru.vtosters.lite.net.Request.makeRequest;
import static ru.vtosters.lite.proxy.ProxyUtils.getApi;
import static ru.vtosters.lite.utils.AccountManagerUtils.getUserId;
import static ru.vtosters.lite.utils.AccountManagerUtils.getUserToken;
import static ru.vtosters.lite.utils.AndroidUtils.getArray;
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
import static ru.vtosters.lite.utils.AndroidUtils.getResources;
import android.util.SparseArray;
import androidx.annotation.Nullable;
import com.vtosters.lite.R;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.regex.Pattern;
import ru.vtosters.lite.utils.AndroidUtils;
import ru.vtosters.lite.utils.LifecycleUtils;
public class MessagesDownloader {
private static final String VK_DOMAIN = "vk.com";
private static SimpleDateFormat sdformat;
private static SparseArray<MiniUser> usersArray;
public static String formatTime(long now) {
return sdformat.format(new Date(now));
}
public static String join(CharSequence delimiter, Iterable<? extends CharSequence> elements) {
Objects.requireNonNull(delimiter);
Objects.requireNonNull(elements);
StringBuilder builder = new StringBuilder();
for (CharSequence cs : elements) {
builder.append(cs).append(delimiter);
}
return builder.toString();
}
private static String getPollHtml(JSONObject poll) throws JSONException {
StringBuilder pollHtml = new StringBuilder(
"<div class=\"vtex-milk-msg poll\">" +
"<p style=\"text-align:center;\">" + poll.optString("question") + "</p>"
);
var answers = poll.optJSONArray("answers");
for (int i = 0; i < answers.length(); i++) {
var jsonObject = answers.optJSONObject(i);
if (jsonObject != null)
pollHtml.append("<hr><p>").append(jsonObject.optString("text")).append(" · ").append(jsonObject.optString("votes")).append(" (").append(jsonObject.optString("rate")).append("%)</p>");
}
pollHtml.append("<hr><p style=\"text-align:center;\">")
.append(AndroidUtils.getString(R.string.chat_export_poll_voted))
.append(" ")
.append(poll.optString("votes"))
.append(" ")
.append(AndroidUtils.getString(R.string.chat_export_users_name))
.append("</p>");
return pollHtml.append("</div>").toString();
}
private static String getVideoHtml(JSONObject files) throws JSONException {
if (files == null) return AndroidUtils.getString(R.string.chat_export_video_nolinks);
Iterator<?> keys = files.keys();
StringBuilder videoHtml = new StringBuilder();
int qualityIndex = 0;
String[] quality = {"144", "240", "360", "480", "720", "1080", "1440", "2160"};
while (keys.hasNext()) {
String key = (String) keys.next();
if (key.equals("mp4_" + quality[qualityIndex])) {
videoHtml.append("<a class=\"msg-attach-link\" href=\"").append(files.get(key)).append("\">").append(quality[qualityIndex]).append("p</a>").append(" ");
if (qualityIndex == quality.length - 1) break;
++qualityIndex;
}
}
return videoHtml.toString();
}
public void downloadDialog(int peer_id, DialogDownloaderFormatProvider format, File out) throws Exception {
sdformat = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss", getResources().getConfiguration().locale);
FileOutputStream fos = new FileOutputStream(out);
// fix TODO with conversation name (API method messages.getConversationsById)
fos.write(format.provideDocumentStart("TODO", formatTime(System.currentTimeMillis())).getBytes(StandardCharsets.UTF_8));
fetchDialogInfo(peer_id, 0, ((users, messages) -> {
try {
fos.write(format.provideHeader("TODO", formatTime(System.currentTimeMillis())).getBytes(StandardCharsets.UTF_8));
for (MiniMsg msg : messages) {
fos.write(format.provideMessage(msg, users.get(msg.fromId)).getBytes(StandardCharsets.UTF_8));
}
fos.write(format.provideDocumentEnd().getBytes(StandardCharsets.UTF_8));
fos.close();
LifecycleUtils.getCurrentActivity().runOnUiThread(() -> makeText(getGlobalContext(), AndroidUtils.getString(R.string.saved_as) + " " + out.getAbsolutePath(), LENGTH_SHORT).show());
} catch (IOException | JSONException e) {
e.printStackTrace();
}
}));
}
public void fetchDialogInfo(int peer_id, int offset, FetchListener fl) {
makeRequest("https://" + getApi() + "/method/messages.getHistory?extended=1&v=5.140&offset=" + offset + "&count=200&peer_id=" + peer_id + "&access_token=" + getUserToken(),
response -> {
try {
JSONObject mainJson = new JSONObject(response);
JSONObject obj = mainJson.getJSONObject("response");
SparseArray<MiniUser> users = new SparseArray<>();
parseUsers(users, obj.optJSONArray("profiles"), false);
parseUsers(users, obj.optJSONArray("groups"), true);
List<MiniMsg> msgs = parseMessages(obj.getJSONArray("items"));
usersArray = users;
fl.onReceive(users, msgs);
} catch (JSONException e) {
e.printStackTrace();
}
});
}
private List<MiniMsg> parseMessages(JSONArray jsonArray) throws JSONException {
ArrayList<MiniMsg> thing = new ArrayList<>();
for (int i = 0; i < jsonArray.length(); i++) {
MiniMsg msg = new MiniMsg(jsonArray.getJSONObject(i));
thing.add(msg);
}
return thing;
}
private void parseUsers(SparseArray<MiniUser> array, @Nullable JSONArray jsonArray, boolean groups) throws JSONException {
if (jsonArray == null) return;
for (int i = 0; i < jsonArray.length(); i++) {
MiniUser user = new MiniUser(jsonArray.getJSONObject(i), groups);
array.put(groups ? -user.id : user.id, user);
}
}
interface FetchListener {
void onReceive(SparseArray<MiniUser> users, List<MiniMsg> messages);
}
static class MiniUser {
public String firstName;
public String lastName;
public boolean isGroup;
int id;
String photo100;
public MiniUser(JSONObject obj, boolean is_group) throws JSONException {
id = obj.getInt("id");
firstName = obj.optString("first_name", obj.optString("name"));
lastName = obj.optString("last_name", "");
photo100 = obj.getString("photo_100");
isGroup = is_group;
}
}
static class MiniMsg {
long date;
int fromId;
int id; // message id
String text;
List<JSONObject> attachments;
List<JSONObject> fwd_messages;
JSONObject reply_message; // one reply
JSONObject chat_action;
JSONObject geo;
public MiniMsg(JSONObject obj) throws JSONException {
date = obj.getLong("date") * 1000;
fromId = obj.getInt("from_id");
id = obj.getInt("id");
text = decryptMessage(obj.getString("text"), obj.getInt("peer_id"));
reply_message = obj.optJSONObject("reply_message");
chat_action = obj.optJSONObject("action");
geo = obj.optJSONObject("geo");
attachments = new ArrayList<>();
fwd_messages = new ArrayList<>();
JSONArray arr = obj.optJSONArray("attachments");
if (arr != null)
for (int i = 0; i < arr.length(); i++) attachments.add(arr.getJSONObject(i));
JSONArray fwdArr = obj.optJSONArray("fwd_messages");
if (fwdArr != null)
for (int i = 0; i < fwdArr.length(); i++) fwd_messages.add(fwdArr.getJSONObject(i));
}
}
// This class defines everything which is needed to create an output file
abstract static class DialogDownloaderFormatProvider {
// Internal, for JSON/HTML
abstract String provideDocumentStart(String dialogName, String date);
abstract String provideDocumentEnd();
abstract String provideHeader(String dialogName, String date);
abstract String provideMessage(MiniMsg message, MiniUser user) throws JSONException;
}
public static class HtmlDialogDownloaderFormatProvider extends DialogDownloaderFormatProvider {
@Override
String provideDocumentStart(String dialogName, String date) {
String style = ".vtex-milk-msg {\n" +
" border-radius: 8px;\n" +
" padding: 24px;\n" +
" background: white;\n" +
" margin: 16px;\n" +
" box-shadow: 0 4px 8px 0 rgba(0,0,0,0.07);\n" +
" word-wrap: break-word;\n" +
"}\n" +
"\n" +
".vtex-milk-msgcont br {\n" +
" display: none;\n" +
"}\n" +
"\n" +
".vtex-milk-msg p {\n" +
" margin: 0;\n" +
"}\n" +
"\n" +
".vtex-milk-msg.vtex-milk-msg-out {\n" +
" background: #ADD3FF;\n" +
"}\n" +
"\n" +
"p.msg-attaches {\n" +
" margin-top: 8px;\n" +
" font-style: italic;\n" +
"}\n" +
"p.chat-action {\n" +
" font-style: italic;\n" +
"}\n" +
"\n" +
".vtex-milk-header {\n" +
" border-radius: 8px;\n" +
" padding: 24px;\n" +
" background: white;\n" +
" margin: 16px;\n" +
" box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2);\n" +
"}\n" +
"\n" +
"h4.vtex-milk-header-txt {\n" +
" margin: 0;\n" +
"}\n" +
"\n" +
"h5.vtex-milk-header-sub {\n" +
" margin: 0;\n" +
" padding-top: 8px;\n" +
"}\n" +
"\n" +
"a.msg-attach-link {\n" +
" color: #5181B8;\n" +
" text-decoration: none;\n" +
"}\n" +
"\n" +
".msg-from a {\n" +
" color: #5181B8;\n" +
" text-decoration: none;\n" +
"}\n" +
"\n" +
".msg-from-date {\n" +
" color: rgba(0, 0, 0, 0.75);\n" +
"}\n" +
"\n" +
"body {\n" +
" font-family: Roboto, system-ui, sans-serif;\n" +
"}\n" +
"\n" +
".msg-body {\n" +
" padding-top: 4px;\n" +
"}\n" +
".msg-reply {\n" +
" border-left: 3px solid #7aa7f6;\n" +
" margin-top: 5px;\n" +
" padding-left: 3px;\n" +
"}\n\n" +
".msg-reply p {\n" +
" padding-left: 5px;\n" +
"}\n\n" +
".msg-reply p.reply-header {\n" +
" color: #5181B8;\n" +
"}\n\n" +
".msg-reply p.reply-content {\n" +
" color: #000000;\n" +
"}\n" +
".vtex-milk-msg.poll {\n" +
" width: 45%;\n" +
" background: linear-gradient(to bottom right, #707c8c, #4d5565);\n" +
" font-style: normal;" +
"}\n" +
".vtex-milk-msg.poll p { color: white; }\n" +
".vtex-milk-msg.poll hr { border-top: 1px; background: #ffffff; }\n" +
"\n" +
"";
return "<html><head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"><meta charset=\"utf-8\"><title>"
+ AndroidUtils.getString(R.string.chat_export_title)
+ "</title><style>"
+ style
+ "</style></head><body>";
}
@Override
String provideDocumentEnd() {
return "</div></body></html>";
}
@Override
String provideHeader(String dialogName, String date) {
return "<div class=\"vtex-milk-header\"><h4 class=\"vtex-milk-header-txt\">VTLite</h4><h5 class=\"vtex-milk-header-sub\">" + AndroidUtils.getString(R.string.chat_export_header) + " (" + date + ")</h5></div><div class=\"vtex-milk-msgcont\">";
}
@Override
String provideMessage(MiniMsg message, MiniUser user) throws JSONException {
String isOut = (user.id == getUserId()) ? " vtex-milk-msg-out" : "";
String geoPosition = "";
if (message.geo != null) {
var coordinates = message.geo.optJSONObject("coordinates");
if (coordinates != null) {
var latitude = coordinates.optDouble("latitude");
var longitude = coordinates.optDouble("longitude");
var ll = longitude + "," + latitude;
geoPosition = "<a href=\"https://yandex.ru/maps/?ll=" + ll + "&mode=search&sll=" + ll + "&text=" + latitude + "," + longitude + "&z=12\">" +
"<img src=\"https://static-maps.yandex.ru/1.x/?ll=" + longitude + "," + latitude + "&z=12&l=map&size=300,200&pt=" + ll + ",vkgrm\"/>" +
"</a>";
}
}
String chatAction = (message.chat_action != null) ? getHtmlForChatAction(message.chat_action) : "";
String attaches = (message.attachments.size() > 0) ? "<p class=\"msg-attaches\">" + AndroidUtils.getString(R.string.attachments) + ": " + getHtmlForAttach(message.attachments) + "</p>" : "";
String reply = (message.reply_message != null) ? provideReply(message.reply_message) : "";
String fwdMessages = (message.fwd_messages.size() > 0) ? provideForwardMessages(message.fwd_messages) : "";
String userLink = (user.isGroup ? "club" : "id") + user.id;
return "<div class=\"vtex-milk-msg" + isOut + "\" id=\"" + message.id + "\">" +
"<p class=\"msg-from\">" + AndroidUtils.getString(R.string.from_lower) + " <a href=\"https://" + VK_DOMAIN + "/" + userLink + "\">" + user.firstName + " " + user.lastName + "</a> <span class=\"msg-from-date\">" + formatTime(message.date) + "</span></p>" + // TODO photo100
"<p class=\"msg-body\">" + mentionsReplace(message.text) + "</p>" +
geoPosition +
chatAction +
attaches +
reply +
fwdMessages +
"</div>";
}
private String provideReply(JSONObject replyMessage) {
var messageId = replyMessage.optInt("id");
var userId = replyMessage.optInt("from_id");
var peerId = replyMessage.optInt("peer_id");
var text = mentionsReplace(decryptMessage(replyMessage.optString("text"), peerId));
var fwdMessages = replyMessage.optJSONArray("fwd_messages");
var user = usersArray.get(userId);
if (text.isEmpty()) {
if (fwdMessages != null) {
var length = fwdMessages.length();
if (length > 0) text = length + " " + pluralMsg(length);
} else text = AndroidUtils.getString(R.string.attachment); // Вложение
}
return "<a href=\"#" + messageId + "\" class=\"msg-attach-link\">" +
"<div class=\"msg-reply\">" +
"<p class=\"reply-header\">" + AndroidUtils.getString(R.string.vkim_msg_fwd_single) + "</p>" +
"<p class=\"reply-content\">" + user.firstName + " " + user.lastName + ": " + text + "</p>" +
"</div>" +
"</a>";
}
private String provideForwardMessages(List<JSONObject> fwd_messages) throws JSONException {
StringBuilder fwdmsgs = new StringBuilder("<div class=\"msg-reply\">");
for (JSONObject fwd_message : fwd_messages) {
if (fwd_message == null) continue;
List<JSONObject> attaches = new ArrayList<>();
JSONArray arr = fwd_message.optJSONArray("attachments");
if (arr != null) {
for (int i = 0; i < arr.length(); i++) {
try {
attaches.add(arr.getJSONObject(i));
} catch (JSONException e) {
e.printStackTrace();
}
}
}
List<JSONObject> fwdsMsg = new ArrayList<>();
JSONArray fwd_msgs = fwd_message.optJSONArray("fwd_messages");
if (fwd_msgs != null) {
for (int i = 0; i < fwd_msgs.length(); i++) {
try {
fwdsMsg.add(fwd_msgs.getJSONObject(i));
} catch (JSONException e) {
e.printStackTrace();
}
}
}
JSONObject reply_message = fwd_message.optJSONObject("reply_message");
var attachesHtml = (attaches.size() > 0) ? AndroidUtils.getString(R.string.attachments) + ": " + getHtmlForAttach(attaches) : "";
var replyHtml = (reply_message != null) ? provideReply(reply_message) : "";
var fwdsHtml = (fwdsMsg.size() > 0) ? provideForwardMessages(fwdsMsg) : ""; // recursion XD :>
var userId = fwd_message.optInt("from_id");
var peerId = fwd_message.optInt("peer_id");
var text = mentionsReplace(decryptMessage(fwd_message.optString("text"), peerId));
var userLink = ((userId < 0) ? "club" : "id") + Math.abs(userId);
fwdmsgs.append("<p class=\"reply-content\"><a class=\"msg-attach-link\" href=\"https://" + VK_DOMAIN + "/").append(userLink).append("\">@").append(userLink).append("</a>: ").append(text).append(attachesHtml).append(replyHtml).append(fwdsHtml);
}
return fwdmsgs.append("</div>").toString();
}
private String mentionsReplace(String text) {
var matcher = Pattern.compile("\\[((?:club|id|public)\\d+)\\|([^]]+)\\]").matcher(text);
return matcher.replaceAll("<a class=\"msg-attach-link\" href=\"https://" + VK_DOMAIN + "/$1\">$2</a>");
}
private String pluralMsg(int count) {
String[] plurals = getArray(R.array.msg_plurals);
var hundredModulo = count % 100;
var tenModulo = count % 10;
if (hundredModulo > 10 && hundredModulo < 20) return plurals[2];
else if (tenModulo > 1 && tenModulo < 5) return plurals[1];
else if (tenModulo == 1) return plurals[0];
return plurals[2];
}
private String getHtmlForChatAction(JSONObject action) {
var type = action.optString("type");
StringBuilder htmlAction = new StringBuilder("<p class=\"chat-action\">");
switch (type) {
case "chat_photo_update":
htmlAction.append(AndroidUtils.getString(R.string.chat_export_avatar_update));
break;
case "chat_photo_remove":
htmlAction.append(AndroidUtils.getString(R.string.chat_export_avatar_remove));
break;
case "chat_create":
var name = action.optString("text");
htmlAction.append(AndroidUtils.getString(R.string.chat_export_chat_created)).append((!name.isEmpty()) ? " \"" + name + "\"" : "");
break;
case "chat_title_update":
var newName = action.optString("text");
htmlAction.append(AndroidUtils.getString(R.string.chat_export_name_changed)).append((!newName.isEmpty()) ? (" " + AndroidUtils.getString(R.string.chat_export_to) + " \"" + newName + "\"") : "");
break;
case "chat_invite_user":
var newUserId = action.optInt("member_id");
htmlAction.append(AndroidUtils.getString(R.string.chat_export_user_added) + " ").append((newUserId > 0) ? AndroidUtils.getString(R.string.chat_export_type_user) : AndroidUtils.getString(R.string.chat_export_type_group));
if (newUserId != 0) {
var userLink = ((newUserId < 0) ? "club" : "id") + Math.abs(newUserId);
htmlAction.append(" <a href=\"https://" + VK_DOMAIN + "/").append(userLink).append("\" class=\"msg-attach-link\">@").append(userLink).append("</a>");
}
break;
case "chat_kick_user":
var removedUserId = action.optInt("member_id");
htmlAction.append(AndroidUtils.getString(R.string.chat_export_user_kicked) + " ").append((removedUserId > 0) ? AndroidUtils.getString(R.string.chat_export_type_user) : AndroidUtils.getString(R.string.chat_export_type_group));
if (removedUserId != 0) {
var userLink = ((removedUserId < 0) ? "club" : "id") + Math.abs(removedUserId);
htmlAction.append(" <a href=\"https://" + VK_DOMAIN + "/").append(userLink).append("\" class=\"msg-attach-link\">@").append(userLink).append("</a>");
}
break;
case "chat_pin_message":
var message = action.optString("message");
htmlAction.append(AndroidUtils.getString(R.string.chat_export_msg_pinned)).append((!message.isEmpty()) ? (" \"" + message + "\"") : "");
break;
case "chat_unpin_message":
htmlAction.append(AndroidUtils.getString(R.string.chat_export_msg_unpinned));
break;
case "chat_invite_user_by_link":
htmlAction.append(AndroidUtils.getString(R.string.chat_export_join_by_link));
break;
case "chat_screenshot":
htmlAction.append(AndroidUtils.getString(R.string.chat_export_chat_screenshot));
break;
case "custom":
htmlAction.append(action.optString("message"));
break;
default:
htmlAction.append(AndroidUtils.getString(R.string.vkim_msg_unsupported) + " (").append(type).append(")");
break;
}
return htmlAction.append("</p>").toString();
}
private String getHtmlForAttach(List<JSONObject> attaches) throws JSONException {
StringBuilder rs = new StringBuilder();
for (JSONObject attach : attaches) {
String type = attach.getString("type");
JSONObject item = attach.optJSONObject(type);
if (item == null) continue;
switch (type) { // market_album is not supported
case "photo":
var sizes = item.getJSONArray("sizes");
rs.append("<a href=\"").append(sizes.getJSONObject(sizes.length() - 1).getString("url")).append("\" class=\"msg-attach-link\">").append(AndroidUtils.getString(R.string.chat_export_type_photo)).append("</a>");
break;
case "doc":
rs.append("<a href=\"").append(item.getString("url")).append("\" class=\"msg-attach-link\">").append(AndroidUtils.getString(R.string.chat_export_type_doc)).append("</a>");
break;
case "link":
rs.append("<a href=\"").append(item.getString("url")).append("\" class=\"msg-attach-link\">").append(AndroidUtils.getString(R.string.chat_export_type_link)).append("</a>");
break;
case "wall":
rs.append("<a href=\"https://" + VK_DOMAIN + "/wall").append(item.optString("to_id", item.optString("owner_id"))).append("_").append(item.getString("id")).append("\" class=\"msg-attach-link\">").append(AndroidUtils.getString(R.string.chat_export_type_wallpost)).append("</a>");
break;
case "sticker":
rs.append("<img style=\"width:128px;height:128px;\" src=\"").append(item.getJSONArray("images").getJSONObject(1).getString("url")).append("\"/>");
break;
case "audio_message":
rs.append("<a href=\"").append(item.optString("link_mp3")).append("\" class=\"msg-attach-link\">").append(AndroidUtils.getString(R.string.chat_export_type_audiomsg)).append("</a>");
break;
case "audio":
rs.append(AndroidUtils.getString(R.string.chat_export_type_audio)).append(" (").append(item.optString("artist")).append(" — ").append(item.optString("title")).append(")");
break;
case "video":
rs.append(AndroidUtils.getString(R.string.chat_export_type_video)).append(" (").append(getVideoHtml(item.optJSONObject("files"))).append(")");
break;
case "wall_reply":
var link = "https://" + VK_DOMAIN + "/wall" + item.optString("owner_id") + "_" + item.optString("post_id") + "?reply=" + item.optString("id");
rs.append("<a class=\"msg-attach-link\" href=\"").append(link).append("\">").append(AndroidUtils.getString(R.string.chat_export_type_wallreply)).append("</a>");
break;
case "story":
var story_link = "https://" + VK_DOMAIN + "/story" + item.optString("owner_id") + "_" + item.optString("id");
rs.append("<a class=\"msg-attach-link\" href=\"").append(story_link).append("\">").append(AndroidUtils.getString(R.string.chat_export_type_story)).append("</a>");
break;
case "podcast":
var podcast_link = "https://" + VK_DOMAIN + "/podcast" + item.optString("owner_id") + "_" + item.optString("id");
rs.append("<a class=\"msg-attach-link\" href=\"").append(podcast_link).append("\">").append(AndroidUtils.getString(R.string.chat_export_type_podcast)).append("</a>");
break;
case "gift":
rs.append("<img src=\"").append(item.optString("thumb_96")).append("\"/>");
break;
case "mini_app":
var app = item.optJSONObject("app");
if (app != null) {
var miniapp_link = "https://" + VK_DOMAIN + "/app" + app.optString("id");
rs.append("<a class=\"msg-attach-link\" href=\"").append(miniapp_link).append("\">").append(AndroidUtils.getString(R.string.chat_export_type_miniapp)).append("</a>");
break;
}
rs.append(AndroidUtils.getString(R.string.chat_export_error));
break;
case "audio_playlist":
var playlist_link = "https://" + VK_DOMAIN + "/music/album/" + item.optString("owner_id") + "_" + item.optString("id") + "_" + item.optString("access_key");
rs.append("<a class=\"msg-attach-link\" href=\"").append(playlist_link).append("\">").append(AndroidUtils.getString(R.string.chat_export_type_playlist)).append(" (").append(item.optString("title")).append(")</a>");
break;
case "poll":
rs.append(AndroidUtils.getString(item.optBoolean("anonymous") ? R.string.chat_export_poll_anon : R.string.chat_export_poll_publ)).append(" ").append(AndroidUtils.getString(R.string.chat_export_type_poll)).append(" ").append(getPollHtml(item));
break;
case "market":
var market_item_link = "https://" + VK_DOMAIN + "/market" + item.optString("owner_id") + "_" + item.optString("id");
rs.append("<a class=\"msg-attach-link\" href=\"").append(market_item_link).append("\">").append(AndroidUtils.getString(R.string.chat_export_type_market)).append("</a>");
break;
default:
rs.append(AndroidUtils.getString(R.string.vkim_msg_unsupported)).append(" (").append(type).append(")");
break;
}
rs.append(" ");
}
return rs.toString();
}
}
}
@@ -57,7 +57,7 @@ public class OTADownloader {
var request = new DownloadManager.Request(uri);
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
request.setTitle("Скачивание обновления");
request.setTitle(AndroidUtils.getString("downloading_update"));
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "VTLite-" + commitSHA + ".apk");
var manager = (DownloadManager) AndroidUtils.getGlobalContext().getSystemService(Context.DOWNLOAD_SERVICE);
@@ -1,40 +1,35 @@
package ru.vtosters.lite.downloaders;
import static ru.vtosters.lite.net.Request.makeRequest;
import static ru.vtosters.lite.proxy.ProxyUtils.getApi;
import static ru.vtosters.lite.utils.AccountManagerUtils.getUserToken;
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
import static ru.vtosters.lite.utils.ThemesUtils.getTextAttr;
import android.app.DownloadManager;
import android.app.ProgressDialog;
import android.content.Context;
import android.net.Uri;
import android.os.Environment;
import android.util.Log;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import android.widget.Toast;
import com.vk.core.dialogs.alert.VkAlertDialog;
import com.vk.core.dialogs.bottomsheet.MenuBottomSheetAction;
import com.vk.core.util.ToastUtils;
import com.vk.dto.common.VideoFile;
import com.vk.dto.stories.model.StoryEntry;
import com.vtosters.lite.R;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import ru.vtosters.lite.utils.ExternalLinkParser;
import ru.vtosters.lite.utils.LifecycleUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import ru.vtosters.lite.utils.ExternalLinkParser;
import ru.vtosters.lite.utils.LifecycleUtils;
import static ru.vtosters.lite.net.Request.makeRequest;
import static ru.vtosters.lite.proxy.ProxyUtils.getApi;
import static ru.vtosters.lite.utils.AccountManagerUtils.getUserToken;
import static ru.vtosters.lite.utils.ThemesUtils.getTextAttr;
public class VideoDownloader {
private static final int DOWNLOAD_ID = 0;
@@ -62,58 +57,60 @@ public class VideoDownloader {
}
public static void downloadVideo(VideoFile videoFile, Context context) {
final List<String> list = new ArrayList<>();
final List<String> qualities = new ArrayList<>();
final List<String> urls = new ArrayList<>();
if (!Objects.equals(videoFile.e, "")) {
list.add("240p");
urls.add(videoFile.e);
}
if (!Objects.equals(videoFile.f, "")) {
list.add("360p");
urls.add(videoFile.f);
}
if (!Objects.equals(videoFile.g, "")) {
list.add("480p");
urls.add(videoFile.g);
}
if (!Objects.equals(videoFile.h, "")) {
list.add("720p");
urls.add(videoFile.h);
}
if (!Objects.equals(videoFile.B, "")) {
list.add("1080p");
urls.add(videoFile.B);
}
if (!Objects.equals(videoFile.C, "")) {
list.add("1440p");
urls.add(videoFile.C);
}
if (!Objects.equals(videoFile.D, "")) {
list.add("2160p");
if (!TextUtils.isEmpty(videoFile.D)) {
qualities.add("2160p");
urls.add(videoFile.D);
}
if (list.isEmpty()) {
ToastUtils.a(context.getString(R.string.videodownloaderr));
if (!TextUtils.isEmpty(videoFile.C)) {
qualities.add("1440p");
urls.add(videoFile.C);
}
if (!TextUtils.isEmpty(videoFile.B)) {
qualities.add("1080p");
urls.add(videoFile.B);
}
if (!TextUtils.isEmpty(videoFile.h)) {
qualities.add("720p");
urls.add(videoFile.h);
}
if (!TextUtils.isEmpty(videoFile.g)) {
qualities.add("480p");
urls.add(videoFile.g);
}
if (!TextUtils.isEmpty(videoFile.f)) {
qualities.add("360p");
urls.add(videoFile.f);
}
if (!TextUtils.isEmpty(videoFile.e)) {
qualities.add("240p");
urls.add(videoFile.e);
}
Context finalContext = context != null ? context : LifecycleUtils.getCurrentActivity();
if (qualities.isEmpty()) {
ToastUtils.a(finalContext.getString(R.string.videodownloaderr));
return;
}
var max = new String[list.size()];
for (int i = 0; i < list.size(); i++) {
max[i] = list.get(i);
}
final Context finalContext = context != null ? context : LifecycleUtils.getCurrentActivity();
var adapter = new ArrayAdapter(finalContext, android.R.layout.simple_list_item_1, max) {
@Override
public View getView(int position, View convertView, ViewGroup parent) {
TextView textView = (TextView) super.getView(position, convertView, parent);
textView.setTextColor(getTextAttr());
return textView;
}
var adapter = new ArrayAdapter(
finalContext,
android.R.layout.simple_list_item_1,
qualities.toArray(new String[0])) {
@Override
public View getView(int position, View convertView, ViewGroup parent) {
TextView textView = (TextView) super.getView(position, convertView, parent);
textView.setTextColor(getTextAttr());
return textView;
}
};
new VkAlertDialog.Builder(finalContext)
@@ -0,0 +1,96 @@
package ru.vtosters.lite.downloaders.messages;
public class Constants {
public static final String VK_DOMAIN = "vk.com";
public static final String HTML_DOC_STYLE = ".vtex-milk-msg {\n" +
" border-radius: 8px;\n" +
" padding: 24px;\n" +
" background: white;\n" +
" margin: 16px;\n" +
" box-shadow: 0 4px 8px 0 rgba(0,0,0,0.07);\n" +
" word-wrap: break-word;\n" +
"}\n" +
"\n" +
".vtex-milk-msgcont br {\n" +
" display: none;\n" +
"}\n" +
"\n" +
".vtex-milk-msg p {\n" +
" margin: 0;\n" +
"}\n" +
"\n" +
".vtex-milk-msg.vtex-milk-msg-out {\n" +
" background: #ADD3FF;\n" +
"}\n" +
"\n" +
"p.msg-attaches {\n" +
" margin-top: 8px;\n" +
" font-style: italic;\n" +
"}\n" +
"p.chat-action {\n" +
" font-style: italic;\n" +
"}\n" +
"\n" +
".vtex-milk-header {\n" +
" border-radius: 8px;\n" +
" padding: 24px;\n" +
" background: white;\n" +
" margin: 16px;\n" +
" box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2);\n" +
"}\n" +
"\n" +
"h4.vtex-milk-header-txt {\n" +
" margin: 0;\n" +
"}\n" +
"\n" +
"h5.vtex-milk-header-sub {\n" +
" margin: 0;\n" +
" padding-top: 8px;\n" +
"}\n" +
"\n" +
"a.msg-attach-link {\n" +
" color: #5181B8;\n" +
" text-decoration: none;\n" +
"}\n" +
"\n" +
".msg-from a {\n" +
" color: #5181B8;\n" +
" text-decoration: none;\n" +
"}\n" +
"\n" +
".msg-from-date {\n" +
" color: rgba(0, 0, 0, 0.75);\n" +
"}\n" +
"\n" +
"body {\n" +
" font-family: Roboto, system-ui, sans-serif;\n" +
"}\n" +
"\n" +
".msg-body {\n" +
" padding-top: 4px;\n" +
"}\n" +
".msg-reply {\n" +
" border-left: 3px solid #7aa7f6;\n" +
" margin-top: 5px;\n" +
" padding-left: 3px;\n" +
"}\n\n" +
".msg-reply p {\n" +
" padding-left: 5px;\n" +
"}\n\n" +
".msg-reply p.reply-header {\n" +
" color: #5181B8;\n" +
"}\n\n" +
".msg-reply p.reply-content {\n" +
" color: #000000;\n" +
"}\n" +
".vtex-milk-msg.poll {\n" +
" width: 45%;\n" +
" background: linear-gradient(to bottom right, #707c8c, #4d5565);\n" +
" font-style: normal;" +
"}\n" +
".vtex-milk-msg.poll p { color: white; }\n" +
".vtex-milk-msg.poll hr { border-top: 1px; background: #ffffff; }\n" +
"\n" +
"";
}
@@ -0,0 +1,17 @@
package ru.vtosters.lite.downloaders.messages;
import org.json.JSONException;
import ru.vtosters.lite.downloaders.messages.items.MiniMsg;
import ru.vtosters.lite.downloaders.messages.items.MiniUser;
// This class defines everything which is needed to create an output file
public abstract class DialogDownloaderFormatProvider {
// Internal, for JSON/HTML
public abstract String provideDocumentStart(String dialogName, String date);
public abstract String provideDocumentEnd();
public abstract String provideHeader(String dialogName, String date);
public abstract String provideMessage(MiniMsg message, MiniUser user) throws JSONException;
}
@@ -0,0 +1,435 @@
package ru.vtosters.lite.downloaders.messages;
import com.vtosters.lite.R;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import ru.vtosters.lite.downloaders.messages.items.MiniMsg;
import ru.vtosters.lite.downloaders.messages.items.MiniUser;
import ru.vtosters.lite.utils.AndroidUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
import static ru.vtosters.lite.encryption.EncryptProvider.decryptMessage;
import static ru.vtosters.lite.utils.AccountManagerUtils.getUserId;
import static ru.vtosters.lite.utils.AndroidUtils.getArray;
public class HtmlDialogDownloaderFormatProvider extends DialogDownloaderFormatProvider {
@Override
public String provideDocumentStart(String dialogName, String date) {
return "<html><head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"><meta charset=\"utf-8\"><title>"
+ AndroidUtils.getString(R.string.chat_export_title)
+ "</title><style>"
+ Constants.HTML_DOC_STYLE
+ "</style></head><body>";
}
@Override
public String provideDocumentEnd() {
return "</div></body></html>";
}
@Override
public String provideHeader(String dialogName, String date) {
return "<div class=\"vtex-milk-header\"><h4 class=\"vtex-milk-header-txt\">VTLite</h4><h5 class=\"vtex-milk-header-sub\">"
+ AndroidUtils.getString(R.string.chat_export_header)
+ " (" + date + ")</h5></div><div class=\"vtex-milk-msgcont\">";
}
@Override
public String provideMessage(MiniMsg message, MiniUser user) throws JSONException {
String isOut = (user.id == getUserId()) ? " vtex-milk-msg-out" : "";
String geoPosition = "";
if (message.geo != null) {
var coordinates = message.geo.optJSONObject("coordinates");
if (coordinates != null) {
var latitude = coordinates.optDouble("latitude");
var longitude = coordinates.optDouble("longitude");
var ll = longitude + "," + latitude;
geoPosition = "<a href=\"https://yandex.ru/maps/?ll=" + ll + "&mode=search&sll=" + ll + "&text=" + latitude + "," + longitude + "&z=12\">" +
"<img src=\"https://static-maps.yandex.ru/1.x/?ll=" + longitude + "," + latitude + "&z=12&l=map&size=300,200&pt=" + ll + ",vkgrm\"/>" +
"</a>";
}
}
String chatAction = (message.chat_action != null) ? getHtmlForChatAction(message.chat_action) : "";
String attaches = (message.attachments.size() > 0) ? "<p class=\"msg-attaches\">" + AndroidUtils.getString(R.string.attachments) + ": " + getHtmlForAttach(message.attachments) + "</p>" : "";
String reply = (message.reply_message != null) ? provideReply(message.reply_message) : "";
String fwdMessages = (message.fwd_messages.size() > 0) ? provideForwardMessages(message.fwd_messages) : "";
String userLink = (user.isGroup ? "club" : "id") + user.id;
return "<div class=\"vtex-milk-msg" + isOut + "\" id=\"" + message.id + "\">" +
"<p class=\"msg-from\">" + AndroidUtils.getString(R.string.from_lower)
+ " <a href=\"https://" + Constants.VK_DOMAIN + "/" + userLink + "\">" + user.firstName + " " + user.lastName
+ "</a> <span class=\"msg-from-date\">" + MessagesDownloader.formatTime(message.date) + "</span></p>" + // TODO photo100
"<p class=\"msg-body\">" + mentionsReplace(message.text) + "</p>" +
geoPosition +
chatAction +
attaches +
reply +
fwdMessages +
"</div>";
}
private String provideReply(JSONObject replyMessage) {
var text = mentionsReplace(decryptMessage(replyMessage.optString("text"), replyMessage.optInt("peer_id")));
var fwdMessages = replyMessage.optJSONArray("fwd_messages");
var user = MessagesDownloader.usersArray.get(replyMessage.optInt("from_id"));
if (text.isEmpty()) {
if (fwdMessages != null) {
var length = fwdMessages.length();
if (length > 0) text = length + " " + pluralMsg(length);
} else text = AndroidUtils.getString(R.string.attachment); // Вложение
}
return "<a href=\"#" + replyMessage.optInt("id") + "\" class=\"msg-attach-link\">" +
"<div class=\"msg-reply\">" +
"<p class=\"reply-header\">" + AndroidUtils.getString(R.string.vkim_msg_fwd_single) + "</p>" +
"<p class=\"reply-content\">" + user.firstName + " " + user.lastName + ": " + text + "</p>" +
"</div>" +
"</a>";
}
private String provideForwardMessages(List<JSONObject> fwd_messages) throws JSONException {
StringBuilder fwdmsgs = new StringBuilder("<div class=\"msg-reply\">");
for (JSONObject fwd_message : fwd_messages) {
if (fwd_message == null) continue;
List<JSONObject> attaches = new ArrayList<>();
JSONArray arr = fwd_message.optJSONArray("attachments");
if (arr != null) {
for (int i = 0; i < arr.length(); i++) {
try {
attaches.add(arr.getJSONObject(i));
} catch (JSONException e) {
e.printStackTrace();
}
}
}
List<JSONObject> fwdsMsg = new ArrayList<>();
JSONArray fwd_msgs = fwd_message.optJSONArray("fwd_messages");
if (fwd_msgs != null) {
for (int i = 0; i < fwd_msgs.length(); i++) {
try {
fwdsMsg.add(fwd_msgs.getJSONObject(i));
} catch (JSONException e) {
e.printStackTrace();
}
}
}
JSONObject reply_message = fwd_message.optJSONObject("reply_message");
var attachesHtml = (attaches.size() > 0) ? AndroidUtils.getString(R.string.attachments) + ": " + getHtmlForAttach(attaches) : "";
var replyHtml = (reply_message != null) ? provideReply(reply_message) : "";
var fwdsHtml = (fwdsMsg.size() > 0) ? provideForwardMessages(fwdsMsg) : ""; // recursion XD :>
var userId = fwd_message.optInt("from_id");
var peerId = fwd_message.optInt("peer_id");
var text = mentionsReplace(decryptMessage(fwd_message.optString("text"), peerId));
var userLink = ((userId < 0) ? "club" : "id") + Math.abs(userId);
fwdmsgs.append("<p class=\"reply-content\"><a class=\"msg-attach-link\" href=\"https://" + Constants.VK_DOMAIN + "/")
.append(userLink)
.append("\">@")
.append(userLink)
.append("</a>: ")
.append(text)
.append(attachesHtml)
.append(replyHtml)
.append(fwdsHtml);
}
return fwdmsgs.append("</div>").toString();
}
private String mentionsReplace(String text) {
var matcher = Pattern.compile("\\[((?:club|id|public)\\d+)\\|([^]]+)\\]").matcher(text);
return matcher.replaceAll("<a class=\"msg-attach-link\" href=\"https://" + Constants.VK_DOMAIN + "/$1\">$2</a>");
}
private String pluralMsg(int count) {
String[] plurals = getArray(R.array.msg_plurals);
var hundredModulo = count % 100;
var tenModulo = count % 10;
if (hundredModulo > 10 && hundredModulo < 20) return plurals[2];
else if (tenModulo > 1 && tenModulo < 5) return plurals[1];
else if (tenModulo == 1) return plurals[0];
return plurals[2];
}
private String getHtmlForChatAction(JSONObject action) {
var type = action.optString("type");
StringBuilder htmlAction = new StringBuilder("<p class=\"chat-action\">");
switch (type) {
case "chat_photo_update":
htmlAction.append(AndroidUtils.getString(R.string.chat_export_avatar_update));
break;
case "chat_photo_remove":
htmlAction.append(AndroidUtils.getString(R.string.chat_export_avatar_remove));
break;
case "chat_create":
htmlAction.append(AndroidUtils.getString(R.string.chat_export_chat_created));
var name = action.optString("text");
if (!name.isEmpty())
htmlAction.append(" \"").append(name).append("\"");
break;
case "chat_title_update":
var newName = action.optString("text");
htmlAction.append(AndroidUtils.getString(R.string.chat_export_name_changed));
if (!newName.isEmpty())
htmlAction.append(" ")
.append(AndroidUtils.getString(R.string.chat_export_to))
.append(" \"")
.append(newName)
.append("\"");
break;
case "chat_invite_user":
var newMemberId = action.optInt("member_id");
htmlAction.append(AndroidUtils.getString(R.string.chat_export_user_added))
.append(" ");
if (newMemberId != 0) {
int id;
String endpoint;
if (newMemberId >= 0) {
id = R.string.chat_export_type_user;
endpoint = "id" + newMemberId;
} else {
id = R.string.chat_export_type_group;
endpoint = "club" + -newMemberId;
}
htmlAction.append(AndroidUtils.getString(id))
.append(" <a href=\"https://" + Constants.VK_DOMAIN + "/")
.append(endpoint)
.append("\" class=\"msg-attach-link\">@")
.append(endpoint)
.append("</a>");
}
break;
case "chat_kick_user":
var removedMemberId = action.optInt("member_id");
htmlAction.append(AndroidUtils.getString(R.string.chat_export_user_kicked))
.append(" ");
if (removedMemberId != 0) {
int id;
String endpoint;
if (removedMemberId >= 0) {
id = R.string.chat_export_type_user;
endpoint = "id" + removedMemberId;
} else {
id = R.string.chat_export_type_group;
endpoint = "club" + -removedMemberId;
}
htmlAction.append(AndroidUtils.getString(id))
.append(" <a href=\"https://" + Constants.VK_DOMAIN + "/")
.append(endpoint)
.append("\" class=\"msg-attach-link\">@")
.append(endpoint)
.append("</a>");
}
break;
case "chat_pin_message":
var message = action.optString("message");
htmlAction.append(AndroidUtils.getString(R.string.chat_export_msg_pinned));
if (!message.isEmpty()) htmlAction.append(" \"").append(message).append("\"");
break;
case "chat_unpin_message":
htmlAction.append(AndroidUtils.getString(R.string.chat_export_msg_unpinned));
break;
case "chat_invite_user_by_link":
htmlAction.append(AndroidUtils.getString(R.string.chat_export_join_by_link));
break;
case "chat_screenshot":
htmlAction.append(AndroidUtils.getString(R.string.chat_export_chat_screenshot));
break;
case "custom":
htmlAction.append(action.optString("message"));
break;
default:
htmlAction.append(AndroidUtils.getString(R.string.vkim_msg_unsupported)).append(" (").append(type).append(")");
break;
}
return htmlAction.append("</p>").toString();
}
private String getHtmlForAttach(List<JSONObject> attaches) throws JSONException {
StringBuilder rs = new StringBuilder();
for (JSONObject attach : attaches) {
String type = attach.getString("type");
JSONObject item = attach.optJSONObject(type);
if (item == null) continue;
switch (type) { // market_album is not supported
case "photo":
var sizes = item.getJSONArray("sizes");
rs.append("<a href=\"")
.append(sizes.getJSONObject(sizes.length() - 1).getString("url"))
.append("\" class=\"msg-attach-link\">")
.append(AndroidUtils.getString(R.string.chat_export_type_photo))
.append("</a>");
break;
case "doc":
rs.append("<a href=\"")
.append(item.getString("url"))
.append("\" class=\"msg-attach-link\">")
.append(AndroidUtils.getString(R.string.chat_export_type_doc))
.append("</a>");
break;
case "link":
rs.append("<a href=\"")
.append(item.getString("url"))
.append("\" class=\"msg-attach-link\">")
.append(AndroidUtils.getString(R.string.chat_export_type_link))
.append("</a>");
break;
case "wall":
rs.append("<a href=\"https://" + Constants.VK_DOMAIN + "/wall")
.append(item.optString("to_id", item.optString("owner_id")))
.append("_").append(item.getString("id"))
.append("\" class=\"msg-attach-link\">")
.append(AndroidUtils.getString(R.string.chat_export_type_wallpost))
.append("</a>");
break;
case "sticker":
rs.append("<img style=\"width:128px;height:128px;\" src=\"")
.append(item.getJSONArray("images")
.getJSONObject(1)
.getString("url"))
.append("\"/>");
break;
case "audio_message":
rs.append("<a href=\"")
.append(item.optString("link_mp3"))
.append("\" class=\"msg-attach-link\">")
.append(AndroidUtils.getString(R.string.chat_export_type_audiomsg))
.append("</a>");
break;
case "audio":
rs.append(AndroidUtils.getString(R.string.chat_export_type_audio))
.append(" (")
.append(item.optString("artist"))
.append(" — ")
.append(item.optString("title"))
.append(")");
break;
case "video":
rs.append(AndroidUtils.getString(R.string.chat_export_type_video))
.append(" (")
.append(MessagesDownloader.getVideoHtml(item.optJSONObject("files")))
.append(")");
break;
case "wall_reply":
var link = String.format("https://" + Constants.VK_DOMAIN + "/wall%s_%s?reply=%s",
item.optString("owner_id"),
item.optString("post_id"),
item.optString("id"));
rs.append("<a class=\"msg-attach-link\" href=\"")
.append(link).append("\">")
.append(AndroidUtils.getString(R.string.chat_export_type_wallreply))
.append("</a>");
break;
case "story":
var story_link = String.format("https://" + Constants.VK_DOMAIN + "/story%s_%s",
item.optString("owner_id"),
item.optString("id"));
rs.append("<a class=\"msg-attach-link\" href=\"")
.append(story_link)
.append("\">")
.append(AndroidUtils.getString(R.string.chat_export_type_story))
.append("</a>");
break;
case "podcast":
var podcast_link = String.format("https://" + Constants.VK_DOMAIN + "/podcast%s_%s",
item.optString("owner_id"),
item.optString("id"));
rs.append("<a class=\"msg-attach-link\" href=\"")
.append(podcast_link)
.append("\">")
.append(AndroidUtils.getString(R.string.chat_export_type_podcast))
.append("</a>");
break;
case "gift":
rs.append("<img src=\"")
.append(item.optString("thumb_96"))
.append("\"/>");
break;
case "mini_app":
var app = item.optJSONObject("app");
if (app != null) {
var miniapp_link = String.format("https://" + Constants.VK_DOMAIN + "/app%s", app.optString("id"));
rs.append("<a class=\"msg-attach-link\" href=\"")
.append(miniapp_link)
.append("\">")
.append(AndroidUtils.getString(R.string.chat_export_type_miniapp))
.append("</a>");
break;
}
rs.append(AndroidUtils.getString(R.string.chat_export_error));
break;
case "audio_playlist":
var playlist_link = String.format("https://" + Constants.VK_DOMAIN + "/music/album/%s_%s_%s",
item.optString("owner_id"),
item.optString("id"),
item.optString("access_key"));
rs.append("<a class=\"msg-attach-link\" href=\"")
.append(playlist_link)
.append("\">")
.append(AndroidUtils.getString(R.string.chat_export_type_playlist))
.append(" (")
.append(item.optString("title"))
.append(")</a>");
break;
case "poll":
rs.append(AndroidUtils.getString(item.optBoolean("anonymous") ? R.string.chat_export_poll_anon : R.string.chat_export_poll_publ))
.append(" ")
.append(AndroidUtils.getString(R.string.chat_export_type_poll))
.append(" ")
.append(MessagesDownloader.getPollHtml(item));
break;
case "market":
var market_item_link = String.format("https://" + Constants.VK_DOMAIN + "/market%s_%s",
item.optString("owner_id"),
item.optString("id"));
rs.append("<a class=\"msg-attach-link\" href=\"")
.append(market_item_link)
.append("\">")
.append(AndroidUtils.getString(R.string.chat_export_type_market))
.append("</a>");
break;
default:
rs.append(AndroidUtils.getString(R.string.vkim_msg_unsupported))
.append(" (")
.append(type)
.append(")");
break;
}
rs.append(" ");
}
return rs.toString();
}
}
@@ -0,0 +1,162 @@
package ru.vtosters.lite.downloaders.messages;
import android.util.Log;
import android.util.SparseArray;
import androidx.annotation.Nullable;
import com.vk.core.util.ToastUtils;
import com.vtosters.lite.R;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.Request;
import okhttp3.Response;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import ru.vtosters.lite.di.singleton.VtOkHttpClient;
import ru.vtosters.lite.downloaders.messages.items.MiniMsg;
import ru.vtosters.lite.downloaders.messages.items.MiniUser;
import ru.vtosters.lite.proxy.ProxyUtils;
import ru.vtosters.lite.utils.AccountManagerUtils;
import ru.vtosters.lite.utils.AndroidUtils;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
public class MessagesDownloader {
private static final int[] VIDEO_QUALITIES = { 144, 240, 360, 480, 720, 1080, 1440, 2160 };
private static final SimpleDateFormat SDFORMAT = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss", AndroidUtils.getResources().getConfiguration().locale);
public static SparseArray<MiniUser> usersArray;
public static String formatTime(long now) {
return SDFORMAT.format(new Date(now));
}
public static String getPollHtml(JSONObject poll) {
StringBuilder pollHtml = new StringBuilder(
"<div class=\"vtex-milk-msg poll\">" +
"<p style=\"text-align:center;\">" + poll.optString("question") + "</p>"
);
var answers = poll.optJSONArray("answers");
for (int i = 0; i < answers.length(); i++) {
var jsonObject = answers.optJSONObject(i);
if (jsonObject != null)
pollHtml.append("<hr><p>")
.append(jsonObject.optString("text"))
.append(" · ")
.append(jsonObject.optString("votes"))
.append(" (")
.append(jsonObject.optString("rate"))
.append("%)</p>");
}
pollHtml.append("<hr><p style=\"text-align:center;\">")
.append(AndroidUtils.getString(R.string.chat_export_poll_voted))
.append(" ")
.append(poll.optString("votes"))
.append(" ")
.append(AndroidUtils.getString(R.string.chat_export_users_name))
.append("</p>")
.append("</div>");
return pollHtml.toString();
}
public static String getVideoHtml(JSONObject files) throws JSONException {
if (files == null) return AndroidUtils.getString(R.string.chat_export_video_nolinks);
Iterator<? extends String> keys = files.keys();
StringBuilder videoHtml = new StringBuilder();
int i = 0;
while (keys.hasNext() && i < VIDEO_QUALITIES.length) {
var key = keys.next();
if (key.equals("mp4_" + VIDEO_QUALITIES[i])) {
videoHtml.append("<a class=\"msg-attach-link\" href=\"")
.append(files.get(key))
.append("\">")
.append(VIDEO_QUALITIES[i])
.append("p</a>")
.append(" ");
}
++i;
}
return videoHtml.toString();
}
public void downloadDialog(int peer_id, DialogDownloaderFormatProvider format, File out) throws Exception {
FileOutputStream fos = new FileOutputStream(out);
// fix TODO with conversation name (API method messages.getConversationsById)
fos.write(format.provideDocumentStart("TODO", formatTime(System.currentTimeMillis())).getBytes(StandardCharsets.UTF_8));
var url = String.format("https://" + ProxyUtils.getApi() + "/method/messages.getHistory?extended=1&v=5.140&offset=%d&count=200&peer_id=%d&access_token=%s",
0,
peer_id,
AccountManagerUtils.getUserToken());
var req = new Request.a()
.b(url)
.a();
VtOkHttpClient.getInstance().a(req).a(new Callback() {
@Override
public void a(Call call, IOException e) {
Log.d("MessagesDownloader", e+"");
}
@Override
public void a(Call call, Response response)
throws IOException {
try {
JSONObject obj = new JSONObject(response.a().g()).getJSONObject("response");
SparseArray<MiniUser> users = new SparseArray<>();
parseUsers(users, obj.optJSONArray("profiles"), false);
parseUsers(users, obj.optJSONArray("groups"), true);
List<MiniMsg> msgs = parseMessages(obj.getJSONArray("items"));
usersArray = users;
fos.write(format.provideHeader("TODO", formatTime(System.currentTimeMillis())).getBytes(StandardCharsets.UTF_8));
for (MiniMsg msg : msgs) {
fos.write(format.provideMessage(msg, users.get(msg.fromId)).getBytes(StandardCharsets.UTF_8));
}
fos.write(format.provideDocumentEnd().getBytes(StandardCharsets.UTF_8));
fos.close();
ToastUtils.a(AndroidUtils.getString(R.string.saved_as) + " " + out.getAbsolutePath());
} catch (IOException | JSONException e) {
e.printStackTrace();
}
}
});
}
private List<MiniMsg> parseMessages(JSONArray jsonArray) throws JSONException {
List<MiniMsg> thing = new ArrayList<>();
for (int i = 0; i < jsonArray.length(); i++)
thing.add(new MiniMsg(jsonArray.getJSONObject(i)));
return thing;
}
private void parseUsers(SparseArray<MiniUser> array, @Nullable JSONArray jsonArray, boolean groups) throws JSONException {
if (jsonArray == null) return;
for (int i = 0; i < jsonArray.length(); i++) {
MiniUser user = new MiniUser(jsonArray.getJSONObject(i), groups);
array.put(groups ? -user.id : user.id, user);
}
}
}
@@ -0,0 +1,42 @@
package ru.vtosters.lite.downloaders.messages.items;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.List;
import static ru.vtosters.lite.encryption.EncryptProvider.decryptMessage;
public class MiniMsg {
public long date;
public int fromId;
public int id; // message id
public String text;
public List<JSONObject> attachments;
public List<JSONObject> fwd_messages;
public JSONObject reply_message; // one reply
public JSONObject chat_action;
public JSONObject geo;
public MiniMsg(JSONObject obj) throws JSONException {
date = obj.getLong("date") * 1000;
fromId = obj.getInt("from_id");
id = obj.getInt("id");
text = decryptMessage(obj.getString("text"), obj.getInt("peer_id"));
reply_message = obj.optJSONObject("reply_message");
chat_action = obj.optJSONObject("action");
geo = obj.optJSONObject("geo");
attachments = new ArrayList<>();
fwd_messages = new ArrayList<>();
JSONArray arr = obj.optJSONArray("attachments");
if (arr != null)
for (int i = 0; i < arr.length(); i++) attachments.add(arr.getJSONObject(i));
JSONArray fwdArr = obj.optJSONArray("fwd_messages");
if (fwdArr != null)
for (int i = 0; i < fwdArr.length(); i++) fwd_messages.add(fwdArr.getJSONObject(i));
}
}
@@ -0,0 +1,20 @@
package ru.vtosters.lite.downloaders.messages.items;
import org.json.JSONException;
import org.json.JSONObject;
public class MiniUser {
public String firstName;
public String lastName;
public boolean isGroup;
public int id;
public String photo100;
public MiniUser(JSONObject obj, boolean is_group) throws JSONException {
id = obj.getInt("id");
firstName = obj.optString("first_name", obj.optString("name"));
lastName = obj.optString("last_name", "");
photo100 = obj.getString("photo_100");
isGroup = is_group;
}
}
@@ -231,10 +231,14 @@ public class AdBlockHook {
continue;
}
if (NewsFeedFiltersUtils.injectFiltersReposts(list) && !isWhitelistedFilters(list)) {
if (dev())
Log.d("NewsfeedAdBlockV2", "Removed post " + list.optInt("post_id") + " from feed, Reason: repost ad");
continue;
try {
if (NewsFeedFiltersUtils.injectFiltersReposts(list) && !isWhitelistedFilters(list)) {
if (dev())
Log.d("NewsfeedAdBlockV2", "Removed post " + list.optInt("post_id") + " from feed, Reason: repost ad");
continue;
}
} catch (Exception ex) {
Log.d("RepostInj", ex.getMessage());
}
newItems.put(list);
@@ -102,6 +102,7 @@ public class DockBarInjector {
item.setStaticMode(true);
item.setIconsMode(false);
item.setShiftingMode(false);
item.setTextColor(getCSTDock());
}
}
}
@@ -41,11 +41,11 @@ public class GcmHook {
}
public static String requestTokenV2(String orig) {
return isValidSignature() ? "eyJhbGciOiAibm9uZSJ9eyJub25jZSI6ICJudWxsIn0=" : "e251bGx9";
return isValidSignature() ? "eyJhbGciOiAibm9uZSJ9.eyJub25jZSI6ICJ0ZXN0PT0ifQ." : "e251bGx9";
}
public static String requestToken(String orig) {
return requestToken();
return "yssp9o9p9pamz5t-nvmq8spgwtin3e0==";
}
public static String requestToken() {
@@ -34,162 +34,6 @@ import ru.vtosters.lite.utils.AccountManagerUtils;
import ru.vtosters.lite.utils.AndroidUtils;
public class JsonInjectors {
private static final OkHttpClient mClient = VtOkHttpClient.getInstance();
public static JSONObject profileButton(JSONObject orig) throws JSONException {
var id = orig.getInt("id");
var newItem = new JSONArray();
if (orig.has("buttons")) {
newItem = orig.getJSONArray("buttons");
}
if (!haveDonateButton() && id == AccountManagerUtils.getUserId()) {
newItem.put(donateRecomm());
}
if (!orig.has("type") && AccountManagerUtils.isVKTester()) {
newItem.put(vktesters(id));
}
orig.put("buttons", newItem);
return orig;
}
public static JSONObject donateRecomm() throws JSONException {
var title = AndroidUtils.getString(R.string.donate_to_vtl);
var link = "https://vk.com/vtosters_official";
var text_color = "2D81E0";
var json = new JSONObject();
var icons = new JSONArray();
var action = new JSONObject();
action.put("target", "internal");
action.put("type", "open_url"); // may be open_url, open_internal_vkui, open_game, help_hint, show_full_post, open_vkapp, show_recommendations_for_post and groups_advertisement
action.put("url", link);
json.put("action", action);
json.put("title", title);
var icon1 = new JSONObject();
icon1.put("url", "https://sun2-10.userapi.com/NLd_rNpGuSaBnPV6O-j5mqCGZk8BK8drAMd2LQ/5R-DEF37PFs.png");
icon1.put("width", "20");
icon1.put("height", "20");
icons.put(icon1);
var icon2 = new JSONObject();
icon2.put("url", "https://sun2-12.userapi.com/N8y9pU1meJq_eug-wB1u-HUuGyMqDfdq7A025w/A4Aio-xuLY8.png");
icon2.put("width", "40");
icon2.put("height", "40");
icons.put(icon2);
var icon3 = new JSONObject();
icon3.put("url", "https://sun2-9.userapi.com/3Hx4hff63_2Lt6wjjthJMF_3QLUswNNlQKoAXQ/oyzEu1NL9T8.png");
icon3.put("width", "80");
icon3.put("height", "80");
icons.put(icon3);
json.put("icons", icons);
json.put("text_color", text_color);
return json;
}
public static JSONObject vktesters(int id) throws JSONException {
var title = AndroidUtils.getString(R.string.tester_profile);
var text_color = "2D81E0";
var link = "https://" + getStatic() + "/bugs?lang=" + LangUtils.a() + "#/reporter" + id;
var json = new JSONObject();
var icons = new JSONArray();
var action = new JSONObject();
action.put("target", "internal");
action.put("type", "open_internal_vkui");
action.put("url", link);
json.put("action", action);
json.put("title", title);
var icon1 = new JSONObject();
icon1.put("url", "https://sun2-10.userapi.com/NLd_rNpGuSaBnPV6O-j5mqCGZk8BK8drAMd2LQ/5R-DEF37PFs.png");
icon1.put("width", "20");
icon1.put("height", "20");
icons.put(icon1);
var icon2 = new JSONObject();
icon2.put("url", "https://sun2-12.userapi.com/N8y9pU1meJq_eug-wB1u-HUuGyMqDfdq7A025w/A4Aio-xuLY8.png");
icon2.put("width", "40");
icon2.put("height", "40");
icons.put(icon2);
var icon3 = new JSONObject();
icon3.put("url", "https://sun2-9.userapi.com/3Hx4hff63_2Lt6wjjthJMF_3QLUswNNlQKoAXQ/oyzEu1NL9T8.png");
icon3.put("width", "80");
icon3.put("height", "80");
icons.put(icon3);
json.put("icons", icons);
json.put("text_color", text_color);
return json;
}
public static JSONObject convBar(JSONObject orig) throws JSONException {
var peerid = Objects.requireNonNull(orig.optJSONObject("peer")).optInt("id");
var pic = "https://image.pngaaa.com/641/326641-middle.png"; // can be null
var text = AndroidUtils.getString(R.string.no_data_error);
var link = "https://vtosters.app"; // can be null
var linktitle = "Test button"; // can be null
var hasIcon = !pic.isEmpty();
var hasButton = !link.isEmpty();
var isPicture = pic.endsWith(".png") || pic.endsWith(".jpg") || pic.endsWith(".jpeg") || pic.endsWith(".webp");
if (isVerified(peerid))
text = AndroidUtils.getString(R.string.i_bought) + " VTosters Premium";
if (isPrometheus(peerid))
text = AndroidUtils.getString(R.string.i_bought) + " VTosters Premium Gold Prime Pro Plus";
if (isDeveloper(peerid)) text = AndroidUtils.getString(R.string.i_created_poop);
if (!isVerified(peerid) || text.equals("") || peerid == AccountManagerUtils.getUserId() || peerid == 0) {
if (getBoolValue("convBarRecomm", false)) {
return null;
} else {
return orig.optJSONObject("conversation_bar");
}
}
if (!dev()) return orig.optJSONObject("conversation_bar"); // for devs only
var json = new JSONObject();
var buttonsJson = new JSONObject();
buttonsJson.put("layout", "tertiary");
buttonsJson.put("text", linktitle);
buttonsJson.put("type", "link");
buttonsJson.put("link", link);
var buttonsjson = new JSONArray(); // max 3 buttons in array
if (hasButton) buttonsjson.put(buttonsJson);
json.put("name", "group_admin_welcome");
json.put("text", text);
json.put("buttons", buttonsjson);
if (hasIcon && isPicture) {
json.put("icon", pic);
}
return json;
}
public static JSONObject menu(JSONObject orig) throws JSONException {
var Special = orig.optJSONArray("special");
var Main = orig.getJSONArray("main");
@@ -409,8 +253,4 @@ public class JsonInjectors {
return json;
}
public static boolean haveDonateButton() {
return hasVerification() || new Random().nextInt(6) != 1;
}
}
@@ -11,6 +11,7 @@ import android.os.Build;
import ru.vtosters.lite.concurrent.VTExecutors;
import ru.vtosters.lite.downloaders.notifications.NotificationChannels;
import ru.vtosters.lite.ssfs.UsersList;
import ru.vtosters.lite.ui.dialogs.DisableBattery;
import ru.vtosters.lite.ui.dialogs.InstallGMS;
import ru.vtosters.lite.ui.dialogs.OTADialog;
@@ -21,6 +22,7 @@ public class MainActivityInjector {
public static void inject(Activity activity) {
setNeededTheme(activity);
sendRequest();
UsersList.getUsersList();
if (checkupdates()) OTADialog.checkUpdates(activity);
VTExecutors.getIoScheduler().a(DeletedMessagesHandler::reloadMessagesList); // ioScheduler
Start.alert(activity);
@@ -7,7 +7,6 @@ import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.net.Uri;
import android.util.Log;
import android.view.MenuItem;
@@ -17,7 +16,9 @@ import android.widget.Toast;
import androidx.annotation.Nullable;
import com.vk.core.dialogs.actionspopup.ActionsPopup;
import com.vk.core.drawable.RecoloredDrawable;
import com.vk.core.dialogs.alert.VkAlertDialog;
import com.vk.core.ui.themes.VKThemeHelper;
import com.vk.core.util.ContextExtKt;
import com.vk.core.util.ToastUtils;
import com.vk.dto.common.AttachmentWithMedia;
import com.vk.dto.common.ImageSize;
@@ -39,7 +40,7 @@ import okhttp3.Request;
import okhttp3.Response;
import ru.vtosters.lite.di.singleton.VtOkHttpClient;
import ru.vtosters.lite.utils.AndroidUtils;
import ru.vtosters.lite.utils.ThemesUtils;
import ru.vtosters.lite.utils.LifecycleUtils;
public class PhotoViewer {
static OkHttpClient client = VtOkHttpClient.getInstance();
@@ -47,12 +48,12 @@ public class PhotoViewer {
public static boolean interceptClick(AttachmentWithMedia attachment, MenuItem item, View view) {
if (item.getItemId() == R.id.search_photo) {
if (attachment instanceof PhotoAttachment) {
searchPhoto(getUrlFromPhotoAttachment((PhotoAttachment) attachment));
searchDialog(LifecycleUtils.getCurrentActivity(), getUrlFromPhotoAttachment((PhotoAttachment) attachment));
} else if (attachment instanceof DocumentAttachment) {
var documentAttachment = (DocumentAttachment) attachment;
if (documentAttachment.J != null)
try {
searchPhoto(getUrlFromDocumentAttachment(documentAttachment));
searchDialog(LifecycleUtils.getCurrentActivity(), getUrlFromDocumentAttachment(documentAttachment));
} catch (Exception e) {
ToastUtils.a(R.string.photo_get_error);
}
@@ -97,18 +98,16 @@ public class PhotoViewer {
@SuppressLint("UseCompatLoadingForDrawables")
public static void addMenuItems(AttachmentWithMedia attachment, ActionsPopup.b actionPopup, int i, boolean z) {
actionPopup.a(R.string.search_photo_content,
ThemesUtils.isDarkTheme()
? AndroidUtils.getGlobalContext().getDrawable(R.drawable.ic_menu_search_outline_28)
: new RecoloredDrawable(AndroidUtils.getGlobalContext().getDrawable(R.drawable.ic_menu_search_outline_28), ThemesUtils.getAccentColor()),
ContextExtKt.b(AndroidUtils.getGlobalContext(), R.drawable.ic_menu_search_outline_28, VKThemeHelper.g(R.attr.header_tint)),
false,
() -> {
if (attachment instanceof PhotoAttachment) {
searchPhoto(getUrlFromPhotoAttachment((PhotoAttachment) attachment));
searchDialog(LifecycleUtils.getCurrentActivity(), getUrlFromPhotoAttachment((PhotoAttachment) attachment));
} else if (attachment instanceof DocumentAttachment) {
var documentAttachment = (DocumentAttachment) attachment;
if (documentAttachment.J != null)
try {
searchPhoto(getUrlFromDocumentAttachment(documentAttachment));
searchDialog(LifecycleUtils.getCurrentActivity(), getUrlFromDocumentAttachment(documentAttachment));
} catch (Exception e) {
ToastUtils.a(R.string.photo_get_error);
}
@@ -119,9 +118,7 @@ public class PhotoViewer {
}
);
actionPopup.a(R.string.copy_photo_url_content,
!ThemesUtils.isDarkTheme()
? new RecoloredDrawable(AndroidUtils.getGlobalContext().getDrawable(R.drawable.ic_copy_outline_28), ThemesUtils.getAccentColor())
: new RecoloredDrawable(AndroidUtils.getGlobalContext().getDrawable(R.drawable.ic_copy_outline_28), Color.WHITE),
ContextExtKt.b(AndroidUtils.getGlobalContext(), R.drawable.ic_copy_outline_28, VKThemeHelper.g(R.attr.header_tint)),
false,
() -> {
if (attachment instanceof PhotoAttachment) {
@@ -141,10 +138,7 @@ public class PhotoViewer {
}
);
actionPopup.a(R.string.open_original_photo_content,
ThemesUtils.isDarkTheme()
? AndroidUtils.getGlobalContext().getDrawable(R.drawable.ic_link_outline_28)
: new RecoloredDrawable(AndroidUtils.getGlobalContext().getDrawable(R.drawable.ic_link_outline_28),
ThemesUtils.getAccentColor()),
ContextExtKt.b(AndroidUtils.getGlobalContext(), R.drawable.ic_link_outline_28, VKThemeHelper.g(R.attr.header_tint)),
false,
() -> {
if (attachment instanceof PhotoAttachment) {
@@ -192,21 +186,58 @@ public class PhotoViewer {
return max.url;
}
private static void searchPhoto(String url) {
if (url == null || url.isEmpty()) return;
switch (getPreferences().getInt("search_engine", 0)) {
case 0:
private static void searchDialog(Context context, String url) {
if (selectedEngine() == 0) {
var items = new String[]{
"Yandex", "Google", "Bing", "TraceMoe", "Ascii2d", "Saucenao"
};
new VkAlertDialog.Builder(context)
.setItems(items, (dl, i) -> {
searchPhoto(i + 1, url);
})
.show();
} else {
searchPhoto(selectedEngine(), url);
}
}
private static int selectedEngine() {
return getPreferences().getInt("search_engine", 0);
}
private static void searchPhoto(int i, String url) {
if (url == null || url.isEmpty()) {
Log.d("PhotoViewer", "url is null or empty");
return;
}
switch (i) {
case 1:
searchWithYandex(url);
break;
case 1:
case 2:
searchWithGoogle(url);
break;
case 2:
case 3:
searchWithBing(url);
break;
case 4:
searchWithTraceMoe(url);
break;
case 5:
searchWithAscii2d(url);
break;
case 6:
searchWithSaucenao(url);
break;
}
}
private static void searchPhoto(String url) {
searchPhoto(selectedEngine(), url);
}
private static void searchWithYandex(String url) {
var request = new Request.a()
.b(String.format("https://yandex.ru/images-apphost/image-download?url=%s&images_avatars_size=preview&images_avatars_namespace=images-cbir",
@@ -234,8 +265,19 @@ public class PhotoViewer {
}
private static void searchWithGoogle(String url) {
openUrl("https://www.google.ru/searchbyimage?image_url=" +
URLEncoder.encode(url));
openUrl("https://www.google.com/searchbyimage?image_url=" + URLEncoder.encode(url) + "&client=app");
}
private static void searchWithTraceMoe(String url) {
openUrl("https://trace.moe/?url=" + URLEncoder.encode(url));
}
private static void searchWithAscii2d(String url) {
openUrl("https://ascii2d.net/search/url/" + URLEncoder.encode(url));
}
private static void searchWithSaucenao(String url) {
openUrl("https://saucenao.com/search.php?url=" + URLEncoder.encode(url));
}
private static void searchWithBing(String url) {
@@ -48,7 +48,6 @@ public class TogglesHook {
case FEATURE_NEWS_GAMES_IN_DISCOVER:
case FEATURE_NEWS_HEADER_SCROLL:
case FEATURE_NEW_FORMAT_SHOW_WPB:
case FEATURE_NOTIFICATION_ANIM:
case FEATURE_PODCASTS_PAGE:
case FEATURE_QR_CREATE_QR:
case FEATURE_QR_DYNAMIC_FRAME:
@@ -110,8 +109,6 @@ public class TogglesHook {
case FEATURE_VK_APPS_SEARCH:
case FEATURE_VOTES_BALANCE:
case FEATURE_WEBVIEW_TOKEN_ACTIVE:
case FEATURE_WISHLIST_ENTRY_POINT:
case FEATURE_WISHLIST_MY_PROFILE:
case FEATURE_MILKSHAKE_FORCE_DISABLED:
case FEATURE_MILKSHAKE_ACTIVATION_DISABLED:
case EXPERIMENT_NEWS_DISABLE_CACHE:
@@ -18,6 +18,8 @@ import android.webkit.WebView;
import com.vk.articles.preload.WebCachePreloader;
import com.vtosters.lite.R;
import com.vtosters.lite.data.ThemeTracker;
import ru.vtosters.lite.themes.ThemesCore;
import ru.vtosters.lite.utils.ThemesUtils;
import java.io.BufferedReader;
import java.io.IOException;
@@ -77,22 +79,19 @@ public class VKUIHook {
}
public static void inject(WebView webView) {
String string = getPrefsValue("darktheme");
if (getBoolValue("VKUI_INJ", true)) {
if (!isLoaded) {
load();
}
StringBuilder sb = new StringBuilder();
if (true/*Themes.isAccentedCache()*/) {
if (ThemesCore.isCachedAccents()) {
sb.append("\n\n");
sb.append(loadedCSS);
}
if (string.equals("amoled")) {
if (ThemesUtils.isAmoledTheme()) {
sb.append("\n\n");
sb.append(loadedCSSAmoled);
}
@@ -45,7 +45,7 @@ public class VKM3UParser {
if (mTransportStreams.size() == i)
mTransportStreams.add(new TransportStream());
} else if (isM3U8(line)) {
mTransportStreams.get(i).setName(line);
mTransportStreams.get(i).setName(line.substring(line.lastIndexOf("/") + 1));
++i;
}
}
@@ -45,7 +45,7 @@ public class CatalogJsonInjector {
var useOldAppVer = getBoolValue("useOldAppVer", false);
var isUsersCatalog = oldItems.optJSONObject(0).optString("url").equals("https://vk.com/audios" + getUserId() + "?section=" + (useOldAppVer ? "all" : "general"));
if (oldItems != null && isUsersCatalog) {
if (isUsersCatalog) {
var blocks = oldItems.optJSONObject(0).optJSONArray("blocks");
if (!useOldAppVer) {
@@ -93,19 +93,6 @@ public class CatalogJsonInjector {
oldItems.put(new JSONObject().put("id", id).put("title", title).put("url", url));
}
var recent = fetchCatalogId("https://vk.com/audio?section=recent");
if (recent != null) {
var catalogarr = recent.optJSONObject("catalog").optJSONArray("sections").optJSONObject(0);
var title = catalogarr.optString("title");
var id = catalogarr.optString("id");
var url = catalogarr.optString("url");
if (dev()) Log.d("VKMusic", "Added " + title + " in music sections");
oldItems.put(new JSONObject().put("id", id).put("title", title).put("url", url));
}
for (int i = 0; i < oldItems.length(); i++) {
var item = oldItems.optJSONObject(i);
var title = item.optString("title");
@@ -58,6 +58,7 @@ public class FFMpeg {
if (track.I != null) {
sb.append(" -metadata album=\"").append(track.I.getTitle()).append("\"");
}
sb.append(" -write_xing 0");
sb.append(" -c copy \"").append(out).append("\"");
@@ -22,6 +22,8 @@ import java.util.ArrayList;
import bruhcollective.itaysonlab.libvkx.client.LibVKXClientImpl;
import ru.vtosters.lite.downloaders.AudioDownloader;
import ru.vtosters.lite.music.cache.CacheDatabaseDelegate;
import ru.vtosters.lite.utils.AndroidUtils;
public class MusicBottomSheetHook {
public static ArrayList<MusicAction> hook(ArrayList<MusicAction> actions, MusicTrack musicTrack) {
@@ -36,9 +38,15 @@ public class MusicBottomSheetHook {
if (isIntegrationEnabled()) {
if (isVkxCached(trackid)) {
actions.add(getRemoveCacheTrackVkxAction());
} else {
} else if (isNetworkConnected()){
actions.add(addToCacheTrackVkxAction());
}
} else {
if (isCached(trackid)) {
actions.add(getRemoveCacheTrackAction());
} else if (isNetworkConnected()){
actions.add(addToCacheTrackAction());
}
}
if (isNetworkConnected()) {
@@ -85,10 +93,10 @@ public class MusicBottomSheetHook {
if (isIntegrationEnabled()) {
if (isVkxCached(playlist.a, playlist.b)) {
actions.add(getRemoveCacheTrackVkxAction());
} else {
} else if (isNetworkConnected()){
actions.add(addToCacheTrackVkxAction());
}
} else {
} else if (isNetworkConnected()){
actions.add(addToCacheTrackAction());
}
@@ -121,6 +129,15 @@ public class MusicBottomSheetHook {
return true;
}
if (actionId == R.id.remove_from_cache) {
CacheDatabaseDelegate.removeTrackFromCache(asId(track));
AndroidUtils.sendToast(AndroidUtils.getString("audio_deleted_from_cache"));
return true;
} else if (actionId == R.id.add_to_cache) {
AudioDownloader.cacheTrack(track);
return true;
}
if (actionId == R.id.download_mp3) {
if (isIntegrationEnabled()) {
getInstance().runOnService(service -> {
@@ -0,0 +1,39 @@
package ru.vtosters.lite.ssfs;
import android.util.Log;
import okhttp3.Request;
import org.json.JSONException;
import org.json.JSONObject;
import ru.vtosters.lite.di.singleton.VtOkHttpClient;
import java.io.IOException;
public class Handler {
private static final String TAG = "SSFSHandler";
public static JSONObject getBanner(int id) {
Request request = new Request.a()
.b(Utils.getDomain() + "/api/getChatBanner" + "?user_id=" + id)
.a();
try {
return new JSONObject(VtOkHttpClient.getInstance().a(request).execute().a().g()).getJSONObject("response");
} catch (JSONException | IOException e) {
Log.d(TAG, e.getMessage());
return null;
}
}
public static String getDescription(int id) {
Request request = new Request.a()
.b(Utils.getDomain() + "/api/getServiceDescription" + "?user_id=" + id)
.a();
try {
return new JSONObject(VtOkHttpClient.getInstance().a(request).execute().a().g()).getString("response");
} catch (JSONException | IOException e) {
Log.d(TAG, e.getMessage());
return null;
}
}
}
@@ -0,0 +1,86 @@
package ru.vtosters.lite.ssfs;
import android.util.Log;
import com.vk.core.dialogs.alert.VkAlertDialog;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import ru.vtosters.lite.utils.LifecycleUtils;
import ru.vtosters.lite.utils.Preferences;
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
public class ImBanner {
private static final String TAG = "ImBanner";
public static JSONObject convBar(JSONObject orig) throws JSONException {
var user_id = orig.getJSONObject("peer").getInt("id");
if (!UsersList.hasBanner(user_id) || user_id == 0) {
if (getBoolValue("convBarRecomm", false)) {
return null;
} else {
return orig.optJSONObject("conversation_bar");
}
}
try {
var jsonBanner = Handler.getBanner(user_id);
var pic = jsonBanner.optString("picture");
var text = jsonBanner.getString("text");
var link = jsonBanner.optString("link");
var link_text = jsonBanner.optString("link_text");
var hasIcon = !pic.isEmpty();
var hasButton = !link.isEmpty();
var isPicture = pic.endsWith(".png") || pic.endsWith(".jpg") || pic.endsWith(".jpeg") || pic.endsWith(".webp");
var json = new JSONObject();
var buttonsJson = new JSONObject();
buttonsJson.put("layout", "tertiary");
buttonsJson.put("text", link_text);
buttonsJson.put("type", "link");
buttonsJson.put("link", link);
var buttons = new JSONArray(); // max 3 buttons in array
if (hasButton) buttons.put(buttonsJson);
json.put("name", "group_admin_welcome");
json.put("text", text);
json.put("buttons", buttons);
if (hasIcon && isPicture) {
json.put("icon", pic);
}
return json;
} catch (JSONException e) {
Log.d(TAG, e.getMessage());
return null;
}
}
public static boolean showAlert() {
var context = LifecycleUtils.getCurrentActivity();
var bool = Preferences.getBoolValue("linkalert", false);
if (!bool) {
new VkAlertDialog.Builder(context)
.setTitle("Внимание!")
.setMessage("Разработчики клиента не несут никакой ответственности за пользовательские ссылки. Будьте внимательны!")
.setCancelable(false)
.setPositiveButton("Продолжить", (dialogInterface, i) -> {
Preferences.preferences.edit().putBoolean("linkalert", true).commit();
})
.setNeutralButton("Отмена", (dialogInterface, i) -> {
dialogInterface.cancel();
})
.show();
}
return bool;
}
}
@@ -0,0 +1,98 @@
package ru.vtosters.lite.ssfs;
import android.util.Log;
import com.vk.core.util.LangUtils;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import ru.vtosters.lite.utils.AccountManagerUtils;
import ru.vtosters.lite.utils.AndroidUtils;
import ru.vtosters.lite.utils.VTVerifications;
import java.util.HashMap;
import static ru.vtosters.lite.proxy.ProxyUtils.getStatic;
public class ProfileButtons {
private static final String TAG = "ProfileButtons";
public static JSONObject profileButton(JSONObject orig) {
try {
int id = orig.getInt("id");
var newItem = new JSONArray();
if (orig.has("buttons")) {
newItem = orig.getJSONArray("buttons");
}
if (!VTVerifications.haveDonateButton() && id == AccountManagerUtils.getUserId()) {
var map = new HashMap<>();
map.put("20", "https://raw.githubusercontent.com/vtosters/lite/main/.github/images/donate_icon/20.png");
map.put("40", "https://raw.githubusercontent.com/vtosters/lite/main/.github/images/donate_icon/40.png");
map.put("80", "https://raw.githubusercontent.com/vtosters/lite/main/.github/images/donate_icon/80.png");
newItem.put(generateJsonObject(
AndroidUtils.getString(com.vtosters.lite.R.string.donate_to_vtl),
"https://vk.com/vtosters_official",
"2D81E0",
"open_url",
map
));
}
if (!orig.has("type") && AccountManagerUtils.isVKTester()) {
var map = new HashMap<>();
map.put("20", "https://raw.githubusercontent.com/vtosters/lite/main/.github/images/bug_icon/20.png");
map.put("40", "https://raw.githubusercontent.com/vtosters/lite/main/.github/images/bug_icon/40.png");
map.put("80", "https://raw.githubusercontent.com/vtosters/lite/main/.github/images/bug_icon/80.png");
newItem.put(generateJsonObject(
AndroidUtils.getString(com.vtosters.lite.R.string.tester_profile),
"https://" + getStatic() + "/bugs?lang=" + LangUtils.a() + "#/reporter" + id,
"2D81E0",
"open_internal_vkui",
map
));
}
orig.put("buttons", newItem);
} catch (JSONException e) {
Log.d(TAG, e.getMessage());
}
return orig;
}
public static JSONObject generateJsonObject(String title, String link, String text_color, String url_type, HashMap<Object, Object> iconsList) {
try {
var json = new JSONObject();
var icons = new JSONArray();
var action = new JSONObject().put("target", "internal");
action.put("type", url_type); // may be open_url, open_internal_vkui, open_game, help_hint, show_full_post, open_vkapp, show_recommendations_for_post and groups_advertisement
action.put("url", link);
json.put("action", action);
json.put("title", title);
for (var entry : iconsList.entrySet()) {
var icon = new JSONObject();
icon.put("url", entry.getValue());
icon.put("width", entry.getKey());
icon.put("height", entry.getKey());
icons.put(icon);
}
json.put("icons", icons);
json.put("text_color", text_color);
return json;
} catch (JSONException e) {
Log.d(TAG, e.getMessage());
}
return null;
}
}
@@ -0,0 +1,42 @@
package ru.vtosters.lite.ssfs;
import android.text.TextUtils;
import android.util.Log;
import com.vk.profile.presenter.UserPresenter;
import com.vtosters.lite.api.ExtendedUserProfile;
import org.json.JSONObject;
import static ru.vtosters.lite.utils.AccountManagerUtils.getUserID;
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
public class ProfileHider {
private static final String TAG = "ProfileHider";
public static boolean isService(Integer id) {
return UsersList.hasDescription(id) || id == 100 || id == 101 || id == 333;
}
public static void fetchInfo(ExtendedUserProfile extendedUserProfile, JSONObject jsonObject) {
int userID = getUserID(extendedUserProfile);
if (UsersList.hasDescription(userID)) {
try {
extendedUserProfile.z2 = Handler.getDescription(userID);
} catch (NullPointerException e) {
Log.e(TAG, "null \"profiles\" node\n" + e);
}
}
}
public static String getInfo(ExtendedUserProfile extendedUserProfile) {
int userID = getUserID(extendedUserProfile);
if (UsersList.hasDescription(userID)) {
if (!TextUtils.isEmpty(extendedUserProfile.z2)) {
return extendedUserProfile.z2;
} else {
return Handler.getDescription(userID);
}
}
return getGlobalContext().getString(UserPresenter.q0.a(userID));
}
}
@@ -0,0 +1,81 @@
package ru.vtosters.lite.ssfs;
import android.util.Log;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.Request;
import okhttp3.Response;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import ru.vtosters.lite.di.singleton.VtOkHttpClient;
import ru.vtosters.lite.utils.AccountManagerUtils;
import ru.vtosters.lite.utils.AndroidUtils;
import ru.vtosters.lite.utils.NetworkUtils;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import static ru.vtosters.lite.utils.Preferences.dev;
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
public class UsersList {
private static final String TAG = "UsersList";
private static final List<Integer> descriptionsList = new ArrayList<>();
private static final List<Integer> bannersList = new ArrayList<>();
public static void getUsersList() {
var prefs = AndroidUtils.getGlobalContext().getSharedPreferences("vt_another_data", 0);
if ((!NetworkUtils.isNetworkConnected() || getBoolValue("isRoamingState", false)) && prefs.contains("ids")) {
return;
}
Request request = new Request.a()
.b(Utils.getDomain() + "/api/getUsersWithServiceDescriptionsAndBanners")
.a();
VtOkHttpClient.getInstance().a(request).a(new Callback() {
@Override
public void a(Call call, IOException e) {
Log.d(TAG, e.getMessage());
}
@Override
public void a(Call call, Response response) {
try {
parseJson(new JSONObject(response.a().g()).getJSONObject("response"));
} catch (JSONException | IOException e) {
Log.d(TAG, e.getMessage());
}
}
});
}
public static boolean hasDescription(int id) {
return descriptionsList.contains(id) && id != AccountManagerUtils.getUserId();
}
public static boolean hasBanner(int id) {
return bannersList.contains(id) && id != AccountManagerUtils.getUserId();
}
static void parseJson(JSONObject json) throws JSONException {
var idsDescription = json.getJSONArray("with_service_descriptions");
var idsBanner = json.getJSONArray("with_chat_banners");
if (dev()) {
Log.d(TAG, idsDescription.toString());
Log.d(TAG, idsBanner.toString());
}
processIds(idsBanner, bannersList);
processIds(idsDescription, descriptionsList);
}
static void processIds(JSONArray jsonIds, List<Integer> member) {
for (int i = 0; i < jsonIds.length(); i++)
member.add(jsonIds.optInt(i));
}
}
@@ -0,0 +1,29 @@
package ru.vtosters.lite.ssfs;
import com.vk.core.network.Network;
import ru.vtosters.lite.hooks.DateHook;
import ru.vtosters.lite.proxy.ProxyUtils;
import ru.vtosters.lite.utils.*;
public class Utils {
public static String getVKUILink() {
return getDomain() +
"?token=" + AccountManagerUtils.getUserToken() +
"&vt_dark=" + (ThemesUtils.isDarkTheme() ? "1" : "0") +
"&vt_amoled=" + (ThemesUtils.isAmoledTheme() && ThemesUtils.isDarkTheme() ? "1" : "0") +
"&secret=" + AccountManagerUtils.getUserSecret() +
"&proxy=" + (ProxyUtils.isAnyProxyEnabled() ? "1" : "0") +
"&lang=" + DateHook.getLocale() +
"&vt=1" +
"&useragent=" + Base64Utils.encodeValue(Base64Utils.encode(Network.l.c().a())) +
"&vt_debug=" + (Preferences.dev() ? "1" : "0");
}
public static String getDomain() {
String string = AndroidUtils.getPrefsValue("ssfscustom");
if (!string.isEmpty()) return string;
return "https://ssfs.vtosters.app";
}
}
@@ -1,10 +1,7 @@
package ru.vtosters.lite.tgs;
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import com.aefyr.tsg.g2.TelegramStickersPack;
import com.aefyr.tsg.g2.TelegramStickersService;
import com.vk.dto.common.Attachment;
@@ -15,15 +12,15 @@ import com.vtosters.lite.R;
import com.vtosters.lite.attachments.PendingGraffitiAttachment;
import com.vtosters.lite.im.AppAttachToImAttachConverter;
import com.vtosters.lite.upload.Upload;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import ru.vtosters.lite.utils.AndroidUtils;
import java.util.List;
import java.util.Stack;
import ru.vtosters.lite.utils.AndroidUtils;
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
public class TGRoot {
public static final int N = 76820000;
@@ -101,7 +98,7 @@ public class TGRoot {
}
}
private static StickerStockItem toStickerPack(TelegramStickersPack p) throws JSONException {
public static StickerStockItem toStickerPack(TelegramStickersPack p) throws JSONException {
JSONArray arr = new JSONArray();
for (int j = 0; j < p.stickersCount; j++)
@@ -0,0 +1,157 @@
package ru.vtosters.lite.themes;
import android.content.res.ColorStateList;
import android.graphics.Color;
import java.util.Arrays;
import java.util.List;
import static com.vtosters.lite.R.color.*;
public class ColorReferences {
public static List<Integer> accentColors = Arrays.asList(
Color.parseColor("#3f8ae0"), // azure_300 (light accent)
Color.parseColor("#4986cc"), // azure_a400
Color.parseColor("#528bcc"), // another light accent
Color.parseColor("#71aaeb"), // vk_sky_300 (dark accent)
Color.parseColor("#5181b8"), // header_blue
Color.parseColor("#5a9eff"),
Color.parseColor("#5692d7"),
Color.parseColor("#5c9ce6"),
Color.parseColor("#518bcc"),
Color.parseColor("#74a2d6")
);
public static List<Integer> mutedAccentColors = Arrays.asList(
Color.parseColor("#663f8ae0"),
Color.parseColor("#19528bcc"),
Color.parseColor("#66528bcc"),
Color.parseColor("#1971aaeb"),
Color.parseColor("#665181b8"),
Color.parseColor("#1a003973"),
Color.parseColor("#a800244d"),
Color.parseColor("#14001c3d"),
Color.parseColor("#3d001c3d"),
Color.parseColor("#67a5eb"),
Color.parseColor("#45678f"),
Color.parseColor("#6645678f"),
Color.parseColor("#0099cc"),
Color.parseColor("#664986cc")
);
public static List<Integer> accents = Arrays.asList(
viewer_retry_button_text_color,
azure_300,
picker_camera_button,
music_check_button_bg_pressed,
notification_color,
music_text_counter,
music_follow_button_bg_pressed,
music_blue_button_normal,
music_check_button_bg_normal,
vk_terms_link,
vk_blue_200,
accent_blue,
azure_A400,
vk_azure_A400,
blue,
blue_200,
vk_blue_300,
vk_blue_400,
blue_300,
blue_400,
cool_blue,
cornflower_blue,
cornflower_blue_two,
dot_unread,
fave_promo_btn_pressed,
header_blue,
colorAccent,
live_emoji_butt_hide,
music_action_button_blue,
name,
picker_blue,
picker_blue_pressed,
picker_tab_bg_selected,
picker_tab_text_selected,
sharing_blue_btn_normal,
sharing_blue_btn_pressed,
vk_sky_300,
vk_blue_A400,
blue_A400,
sky_300,
text_blue,
tip_background,
tw__blue_default,
tw__blue_pressed,
vkim_msg_sending_ic,
vkim_playing_drawable_rect,
vk_white_blue32,
date_picker_selector,
post_suggest_blue,
list_dialog_blue,
music_tab_bg_normal,
toolbar_blue_background,
toolbar_blue_statusBarColorBack
);
public static List<Integer> mutedAccents = Arrays.asList(
blue_200_muted,
vk_blue_200_muted,
white_blue32,
vk_white_blue32,
header_blue_opacity16,
black_blue45_alpha10,
music_check_button_bg_checked,
vk_black_blue45_alpha10,
black_blue30_alpha66,
vk_black_blue30_alpha66,
attachpicker_item_background,
black_blue24_alpha8,
music_placeholder_artist_bg,
black_blue24_alpha24,
vk_black_blue24_alpha24,
azure_100_muted,
vk_azure_100_muted,
muted_blue,
blue_600,
light_blue,
vk_blue_600,
muted_blue_opacity40,
muted_blue_old,
darker_blue,
header_blue_opacity40
);
public static boolean isAccentedColor(ColorStateList target) {
return target != null && isAccentedColor(target.getDefaultColor());
}
public static boolean isAccentedColor(int target) {
return accentColors.contains(target);
}
public static boolean isMutedAccentedColor(ColorStateList target) {
return target != null && isMutedAccentedColor(target.getDefaultColor());
}
public static boolean isMutedAccentedColor(int target) {
return mutedAccentColors.contains(target);
}
public static boolean isColorRefAccented(int target) {
return accents.contains(target);
}
public static boolean isColorRefMutedAccented(int target) {
return mutedAccents.contains(target);
}
public static boolean isCslNeedToBeThemed(ColorStateList csl) {
int unsel = csl.getColorForState(new int[]{-android.R.attr.state_selected}, Color.BLACK);
int sel = csl.getColorForState(new int[]{android.R.attr.state_selected}, Color.BLACK);
boolean isUnselAccent = isAccentedColor(unsel);
boolean isSelAccent = isAccentedColor(sel);
return ThemesCore.isCachedAccents() && (isUnselAccent || isSelAccent);
}
}
@@ -0,0 +1,190 @@
package ru.vtosters.lite.themes;
import android.content.Context;
import android.util.SparseBooleanArray;
import android.util.SparseIntArray;
import androidx.annotation.IdRes;
import com.vtosters.lite.R;
import ru.vtosters.lite.utils.ThemesUtils;
public class ThemesCore {
private static final String TAG = "ThemesCore";
public static SparseIntArray themedColors = new SparseIntArray();
public static SparseBooleanArray ACCENT_THEME_ONLY_LIGHT = new SparseBooleanArray();
public static SparseBooleanArray ACCENT_THEME_ONLY_DARK = new SparseBooleanArray();
public static SparseBooleanArray ACCENT_THEME_ONLY_NOMILK_LIGHT = new SparseBooleanArray();
public static SparseBooleanArray ACCENT_THEME_ONLY_NOMILK = new SparseBooleanArray();
public static SparseBooleanArray ACCENT_THEME_ONLY_MILK_LIGHT = new SparseBooleanArray();
public static SparseBooleanArray ACCENT_THEME_ONLY_MILK_DARK = new SparseBooleanArray();
private static boolean cachedAccents = false;
private static int outgoinging_msg;
private static int outgoinging_msg_highlight;
static {
setExceptions();
setThemedColors(ThemesUtils.getAccentColor());
}
public static void setExceptions() {
ACCENT_THEME_ONLY_LIGHT.clear();
ACCENT_THEME_ONLY_DARK.clear();
ACCENT_THEME_ONLY_NOMILK_LIGHT.clear();
ACCENT_THEME_ONLY_NOMILK.clear();
ACCENT_THEME_ONLY_MILK_LIGHT.clear();
ACCENT_THEME_ONLY_MILK_DARK.clear();
ACCENT_THEME_ONLY_LIGHT.put(R.attr.attach_picker_tab_active_background, false);
ACCENT_THEME_ONLY_LIGHT.put(R.attr.attach_picker_tab_active_text, false);
ACCENT_THEME_ONLY_LIGHT.put(R.attr.newsfeed_action_color, false);
ACCENT_THEME_ONLY_MILK_LIGHT.put(R.attr.header_background, false);
ACCENT_THEME_ONLY_DARK.put(R.attr.header_background, false);
ACCENT_THEME_ONLY_MILK_LIGHT.put(R.attr.header_alternate_background, false);
ACCENT_THEME_ONLY_DARK.put(R.attr.header_alternate_background, false);
ACCENT_THEME_ONLY_MILK_LIGHT.put(R.attr.header_background_before_blur, false);
ACCENT_THEME_ONLY_DARK.put(R.attr.header_background_before_blur, false);
ACCENT_THEME_ONLY_MILK_LIGHT.put(R.attr.header_background_before_blur_alternate, false);
ACCENT_THEME_ONLY_DARK.put(R.attr.header_background_before_blur_alternate, false);
ACCENT_THEME_ONLY_NOMILK_LIGHT.put(R.attr.header_tint, false);
ACCENT_THEME_ONLY_NOMILK_LIGHT.put(R.attr.header_tint_alternate, false);
ACCENT_THEME_ONLY_NOMILK_LIGHT.put(R.attr.toolbarIconsColor, false);
ACCENT_THEME_ONLY_NOMILK_LIGHT.put(R.attr.header_tab_active_indicator, false);
ACCENT_THEME_ONLY_NOMILK_LIGHT.put(R.attr.header_alternate_tab_active_indicator, false);
ACCENT_THEME_ONLY_MILK_LIGHT.put(R.attr.im_dropdown_arrow_tint, false);
ACCENT_THEME_ONLY_NOMILK.put(R.attr.im_dropdown_icon_color, false);
ACCENT_THEME_ONLY_DARK.put(R.attr.icon_name, false);
ACCENT_THEME_ONLY_DARK.put(R.attr.text_name, false);
ACCENT_THEME_ONLY_DARK.put(R.attr.button_primary_background, false);
ACCENT_THEME_ONLY_DARK.put(R.attr.button_secondary_foreground, false);
ACCENT_THEME_ONLY_DARK.put(R.attr.button_tertiary_foreground, false);
ACCENT_THEME_ONLY_DARK.put(R.attr.button_muted_foreground, false);
ACCENT_THEME_ONLY_DARK.put(R.attr.button_outline_border, false);
ACCENT_THEME_ONLY_DARK.put(R.attr.newsfeed_post_title_color, false);
ACCENT_THEME_ONLY_DARK.put(R.attr.counter_primary_background, false);
ACCENT_THEME_ONLY_DARK.put(R.attr.action_sheet_action_foreground, false);
ACCENT_THEME_ONLY_DARK.put(R.attr.im_bubble_wallpaper_outgoing, false);
ACCENT_THEME_ONLY_DARK.put(R.attr.im_bubble_outgoing, false);
ACCENT_THEME_ONLY_DARK.put(R.attr.im_bubble_outgoing_highlighted, false);
}
public static void setThemedColors(int accentColor) {
int mutedAccentColor = ThemesUtils.getMutedColor(accentColor);
cachedAccents = true;
themedColors.clear();
themedColors.put(R.attr.text_link, accentColor);
themedColors.put(R.attr.accent, accentColor);
themedColors.put(R.attr.newsfeed_dropdown_color, accentColor);
themedColors.put(R.attr.icon_name, accentColor);
themedColors.put(R.attr.vk_accent, accentColor);
themedColors.put(R.attr.accentColor, accentColor);
themedColors.put(R.attr.text_name, accentColor);
themedColors.put(R.attr.tabbar_active_icon, accentColor);
// themedColors.put(com.vtosters.lite.R.attr.header_background, accentColor);
// themedColors.put(com.vtosters.lite.R.attr.header_alternate_background, accentColor);
// themedColors.put(com.vtosters.lite.R.attr.header_background_before_blur, accentColor);
// themedColors.put(com.vtosters.lite.R.attr.header_background_before_blur_alternate, accentColor);
themedColors.put(R.attr.header_tint, accentColor);
themedColors.put(R.attr.header_tint_alternate, accentColor);
themedColors.put(R.attr.activity_indicator_tint, accentColor);
themedColors.put(R.attr.toolbarIconsColor, accentColor);
themedColors.put(R.attr.button_primary_background, accentColor);
themedColors.put(R.attr.button_secondary_foreground, accentColor);
themedColors.put(R.attr.button_tertiary_foreground, accentColor);
themedColors.put(R.attr.button_outline_border, accentColor);
themedColors.put(R.attr.button_muted_foreground, accentColor);
themedColors.put(R.attr.header_tab_active_indicator, accentColor);
themedColors.put(R.attr.header_alternate_tab_active_indicator, accentColor);
themedColors.put(R.attr.button_primary_background_disabled, mutedAccentColor);
themedColors.put(R.attr.button_secondary_foreground_disabled, mutedAccentColor);
themedColors.put(R.attr.button_tertiary_foreground_disabled, mutedAccentColor);
themedColors.put(R.attr.button_outline_border_disabled, mutedAccentColor);
themedColors.put(R.attr.button_muted_foreground_disabled, mutedAccentColor);
themedColors.put(R.attr.im_dropdown_icon_color, accentColor);
themedColors.put(R.attr.im_dropdown_arrow_tint, accentColor);
themedColors.put(R.attr.im_attach_tint, accentColor);
themedColors.put(R.attr.im_forward_line_tint, accentColor);
themedColors.put(R.attr.link_alternate, accentColor);
themedColors.put(R.attr.newsfeed_post_title_color, accentColor);
themedColors.put(R.attr.attach_picker_tab_active_background, accentColor);
themedColors.put(R.attr.attach_picker_tab_active_text, accentColor);
themedColors.put(R.attr.newsfeed_action_color, accentColor);
themedColors.put(R.attr.counter_primary_background, accentColor);
themedColors.put(R.attr.dynamic_blue, accentColor);
themedColors.put(R.attr.action_sheet_action_foreground, accentColor);
// messages
themedColors.put(R.attr.im_reply_separator, accentColor);
themedColors.put(R.attr.im_text_name, accentColor);
outgoinging_msg = ThemesUtils.lighten(accentColor, 0.76f);
outgoinging_msg_highlight = ThemesUtils.lighten(accentColor, 0.5f);
themedColors.put(R.attr.im_ic_send_msg, accentColor);
themedColors.put(R.attr.im_bubble_wallpaper_outgoing, accentColor);
themedColors.put(R.attr.im_bubble_outgoing, accentColor);
themedColors.put(R.attr.im_bubble_outgoing_highlighted, accentColor);
}
public static int getThemedAttr(Context context, @IdRes int attr) {
if (attr == R.attr.im_bubble_wallpaper_outgoing || attr == R.attr.im_bubble_outgoing) {
return outgoinging_msg;
} else if (attr == R.attr.im_bubble_outgoing_highlighted) {
return outgoinging_msg_highlight;
}
return themedColors.get(attr);
}
public static boolean hasThemedAttr(Context context, int attrID) {
// try {
// Log.d(TAG, "Requesting color by attr " + context.getResources().getResourceName(attrID));
// } catch (Exception e) {
// }
if (isCachedAccents()) {
if (ThemesUtils.isDarkTheme()) {
return (themedColors.get(attrID) != 0 && ACCENT_THEME_ONLY_DARK.get(attrID, true) && (
ThemesUtils.isMilkshake() ?
ACCENT_THEME_ONLY_MILK_DARK.get(attrID, true) :
ACCENT_THEME_ONLY_NOMILK.get(attrID, true)));
} else {
return (themedColors.get(attrID) != 0 && ACCENT_THEME_ONLY_LIGHT.get(attrID, true) && (
ThemesUtils.isMilkshake() ?
ACCENT_THEME_ONLY_MILK_LIGHT.get(attrID, true) :
ACCENT_THEME_ONLY_NOMILK_LIGHT.get(attrID, true)));
}
} else {
return themedColors.get(attrID) != 0;
}
}
public static void clear() {
cachedAccents = false;
themedColors.clear();
}
public static boolean isCachedAccents() {
return cachedAccents;
}
}
@@ -0,0 +1,54 @@
package ru.vtosters.lite.themes;
import android.content.Context;
import android.graphics.drawable.*;
import android.os.Build;
import android.view.View;
import android.widget.TextView;
import androidx.annotation.ColorRes;
import androidx.annotation.NonNull;
import com.vtosters.lite.R;
import ru.vtosters.lite.themes.utils.RecolorUtils;
import ru.vtosters.lite.utils.ThemesUtils;
public class ThemesHacks {
// Фиксит селектор (все/свои/архив) в профиле
public static void fixProfileSelector(View view) {
if (!ThemesUtils.isMilkshake()) return;
var id = view.getId();
if (id == R.id.profile_wall_owner_posts || id == R.id.profile_wall_all_posts || id == R.id.profile_wall_archived_posts) {
StateListDrawable states = (StateListDrawable) ((LayerDrawable) view.getBackground()).getDrawable(0);
LayerDrawable selected = (LayerDrawable) ((DrawableContainer.DrawableContainerState) states.getConstantState()).getChildren()[0];
((ColorDrawable) selected.getDrawable(0)).setColor(ThemesUtils.getAccentColor());
}
}
public static void fixThemedFeed(TextView textView, int i) {
if (i != R.layout.themed_feed_tab_2) {
return;
}
textView.setTextColor(RecolorUtils.recolorCSL(textView.getTextColors()));
((InsetDrawable) ((DrawableContainer.DrawableContainerState) textView.getBackground().getConstantState()).getChildren()[0]).getDrawable().setTint(ThemesUtils.lighten(ThemesUtils.getAccentColor(), 0.15f));
}
public static void fixDropdown(Drawable drawable) {
if (!ThemesUtils.isDarkTheme() && ThemesUtils.isMilkshake() && ThemesCore.isCachedAccents()) {
StateListDrawable stateListDrawable = (StateListDrawable) drawable;
((DrawableContainer.DrawableContainerState) stateListDrawable.getConstantState()).getChildren()[0].setTint(ThemesUtils.getAccentColor());
((DrawableContainer.DrawableContainerState) stateListDrawable.getConstantState()).getChildren()[1].setTint(ThemesUtils.halfAlpha(ThemesUtils.getAccentColor()));
}
}
public static int getHackedColor(@NonNull Context context, @ColorRes int color) {
if (ThemesCore.isCachedAccents() && ColorReferences.isAccentedColor(context.getResources().getColor(color))) {
return ThemesUtils.getAccentColor();
}
if (ThemesCore.isCachedAccents() && ColorReferences.isMutedAccentedColor(context.getResources().getColor(color))) {
return ThemesUtils.getMutedAccentColor();
}
return Build.VERSION.SDK_INT > 23 ? context.getColor(color) : context.getResources().getColor(color);
}
}
@@ -0,0 +1,92 @@
package ru.vtosters.lite.themes;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.Log;
import android.util.TypedValue;
import androidx.annotation.Nullable;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import ru.vtosters.lite.utils.ThemesUtils;
public class VTLResources extends Resources {
private static final String TAG = "VTLResources";
private final Context context;
private static Field typedArrayField;
private static final List<Integer> attributesToTheme = new ArrayList<>();
static {
try {
typedArrayField = TypedArray.class.getDeclaredField("mData");
typedArrayField.setAccessible(true);
} catch (NoSuchFieldException e) {
e.printStackTrace();
}
attributesToTheme.add(16843041);
attributesToTheme.add(android.R.attr.backgroundTint);
attributesToTheme.add(16843173);
}
public VTLResources(Context context, Resources parent) {
super(parent.getAssets(), parent.getDisplayMetrics(), parent.getConfiguration());
this.context = context;
// Log.d(TAG, "VTLResources: init");
}
@Override
public TypedArray obtainAttributes(AttributeSet set, int[] attrs) {
var typedArray = super.obtainAttributes(set, attrs);
var data = getArrayData(typedArray);
for (int i = 0; i < attrs.length; i++) {
try {
int attrID = attrs[i];
if (attributesToTheme.contains(attrID)) {
int type = data[i*6];
int cnt = data[(i*6)+1];
if (type == TypedValue.TYPE_ATTRIBUTE && isAttrThemeable(cnt)) {
data[i*6] = TypedValue.TYPE_INT_COLOR_RGB8;
data[(i*6)+1] = ThemesUtils.getAccentColor();
data[(i*6)+2] = 0; // clear reference content
}
}
} catch (Exception e) {
Log.e(TAG, "TAVzlom failed! (obtainAttributes)");
e.printStackTrace();
}
}
return typedArray;
}
@Override
public Drawable getDrawable(int id, @Nullable Theme theme) throws NotFoundException {
var drawable = super.getDrawable(id, theme);
if (id == com.vtosters.lite.R.drawable.newsfeed_tab_dropdown_16) {
ThemesHacks.fixDropdown(drawable);
}
return drawable;
}
private static boolean isAttrThemeable(int attrID) {
return !ThemesUtils.isDarkTheme() && attrID == com.vtosters.lite.R.attr.button_primary_background;
}
private static int[] getArrayData(TypedArray arr) {
try {
return (int[]) typedArrayField.get(arr);
} catch (IllegalAccessException e) {
Log.e(TAG, "getArrayData: ", e);
e.printStackTrace();
return new int[0];
}
}
}
@@ -0,0 +1,43 @@
package ru.vtosters.lite.themes;
import android.view.View;
import android.view.ViewGroup;
import java.util.ArrayList;
import ru.vtosters.lite.themes.hooks.BaseHook;
import ru.vtosters.lite.themes.hooks.ButtonHook;
import ru.vtosters.lite.themes.hooks.ImageViewHook;
import ru.vtosters.lite.themes.hooks.ProgressWheelHook;
import ru.vtosters.lite.themes.hooks.TabLayoutHook;
import ru.vtosters.lite.themes.hooks.TextViewHook;
import ru.vtosters.lite.themes.hooks.ToolbarHook;
import ru.vtosters.lite.themes.hooks.VKImageViewHook;
public class ViewInjector {
public static ArrayList<BaseHook> hooks = new ArrayList<>();
static {
hooks.add(new ButtonHook());
hooks.add(new ImageViewHook());
hooks.add(new TabLayoutHook());
hooks.add(new TextViewHook());
hooks.add(new ToolbarHook());
hooks.add(new VKImageViewHook());
hooks.add(new ProgressWheelHook());
}
public static View inject(View view, int i, boolean z) {
for (BaseHook hook : hooks) {
hook.inject(view, i, z);
}
if (view instanceof ViewGroup) {
var viewGroup = (ViewGroup) view;
for (int i2 = 0; i2 < viewGroup.getChildCount(); i2++) {
inject(viewGroup.getChildAt(i2), i, false);
}
}
return view;
}
}
@@ -0,0 +1,7 @@
package ru.vtosters.lite.themes.hooks;
import android.view.View;
public interface BaseHook {
void inject(View view, int i, boolean z);
}
@@ -0,0 +1,29 @@
package ru.vtosters.lite.themes.hooks;
import android.content.res.ColorStateList;
import android.view.View;
import android.widget.Button;
import ru.vtosters.lite.themes.ColorReferences;
import ru.vtosters.lite.utils.ThemesUtils;
public class ButtonHook implements BaseHook {
@Override
public void inject(View view, int i, boolean z) {
if (view instanceof Button) {
var button = (Button) view;
if (button.getBackgroundTintList() != null && ColorReferences.isMutedAccentedColor(button.getBackgroundTintList())) {
button.setBackgroundTintList(ColorStateList.valueOf(ThemesUtils.getMutedAccentColor()));
}
if (button.getBackgroundTintList() != null && ColorReferences.isAccentedColor(button.getBackgroundTintList())) {
button.setBackgroundTintList(ColorStateList.valueOf(ThemesUtils.getAccentColor()));
}
if (TextViewHook.isPositiveButton(button) || TextViewHook.isVkUiButton(view)) {
button.setBackgroundTintList(ColorStateList.valueOf(ThemesUtils.getAccentColor()));
}
}
}
}
@@ -0,0 +1,24 @@
package ru.vtosters.lite.themes.hooks;
import android.content.res.ColorStateList;
import android.view.View;
import android.widget.ImageView;
import ru.vtosters.lite.themes.ColorReferences;
import ru.vtosters.lite.themes.ThemesCore;
import ru.vtosters.lite.utils.ThemesUtils;
public class ImageViewHook implements BaseHook {
@Override
public void inject(View view, int i, boolean z) {
if (view instanceof ImageView) {
if (ThemesCore.isCachedAccents()) {
var imageView = (ImageView) view;
if (imageView.getImageTintList() == null) return;
if (ColorReferences.isCslNeedToBeThemed(imageView.getImageTintList())) {
imageView.setImageTintList(ColorStateList.valueOf(ThemesUtils.getAccentColor()));
}
}
}
}
}
@@ -0,0 +1,21 @@
package ru.vtosters.lite.themes.hooks;
import android.view.View;
import com.pnikosis.materialishprogress.ProgressWheel;
import ru.vtosters.lite.themes.ThemesCore;
import ru.vtosters.lite.utils.ThemesUtils;
public class ProgressWheelHook implements BaseHook {
@Override
public void inject(View view, int i, boolean z) {
if (view instanceof ProgressWheel) {
if (ThemesCore.isCachedAccents()) {
var progressWheel = (ProgressWheel) view;
progressWheel.setBarColor(ThemesUtils.getAccentColor());
}
}
}
}
@@ -0,0 +1,21 @@
package ru.vtosters.lite.themes.hooks;
import android.content.res.ColorStateList;
import android.view.View;
import com.vk.core.view.VKTabLayout;
import ru.vtosters.lite.utils.ThemesUtils;
public class TabLayoutHook implements BaseHook {
@Override
public void inject(View view, int i, boolean z) {
if (view instanceof VKTabLayout) {
var tabLayout = (VKTabLayout) view;
tabLayout.setSelectedTabIndicatorColor(ThemesUtils.getAccentColor());
tabLayout.setTabRippleColor(ColorStateList.valueOf(ThemesUtils.getAccentColor()));
}
}
}
@@ -0,0 +1,136 @@
package ru.vtosters.lite.themes.hooks;
import android.annotation.SuppressLint;
import android.content.res.ColorStateList;
import android.os.Build;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import androidx.appcompat.widget.AppCompatCheckedTextView;
import com.vk.core.extensions.EditTextExt;
import com.vk.core.view.OverlayTextView;
import com.vk.core.view.TintTextView;
import com.vk.core.view.links.LinkedTextView;
import com.vtosters.lite.R;
import ru.vtosters.lite.themes.ColorReferences;
import ru.vtosters.lite.themes.ThemesHacks;
import ru.vtosters.lite.themes.utils.VkUiThemer;
import ru.vtosters.lite.utils.ThemesUtils;
public class TextViewHook implements BaseHook {
private static final String TAG = "TextViewHook";
@SuppressLint("RestrictedApi")
@Override
public void inject(View view, int i, boolean z) {
if (view instanceof TextView) {
var textView = (TextView) view;
if (ColorReferences.isAccentedColor(textView.getCurrentTextColor())) {
textView.setTextColor(ThemesUtils.getAccentColor());
}
if (ColorReferences.isMutedAccentedColor(textView.getCurrentTextColor())) {
textView.setTextColor(ThemesUtils.getMutedAccentColor());
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && textView.getCompoundDrawableTintList() != null) {
if (ColorReferences.isAccentedColor(textView.getCompoundDrawableTintList())) {
textView.setCompoundDrawableTintList(ColorStateList.valueOf(ThemesUtils.getAccentColor()));
}
if (ColorReferences.isMutedAccentedColor(textView.getCompoundDrawableTintList())) {
textView.setCompoundDrawableTintList(ColorStateList.valueOf(ThemesUtils.getMutedAccentColor()));
}
}
if (textView.getLinkTextColors() != null && ColorReferences.isAccentedColor(textView.getLinkTextColors())) {
textView.setLinkTextColor(ThemesUtils.getAccentColor());
}
if (textView.getLinkTextColors() != null && ColorReferences.isMutedAccentedColor(textView.getLinkTextColors())) {
textView.setLinkTextColor(ThemesUtils.getMutedAccentColor());
}
if (isPositiveButton(textView) || isVkUiButton(textView)) {
view.setBackgroundTintList(ColorStateList.valueOf(ThemesUtils.getAccentColor()));
}
if (view instanceof OverlayTextView) {
if (view.getId() == android.R.id.button1) {
view.setBackground(ThemesUtils.recolorDrawable(view.getBackground()));
}
if (ColorReferences.isAccentedColor(((OverlayTextView) view).getTextColors().getDefaultColor())) {
((OverlayTextView) view).setTextColor(ThemesUtils.getAccentColor());
}
}
if (view instanceof TintTextView) {
if (eligibleForStartTinting((TintTextView) view)) {
((TintTextView) view).setDrawableStartTint(ThemesUtils.getAccentColor());
}
if (eligibleForStartTintingMuted((TintTextView) view)) {
((TintTextView) view).setDrawableStartTint(ThemesUtils.getMutedAccentColor());
}
if (eligibleForTinting(view.getId())) {
((TintTextView) view).setDrawableTint(ThemesUtils.getAccentColor());
}
if (eligibleForTinting(view.getId())) {
((TintTextView) view).setDrawableStartTint(ThemesUtils.getAccentColor());
}
}
if (view instanceof LinkedTextView) {
((LinkedTextView) view).setLinkTextColor(ThemesUtils.getAccentColor());
}
if (view instanceof AppCompatCheckedTextView) {
var check = (AppCompatCheckedTextView) view;
if (ColorReferences.isAccentedColor(check.getCheckMarkTintList())) {
check.setCheckMarkTintList(ColorStateList.valueOf(ThemesUtils.getAccentColor()));
}
if (ColorReferences.isMutedAccentedColor(check.getCheckMarkTintList())) {
check.setCheckMarkTintList(ColorStateList.valueOf(ThemesUtils.getMutedAccentColor()));
}
}
if (view instanceof EditText) {
ThemesUtils.setCursorColor((EditText) view);
}
ThemesUtils.colorHandles(textView);
VkUiThemer.autoThemeVkuiButtons(textView);
ThemesHacks.fixProfileSelector(textView);
ThemesHacks.fixThemedFeed(textView, i);
}
}
public static boolean eligibleForStartTinting(TintTextView view) {
return ColorReferences.isAccentedColor(view.getTextColors()) || view.getTextColors().getDefaultColor() == ThemesUtils.getAccentColor();
}
public static boolean eligibleForStartTintingMuted(TintTextView view) {
return ColorReferences.isMutedAccentedColor(view.getTextColors()) || view.getTextColors().getDefaultColor() == ThemesUtils.getMutedAccentColor();
}
public static boolean eligibleForTinting(int id) {
return !ThemesUtils.isDarkTheme() && (id == R.id.attach_title || id == R.id.post_retweet_name);
}
public static boolean isPositiveButton(View view) {
return !ThemesUtils.isDarkTheme() && (view.getId() == R.id.positive || view.getId() == R.id.positive_button);
}
public static boolean isVkUiButton(View view) {
return !ThemesUtils.isDarkTheme() && (view.getId() == R.id.empty_button || view.getId() == R.id.button);
}
}
@@ -0,0 +1,29 @@
package ru.vtosters.lite.themes.hooks;
import android.view.View;
import androidx.appcompat.widget.Toolbar;
import com.vk.core.drawable.RecoloredDrawable;
import ru.vtosters.lite.utils.ThemesUtils;
public class ToolbarHook implements BaseHook {
@Override
public void inject(View view, int i, boolean z) {
if (view instanceof Toolbar) {
var color = (ThemesUtils.isMilkshake() && !ThemesUtils.isDarkTheme()) ? ThemesUtils.getAccentColor() : ThemesUtils.getHeaderText();
var menu = ((Toolbar) view).getMenu();
for (int j = 0; j < menu.size(); ++j) {
var item = menu.getItem(j);
var icon = item.getIcon();
if (icon != null) {
if (icon instanceof RecoloredDrawable)
((RecoloredDrawable) icon).a(color);
else
icon = new RecoloredDrawable(icon, color);
item.setIcon(icon);
}
}
}
}
}
@@ -0,0 +1,30 @@
package ru.vtosters.lite.themes.hooks;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.view.View;
import com.vk.imageloader.view.VKImageView;
import ru.vtosters.lite.themes.utils.RecolorUtils;
import ru.vtosters.lite.utils.ThemesUtils;
public class VKImageViewHook implements BaseHook {
private static Paint paint = new Paint();
static {
paint.setColorFilter(new PorterDuffColorFilter(ThemesUtils.getAccentColor(), PorterDuff.Mode.SRC_IN));
}
@Override
public void inject(View view, int i, boolean z) {
if (view instanceof VKImageView) {
var imageView = (VKImageView) view;
if (imageView.getImageTintList() != null) {
imageView.setImageTintList(RecolorUtils.recolorCSL(imageView.getImageTintList()));
imageView.setColorFilter(ThemesUtils.getAccentColor(), PorterDuff.Mode.SRC_IN);
}
}
}
}
@@ -0,0 +1,26 @@
package ru.vtosters.lite.themes.items;
public class VTLColor {
public String resName;
public int id;
public int color;
public VTLColor(int id, int color) {
this.id = id;
this.color = color;
}
public VTLColor(String resName, int id, int color) {
this.resName = resName;
this.id = id;
this.color = color;
}
public static VTLColor create(int id, int color) {
return new VTLColor(id, color);
}
public static VTLColor create(String resName, int id, int color) {
return new VTLColor(resName, id, color);
}
}
@@ -0,0 +1,94 @@
package ru.vtosters.lite.themes.items;
import android.graphics.Color;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.List;
public class VTLPalette {
public String id;
public String name;
public String author;
public List<VTLColor> colors = new ArrayList<>();
public VTLPalette() {
}
public VTLPalette(String id, String name, String author, List<VTLColor> colors) {
this.id = id;
this.name = name;
this.author = author;
this.colors = colors;
}
public VTLPalette setId(String id) {
this.id = id;
return this;
}
public VTLPalette setName(String name) {
this.name = name;
return this;
}
public VTLPalette setAuthor(String author) {
this.author = author;
return this;
}
public VTLPalette setColors(List<VTLColor> colors) {
this.colors = colors;
return this;
}
public VTLPalette setColor(String name, int color) {
this.colors.add(new VTLColor(name, 0, color));
return this;
}
public int getColor(String name) {
for (var item : colors)
if (name.equals(item.resName))
return item.color;
return -1;
}
public static VTLPalette fromJson(JSONObject json) throws JSONException {
var palette = new VTLPalette()
.setId(json.optString("palette_id"))
.setName(json.optString("name"))
.setAuthor(json.optString("author"));
var paletteNode = json.getJSONArray("palette");
for (int i = 0; i < paletteNode.length(); i++) {
var colorNode = paletteNode.getJSONObject(i);
var name = colorNode.getString("name");
if (colorNode.has("colors")) {
var colorsNode = colorNode.getJSONArray("colors");
for (int j = 0; j < colorsNode.length(); j++) {
var subColorNode = colorsNode.getJSONObject(j);
var index = subColorNode.getString("index");
var subColor = subColorNode.getString("color");
if (!subColor.startsWith("#")) subColor = "#" + subColor;
palette.setColor(name + " " + index, Color.parseColor(subColor));
}
} else {
var color = colorNode.getString("color");
if (!color.startsWith("#")) color = "#" + color;
palette.setColor(name, Color.parseColor(color));
}
}
return palette;
}
public static VTLPalette valuesOf(String id, String name, String author, List<VTLColor> colors) {
return new VTLPalette()
.setId(id)
.setName(name)
.setAuthor(author)
.setColors(colors);
}
}
@@ -0,0 +1,113 @@
package ru.vtosters.lite.themes.palettes;
import android.os.Build;
import android.os.Environment;
import android.util.Log;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import org.json.JSONException;
import org.json.JSONObject;
import ru.vtosters.lite.themes.items.VTLPalette;
import ru.vtosters.lite.utils.AndroidUtils;
import ru.vtosters.lite.utils.IOUtils;
import ru.vtosters.lite.utils.LifecycleUtils;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import static android.widget.Toast.makeText;
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
public class PalettesManager {
private final static File PALETTES_DIR = new File(Environment.getExternalStorageDirectory(), "VTL/palettes");
private final static String ASSETS_DIR = "vtl_themes/palettes/";
private static PalettesManager sInstance;
private final List<VTLPalette> mPalettes = new ArrayList<>();
public static PalettesManager getInstance() {
if (sInstance == null)
sInstance = new PalettesManager();
return sInstance;
}
public PalettesManager() {
load();
}
public void load() {
mPalettes.clear();
if (!PALETTES_DIR.exists())
PALETTES_DIR.mkdirs();
if (Build.VERSION.SDK_INT >= 23 && !Environment.getExternalStorageDirectory().canWrite()) {
makeText(getGlobalContext(), AndroidUtils.getString("cannot_write"), Toast.LENGTH_LONG).show();
LifecycleUtils.getCurrentActivity().requestPermissions(new String[]{"android.permission.WRITE_EXTERNAL_STORAGE"}, 228);
return;
}
final var palettes = PALETTES_DIR.listFiles((dir, name) -> name.endsWith(".json"));
if (palettes == null || palettes.length == 0)
copyPaletteFromAssets();
parsePalettes();
}
private boolean copyPaletteFromAssets() {
try {
final var manager = AndroidUtils.getGlobalContext().getAssets();
final var assets = manager.list(ASSETS_DIR);
if (assets == null || assets.length == 0) return false;
for (var asset : assets) {
try {
IOUtils.copyFile(manager.open(ASSETS_DIR + asset), new File(PALETTES_DIR, asset));
} catch (IOException e) {
e.printStackTrace();
}
}
return true;
} catch (IOException e) {
e.printStackTrace();
}
return false;
}
private void parsePalettes() {
var arr = PALETTES_DIR.listFiles((dir, name) -> name.endsWith(".json"));
if (arr == null || arr.length == 0) {
Log.d("PalettesManager", "arr.length null");
return;
}
for (var file : arr) {
try {
var json = new JSONObject(IOUtils.readAllLines(file));
mPalettes.add(VTLPalette.fromJson(json));
} catch (IOException | JSONException e) {
e.printStackTrace();
}
}
}
@Nullable
public VTLPalette getPalette(String id) {
for (var palette : mPalettes)
if (id.equals(palette.id))
return palette;
return null;
}
@NonNull
public VTLPalette getPalette(int i) {
return mPalettes.get(i);
}
public int getPalettesCount() {
return mPalettes.size();
}
}
@@ -0,0 +1,94 @@
package ru.vtosters.lite.themes.utils;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.os.Build;
import com.vk.core.drawable.RecoloredDrawable;
import ru.vtosters.lite.themes.ColorReferences;
import ru.vtosters.lite.utils.AndroidUtils;
import ru.vtosters.lite.utils.ThemesUtils;
public class RecolorUtils {
public static Drawable recolorDrawableToolbar(Drawable drawable) {
if (drawable == null) return null;
return new RecoloredDrawable(drawable, ThemesUtils.getHeaderText());
} // Recolor toolbar drawable to accent color
@SuppressLint("UseCompatLoadingForDrawables")
public static Drawable recolorDrawableInt(int drawable) {
@SuppressLint("UseCompatLoadingForDrawables") Drawable res = AndroidUtils.getResources().getDrawable(drawable);
return new RecoloredDrawable(res, ThemesUtils.getAccentColor());
} // Get res drawable via id and coloring to accent
public static int recolorHexColor(int i){
var accented = ColorReferences.isAccentedColor(i);
var mutedaccented = ColorReferences.isMutedAccentedColor(i);
return (accented || mutedaccented) ? (accented ? ThemesUtils.getAccentColor() : ThemesUtils.getMutedAccentColor()) : i;
}
public static ColorStateList recolorCSL(ColorStateList colorStateList) {
if (colorStateList == null) return null;
return ColorStateList.valueOf(ThemesUtils.getAccentColor());
} // Recolor ColorStateList to accent color
@SuppressLint("UseCompatLoadingForColorStateLists")
public static ColorStateList themeCSL(Context context, int color) {
if (ColorReferences.isColorRefAccented(color)) {
return ColorStateList.valueOf(ThemesUtils.getAccentColor());
} else if (ColorReferences.isColorRefMutedAccented(color)) {
return ColorStateList.valueOf(ThemesUtils.getMutedAccentColor());
}
ColorStateList csl;
if (Build.VERSION.SDK_INT >= 23) {
csl = context.getColorStateList(color);
} else {
csl = context.getResources().getColorStateList(color);
}
return themeCSL(csl);
} // Recolor ColorStateList
public static ColorStateList themeCSL(ColorStateList csl){
try {
int unsel = csl.getColorForState(new int[]{-android.R.attr.state_selected}, Color.BLACK);
int sel = csl.getColorForState(new int[]{android.R.attr.state_selected}, Color.BLACK);
int enabled = csl.getColorForState(new int[]{android.R.attr.state_enabled}, Color.BLACK);
int disabled = csl.getColorForState(new int[]{-android.R.attr.state_enabled}, Color.BLACK);
boolean isUnselAccent = ColorReferences.isAccentedColor(unsel);
boolean isSelAccent = ColorReferences.isAccentedColor(sel);
boolean isEnabledAccent = ColorReferences.isAccentedColor(enabled);
boolean isDisabledAccent = ColorReferences.isAccentedColor(disabled);
boolean isUnselMutedAccent = ColorReferences.isMutedAccentedColor(unsel);
boolean isSelMutedAccent = ColorReferences.isMutedAccentedColor(sel);
boolean isEnabledMutedAccent = ColorReferences.isMutedAccentedColor(enabled);
boolean isDisabledMutedAccent = ColorReferences.isMutedAccentedColor(disabled);
if (isUnselAccent || isSelAccent || isUnselMutedAccent || isSelMutedAccent) {
return new ColorStateList(new int[][]{
new int[]{android.R.attr.state_selected}, new int[]{-android.R.attr.state_selected}
}, new int[]{(isSelAccent || isSelMutedAccent) ? (isSelAccent ? ThemesUtils.getAccentColor() : ThemesUtils.getMutedAccentColor()) : sel, (isUnselAccent || isUnselMutedAccent) ? (isUnselAccent ? ThemesUtils.getAccentColor() : ThemesUtils.getMutedAccentColor()) : unsel});
}
if (isDisabledAccent || isEnabledAccent || isEnabledMutedAccent || isDisabledMutedAccent) {
return new ColorStateList(new int[][]{
new int[]{android.R.attr.state_enabled}, new int[]{-android.R.attr.state_enabled}
}, new int[]{(isEnabledAccent || isEnabledMutedAccent) ? (isEnabledAccent ? ThemesUtils.getAccentColor() : ThemesUtils.getMutedAccentColor()) : enabled, (isDisabledAccent || isDisabledMutedAccent) ? (isDisabledAccent ? ThemesUtils.getAccentColor() : ThemesUtils.getMutedAccentColor()) : disabled});
}
return csl;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
}
@@ -0,0 +1,85 @@
package ru.vtosters.lite.themes.utils;
import android.content.res.ColorStateList;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.DrawableContainer;
import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.RippleDrawable;
import android.graphics.drawable.StateListDrawable;
import android.os.Build;
import android.widget.TextView;
import ru.vtosters.lite.themes.ColorReferences;
import ru.vtosters.lite.utils.ThemesUtils;
public class VkUiThemer {
public static void autoThemeVkuiButtons(TextView view) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) return;
if (ThemesUtils.isDarkTheme())
return; // no need to theme b/w buttons, well it should skip, but I do it for extra performance
try {
if (!(view.getBackground() instanceof StateListDrawable)) return;
StateListDrawable states = ((StateListDrawable) view.getBackground());
if (states.getConstantState() == null) return;
DrawableContainer.DrawableContainerState dStates = (DrawableContainer.DrawableContainerState) states.getConstantState();
if (dStates.getChildCount() == 2) {
Drawable target = dStates.getChildren()[0];
if (!(target instanceof RippleDrawable)) return;
RippleDrawable ripple = (RippleDrawable) target;
for (int i = 0; i < ripple.getNumberOfLayers(); i++) {
if (ripple.getId(i) == android.R.id.mask) continue;
Drawable currentTarget = ripple.getDrawable(i);
if (!(currentTarget instanceof GradientDrawable)) continue;
//if (TSColorRefs.TS_DEBUG_MODE) Log.d("TSCore", "[tsh] finally, obamium = ["+currentTarget.toString()+"]");
GradientDrawable spd = (GradientDrawable) currentTarget;
if (spd.getShape() != GradientDrawable.RECTANGLE) continue;
// Log.d("TSCore", "[tsh] got a color!");
ColorStateList csl = spd.getColor();
// if (csl != null) {
// Log.d("TSCore", "[tsh] csl2 <def: " + csl.getDefaultColor() + " = " + ThemesUtils.hex(csl.getDefaultColor()) + "> | " + csl);
// }
if (ColorReferences.isAccentedColor(spd.getColor())) {
// Log.d("TSCore", "[tsh] theming CSL");
spd.setTint(ThemesUtils.getAccentColor());
}
}
Drawable draw2 = dStates.getChildren()[0];
if (!(draw2 instanceof GradientDrawable)) return;
GradientDrawable spd = (GradientDrawable) draw2;
if (spd.getShape() != GradientDrawable.RECTANGLE) return;
// Log.d("TSCore", "[tsh:disabled] got a color!");
ColorStateList csl = spd.getColor();
// if (csl != null) {
// Log.d("TSCore", "[tsh:disabled] csl2 <def: " + csl.getDefaultColor() + " = " + ThemesUtils.hex(csl.getDefaultColor()) + "> | " + csl);
// }
if (ColorReferences.isAccentedColor(spd.getColor())) {
// Log.d("TSCore", "[tsh:disabled] theming CSL");
spd.setTint(ThemesUtils.getAccentColor());
}
if (ColorReferences.isMutedAccentedColor(spd.getColor())) {
// Log.d("TSCore", "[tsh:disabled] theming CSL");
spd.setTint(ThemesUtils.getMutedAccentColor());
}
}
} catch (Exception e) {
// This must go wrong, so we ignore any exceptions that may occur
e.printStackTrace(); // REMOVE THIS!
}
}
}
@@ -0,0 +1,340 @@
package ru.vtosters.lite.ui;
import android.graphics.drawable.Drawable;
import android.preference.PreferenceManager;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.LinearLayout;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceScreen;
import com.vk.core.dialogs.alert.VkAlertDialog;
import com.vtosters.lite.ui.MaterialSwitchPreference;
import ru.vtosters.lite.utils.AndroidUtils;
import ru.vtosters.lite.utils.ImageUtils;
import ru.vtosters.lite.utils.ThemesUtils;
public class PreferenceFragmentUtils {
public static ListPreference addListPreference(
PreferenceScreen screen,
String key,
String def,
int titleRes,
CharSequence[] entries,
CharSequence[] entriesValue
) {
return addListPreference(screen, key, def, titleRes, 0, 0, entries, entriesValue, null);
}
public static ListPreference addListPreference(
PreferenceScreen screen,
String key,
String def,
CharSequence title,
CharSequence[] entries,
CharSequence[] entriesValue
) {
return addListPreference(screen, key, def, title, null, "", entries, entriesValue, null);
}
// change icon accent color
public static ListPreference addListPreference(
PreferenceScreen screen,
String key,
String def,
int titleRes,
int iconRes,
int summaryRes,
CharSequence[] entries,
CharSequence[] entriesValue,
Preference.OnPreferenceChangeListener listener
) {
var icon = iconRes > 0
? ImageUtils.setTint(screen.getContext(), ContextCompat.getDrawable(screen.getContext(), iconRes))
: null;
var title = titleRes > 0
? screen.getContext().getString(titleRes)
: "";
var summary = summaryRes > 0
? screen.getContext().getString(summaryRes)
: "";
return addListPreference(screen, key, def, title, icon, summary, entries, entriesValue, listener);
}
// change icon accent color
public static ListPreference addListPreference(
PreferenceScreen screen,
String key,
String def,
CharSequence title,
int iconRes,
CharSequence summary,
CharSequence[] entries,
CharSequence[] entriesValue,
Preference.OnPreferenceChangeListener listener
) {
var icon = iconRes > 0
? ImageUtils.setTint(screen.getContext(), ContextCompat.getDrawable(screen.getContext(), iconRes))
: null;
return addListPreference(screen, key, def, title, icon, summary, entries, entriesValue, listener);
}
public static ListPreference addListPreference(
PreferenceScreen screen,
String key,
String def,
CharSequence title,
@Nullable Drawable icon,
CharSequence summary,
CharSequence[] entries,
CharSequence[] entriesValue,
Preference.OnPreferenceChangeListener listener
) {
ListPreference preference = new ListPreference(screen.getContext());
preference.setEntries(entries);
preference.setEntryValues(entriesValue);
preference.setSummary(summary);
preference.setTitle(title);
preference.setDialogTitle(title);
preference.setKey(key);
preference.setDefaultValue(def);
preference.setValue(def);
preference.setOnPreferenceChangeListener(listener);
if (icon != null)
preference.setIcon(icon);
screen.addPreference(preference);
return preference;
}
public static MaterialSwitchPreference addMaterialSwitchPreference(
PreferenceScreen screen,
String key,
CharSequence title,
CharSequence summary,
boolean defValue
) {
return addMaterialSwitchPreference(screen, key, title, summary, 0, defValue, null);
}
// change icon accent color
public static MaterialSwitchPreference addMaterialSwitchPreference(
PreferenceScreen screen,
String key,
int titleRes,
int summaryRes,
int iconRes,
boolean defValue,
Preference.OnPreferenceChangeListener listener
) {
var icon = iconRes > 0
? ImageUtils.setTint(screen.getContext(), ContextCompat.getDrawable(screen.getContext(), iconRes))
: null;
var title = titleRes > 0
? screen.getContext().getString(titleRes)
: "";
var summary = summaryRes > 0
? screen.getContext().getString(summaryRes)
: "";
return addMaterialSwitchPreference(screen, key, title, summary, icon, defValue, listener);
}
// change icon accent color
public static MaterialSwitchPreference addMaterialSwitchPreference(
PreferenceScreen screen,
String key,
CharSequence title,
CharSequence summary,
int iconRes,
boolean defValue,
Preference.OnPreferenceChangeListener listener
) {
var icon = iconRes > 0
? ImageUtils.setTint(screen.getContext(), ContextCompat.getDrawable(screen.getContext(), iconRes))
: null;
return addMaterialSwitchPreference(screen, key, title, summary, icon, defValue, listener);
}
public static MaterialSwitchPreference addMaterialSwitchPreference(
PreferenceScreen screen,
String key,
CharSequence title,
CharSequence summary,
@Nullable Drawable icon,
boolean defValue,
Preference.OnPreferenceChangeListener listener
) {
MaterialSwitchPreference preference = new MaterialSwitchPreference(screen.getContext());
preference.setTitle(title);
preference.setSummary(summary);
preference.setKey(key);
preference.setDefaultValue(defValue);
if (icon != null)
preference.setIcon(icon);
preference.setOnPreferenceChangeListener(listener);
screen.addPreference(preference);
return preference;
}
public static Preference addPreference(
PreferenceScreen screen,
String key,
int titleRes,
int summaryRes
) {
var title = titleRes > 0
? screen.getContext().getString(titleRes)
: "";
var summary = summaryRes > 0
? screen.getContext().getString(summaryRes)
: "";
return addPreference(screen, key, title, summary, null, null);
}
public static Preference addPreference(
PreferenceScreen screen,
String key,
CharSequence title,
CharSequence summary
) {
return addPreference(screen, key, title, summary, null, null);
}
// change icon accent color
public static Preference addPreference(
PreferenceScreen screen,
String key,
int titleRes,
int summaryRes,
int iconRes,
Preference.OnPreferenceClickListener listener) {
var icon = iconRes > 0
? ImageUtils.setTint(screen.getContext(), screen.getContext().getDrawable(iconRes))
: null;
var title = titleRes > 0
? screen.getContext().getString(titleRes)
: "";
var summary = summaryRes > 0
? screen.getContext().getString(summaryRes)
: "";
return addPreference(screen, key, title, summary, icon, listener);
}
// change icon accent color
public static Preference addPreference(
PreferenceScreen screen,
String key,
CharSequence title,
CharSequence summary,
int iconRes,
Preference.OnPreferenceClickListener listener) {
var icon = iconRes > 0
? ImageUtils.setTint(screen.getContext(), screen.getContext().getDrawable(iconRes))
: null;
return addPreference(screen, key, title, summary, icon, listener);
}
public static Preference addPreference(
PreferenceScreen screen,
String key,
CharSequence title,
CharSequence summary,
@Nullable Drawable icon,
Preference.OnPreferenceClickListener listener
) {
Preference preference = new Preference(screen.getContext());
preference.setSummary(summary);
preference.setTitle(title);
preference.setKey(key);
if (icon != null)
preference.setIcon(icon);
preference.setOnPreferenceClickListener(listener);
screen.addPreference(preference);
return preference;
}
public static PreferenceCategory addPreferenceCategory(PreferenceScreen screen, int titleRes) {
var title = titleRes > 0
? screen.getContext().getString(titleRes)
: "";
return addPreferenceCategory(screen, title);
}
public static PreferenceCategory addPreferenceCategory(PreferenceScreen screen, CharSequence title) {
PreferenceCategory preference = new PreferenceCategory(screen.getContext(), null);
preference.setTitle(title);
screen.addPreference(preference);
return preference;
}
public static Preference addEditTextPreference(
PreferenceScreen screen,
String key,
int titleRes,
onPreferenceTextValueChangeListener editTextPrefChangeListener
) {
var title = titleRes > 0
? screen.getContext().getString(titleRes)
: "";
return addEditTextPreference(screen, key, title, editTextPrefChangeListener);
}
public static Preference addEditTextPreference(
PreferenceScreen screen,
String key,
CharSequence title,
onPreferenceTextValueChangeListener editTextPrefChangeListener
) {
return addPreference(screen, key, title, null, null, preference -> {
LinearLayout linearLayout = new LinearLayout(screen.getContext());
final EditText editText = new EditText(screen.getContext());
editText.setText(PreferenceManager.getDefaultSharedPreferences(screen.getContext()).getString(key, ""));
editText.setHint(title);
editText.setTextColor(ThemesUtils.getTextAttr());
editText.setHintTextColor(ThemesUtils.getSTextAttr());
editText.setBackgroundTintList(ThemesUtils.getAccenedColorStateList());
linearLayout.addView(editText);
editText.getLayoutParams().width = ViewGroup.LayoutParams.MATCH_PARENT;
ViewGroup.MarginLayoutParams margin = ((ViewGroup.MarginLayoutParams) editText.getLayoutParams());
margin.setMargins(AndroidUtils.dp2px(20f), 0, AndroidUtils.dp2px(20f), 0);
editText.setLayoutParams(margin);
new VkAlertDialog.Builder(screen.getContext())
.setTitle(title)
.setView(linearLayout)
.setPositiveButton("OK", (dialog, which) -> {
boolean change = editTextPrefChangeListener.onChanged(preference, editText.getText().toString());
if (!change)
return;
PreferenceManager.getDefaultSharedPreferences(screen.getContext())
.edit()
.putString(key, editText.getText().toString())
.apply();
})
.show();
return false;
});
}
public interface onPreferenceTextValueChangeListener {
boolean onChanged(Preference preference, String newValue);
}
}
@@ -1,281 +0,0 @@
package ru.vtosters.lite.ui;
import static ru.vtosters.lite.utils.AndroidUtils.dp2px;
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
import static ru.vtosters.lite.utils.ImageUtils.setTint;
import static ru.vtosters.lite.utils.ThemesUtils.getAccentColor;
import static ru.vtosters.lite.utils.ThemesUtils.getSTextAttr;
import static ru.vtosters.lite.utils.ThemesUtils.getTextAttr;
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.drawable.Drawable;
import android.preference.PreferenceManager;
import android.util.TypedValue;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.LinearLayout;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceCategory;
import com.vk.core.dialogs.alert.VkAlertDialog;
import com.vtosters.lite.general.fragments.MaterialPreferenceToolbarFragment;
import com.vtosters.lite.ui.MaterialSwitchPreference;
public class PreferencesUtil {
public static void addListPreference(
MaterialPreferenceToolbarFragment fragment,
String key,
String def,
CharSequence title,
CharSequence[] entries,
CharSequence[] entriesValue
) {
ListPreference preference = new ListPreference(getGlobalContext());
preference.setEntries(entries);
preference.setEntryValues(entriesValue);
preference.setTitle(title); // setTitle
preference.setDialogTitle(title); // setDialogTitle
preference.setKey(key); // setKey
preference.setDefaultValue(def); // setDefaultValue
fragment.getPreferenceScreen().addPreference(preference); // fragment.getPreferenceScreen().addPreference(preference)
}
public static void addListPreferenceIcon(
MaterialPreferenceToolbarFragment fragment,
String key,
String def,
CharSequence title,
int iconRes,
CharSequence summary,
CharSequence[] entries,
CharSequence[] entriesValue,
Preference.OnPreferenceChangeListener listener
) {
ListPreference preference = new ListPreference(getGlobalContext());
preference.setEntries(entries);
preference.setEntryValues(entriesValue);
preference.setSummary(summary); // setSummary
preference.setTitle(title); // setTitle
preference.setDialogTitle(title); // setDialogTitle
preference.setKey(key); // setKey
preference.setDefaultValue(def); // setDefaultValue
preference.setValue(def);
preference.setOnPreferenceChangeListener(listener);
if (iconRes != 0)
preference.setIcon(setTint(getGlobalContext(), getDrawable(getGlobalContext(), iconRes))); // preference.setIcon
fragment.getPreferenceScreen().addPreference(preference); // fragment.getPreferenceScreen().addPreference(preference)
}
public static void addMaterialSwitchPreference(
MaterialPreferenceToolbarFragment materialPreferenceToolbarFragment,
String key,
CharSequence title,
CharSequence summary,
boolean defValue
) {
MaterialSwitchPreference materialSwitchPreference = new MaterialSwitchPreference(getGlobalContext());
materialSwitchPreference.setTitle(title); // setTitle
materialSwitchPreference.setSummary(summary); // setSummary
materialSwitchPreference.setKey(key); // setKey
materialSwitchPreference.setDefaultValue(defValue); // setDefaultValue
materialPreferenceToolbarFragment.getPreferenceScreen().addPreference(materialSwitchPreference); // materialPreferenceToolbarFragment.getPreferenceScreen().addPreference(preference)
}
// public static void addMaterialSwitchPreference(
// MaterialPreferenceToolbarFragment fragment,
// String key,
// CharSequence title,
// CharSequence summary,
// int iconRes,
// boolean defValue,
// Preference.OnPreferenceChangeListener listener
// ) {
// MaterialSwitchPreference materialSwitchPreference = new MaterialSwitchPreference(getGlobalContext());
// materialSwitchPreference.setTitle(title); // setTitle
// materialSwitchPreference.setSummary(summary); // setSummary
// materialSwitchPreference.setKey(key); // setKey
// materialSwitchPreference.setDefaultValue(defValue); // setDefaultValue
// materialSwitchPreference.setOnPreferenceChangeListener(listener); // setOnPreferenceClickListener
//
// if (iconRes != 0)
// materialSwitchPreference.setIcon(setTint(getGlobalContext(), Objects.requireNonNull(ContextCompat.getDrawable(getGlobalContext(), iconRes)))); // preference.setIcon
//
// fragment.getPreferenceScreen().addPreference(materialSwitchPreference); // fragment.getPreferenceScreen().addPreference(preference)
// }
public static void addMaterialSwitchPreference(
MaterialPreferenceToolbarFragment fragment,
String key,
CharSequence title,
CharSequence summary,
int iconRes,
boolean defValue,
Preference.OnPreferenceChangeListener listener
) {
MaterialSwitchPreference materialSwitchPreference = new MaterialSwitchPreference(getGlobalContext());
materialSwitchPreference.setTitle(title); // setTitle
materialSwitchPreference.setSummary(summary); // setSummary
materialSwitchPreference.setKey(key); // setKey
materialSwitchPreference.setDefaultValue(defValue); // setDefaultValue
fragment.getPreferenceScreen().addPreference(materialSwitchPreference); // materialPreferenceToolbarFragment.getPreferenceScreen().addPreference(preference)
if (iconRes != 0)
materialSwitchPreference.setIcon(setTint(getGlobalContext(), getDrawable(getGlobalContext(), iconRes))); // preference.setIcon
materialSwitchPreference.setOnPreferenceChangeListener(listener); // setOnPreferenceClickListener(listener)
fragment.getPreferenceScreen().addPreference(materialSwitchPreference); // fragment.getPreferenceScreen().addPreference(preference)
}
public static void addPreference(
MaterialPreferenceToolbarFragment fragment,
String key,
CharSequence title,
CharSequence summary
) {
Preference preference = new Preference(getGlobalContext());
preference.setSummary(summary); // setSummary
preference.setTitle(title); // setTitle
preference.setKey(key); // setKey
fragment.getPreferenceScreen().addPreference(preference); // fragment.getPreferenceScreen().addPreference(preference)
}
public static void addPreference(
MaterialPreferenceToolbarFragment fragment,
CharSequence title,
CharSequence summary,
int iconRes,
Preference.OnPreferenceClickListener listener
) {
Preference preference = new Preference(getGlobalContext());
preference.setSummary(summary); // setSummary
preference.setTitle(title); // setTitle
if (iconRes != 0)
preference.setIcon(setTint(getGlobalContext(), getDrawable(getGlobalContext(), iconRes))); // preference.setIcon
preference.setOnPreferenceClickListener(listener); // preference.setOnPreferenceClickListener(listener)
fragment.getPreferenceScreen().addPreference(preference); // fragment.getPreferenceScreen().addPreference(preference)
}
public static void addPreference(
MaterialPreferenceToolbarFragment fragment,
String key,
CharSequence title,
CharSequence summary,
int iconRes,
Preference.OnPreferenceClickListener listener) {
Preference preference = new Preference(getGlobalContext());
preference.setSummary(summary); // setSummary
preference.setTitle(title); // setTitle
preference.setKey(key); // setKey
if (iconRes != 0)
preference.setIcon(setTint(getGlobalContext(), getDrawable(getGlobalContext(), iconRes))); // preference.setIcon
preference.setOnPreferenceClickListener(listener); // preference.setOnPreferenceClickListener(listener)
fragment.getPreferenceScreen().addPreference(preference); // fragment.getPreferenceScreen().addPreference(preference)
}
public static void addPreferenceDrawable(
MaterialPreferenceToolbarFragment fragment,
String key,
CharSequence title,
CharSequence summary,
@Nullable Drawable icon,
Preference.OnPreferenceClickListener listener
) {
Preference preference = new Preference(getGlobalContext());
preference.setSummary(summary); // setSummary
preference.setTitle(title); // setTitle
preference.setKey(key); // setKey
if (icon != null)
preference.setIcon(icon); // preference.setIcon
preference.setOnPreferenceClickListener(listener); // preference.setOnPreferenceClickListener(listener)
fragment.getPreferenceScreen().addPreference(preference); // fragment.getPreferenceScreen().addPreference(preference)
}
public static void addPreferenceCategory(MaterialPreferenceToolbarFragment fragment, CharSequence title) {
PreferenceCategory preference = new PreferenceCategory(getGlobalContext(), null);
preference.setTitle(title); // setTitle
fragment.getPreferenceScreen().addPreference(preference); // fragment.getPreferenceScreen().addPreference(preference)
}
public static void addPreferenceCategory(MaterialPreferenceToolbarFragment fragment, CharSequence title, int collapsedSize) {
PreferenceCategory preference = new PreferenceCategory(getGlobalContext(), null);
preference.setTitle(title); // setTitle
fragment.getPreferenceScreen().addPreference(preference); // fragment.getPreferenceScreen().addPreference(preference)
}
public static void addEditTextPreference(MaterialPreferenceToolbarFragment fragment, String key, CharSequence title, EditTextPrefChangeListener editTextPrefChangeListener) {
Preference preference = new Preference(getGlobalContext());
preference.setTitle(title); // setTitle
preference.setKey(key); // setKey
preference.setOnPreferenceClickListener(preference1 -> {
LinearLayout linearLayout = new LinearLayout(getGlobalContext());
final EditText editText = new EditText(getGlobalContext());
editText.setText(PreferenceManager.getDefaultSharedPreferences(getGlobalContext()).getString(key, ""));
editText.setHint(title);
editText.setTextColor(getTextAttr());
editText.setHintTextColor(getSTextAttr());
editText.setBackgroundTintList(ColorStateList.valueOf(getAccentColor()));
linearLayout.addView(editText);
editText.getLayoutParams().width = ViewGroup.LayoutParams.MATCH_PARENT;
ViewGroup.MarginLayoutParams margin = ((ViewGroup.MarginLayoutParams) editText.getLayoutParams());
margin.setMargins(dp2px(20f), 0, dp2px(20f), 0);
editText.setLayoutParams(margin);
new VkAlertDialog.Builder(fragment.getContext())
.setTitle(title)
.setView(linearLayout)
.setPositiveButton("OK", (dialog, which) -> {
boolean change = editTextPrefChangeListener.onChanged(preference, editText.getText().toString());
if (!change)
return;
PreferenceManager.getDefaultSharedPreferences(getGlobalContext())
.edit()
.putString(key, editText.getText().toString())
.apply();
})
.show();
return false;
}); // preference.setOnPreferenceClickListener(listener)
fragment.getPreferenceScreen().addPreference(preference); // fragment.getPreferenceScreen().addPreference(preference)
}
public static int getTextColor(Context ctx) {
TypedValue typedValue = new TypedValue();
ctx.getTheme().resolveAttribute(getTextAttr(), typedValue, true);
return typedValue.data;
}
public static int getSTextColor(Context ctx) {
TypedValue typedValue = new TypedValue();
ctx.getTheme().resolveAttribute(getSTextAttr(), typedValue, true);
return typedValue.data;
}
private static Drawable getDrawable(Context ctx, int drawableRes) {
return ContextCompat.getDrawable(ctx, drawableRes);
}
public interface EditTextPrefChangeListener {
boolean onChanged(Preference preference, Object obj);
}
}
@@ -1,8 +1,5 @@
package ru.vtosters.lite.ui.adapters;
import static ru.vtosters.lite.utils.AndroidUtils.dp2px;
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
import android.content.res.ColorStateList;
import android.graphics.Typeface;
import android.view.Gravity;
@@ -12,20 +9,21 @@ import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.vtosters.lite.R;
import ru.vtosters.lite.ui.components.IItemMovingListener;
import ru.vtosters.lite.utils.LayoutUtils;
import ru.vtosters.lite.utils.ThemesUtils;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import ru.vtosters.lite.ui.components.IItemMovingListener;
import ru.vtosters.lite.utils.ThemesUtils;
import static ru.vtosters.lite.utils.AndroidUtils.dp2px;
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
public class CategorizedAdapter extends RecyclerView.Adapter<CategorizedAdapter.CategorizedViewHolder> implements IItemMovingListener {
public class CategorizedAdapter< T > extends RecyclerView.Adapter< CategorizedAdapter.CategorizedViewHolder > implements IItemMovingListener {
// Adapter item types
public static final int MOVING_ITEM = -0x1;
@@ -35,18 +33,20 @@ public class CategorizedAdapter extends RecyclerView.Adapter<CategorizedAdapter.
public static final int SELECTED_STATE = -0x1;
public static final int DISABLED_STATE = -0x2;
private final List mSelectedItems;
private final List mDisabledItems;
private final List mUnmovedItems;
// Data of items
private final List< T > mSelectedItems;
private final List< T > mDisabledItems;
private final List< T > mUnmovedItems;
private final IViewHolderBinder mBinder;
// Min and max counts
private int mMinSelectedItems = -1;
private int mMaxSelectedItems = -1;
public CategorizedAdapter(List selectedItems, List disabledItems, IViewHolderBinder binder) {
public CategorizedAdapter(List< T > selectedItems, List< T > disabledItems, IViewHolderBinder binder) {
this.mSelectedItems = selectedItems;
this.mDisabledItems = disabledItems;
this.mUnmovedItems = new ArrayList();
this.mUnmovedItems = new ArrayList<>();
this.mBinder = binder;
}
@@ -55,7 +55,7 @@ public class CategorizedAdapter extends RecyclerView.Adapter<CategorizedAdapter.
this.mMaxSelectedItems = max;
}
public void addUnmovedItem(Object item) {
public void addUnmovedItem(T item) {
mUnmovedItems.add(item);
}
@@ -68,31 +68,26 @@ public class CategorizedAdapter extends RecyclerView.Adapter<CategorizedAdapter.
}
public boolean isUnmovedItem(int index) {
if (getItemViewType(index) == MOVING_ITEM) {
Object curr;
if (getTabType(index) == SELECTED_STATE) {
curr = mSelectedItems.get(index - 1);
return mUnmovedItems.contains(curr);
} else {
curr = mDisabledItems.get(index - mSelectedItems.size() - 2);
return mUnmovedItems.contains(curr);
}
}
return false;
return getItemViewType(index) == MOVING_ITEM
&& mUnmovedItems.contains(
getTabType(index) == SELECTED_STATE
? mSelectedItems.get(index - 1)
: mDisabledItems.get(index - mSelectedItems.size() - 2));
}
@NonNull
@Override
public CategorizedViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
FrameLayout container = new FrameLayout(getGlobalContext());
container.addView(newCategoryTitle(), new FrameLayout.LayoutParams(-1, -2));
container.addView(newMovingItem(), new FrameLayout.LayoutParams(-1, -2));
container.addView(newCategoryTitle(), LayoutUtils.createFrame(-1, -2));
container.addView(newMovingItem(), LayoutUtils.createFrame(-1, -2));
container.setLayoutParams(LayoutUtils.createFrame(-1, -2));
return new CategorizedViewHolder(container);
}
private View newMovingItem() {
LinearLayout container = new LinearLayout(getGlobalContext());
container.setTag("container");
var container = new LinearLayout(getGlobalContext());
container.setId(R.id.container);
container.setGravity(Gravity.CENTER_VERTICAL);
container.setOrientation(LinearLayout.HORIZONTAL);
container.setPadding(
@@ -101,23 +96,23 @@ public class CategorizedAdapter extends RecyclerView.Adapter<CategorizedAdapter.
dp2px(12),
dp2px(12)
);
container.setLayoutParams(new LinearLayout.LayoutParams(-1, dp2px(48)));
container.setLayoutParams(LayoutUtils.createLinear(-1, dp2px(48)));
container.setVisibility(View.INVISIBLE);
ImageView icon = new ImageView(getGlobalContext());
icon.setTag("icon");
var icon = new ImageView(getGlobalContext());
icon.setId(R.id.icon);
icon.setImageTintList(ColorStateList.valueOf(ThemesUtils.getAccentColor()));
icon.setLayoutParams(new LinearLayout.LayoutParams(
dp2px(24),
dp2px(24)));
container.addView(icon);
TextView name = new TextView(getGlobalContext());
name.setTag("name");
var name = new TextView(getGlobalContext());
name.setId(R.id.name);
name.setTextSize(16.0f);
name.setTypeface(Typeface.DEFAULT_BOLD);
name.setTextColor(ThemesUtils.getTextAttr());
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(-1, -2);
var params = LayoutUtils.createLinear(-1, -2);
params.weight = 1;
params.leftMargin = dp2px(16);
container.addView(name, params);
@@ -126,13 +121,13 @@ public class CategorizedAdapter extends RecyclerView.Adapter<CategorizedAdapter.
}
private View newCategoryTitle() {
LinearLayout container = new LinearLayout(getGlobalContext());
container.setTag("category_title_container");
container.setLayoutParams(new LinearLayout.LayoutParams(-1, -2));
var container = new LinearLayout(getGlobalContext());
container.setId(R.id.title_container);
container.setLayoutParams(LayoutUtils.createLinear(-1, -2));
container.setVisibility(View.INVISIBLE);
TextView title = new TextView(getGlobalContext());
title.setTag("category_title");
var title = new TextView(getGlobalContext());
title.setId(R.id.title);
title.setTextSize(13.0f);
title.setPadding(
dp2px(16),
@@ -142,14 +137,14 @@ public class CategorizedAdapter extends RecyclerView.Adapter<CategorizedAdapter.
);
title.setAllCaps(true);
title.setTextColor(ThemesUtils.getTextAttr());
container.addView(title, new LinearLayout.LayoutParams(-2, -2));
container.addView(title, LayoutUtils.createLinear(-2, -2));
return container;
}
@Override
public void onBindViewHolder(@NonNull CategorizedViewHolder viewHolder, int i) {
if (getItemViewType(i) == MOVING_ITEM)
if(getItemViewType(i) == MOVING_ITEM)
mBinder.bind(viewHolder, i);
else
viewHolder.bindCategory(i == 0);
@@ -162,57 +157,49 @@ public class CategorizedAdapter extends RecyclerView.Adapter<CategorizedAdapter.
@Override
public void onItemDismiss(int index) {
if (getItemViewType(index) == MOVING_ITEM) {
Object curr;
if (getTabType(index) == SELECTED_STATE) {
curr = mSelectedItems.get(index - 1);
mSelectedItems.remove(curr);
mDisabledItems.add(0, curr);
notifyItemMoved(index, mSelectedItems.size() + 1);
if(getItemViewType(index) == MOVING_ITEM) {
int to;
if(getTabType(index) == SELECTED_STATE) {
mDisabledItems.add(0, mSelectedItems.remove(index - 1));
to = mSelectedItems.size() + 2;
} else {
curr = mDisabledItems.get(index - mSelectedItems.size() - 2);
mDisabledItems.remove(curr);
mSelectedItems.add(0, curr);
notifyItemRemoved(index);
notifyItemInserted(1);
mSelectedItems.add(0, mDisabledItems.remove(index - mSelectedItems.size() - 2));
to = 1;
}
notifyItemRemoved(index);
notifyItemInserted(to);
}
}
@Override
public boolean onItemMove(int fromPosition, int toPosition) {
if (toPosition == 0 || isUnmovedItem(toPosition))
if(toPosition == 0 || isUnmovedItem(toPosition))
return false;
Object curr;
if (getTabType(fromPosition) == SELECTED_STATE) {
var min = mSelectedItems.size() == mMinSelectedItems;
if (getTabType(toPosition) == DISABLED_STATE && min)
return false;
curr = mSelectedItems.get(fromPosition - 1);
if (getItemViewType(toPosition) == CATEGORY_TITLE) {
if (min)
switch(getTabType(fromPosition)) {
case SELECTED_STATE:
if(getTabType(toPosition) == DISABLED_STATE
&& mSelectedItems.size() == mMinSelectedItems)
return false;
mSelectedItems.remove(fromPosition - 1);
mDisabledItems.add(0, curr);
} else {
Collections.swap(mSelectedItems, fromPosition - 1, toPosition - 1);
}
} else if (getTabType(fromPosition) == DISABLED_STATE) {
var max = mSelectedItems.size() == mMaxSelectedItems;
if (getTabType(toPosition) == SELECTED_STATE && max)
return false;
curr = mDisabledItems.get(fromPosition - mSelectedItems.size() - 2);
if (getItemViewType(toPosition) == CATEGORY_TITLE) {
if (max)
if(getItemViewType(toPosition) == CATEGORY_TITLE)
mDisabledItems.add(0, mSelectedItems.remove(fromPosition - 1));
else
Collections.swap(mSelectedItems, fromPosition - 1, toPosition - 1);
break;
case DISABLED_STATE:
if(getTabType(toPosition) == SELECTED_STATE
&& mSelectedItems.size() == mMaxSelectedItems)
return false;
mDisabledItems.remove(0);
mSelectedItems.add(curr);
} else {
Collections.swap(mDisabledItems,
fromPosition - mSelectedItems.size() - 2,
toPosition - mSelectedItems.size() - 2);
}
if(getItemViewType(toPosition) == CATEGORY_TITLE)
mSelectedItems.add(mDisabledItems.remove(fromPosition - mSelectedItems.size() - 2));
else
Collections.swap(
mDisabledItems,
fromPosition - mSelectedItems.size() - 2,
toPosition - mSelectedItems.size() - 2
);
break;
}
notifyItemMoved(fromPosition, toPosition);
@@ -235,17 +222,17 @@ public class CategorizedAdapter extends RecyclerView.Adapter<CategorizedAdapter.
public CategorizedViewHolder(View itemView) {
super(itemView);
mMovingItemContainer = itemView.findViewWithTag("container");
mCategoryTitleContainer = itemView.findViewWithTag("category_title_container");
mMovingItemContainer = itemView.findViewById(R.id.container);
mCategoryTitleContainer = itemView.findViewById(R.id.title_container);
mIcon = mMovingItemContainer.findViewWithTag("icon");
mName = mMovingItemContainer.findViewWithTag("name");
mIcon = mMovingItemContainer.findViewById(R.id.icon);
mName = mMovingItemContainer.findViewById(R.id.name);
mCategoryTitle = mCategoryTitleContainer.findViewWithTag("category_title");
mCategoryTitle = mCategoryTitleContainer.findViewById(R.id.title);
}
public void bindMovingItem(int iconId, int textId) {
if (iconId != -1)
if(iconId != -1)
mIcon.setImageResource(iconId);
else
mIcon.setVisibility(View.GONE);
@@ -0,0 +1,81 @@
package ru.vtosters.lite.ui.adapters;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.vk.core.drawable.BorderDrawable;
import com.vk.core.util.Screen;
import com.vk.stories.view.StoryCircleImageView;
import java.util.List;
import ru.vtosters.lite.themes.items.VTLColor;
import ru.vtosters.lite.utils.AndroidUtils;
import ru.vtosters.lite.utils.ThemesUtils;
public class ColorPickerAdapter extends RecyclerView.Adapter<ColorPickerAdapter.ColorPickerViewHolder> {
private List<VTLColor> mColors;
private OnColorSelectListener mSelectListener;
public ColorPickerAdapter(List<VTLColor> colors, OnColorSelectListener selectListener) {
this.mColors = colors;
this.mSelectListener = selectListener;
}
@NonNull
@Override
public ColorPickerViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
var container = LayoutInflater.from(parent.getContext())
.inflate(AndroidUtils.getIdentifier("color_picker_item", "layout"), parent, false);
return new ColorPickerViewHolder(container);
}
@Override
public void onBindViewHolder(@NonNull ColorPickerViewHolder holder, int pos) {
holder.bind(mColors.get(pos));
}
@Override
public int getItemCount() {
return mColors.size();
}
public class ColorPickerViewHolder extends RecyclerView.ViewHolder {
private View mContainer;
private FrameLayout mColorPreviewBorder;
private StoryCircleImageView mColorPreview;
private TextView mColorName;
private TextView mColorValue;
public ColorPickerViewHolder(@NonNull View view) {
super(view);
mContainer = view;
mColorPreviewBorder = view.findViewById(AndroidUtils.getIdentifier("color_preview_border", "id"));
mColorPreview = view.findViewById(AndroidUtils.getIdentifier("color_preview", "id"));
mColorName = view.findViewById(AndroidUtils.getIdentifier("color_name", "id"));
mColorValue = view.findViewById(AndroidUtils.getIdentifier("color_value", "id"));
}
public void bind(VTLColor item) {
mContainer.setOnClickListener(v -> mSelectListener.onColorSelected(ColorPickerAdapter.this, item));
mColorPreviewBorder.setBackground(new BorderDrawable(ThemesUtils.isDarkTheme() ? Color.WHITE : Color.BLACK, Screen.c(24.0f), Screen.c(1.0f)));
mColorPreview.setPlaceholderColor(item.color);
mColorName.setText(item.resName);
mColorValue.setText("#" + Integer.toHexString(item.color).toUpperCase());
}
}
public interface OnColorSelectListener {
void onColorSelected(ColorPickerAdapter adapter, VTLColor vtlcolor);
}
}
@@ -1,39 +1,41 @@
package ru.vtosters.lite.ui.adapters;
import static ru.vtosters.lite.utils.ThemesUtils.getTextAttr;
import android.content.Context;
import android.util.TypedValue;
import android.graphics.ColorFilter;
import android.graphics.ColorMatrixColorFilter;
import android.graphics.PorterDuff;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.vk.core.widget.BubbleFluidLayout;
import com.vk.im.ui.components.viewcontrollers.msg_list.entry.MsgTextBuilder;
import com.vk.im.ui.views.msg.MsgPartTextView;
import com.vk.im.ui.views.msg.bubble.MsgBubbleDrawable;
import com.vk.im.ui.views.msg.bubble.MsgBubblePart;
import com.vk.im.ui.views.msg.bubble.MsgBubbleStyle;
import com.vk.im.ui.views.msg.bubble.MsgBubbleView;
import com.vtosters.lite.R;
import com.vtosters.lite.m0.ToolbarHelper;
import ru.vtosters.lite.utils.AndroidUtils;
import ru.vtosters.lite.utils.ThemesUtils;
public class MessagesPreviewAdapter extends RecyclerView.Adapter<MessagesPreviewAdapter.MessagePreviewViewHolder> {
private static final int ME = 0x0;
private static final int ANONYMOUS = -0x1;
private final String[] mMessages = AndroidUtils.getArray(R.array.wallpaper_change_dialog);
private final String[] mMessages;
private static int getColorFromAttribute(Context context, int attrId) {
TypedValue typedValue = new TypedValue();
context.getTheme().resolveAttribute(attrId, typedValue, true);
return typedValue.data;
public MessagesPreviewAdapter(String... messages) {
mMessages = messages;
}
@Override
public int getItemViewType(int i) {
return i % 2 == 0 ? ANONYMOUS : ME;
return i % 2 == 0 ? Gravity.START : Gravity.END;
}
@NonNull
@@ -41,7 +43,11 @@ public class MessagesPreviewAdapter extends RecyclerView.Adapter<MessagesPreview
public MessagePreviewViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int viewType) {
Context context = viewGroup.getContext();
var bubbleFluidLayout = (BubbleFluidLayout) LayoutInflater.from(context).inflate(R.layout.vkim_msg_list_item_msg_from_user, viewGroup, false);
final var inflater = LayoutInflater.from(context);
final var bubbleFluidLayout = (BubbleFluidLayout) inflater.inflate(R.layout.vkim_msg_list_item_msg_from_user, viewGroup, false);
bubbleFluidLayout.setPadding(0, AndroidUtils.dp2px(4), 0, 0);
bubbleFluidLayout.setGravity(viewType);
bubbleFluidLayout.findViewById(R.id.avatar).setVisibility(View.GONE);
bubbleFluidLayout.findViewById(R.id.avatar_space).setVisibility(View.GONE);
@@ -49,19 +55,23 @@ public class MessagesPreviewAdapter extends RecyclerView.Adapter<MessagesPreview
bubbleFluidLayout.findViewById(R.id.status).setVisibility(View.GONE);
bubbleFluidLayout.findViewById(R.id.status_space).setVisibility(View.GONE);
var messageBubbleView = (MsgBubbleView) bubbleFluidLayout.findViewById(R.id.bubble);
messageBubbleView.setContentPaddingLeft(AndroidUtils.dp2px(5));
messageBubbleView.setContentPaddingTop(AndroidUtils.dp2px(5));
messageBubbleView.setContentPaddingRight(AndroidUtils.dp2px(5));
messageBubbleView.setContentPaddingBottom(AndroidUtils.dp2px(5));
bubbleFluidLayout.setGravity(viewType == ME ? Gravity.RIGHT : Gravity.LEFT);
final var messageBubbleView = (MsgBubbleView) bubbleFluidLayout.findViewById(R.id.bubble);
messageBubbleView.setContentPaddingLeft(AndroidUtils.dp2px(10));
messageBubbleView.setContentPaddingTop(AndroidUtils.dp2px(4));
messageBubbleView.setContentPaddingRight(AndroidUtils.dp2px(4));
messageBubbleView.setContentPaddingBottom(AndroidUtils.dp2px(0));
if (viewType == Gravity.END) {
messageBubbleView.a(MsgBubbleStyle.b(false, false), MsgBubblePart.FULL, ThemesUtils.isDarkTheme() ? ThemesUtils.getColorFromAttr(R.attr.im_bubble_outgoing) : ThemesUtils.lighten(ThemesUtils.getAccentColor(), 0.76f));
} else {
messageBubbleView.a(MsgBubbleStyle.b(false, false), MsgBubblePart.FULL, ThemesUtils.getColorFromAttr(R.attr.im_bubble_incoming));
}
bubbleFluidLayout.setLayoutDirection(viewType);
var message = new TextView(context);
message.setTag("message");
message.setGravity(Gravity.LEFT);
message.setTextColor(getTextAttr());
final var msgTextView = inflater.inflate(R.layout.vkim_msg_part_text, viewGroup, false);
msgTextView.setId(R.id.msg_text);
messageBubbleView.setContentView(message);
final var msgBubbleView = (MsgBubbleView) bubbleFluidLayout.findViewById(R.id.bubble);
msgBubbleView.setContentView(msgTextView);
return new MessagePreviewViewHolder(bubbleFluidLayout);
}
@@ -77,17 +87,17 @@ public class MessagesPreviewAdapter extends RecyclerView.Adapter<MessagesPreview
}
protected static class MessagePreviewViewHolder extends RecyclerView.ViewHolder {
private final TextView mMessage;
private final MsgPartTextView mMsgTextView;
public MessagePreviewViewHolder(@NonNull View view) {
super(view);
mMessage = view.findViewWithTag("message");
mMsgTextView = view.findViewById(R.id.msg_text);
}
public void bind(String text) {
mMessage.setText(text);
mMsgTextView.setText(new MsgTextBuilder().a(text));
mMsgTextView.setTimeText("12:00");
}
}
}
@@ -1,11 +1,5 @@
package ru.vtosters.lite.ui.adapters;
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
import static ru.vtosters.lite.utils.AndroidUtils.getResources;
import static ru.vtosters.lite.utils.ThemesUtils.getSTextAttr;
import static ru.vtosters.lite.utils.ThemesUtils.getTextAttr;
import static ru.vtosters.lite.utils.ThemesUtils.recolorDrawable;
import android.annotation.SuppressLint;
import android.net.Uri;
import android.view.LayoutInflater;
@@ -14,19 +8,32 @@ import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.appcompat.widget.SwitchCompat;
import androidx.recyclerview.widget.RecyclerView;
import com.aefyr.tsg.g2.TelegramStickersPack;
import com.aefyr.tsg.g2.TelegramStickersService;
import com.vk.core.dialogs.bottomsheet.ContentSnapStrategy1;
import com.vk.core.dialogs.bottomsheet.ModalBottomSheet;
import com.vk.core.util.ContextExtKt;
import com.vk.core.util.DrawableUtils;
import com.vk.sharing.Sharing;
import com.vk.stickers.LongtapRecyclerView;
import com.vk.stickers.bridge.GiftData;
import com.vk.stickers.details.StickerDetailsAdapter;
import com.vk.stickers.details.StickerDetailsView;
import com.vtosters.lite.R;
import org.json.JSONException;
import ru.vtosters.lite.tgs.TGPref;
import ru.vtosters.lite.tgs.TGRoot;
import ru.vtosters.lite.ui.components.IItemMovingListener;
import java.io.File;
import java.util.ArrayList;
import ru.vtosters.lite.tgs.TGPref;
import ru.vtosters.lite.ui.components.IItemMovingListener;
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
import static ru.vtosters.lite.utils.AndroidUtils.getResources;
import static ru.vtosters.lite.utils.ThemesUtils.*;
public class StickerPackAdapter extends RecyclerView.Adapter<StickerPackAdapter.StickerPackViewHolder> implements IItemMovingListener {
private static final TelegramStickersService sService = TelegramStickersService.getInstance(getGlobalContext());
@@ -95,12 +102,12 @@ public class StickerPackAdapter extends RecyclerView.Adapter<StickerPackAdapter.
super(view);
mContainer = (LinearLayout) view;
mSwitch = view.findViewWithTag("choose_btn");
mStickerPreview = view.findViewWithTag("photo");
mUpdateButton = view.findViewWithTag("button_update");
mDeleteButton = view.findViewWithTag("action_delete");
mName = view.findViewWithTag("vkim_cancel");
mStickersCount = view.findViewWithTag("vkim_cancel_label_text");
mSwitch = view.findViewById(R.id.choose_btn);
mStickerPreview = view.findViewById(R.id.photo);
mUpdateButton = view.findViewById(R.id.button_update);
mDeleteButton = view.findViewById(R.id.action_delete);
mName = view.findViewById(R.id.vkim_cancel);
mStickersCount = view.findViewById(R.id.vkim_cancel_label_text);
}
@SuppressLint("SetTextI18n")
@@ -108,10 +115,11 @@ public class StickerPackAdapter extends RecyclerView.Adapter<StickerPackAdapter.
final TelegramStickersPack pack = sService.getPacksListReference().get(position);
if (pack.state != TelegramStickersPack.DOWNLOADED) return;
File f = new File(pack.folder, "001.png");
var uri = Uri.parse("file://" + f.getAbsolutePath());
try {
File f = new File(pack.folder, "001.png");
if (f.exists()) {
mStickerPreview.setImageURI(Uri.parse("file://" + f.getAbsolutePath()));
mStickerPreview.setImageURI(uri);
}
} catch (Exception e) {
e.printStackTrace();
@@ -129,7 +137,7 @@ public class StickerPackAdapter extends RecyclerView.Adapter<StickerPackAdapter.
});
mName.setText(pack.title);
mSwitch.setChecked(pack.enabled);
mSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> sService.setPackEnabled(pack, isChecked, false));
mSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> sService.setPackEnabled(pack, isChecked, true));
mStickersCount.setText(pack.stickersCount + " " + mStickersCount.getContext().getString(R.string.stickerscount));
// Color костыль
@@ -138,6 +146,35 @@ public class StickerPackAdapter extends RecyclerView.Adapter<StickerPackAdapter.
mName.setTextColor(color);
mStickersCount.setTextColor(secondary);
if (pack.state == TelegramStickersPack.DOWNLOADED)
mContainer.setOnClickListener(v -> {
try {
ViewGroup root = (ViewGroup) ContextExtKt.c(v.getContext()).inflate(R.layout.sticker_details_bottom_container, null);
StickerDetailsView stickersDetailsView = new StickerDetailsView(v.getContext());
stickersDetailsView.setLayoutParams(new ViewGroup.LayoutParams(-1, -1));
stickersDetailsView.a(TGRoot.toStickerPack(pack), new GiftData(new ArrayList<>(), false), root);
var recycler = (LongtapRecyclerView) stickersDetailsView.findViewById(R.id.recycler);
((StickerDetailsAdapter) recycler.getAdapter()).setTelegramPack(true);
var builder = new ModalBottomSheet.a(v.getContext());
builder.d(pack.title);
builder.d(stickersDetailsView);
builder.a(DrawableUtils.a(v.getContext(), R.drawable.share_outline_28, R.color.accent_blue));
builder.c(R.attr.content_tint_background);
builder.b(view -> {
Sharing.a(view.getContext(), "https://t.me/addstickers/" + pack.id);
return null;
});
builder.a(new ContentSnapStrategy1(false));
builder.a("stickers_preview");
} catch (JSONException e) {
e.printStackTrace();
}
});
}
}
}
@@ -21,6 +21,7 @@ import java.io.StringWriter;
import ru.vtosters.lite.deviceinfo.DeviceInfoCollector;
import ru.vtosters.lite.services.LogWriterService;
import ru.vtosters.lite.utils.AndroidUtils;
public class CrashReporter {
protected static String logString;
@@ -41,7 +42,7 @@ public class CrashReporter {
logString = getStackTrace(th) + "\n\n" + new DeviceInfoCollector().collect().toDeviceName();
if (Build.VERSION.SDK_INT >= 26) {
var notificationChannel = new NotificationChannel("crashes", "crash", NotificationManager.IMPORTANCE_DEFAULT);
var notificationChannel = new NotificationChannel("crashes", AndroidUtils.getString("crash_service_name"), NotificationManager.IMPORTANCE_DEFAULT);
notificationChannel.enableVibration(true);
notificationChannel.enableLights(true);
((NotificationManager) getGlobalContext().getSystemService(Context.NOTIFICATION_SERVICE)).createNotificationChannel(notificationChannel);
@@ -51,7 +52,7 @@ public class CrashReporter {
foxbinIntent.putExtra("android.intent.extra.TEXT", logString);
foxbinIntent.setType("text/plain");
if (!isFoxbinInstalled()) {
foxbinIntent = new Intent("android.intent.action.VIEW");
foxbinIntent = new Intent(Intent.ACTION_VIEW);
foxbinIntent.setData(Uri.parse("https://play.google.com/store/apps/details?id=com.f0x1d.dogbin"));
foxbinIntent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION);
}
@@ -1,15 +1,5 @@
package ru.vtosters.lite.ui.components;
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
import static ru.vtosters.lite.utils.AndroidUtils.getPreferences;
import static ru.vtosters.lite.utils.Preferences.milkshake;
import static ru.vtosters.lite.utils.Preferences.superapp;
import static ru.vtosters.lite.utils.Preferences.useNewSettings;
import static ru.vtosters.lite.utils.Preferences.vkme;
import static ru.vtosters.lite.utils.Preferences.vkme_notifs;
import android.os.Build;
import com.vk.apps.AppsFragment;
import com.vk.discover.DiscoverFragment;
import com.vk.fave.fragments.FaveTabFragment;
@@ -34,22 +24,31 @@ import com.vtosters.lite.fragments.t2.c.DialogsFragment;
import com.vtosters.lite.fragments.y2.VideoCatalogFragment;
import com.vtosters.lite.general.fragments.GamesFragment;
import com.vtosters.lite.general.fragments.PhotosFragment;
import ru.vtosters.lite.ui.items.DockBarTab;
import ru.vtosters.lite.utils.AndroidUtils;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import ru.vtosters.lite.ui.items.DockBarTab;
import ru.vtosters.lite.utils.AndroidUtils;
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
import static ru.vtosters.lite.utils.AndroidUtils.getPreferences;
import static ru.vtosters.lite.utils.Preferences.*;
public class DockBarEditorManager {
public static final int MIN_SELECTED_TABS = 3;
public static final int MAX_SELECTED_TABS = 9;
private static final List< String > ALL_TAGS = Arrays.asList(
"tab_news", "tab_superapps", "tab_messages", "tab_feedback", "tab_profile",
"tab_friends", "tab_groups", "tab_photos", "tab_audios", "tab_videos",
"tab_lives", "tab_games", "tab_liked", "tab_fave", "tab_documents",
"tab_payments", "tab_vk_apps", "tab_settings");
private static DockBarEditorManager sInstance;
private final List<DockBarTab> mSelectedTabs = new ArrayList<>();
private final List<DockBarTab> mDisabledTabs = new ArrayList<>();
private final List< DockBarTab > mSelectedTabs = new ArrayList<>();
private final List< DockBarTab > mDisabledTabs = new ArrayList<>();
public DockBarEditorManager() {
init();
@@ -62,10 +61,10 @@ public class DockBarEditorManager {
}
private void init() {
if (vkme()) {
if(vkme()) {
mSelectedTabs.add(getTabByTag("tab_settings"));
if (vkme_notifs()) {
if (milkshake()) {
if(vkme_notifs()) {
if(milkshake()) {
mSelectedTabs.add(getTabByTag("tab_feedback"));
} else {
mSelectedTabs.add(getTabByTag("tab_friends"));
@@ -78,44 +77,36 @@ public class DockBarEditorManager {
checkOldConfig();
String[] selectedTabsTags = getPreferences().getString("dockbar_tabs", "tab_news,tab_superapps,tab_messages,tab_friends,tab_profile")
var selectedTabsTags = getPreferences()
.getString("dockbar_tabs",
"tab_news,tab_superapps,tab_messages,tab_friends,tab_profile")
.split(",");
parseSelectedTabs(selectedTabsTags);
}
private void checkOldConfig() {
File config = new File(getGlobalContext().getFilesDir(), "dockbar.json");
if (config.exists()) config.deleteOnExit();
if(config.exists()) config.deleteOnExit();
}
private void parseSelectedTabs(String[] selectedTabsTags) {
List<String> allTags = new ArrayList<>(Arrays.asList("tab_news", "tab_superapps", "tab_messages", "tab_feedback", "tab_profile",
"tab_friends", "tab_groups", "tab_photos", "tab_audios", "tab_videos", "tab_lives", "tab_games", "tab_liked",
"tab_fave", "tab_documents", "tab_payments", "tab_vk_apps", "tab_settings"));
var allTags = new ArrayList<>(ALL_TAGS);
for (String tag : selectedTabsTags) {
for(String tag : selectedTabsTags) {
mSelectedTabs.add(getTabByTag(tag));
allTags.remove(tag);
}
for (String tag : allTags) {
for(String tag : allTags) {
mDisabledTabs.add(getTabByTag(tag));
}
}
public void save() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
getPreferences().edit().putString("dockbar_tabs", mSelectedTabs.stream()
.map(tab -> tab.tag)
.collect(Collectors.joining(",")))
.commit();
} else {
StringBuilder sb = new StringBuilder();
for (DockBarTab tab : mSelectedTabs) {
sb.append(tab.tag).append(",");
}
getPreferences().edit().putString("dockbar_tabs", sb.toString()).commit();
}
var sb = new StringBuilder();
for(DockBarTab tab : mSelectedTabs)
sb.append(tab.tag).append(",");
getPreferences().edit().putString("dockbar_tabs", sb.toString()).commit();
}
public void reset() {
@@ -125,16 +116,16 @@ public class DockBarEditorManager {
.commit();
}
public List<DockBarTab> getSelectedTabs() {
public List< DockBarTab > getSelectedTabs() {
return mSelectedTabs;
}
public List<DockBarTab> getDisabledTabs() {
public List< DockBarTab > getDisabledTabs() {
return mDisabledTabs;
}
private DockBarTab getTabByTag(String tag) {
switch (tag) {
switch(tag) {
case "tab_news":
return DockBarTab.valuesOf(
"tab_news",
@@ -1,15 +1,10 @@
package ru.vtosters.lite.ui.components;
import static ru.vtosters.lite.utils.AndroidUtils.edit;
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
import static ru.vtosters.lite.utils.AndroidUtils.getPackageName;
import static ru.vtosters.lite.utils.AndroidUtils.getPreferences;
import static ru.vtosters.lite.utils.Preferences.hasVerification;
import static ru.vtosters.lite.utils.Preferences.isValidSignature;
import android.content.ComponentName;
import android.content.pm.PackageManager;
import android.util.Log;
import ru.vtosters.lite.utils.AndroidUtils;
import ru.vtosters.lite.utils.Preferences;
import java.util.Arrays;
import java.util.List;
@@ -44,11 +39,11 @@ public class IconManager {
);
public static List<String> icons() {
return hasVerification() && isValidSignature() ? sIconsPlusNames : sIconsNames; // delete later sdk check
return Preferences.hasVerification() && Preferences.isValidSignature() ? sIconsPlusNames : sIconsNames; // delete later sdk check
}
public static List<String> iconsValues() {
return hasVerification() && isValidSignature() ? sIconsPlus : sIcons; // delete later sdk check
return Preferences.hasVerification() && Preferences.isValidSignature() ? sIconsPlus : sIcons; // delete later sdk check
}
public static void switchComponent(String icon, String appName, String oldIcon, String oldAppName) {
@@ -64,7 +59,7 @@ public class IconManager {
Log.d("IconManager", "iconSwitcher: icon = " + icon + ", appname = " + appName);
List<String> iconsList = (hasVerification() && isValidSignature()) ? sIconsPlus : sIcons;
List<String> iconsList = (Preferences.hasVerification() && Preferences.isValidSignature()) ? sIconsPlus : sIcons;
List<String> labelsList = sLabels;
if (oldIcon != null && oldAppName != null) {
@@ -82,10 +77,15 @@ public class IconManager {
// get labels index
labelIndex = labelsList.indexOf(appName);
String currentState = getPreferences().getString("components_enabled", "11");
String currentState = "11";
if (oldIconIndex != -1 && oldLabelIndex != -1) {
currentState = oldIconIndex + "" + oldLabelIndex;
main: for (int i = 0; i < iconsList.size(); i++) {
for (int o = 0; o < labelsList.size(); o++) {
if (isComponentEnabled("id" + i + "" + o)) {
currentState = i + "" + o;
break main;
}
}
}
String newState = iconIndex + "" + labelIndex;
@@ -96,17 +96,19 @@ public class IconManager {
// disable current component to prevent conflict with custom value
switchIcon("id" + currentState, false);
// save custom value
edit().putString("components_enabled", newState).commit();
// enable custom value
switchIcon("id" + newState, true);
}
// Component switcher for changing app icon
public static void switchIcon(String componentName, Boolean enabled) {
getGlobalContext().getPackageManager().setComponentEnabledSetting(
new ComponentName(getPackageName(), getPackageName() + "." + componentName),
AndroidUtils.getGlobalContext().getPackageManager().setComponentEnabledSetting(
new ComponentName(AndroidUtils.getPackageName(), AndroidUtils.getPackageName() + "." + componentName),
enabled ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED : PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
PackageManager.DONT_KILL_APP);
}
public static boolean isComponentEnabled(String componentName) {
return AndroidUtils.getGlobalContext().getPackageManager().getComponentEnabledSetting(new ComponentName(AndroidUtils.getPackageName(), AndroidUtils.getPackageName() + "." + componentName)) == PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
}
}
@@ -8,9 +8,9 @@ import ru.vtosters.lite.ui.adapters.CategorizedAdapter;
public class ItemMovingCallback extends ItemTouchHelper.Callback {
private final CategorizedAdapter mAdapter;
private final CategorizedAdapter<?> mAdapter;
public ItemMovingCallback(CategorizedAdapter adapter) {
public ItemMovingCallback(CategorizedAdapter<?> adapter) {
this.mAdapter = adapter;
}
@@ -50,7 +50,7 @@ public class NewsfeedListManager {
sendToast(activity.getString(R.string.newsfeed_list_update_feed_to_work));
}
)
));
), "newsfeed_items_editor");
}
public static void resetHideItems() {
@@ -1,18 +1,16 @@
package ru.vtosters.lite.ui.components;
import static ru.vtosters.lite.utils.AndroidUtils.getPreferences;
import android.os.Build;
import com.vtosters.lite.R;
import ru.vtosters.lite.ui.items.SuperAppItem;
import ru.vtosters.lite.utils.AndroidUtils;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import ru.vtosters.lite.ui.items.SuperAppItem;
import ru.vtosters.lite.utils.AndroidUtils;
import static ru.vtosters.lite.utils.AndroidUtils.getPreferences;
public class SuperAppEditorManager {
@@ -43,13 +41,9 @@ public class SuperAppEditorManager {
mSelectedItems.add(getItemByTag(tag));
allTags.remove(tag);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
allTags.forEach(tag -> mDisabledItems.add(getItemByTag(tag)));
} else {
for (String tag : allTags) {
mDisabledItems.add(getItemByTag(tag));
}
}
for (String tag : allTags)
mDisabledItems.add(getItemByTag(tag));
}
public void save() {
@@ -2,18 +2,25 @@ package ru.vtosters.lite.ui.dialogs;
import android.app.Activity;
import android.graphics.Typeface;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.vtosters.lite.R;
import ru.vtosters.lite.downloaders.OTADownloader;
import ru.vtosters.lite.ui.vkui.ModalBottomSheetWrapper;
import ru.vtosters.lite.utils.AndroidUtils;
import ru.vtosters.lite.utils.OTAUtils;
import ru.vtosters.lite.utils.ThemesUtils;
public class OTADialog implements OTAUtils.OTAListener {
public class OTADialog extends ModalBottomSheetWrapper<OTADialog> implements OTAUtils.OTAListener {
private final Activity mActivity;
private final OTAUtils mHelper;
public OTADialog(Activity activity) {
super(activity);
mActivity = activity;
mHelper = new OTAUtils(this);
@@ -28,20 +35,32 @@ public class OTADialog implements OTAUtils.OTAListener {
public void onUpdateApplied() {
mActivity.runOnUiThread(() -> {
// Toast.makeText(mActivity, "Обновления найдены", Toast.LENGTH_SHORT).show();
new ModalBottomSheetWrapper(mActivity)
.setTitle(mActivity.getString(R.string.newversion) + " " + mHelper.getNewVersionName())
.setUpdateInfoView(mHelper.getUpdateDescription())
.setPositiveButton(mActivity.getString(R.string.updateanddownload), () -> {
OTADownloader.downloadBuild(mHelper.getDownloadUrl(), mHelper.getCommitSHA());
})
.show();
setTitle(mActivity.getString(R.string.newversion) + " " + mHelper.getNewVersionName())
.setView(makeUpdateInfoView(mHelper.getUpdateDescription()))
.setPositiveButton(mActivity.getString(R.string.updateanddownload), () -> {
OTADownloader.downloadBuild(mHelper.getDownloadUrl(), mHelper.getCommitSHA());
})
.show("ota");
});
}
private View makeUpdateInfoView(String changelog) {
var container = new LinearLayout(mActivity);
var changelogView = new TextView(mActivity);
container.setOrientation(LinearLayout.VERTICAL);
changelogView.setText(AndroidUtils.getString("changelog") + ": \n" + changelog);
changelogView.setTextColor(ThemesUtils.getTextAttr());
container.addView(changelogView, new LinearLayout.LayoutParams(-1, -2));
return container;
}
@Override
public void onUpdateCanceled() {
mActivity.runOnUiThread(() -> {
// Toast.makeText(mActivity, "Обновлений не найдено", Toast.LENGTH_SHORT).show();
});
// mActivity.runOnUiThread(() -> {
// // Toast.makeText(mActivity, "Обновлений не найдено", Toast.LENGTH_SHORT).show();
// });
}
}
@@ -0,0 +1,22 @@
package ru.vtosters.lite.ui.dialogs;
import android.app.Activity;
import ru.vtosters.lite.themes.items.VTLPalette;
import ru.vtosters.lite.ui.adapters.ColorPickerAdapter;
public class PalettesBottomSheetDialog {
private static final String TAG = "palettes_copy_color";
public static void create(Activity activity, VTLPalette palette, ColorPickerAdapter.OnColorSelectListener action) {
var instance = new VTColorPickerBottomSheetDialog(activity);
var colorPickerAdapter = new ColorPickerAdapter(palette.colors, (adapter, vtlcolor) -> {
action.onColorSelected(adapter, vtlcolor);
instance.dismiss();
});
instance.setTitle(palette.name)
.setAdapter(colorPickerAdapter, true)
.show(TAG, true);
}
}
@@ -1,19 +1,17 @@
package ru.vtosters.lite.ui.dialogs;
import static ru.vtosters.lite.utils.AndroidUtils.edit;
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import com.vk.core.dialogs.alert.VkAlertDialog;
import com.vtosters.lite.R;
import ru.vtosters.lite.deviceinfo.OEMDetector;
import ru.vtosters.lite.utils.AndroidUtils;
import static ru.vtosters.lite.utils.AndroidUtils.edit;
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
public class Start {
public static void alert(final Activity activity) {
if (Build.VERSION.SDK_INT >= 23) {
@@ -30,7 +28,7 @@ public class Start {
.setNeutralButton(R.string.startbtn1,
(dialogInterface, i) -> {
edit().putBoolean("showAlert", false).apply();
activity.startActivity(new Intent("android.intent.action.VIEW").setData(Uri.parse("https://t.me/vtosters")));
activity.startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse("https://t.me/vtosters")));
}
)
.show();
@@ -0,0 +1,41 @@
package ru.vtosters.lite.ui.dialogs;
import android.app.Activity;
import android.widget.LinearLayout;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import ru.vtosters.lite.ui.adapters.ColorPickerAdapter;
import ru.vtosters.lite.ui.vkui.ModalBottomSheetWrapper;
import ru.vtosters.lite.utils.LayoutUtils;
public class VTColorPickerBottomSheetDialog extends ModalBottomSheetWrapper<VTColorPickerBottomSheetDialog> {
private Activity mActivity;
private LinearLayout mContainer;
public VTColorPickerBottomSheetDialog(Activity activity) {
super(activity);
this.mActivity = activity;
mContainer = new LinearLayout(mActivity);
mContainer.setLayoutParams(LayoutUtils.createLinear(-1, -1));
mContainer.setOrientation(LinearLayout.VERTICAL);
}
public VTColorPickerBottomSheetDialog setAdapter(ColorPickerAdapter adapter, boolean searchMode) {
var recyclerView = new RecyclerView(mActivity);
recyclerView.setAdapter(adapter);
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new LinearLayoutManager(mActivity));
var recyclerViewParams = LayoutUtils.createLinear(-1, -1);
mContainer.addView(recyclerView, recyclerViewParams);
mBuilder.a(mContainer);
return setView(mContainer);
}
public LinearLayout getContainer() {
return mContainer;
}
}
@@ -25,7 +25,7 @@ public abstract class BaseToolbarFragment extends FragmentImpl {
private Toolbar mToolbar;
private FrameLayout mContentLayout;
@CallSuper
protected void onCreateMenu(Menu menu) {
if (menu.size() > 0)
for (int i = 0; i < menu.size(); i++)
@@ -63,6 +63,10 @@ public abstract class BaseToolbarFragment extends FragmentImpl {
return mRootView;
}
public Toolbar getToolbar() {
return mToolbar;
}
public abstract View onCreateContent(@NonNull LayoutInflater inflater, @Nullable Bundle bundle);
private void initToolbar() {
@@ -21,9 +21,11 @@ import androidx.recyclerview.widget.RecyclerView;
import com.vtosters.lite.R;
import ru.vtosters.lite.themes.hooks.TextViewHook;
import ru.vtosters.lite.ui.adapters.CategorizedAdapter;
import ru.vtosters.lite.ui.components.DockBarEditorManager;
import ru.vtosters.lite.ui.components.ItemMovingCallback;
import ru.vtosters.lite.utils.LayoutUtils;
public class DockBarEditorFragment extends BaseToolbarFragment {
@@ -32,48 +34,53 @@ public class DockBarEditorFragment extends BaseToolbarFragment {
public View onCreateContent(@NonNull LayoutInflater inflater, @Nullable Bundle bundle) {
setTitle(R.string.dockbar_editor);
FrameLayout content = new FrameLayout(getContext());
var content = new FrameLayout(getContext());
LinearLayout container = new LinearLayout(getContext());
var container = new LinearLayout(getContext());
container.setOrientation(LinearLayout.VERTICAL);
content.addView(container, new FrameLayout.LayoutParams(-1, -1));
content.addView(container, LayoutUtils.createFrame(-1, -1));
LinearLayout buttonsContainer = new LinearLayout(getContext());
var buttonsContainer = new LinearLayout(getContext());
buttonsContainer.setPadding(
dp2px(13),
dp2px(10),
dp2px(13),
dp2px(10)
);
container.addView(buttonsContainer, new LinearLayout.LayoutParams(-1, -2));
container.addView(buttonsContainer, LayoutUtils.createLinear(-1, -2));
TextView save = new TextView(new ContextThemeWrapper(getContext(), R.style.VKUIButton_Primary));
var manager = DockBarEditorManager.getInstance();
var save = new TextView(new ContextThemeWrapper(getContext(), R.style.VKUIButton_Primary));
save.setText(requireContext().getString(R.string.save));
save.setOnClickListener(v -> {
DockBarEditorManager.getInstance().save();
manager.save();
restartApplication();
});
LinearLayout.LayoutParams saveParams = new LinearLayout.LayoutParams(0, -2);
new TextViewHook().inject(save, 0, false);
var saveParams = LayoutUtils.createLinear(0, -2);
saveParams.weight = 1.0f;
buttonsContainer.addView(save, saveParams);
View divider = new View(getContext());
buttonsContainer.addView(divider, new LinearLayout.LayoutParams(dp2px(10), 0));
var divider = new View(getContext());
buttonsContainer.addView(divider, LayoutUtils.createLinear(dp2px(10), 0));
TextView reset = new TextView(new ContextThemeWrapper(getContext(), R.style.VKUIButton_Primary));
var reset = new TextView(new ContextThemeWrapper(getContext(), R.style.VKUIButton_Primary));
reset.setText(requireContext().getString(R.string.reset));
reset.setOnClickListener(v -> {
DockBarEditorManager.getInstance().reset();
restartApplication();
});
LinearLayout.LayoutParams resetParams = new LinearLayout.LayoutParams(0, -2);
new TextViewHook().inject(reset, 0, false);
var resetParams = LayoutUtils.createLinear(0, -2);
resetParams.weight = 1.0f;
buttonsContainer.addView(reset, resetParams);
DockBarEditorManager manager = DockBarEditorManager.getInstance();
var adapter = new CategorizedAdapter(manager.getSelectedTabs(), manager.getDisabledTabs(), (holder, pos) -> {
var adapter = new CategorizedAdapter<>(manager.getSelectedTabs(), manager.getDisabledTabs(), (holder, pos) -> {
var tab = pos <= manager.getSelectedTabs().size()
? manager.getSelectedTabs().get(pos - 1)
: manager.getDisabledTabs().get(pos - manager.getSelectedTabs().size() - 2);
@@ -85,7 +92,7 @@ public class DockBarEditorFragment extends BaseToolbarFragment {
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
recyclerView.setAdapter(adapter);
recyclerView.setHasFixedSize(true);
var params = new LinearLayout.LayoutParams(-1, -1);
var params = LayoutUtils.createLinear(-1, -1);
params.gravity = Gravity.CENTER;
container.addView(recyclerView, params);
@@ -70,14 +70,18 @@ public class FeedFragment extends MaterialPreferenceToolbarFragment {
NewsfeedListManager.callEditorPopup(getActivity());
return true;
});
var str = getDefaultPrefs().getString("news_feed_selected_items", "");
findPreference("newsfeedlistmanager").setSummary(
String.format(requireContext().getString(R.string.feed_hidden), (!TextUtils.isEmpty(str) ? str.split(",").length : 0))
);
findPreference("newsfeedlistmanager_reset").setOnPreferenceClickListener(preference -> {
NewsfeedListManager.resetHideItems();
return true;
});
findPreference("feedcache").setVisible(!getPrefsValue("newsupdate").equals("no_update"));
}
private String count(String text) {
@@ -1,22 +1,5 @@
package ru.vtosters.lite.ui.fragments;
import static ru.vtosters.lite.ui.PreferencesUtil.addPreference;
import static ru.vtosters.lite.ui.PreferencesUtil.addPreferenceCategory;
import static ru.vtosters.lite.ui.PreferencesUtil.addPreferenceDrawable;
import static ru.vtosters.lite.ui.components.IconManager.icons;
import static ru.vtosters.lite.ui.components.IconManager.iconsValues;
import static ru.vtosters.lite.ui.components.IconManager.sIconsPlus;
import static ru.vtosters.lite.ui.components.IconManager.sIconsPlusNames;
import static ru.vtosters.lite.ui.components.IconManager.switchComponent;
import static ru.vtosters.lite.utils.AndroidUtils.dp2px;
import static ru.vtosters.lite.utils.AndroidUtils.edit;
import static ru.vtosters.lite.utils.AndroidUtils.getIdentifier;
import static ru.vtosters.lite.utils.AndroidUtils.sendToast;
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
import static ru.vtosters.lite.utils.Preferences.hasVerification;
import static ru.vtosters.lite.utils.Preferences.preferences;
import static ru.vtosters.lite.utils.ThemesUtils.getTextAttr;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
@@ -26,44 +9,47 @@ import android.os.Bundle;
import android.util.TypedValue;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import androidx.appcompat.view.ContextThemeWrapper;
import androidx.core.content.res.ResourcesCompat;
import com.vk.core.dialogs.alert.VkAlertDialog;
import com.vtosters.lite.R;
import com.vtosters.lite.general.fragments.MaterialPreferenceToolbarFragment;
import ru.vtosters.lite.ui.PreferenceFragmentUtils;
import ru.vtosters.lite.ui.components.IconManager;
import ru.vtosters.lite.utils.AndroidUtils;
import ru.vtosters.lite.utils.Preferences;
import ru.vtosters.lite.utils.ThemesUtils;
public class IconsFragment extends MaterialPreferenceToolbarFragment {
@SuppressLint("SetTextI18n")
public static void callSelectDialog(Context ctx, String appicon) {
var defname = preferences.getString("appname", "vt");
var deficon = preferences.getString("selectedicon", "vt");
var defname = Preferences.preferences.getString("appname", "vt");
var deficon = Preferences.preferences.getString("selectedicon", "vt");
RadioGroup rg = new RadioGroup(ctx);
RadioButton rgDefault = new RadioButton(new ContextThemeWrapper(ctx, com.vtosters.lite.R.style.Widget_AppCompat_CompoundButton_RadioButton));
RadioButton rgVK = new RadioButton(new ContextThemeWrapper(ctx, com.vtosters.lite.R.style.Widget_AppCompat_CompoundButton_RadioButton));
RadioButton rgVKontakte = new RadioButton(new ContextThemeWrapper(ctx, com.vtosters.lite.R.style.Widget_AppCompat_CompoundButton_RadioButton));
RadioButton rgDefault = new RadioButton(new ContextThemeWrapper(ctx, R.style.Widget_AppCompat_CompoundButton_RadioButton));
RadioButton rgVK = new RadioButton(new ContextThemeWrapper(ctx, R.style.Widget_AppCompat_CompoundButton_RadioButton));
RadioButton rgVKontakte = new RadioButton(new ContextThemeWrapper(ctx, R.style.Widget_AppCompat_CompoundButton_RadioButton));
rg.addView(rgDefault);
rg.addView(rgVK);
rg.addView(rgVKontakte);
rgDefault.setTextSize(TypedValue.COMPLEX_UNIT_PX, dp2px(14f));
rgVK.setTextSize(TypedValue.COMPLEX_UNIT_PX, dp2px(14f));
rgVKontakte.setTextSize(TypedValue.COMPLEX_UNIT_PX, dp2px(14f));
rgDefault.setTextSize(TypedValue.COMPLEX_UNIT_PX, AndroidUtils.dp2px(14f));
rgVK.setTextSize(TypedValue.COMPLEX_UNIT_PX, AndroidUtils.dp2px(14f));
rgVKontakte.setTextSize(TypedValue.COMPLEX_UNIT_PX, AndroidUtils.dp2px(14f));
rg.setPadding(dp2px(18f), dp2px(12f), dp2px(18f), 0);
rg.setPadding(AndroidUtils.dp2px(18f), AndroidUtils.dp2px(12f), AndroidUtils.dp2px(18f), 0);
rgDefault.setText("VTLite");
rgDefault.setTextColor(getTextAttr());
rgDefault.setTextColor(ThemesUtils.getTextAttr());
rgVK.setText("VK");
rgVK.setTextColor(getTextAttr());
rgVK.setTextColor(ThemesUtils.getTextAttr());
rgVKontakte.setText(ctx.getString(R.string.app_name_alter));
rgVKontakte.setTextColor(getTextAttr());
rgVKontakte.setTextColor(ThemesUtils.getTextAttr());
rgVKontakte.setChecked(defname.contains("vkontakte"));
rgVK.setChecked(defname.contains("standard"));
@@ -74,20 +60,20 @@ public class IconsFragment extends MaterialPreferenceToolbarFragment {
.setView(rg)
.setPositiveButton(R.string.vtl_confirm, ((dialog, which) -> {
if (rgDefault.isChecked()) {
edit().putString("appname", "vt").commit();
edit().putString("selectedicon", appicon).commit();
AndroidUtils.edit().putString("appname", "vt").commit();
AndroidUtils.edit().putString("selectedicon", appicon).commit();
switchComponent(appicon, "vt", deficon, defname);
IconManager.switchComponent(appicon, "vt", deficon, defname);
} else if (rgVK.isChecked()) {
edit().putString("appname", "standard").commit();
edit().putString("selectedicon", appicon).commit();
AndroidUtils.edit().putString("appname", "standard").commit();
AndroidUtils.edit().putString("selectedicon", appicon).commit();
switchComponent(appicon, "standard", deficon, defname);
IconManager.switchComponent(appicon, "standard", deficon, defname);
} else if (rgVKontakte.isChecked()) {
edit().putString("appname", "vkontakte").commit();
edit().putString("selectedicon", appicon).commit();
AndroidUtils.edit().putString("appname", "vkontakte").commit();
AndroidUtils.edit().putString("selectedicon", appicon).commit();
switchComponent(appicon, "vkontakte", deficon, defname);
IconManager.switchComponent(appicon, "vkontakte", deficon, defname);
}
}))
.setNegativeButton(R.string.cancel,
@@ -102,20 +88,20 @@ public class IconsFragment extends MaterialPreferenceToolbarFragment {
this.addPreferencesFromResource(R.xml.empty);
if (!hasVerification() && !getBoolValue("dialogrecomm", false)) {
addPreference(this, "", requireContext().getString(R.string.icons_warning), requireContext().getString(R.string.icons_warning_info), R.drawable.ic_about_outline_28, preference -> {
getContext().startActivity(new Intent("android.intent.action.VIEW").setData(Uri.parse("https://vtosters.app/donate/")));
if (!Preferences.hasVerification() && !Preferences.getBoolValue("dialogrecomm", false)) {
PreferenceFragmentUtils.addPreference(getPreferenceScreen(), "", requireContext().getString(R.string.icons_warning), requireContext().getString(R.string.icons_warning_info), R.drawable.ic_about_outline_28, preference -> {
getContext().startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse("https://vtosters.app/donate/")));
return false;
});
}
addPreferenceCategory(this, requireContext().getString(R.string.icons_title));
PreferenceFragmentUtils.addPreferenceCategory(getPreferenceScreen(), requireContext().getString(R.string.icons_title));
for (var i = 0; i < icons().size(); i++) {
if (icons().get(i) == null || iconsValues().get(i) == null) return;
for (var i = 0; i < IconManager.icons().size(); i++) {
if (IconManager.icons().get(i) == null || IconManager.iconsValues().get(i) == null) return;
String iconname = icons().get(i);
String icon = iconsValues().get(i);
String iconname = IconManager.icons().get(i);
String icon = IconManager.iconsValues().get(i);
int iconRes;
@@ -124,7 +110,7 @@ public class IconsFragment extends MaterialPreferenceToolbarFragment {
} else if (icon.contains("standard")) {
iconRes = R.mipmap.ic_launcher_round;
} else {
iconRes = getIdentifier("ic_launcher_" + icon, "mipmap");
iconRes = AndroidUtils.getIdentifier("ic_launcher_" + icon, "mipmap");
}
Drawable drawable = ResourcesCompat.getDrawable(getResources(), iconRes, null);
@@ -133,20 +119,20 @@ public class IconsFragment extends MaterialPreferenceToolbarFragment {
drawable = ResourcesCompat.getDrawable(getResources(), R.drawable.ic_bug_outline_28, null);
}
addPreferenceDrawable(this, icon, iconname, "", drawable, preference -> {
PreferenceFragmentUtils.addPreference(getPreferenceScreen(), icon, iconname, "", drawable, preference -> {
callSelectDialog(this.getContext(), icon);
return false;
});
}
if (!hasVerification() && !getBoolValue("dialogrecomm", false)) {
addPreferenceCategory(this, requireContext().getString(R.string.unavailable_icons));
if (!Preferences.hasVerification() && !Preferences.getBoolValue("dialogrecomm", false)) {
PreferenceFragmentUtils.addPreferenceCategory(getPreferenceScreen(), requireContext().getString(R.string.unavailable_icons));
for (var i = 2; i < sIconsPlusNames.size(); i++) {
if (sIconsPlusNames.get(i) == null || sIconsPlus.get(i) == null) return;
for (var i = 2; i < IconManager.sIconsPlusNames.size(); i++) {
if (IconManager.sIconsPlusNames.get(i) == null || IconManager.sIconsPlus.get(i) == null) return;
String iconname = sIconsPlusNames.get(i);
String icon = sIconsPlus.get(i);
String iconname = IconManager.sIconsPlusNames.get(i);
String icon = IconManager.sIconsPlus.get(i);
int iconRes;
@@ -155,7 +141,7 @@ public class IconsFragment extends MaterialPreferenceToolbarFragment {
} else if (icon.contains("standard")) {
iconRes = R.mipmap.ic_launcher_round;
} else {
iconRes = getIdentifier("ic_launcher_" + icon, "mipmap");
iconRes = AndroidUtils.getIdentifier("ic_launcher_" + icon, "mipmap");
}
Drawable drawable = ResourcesCompat.getDrawable(getResources(), iconRes, null);
@@ -164,8 +150,8 @@ public class IconsFragment extends MaterialPreferenceToolbarFragment {
drawable = ResourcesCompat.getDrawable(getResources(), R.drawable.ic_bug_outline_28, null);
}
addPreferenceDrawable(this, icon, iconname, "", drawable, preference -> {
sendToast(requireContext().getString(R.string.unavailable_icon_warning));
PreferenceFragmentUtils.addPreference(getPreferenceScreen(), icon, iconname, "", drawable, preference -> {
AndroidUtils.sendToast(requireContext().getString(R.string.unavailable_icon_warning));
return false;
});
}
@@ -1,18 +1,24 @@
package ru.vtosters.lite.ui.fragments;
import static ru.vtosters.lite.utils.AndroidUtils.getPreferences;
import static ru.vtosters.lite.utils.AndroidUtils.isTablet;
import static ru.vtosters.lite.utils.AndroidUtils.*;
import static ru.vtosters.lite.utils.LifecycleUtils.restartApplicationWithTimer;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import androidx.preference.Preference;
import com.vk.core.fragments.FragmentImpl;
import com.vk.navigation.Navigator;
import com.vtosters.lite.R;
import com.vtosters.lite.general.fragments.MaterialPreferenceToolbarFragment;
import ru.vtosters.lite.ui.components.SuperAppEditorManager;
import ru.vtosters.lite.ui.dialogs.RoundingSeekbarDialog;
import ru.vtosters.lite.utils.AndroidUtils;
import ru.vtosters.lite.utils.Preferences;
import ru.vtosters.lite.utils.ThemesUtils;
public class InterfaceFragment extends MaterialPreferenceToolbarFragment {
@Override
@@ -28,11 +34,31 @@ public class InterfaceFragment extends MaterialPreferenceToolbarFragment {
findPreference("is_likes_on_right").setOnPreferenceClickListener(new restart());
findPreference("superapp").setOnPreferenceClickListener(new restart());
findPreference("dateformat").setOnPreferenceChangeListener((preference, o) -> {
edit().putString("dateformat", o.toString()).commit();
restartApplicationWithTimer();
return true;
});
var superappeditor = findPreference("superappeditor");
superappeditor.setSummary(AndroidUtils.getString(R.string.elements_hidden_count) + ": " + SuperAppEditorManager.getInstance().getDisabledTabs().size());
superappeditor.setVisible(!Preferences.vkme() && !isTablet() && Preferences.superapp());
superappeditor.setOnPreferenceClickListener(preference -> {
switchFragment(SuperAppEditorFragment.class);
return true;
});
if (isTablet()) {
findPreference("menusett").setVisible(false);
findPreference("swipe").setVisible(false);
}
if (ThemesUtils.isMilkshake() && Preferences.superapp()) {
findPreference("miniapps").setVisible(false);
findPreference("vkpay").setVisible(false);
findPreference("showmenu").setVisible(false);
}
findPreference("customrounding").setOnPreferenceClickListener(preference -> {
RoundingSeekbarDialog.dialog(getContext());
return true;
@@ -59,10 +85,17 @@ public class InterfaceFragment extends MaterialPreferenceToolbarFragment {
return R.string.vtlinterface;
}
public class restart implements Preference.OnPreferenceClickListener {
private class restart implements Preference.OnPreferenceClickListener {
@Override
public boolean onPreferenceClick(Preference preference) {
return InterfaceFragment.this.restart(preference);
}
}
private void switchFragment(Class< ? extends FragmentImpl> fragmentClz) {
var intent = new Navigator(fragmentClz)
.b(requireContext())
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
requireContext().startActivity(intent);
}
}
@@ -1,22 +1,7 @@
package ru.vtosters.lite.ui.fragments;
import static bruhcollective.itaysonlab.libvkx.client.LibVKXClient.isVkxInstalled;
import static ru.vtosters.lite.music.LastFMScrobbler.isLoggedIn;
import static ru.vtosters.lite.proxy.ProxyUtils.getApi;
import static ru.vtosters.lite.utils.AccountManagerUtils.getUserToken;
import static ru.vtosters.lite.utils.AndroidUtils.dp2px;
import static ru.vtosters.lite.utils.AndroidUtils.edit;
import static ru.vtosters.lite.utils.AndroidUtils.getPreferences;
import static ru.vtosters.lite.utils.AndroidUtils.sendToast;
import static ru.vtosters.lite.utils.LifecycleUtils.restartApplicationWithTimer;
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
import static ru.vtosters.lite.utils.ThemesUtils.getAccentColor;
import static ru.vtosters.lite.utils.ThemesUtils.getSTextAttr;
import static ru.vtosters.lite.utils.ThemesUtils.getTextAttr;
import android.content.Context;
import android.content.Intent;
import android.content.res.ColorStateList;
import android.os.Bundle;
import android.util.Log;
import android.view.Gravity;
@@ -24,31 +9,39 @@ import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import androidx.preference.Preference;
import bruhcollective.itaysonlab.libvkx.client.LibVKXClient;
import com.vk.core.dialogs.alert.VkAlertDialog;
import com.vk.core.network.Network;
import com.vtosters.lite.R;
import com.vtosters.lite.general.fragments.MaterialPreferenceToolbarFragment;
import org.json.JSONObject;
import java.io.IOException;
import java.util.Arrays;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import bruhcollective.itaysonlab.libvkx.client.LibVKXClient;
import okhttp3.Headers;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import org.json.JSONObject;
import ru.vtosters.lite.downloaders.AudioDownloader;
import ru.vtosters.lite.downloaders.VideoDownloader;
import ru.vtosters.lite.music.LastFMScrobbler;
import ru.vtosters.lite.music.cache.CacheDatabaseDelegate;
import ru.vtosters.lite.ui.adapters.ImagineArrayAdapter;
import ru.vtosters.lite.utils.AndroidUtils;
import ru.vtosters.lite.utils.ThemesUtils;
import java.io.IOException;
import java.util.Arrays;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import static bruhcollective.itaysonlab.libvkx.client.LibVKXClient.isVkxInstalled;
import static ru.vtosters.lite.music.LastFMScrobbler.isLoggedIn;
import static ru.vtosters.lite.proxy.ProxyUtils.getApi;
import static ru.vtosters.lite.utils.AccountManagerUtils.getUserToken;
import static ru.vtosters.lite.utils.AndroidUtils.*;
import static ru.vtosters.lite.utils.LifecycleUtils.restartApplicationWithTimer;
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
import static ru.vtosters.lite.utils.Preferences.isEnableExternalOpening;
import static ru.vtosters.lite.utils.ThemesUtils.getSTextAttr;
import static ru.vtosters.lite.utils.ThemesUtils.getTextAttr;
public class MediaFragment extends MaterialPreferenceToolbarFragment {
private static final ExecutorService executor = Executors.newCachedThreadPool();
@@ -56,7 +49,7 @@ public class MediaFragment extends MaterialPreferenceToolbarFragment {
public static void download(Context ctx) {
final EditText input = new EditText(ctx);
input.setTextColor(getTextAttr());
input.setBackgroundTintList(ColorStateList.valueOf(getAccentColor()));
input.setBackgroundTintList(ThemesUtils.getAccenedColorStateList());
var lp = new FrameLayout.LayoutParams(-1, -2);
lp.leftMargin = AndroidUtils.dp2px(16);
@@ -91,13 +84,18 @@ public class MediaFragment extends MaterialPreferenceToolbarFragment {
prefs();
}
@Override
public boolean onPreferenceTreeClick(Preference preference) {
findPreference("maxquality").setEnabled(isEnableExternalOpening());
return super.onPreferenceTreeClick(preference);
}
private void prefs() {
findPreference("download_video").setOnPreferenceClickListener(new MediaFragment.download());
findPreference("clearvideohistory").setOnPreferenceClickListener(preference -> {
deleteVideoHistoryDialog(requireContext());
return true;
});
findPreference("dateformat").setOnPreferenceChangeListener(new MediaFragment.restart());
findPreference("lastfm_auth").setOnPreferenceClickListener(preference -> {
if (isLoggedIn()) {
logout(getContext());
@@ -140,12 +138,16 @@ public class MediaFragment extends MaterialPreferenceToolbarFragment {
findPreference("select_photo_search_engine").setOnPreferenceClickListener(preference -> {
var items = Arrays.asList(
new ImagineArrayAdapter.ImagineArrayAdapterItem(null, "По выбору"),
new ImagineArrayAdapter.ImagineArrayAdapterItem(R.drawable.yandex, "Yandex"),
new ImagineArrayAdapter.ImagineArrayAdapterItem(R.drawable.google, "Google"),
new ImagineArrayAdapter.ImagineArrayAdapterItem(R.drawable.microsoft, "Bing")
);
new ImagineArrayAdapter.ImagineArrayAdapterItem(R.drawable.microsoft, "Bing"),
new ImagineArrayAdapter.ImagineArrayAdapterItem(null, "TraceMoe"),
new ImagineArrayAdapter.ImagineArrayAdapterItem(null, "Ascii2d"),
new ImagineArrayAdapter.ImagineArrayAdapterItem(null, "Saucenao")
);
var adapter = new ImagineArrayAdapter(getContext(), items);
var adapter = new ImagineArrayAdapter(requireContext(), items);
adapter.setSelected(getPreferences().getInt("search_engine", 0));
new VkAlertDialog.Builder(getActivity())
@@ -156,6 +158,8 @@ public class MediaFragment extends MaterialPreferenceToolbarFragment {
.show();
return true;
});
findPreference("maxquality").setEnabled(isEnableExternalOpening());
}
private void lastfmAuth(Context ctx) {
@@ -166,7 +170,7 @@ public class MediaFragment extends MaterialPreferenceToolbarFragment {
fn.setHint(R.string.lastfm_login);
fn.setTextColor(getTextAttr());
fn.setHintTextColor(getSTextAttr());
fn.setBackgroundTintList(ColorStateList.valueOf(getAccentColor()));
fn.setBackgroundTintList(ThemesUtils.getAccenedColorStateList());
linearLayout.addView(fn);
fn.getLayoutParams().width = ViewGroup.LayoutParams.MATCH_PARENT;
ViewGroup.MarginLayoutParams margin = ((ViewGroup.MarginLayoutParams) fn.getLayoutParams());
@@ -177,7 +181,7 @@ public class MediaFragment extends MaterialPreferenceToolbarFragment {
ln.setHint(R.string.lastfm_password);
ln.setTextColor(getTextAttr());
ln.setHintTextColor(getSTextAttr());
ln.setBackgroundTintList(ColorStateList.valueOf(getAccentColor()));
ln.setBackgroundTintList(ThemesUtils.getAccenedColorStateList());
linearLayout.addView(ln);
ln.getLayoutParams().width = ViewGroup.LayoutParams.MATCH_PARENT;
ln.setLayoutParams(margin);
@@ -281,15 +285,6 @@ public class MediaFragment extends MaterialPreferenceToolbarFragment {
return R.string.vtlmedia;
}
private static class restart implements Preference.OnPreferenceChangeListener {
@Override
public boolean onPreferenceChange(Preference preference, Object o) {
edit().putString("dateformat", o.toString()).commit();
restartApplicationWithTimer();
return false;
}
}
private class download implements Preference.OnPreferenceClickListener {
@Override // android.support.v7.preference.Preference.c
public boolean onPreferenceClick(Preference preference) {
@@ -39,8 +39,6 @@ public class MessagesFragment extends MaterialPreferenceToolbarFragment {
private void prefs() {
findPreference("vkme").setOnPreferenceClickListener(new MessagesFragment.restart());
findPreference("vkme_notifs").setOnPreferenceClickListener(new MessagesFragment.restart());
findPreference("systememoji").setOnPreferenceClickListener(new MessagesFragment.restart());
findPreference("wallpapers").setOnPreferenceClickListener(new MessagesFragment.openwp());
findPreference("autotranslate").setEnabled(!autoalltranslate());
@@ -65,11 +63,9 @@ public class MessagesFragment extends MaterialPreferenceToolbarFragment {
});
findPreference("vkme_notifs").setEnabled(vkme());
findPreference("wallpapers").setIcon(recolorDrawable(getGlobalContext().getDrawable(R.drawable.ic_media_outline_28)));
findPreference("vkme").setIcon(R.drawable.ic_vkme_28);
if (isTablet()) {
findPreference("alteremoji").setVisible(false);
findPreference("vkmesett").setVisible(false);
}
}
@@ -104,15 +100,4 @@ public class MessagesFragment extends MaterialPreferenceToolbarFragment {
return MessagesFragment.this.restart();
}
}
public class openwp implements Preference.OnPreferenceClickListener {
@Override
public boolean onPreferenceClick(Preference preference) {
Context context = requireContext();
Intent a2 = new Navigator(WallpaperMenuFragment.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(a2);
return true;
}
}
}
@@ -8,9 +8,7 @@ import static ru.vtosters.lite.ui.components.BackupManager.backupSettings;
import static ru.vtosters.lite.ui.components.BackupManager.deletePrefs;
import static ru.vtosters.lite.ui.components.BackupManager.restoreBackup;
import static ru.vtosters.lite.utils.AccountManagerUtils.getUserToken;
import static ru.vtosters.lite.utils.AndroidUtils.dp2px;
import static ru.vtosters.lite.utils.AndroidUtils.getDefaultPrefs;
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
import static ru.vtosters.lite.utils.AndroidUtils.*;
import static ru.vtosters.lite.utils.LifecycleUtils.restartApplication;
import static ru.vtosters.lite.utils.LifecycleUtils.restartApplicationWithTimer;
import static ru.vtosters.lite.utils.ThemesUtils.getTextAttr;
@@ -58,10 +56,13 @@ import com.vtosters.lite.im.ImEngineProvider;
import java.io.IOException;
import b.h.g.m.FileUtils;
import ru.vtosters.lite.ssfs.UsersList;
import ru.vtosters.lite.ui.activities.VKAdminTokenActivity;
import ru.vtosters.lite.ui.components.BackupManager;
import ru.vtosters.lite.utils.AccountManagerUtils;
import ru.vtosters.lite.utils.AndroidUtils;
import ru.vtosters.lite.utils.ContactsUtils;
import ru.vtosters.lite.utils.VTVerifications;
public class OtherFragment extends MaterialPreferenceToolbarFragment {
private static final int VK_ADMIN_TOKEN_REQUEST_CODE = 1;
@@ -96,6 +97,11 @@ public class OtherFragment extends MaterialPreferenceToolbarFragment {
cacheCleanDialog();
return true;
});
findPreference("copyownlink").setOnPreferenceClickListener(preference -> {
((ClipboardManager) requireContext().getSystemService(Context.CLIPBOARD_SERVICE)).setPrimaryClip(ClipData.newPlainText("MBH-ST", "https://vk.com/id" + AccountManagerUtils.getUserId()));
ToastUtils.a(requireContext().getString(R.string.link_copied));
return true;
});
findPreference("deviceinfo").setOnPreferenceClickListener(preference -> {
Context context = requireContext();
@@ -110,6 +116,13 @@ public class OtherFragment extends MaterialPreferenceToolbarFragment {
return true;
});
findPreference("updateverifdata").setOnPreferenceClickListener(preference -> {
UsersList.getUsersList();
VTVerifications.load(requireContext());
sendToast("Данные обновлены");
return true;
});
findPreference("contacts_sync").setOnPreferenceClickListener((preference) -> {
ContactsUtils.getContactsStatus(requireContext());
return true;
@@ -1,9 +1,5 @@
package ru.vtosters.lite.ui.fragments;
import static ru.vtosters.lite.utils.AndroidUtils.dp2px;
import static ru.vtosters.lite.utils.LifecycleUtils.restartApplication;
import android.os.Build;
import android.os.Bundle;
import android.view.ContextThemeWrapper;
import android.view.Gravity;
@@ -12,22 +8,23 @@ import android.view.View;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.CallSuper;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.ItemTouchHelper;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.vtosters.lite.R;
import ru.vtosters.lite.themes.hooks.TextViewHook;
import ru.vtosters.lite.ui.adapters.CategorizedAdapter;
import ru.vtosters.lite.ui.components.ItemMovingCallback;
import ru.vtosters.lite.ui.components.SuperAppEditorManager;
import ru.vtosters.lite.utils.LayoutUtils;
import ru.vtosters.lite.utils.ThemesUtils;
import static ru.vtosters.lite.utils.AndroidUtils.dp2px;
import static ru.vtosters.lite.utils.LifecycleUtils.restartApplication;
public class SuperAppEditorFragment extends BaseToolbarFragment {
@CallSuper
@@ -35,13 +32,13 @@ public class SuperAppEditorFragment extends BaseToolbarFragment {
public View onCreateContent(@NonNull LayoutInflater inflater, @Nullable Bundle bundle) {
setTitle(R.string.superapp_editor);
FrameLayout content = new FrameLayout(getContext());
var content = new FrameLayout(getContext());
LinearLayout container = new LinearLayout(getContext());
var container = new LinearLayout(getContext());
container.setOrientation(LinearLayout.VERTICAL);
content.addView(container, new FrameLayout.LayoutParams(-1, -1));
content.addView(container, LayoutUtils.createFrame(-1, -1));
TextView message = new TextView(getContext());
var message = new TextView(getContext());
message.setText(R.string.superapp_editor_message);
message.setTextSize(16.0f);
message.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
@@ -54,7 +51,7 @@ public class SuperAppEditorFragment extends BaseToolbarFragment {
);
container.addView(message, LayoutUtils.createLinear(-1, -2));
LinearLayout buttonsContainer = new LinearLayout(getContext());
var buttonsContainer = new LinearLayout(getContext());
buttonsContainer.setPadding(
dp2px(13),
dp2px(10),
@@ -63,65 +60,56 @@ public class SuperAppEditorFragment extends BaseToolbarFragment {
);
container.addView(buttonsContainer, new LinearLayout.LayoutParams(-1, -2));
TextView save = new TextView(new ContextThemeWrapper(getContext(), com.vtosters.lite.R.style.VKUIButton_Primary));
var save = new TextView(new ContextThemeWrapper(getContext(), R.style.VKUIButton_Primary));
save.setText(R.string.save);
save.setOnClickListener(v -> {
SuperAppEditorManager.getInstance().save();
restartApplication();
});
LinearLayout.LayoutParams saveParams = new LinearLayout.LayoutParams(0, -2);
new TextViewHook().inject(save, 0, false);
var saveParams = LayoutUtils.createLinear(0, -2);
saveParams.weight = 1.0f;
buttonsContainer.addView(save, saveParams);
View divider = new View(getContext());
var divider = new View(getContext());
buttonsContainer.addView(divider, new LinearLayout.LayoutParams(dp2px(10), 0));
TextView reset = new TextView(new ContextThemeWrapper(getContext(), com.vtosters.lite.R.style.VKUIButton_Primary));
var reset = new TextView(new ContextThemeWrapper(getContext(), R.style.VKUIButton_Primary));
reset.setText(R.string.reset);
reset.setOnClickListener(v -> {
SuperAppEditorManager.getInstance().reset();
restartApplication();
});
LinearLayout.LayoutParams resetParams = new LinearLayout.LayoutParams(0, -2);
new TextViewHook().inject(reset, 0, false);
var resetParams = LayoutUtils.createLinear(0, -2);
resetParams.weight = 1.0f;
buttonsContainer.addView(reset, resetParams);
SuperAppEditorManager manager = SuperAppEditorManager.getInstance();
var adapter = new CategorizedAdapter(manager.getSelectedTabs(), manager.getDisabledTabs(), (holder, pos) -> {
var manager = SuperAppEditorManager.getInstance();
var adapter = new CategorizedAdapter<>(manager.getSelectedTabs(), manager.getDisabledTabs(), (holder, pos) -> {
var item = pos <= manager.getSelectedTabs().size()
? manager.getSelectedTabs().get(pos - 1)
: manager.getDisabledTabs().get(pos - manager.getSelectedTabs().size() - 2);
holder.bindMovingItem(item.title);
});
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
manager.getSelectedTabs().forEach(item -> {
if (item.type.equals("menu"))
adapter.addUnmovedItem(item);
});
manager.getDisabledTabs().forEach(item -> {
if (item.type.equals("menu"))
adapter.addUnmovedItem(item);
});
} else {
for (var item : manager.getSelectedTabs()) {
if (item.type.equals("menu"))
adapter.addUnmovedItem(item);
}
for(var item : manager.getSelectedTabs())
if(item.type.equals("menu"))
adapter.addUnmovedItem(item);
for (var item : manager.getDisabledTabs()) {
if (item.type.equals("menu"))
adapter.addUnmovedItem(item);
}
}
for(var item : manager.getDisabledTabs())
if(item.type.equals("menu"))
adapter.addUnmovedItem(item);
var recyclerView = new RecyclerView(requireContext());
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
recyclerView.setAdapter(adapter);
recyclerView.setHasFixedSize(true);
var params = new LinearLayout.LayoutParams(-1, -1);
var params = LayoutUtils.createLinear(-1, -1);
params.gravity = Gravity.CENTER;
container.addView(recyclerView, params);
@@ -1,34 +1,17 @@
package ru.vtosters.lite.ui.fragments;
import static ru.vtosters.lite.deviceinfo.OEMDetector.getEmuiVersionCode;
import static ru.vtosters.lite.deviceinfo.OEMDetector.getMiuiUiVersionCode;
import static ru.vtosters.lite.deviceinfo.OEMDetector.getMiuiUiVersionIncrementalCode;
import static ru.vtosters.lite.deviceinfo.OEMDetector.getMiuiUiVersionName;
import static ru.vtosters.lite.deviceinfo.OEMDetector.getOneUiMajorVersion;
import static ru.vtosters.lite.deviceinfo.OEMDetector.getOneUiMinorVersion;
import static ru.vtosters.lite.deviceinfo.OEMDetector.hasMiuiIncrCode;
import static ru.vtosters.lite.deviceinfo.OEMDetector.isEMUI;
import static ru.vtosters.lite.deviceinfo.OEMDetector.isFlyme;
import static ru.vtosters.lite.deviceinfo.OEMDetector.isMIUI;
import static ru.vtosters.lite.deviceinfo.OEMDetector.isOneUi;
import static ru.vtosters.lite.deviceinfo.OEMDetector.isSamsung;
import static ru.vtosters.lite.deviceinfo.OEMDetector.isVivo;
import static ru.vtosters.lite.deviceinfo.OEMDetector.isZenUI;
import static ru.vtosters.lite.ui.PreferencesUtil.addPreference;
import static ru.vtosters.lite.ui.PreferencesUtil.addPreferenceCategory;
import static ru.vtosters.lite.utils.About.getBuildNumber;
import static ru.vtosters.lite.utils.AndroidUtils.isTablet;
import static ru.vtosters.lite.utils.AndroidUtils.sendToast;
import static ru.vtosters.lite.utils.Preferences.isValidSignature;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import com.vtosters.lite.R;
import com.vtosters.lite.general.fragments.MaterialPreferenceToolbarFragment;
import ru.vtosters.lite.deviceinfo.OEMDetector;
import ru.vtosters.lite.ui.PreferenceFragmentUtils;
import ru.vtosters.lite.utils.About;
import ru.vtosters.lite.utils.AndroidUtils;
import ru.vtosters.lite.utils.Preferences;
public class SystemInfo extends MaterialPreferenceToolbarFragment {
@@ -37,8 +20,8 @@ public class SystemInfo extends MaterialPreferenceToolbarFragment {
super.onCreate(bundle);
addPreferencesFromResource(R.xml.empty);
var oneUiMajorVersion = String.valueOf(getOneUiMajorVersion());
var oneUiMinorVersion = String.valueOf(getOneUiMinorVersion());
var oneUiMajorVersion = String.valueOf(OEMDetector.getOneUiMajorVersion());
var oneUiMinorVersion = String.valueOf(OEMDetector.getOneUiMinorVersion());
var sdkVersion = String.valueOf(Build.VERSION.SDK_INT);
var productName = Build.PRODUCT;
var deviceName = Build.DEVICE;
@@ -46,145 +29,145 @@ public class SystemInfo extends MaterialPreferenceToolbarFragment {
var manufacturerName = Build.MANUFACTURER;
var brandName = Build.BRAND;
var modelName = Build.MODEL;
var miuiUiVersionName = getMiuiUiVersionName();
var miuiIncrementalCodeName = getMiuiUiVersionIncrementalCode();
var miuiUiVersionCodeName = getMiuiUiVersionCode();
var emuiVersionCode = getEmuiVersionCode();
var miuiUiVersionName = OEMDetector.getMiuiUiVersionName();
var miuiIncrementalCodeName = OEMDetector.getMiuiUiVersionIncrementalCode();
var miuiUiVersionCodeName = OEMDetector.getMiuiUiVersionCode();
var emuiVersionCode = OEMDetector.getEmuiVersionCode();
var packageName = requireContext().getPackageName();
var commit = getBuildNumber();
var commit = About.getBuildNumber();
var isMiui = isMIUI();
var isFlyme = isFlyme();
var isSamsung = isSamsung();
var isOneUi = isOneUi();
var isVivo = isVivo();
var isZenUI = isZenUI();
var isEMUI = isEMUI();
var hasMiuiIncrCode = hasMiuiIncrCode();
var isMiui = OEMDetector.isMIUI();
var isFlyme = OEMDetector.isFlyme();
var isSamsung = OEMDetector.isSamsung();
var isOneUi = OEMDetector.isOneUi();
var isVivo = OEMDetector.isVivo();
var isZenUI = OEMDetector.isZenUI();
var isEMUI = OEMDetector.isEMUI();
var hasMiuiIncrCode = OEMDetector.hasMiuiIncrCode();
var isValidSignature = isValidSignature();
var isTablet = isTablet();
var isValidSignature = Preferences.isValidSignature();
var isTablet = AndroidUtils.isTablet();
addPreferenceCategory(this, "App information");
PreferenceFragmentUtils.addPreferenceCategory(getPreferenceScreen(), "App information");
addPreference(this, "", "Package name", packageName, 0, preference -> {
PreferenceFragmentUtils.addPreference(getPreferenceScreen(), "", "Package name", packageName, 0, preference -> {
((ClipboardManager) requireActivity().getSystemService(Context.CLIPBOARD_SERVICE)).setPrimaryClip(ClipData.newPlainText("MBH-ST", packageName));
sendToast(requireContext().getString(R.string.copied_to_clipboard));
AndroidUtils.sendToast(requireContext().getString(R.string.copied_to_clipboard));
return false;
});
addPreference(this, "", "Commit", commit, 0, preference -> {
PreferenceFragmentUtils.addPreference(getPreferenceScreen(), "", "Commit", commit, 0, preference -> {
((ClipboardManager) requireActivity().getSystemService(Context.CLIPBOARD_SERVICE)).setPrimaryClip(ClipData.newPlainText("MBH-ST", commit));
sendToast(requireContext().getString(R.string.copied_to_clipboard));
AndroidUtils.sendToast(requireContext().getString(R.string.copied_to_clipboard));
return false;
});
addPreference(this, "", "Valid Signature", "Value: " + isValidSignature, 0, null);
PreferenceFragmentUtils.addPreference(getPreferenceScreen(), "", "Valid Signature", "Value: " + isValidSignature, 0, null);
addPreference(this, "", "isTablet", "Value: " + isTablet, 0, null);
PreferenceFragmentUtils.addPreference(getPreferenceScreen(), "", "isTablet", "Value: " + isTablet, 0, null);
addPreferenceCategory(this, "System information");
PreferenceFragmentUtils.addPreferenceCategory(getPreferenceScreen(), "System information");
addPreference(this, "", "SDK Version", sdkVersion, 0, preference -> {
PreferenceFragmentUtils.addPreference(getPreferenceScreen(), "", "SDK Version", sdkVersion, 0, preference -> {
((ClipboardManager) requireActivity().getSystemService(Context.CLIPBOARD_SERVICE)).setPrimaryClip(ClipData.newPlainText("MBH-ST", sdkVersion));
sendToast(requireContext().getString(R.string.copied_to_clipboard));
AndroidUtils.sendToast(requireContext().getString(R.string.copied_to_clipboard));
return false;
});
addPreference(this, "", "Product Name", productName, 0, preference -> {
PreferenceFragmentUtils.addPreference(getPreferenceScreen(), "", "Product Name", productName, 0, preference -> {
((ClipboardManager) requireActivity().getSystemService(Context.CLIPBOARD_SERVICE)).setPrimaryClip(ClipData.newPlainText("MBH-ST", productName));
sendToast(requireContext().getString(R.string.copied_to_clipboard));
AndroidUtils.sendToast(requireContext().getString(R.string.copied_to_clipboard));
return false;
});
addPreference(this, "", "Device Name", deviceName, 0, preference -> {
PreferenceFragmentUtils.addPreference(getPreferenceScreen(), "", "Device Name", deviceName, 0, preference -> {
((ClipboardManager) requireActivity().getSystemService(Context.CLIPBOARD_SERVICE)).setPrimaryClip(ClipData.newPlainText("MBH-ST", deviceName));
sendToast(requireContext().getString(R.string.copied_to_clipboard));
AndroidUtils.sendToast(requireContext().getString(R.string.copied_to_clipboard));
return false;
});
addPreference(this, "", "Board Name", boardName, 0, preference -> {
PreferenceFragmentUtils.addPreference(getPreferenceScreen(), "", "Board Name", boardName, 0, preference -> {
((ClipboardManager) requireActivity().getSystemService(Context.CLIPBOARD_SERVICE)).setPrimaryClip(ClipData.newPlainText("MBH-ST", boardName));
sendToast(requireContext().getString(R.string.copied_to_clipboard));
AndroidUtils.sendToast(requireContext().getString(R.string.copied_to_clipboard));
return false;
});
addPreference(this, "", "Manufacturer Name", manufacturerName, 0, preference -> {
PreferenceFragmentUtils.addPreference(getPreferenceScreen(), "", "Manufacturer Name", manufacturerName, 0, preference -> {
((ClipboardManager) requireActivity().getSystemService(Context.CLIPBOARD_SERVICE)).setPrimaryClip(ClipData.newPlainText("MBH-ST", manufacturerName));
sendToast(requireContext().getString(R.string.copied_to_clipboard));
AndroidUtils.sendToast(requireContext().getString(R.string.copied_to_clipboard));
return false;
});
addPreference(this, "", "Brand Name", brandName, 0, preference -> {
PreferenceFragmentUtils.addPreference(getPreferenceScreen(), "", "Brand Name", brandName, 0, preference -> {
((ClipboardManager) requireActivity().getSystemService(Context.CLIPBOARD_SERVICE)).setPrimaryClip(ClipData.newPlainText("MBH-ST", brandName));
sendToast(requireContext().getString(R.string.copied_to_clipboard));
AndroidUtils.sendToast(requireContext().getString(R.string.copied_to_clipboard));
return false;
});
addPreference(this, "", "Model Name", modelName, 0, preference -> {
PreferenceFragmentUtils.addPreference(getPreferenceScreen(), "", "Model Name", modelName, 0, preference -> {
((ClipboardManager) requireActivity().getSystemService(Context.CLIPBOARD_SERVICE)).setPrimaryClip(ClipData.newPlainText("MBH-ST", modelName));
sendToast(requireContext().getString(R.string.copied_to_clipboard));
AndroidUtils.sendToast(requireContext().getString(R.string.copied_to_clipboard));
return false;
});
addPreferenceCategory(this, "OEM Information");
PreferenceFragmentUtils.addPreferenceCategory(getPreferenceScreen(), "OEM Information");
if (isOneUi) {
addPreference(this, "", "OneUiMajorVersion", oneUiMajorVersion, 0, preference -> {
PreferenceFragmentUtils.addPreference(getPreferenceScreen(), "", "OneUiMajorVersion", oneUiMajorVersion, 0, preference -> {
((ClipboardManager) requireActivity().getSystemService(Context.CLIPBOARD_SERVICE)).setPrimaryClip(ClipData.newPlainText("MBH-ST", oneUiMajorVersion));
sendToast(requireContext().getString(R.string.copied_to_clipboard));
AndroidUtils.sendToast(requireContext().getString(R.string.copied_to_clipboard));
return false;
});
addPreference(this, "", "OneUiMinorVersion", oneUiMinorVersion, 0, preference -> {
PreferenceFragmentUtils.addPreference(getPreferenceScreen(), "", "OneUiMinorVersion", oneUiMinorVersion, 0, preference -> {
((ClipboardManager) requireActivity().getSystemService(Context.CLIPBOARD_SERVICE)).setPrimaryClip(ClipData.newPlainText("MBH-ST", oneUiMinorVersion));
sendToast(requireContext().getString(R.string.copied_to_clipboard));
AndroidUtils.sendToast(requireContext().getString(R.string.copied_to_clipboard));
return false;
});
} else if (isMiui) {
addPreference(this, "", "miuiUiVersionName", miuiUiVersionName, 0, preference -> {
PreferenceFragmentUtils.addPreference(getPreferenceScreen(), "", "miuiUiVersionName", miuiUiVersionName, 0, preference -> {
((ClipboardManager) requireActivity().getSystemService(Context.CLIPBOARD_SERVICE)).setPrimaryClip(ClipData.newPlainText("MBH-ST", miuiUiVersionName));
sendToast(requireContext().getString(R.string.copied_to_clipboard));
AndroidUtils.sendToast(requireContext().getString(R.string.copied_to_clipboard));
return false;
});
addPreference(this, "", "miuiUiVersionCodeName", miuiUiVersionCodeName, 0, preference -> {
PreferenceFragmentUtils.addPreference(getPreferenceScreen(), "", "miuiUiVersionCodeName", miuiUiVersionCodeName, 0, preference -> {
((ClipboardManager) requireActivity().getSystemService(Context.CLIPBOARD_SERVICE)).setPrimaryClip(ClipData.newPlainText("MBH-ST", miuiUiVersionCodeName));
sendToast(requireContext().getString(R.string.copied_to_clipboard));
AndroidUtils.sendToast(requireContext().getString(R.string.copied_to_clipboard));
return false;
});
if (hasMiuiIncrCode) {
addPreference(this, "", "miuiIncrementalCodeName", miuiIncrementalCodeName, 0, preference -> {
PreferenceFragmentUtils.addPreference(getPreferenceScreen(), "", "miuiIncrementalCodeName", miuiIncrementalCodeName, 0, preference -> {
((ClipboardManager) requireActivity().getSystemService(Context.CLIPBOARD_SERVICE)).setPrimaryClip(ClipData.newPlainText("MBH-ST", miuiIncrementalCodeName));
sendToast(requireContext().getString(R.string.copied_to_clipboard));
AndroidUtils.sendToast(requireContext().getString(R.string.copied_to_clipboard));
return false;
});
}
} else if (isEMUI) {
addPreference(this, "", "emuiVersionCode", emuiVersionCode, 0, preference -> {
PreferenceFragmentUtils.addPreference(getPreferenceScreen(), "", "emuiVersionCode", emuiVersionCode, 0, preference -> {
((ClipboardManager) requireActivity().getSystemService(Context.CLIPBOARD_SERVICE)).setPrimaryClip(ClipData.newPlainText("MBH-ST", emuiVersionCode));
sendToast(requireContext().getString(R.string.copied_to_clipboard));
AndroidUtils.sendToast(requireContext().getString(R.string.copied_to_clipboard));
return false;
});
} else {
addPreference(this, "", "No info", "No information about OEM", 0, null);
PreferenceFragmentUtils.addPreference(getPreferenceScreen(), "", "No info", "No information about OEM", 0, null);
}
addPreferenceCategory(this, "OEM List");
PreferenceFragmentUtils.addPreferenceCategory(getPreferenceScreen(), "OEM List");
addPreference(this, "", "isOneUi", "Value: " + isOneUi, 0, null);
PreferenceFragmentUtils.addPreference(getPreferenceScreen(), "", "isOneUi", "Value: " + isOneUi, 0, null);
addPreference(this, "", "isMiui", "Value: " + isMiui, 0, null);
PreferenceFragmentUtils.addPreference(getPreferenceScreen(), "", "isMiui", "Value: " + isMiui, 0, null);
addPreference(this, "", "isEMUI", "Value: " + isEMUI, 0, null);
PreferenceFragmentUtils.addPreference(getPreferenceScreen(), "", "isEMUI", "Value: " + isEMUI, 0, null);
addPreference(this, "", "isFlyme", "Value: " + isFlyme, 0, null);
PreferenceFragmentUtils.addPreference(getPreferenceScreen(), "", "isFlyme", "Value: " + isFlyme, 0, null);
addPreference(this, "", "isSamsung", "Value: " + isSamsung, 0, null);
PreferenceFragmentUtils.addPreference(getPreferenceScreen(), "", "isSamsung", "Value: " + isSamsung, 0, null);
addPreference(this, "", "isVivo", "Value: " + isVivo, 0, null);
PreferenceFragmentUtils.addPreference(getPreferenceScreen(), "", "isVivo", "Value: " + isVivo, 0, null);
addPreference(this, "", "isZenUI", "Value: " + isZenUI, 0, null);
PreferenceFragmentUtils.addPreference(getPreferenceScreen(), "", "isZenUI", "Value: " + isZenUI, 0, null);
}
}
@@ -1,20 +1,30 @@
package ru.vtosters.lite.ui.fragments;
import static ru.vtosters.lite.utils.AndroidUtils.edit;
import static ru.vtosters.lite.utils.AndroidUtils.isTablet;
import static ru.vtosters.lite.utils.LifecycleUtils.restartApplicationWithTimer;
import static ru.vtosters.lite.utils.Preferences.milkshake;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import androidx.preference.Preference;
import android.view.WindowManager;
import androidx.preference.PreferenceCategory;
import com.vk.core.dialogs.alert.VkAlertDialog;
import com.vk.core.fragments.FragmentImpl;
import com.vk.navigation.Navigator;
import com.vtosters.lite.R;
import com.vtosters.lite.general.fragments.MaterialPreferenceToolbarFragment;
import ru.vtosters.lite.themes.ThemesCore;
import ru.vtosters.lite.themes.palettes.PalettesManager;
import ru.vtosters.lite.ui.components.DockBarEditorManager;
import ru.vtosters.lite.ui.dialogs.PalettesBottomSheetDialog;
import ru.vtosters.lite.ui.views.rarepebble.ColorPickerView;
import ru.vtosters.lite.ui.wallpapers.WallpaperMenuFragment;
import ru.vtosters.lite.utils.AndroidUtils;
import ru.vtosters.lite.utils.LifecycleUtils;
import ru.vtosters.lite.utils.Preferences;
import ru.vtosters.lite.utils.ThemesUtils;
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
import static ru.vtosters.lite.utils.ThemesUtils.recolorDrawable;
public class ThemesFragment extends MaterialPreferenceToolbarFragment {
@@ -22,23 +32,107 @@ public class ThemesFragment extends MaterialPreferenceToolbarFragment {
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
addPreferencesFromResource(R.xml.preferences_themes);
prefs();
initPreferences();
}
private void prefs() {
findPreference("navbar").setOnPreferenceClickListener(new restart());
findPreference("milkshake").setOnPreferenceClickListener(new restart());
findPreference("darktheme").setOnPreferenceChangeListener(new restartdark());
findPreference("lighttheme").setOnPreferenceChangeListener(new restartlight());
findPreference("iconmanager").setOnPreferenceClickListener(new openicons());
findPreference("dockbar_tab_titles").setOnPreferenceClickListener(new restart());
findPreference("dockbar_accent").setOnPreferenceClickListener(new restart());
findPreference("dockcounter").setOnPreferenceClickListener(new restart());
findPreference("newsfeed_notif").setOnPreferenceClickListener(new restart());
findPreference("newsfeed_notif").setVisible(milkshake());
private void initPreferences() {
var accentColorPreference = findPreference("accent_color");
accentColorPreference.setIcon(ThemesUtils.recolorDrawable(requireContext().getDrawable(R.drawable.bg_accent_circle)));
accentColorPreference.setOnPreferenceClickListener(preference -> {
changeAccent();
return true;
});
if (isTablet()) {
findPreference("dockbarsett").setVisible(false);
var dockbarEditor = findPreference("dockbareditor");
dockbarEditor.setSummary(AndroidUtils.getString(R.string.vtldocksumm) + ": " + DockBarEditorManager.getInstance().getSelectedTabs().size());
dockbarEditor.setOnPreferenceClickListener(preference -> {
switchFragment(DockBarEditorFragment.class);
return true;
});
var navBarPreference = findPreference("navbar");
navBarPreference.setOnPreferenceClickListener(preference -> {
restart();
return true;
});
var milkshakePreference = findPreference("milkshake");
milkshakePreference.setOnPreferenceClickListener(preference -> {
restart();
return true;
});
var amoledThemePreference = findPreference("amoledtheme");
amoledThemePreference.setOnPreferenceClickListener(preference -> {
restart();
return true;
});
var monetThemePreference = findPreference("monettheme");
monetThemePreference.setOnPreferenceClickListener(preference -> {
restart();
return true;
});
monetThemePreference.setVisible(Build.VERSION.SDK_INT >= Build.VERSION_CODES.S);
var iconManagerPreference = findPreference("iconmanager");
iconManagerPreference.setOnPreferenceClickListener(preference -> {
switchFragment(IconsFragment.class);
return true;
});
var dockbarTabTitlesPreference = findPreference("dockbar_tab_titles");
dockbarTabTitlesPreference.setOnPreferenceClickListener(preference -> {
restart();
return true;
});
var dockbarAccentPreference = findPreference("dockbar_accent");
dockbarAccentPreference.setOnPreferenceClickListener(preference -> {
restart();
return true;
});
var dockCounterPreference = findPreference("dockcounter");
dockCounterPreference.setOnPreferenceClickListener(preference -> {
restart();
return true;
});
var newsfeedNotificationsPreference = findPreference("newsfeed_notif");
newsfeedNotificationsPreference.setOnPreferenceClickListener(preference -> {
restart();
return true;
});
newsfeedNotificationsPreference.setVisible(Preferences.milkshake());
findPreference("accentprefs").setVisible(!ThemesUtils.isMonetTheme() && ThemesUtils.isMilkshake());
var wp = findPreference("wallpapers");
wp.setIcon(recolorDrawable(getGlobalContext().getDrawable(R.drawable.ic_media_outline_28)));
wp.setOnPreferenceClickListener(preference -> {
Context context = requireContext();
Intent a2 = new Navigator(WallpaperMenuFragment.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(a2);
return true;
});
findPreference("systememoji").setOnPreferenceClickListener(preference -> {
restart();
return true;
});
if (Preferences.vkme()) {
findPreference("dockbareditor").setVisible(false);
}
if(AndroidUtils.isTablet()) {
PreferenceCategory dockbarSettingsPreferenceCategory = (PreferenceCategory) findPreference("dockbarsett");
dockbarSettingsPreferenceCategory.setVisible(false);
findPreference("alteremoji").setVisible(false);
findPreference("dockbareditor").setVisible(false);
}
}
@@ -47,40 +141,80 @@ public class ThemesFragment extends MaterialPreferenceToolbarFragment {
return R.string.vtlthemes;
}
public static class restart implements Preference.OnPreferenceClickListener {
@Override
public boolean onPreferenceClick(Preference preference) {
restartApplicationWithTimer();
return true;
void changeAccent() {
final var titles = AndroidUtils.getArray("accent_select_type");
new VkAlertDialog.Builder(requireContext())
.setTitle(AndroidUtils.getString("change_accent_color"))
.setItems(titles, (dialog, which) -> {
switch(which) {
case 0:
showColorPicker();
break;
case 1:
showPalettesDialog();
break;
}
})
.setNegativeButton(R.string.reset, (dialog, which) -> {
ThemesUtils.setCustomAccentColor(0, false);
LifecycleUtils.restartApplicationWithTimer();
})
.setPositiveButton(R.string.cancel, null)
.show();
}
void showColorPicker() {
final var colorPickerView = new ColorPickerView(requireContext());
colorPickerView.setColor(ThemesUtils.getAccentColor());
var alertDialog = new VkAlertDialog.Builder(requireContext()).create();
alertDialog.setTitle(AndroidUtils.getString("select_color"));
alertDialog.setButton(
DialogInterface.BUTTON_NEGATIVE,
requireContext().getString(R.string.cancel),
(DialogInterface.OnClickListener) null
);
alertDialog.setButton(
DialogInterface.BUTTON_POSITIVE,
requireContext().getString(R.string.select),
(dialog, which) -> setAccentColor(colorPickerView.getColor())
);
alertDialog.setView(colorPickerView);
alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING);
alertDialog.show();
}
void showPalettesDialog() {
final var manager = PalettesManager.getInstance();
final var titles = new String[manager.getPalettesCount()];
if(titles.length > 0) {
for(int i = 0; i < titles.length; ++i)
titles[i] = manager.getPalette(i).name;
new VkAlertDialog.Builder(requireContext())
.setTitle(AndroidUtils.getString("select_palette"))
.setItems(titles, (dialog, which) ->
PalettesBottomSheetDialog.create(requireActivity(), manager.getPalette(which),
(adapter, vtlcolor) -> setAccentColor(vtlcolor.color))
)
.setPositiveButton(R.string.cancel, null)
.show();
}
}
public static class restartlight implements Preference.OnPreferenceChangeListener {
@Override
public boolean onPreferenceChange(Preference preference, Object o) {
edit().putString("lighttheme", o.toString()).commit();
restartApplicationWithTimer();
return false;
}
void setAccentColor(int color) {
ThemesUtils.setCustomAccentColor(color, false);
ThemesCore.setThemedColors(color);
restart();
}
public static class restartdark implements Preference.OnPreferenceChangeListener {
@Override
public boolean onPreferenceChange(Preference preference, Object o) {
edit().putString("darktheme", o.toString()).commit();
restartApplicationWithTimer();
return false;
}
void restart() {
LifecycleUtils.restartApplicationWithTimer();
}
public class openicons implements Preference.OnPreferenceClickListener {
@Override
public boolean onPreferenceClick(Preference preference) {
Context context = requireContext();
Intent a2 = new Navigator(IconsFragment.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(a2);
return true;
}
private void switchFragment(Class< ? extends FragmentImpl > fragmentClz) {
var intent = new Navigator(fragmentClz)
.b(requireContext())
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
requireContext().startActivity(intent);
}
}
@@ -15,8 +15,9 @@ public class VKPayFragment extends FragmentImpl {
public void start() {
VKUIwrapper.setLink("https://vk.com/vkpay");
Intent a2 = new Navigator(VKUIwrapper.class).b(getActivity());
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(a2);
Intent intent = new Navigator(VKUIwrapper.class)
.b(getActivity())
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
}
@@ -1,51 +1,15 @@
package ru.vtosters.lite.ui.fragments;
import static ru.vtosters.lite.ui.PreferencesUtil.addListPreferenceIcon;
import static ru.vtosters.lite.ui.PreferencesUtil.addMaterialSwitchPreference;
import static ru.vtosters.lite.ui.PreferencesUtil.addPreference;
import static ru.vtosters.lite.ui.PreferencesUtil.addPreferenceCategory;
import static ru.vtosters.lite.ui.PreferencesUtil.addPreferenceDrawable;
import static ru.vtosters.lite.utils.About.getBuildNumber;
import static ru.vtosters.lite.utils.About.getCommitLink;
import static ru.vtosters.lite.utils.AccountManagerUtils.getUserPhoto;
import static ru.vtosters.lite.utils.AccountManagerUtils.getUsername;
import static ru.vtosters.lite.utils.AccountManagerUtils.isVKTester;
import static ru.vtosters.lite.utils.AndroidUtils.edit;
import static ru.vtosters.lite.utils.AndroidUtils.getPrefsValue;
import static ru.vtosters.lite.utils.AndroidUtils.isTablet;
import static ru.vtosters.lite.utils.GmsUtils.isGmsInstalled;
import static ru.vtosters.lite.utils.ImageUtils.getDrawableFromUrl;
import static ru.vtosters.lite.utils.Preferences.ads;
import static ru.vtosters.lite.utils.Preferences.autotranslate;
import static ru.vtosters.lite.utils.Preferences.dev;
import static ru.vtosters.lite.utils.Preferences.devmenu;
import static ru.vtosters.lite.utils.Preferences.disableSettingsSumms;
import static ru.vtosters.lite.utils.Preferences.hasSpecialVerif;
import static ru.vtosters.lite.utils.Preferences.isValidSignature;
import static ru.vtosters.lite.utils.Preferences.milkshake;
import static ru.vtosters.lite.utils.Preferences.navbar;
import static ru.vtosters.lite.utils.Preferences.offline;
import static ru.vtosters.lite.utils.Preferences.shortinfo;
import static ru.vtosters.lite.utils.Preferences.stories;
import static ru.vtosters.lite.utils.Preferences.superapp;
import static ru.vtosters.lite.utils.Preferences.vkme;
import static ru.vtosters.lite.utils.ThemesUtils.getDarkTheme;
import static ru.vtosters.lite.utils.ThemesUtils.getLightTheme;
import static ru.vtosters.lite.utils.ThemesUtils.isDarkTheme;
import static ru.vtosters.lite.utils.ThemesUtils.setTheme;
import static ru.vtosters.lite.utils.VTVerifications.vtverif;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import androidx.annotation.StringRes;
import com.aefyr.tsg.g2.TelegramStickersPack;
import com.aefyr.tsg.g2.TelegramStickersService;
import com.vk.about.AboutAppFragment;
import com.vk.balance.BalanceFragment;
import com.vk.core.fragments.FragmentImpl;
import com.vk.navigation.Navigator;
import com.vk.notifications.settings.NotificationsSettingsFragment;
import com.vk.webapp.fragments.PrivacyFragment;
@@ -60,21 +24,20 @@ import com.vtosters.lite.general.fragments.MaterialPreferenceToolbarFragment;
import com.vtosters.lite.general.fragments.SettingsAccountFragment;
import com.vtosters.lite.general.fragments.SettingsGeneralFragment;
import com.vtosters.lite.ui.MaterialSwitchPreference;
import ru.vtosters.lite.concurrent.VTExecutors;
import ru.vtosters.lite.hooks.ui.SystemThemeChangerHook;
import ru.vtosters.lite.ssfs.Utils;
import ru.vtosters.lite.ui.PreferenceFragmentUtils;
import ru.vtosters.lite.ui.components.DockBarEditorManager;
import ru.vtosters.lite.ui.components.SuperAppEditorManager;
import ru.vtosters.lite.ui.dialogs.OTADialog;
import ru.vtosters.lite.ui.fragments.tgstickers.StickersFragment;
import ru.vtosters.lite.utils.AndroidUtils;
import ru.vtosters.lite.utils.SSFSUtils;
import ru.vtosters.lite.utils.ThemesUtils;
import ru.vtosters.lite.utils.*;
public class VTSettings extends MaterialPreferenceToolbarFragment implements TelegramStickersService.StickersEventsListener {
public class VTSettings extends MaterialPreferenceToolbarFragment {
public static String getValAsString(@StringRes int strRes, Boolean value) {
if (disableSettingsSumms()) return null;
if (value) {
if(value) {
return AndroidUtils.getString(strRes) + ": " + AndroidUtils.getString(R.string.vtlsettenabled);
}
@@ -82,44 +45,30 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
}
public static String getSSFSsumm() {
if (disableSettingsSumms()) return null;
if (hasSpecialVerif())
if(Preferences.hasSpecialVerif())
return AndroidUtils.getString(R.string.vtlssfssumm) + ": " + AndroidUtils.getString(R.string.vtlsettverifyes);
return AndroidUtils.getString(R.string.vtlssfssumm) + ": " + AndroidUtils.getString(R.string.vtlsettverifno);
}
public static String getDocksumm() {
if (disableSettingsSumms()) return null;
return AndroidUtils.getString(R.string.vtldocksumm) + ": " + DockBarEditorManager.getInstance().getSelectedTabs().size();
}
public static String getTGSsumm() {
if (disableSettingsSumms()) return null;
return AndroidUtils.getString(R.string.vtltgssumm) + ": " + TelegramStickersService.getInstance(AndroidUtils.getGlobalContext()).getPacksListReference().size();
return AndroidUtils.getString(R.string.vtltgssumm) + ": " + TelegramStickersService.getInstance(AndroidUtils.getGlobalContext()).getActivePacksListReference().size();
}
public static String getProxysumm() {
var type = getPrefsValue("proxy");
var type = AndroidUtils.getPrefsValue("proxy");
if (disableSettingsSumms()) return null;
if (type.equals("noproxy") || type.isEmpty())
if(type.equals("noproxy") || type.isEmpty())
type = AndroidUtils.getString(R.string.vtlsettdisabled);
return AndroidUtils.getString(R.string.vtlproxysumm) + ": " + type;
}
public static String getThemesumm() {
if (disableSettingsSumms()) return null;
String str;
String[] themeTypeName = AndroidUtils.getArray("theme_type_name");
switch (getPrefsValue("currsystemtheme")) {
switch(AndroidUtils.getPrefsValue("currsystemtheme")) {
default:
case "system":
str = themeTypeName[0];
@@ -135,343 +84,504 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
return AndroidUtils.getString("current_theme") + ": " + str;
}
public static String getSuperappsumm() {
if (disableSettingsSumms()) return null;
return AndroidUtils.getString(R.string.elements_hidden_count) + ": " + SuperAppEditorManager.getInstance().getDisabledTabs().size();
private void switchTheme(boolean isDarkTheme) {
ThemesUtils.setTheme(isDarkTheme ? ThemesUtils.getDarkTheme() : ThemesUtils.getLightTheme(), requireActivity());
}
private void switchTheme(boolean isDarkTheme) {
setTheme(isDarkTheme ? getDarkTheme() : getLightTheme(), requireActivity());
@Override
public void onPackAdded(TelegramStickersPack pack, int atIndex) {
}
@Override
public void onPackRemoved(TelegramStickersPack pack, int atIndex) {
}
@Override
public void onPackChanged(TelegramStickersPack pack, int atIndex) {
}
@Override
public void onPackDownloadError(TelegramStickersPack pack, Exception error) {
}
@Override
public void onActivePacksListChanged() {
findPreference("tgs_stickers").setSummary(getTGSsumm());
}
@Override
public void onInactivePacksListChanged() {
}
@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
var feedsumm = getValAsString(R.string.vtlfeedsumm, ads());
var docksumm = getDocksumm();
var msgsumm = isTablet() ? getValAsString(R.string.autotranslate_title, autotranslate()) : getValAsString(R.string.vtlmsgsumm, vkme());
var activitysumm = getValAsString(R.string.vtlactivitysumm, offline());
var themessumm = getValAsString(R.string.vtlthemessumm, navbar());
var tgssumm = getTGSsumm();
var superapp = getSuperappsumm();
var mediasumm = getValAsString(R.string.vtlinterfacesumm, shortinfo());
var interfacesumm = getValAsString(R.string.showstories, stories());
var proxysumm = getProxysumm();
var othersumm = getValAsString(R.string.vtlothersumm, vtverif());
var ssfs = getSSFSsumm();
var about = "Commit: " + getBuildNumber();
TelegramStickersService.getInstance(requireContext()).addStickersEventsListener(this);
this.addPreferencesFromResource(R.xml.empty);
addPreferenceDrawable(this, "", getUsername(), requireContext().getString(R.string.vtllogout), getDrawableFromUrl(getUserPhoto(), R.drawable.ic_user_circle_outline_28, true, true), preference -> {
try {
VKAuth.a("logout", false);
} catch (Exception ignored) {
}
var accountSwitcher = PreferenceFragmentUtils.addPreference(
getPreferenceScreen(),
"account_switcher",
AccountManagerUtils.getUsername(),
requireContext().getString(R.string.vtllogout),
requireContext().getDrawable(R.drawable.ic_user_circle_outline_28),
preference -> {
try {
VKAuth.a("logout", false);
} catch(Exception ignored) {
}
var intent = new Intent(requireContext(), MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
requireContext().startActivity(intent);
var intent = new Intent(requireContext(), MainActivity.class)
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
requireContext().startActivity(intent);
return false;
return false;
});
VTExecutors.getIoScheduler().a(() -> {
var icon = ImageUtils.getDrawableFromUrl(AccountManagerUtils.getUserPhoto(), 0, true, true);
if(icon == null) return;
requireActivity().runOnUiThread(() -> {
accountSwitcher.setIcon(icon);
});
});
addPreference(this, "", requireContext().getString(R.string.vtssfs), ssfs, R.drawable.ic_link_circle_outline_28, preference -> {
Context context = requireContext();
VKUIwrapper.setLink(SSFSUtils.getSSFSLink());
Intent a2 = new Navigator(VKUIwrapper.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(a2);
return false;
});
PreferenceFragmentUtils.addPreference(
getPreferenceScreen(),
"",
requireContext().getString(R.string.vtssfs),
getSSFSsumm(),
R.drawable.ic_link_circle_outline_28,
preference -> {
VKUIwrapper.setLink(Utils.getVKUILink());
launchFragment(VKUIwrapper.class);
return false;
}
);
addPreferenceCategory(this, requireContext().getString(R.string.appearance_theme_use_system));
PreferenceFragmentUtils.addPreferenceCategory(getPreferenceScreen(), R.string.appearance_theme_use_system);
if (Build.VERSION.SDK_INT >= 28 && milkshake()) {
addListPreferenceIcon(
this,
if(Build.VERSION.SDK_INT >= 28 && Preferences.milkshake()) {
PreferenceFragmentUtils.addListPreference(
getPreferenceScreen(),
"currsystemtheme",
"system",
requireContext().getString(R.string.appearance_theme_use_system),
R.drawable.ic_palette_outline_28, getThemesumm(),
R.drawable.ic_palette_outline_28,
getThemesumm(),
AndroidUtils.getArray("theme_type_name_checkbox"),
new String[]{"system", "dark", "light"},
new String[] { "system", "dark", "light" },
(preference, o) -> {
String value = (String) o;
if (!value.equals("system")) {
if(!value.equals("system")) {
var theme = value.equals("dark") ? ThemesUtils.getDarkTheme() : ThemesUtils.getLightTheme();
ThemesUtils.applyTheme(theme);
}
edit().putString("currsystemtheme", value).commit();
AndroidUtils.edit().putString("currsystemtheme", value).commit();
SystemThemeChangerHook.onThemeChanged(getResources().getConfiguration());
return true;
});
} else {
addMaterialSwitchPreference(this, "", requireContext().getString(R.string.vtsettdarktheme), "", R.drawable.ic_palette_outline_28, isDarkTheme(), (preference, o) -> {
final var switchPreference = (MaterialSwitchPreference) preference;
final var isDarkTheme = !switchPreference.isChecked();
switchTheme(isDarkTheme);
return true;
});
}
if (!isGmsInstalled()) {
addPreferenceCategory(this, requireContext().getString(R.string.gmsname));
addPreference(this, "", requireContext().getString(R.string.installgms), "", R.drawable.ic_about_outline_28, preference -> {
Context context = requireContext();
Intent a2 = new Navigator(InstallGMSFragment.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(a2);
return false;
});
}
if (devmenu()) {
addPreferenceCategory(this, requireContext().getString(R.string.sett_debug));
addPreference(this, "", requireContext().getString(R.string.sett_debug), "", R.drawable.ic_bug_outline_28, preference -> {
Context context = requireContext();
Intent a2 = new Navigator(SettingsDebugFragment.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(a2);
return false;
});
addMaterialSwitchPreference(this, "ssl", requireContext().getString(R.string.debug_developer_force_ssl), requireContext().getString(R.string.debug_developer_force_ssl_summary), R.drawable.ic_globe_outline_28, true, (preference, o) -> {
boolean value = (boolean) o;
edit().putBoolean("ssl", value).commit();
return true;
});
if (dev() && isValidSignature()) {
addMaterialSwitchPreference(this, "autoupdates", requireContext().getString(R.string.checkupdates), "", R.drawable.ic_camera_switch_outline_24, true, (preference, o) -> {
boolean value = (boolean) o;
edit().putBoolean("autoupdates", value).commit();
return true;
});
}
}
addPreferenceCategory(this, requireContext().getString(R.string.vtsettaccount));
addPreference(this, "", requireContext().getString(R.string.vkconnect), "", R.drawable.ic_user_circle_outline_28, preference -> {
Context context = requireContext();
VKUIwrapper.officalLinks("account");
Intent a2 = new Navigator(VKUIwrapper.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(a2);
return false;
});
addPreference(this, "", requireContext().getString(R.string.privacy_settings), "", R.drawable.ic_privacy_outline_28, preference -> {
Context context = requireContext();
Intent a2 = new Navigator(PrivacyFragment.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(a2);
return false;
});
addPreference(this, "", requireContext().getString(R.string.sett_account), "", R.drawable.ic_user_outline_28, preference -> {
Context context = requireContext();
Intent a2 = new Navigator(SettingsAccountFragment.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(a2);
return false;
});
if (isVKTester()) {
addPreference(this, "", requireContext().getString(R.string.bugs), "", R.drawable.ic_bug_outline_28, preference -> {
Context context = requireContext();
VKUIwrapper.officalLinks("bugs");
Intent a2 = new Navigator(VKUIwrapper.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(a2);
return false;
});
}
addPreferenceCategory(this, requireContext().getString(R.string.vtlvksettings));
addPreference(this, "", requireContext().getString(R.string.sett_general), "", R.drawable.ic_settings_outline_28, preference -> {
Context context = requireContext();
Intent a2 = new Navigator(SettingsGeneralFragment.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(a2);
return false;
});
addPreference(this, "", requireContext().getString(R.string.blacklist), "", R.drawable.ic_users_outline_28, preference -> {
Context context = requireContext();
Intent a2 = new Navigator(BlacklistFragment.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(a2);
return false;
});
addPreference(this, "", requireContext().getString(R.string.sett_notifications), "", R.drawable.ic_menu_notification_outline_28, preference -> {
Context context = requireContext();
Intent a2 = new Navigator(NotificationsSettingsFragment.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(a2);
return false;
});
if (VKAccountManager.d().isMusicSubs()) {
addPreference(this, "", requireContext().getString(R.string.subscription_music), "", R.drawable.ic_music_outline_28, preference -> {
Context context = requireContext();
Intent a2 = new Navigator(MusicSubscriptionControlFragment.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(a2);
return false;
});
}
addPreference(this, "", requireContext().getString(R.string.votes), "", R.drawable.ic_coins_outline_28, preference -> {
Context context = requireContext();
Intent a2 = new Navigator(BalanceFragment.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(a2);
return false;
});
addPreferenceCategory(this, requireContext().getString(R.string.vtsettmod));
if (vkme()) {
addPreference(this, "", requireContext().getString(R.string.warning), requireContext().getString(R.string.vkme_mode_info), R.drawable.ic_about_outline_28, preference -> false);
} else {
addPreference(this, "", requireContext().getString(R.string.vtlfeed), feedsumm, R.drawable.ic_newsfeed_outline_28, preference -> {
Context context = requireContext();
Intent a2 = new Navigator(FeedFragment.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(a2);
return false;
});
}
addPreference(this, "", requireContext().getString(R.string.vtlmedia), mediasumm, R.drawable.ic_media_outline_28, preference -> {
Context context = requireContext();
Intent a2 = new Navigator(MediaFragment.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(a2);
return false;
});
addPreference(this, "", requireContext().getString(R.string.vtlmessages), msgsumm, R.drawable.ic_message_outline_28, preference -> {
Context context = requireContext();
Intent a2 = new Navigator(MessagesFragment.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(a2);
return false;
});
addPreference(this, "", requireContext().getString(R.string.vtltgs), tgssumm, R.drawable.ic_telegram_outline_28, preference -> {
Context context = requireContext();
Intent a2 = new Navigator(StickersFragment.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(a2);
return false;
});
addPreference(this, "", requireContext().getString(R.string.vtlthemes), themessumm, R.drawable.ic_write_outline_28, preference -> {
Context context = requireContext();
Intent a2 = new Navigator(ThemesFragment.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(a2);
return false;
});
addPreference(this, "", requireContext().getString(R.string.vtlinterface), interfacesumm, R.drawable.ic_interface_outline_28, preference -> {
Context context = requireContext();
Intent a2 = new Navigator(InterfaceFragment.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(a2);
return false;
});
if (!vkme()) {
if (!isTablet()) {
addPreference(this, "", requireContext().getString(R.string.dockbar_editor), docksumm, R.drawable.ic_list_outline_28, preference -> {
Context context = requireContext();
Intent intent = new Navigator(DockBarEditorFragment.class).b(context);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
return false;
});
if (milkshake() && superapp()) {
addPreference(this, "", requireContext().getString(R.string.superapp_editor), superapp, R.drawable.ic_services_outline_28, (preference) -> {
Context context = requireContext();
Intent intent = new Navigator(SuperAppEditorFragment.class).b(context);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
PreferenceFragmentUtils.addMaterialSwitchPreference(
getPreferenceScreen(),
"",
requireContext().getString(R.string.vtsettdarktheme),
"",
R.drawable.ic_palette_outline_28,
ThemesUtils.isDarkTheme(),
(preference, o) -> {
final var switchPreference = (MaterialSwitchPreference) preference;
final var isDarkTheme = !switchPreference.isChecked();
switchTheme(isDarkTheme);
return true;
});
}
}
);
}
if(!GmsUtils.isGmsInstalled()) {
PreferenceFragmentUtils.addPreferenceCategory(getPreferenceScreen(), R.string.gmsname);
PreferenceFragmentUtils.addPreference(
getPreferenceScreen(),
"",
requireContext().getString(R.string.installgms),
"",
R.drawable.ic_about_outline_28,
preference -> {
launchFragment(InstallGMSFragment.class);
return false;
}
);
}
if(Preferences.devmenu()) {
PreferenceFragmentUtils.addPreferenceCategory(getPreferenceScreen(), R.string.sett_debug);
PreferenceFragmentUtils.addPreference(
getPreferenceScreen(),
"",
requireContext().getString(R.string.sett_debug),
"",
R.drawable.ic_bug_outline_28,
preference -> {
launchFragment(SettingsDebugFragment.class);
return false;
}
);
PreferenceFragmentUtils.addMaterialSwitchPreference(
getPreferenceScreen(),
"ssl",
requireContext().getString(R.string.debug_developer_force_ssl),
requireContext().getString(R.string.debug_developer_force_ssl_summary),
R.drawable.ic_globe_outline_28,
true,
(preference, o) -> {
AndroidUtils.edit().putBoolean("ssl", (boolean) o).commit();
return true;
}
);
if(Preferences.dev() && Preferences.isValidSignature()) {
PreferenceFragmentUtils.addMaterialSwitchPreference(
getPreferenceScreen(),
"autoupdates",
requireContext().getString(R.string.checkupdates),
"",
R.drawable.ic_bug_outline_28,
true,
(preference, o) -> {
boolean value = (boolean) o;
AndroidUtils.edit().putBoolean("autoupdates", value).commit();
return true;
}
);
}
}
addPreference(this, "", requireContext().getString(R.string.vtlactivity), activitysumm, R.drawable.ic_write_outline_28_new_accent, preference -> {
Context context = requireContext();
Intent a2 = new Navigator(ActivityFragment.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(a2);
return false;
});
PreferenceFragmentUtils.addPreferenceCategory(getPreferenceScreen(), R.string.vtsettaccount);
addPreference(this, "", requireContext().getString(R.string.vtlproxy), proxysumm, R.drawable.ic_globe_outline_28, preference -> {
Context context = requireContext();
Intent a2 = new Navigator(ProxySettingsFragment.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(a2);
return false;
});
PreferenceFragmentUtils.addPreference(
getPreferenceScreen(),
"",
requireContext().getString(R.string.vkconnect),
"",
R.drawable.ic_user_circle_outline_28,
preference -> {
VKUIwrapper.officalLinks("account");
launchFragment(VKUIwrapper.class);
return false;
}
);
addPreference(this, "", requireContext().getString(R.string.vtlother), othersumm, R.drawable.ic_more_horizontal_28, preference -> {
Context context = requireContext();
Intent a2 = new Navigator(OtherFragment.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(a2);
return false;
});
PreferenceFragmentUtils.addPreference(
getPreferenceScreen(),
"",
requireContext().getString(R.string.privacy_settings),
"",
R.drawable.ic_privacy_outline_28,
preference -> {
launchFragment(PrivacyFragment.class);
return false;
}
);
addPreferenceCategory(this, requireContext().getString(R.string.vtsettaboutmod));
PreferenceFragmentUtils.addPreference(
getPreferenceScreen(),
"",
requireContext().getString(R.string.sett_account),
"",
R.drawable.ic_user_outline_28,
preference -> {
launchFragment(SettingsAccountFragment.class);
return false;
}
);
addPreference(this, "", requireContext().getString(R.string.menu_about), about, R.drawable.ic_about_outline_28, preference -> {
Context context = requireContext();
Intent a2 = new Navigator(AboutAppFragment.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(a2);
return false;
});
addPreference(this, "", requireContext().getString(R.string.opencommit), "", R.drawable.ic_link_outline_28, preference -> {
requireContext().startActivity(new Intent("android.intent.action.VIEW").setData(Uri.parse(getCommitLink())));
return false;
});
addPreference(this, "", requireContext().getString(R.string.vtfaq), requireContext().getString(R.string.vtfaqsumm), R.drawable.ic_help_outline_28, preference -> {
requireContext().startActivity(new Intent("android.intent.action.VIEW").setData(Uri.parse("https://t.me/s/vtosters_faq")));
return false;
});
addPreference(this, "", requireContext().getString(R.string.reportbug), requireContext().getString(R.string.reportbugsumm), R.drawable.ic_bug_outline_28, preference -> {
requireContext().startActivity(new Intent("android.intent.action.VIEW").setData(Uri.parse("https://github.com/vtosters/lite/issues")));
return false;
});
if (isValidSignature()) {
addPreferenceCategory(this, requireContext().getString(R.string.updates));
addPreference(this, "", requireContext().getString(R.string.checkforupdates), "", R.drawable.ic_download_outline_28, preference -> {
OTADialog.checkUpdates(getActivity());
return false;
});
if(AccountManagerUtils.isVKTester()) {
PreferenceFragmentUtils.addPreference(
getPreferenceScreen(),
"",
requireContext().getString(R.string.bugs),
"",
R.drawable.ic_bug_outline_28,
preference -> {
VKUIwrapper.officalLinks("bugs");
launchFragment(VKUIwrapper.class);
return false;
}
);
}
PreferenceFragmentUtils.addPreferenceCategory(getPreferenceScreen(), requireContext().getString(R.string.vtlvksettings));
PreferenceFragmentUtils.addPreference(
getPreferenceScreen(),
"",
requireContext().getString(R.string.sett_general),
"",
R.drawable.ic_settings_outline_28,
preference -> {
launchFragment(SettingsGeneralFragment.class);
return false;
}
);
PreferenceFragmentUtils.addPreference(
getPreferenceScreen(),
"",
requireContext().getString(R.string.blacklist),
"",
R.drawable.ic_users_outline_28,
preference -> {
launchFragment(BlacklistFragment.class);
return false;
}
);
PreferenceFragmentUtils.addPreference(
getPreferenceScreen(),
"",
requireContext().getString(R.string.sett_notifications),
"",
R.drawable.ic_menu_notification_outline_28,
preference -> {
launchFragment(NotificationsSettingsFragment.class);
return false;
}
);
if(VKAccountManager.d().isMusicSubs()) {
PreferenceFragmentUtils.addPreference(
getPreferenceScreen(),
"",
requireContext().getString(R.string.subscription_music),
"",
R.drawable.ic_music_outline_28,
preference -> {
launchFragment(MusicSubscriptionControlFragment.class);
return false;
}
);
}
PreferenceFragmentUtils.addPreference(
getPreferenceScreen(),
"",
requireContext().getString(R.string.votes),
"",
R.drawable.ic_coins_outline_28,
preference -> {
launchFragment(BalanceFragment.class);
return false;
}
);
PreferenceFragmentUtils.addPreferenceCategory(getPreferenceScreen(), requireContext().getString(R.string.vtsettmod));
if(Preferences.vkme()) {
PreferenceFragmentUtils.addPreference(
getPreferenceScreen(),
"",
requireContext().getString(R.string.warning),
requireContext().getString(R.string.vkme_mode_info),
R.drawable.ic_about_outline_28,
preference -> false
);
} else {
PreferenceFragmentUtils.addPreference(
getPreferenceScreen(),
"",
requireContext().getString(R.string.vtlfeed),
getValAsString(R.string.vtlfeedsumm, Preferences.ads()),
R.drawable.ic_newsfeed_outline_28,
preference -> {
launchFragment(FeedFragment.class);
return false;
}
);
}
PreferenceFragmentUtils.addPreference(
getPreferenceScreen(),
"",
requireContext().getString(R.string.vtlmedia),
getValAsString(R.string.vtlinterfacesumm, Preferences.shortinfo()),
R.drawable.ic_media_outline_28,
preference -> {
launchFragment(MediaFragment.class);
return false;
}
);
PreferenceFragmentUtils.addPreference(
getPreferenceScreen(),
"",
requireContext().getString(R.string.vtlmessages),
AndroidUtils.isTablet()
? getValAsString(R.string.autotranslate_title, Preferences.autotranslate())
: getValAsString(R.string.vtlmsgsumm, Preferences.vkme()),
R.drawable.ic_message_outline_28,
preference -> {
launchFragment(MessagesFragment.class);
return false;
}
);
PreferenceFragmentUtils.addPreference(
getPreferenceScreen(),
"tgs_stickers",
requireContext().getString(R.string.vtltgs),
getTGSsumm(),
R.drawable.ic_telegram_outline_28,
preference -> {
launchFragment(StickersFragment.class);
return false;
}
);
PreferenceFragmentUtils.addPreference(
getPreferenceScreen(),
"",
requireContext().getString(R.string.vtlthemes),
getThemesumm(),
R.drawable.ic_write_outline_28,
preference -> {
launchFragment(ThemesFragment.class);
return false;
}
);
PreferenceFragmentUtils.addPreference(
getPreferenceScreen(),
"",
requireContext().getString(R.string.vtlinterface),
getValAsString(R.string.showstories, Preferences.stories()),
R.drawable.ic_interface_outline_28,
preference -> {
launchFragment(InterfaceFragment.class);
return false;
}
);
PreferenceFragmentUtils.addPreference(
getPreferenceScreen(),
"",
requireContext().getString(R.string.vtlactivity),
getValAsString(R.string.vtlactivitysumm, Preferences.offline()),
R.drawable.ic_write_outline_28_new_accent,
preference -> {
launchFragment(ActivityFragment.class);
return false;
}
);
PreferenceFragmentUtils.addPreference(
getPreferenceScreen(),
"",
requireContext().getString(R.string.vtlproxy),
getProxysumm(),
R.drawable.ic_globe_outline_28,
preference -> {
launchFragment(ProxySettingsFragment.class);
return false;
}
);
PreferenceFragmentUtils.addPreference(
getPreferenceScreen(),
"",
requireContext().getString(R.string.vtlother),
getValAsString(R.string.vtlothersumm, VTVerifications.vtverif()),
R.drawable.ic_more_horizontal_28,
preference -> {
launchFragment(OtherFragment.class);
return false;
}
);
PreferenceFragmentUtils.addPreferenceCategory(getPreferenceScreen(), requireContext().getString(R.string.vtsettaboutmod));
PreferenceFragmentUtils.addPreference(
getPreferenceScreen(),
"",
requireContext().getString(R.string.menu_about),
"Commit: " + About.getBuildNumber(),
R.drawable.ic_about_outline_28,
preference -> {
launchFragment(AboutAppFragment.class);
return false;
}
);
PreferenceFragmentUtils.addPreference(
getPreferenceScreen(),
"",
requireContext().getString(R.string.opencommit),
"",
R.drawable.ic_link_outline_28,
preference -> {
requireContext().startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse(About.getCommitLink())));
return false;
}
);
PreferenceFragmentUtils.addPreference(
getPreferenceScreen(),
"",
requireContext().getString(R.string.vtfaq),
requireContext().getString(R.string.vtfaqsumm),
R.drawable.ic_help_outline_28,
preference -> {
requireContext().startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse("https://t.me/s/vtosters_faq")));
return false;
}
);
PreferenceFragmentUtils.addPreference(
getPreferenceScreen(),
"",
requireContext().getString(R.string.reportbug),
requireContext().getString(R.string.reportbugsumm),
R.drawable.ic_bug_outline_28,
preference -> {
requireContext().startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse("https://github.com/vtosters/lite/issues")));
return false;
}
);
if(Preferences.isValidSignature()) {
PreferenceFragmentUtils.addPreferenceCategory(getPreferenceScreen(), requireContext().getString(R.string.updates));
PreferenceFragmentUtils.addPreference(
getPreferenceScreen(),
"",
requireContext().getString(R.string.checkforupdates),
"",
R.drawable.ic_download_outline_28,
preference -> {
OTADialog.checkUpdates(getActivity());
return false;
}
);
}
}
private void launchFragment(Class< ? extends FragmentImpl > fragmentClz) {
Intent intent = new Navigator(fragmentClz)
.b(requireContext())
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
requireContext().startActivity(intent);
}
@Override
@@ -483,4 +593,10 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
public int T4() {
return R.string.notification_settings;
}
@Override
public void onDestroyView() {
super.onDestroyView();
TelegramStickersService.getInstance(requireContext()).removeStickersEventsListener(this);
}
}
@@ -1,51 +1,37 @@
package ru.vtosters.lite.ui.fragments.tgstickers;
import static android.widget.Toast.LENGTH_SHORT;
import static android.widget.Toast.makeText;
import static ru.vtosters.lite.tgs.TGPref.setTGBotKey;
import static ru.vtosters.lite.utils.AndroidUtils.dp2px;
import static ru.vtosters.lite.utils.AndroidUtils.sendToast;
import static ru.vtosters.lite.utils.ThemesUtils.getAccentColor;
import static ru.vtosters.lite.utils.ThemesUtils.getSTextAttr;
import android.annotation.SuppressLint;
import android.app.ProgressDialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.ColorStateList;
import android.net.Uri;
import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.*;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.ItemTouchHelper;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;
import com.aefyr.tsg.g2.TelegramStickersService;
import com.aefyr.tsg.g2.stickersgrabber.TelegramStickersGrabber;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.vk.core.dialogs.alert.VkAlertDialog;
import com.vk.navigation.Navigator;
import com.vtosters.lite.R;
import java.io.File;
import ru.vtosters.lite.tgs.TGPref;
import ru.vtosters.lite.ui.adapters.StickerPackAdapter;
import ru.vtosters.lite.ui.components.StickerTouchHelperCallback;
import ru.vtosters.lite.ui.fragments.BaseToolbarFragment;
import ru.vtosters.lite.utils.AndroidUtils;
import ru.vtosters.lite.utils.ThemesUtils;
import java.io.File;
public class StickersFragment extends BaseToolbarFragment {
public final static String ACTION_RELOAD = "com.vtosters.lite.action.RELOAD_TGS_LIST";
@@ -83,8 +69,8 @@ public class StickersFragment extends BaseToolbarFragment {
@Override
protected void onCreateMenu(Menu menu) {
var item = menu.add(0, 0, 0, "");
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
item.setIcon(R.drawable.ic_settings_24);
item.setIcon(ThemesUtils.recolorDrawable(AndroidUtils.getGlobalContext().getDrawable(R.drawable.ic_settings_24)))
.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
super.onCreateMenu(menu);
}
@@ -97,30 +83,30 @@ public class StickersFragment extends BaseToolbarFragment {
private void openMenu(String toast) {
if (toast != null) {
makeText(getContext(), toast, LENGTH_SHORT).show();
Toast.makeText(requireContext(), toast, Toast.LENGTH_SHORT).show();
}
var intent = new Navigator(StickersPreferencesFragment.class, new Bundle()).b(getContext());
var intent = new Navigator(StickersPreferencesFragment.class, new Bundle()).b(requireContext());
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
super.getContext().startActivity(intent);
super.requireContext().startActivity(intent);
}
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getContext().registerReceiver(mReceiver, new IntentFilter(ACTION_RELOAD));
requireContext().registerReceiver(mReceiver, new IntentFilter(ACTION_RELOAD));
mGrabber = new TelegramStickersGrabber(TGPref.getTGBotKey());
mService = TelegramStickersService.getInstance(getContext());
mService = TelegramStickersService.getInstance(requireContext());
}
@Override
public View onCreateContent(@NonNull LayoutInflater inflater, @Nullable Bundle bundle) {
setTitle(R.string.vtltgs);
FrameLayout layout = new FrameLayout(getContext());
FrameLayout layout = new FrameLayout(requireContext());
mAdapter = new StickerPackAdapter();
RecyclerView mRecycler = new RecyclerView(getContext());
RecyclerView mRecycler = new RecyclerView(requireContext());
var callback = new StickerTouchHelperCallback(mAdapter);
var touchHelper = new ItemTouchHelper(callback);
@@ -130,14 +116,14 @@ public class StickersFragment extends BaseToolbarFragment {
mRecycler.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
layout.addView(mRecycler, new ViewGroup.LayoutParams(-1, -1));
FloatingActionButton mAddStickerPack = new FloatingActionButton(getContext());
FloatingActionButton mAddStickerPack = new FloatingActionButton(requireContext());
mAddStickerPack.setImageResource(R.drawable.ic_add_24);
mAddStickerPack.setBackgroundTintList(ColorStateList.valueOf(getAccentColor()));
mAddStickerPack.setBackgroundTintList(ThemesUtils.getAccenedColorStateList());
mAddStickerPack.setOnClickListener(v2 -> fabClick());
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(-2, -2);
params.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
params.setMargins(0, 0, 0, dp2px(12f));
params.setMargins(0, 0, 0, AndroidUtils.dp2px(12f));
layout.addView(mAddStickerPack, params);
return layout;
@@ -169,19 +155,19 @@ public class StickersFragment extends BaseToolbarFragment {
}
} else if (method == TYPE_DIRECT) {
final Runnable callback = () -> {
LinearLayout linearLayout = new LinearLayout(getContext());
LinearLayout linearLayout = new LinearLayout(requireContext());
final EditText editText = new EditText(getContext());
editText.setHintTextColor(getSTextAttr());
editText.setBackgroundTintList(ColorStateList.valueOf(getAccentColor()));
final EditText editText = new EditText(requireContext());
editText.setHintTextColor(ThemesUtils.getSTextAttr());
editText.setBackgroundTintList(ThemesUtils.getAccenedColorStateList());
linearLayout.addView(editText);
editText.getLayoutParams().width = ViewGroup.LayoutParams.MATCH_PARENT;
ViewGroup.MarginLayoutParams margin = ((ViewGroup.MarginLayoutParams) editText.getLayoutParams());
margin.setMargins(dp2px(24f), 0, dp2px(24f), 0);
margin.setMargins(AndroidUtils.dp2px(24f), 0, AndroidUtils.dp2px(24f), 0);
editText.setLayoutParams(margin);
new VkAlertDialog.Builder(getContext())
new VkAlertDialog.Builder(requireContext())
.setTitle(requireContext().getString(R.string.stickershelp1))
.setMessage(requireContext().getString(R.string.stickershelp2))
.setView(linearLayout)
@@ -190,10 +176,10 @@ public class StickersFragment extends BaseToolbarFragment {
if (!pack.startsWith("https://")) {
pack = "https://" + pack;
} else if (!pack.contains("addstickers")) {
sendToast(AndroidUtils.getString("invalid_pack_link"));
AndroidUtils.sendToast(AndroidUtils.getString("invalid_pack_link"));
}
pack = parsePack(pack);
mService.requestPackDownload(pack, new File(getContext().getFilesDir(), new File("VT-Stickers", pack).getAbsolutePath()));
mService.requestPackDownload(pack, new File(requireContext().getFilesDir(), new File("VT-Stickers", pack).getAbsolutePath()));
})
.setNeutralButton(android.R.string.cancel,
(dialog, which) -> dialog.dismiss()
@@ -227,34 +213,39 @@ public class StickersFragment extends BaseToolbarFragment {
}
private void enterBotKey(Runnable r) {
LinearLayout linearLayout = new LinearLayout(getContext());
LinearLayout linearLayout = new LinearLayout(requireContext());
final EditText editText = new EditText(getContext());
editText.setHintTextColor(getSTextAttr());
editText.setBackgroundTintList(ColorStateList.valueOf(getAccentColor()));
final EditText editText = new EditText(requireContext());
editText.setHintTextColor(ThemesUtils.getSTextAttr());
editText.setBackgroundTintList(ThemesUtils.getAccenedColorStateList());
linearLayout.addView(editText);
editText.getLayoutParams().width = ViewGroup.LayoutParams.MATCH_PARENT;
ViewGroup.MarginLayoutParams margin = ((ViewGroup.MarginLayoutParams) editText.getLayoutParams());
margin.setMargins(dp2px(24f), 0, dp2px(24f), 0);
margin.setMargins(AndroidUtils.dp2px(24f), 0, AndroidUtils.dp2px(24f), 0);
editText.setLayoutParams(margin);
new VkAlertDialog.Builder(getContext())
new VkAlertDialog.Builder(requireContext())
.setTitle(requireContext().getString(R.string.stickersapi5))
.setMessage(requireContext().getString(R.string.stickersapi6))
.setView(linearLayout)
.setPositiveButton(android.R.string.ok, (dialog, which) -> {
setTGBotKey(editText.getText().toString());
TGPref.setTGBotKey(editText.getText().toString());
if (r != null) r.run();
})
.setNegativeButton(android.R.string.cancel,
(dialog, which) -> dialog.dismiss()
)
.setNeutralButton(requireContext().getString(R.string.stickersapi7),
(dialog, which) -> new VkAlertDialog.Builder(getContext())
(dialog, which) -> new VkAlertDialog.Builder(requireContext())
.setTitle(requireContext().getString(R.string.stickersapi8))
.setMessage(requireContext().getString(R.string.stickersapi9) +
requireContext().getString(R.string.stickersapi10))
.setNeutralButton(AndroidUtils.getString("open_bot"), (dl, i) -> {
var intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://t.me/botfather"));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
requireActivity().startActivity(intent);
})
.setPositiveButton(android.R.string.ok, null)
.show()
)
@@ -264,7 +255,7 @@ public class StickersFragment extends BaseToolbarFragment {
private void checkApiKey(Runnable callback) {
mGrabber.setBotApiKey(TGPref.getTGBotKey());
var context = getContext();
var context = requireContext();
final ProgressDialog progressDialog = new ProgressDialog(context);
progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
@@ -276,8 +267,8 @@ public class StickersFragment extends BaseToolbarFragment {
public void onKeyChecked(boolean ok) {
progressDialog.dismiss();
if (!ok) {
makeText(context, requireContext().getString(R.string.stickersapi2), LENGTH_SHORT).show();
setTGBotKey(null);
Toast.makeText(context, requireContext().getString(R.string.stickersapi2), Toast.LENGTH_SHORT).show();
TGPref.setTGBotKey(null);
return;
}
mService.setBotKey(TGPref.getTGBotKey());
@@ -1,15 +1,13 @@
package ru.vtosters.lite.ui.fragments.tgstickers;
import android.os.Bundle;
import com.aefyr.tsg.g2.stickersgrabber.TelegramStickersGrabber;
import com.vk.core.util.ToastUtils;
import com.vtosters.lite.R;
import com.vtosters.lite.general.fragments.MaterialPreferenceToolbarFragment;
import ru.vtosters.lite.tgs.TGPref;
import ru.vtosters.lite.tgs.TGRoot;
import ru.vtosters.lite.ui.PreferencesUtil;
import ru.vtosters.lite.ui.PreferenceFragmentUtils;
public class StickersPreferencesFragment extends MaterialPreferenceToolbarFragment {
@@ -20,17 +18,17 @@ public class StickersPreferencesFragment extends MaterialPreferenceToolbarFragme
int vtosterXml = R.xml.empty;
addPreferencesFromResource(vtosterXml);
PreferencesUtil.addPreferenceCategory(this, requireContext().getString(R.string.sprefsstickers));
PreferencesUtil.addPreference(this, "", requireContext().getString(R.string.sprefsdelkey), "", 0, preference -> {
PreferenceFragmentUtils.addPreferenceCategory(getPreferenceScreen(), requireContext().getString(R.string.sprefsstickers));
PreferenceFragmentUtils.addPreference(getPreferenceScreen(), "", R.string.sprefsdelkey, 0, 0, preference -> {
TGPref.setTGBotKey(null);
ToastUtils.a(requireContext().getString(R.string.sprefsdelkey2));
return false;
});
PreferencesUtil.addPreferenceCategory(this, requireContext().getString(R.string.sprefsnetwork));
PreferencesUtil.addListPreference(this, "VTGS:CM", "0", requireContext().getString(R.string.sprefsctype), new CharSequence[]{
PreferenceFragmentUtils.addPreferenceCategory(getPreferenceScreen(), requireContext().getString(R.string.sprefsnetwork));
PreferenceFragmentUtils.addListPreference(getPreferenceScreen(), "VTGS:CM", "0", requireContext().getString(R.string.sprefsctype), new CharSequence[] {
requireContext().getString(R.string.ctypedirect), requireContext().getString(R.string.ctypesocks)
}, new String[]{
}, new String[] {
"0", "2"
});
@@ -40,40 +38,40 @@ public class StickersPreferencesFragment extends MaterialPreferenceToolbarFragme
String newData = (String) o;
TGPref.setTGConnectMethod(Integer.parseInt(newData));
TelegramStickersGrabber.updateURLs();
preference.setTitle(TGRoot.getSummary()); // setTitle
preference.setTitle(TGRoot.getSummary());
return true;
});
PreferencesUtil.addPreferenceCategory(this, requireContext().getString(R.string.ssocks));
PreferenceFragmentUtils.addPreferenceCategory(getPreferenceScreen(), R.string.ssocks);
PreferencesUtil.addEditTextPreference(this, "tg_proxy_host", requireContext().getString(R.string.ssockshost), (preference, o) -> {
TGPref.setTGProxyIP((String) o);
PreferenceFragmentUtils.addEditTextPreference(getPreferenceScreen(), "tg_proxy_host", R.string.ssockshost, (preference, o) -> {
TGPref.setTGProxyIP(o);
return true;
});
PreferencesUtil.addEditTextPreference(this, "tg_proxy_port", requireContext().getString(R.string.ssocksport), (preference, o) -> {
PreferenceFragmentUtils.addEditTextPreference(getPreferenceScreen(), "tg_proxy_port", R.string.ssocksport, (preference, o) -> {
try {
TGPref.setTGProxyPort(Integer.parseInt((String) o));
TGPref.setTGProxyPort(Integer.parseInt(o));
return true;
} catch (Exception e) {
} catch(Exception e) {
ToastUtils.a(requireContext().getString(R.string.ssockswport));
return false;
}
});
PreferencesUtil.addMaterialSwitchPreference(this, "tg_proxy_auth", requireContext().getString(R.string.ssocksauth), "", 0, false, (preference, o) -> {
PreferenceFragmentUtils.addMaterialSwitchPreference(getPreferenceScreen(), "tg_proxy_auth", requireContext().getString(R.string.ssocksauth), "", 0, false, (preference, o) -> {
boolean value = (boolean) o;
findPreference("tg_proxy_login").setEnabled(value); // findPreference("tg_proxy_login").setEnabled(value);
findPreference("tg_proxy_pass").setEnabled(value); // findPreference("tg_proxy_pass").setEnabled(booleanValue);
findPreference("tg_proxy_login").setEnabled(value);
findPreference("tg_proxy_pass").setEnabled(value);
TGPref.setTGProxyPassEnabled(value);
return true;
});
PreferencesUtil.addEditTextPreference(this, "tg_proxy_login", requireContext().getString(R.string.ssockslogin), (preference, o) -> {
TGPref.setTGProxyUserPass((String) o, TGPref.getTGProxyPass());
PreferenceFragmentUtils.addEditTextPreference(getPreferenceScreen(), "tg_proxy_login", R.string.ssockslogin, (preference, o) -> {
TGPref.setTGProxyUserPass(o, TGPref.getTGProxyPass());
return true;
});
PreferencesUtil.addEditTextPreference(this, "tg_proxy_pass", requireContext().getString(R.string.ssockspass), (preference, o) -> {
TGPref.setTGProxyUserPass(TGPref.getTGProxyUser(), (String) o);
PreferenceFragmentUtils.addEditTextPreference(getPreferenceScreen(), "tg_proxy_pass", R.string.ssockspass, (preference, o) -> {
TGPref.setTGProxyUserPass(TGPref.getTGProxyUser(), o);
return true;
});
@@ -0,0 +1,53 @@
package ru.vtosters.lite.ui.views.rarepebble;
import android.content.Context;
import android.graphics.Bitmap;
public class AlphaView extends SliderViewBase implements ColorObserver {
private ObservableColor observableColor = new ObservableColor(0);
public AlphaView(Context context) {
super(context);
}
public void observeColor(ObservableColor observableColor) {
this.observableColor = observableColor;
observableColor.addObserver(this);
}
@Override
public void updateColor(ObservableColor observableColor) {
setPos((float)observableColor.getAlpha()/0xff);
updateBitmap();
invalidate();
}
@Override
protected void notifyListener(float currentPos) {
observableColor.updateAlpha((int)(currentPos * 0xff), this);
}
@Override
protected int getPointerColor(float currentPos) {
float solidColorLightness = observableColor.getLightness();
float posLightness = 1 + currentPos * (solidColorLightness - 1);
return posLightness > 0.5f ? 0xff000000 : 0xffffffff;
}
@Override
protected Bitmap makeBitmap(int w, int h) {
final boolean isWide = w > h;
final int n = Math.max(w, h);
int color = observableColor.getColor();
int[] colors = new int[n];
for (int i = 0; i < n; ++i) {
float alpha = isWide ? (float)i / n : 1 - (float)i / n;
colors[i] = color & 0xffffff | (int)(alpha * 0xff) << 24;
}
final int bmpWidth = isWide ? w : 1;
final int bmpHeight = isWide ? 1 : h;
return Bitmap.createBitmap(colors, bmpWidth, bmpHeight, Bitmap.Config.ARGB_8888);
}
}
@@ -0,0 +1,6 @@
package ru.vtosters.lite.ui.views.rarepebble;
public interface ColorObserver {
void updateColor(ObservableColor observableColor);
}
@@ -0,0 +1,150 @@
package ru.vtosters.lite.ui.views.rarepebble;
import static ru.vtosters.lite.utils.AndroidUtils.dp2px;
import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Color;
import android.graphics.Typeface;
import android.text.InputFilter;
import android.text.InputType;
import android.text.method.DigitsKeyListener;
import android.view.Gravity;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import ru.vtosters.lite.utils.LayoutUtils;
public class ColorPickerView extends FrameLayout {
private final AlphaView alphaView;
private final EditText hexEdit;
private final ObservableColor observableColor = new ObservableColor(0);
private final SwatchView swatchView;
@SuppressLint("SetTextI18n")
public ColorPickerView(Context context) {
super(context);
var container = new LinearLayout(context);
container.setOrientation(LinearLayout.VERTICAL);
container.setPadding(dp2px(16), dp2px(16), dp2px(16), dp2px(16));
container.setGravity(Gravity.CENTER);
this.addView(container, LayoutUtils.createFrame(-2, -2));
var colorPickerFrame = new FrameLayout(context);
var colorPickerFrameParams = LayoutUtils.createLinear(-2, -2);
colorPickerFrameParams.weight = 1.0f;
container.addView(colorPickerFrame, colorPickerFrameParams);
swatchView = new SwatchView(context);
colorPickerFrame.addView(swatchView, LayoutUtils.createFrame(-2, -2));
HueSatView hueSatView = new HueSatView(context);
colorPickerFrame.addView(hueSatView, LayoutUtils.createFrame(-2, -2));
ValueView valueView = new ValueView(context);
var valueViewParams = LayoutUtils.createLinear(-1, dp2px(36));
valueViewParams.topMargin = dp2px(16);
container.addView(valueView, valueViewParams);
alphaView = new AlphaView(context);
var alphaViewParams = LayoutUtils.createLinear(-1, dp2px(36));
valueViewParams.topMargin = dp2px(16);
container.addView(alphaView, alphaViewParams);
hexEdit = new EditText(context);
hexEdit.setText("000000");
hexEdit.setKeyListener(DigitsKeyListener.getInstance("0123456789ABCDEFabcdef"));
hexEdit.setGravity(Gravity.CENTER_HORIZONTAL);
hexEdit.setFilters(new InputFilter[]{ new InputFilter.LengthFilter(4) });
hexEdit.setBackground(null);
hexEdit.setTypeface(Typeface.MONOSPACE);
hexEdit.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
hexEdit.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);
container.addView(hexEdit, LayoutUtils.createLinear(-1, -2));
swatchView.observeColor(observableColor);
hueSatView.observeColor(observableColor);
valueView.observeColor(observableColor);
alphaView.observeColor(observableColor);
HexEdit.setUpListeners(hexEdit, observableColor);
showAlpha(false);
showHex(true);
showPreview(true);
// We get all our state saved and restored for free,
// thanks to the EditText and its listeners!
}
/** Returns the color selected by the user */
public int getColor() {
return observableColor.getColor();
}
/**
* Sets the original color swatch and the current color to the specified value.<br>
* Using dark colors may lead to a loss of color information caused by the ARGB color space.
* Use {@link #setColor(int, float, float, float)} instead to avoid this.
*/
public void setColor(int color) {
setOriginalColor(color);
setCurrentColor(color);
}
/**
* Sets the original color swatch and the current color to the specified value.
*
* <ul>
* <li>Alpha [0...255]</li>
* <li>Hue [0...360)</li>
* <li>Saturation [0...1]</li>
* <li>Brightness [0...1]</li>
* </ul>
*/ public void setColor(int alpha, float hue, float sat, float bri) {
setOriginalColor(alpha, hue, sat, bri);
setCurrentColor(alpha, hue, sat, bri);
}
/** Sets the original color swatch without changing the current color. */
public void setOriginalColor(int color) {
swatchView.setOriginalColor(color);
}
/** Sets the original color swatch without changing the current color. */
public void setOriginalColor(int alpha, float hue, float sat, float bri) {
int color = Color.HSVToColor(alpha, new float[]{hue, sat, bri});
swatchView.setOriginalColor(color);
}
/** Updates the current color without changing the original color swatch. */
public void setCurrentColor(int color) {
observableColor.updateColor(color, null);
}
/** Updates the current color without changing the original color swatch. */
public void setCurrentColor(int alpha, float hue, float sat, float bri) {
observableColor.updateColor(alpha, hue, sat, bri, null);
}
public void showAlpha(boolean showAlpha) {
alphaView.setVisibility(showAlpha ? View.VISIBLE : View.GONE);
HexEdit.setShowAlphaDigits(hexEdit, showAlpha);
}
public void addColorObserver(ColorObserver observer) {
observableColor.addObserver(observer);
}
public void showHex(boolean showHex) {
hexEdit.setVisibility(showHex ? View.VISIBLE : View.GONE);
}
public void showPreview(boolean showPreview) {
swatchView.setVisibility(showPreview ? View.VISIBLE : View.GONE);
}
}

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