Compare commits

...
Author SHA1 Message Date
gdlbo 1b3896f4ca fix colors issue 2023-07-28 19:01:57 +03:00
gdlbo fc9ccf66d1 fix #1409 2023-07-28 18:49:11 +03:00
Vologhat d205f2894b rewrite StickersFragment.java
- move add tgs action to toolbar
- some optimizations
2023-07-14 12:53:57 +03:00
Vologhat 7afc04b2b2 fix tgs packs download 2023-07-14 12:48:45 +03:00
Vologhat 584ee96ee0 fix #1406 2023-07-14 12:37:50 +03:00
gdlbo 66f7ea1b79 Update VTVerifications.java 2023-07-11 21:47:53 +03:00
gdlbo 7b0a83458b Update README.md 2023-07-08 18:03:41 +03:00
gdlbo cdaf7909d4 fix old android crash accenting 2023-07-04 23:23:18 +03:00
gdlbo c70ab388c1 fixed account saving 2023-07-04 22:55:22 +03:00
gdlbo 50c66c2703 fix music metrics 2023-07-04 19:56:12 +03:00
gdlbo 357e520bb0 some code fixes 2023-07-04 18:57:06 +03:00
gdlbo 6379ce5741 cleanup code 2023-07-04 13:42:04 +03:00
Vologhat 02807739a1 fix #1394 2023-07-02 22:32:26 +03:00
gdlbo 40635ab75a fix #1388 2023-07-02 13:44:47 +03:00
gdlbo 32e1bfe6fd fix messages color accent 2023-07-02 00:04:10 +03:00
gdlbo 281a0e8499 updated translations 2023-07-01 18:45:45 +03:00
gdlbo 220c61afe1 Update preferences_themes.xml 2023-07-01 18:33:46 +03:00
Vologhat 7a632d5224 Update preferences_themes.xml 2023-07-01 18:31:23 +03:00
Vologhat 3218c1a46b add optionally theme cache invalidation every update 2023-07-01 18:29:47 +03:00
Vologhat b2028d86ba add optionally theme cache invalidation every update 2023-07-01 18:24:42 +03:00
gdlbo 45ed5879e6 Update build.gradle 2023-07-01 17:46:06 +03:00
gdlbo 48479dd064 removed old color engine prefs 2023-07-01 17:33:45 +03:00
gdlbo 3b556b81a1 Update StandartFilter.txt 2023-07-01 17:33:05 +03:00
gdlbo 526c9a607a auto refactor imports 2023-07-01 16:42:33 +03:00
Vologhat 81752895ab Revert "auto refactor code"
This reverts commit ad970d097a.
2023-07-01 16:39:36 +03:00
gdlbo ad970d097a auto refactor code 2023-07-01 16:38:42 +03:00
gdlbo bc2010b49d gradle downgrade 2023-07-01 16:34:27 +03:00
Vologhat ff4a4094ff add type validating of resource value 2023-07-01 16:15:20 +03:00
abslike 3629e71098 Update monet dark and amoled theme (nomilkshake) (#1378) 2023-06-27 22:21:45 +03:00
Vologhat b955ac355f fix #1386 2023-06-27 22:17:43 +03:00
Vologhat 409279eca0 fix apk path building 2023-06-27 17:32:28 +03:00
Vologhat ea0a0f1d93 Optimize build scripts
- rewrite the"exportDex" task group
- move  the logic of deleting temporary files into a gradle script
- fix "APPCENTER_KEY" property defining while debug building
2023-06-27 16:42:07 +03:00
gdlbo 3cc81dfddc fix #1376 2023-06-19 05:06:22 +03:00
gdlbo 86041e6031 invert exceptions filters 2023-06-19 01:40:22 +03:00
gdlbo e140ce2661 fixed monet msg colors 2023-06-19 00:46:27 +03:00
gdlbo f6f15132a2 Update build.yml 2023-06-18 18:35:53 +03:00
gdlbo e73751ecf3 Update build.yml 2023-06-18 18:26:12 +03:00
gdlbo 3c0516b4cd cleanup ThemesUtils.java 2023-06-18 18:20:48 +03:00
gdlbo 38d9f4a818 update gradle 2023-06-18 18:20:25 +03:00
gdlbo 207fa4f2e7 fixed memories vkui 2023-06-18 02:38:39 +03:00
abslikeandabslike f9f778b8f4 Updating light nonmilkshake theme (#1374)
Co-authored-by: abslike <abslike@vk.com>
2023-06-17 21:46:13 +03:00
gdlbo 962dcdec67 fixed search engine issue 2023-06-16 22:45:02 +03:00
gdlbo 486026b8aa updated translations 2023-06-14 17:36:34 +03:00
gdlbo e78d08fb94 added frag title for data sett 2023-06-12 16:32:47 +03:00
gdlbo a5e81dbd87 some data sett updated 2023-06-12 16:30:22 +03:00
gdlbo 49051dae9a added filtered buttons for profile #767 2023-06-12 15:28:37 +03:00
gdlbo 94236c87e3 fix incorrect sig 2023-06-10 20:32:06 +03:00
gdlbo 449ba8c768 cleanup NewsFeedFiltersUtils.java 2023-06-10 20:08:28 +03:00
gdlbo 0da81c01e9 fixed monet theme applying 2023-06-10 20:08:13 +03:00
gdlbo b4a0b7e1ea Fixed false filtering of users' own messages 2023-06-10 18:06:13 +03:00
abslikeandabslike f2209eca49 Updating Light and Dark milkshake monet theme (#1359)
Co-authored-by: abslike <abslike@vk.com>
2023-06-10 15:08:13 +03:00
gdlbo 4a004971c6 Update CatalogJsonInjector.java 2023-05-30 19:25:30 +03:00
gdlbo e400b8761c fixed false injection cache playlist in old audio catalog 2023-05-30 17:17:59 +03:00
Vologhat ff8e7b7f41 fix incorrect displaying of selected image searcher 2023-05-30 12:31:21 +03:00
gdlbo 2c501606be amoled vkui issues fix 2023-05-28 18:02:09 +03:00
gdlbo 73420fe1c4 updated vkui injection for new versions 2023-05-28 15:50:11 +03:00
Vologhat 337f81346c replace microsoft icon to bing icon 2023-05-27 20:13:04 +03:00
Vologhat 06f9a4545b added sauceNAO and trace.moe icons 2023-05-27 14:36:09 +03:00
gdlbo fa99df93c4 refactoring some code 2023-05-26 21:03:23 +03:00
Vologhat adcd2472d5 rewrite and fix PhotoViewer hook
- optimize code
- create SearchEngine enum for image searchers
- fix "search photo" on non-monet theme
- fix icon colors in photo viewer context menu
2023-05-26 16:46:43 +03:00
gdlbo 7527b9a07e added update button for all non-dev users 2023-05-26 14:47:49 +03:00
gdlbo 800c223baa fixed dropdown monet icons in menu 2023-05-26 14:37:06 +03:00
gdlbo d1123d3ccf Update MediaNative.java 2023-05-25 23:18:15 +03:00
gdlbo f61fc99d9c Revert "upgraded voice bitrate"
This reverts commit 64303b1709.
2023-05-25 23:04:09 +03:00
gdlbo 60653cc739 medianative converted to java 2023-05-25 23:03:00 +03:00
gdlbo d25bba10b0 fixed profiles crash 2023-05-25 17:06:48 +03:00
gdlbo 3b67ecaa5e deleted voip libs
-10 mb
2023-05-25 17:06:29 +03:00
gdlbo 6600f32392 some settings update 2023-05-25 16:48:04 +03:00
gdlbo 64303b1709 upgraded voice bitrate
opus_encoder_ctl

16000 -> 48000
2023-05-24 20:34:57 +03:00
gdlbo 5c7e50d61e delete pin fix
good fix
2023-05-24 15:18:39 +03:00
gdlbo f68ad105a6 Update Preferences.java 2023-05-24 01:32:02 +03:00
gdlbo 164479da1d disabled profiles/groups rename 2023-05-24 01:00:53 +03:00
gdlbo d93bf41d28 fixed discover bug 2023-05-23 23:43:23 +03:00
gdlbo 38a2b3f2b2 cleanup banner msg code 2023-05-23 23:17:20 +03:00
gdlbo 342534676c fixed another strange issue with banners 2023-05-23 23:08:53 +03:00
gdlbo 56a6a6de03 fixed messages issue 2023-05-23 23:03:10 +03:00
gdlbo d1445c2801 disable language change for miui
https://xiaomi.eu/community/threads/miui-14-per-app-language-support.69022

china number one!!!!!!!!!
2023-05-23 22:28:13 +03:00
gdlbo 6d3ddede38 Update WebViewColoringUtils.java 2023-05-22 19:01:39 +03:00
gdlbo 08dae9b342 Experimental proguard config with hooks refactoring (#1323)
fixed telegram stickers issue
speedup webview coloring
refactored VKUIHook
fixed duplication of eruda
added a check for duplication of adding styles for coloring vkui
2023-05-22 18:48:15 +03:00
gdlbo 8244b31631 fixed issue with aidl 2023-05-21 03:10:23 +03:00
gdlbo 8b29870df9 fixed vk classes crash 2023-05-21 02:57:07 +03:00
gdlbo ab1d0bde0d Update TelegramStickersGrabber.java 2023-05-21 00:59:40 +03:00
gdlbo 782f8a881d updated desugar runtime library 2023-05-21 00:58:39 +03:00
gdlbo b712630809 fixed logging issues 2023-05-21 00:58:19 +03:00
gdlbo b6698287a0 Update proguard-rules.pro 2023-05-21 00:21:59 +03:00
aliveoutside 1b5bfb0ea6 daily mix fix 2023-05-20 19:02:01 +03:00
gdlbo 59d5b83d7b fixed catalog injectors issues
cache playlist fixed
daily mix fixed
2023-05-20 16:32:33 +03:00
gdlbo 9c127931cf updated translations 2023-05-20 14:47:29 +03:00
gdlbo 6f552ee0cb some code cleanup 2023-05-20 14:36:47 +03:00
gdlbo ae1520e189 added logs shrink for release builds 2023-05-20 13:52:43 +03:00
gdlbo 8fae9e952f updated gradle version 2023-05-20 13:52:00 +03:00
gdlbo e6047ffe8a updated appcenter libs 2023-05-20 13:51:26 +03:00
gdlbo b987643ad7 Update arrays.xml 2023-05-19 20:19:43 +03:00
gdlbo b93ce2dd95 fixed issues with translation 2023-05-19 20:18:23 +03:00
gdlbo 1c845c5b34 added more translations 2023-05-19 20:13:51 +03:00
Denis c4af19432d Add compression types translation (#1312) 2023-05-19 19:49:23 +03:00
gdlbo 0c289f8bbb added support for many attachments 10+ (#1311) 2023-05-19 19:34:30 +03:00
Saoqq c68d424b59 Update ffmpeg libs (#1057)
* Update ffmpeg libs

* Bring back metadata writing
2023-05-17 17:45:45 +03:00
aliveoutside 46bac84276 fix daily mix title in playlist view 2023-05-17 11:39:50 +03:00
aliveoutside 16260c5666 temp daily mix fix 2023-05-17 10:55:02 +03:00
gdlbo 594f24d640 Refactored issues with photo compression (#1300)
Added new ways of compression
Added photo copy button
2023-05-15 21:28:45 +03:00
Denis 0deafb5606 Update features.md - editing the list of functions (#1297) 2023-05-15 12:19:27 +03:00
gdlbo 2e3b45a88f Revert "Multithreading verifs downloading"
This reverts commit 0e94efc4f7.
2023-05-14 17:30:14 +03:00
gdlbo 5a7a628117 Revert "added multithread download for some large methods"
This reverts commit 34a0615003.
2023-05-14 17:30:14 +03:00
gdlbo 2d96619c67 Create Multithreading.java 2023-05-13 15:43:29 +03:00
gdlbo 34a0615003 added multithread download for some large methods 2023-05-13 15:07:27 +03:00
gdlbo 0e94efc4f7 Multithreading verifs downloading 2023-05-13 14:38:29 +03:00
gdlbo a11a88e23f moved debug activation to long click of logo/appver 2023-05-12 22:22:27 +03:00
gdlbo 72eb342b98 updated version.properties parsing + cleanup code 2023-05-12 22:00:09 +03:00
gdlbo edb011ccbf Update About.java 2023-05-12 21:19:08 +03:00
gdlbo 8b32e16428 check_for_slow_speed (#1293) 2023-05-12 19:51:27 +03:00
gdlbo d4b457b01d fixed detection admin for kick button 2023-05-12 19:50:48 +03:00
Denis 3d61780240 Sort features in README.md (#1294) 2023-05-12 16:01:09 +03:00
gdlbo 44092032ca Update Requests.java 2023-05-10 19:47:00 +03:00
gdlbo 2800ccdaea refactored dnr/dnt modules 2023-05-10 19:40:33 +03:00
gdlbo a0cce72c64 kick button for admins in chats 2023-05-10 18:01:19 +03:00
gdlbo cbca43c929 Update README.md 2023-05-10 14:14:56 +03:00
gdlbo 0324c9edb7 updated docs for building 2023-05-10 14:13:17 +03:00
Denis c7d34ece2f added features in features list and sorting (#1119)
* added feature text feature

* Add new features in list

* fix text

* Update features.md

* Add dev feature "sync account" and backup settings

* Update - Add genius

* Update features.md - delete unreleased features
2023-05-09 19:38:34 +03:00
gdlbo 681dd177b8 fixed offline genius issue 2023-05-07 12:09:18 +03:00
gdlbo 4405b04285 removed useless conv bar recomms 2023-05-06 23:40:04 +03:00
gdlbo 3c4e981839 fixed lyrics for genius 2023-05-06 23:27:30 +03:00
gdlbo e318634e56 fix some genius issues 2023-05-06 22:49:12 +03:00
aliveoutside 5ea515f6f4 fetch the lyrics from genius even when vk didn't provide them 2023-05-06 19:23:22 +03:00
gdlbo 22cd1a8e22 some audio code cleanup 2023-05-06 12:24:37 +03:00
gdlbo ba0169cb4c fixed thumbnails in online cache catalog and shuffle 2023-05-06 11:51:23 +03:00
gdlbo 5f0458c587 refactored cache tracklist injector and added shuffle button 2023-05-06 11:03:40 +03:00
gdlbo 7b840a1721 added app category for oreo+ 2023-05-05 23:00:07 +03:00
gdlbo 78036bb3db deleted snet 2023-05-05 22:59:24 +03:00
gdlbo da52a7557f cleanup code 2023-05-05 20:48:39 +03:00
Vologhat 6eae209d04 fixed building drm key url and AES-128 decoding 2023-05-05 20:48:39 +03:00
Vologhat 683f0346e2 added null-check of base uri,fixed filename comparator 2023-05-05 20:48:39 +03:00
gdlbo c95b4e7f86 added new cache insert track method 2023-05-05 20:48:39 +03:00
Vologhat 64c55d4b01 init 2023-05-05 20:48:39 +03:00
gdlbo cc55d5ddaa new btn injector for groups 2023-04-29 19:24:55 +03:00
gdlbo 522290e4a5 Update GroupsCatalogInjector.java 2023-04-28 22:26:38 +03:00
gdlbo 78191b716a Update GroupsCatalogInjector.java 2023-04-28 22:16:20 +03:00
gdlbo dcf14266f2 cleanup catalog json injector 2023-04-28 22:11:53 +03:00
gdlbo a295e11a9d fixed issues with music 2023-04-28 21:58:14 +03:00
gdlbo 67ba4319f8 fixed groups fix for catalogs 2023-04-28 21:30:33 +03:00
aliveoutside f4d4c622eb fix #1235 2023-04-28 21:19:50 +03:00
gdlbo 0d61904b19 Update GmsUtils.java 2023-04-26 19:41:22 +03:00
gdlbo 8d9d025f11 some cleanup 2023-04-23 17:22:41 +03:00
gdlbo 6cac613f70 fixed microg pushes 2023-04-20 18:24:29 +03:00
gdlbo a5d0f1b730 microg settings and force microg usage 2023-04-20 16:14:52 +03:00
gdlbo 47465356fa fixed some spoof issues 2023-04-20 15:44:49 +03:00
gdlbo 4c6eed7dad added support for microg 2023-04-20 15:36:09 +03:00
gdlbo 7bdc8b21e4 updated jars 2023-04-20 15:31:59 +03:00
gdlbo 21fc171363 Update ThemesFragment.java 2023-04-03 21:11:55 +03:00
gdlbo fb09513ca7 samsung best fix 2023-04-03 17:43:55 +03:00
gdlbo dc49c75992 Update OEMDetector.java 2023-04-03 16:30:19 +03:00
gdlbo dd289f1933 another theme at start fix..? 2023-04-03 16:01:34 +03:00
gdlbo 360c5db990 fixed shit miui issue 2023-04-03 15:54:08 +03:00
gdlbo 0df490dc55 fixed perms 2023-04-03 15:46:16 +03:00
gdlbo 064f5d8b31 some wallpapers fixes 2023-04-02 21:37:06 +03:00
gdlbo 40f3d74f07 fixed strange bug 2023-04-02 19:54:52 +03:00
awers24 cd08354b5e ukrainian translation 2023-03-31 08:58:19 +03:00
mysh228 64a9a3c1e8 belarusian translation 2023-03-30 20:09:53 +03:00
gdlbo 8770712687 dockbar editor moved to dockbar settings in appearance sett 2023-03-30 14:25:05 +03:00
gdlbo 009f856b33 deleted useless vk apps menu in dockbar editor 2023-03-30 14:24:06 +03:00
gdlbo 022c264740 removed recomm menu in discover 2023-03-30 14:23:39 +03:00
gdlbo dd2d79e474 Update DataSettingsFragment.java 2023-03-29 00:07:40 +03:00
gdlbo f2fe2ec362 added language settings for a13+ 2023-03-28 22:42:45 +03:00
k1zn 46ef15d9c8 /ru/ translate [main] 2023-03-28 02:13:05 +05:00
k1zn 93a507a314 /ru/ localization 2023-03-28 01:36:38 +05:00
gdlbo a3853a012d Сохранение аккаунтов (#1165) 2023-03-27 21:55:57 +03:00
gdlbo 10ed61acfc new color engine now is optional 2023-03-27 21:00:40 +03:00
aliveoutside 8b434d4cae revert apktool 2023-03-27 19:00:13 +03:00
gdlbo 92a33995bd fixed adaptive icons 2023-03-27 17:35:47 +03:00
gdlbo d994439561 fixed cringe build update detection v2 2023-03-25 22:44:58 +03:00
gdlbo ed751bdc30 fixed cringe build update detection 2023-03-25 22:24:33 +03:00
gdlbo ababaad45f revert old theme engine for monet theme 2023-03-25 20:32:44 +03:00
gdlbo 9a76492c06 Update custom_thumb_selector.xml 2023-03-21 16:15:38 +03:00
gdlbo 2d19254d51 fixed start issue 2023-03-21 16:13:18 +03:00
gdlbo d557abe6e9 md3 switch 2023-03-21 16:05:55 +03:00
gdlbo 658c4bcaf6 fixed issue with system theme applying + crashes 2023-03-21 15:21:31 +03:00
gdlbo 7b12be3736 disabled switch coloring 2023-03-20 00:30:06 +03:00
gdlbo 9e2bfe83b8 Revert "disable out api inj for pinned msg"
This reverts commit 8ca73197d6.
2023-03-19 21:06:30 +03:00
gdlbo 817bdd8198 Update strings.xml 2023-03-19 21:06:22 +03:00
gdlbo 230f8e5cd3 Update GiftSendFragment$b.smali 2023-03-19 19:37:32 +03:00
gdlbo cfce4cd1ff fixed polls colors 2023-03-19 19:06:21 +03:00
gdlbo c9c602b1f9 added new icons 2023-03-19 18:14:25 +03:00
gdlbo 8ca73197d6 disable out api inj for pinned msg 2023-03-19 12:17:43 +03:00
gdlbo 2cf60aedac added enc key delete 2023-03-19 12:05:32 +03:00
gdlbo 207a63117e added identity frag support 2023-03-18 19:55:21 +03:00
gdlbo 14e92e7352 removed calls pref 2023-03-18 19:35:08 +03:00
gdlbo 23c60bdf2d reduced logging + reworked debug menu 2023-03-18 19:23:07 +03:00
gdlbo 680dcf9cf2 useCustomPrefsStyle optional 2023-03-18 13:36:36 +03:00
gdlbo 5249600b76 many build features upgrades 2023-03-18 13:10:12 +03:00
gdlbo bc5a401e0e useCustomPrefsStyle true 2023-03-18 11:37:43 +03:00
gdlbo 125c2d3d69 fix switches 2023-03-18 03:14:42 +03:00
gdlbo db95b53d41 added text coloring 2023-03-17 22:31:08 +03:00
952 changed files with 23560 additions and 22300 deletions
+55 -47
View File
@@ -1,49 +1,22 @@
### Все функции модификации ### Весь функционал модификации
* Лента # Реклама
* Блокировка рекламы в ленте * Блокировка рекламы в ленте +
* Блокировка постов через фильтры * Блокировка историй с возможной рекламой +
* Возможность добавлять в вайтлист фильтров группы, чтобы в них не удалялись посты * Блокировка постов:
* С источником
* С MiniApp
* Через фильтры групп, слов
* Возможность добавлять в вайтлист фильтров группы, чтобы в них не удалялись посты+
* Возможность отключить рекомендации от ВК * Возможность отключить рекомендации от ВК
* Медиаконтент * Отключение отправки метрики
# Интерфейс и внешний вид
* Округление дат * Округление дат
* 1 января в 4:20 * 1 января в 4:20
* 1 января в 4:20:00 * 1 января в 4:20:00
* 1 января 2000 в 4:20:00 * 1 января 2000 в 4:20:00
* Округление чисел * Округление чисел
* Сокращение постов **(Показать полностью)**
* Результаты опросов без участия
* Возможность указывать папку для загрузки фото/видео/музыки/всего
* Интеграция с <a href="https://www.last.fm/">LAST.FM</a> (а также возможность скробблинга)
* Возможность **кешировать музыку / автокешировать ее при прослушивании**
* Возможность выбирать раздел музыки, открываемый по умолчанию
* Возможность скачивать видео, очищать историю просмотра видео
* Возможность найти фотографию через поисковые системы
* Интеграция с <a href="https://vkx.app/">VK X</a>
* Возможность кешировать треки в приложении
* Сообщения
* Обои в сообщениях
* Возможность выключения кнопки записи голосовых сообщений
* Возможность скрыть блок рекомендаций в сообщениях
* Режим **VK Me**
* Возможность вернуть вкладку уведомлений для режима VK Me
* Встроенный переводчик текста для сообщений
* Возможность выбрать язык перевода
* Автоматический перевод ваших сообщений на выбранный язык
* Альтернативный дизайн эмодзи меню
* Возможность использовать системные эмодзи
* Возможнсть использовать Enter с аппаратной клавиатуры
* Панель ввода из приложения VK для iOS
* Telegram Стикеры
* Возможность загружать свои стикерпаки из Telegram во ВКонтакте
* Внешний вид
* Возможность отключать новый дизайн версий VK (Milkshake)
* Название заголовков в докбаре
* Возможность использовать акцент для иконок
* Возможность отключить счётчики в докбаре
* Смена иконки приложения (содержит много уникальных иконок для донатеров)
* Возможность покрасить панель навигации, веб-страницы
* Интерфейс
* Возможность отключить блок историй наверху ленты * Возможность отключить блок историй наверху ленты
* Возможность отключить боковую камеру в разделе «Новости» * Возможность отключить боковую камеру в разделе «Новости»
* Возможность отключить блок «Что у вас нового?» в разделе «Новости» * Возможность отключить блок «Что у вас нового?» в разделе «Новости»
@@ -56,23 +29,58 @@
* Возможность отключить сокращение названий разделов в меню * Возможность отключить сокращение названий разделов в меню
* Возможность скрыть блок рекомендаций друзей в разделе «Друзья» * Возможность скрыть блок рекомендаций друзей в разделе «Друзья»
* Возможность скрыть подписи в настройках * Возможность скрыть подписи в настройках
* Анимированный экран входа для Android 12+
* Редактор докбара * Редактор докбара
* Редактор элементов Superapp * Редактор элементов Superapp
* Активность * Возможность отключать новый дизайн версий VK (Milkshake)
* Название заголовков в докбаре
* Возможность использовать свой акцент для иконок
* Возможность отключить счётчики в докбаре
* Смена иконки приложения (содержит много уникальных иконок для донатеров)
* Возможность покрасить панель навигации, веб-страницы
* Обои в сообщениях
* Возможность выключения кнопки записи голосовых сообщений
* Возможность скрыть блок рекомендаций в сообщениях
* Режим **VK Me**
* Возможность вернуть вкладку уведомлений для режима VK Me
* Встроенный переводчик текста для сообщений
* Альтернативный дизайн эмодзи меню
* Возможность использовать системные эмодзи
* Панель ввода из приложения VK для iOS
* Сокращение постов **(Показать полностью)**
* Результаты опросов без участия
# Медиаконтент
* Интеграция с <a href="https://www.last.fm/">LAST.FM</a> (а также возможность скробблинга)
* Возможность **кешировать музыку / автокешировать ее при прослушивании**
* Возможность выбирать раздел музыки, открываемый по умолчанию
* Возможность скачивать видео, очищать историю просмотра видео
* Возможность найти фотографию через поисковые системы ?
* Интеграция с <a href="https://vkx.app/">VK X</a>
* Поддержка новых текстов в музыке (и с Genius в том числе)
# Сообщения
* Шифрование сообщений
* Возможность видеть удаленные сообщения * Возможность видеть удаленные сообщения
* Функционал, позволяющий оставаться в «оффлайне» (принудительный оффлайн/не отправлять статус онлайна и т.п.)
* Нечиталка/неписалка для ЛС/бесед/ботов/групп * Нечиталка/неписалка для ЛС/бесед/ботов/групп
* Возможность загружать свои стикерпаки из Telegram во ВКонтакте
* Возможнсть использовать Enter с аппаратной клавиатуры
# Активность
* Возможность сохранять удалённые сообщения
* Функционал, позволяющий оставаться в «оффлайне» (принудительный оффлайн/не отправлять статус онлайна и т.п.)
* Возможность отключить информацию о том, что вы просмотрели историю/прослушали голосовое сообщение * Возможность отключить информацию о том, что вы просмотрели историю/прослушали голосовое сообщение
* Возможность видеть онлайн пользователей, если у вас скрыт онлайн через VK Messenger * Возможность видеть онлайн пользователей, если у вас скрыт онлайн через VK Messenger
* Возможность сохранять настройки бесшумных сообщений/сообщений-бомбочек * Возможность сохранять настройки бесшумных сообщений/сообщений-бомбочек
* Отключить уведомление о том, что вы сделали скриншот в беседе * Отключить уведомление о том, что вы сделали скриншот в беседе
* Отключение редиректа через away.php * Отключение редиректа через away.php
* Отключение отправки метрики * Отключение бизнес-уведомлений
* Прокси
# Прокси
* Поддержка сторонних прокси, таких как: Zaborona, VikaMobile, рандомные прокси и прочие * Поддержка сторонних прокси, таких как: Zaborona, VikaMobile, рандомные прокси и прочие
* Возможность использовать **HTTP/HTTPS/SOCKS** прокси, менять домены **API/OAuth/Static** * Возможность использовать **HTTP/HTTPS/SOCKS** прокси, менять домены **API/OAuth/Static**
* Другое
* Синхронизация контактов с VK # Другое
* Очистка кеша приложения (**всё/стикеры/изображения/видео/сообщения/WebView**)
* Автоочистка кеша при достижении указанного вами значения (**100/500 MB, 1/2/5 GB**) * Автоочистка кеша при достижении указанного вами значения (**100/500 MB, 1/2/5 GB**)
* Функционал для **дебага приложения/бэкап возможности/верификации VTosters** * Возможность создания резервной копии (бекапа) настроек и аккаунтов
+2 -2
View File
@@ -21,10 +21,10 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Set up JDK 14 - name: Set up JDK
uses: actions/setup-java@v3 uses: actions/setup-java@v3
with: with:
java-version: '14' java-version: '17'
distribution: 'adopt' distribution: 'adopt'
- uses: actions/checkout@v3 - uses: actions/checkout@v3
+13 -4
View File
@@ -37,7 +37,7 @@
* Стабильные сборки находятся в [Releases](https://github.com/vtosters/lite/releases) * Стабильные сборки находятся в [Releases](https://github.com/vtosters/lite/releases)
Зеркало на нашем [<img src="https://git.maki.su/assets/img/logo.svg" align="center" width="20" height="20"/> Git](https://git.maki.su/gdlbo/lite) Зеркало на нашем [<img src="https://gitea.com/assets/img/logo.svg" align="center" width="20" height="20"/> Git](https://git.maki.su/vtosters/lite)
### Быстрая навигация ### Быстрая навигация
@@ -129,6 +129,15 @@
Для сборки необходимо вызвать одну из следующих gradle tasks: Для сборки необходимо вызвать одну из следующих gradle tasks:
+ `./gradlew buildVTL` - соберет и подпишет APK + `./gradlew buildVTL + <Build Type>` - соберет и подпишет APK
+ `./gradlew buildAndInstallVTL` - соберет, подпишет и попытается установить через ADB + `./gradlew buildAndInstallVTL + <Build Type>` - соберет, подпишет и попытается установить через ADB
+ [FOR DEVS] `./gradlew prepareDexForMerge` - соберет все необходимое для сборки в `smali/` + `./gradlew buildAndLaunchVTL + <Build Type>` - соберет, подпишет, попытается установить через ADB и запустит на устройстве
+ [FOR DEVS] `./gradlew prepareDexForMerge + <Build Type>` - соберет все необходимое для сборки в `smali/`
+ [FOR DEVS] `./gradlew exportDex + <Build Type>` - экспортирование дексов из собранного приложения для переноса в `smali/`
```
Build types:
Dev
Beta
Release
```
+56 -71
View File
@@ -1,8 +1,6 @@
import org.apache.tools.ant.taskdefs.condition.Os import org.apache.tools.ant.taskdefs.condition.Os
import java.util.zip.ZipEntry
import java.util.zip.ZipFile import java.util.zip.ZipFile
import java.util.zip.ZipInputStream
plugins { plugins {
id 'com.android.application' id 'com.android.application'
@@ -21,6 +19,10 @@ cargo {
def smaliFolder = projectDir.toPath().resolve("../smali").normalize() def smaliFolder = projectDir.toPath().resolve("../smali").normalize()
def scriptsFolder = projectDir.toPath().resolve("../scripts").normalize() def scriptsFolder = projectDir.toPath().resolve("../scripts").normalize()
//you can add own folders with decompiled smali code
def dexes=smaliFolder.toFile()
.listFiles( { f -> f.isDirectory() && f.name.startsWith("smali") } as FileFilter)
.size()
versionFile { versionFile {
file = projectDir.toPath().resolve("src/main/assets/version.properties").toFile() file = projectDir.toPath().resolve("src/main/assets/version.properties").toFile()
@@ -50,15 +52,22 @@ android {
} }
buildTypes { buildTypes {
release {
minifyEnabled true
buildConfigField 'String', 'APPCENTER_KEY', '""'
proguardFile 'proguard-rules.pro'
}
rc {
minifyEnabled true
buildConfigField 'String', 'APPCENTER_KEY', '""'
proguardFile 'proguard-rules.pro'
}
dev { dev {
initWith release minifyEnabled false
buildConfigField 'String', 'APPCENTER_KEY', '""' buildConfigField 'String', 'APPCENTER_KEY', '""'
} }
beta { beta {
initWith release minifyEnabled false
buildConfigField 'String', 'APPCENTER_KEY', '""'
}
release {
buildConfigField 'String', 'APPCENTER_KEY', '""' buildConfigField 'String', 'APPCENTER_KEY', '""'
} }
} }
@@ -70,77 +79,54 @@ android {
} }
namespace 'ru.vtosters.lite' namespace 'ru.vtosters.lite'
ndkVersion '25.2.9519653' ndkVersion '25.2.9519653'
buildFeatures {
aidl true
}
} }
dependencies { dependencies {
implementation "com.microsoft.appcenter:appcenter-analytics:5.0.0" implementation 'com.microsoft.appcenter:appcenter-analytics:5.0.1'
implementation "com.microsoft.appcenter:appcenter-crashes:5.0.0" implementation 'com.microsoft.appcenter:appcenter-crashes:5.0.1'
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5' coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.3'
implementation 'net.sourceforge.streamsupport:streamsupport-minifuture:1.7.4' implementation 'net.sourceforge.streamsupport:streamsupport-minifuture:1.7.4'
implementation 'com.google.guava:guava:23.3-android'
implementation fileTree(dir: 'libs', include: ['*.aar']) implementation fileTree(dir: 'libs', include: ['*.aar'])
compileOnly fileTree(dir: 'libs', include: ['*.jar']) compileOnly fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.google.guava:guava:23.3-android'
} }
task generateBuildTasks() { task generateBuildTasks() {
android.applicationVariants.all { variant -> android.applicationVariants.all { variant ->
variant.outputs.each { output -> variant.outputs.each { output ->
def buildType = output.name.toString().capitalize() def buildType = output.name.toString().capitalize()
def lowerBuildType = buildType.toLowerCase() if(buildType=="Base")return
task "exportDex$buildType"() { task "exportDex$buildType"() {
dependsOn('assemble' + buildType) dependsOn('assemble' + buildType)
doLast { doLast {
try { try {
var z = "" def suffix=buildType.toLowerCase()
if (lowerBuildType != "debug") { String apkPath=projectDir.getAbsolutePath()+"/build/outputs/apk/$suffix/app-$suffix"
z = "-unsigned" def apk=new File(apkPath+"-unsigned.apk")
} if(!apk.exists())apk=new File(apkPath+".apk")
def zip=new ZipFile(apk)
File moduleDir = projectDir def entries=zip.entries()
ZipInputStream inputStream = new ZipInputStream(new FileInputStream(moduleDir.getAbsolutePath() + "/build/outputs/apk/$lowerBuildType/app-$lowerBuildType${z}.apk")) def dexCounter=dexes
ZipFile file = new ZipFile(moduleDir.getAbsolutePath() + "/build/outputs/apk/$lowerBuildType/app-$lowerBuildType${z}.apk"); while(entries.hasMoreElements())
ZipEntry entry {
while ((entry = inputStream.nextEntry) != null) { def entry=entries.nextElement()
if (entry.getName().equals("classes.dex")) { String filename
print('classes.dex found!') if(entry.name.matches("^classes(?:(?=\\d)2|)\\.dex\$"))filename="classes${++dexCounter}.dex"
else if(entry.name=="assets/version.properties")filename="version.properties"
FileOutputStream outputStream = new FileOutputStream(new File(moduleDir.getAbsoluteFile(), "classes6.dex")) else continue
println("Exporting "+entry.name)
byte[] buffer = new byte[1024] def tmpFile=new File(projectDir,filename)
int len = 0 def is=zip.getInputStream(entry)
while ((len = inputStream.read(buffer)) > 0) { def fos=new FileOutputStream(tmpFile)
outputStream.write(buffer, 0, len) def buff=new byte[0x800]
} int len
outputStream.close() while((len=is.read(buff))>0)fos.write(buff,0,len)
} is.close()
if (entry.getName().equals("classes2.dex")) { fos.close()
print('\nclasses2.dex found!')
FileOutputStream outputStream = new FileOutputStream(new File(moduleDir.getAbsoluteFile(), "classes7.dex"))
byte[] buffer = new byte[1024]
int len = 0
while ((len = inputStream.read(buffer)) > 0) {
outputStream.write(buffer, 0, len)
}
outputStream.close()
}
}
for (ZipEntry e : Collections.list(file.entries())) {
if (e.getName().endsWith("assets/version.properties")) {
var is = file.getInputStream(e)
FileOutputStream outputStream = new FileOutputStream(new File(moduleDir.getAbsoluteFile(), "version.properties"))
byte[] buffer = new byte[1024]
int len = 0
while ((len = is.read(buffer)) > 0) {
outputStream.write(buffer, 0, len)
}
outputStream.close()
print('\nversion.properties found!')
}
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace() e.printStackTrace()
@@ -150,17 +136,16 @@ task generateBuildTasks() {
task "prepareDexForMerge$buildType"(type: Copy) { task "prepareDexForMerge$buildType"(type: Copy) {
dependsOn('exportDex' + buildType) dependsOn('exportDex' + buildType)
// Remove comment for native lib build // Remove comment for native lib build
dependsOn('cargoBuild') //dependsOn('cargoBuild')
into smaliFolder.toString() into smaliFolder.toString()
from(projectDir) { from(projectDir) {
include 'classes6.dex' into '../smali'
include 'classes7.dex' include "classes*.dex"
} }
from(projectDir) { from(projectDir) {
include 'version.properties' include 'version.properties'
into 'assets' into 'assets'
} }
// Remove comment for native lib build
from('../native-effects/target/aarch64-linux-android/release'){ from('../native-effects/target/aarch64-linux-android/release'){
include 'libnative_effects.so' include 'libnative_effects.so'
into 'lib/arm64-v8a' into 'lib/arm64-v8a'
@@ -169,15 +154,16 @@ task generateBuildTasks() {
include 'libnative_effects.so' include 'libnative_effects.so'
into 'lib/armeabi-v7a' into 'lib/armeabi-v7a'
} }
doLast {
new File(projectDir, "classes6.dex").delete()
new File(projectDir, "classes7.dex").delete()
new File(projectDir, "version.properties").delete()
} }
task "cleanTemporaryFiles$buildType"(type:Delete)
{
delete fileTree(dir:projectDir,include:["*.dex","version.properties"])
delete fileTree(dir:smaliFolder,include:['*.dex',"assets/version.properties"])
} }
task "buildVTL$buildType"(type: Exec) { task "buildVTL$buildType"(type: Exec) {
dependsOn('prepareDexForMerge' + buildType) dependsOn('prepareDexForMerge' + buildType)
workingDir(projectDir.parentFile) workingDir(projectDir.parentFile)
finalizedBy "cleanTemporaryFiles$buildType"
if (Os.isFamily("unix") || Os.isFamily("mac")) { if (Os.isFamily("unix") || Os.isFamily("mac")) {
commandLine 'bash', '-c', './scripts/build.sh' commandLine 'bash', '-c', './scripts/build.sh'
} else { } else {
@@ -205,7 +191,6 @@ task generateBuildTasks() {
} }
} }
task generateRjava(type: Exec) { task generateRjava(type: Exec) {
workingDir(projectDir.parentFile) workingDir(projectDir.parentFile)
if (Os.isFamily("unix") || Os.isFamily("mac")) if (Os.isFamily("unix") || Os.isFamily("mac"))
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+25
View File
@@ -19,3 +19,28 @@
## hide the original source file name. ## hide the original source file name.
##-renamesourcefileattribute SourceFile ##-renamesourcefileattribute SourceFile
#-keepclassmembers class fq #-keepclassmembers class fq
-assumenosideeffects class android.util.Log {
public static boolean isLoggable(java.lang.String, int);
public static int v(...);
public static int i(...);
public static int w(...);
public static int d(...);
public static int e(...);
}
-repackageclasses
-allowaccessmodification
-optimizations
-optimizationpasses 5
-keepattributes SourceFile, LineNumberTable
-keep,allowoptimization class ru.vtosters.hooks.**, ru.vtosters.lite.utils.AndroidUtils, ru.vtosters.lite.utils.NetworkUtils, ru.vtosters.lite.utils.CrashReporter, ru.vtosters.lite.ui.activities.**, ru.vtosters.lite.services.**, ru.vtosters.lite.ui.fragments.**, ru.vtosters.lite.themes.**, ru.vtosters.lite.music.hook.**, ru.vtosters.lite.music.cache.injectors.**, ru.vtosters.lite.ui.wallpapers.NativeEffects, com.aefyr.tsg.g2.TelegramStickersService {
public <fields>;
public <methods>;
public <init>(...);
}
-keep class com.vtosters.lite.** { *; }
-keep class com.vk.** { *; }
-keep class bruhcollective.itaysonlab.libvkx.client.** { *; }
@@ -1,20 +1,18 @@
package bruhcollective.itaysonlab.libvkx.client; package bruhcollective.itaysonlab.libvkx.client;
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
import static ru.vtosters.lite.utils.Preferences.isValidSignature;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
import android.os.RemoteException; import android.os.RemoteException;
import bruhcollective.itaysonlab.libvkx.ILibVkxService;
import com.vk.dto.music.MusicTrack; import com.vk.dto.music.MusicTrack;
import com.vk.music.common.MusicPlaybackLaunchContext; import com.vk.music.common.MusicPlaybackLaunchContext;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import bruhcollective.itaysonlab.libvkx.ILibVkxService; import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
import static ru.vtosters.hooks.other.Preferences.getBoolValue;
import static ru.vtosters.hooks.other.Preferences.isValidSignature;
public class LibVKXClient { public class LibVKXClient {
@SuppressLint("StaticFieldLeak") @SuppressLint("StaticFieldLeak")
@@ -1,7 +1,5 @@
package bruhcollective.itaysonlab.libvkx.client; package bruhcollective.itaysonlab.libvkx.client;
import static ru.vtosters.lite.utils.AccountManagerUtils.getUserId;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
@@ -10,10 +8,11 @@ import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo; import android.content.pm.ResolveInfo;
import android.os.IBinder; import android.os.IBinder;
import android.os.RemoteException; import android.os.RemoteException;
import bruhcollective.itaysonlab.libvkx.ILibVkxService;
import java.util.List; import java.util.List;
import bruhcollective.itaysonlab.libvkx.ILibVkxService; import static ru.vtosters.lite.utils.AccountManagerUtils.getUserId;
public class LibVKXClientImpl { public class LibVKXClientImpl {
private ILibVkxService serviceInstance; private ILibVkxService serviceInstance;
@@ -5,19 +5,16 @@ import android.app.NotificationChannel;
import android.app.NotificationManager; import android.app.NotificationManager;
import android.content.Context; import android.content.Context;
import android.os.Build; import android.os.Build;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.core.app.NotificationManagerCompat; import androidx.core.app.NotificationManagerCompat;
import com.aefyr.tsg.g2.stickersgrabber.TelegramStickersGrabber; import com.aefyr.tsg.g2.stickersgrabber.TelegramStickersGrabber;
import com.vtosters.lite.R; import com.vtosters.lite.R;
import ru.vtosters.lite.utils.AndroidUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
import ru.vtosters.lite.utils.AndroidUtils;
/** /**
* Created by Aefyr on 20.05.2018. * Created by Aefyr on 20.05.2018.
*/ */
@@ -3,7 +3,6 @@ package com.aefyr.tsg.g2;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.BitmapFactory; import android.graphics.BitmapFactory;
import android.util.Log; import android.util.Log;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
@@ -37,10 +36,8 @@ public class TelegramStickersPack extends CustomStickersPack {
public HashMap<String, List<Integer>> emojis = new HashMap<>(); public HashMap<String, List<Integer>> emojis = new HashMap<>();
public TelegramStickersPack(String id) { public TelegramStickersPack(String id) {
final var idLowerCase = id.toLowerCase(); this.id=this.title=id;
this.id = idLowerCase; this.hash=id.hashCode();
this.hash = idLowerCase.hashCode();
title = id;
} }
public JSONObject encodeEmojis() throws JSONException { public JSONObject encodeEmojis() throws JSONException {
@@ -104,7 +101,7 @@ public class TelegramStickersPack extends CustomStickersPack {
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
return obj instanceof TelegramStickersPack && ((TelegramStickersPack) obj).id.equalsIgnoreCase(id); return obj instanceof TelegramStickersPack && ((TelegramStickersPack) obj).id.equals(id);
} }
@Override @Override
@@ -8,6 +8,7 @@ import android.util.Log;
import com.aefyr.tsg.g2.sql.TelegramStickersDbHelper; import com.aefyr.tsg.g2.sql.TelegramStickersDbHelper;
import com.aefyr.tsg.g2.stickersgrabber.TelegramStickersGrabber; import com.aefyr.tsg.g2.stickersgrabber.TelegramStickersGrabber;
import com.aefyr.tsg.g2.stickersgrabber.TelegramStickersPackInfo; import com.aefyr.tsg.g2.stickersgrabber.TelegramStickersPackInfo;
import ru.vtosters.lite.ui.fragments.VTSettings;
import ru.vtosters.lite.ui.fragments.tgstickers.StickersFragment; import ru.vtosters.lite.ui.fragments.tgstickers.StickersFragment;
import java.io.File; import java.io.File;
@@ -152,6 +153,7 @@ public class TelegramStickersService {
private void notifyActivePacksListChanged() { private void notifyActivePacksListChanged() {
getGlobalContext().sendBroadcast(new Intent(StickersFragment.ACTION_RELOAD)); getGlobalContext().sendBroadcast(new Intent(StickersFragment.ACTION_RELOAD));
getGlobalContext().sendBroadcast(new Intent(VTSettings.ACTION_INVALIDATE_TGS_COUNT));
if (listeners.isEmpty()) if (listeners.isEmpty())
return; return;
@@ -222,7 +224,7 @@ public class TelegramStickersService {
final TelegramStickersPack newPack = pack; final TelegramStickersPack newPack = pack;
final boolean isUpdate = update; final boolean isUpdate = update;
currentlyDownloading.add(id.toLowerCase()); currentlyDownloading.add(id);
notificationsHelper.packStartedDownloading(newPack); notificationsHelper.packStartedDownloading(newPack);
@@ -8,9 +8,7 @@ import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper; import android.database.sqlite.SQLiteOpenHelper;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.util.Log; import android.util.Log;
import com.aefyr.tsg.g2.TelegramStickersPack; import com.aefyr.tsg.g2.TelegramStickersPack;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
@@ -5,12 +5,11 @@ import android.graphics.BitmapFactory;
import android.os.Handler; import android.os.Handler;
import android.os.Looper; import android.os.Looper;
import android.util.Log; import android.util.Log;
import com.aefyr.tsg.g2.stickersgrabber.util.Flag; import com.aefyr.tsg.g2.stickersgrabber.util.Flag;
import com.aefyr.tsg.g2.stickersgrabber.util.GoalCounter; import com.aefyr.tsg.g2.stickersgrabber.util.GoalCounter;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
import ru.vtosters.lite.net.*;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
@@ -27,12 +26,6 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import ru.vtosters.lite.net.NetCall;
import ru.vtosters.lite.net.NetCallback;
import ru.vtosters.lite.net.NetClient;
import ru.vtosters.lite.net.NetRequest;
import ru.vtosters.lite.net.NetResponse;
/** /**
* Created by Aefyr on 11.05.2018. * Created by Aefyr on 11.05.2018.
*/ */
@@ -67,7 +60,7 @@ public class TelegramStickersGrabber {
try { try {
sha256 = MessageDigest.getInstance("SHA-256"); sha256 = MessageDigest.getInstance("SHA-256");
} catch (NoSuchAlgorithmException e) { } catch (NoSuchAlgorithmException e) {
Log.wtf(TAG, "No support for SHA-256"); Log.d(TAG, "No support for SHA-256");
e.printStackTrace(); e.printStackTrace();
throw new RuntimeException(e); throw new RuntimeException(e);
} }
@@ -2,7 +2,6 @@ package com.arthenica.ffmpegkit;
import android.os.Build; import android.os.Build;
import android.util.Log; import android.util.Log;
import com.arthenica.smartexception.java.Exceptions; import com.arthenica.smartexception.java.Exceptions;
import java.util.Collections; import java.util.Collections;
@@ -35,31 +35,49 @@ import java.util.Map.Entry;
*/ */
public class ArscBlamer { public class ArscBlamer {
/** Maps package key pool indices to blamed resources. */ /**
* Maps package key pool indices to blamed resources.
*/
private final Map<PackageChunk, List<ResourceEntry>[]> keyToBlame = new HashMap<>(); private final Map<PackageChunk, List<ResourceEntry>[]> keyToBlame = new HashMap<>();
/** Maps types to blamed resources. */ /**
* Maps types to blamed resources.
*/
private final Map<PackageChunk, List<ResourceEntry>[]> typeToBlame = new HashMap<>(); private final Map<PackageChunk, List<ResourceEntry>[]> typeToBlame = new HashMap<>();
/** Maps package to blamed resources. */ /**
* Maps package to blamed resources.
*/
private final Multimap<PackageChunk, ResourceEntry> packageToBlame = HashMultimap.create(); private final Multimap<PackageChunk, ResourceEntry> packageToBlame = HashMultimap.create();
/** Maps string indices to blamed resources. */ /**
* Maps string indices to blamed resources.
*/
private final List<ResourceEntry>[] stringToBlame; private final List<ResourceEntry>[] stringToBlame;
/** Maps type chunk entries to blamed resources. */ /**
* Maps type chunk entries to blamed resources.
*/
private final Multimap<TypeChunk.Entry, ResourceEntry> typeEntryToBlame = HashMultimap.create(); private final Multimap<TypeChunk.Entry, ResourceEntry> typeEntryToBlame = HashMultimap.create();
/** Maps resources to the type chunk entries they reference. */ /**
* Maps resources to the type chunk entries they reference.
*/
private Multimap<ResourceEntry, TypeChunk.Entry> resourceEntries; private Multimap<ResourceEntry, TypeChunk.Entry> resourceEntries;
/** Maps resources which have no base config to the type chunk entries they reference. */ /**
* Maps resources which have no base config to the type chunk entries they reference.
*/
private Multimap<ResourceEntry, TypeChunk.Entry> baselessKeys; private Multimap<ResourceEntry, TypeChunk.Entry> baselessKeys;
/** Contains all of the type chunks in {@link #resourceTable}. */ /**
* Contains all of the type chunks in {@link #resourceTable}.
*/
private List<TypeChunk> typeChunks; private List<TypeChunk> typeChunks;
/** This is the {@link ResourceTableChunk} inside of the resources.arsc file in the APK. */ /**
* This is the {@link ResourceTableChunk} inside of the resources.arsc file in the APK.
*/
private final ResourceTableChunk resourceTable; private final ResourceTableChunk resourceTable;
/** /**
@@ -72,7 +90,9 @@ public class ArscBlamer {
this.stringToBlame = createEntryListArray(resourceTable.getStringPool().getStringCount()); this.stringToBlame = createEntryListArray(resourceTable.getStringPool().getStringCount());
} }
/** Generates blame mappings. */ /**
* Generates blame mappings.
*/
public void blame() { public void blame() {
Multimap<ResourceEntry, TypeChunk.Entry> entries = getResourceEntries(); Multimap<ResourceEntry, TypeChunk.Entry> entries = getResourceEntries();
for (Entry<ResourceEntry, Collection<TypeChunk.Entry>> entry : entries.asMap().entrySet()) { for (Entry<ResourceEntry, Collection<TypeChunk.Entry>> entry : entries.asMap().entrySet()) {
@@ -121,7 +141,9 @@ public class ArscBlamer {
} }
} }
/** Returns all {@link BinaryResourceValue} for a single {@code entry}. */ /**
* Returns all {@link BinaryResourceValue} for a single {@code entry}.
*/
private Collection<BinaryResourceValue> getAllResourceValues(TypeChunk.Entry entry) { private Collection<BinaryResourceValue> getAllResourceValues(TypeChunk.Entry entry) {
Set<BinaryResourceValue> values = new HashSet<BinaryResourceValue>(); Set<BinaryResourceValue> values = new HashSet<BinaryResourceValue>();
BinaryResourceValue binaryResourceValue = entry.value(); BinaryResourceValue binaryResourceValue = entry.value();
@@ -138,32 +160,44 @@ public class ArscBlamer {
stringToBlame[stringIndex].add(entry); stringToBlame[stringIndex].add(entry);
} }
/** Must first call {@link #blame}. */ /**
* Must first call {@link #blame}.
*/
public Map<PackageChunk, List<ResourceEntry>[]> getKeyToBlamedResources() { public Map<PackageChunk, List<ResourceEntry>[]> getKeyToBlamedResources() {
return Collections.unmodifiableMap(keyToBlame); return Collections.unmodifiableMap(keyToBlame);
} }
/** Must first call {@link #blame}. */ /**
* Must first call {@link #blame}.
*/
public Map<PackageChunk, List<ResourceEntry>[]> getTypeToBlamedResources() { public Map<PackageChunk, List<ResourceEntry>[]> getTypeToBlamedResources() {
return Collections.unmodifiableMap(typeToBlame); return Collections.unmodifiableMap(typeToBlame);
} }
/** Must first call {@link #blame}. */ /**
* Must first call {@link #blame}.
*/
public Multimap<PackageChunk, ResourceEntry> getPackageToBlamedResources() { public Multimap<PackageChunk, ResourceEntry> getPackageToBlamedResources() {
return Multimaps.unmodifiableMultimap(packageToBlame); return Multimaps.unmodifiableMultimap(packageToBlame);
} }
/** Must first call {@link #blame}. */ /**
* Must first call {@link #blame}.
*/
public List<ResourceEntry>[] getStringToBlamedResources() { public List<ResourceEntry>[] getStringToBlamedResources() {
return stringToBlame; return stringToBlame;
} }
/** Must first call {@link #blame}. */ /**
* Must first call {@link #blame}.
*/
public Multimap<TypeChunk.Entry, ResourceEntry> getTypeEntryToBlamedResources() { public Multimap<TypeChunk.Entry, ResourceEntry> getTypeEntryToBlamedResources() {
return Multimaps.unmodifiableMultimap(typeEntryToBlame); return Multimaps.unmodifiableMultimap(typeEntryToBlame);
} }
/** Returns a multimap of keys for which there is no default resource. */ /**
* Returns a multimap of keys for which there is no default resource.
*/
public Multimap<ResourceEntry, TypeChunk.Entry> getBaselessKeys() { public Multimap<ResourceEntry, TypeChunk.Entry> getBaselessKeys() {
if (baselessKeys != null) { if (baselessKeys != null) {
return baselessKeys; return baselessKeys;
@@ -180,7 +214,9 @@ public class ArscBlamer {
return result; return result;
} }
/** Returns a multimap of resource entries to the chunk entries they reference in this APK. */ /**
* Returns a multimap of resource entries to the chunk entries they reference in this APK.
*/
public Multimap<ResourceEntry, TypeChunk.Entry> getResourceEntries() { public Multimap<ResourceEntry, TypeChunk.Entry> getResourceEntries() {
if (resourceEntries != null) { if (resourceEntries != null) {
return resourceEntries; return resourceEntries;
@@ -195,7 +231,9 @@ public class ArscBlamer {
return result; return result;
} }
/** Returns all {@link TypeChunk} in resources.arsc. */ /**
* Returns all {@link TypeChunk} in resources.arsc.
*/
public List<TypeChunk> getTypeChunks() { public List<TypeChunk> getTypeChunks() {
if (typeChunks != null) { if (typeChunks != null) {
return typeChunks; return typeChunks;
@@ -227,7 +265,9 @@ public class ArscBlamer {
return result; return result;
} }
/** Allows creation of concrete parameterized type arr {@link ArscBlamer#createEntryListArray}. */ /**
* Allows creation of concrete parameterized type arr {@link ArscBlamer#createEntryListArray}.
*/
private static class ArrayListResourceEntry extends ArrayList<ResourceEntry> { private static class ArrayListResourceEntry extends ArrayList<ResourceEntry> {
private ArrayListResourceEntry() { private ArrayListResourceEntry() {
@@ -235,7 +275,9 @@ public class ArscBlamer {
} }
} }
/** Describes a single resource entry. */ /**
* Describes a single resource entry.
*/
public static class ResourceEntry { public static class ResourceEntry {
private final String packageName; private final String packageName;
private final String typeName; private final String typeName;
@@ -255,9 +297,17 @@ public class ArscBlamer {
this.entryName = entryName; this.entryName = entryName;
} }
public String packageName() { return packageName; } public String packageName() {
public String typeName() { return typeName; } return packageName;
public String entryName() { return entryName; } }
public String typeName() {
return typeName;
}
public String entryName() {
return entryName;
}
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
@@ -27,10 +27,14 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
/** Given an arsc file, maps the contents of the file. */ /**
* Given an arsc file, maps the contents of the file.
*/
public final class BinaryResourceFile implements SerializableResource { public final class BinaryResourceFile implements SerializableResource {
/** The chunks contained in this resource file. */ /**
* The chunks contained in this resource file.
*/
private final List<Chunk> chunks = new ArrayList<>(); private final List<Chunk> chunks = new ArrayList<>();
public BinaryResourceFile(byte[] buf) { public BinaryResourceFile(byte[] buf) {
@@ -53,7 +57,9 @@ public final class BinaryResourceFile implements SerializableResource {
return new BinaryResourceFile(buf); return new BinaryResourceFile(buf);
} }
/** Returns the chunks in this resource file. */ /**
* Returns the chunks in this resource file.
*/
public List<Chunk> getChunks() { public List<Chunk> getChunks() {
return Collections.unmodifiableList(chunks); return Collections.unmodifiableList(chunks);
} }
@@ -27,15 +27,21 @@ import java.util.Objects;
*/ */
public class BinaryResourceIdentifier { public class BinaryResourceIdentifier {
/** The {@link PackageChunk} id mask for a packed resource id of the form 0xpptteeee. */ /**
* The {@link PackageChunk} id mask for a packed resource id of the form 0xpptteeee.
*/
private static final int PACKAGE_ID_MASK = 0xFF000000; private static final int PACKAGE_ID_MASK = 0xFF000000;
private static final int PACKAGE_ID_SHIFT = 24; private static final int PACKAGE_ID_SHIFT = 24;
/** The {@link TypeChunk} id mask for a packed resource id of the form 0xpptteeee. */ /**
* The {@link TypeChunk} id mask for a packed resource id of the form 0xpptteeee.
*/
private static final int TYPE_ID_MASK = 0x00FF0000; private static final int TYPE_ID_MASK = 0x00FF0000;
private static final int TYPE_ID_SHIFT = 16; private static final int TYPE_ID_SHIFT = 16;
/** The {@link TypeChunk.Entry} id mask for a packed resource id of the form 0xpptteeee. */ /**
* The {@link TypeChunk.Entry} id mask for a packed resource id of the form 0xpptteeee.
*/
private static final int ENTRY_ID_MASK = 0xFFFF; private static final int ENTRY_ID_MASK = 0xFFFF;
private static final int ENTRY_ID_SHIFT = 0; private static final int ENTRY_ID_SHIFT = 0;
@@ -43,7 +49,9 @@ public class BinaryResourceIdentifier {
private final int typeId; private final int typeId;
private final int entryId; private final int entryId;
/** Returns a {@link BinaryResourceIdentifier} from a {@code resourceId} of the form 0xpptteeee. */ /**
* Returns a {@link BinaryResourceIdentifier} from a {@code resourceId} of the form 0xpptteeee.
*/
public static BinaryResourceIdentifier create(int resourceId) { public static BinaryResourceIdentifier create(int resourceId) {
int packageId = (resourceId & PACKAGE_ID_MASK) >>> PACKAGE_ID_SHIFT; int packageId = (resourceId & PACKAGE_ID_MASK) >>> PACKAGE_ID_SHIFT;
int typeId = (resourceId & TYPE_ID_MASK) >>> TYPE_ID_SHIFT; int typeId = (resourceId & TYPE_ID_MASK) >>> TYPE_ID_SHIFT;
@@ -51,7 +59,9 @@ public class BinaryResourceIdentifier {
return create(packageId, typeId, entryId); return create(packageId, typeId, entryId);
} }
/** Returns a {@link BinaryResourceIdentifier} with the given identifiers. */ /**
* Returns a {@link BinaryResourceIdentifier} with the given identifiers.
*/
public static BinaryResourceIdentifier create(int packageId, int typeId, int entryId) { public static BinaryResourceIdentifier create(int packageId, int typeId, int entryId) {
Preconditions.checkState((packageId & 0xFF) == packageId, "packageId must be <= 0xFF."); Preconditions.checkState((packageId & 0xFF) == packageId, "packageId must be <= 0xFF.");
Preconditions.checkState((typeId & 0xFF) == typeId, "typeId must be <= 0xFF."); Preconditions.checkState((typeId & 0xFF) == typeId, "typeId must be <= 0xFF.");
@@ -65,16 +75,30 @@ public class BinaryResourceIdentifier {
this.entryId = entryId; this.entryId = entryId;
} }
/** The (1-based) id of the {@link PackageChunk} containing this resource. */ /**
public int packageId() { return packageId; } * The (1-based) id of the {@link PackageChunk} containing this resource.
*/
public int packageId() {
return packageId;
}
/** The (1-based) id of the {@link TypeChunk} containing this resource. */ /**
public int typeId() { return typeId; } * The (1-based) id of the {@link TypeChunk} containing this resource.
*/
public int typeId() {
return typeId;
}
/** The (0-based) index of the entry in a {@link TypeChunk} containing this resource. */ /**
public int entryId() { return entryId; } * The (0-based) index of the entry in a {@link TypeChunk} containing this resource.
*/
public int entryId() {
return entryId;
}
public int resId() { return packageId << PACKAGE_ID_SHIFT | typeId << TYPE_ID_SHIFT | entryId; } public int resId() {
return packageId << PACKAGE_ID_SHIFT | typeId << TYPE_ID_SHIFT | entryId;
}
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
@@ -26,10 +26,14 @@ import java.nio.charset.Charset;
import static java.nio.charset.StandardCharsets.UTF_16LE; import static java.nio.charset.StandardCharsets.UTF_16LE;
import static java.nio.charset.StandardCharsets.UTF_8; import static java.nio.charset.StandardCharsets.UTF_8;
/** Provides utilities to decode/encode a String packed in an arsc resource file. */ /**
* Provides utilities to decode/encode a String packed in an arsc resource file.
*/
public final class BinaryResourceString { public final class BinaryResourceString {
/** Type of {@link BinaryResourceString} to encode / decode. */ /**
* Type of {@link BinaryResourceString} to encode / decode.
*/
public enum Type { public enum Type {
UTF8(UTF_8), UTF8(UTF_8),
UTF16(UTF_16LE); UTF16(UTF_16LE);
@@ -45,7 +49,8 @@ public final class BinaryResourceString {
} }
} }
private BinaryResourceString() {} // Private constructor private BinaryResourceString() {
} // Private constructor
/** /**
* Given a buffer and an offset into the buffer, returns a String. The {@code offset} is the * Given a buffer and an offset into the buffer, returns a String. The {@code offset} is the
@@ -26,42 +26,78 @@ import java.nio.ByteOrder;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
/** Represents a single typed resource value. */ /**
* Represents a single typed resource value.
*/
public class BinaryResourceValue implements SerializableResource { public class BinaryResourceValue implements SerializableResource {
/** Resource type codes. */ /**
* Resource type codes.
*/
public enum Type { public enum Type {
/** {@code data} is either 0 (undefined) or 1 (empty). */ /**
* {@code data} is either 0 (undefined) or 1 (empty).
*/
NULL(0x00), NULL(0x00),
/** {@code data} holds a {@link ResourceTableChunk} entry reference. */ /**
* {@code data} holds a {@link ResourceTableChunk} entry reference.
*/
REFERENCE(0x01), REFERENCE(0x01),
/** {@code data} holds an attribute resource identifier. */ /**
* {@code data} holds an attribute resource identifier.
*/
ATTRIBUTE(0x02), ATTRIBUTE(0x02),
/** {@code data} holds an index into the containing resource table's string pool. */ /**
* {@code data} holds an index into the containing resource table's string pool.
*/
STRING(0x03), STRING(0x03),
/** {@code data} holds a single-precision floating point number. */ /**
* {@code data} holds a single-precision floating point number.
*/
FLOAT(0x04), FLOAT(0x04),
/** {@code data} holds a complex number encoding a dimension value, such as "100in". */ /**
* {@code data} holds a complex number encoding a dimension value, such as "100in".
*/
DIMENSION(0x05), DIMENSION(0x05),
/** {@code data} holds a complex number encoding a fraction of a container. */ /**
* {@code data} holds a complex number encoding a fraction of a container.
*/
FRACTION(0x06), FRACTION(0x06),
/** {@code data} holds a dynamic {@link ResourceTableChunk} entry reference. */ /**
* {@code data} holds a dynamic {@link ResourceTableChunk} entry reference.
*/
DYNAMIC_REFERENCE(0x07), DYNAMIC_REFERENCE(0x07),
/** {@code data} holds a dynamic attribute resource identifier. */ /**
* {@code data} holds a dynamic attribute resource identifier.
*/
DYNAMIC_ATTRIBUTE(0x08), DYNAMIC_ATTRIBUTE(0x08),
/** {@code data} is a raw integer value of the form n..n. */ /**
* {@code data} is a raw integer value of the form n..n.
*/
INT_DEC(0x10), INT_DEC(0x10),
/** {@code data} is a raw integer value of the form 0xn..n. */ /**
* {@code data} is a raw integer value of the form 0xn..n.
*/
INT_HEX(0x11), INT_HEX(0x11),
/** {@code data} is either 0 (false) or 1 (true). */ /**
* {@code data} is either 0 (false) or 1 (true).
*/
INT_BOOLEAN(0x12), INT_BOOLEAN(0x12),
/** {@code data} is a raw integer value of the form #aarrggbb. */ /**
* {@code data} is a raw integer value of the form #aarrggbb.
*/
INT_COLOR_ARGB8(0x1c), INT_COLOR_ARGB8(0x1c),
/** {@code data} is a raw integer value of the form #rrggbb. */ /**
* {@code data} is a raw integer value of the form #rrggbb.
*/
INT_COLOR_RGB8(0x1d), INT_COLOR_RGB8(0x1d),
/** {@code data} is a raw integer value of the form #argb. */ /**
* {@code data} is a raw integer value of the form #argb.
*/
INT_COLOR_ARGB4(0x1e), INT_COLOR_ARGB4(0x1e),
/** {@code data} is a raw integer value of the form #rgb. */ /**
* {@code data} is a raw integer value of the form #rgb.
*/
INT_COLOR_RGB4(0x1f); INT_COLOR_RGB4(0x1f);
private final byte code; private final byte code;
@@ -89,12 +125,14 @@ public class BinaryResourceValue implements SerializableResource {
} }
} }
/** The serialized size in bytes of a {@link BinaryResourceValue}. */ /**
* The serialized size in bytes of a {@link BinaryResourceValue}.
*/
public static final int SIZE = 8; public static final int SIZE = 8;
private final int size; public int size;
private final Type type; public Type type;
private final int data; public int data;
public static BinaryResourceValue create(ByteBuffer buffer) { public static BinaryResourceValue create(ByteBuffer buffer) {
int size = (buffer.getShort() & 0xFFFF); int size = (buffer.getShort() & 0xFFFF);
@@ -110,14 +148,26 @@ public class BinaryResourceValue implements SerializableResource {
this.data = data; this.data = data;
} }
/** The length in bytes of this value. */ /**
public int size() { return size; } * The length in bytes of this value.
*/
public int size() {
return size;
}
/** The raw data type of this value. */ /**
public Type type() { return type; } * The raw data type of this value.
*/
public Type type() {
return type;
}
/** The actual 4-byte value; interpretation of the value depends on {@code dataType}. */ /**
public int data() { return data; } * The actual 4-byte value; interpretation of the value depends on {@code dataType}.
*/
public int data() {
return data;
}
@Override @Override
public byte[] toByteArray() { public byte[] toByteArray() {
@@ -30,10 +30,14 @@ import java.nio.ByteBuffer;
import java.nio.ByteOrder; import java.nio.ByteOrder;
import java.util.Map; import java.util.Map;
/** Represents a generic chunk. */ /**
* Represents a generic chunk.
*/
public abstract class Chunk implements SerializableResource { public abstract class Chunk implements SerializableResource {
/** Types of chunks that can exist. */ /**
* Types of chunks that can exist.
*/
public enum Type { public enum Type {
NULL(0x0000), NULL(0x0000),
STRING_POOL(0x0001), STRING_POOL(0x0001),
@@ -75,26 +79,40 @@ public abstract class Chunk implements SerializableResource {
} }
} }
/** The byte boundary to pad chunks on. */ /**
* The byte boundary to pad chunks on.
*/
public static final int PAD_BOUNDARY = 4; public static final int PAD_BOUNDARY = 4;
/** The number of bytes in every chunk that describes chunk type, header size, and chunk size. */ /**
* The number of bytes in every chunk that describes chunk type, header size, and chunk size.
*/
public static final int METADATA_SIZE = 8; public static final int METADATA_SIZE = 8;
/** The offset in bytes, from the start of the chunk, where the chunk size can be found. */ /**
* The offset in bytes, from the start of the chunk, where the chunk size can be found.
*/
private static final int CHUNK_SIZE_OFFSET = 4; private static final int CHUNK_SIZE_OFFSET = 4;
/** The parent to this chunk, if any. */ /**
* The parent to this chunk, if any.
*/
@Nullable @Nullable
private final Chunk parent; private final Chunk parent;
/** Size of the chunk header in bytes. */ /**
* Size of the chunk header in bytes.
*/
protected final int headerSize; protected final int headerSize;
/** headerSize + dataSize. The total size of this chunk. */ /**
* headerSize + dataSize. The total size of this chunk.
*/
protected final int chunkSize; protected final int chunkSize;
/** Offset of this chunk from the start of the file. */ /**
* Offset of this chunk from the start of the file.
*/
protected final int offset; protected final int offset;
protected Chunk(ByteBuffer buffer, @Nullable Chunk parent) { protected Chunk(ByteBuffer buffer, @Nullable Chunk parent) {
@@ -111,7 +129,8 @@ public abstract class Chunk implements SerializableResource {
* *
* @param buffer The buffer that the payload will be initialized from. * @param buffer The buffer that the payload will be initialized from.
*/ */
protected void init(ByteBuffer buffer) {} protected void init(ByteBuffer buffer) {
}
/** /**
* Returns the parent to this chunk, if any. A parent is a chunk whose payload contains this * Returns the parent to this chunk, if any. A parent is a chunk whose payload contains this
@@ -124,7 +143,9 @@ public abstract class Chunk implements SerializableResource {
protected abstract Type getType(); protected abstract Type getType();
/** Returns the size of this chunk's header. */ /**
* Returns the size of this chunk's header.
*/
public final int getHeaderSize() { public final int getHeaderSize() {
return headerSize; return headerSize;
} }
@@ -142,6 +163,7 @@ public abstract class Chunk implements SerializableResource {
/** /**
* Reposition the buffer after this chunk. Use this at the end of a Chunk constructor. * Reposition the buffer after this chunk. Use this at the end of a Chunk constructor.
*
* @param buffer The buffer to be repositioned. * @param buffer The buffer to be repositioned.
*/ */
private final void seekToEndOfChunk(ByteBuffer buffer) { private final void seekToEndOfChunk(ByteBuffer buffer) {
@@ -171,7 +193,8 @@ public abstract class Chunk implements SerializableResource {
* *
* @param output The buffer that the header will be written to. * @param output The buffer that the header will be written to.
*/ */
protected void writeHeader(ByteBuffer output) {} protected void writeHeader(ByteBuffer output) {
}
/** /**
* Writes the chunk payload. The payload is data in a chunk which is not in * Writes the chunk payload. The payload is data in a chunk which is not in
@@ -183,7 +206,8 @@ public abstract class Chunk implements SerializableResource {
* @throws IOException Thrown if {@code output} could not be written to (out of memory). * @throws IOException Thrown if {@code output} could not be written to (out of memory).
*/ */
protected void writePayload(DataOutput output, ByteBuffer header, boolean shrink) protected void writePayload(DataOutput output, ByteBuffer header, boolean shrink)
throws IOException {} throws IOException {
}
/** /**
* Pads {@code output} until {@code currentLength} is on a 4-byte boundary. * Pads {@code output} until {@code currentLength} is on a 4-byte boundary.
@@ -24,7 +24,9 @@ import java.nio.ByteBuffer;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
/** Represents a chunk whose payload is a list of sub-chunks. */ /**
* Represents a chunk whose payload is a list of sub-chunks.
*/
public abstract class ChunkWithChunks extends Chunk { public abstract class ChunkWithChunks extends Chunk {
private final Map<Integer, Chunk> chunks = new LinkedHashMap<>(); private final Map<Integer, Chunk> chunks = new LinkedHashMap<>();
@@ -17,6 +17,7 @@
package com.google.devrel.gmscore.tools.apk.arsc; package com.google.devrel.gmscore.tools.apk.arsc;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import java.io.DataOutput; import java.io.DataOutput;
import java.io.IOException; import java.io.IOException;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
@@ -32,10 +33,14 @@ import java.util.Objects;
*/ */
public final class LibraryChunk extends Chunk { public final class LibraryChunk extends Chunk {
/** The number of resources of this type at creation time. */ /**
* The number of resources of this type at creation time.
*/
private final int entryCount; private final int entryCount;
/** The libraries used in this chunk (package id + name). */ /**
* The libraries used in this chunk (package id + name).
*/
private final List<Entry> entries = new ArrayList<>(); private final List<Entry> entries = new ArrayList<>();
protected LibraryChunk(ByteBuffer buffer, @Nullable Chunk parent) { protected LibraryChunk(ByteBuffer buffer, @Nullable Chunk parent) {
@@ -80,10 +85,14 @@ public final class LibraryChunk extends Chunk {
} }
} }
/** A shared library package-id to package name entry. */ /**
* A shared library package-id to package name entry.
*/
protected static class Entry implements SerializableResource { protected static class Entry implements SerializableResource {
/** Library entries only contain a package ID (4 bytes) and a package name. */ /**
* Library entries only contain a package ID (4 bytes) and a package name.
*/
private static final int SIZE = 4 + PackageUtils.PACKAGE_NAME_SIZE; private static final int SIZE = 4 + PackageUtils.PACKAGE_NAME_SIZE;
private final int packageId; private final int packageId;
@@ -100,11 +109,19 @@ public final class LibraryChunk extends Chunk {
this.packageName = packageName; this.packageName = packageName;
} }
/** The id assigned to the shared library at build time. */ /**
public int packageId() { return packageId; } * The id assigned to the shared library at build time.
*/
public int packageId() {
return packageId;
}
/** The package name of the shared library. */ /**
public String packageName() { return packageName; } * The package name of the shared library.
*/
public String packageName() {
return packageName;
}
@Override @Override
public byte[] toByteArray() throws IOException { public byte[] toByteArray() throws IOException {
@@ -16,11 +16,11 @@
package com.google.devrel.gmscore.tools.apk.arsc; package com.google.devrel.gmscore.tools.apk.arsc;
import androidx.annotation.Nullable;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap; import com.google.common.collect.Multimap;
import androidx.annotation.Nullable;
import java.io.DataOutput; import java.io.DataOutput;
import java.io.IOException; import java.io.IOException;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
@@ -29,43 +29,69 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
/** A package chunk is a collection of resource data types within a package. */ /**
* A package chunk is a collection of resource data types within a package.
*/
public final class PackageChunk extends ChunkWithChunks { public final class PackageChunk extends ChunkWithChunks {
/** Offset in bytes, from the start of the chunk, where {@code typeStringsOffset} can be found. */ /**
* Offset in bytes, from the start of the chunk, where {@code typeStringsOffset} can be found.
*/
private static final int TYPE_OFFSET_OFFSET = 268; private static final int TYPE_OFFSET_OFFSET = 268;
/** Offset in bytes, from the start of the chunk, where {@code keyStringsOffset} can be found. */ /**
* Offset in bytes, from the start of the chunk, where {@code keyStringsOffset} can be found.
*/
private static final int KEY_OFFSET_OFFSET = 276; private static final int KEY_OFFSET_OFFSET = 276;
/** The package id if this is a base package, or 0 if not a base package. */ /**
* The package id if this is a base package, or 0 if not a base package.
*/
private int id; private int id;
/** The name of the package. */ /**
* The name of the package.
*/
private String packageName; private String packageName;
/** The offset (from {@code offset}) in the original buffer where type strings start. */ /**
* The offset (from {@code offset}) in the original buffer where type strings start.
*/
private final int typeStringsOffset; private final int typeStringsOffset;
/** The index into the type string pool of the last public type. */ /**
* The index into the type string pool of the last public type.
*/
private final int lastPublicType; private final int lastPublicType;
/** An offset to the string pool that contains the key strings for this package. */ /**
* An offset to the string pool that contains the key strings for this package.
*/
private final int keyStringsOffset; private final int keyStringsOffset;
/** The index into the key string pool of the last public key. */ /**
* The index into the key string pool of the last public key.
*/
private final int lastPublicKey; private final int lastPublicKey;
/** An offset to the type ID(s). This is undocumented in the original code. */ /**
* An offset to the type ID(s). This is undocumented in the original code.
*/
private final int typeIdOffset; private final int typeIdOffset;
/** Contains a mapping of a type index to its {@link TypeSpecChunk}. */ /**
* Contains a mapping of a type index to its {@link TypeSpecChunk}.
*/
private final Map<Integer, TypeSpecChunk> typeSpecs = new HashMap<>(); private final Map<Integer, TypeSpecChunk> typeSpecs = new HashMap<>();
/** Contains a mapping of a type index to all of the {@link TypeChunk} with that index. */ /**
* Contains a mapping of a type index to all of the {@link TypeChunk} with that index.
*/
private final Multimap<Integer, TypeChunk> types = ArrayListMultimap.create(); private final Multimap<Integer, TypeChunk> types = ArrayListMultimap.create();
/** May contain a library chunk for mapping dynamic references to resolved references. */ /**
* May contain a library chunk for mapping dynamic references to resolved references.
*/
private Optional<LibraryChunk> libraryChunk = Optional.empty(); private Optional<LibraryChunk> libraryChunk = Optional.empty();
protected PackageChunk(ByteBuffer buffer, @Nullable Chunk parent) { protected PackageChunk(ByteBuffer buffer, @Nullable Chunk parent) {
@@ -102,12 +128,16 @@ public final class PackageChunk extends ChunkWithChunks {
} }
} }
/** Returns the package id if this is a base package, or 0 if not a base package. */ /**
* Returns the package id if this is a base package, or 0 if not a base package.
*/
public int getId() { public int getId() {
return id; return id;
} }
/** Sets the package id */ /**
* Sets the package id
*/
public void setId(int id) { public void setId(int id) {
this.id = id; this.id = id;
} }
@@ -144,7 +174,9 @@ public final class PackageChunk extends ChunkWithChunks {
return (StringPoolChunk) chunk; return (StringPoolChunk) chunk;
} }
/** Returns all {@link TypeChunk} in this package. */ /**
* Returns all {@link TypeChunk} in this package.
*/
public Collection<TypeChunk> getTypeChunks() { public Collection<TypeChunk> getTypeChunks() {
return types.values(); return types.values();
} }
@@ -172,12 +204,16 @@ public final class PackageChunk extends ChunkWithChunks {
return getTypeChunks(typeStringPool.indexOf(type) + 1); // Convert 0-based index to 1-based return getTypeChunks(typeStringPool.indexOf(type) + 1); // Convert 0-based index to 1-based
} }
/** Returns all {@link TypeSpecChunk} in this package. */ /**
* Returns all {@link TypeSpecChunk} in this package.
*/
public Collection<TypeSpecChunk> getTypeSpecChunks() { public Collection<TypeSpecChunk> getTypeSpecChunks() {
return typeSpecs.values(); return typeSpecs.values();
} }
/** For a given (1-based) type id, returns the {@link TypeSpecChunk} matching it. */ /**
* For a given (1-based) type id, returns the {@link TypeSpecChunk} matching it.
*/
public TypeSpecChunk getTypeSpecChunk(int id) { public TypeSpecChunk getTypeSpecChunk(int id) {
return Preconditions.checkNotNull(typeSpecs.get(id)); return Preconditions.checkNotNull(typeSpecs.get(id));
} }
@@ -191,12 +227,16 @@ public final class PackageChunk extends ChunkWithChunks {
return getTypeSpecChunk(typeStringPool.indexOf(type) + 1); // Convert 0-based index to 1-based return getTypeSpecChunk(typeStringPool.indexOf(type) + 1); // Convert 0-based index to 1-based
} }
/** Returns the name of this package. */ /**
* Returns the name of this package.
*/
public String getPackageName() { public String getPackageName() {
return packageName; return packageName;
} }
/** Set the package name */ /**
* Set the package name
*/
public void setPackageName(String packageName) { public void setPackageName(String packageName) {
this.packageName = packageName; this.packageName = packageName;
} }
@@ -20,16 +20,20 @@ import java.nio.ByteBuffer;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
/** Provides utility methods for package names. */ /**
* Provides utility methods for package names.
*/
public final class PackageUtils { public final class PackageUtils {
public static final int PACKAGE_NAME_SIZE = 256; public static final int PACKAGE_NAME_SIZE = 256;
private PackageUtils() {} // Prevent instantiation private PackageUtils() {
} // Prevent instantiation
/** /**
* Reads the package name from the buffer and repositions the buffer to point directly after * Reads the package name from the buffer and repositions the buffer to point directly after
* the package name. * the package name.
*
* @param buffer The buffer containing the package name. * @param buffer The buffer containing the package name.
* @param offset The offset in the buffer to read from. * @param offset The offset in the buffer to read from.
* @return The package name. * @return The package name.
@@ -53,6 +57,7 @@ public final class PackageUtils {
/** /**
* Writes the provided package name to the buffer in UTF-16. * Writes the provided package name to the buffer in UTF-16.
*
* @param buffer The buffer that will be written to. * @param buffer The buffer that will be written to.
* @param packageName The package name that will be written to the buffer. * @param packageName The package name that will be written to the buffer.
*/ */
@@ -26,15 +26,19 @@ import java.util.Map.Entry;
/** /**
* Calculates extra information about an {@link ResourceEntry}, such as the total * Calculates extra information about an {@link ResourceEntry}, such as the total
* APK size the entry is responsible for. * APK size the entry is responsible for.
* * <p>
* This class is not thread-safe. * This class is not thread-safe.
*/ */
public class ResourceEntryStatsCollector { public class ResourceEntryStatsCollector {
/** The size in bytes of an offset in a chunk. */ /**
* The size in bytes of an offset in a chunk.
*/
private static final int OFFSET_SIZE = 4; private static final int OFFSET_SIZE = 4;
/** The size in bytes of overhead for styles, if present, in {@link StringPoolChunk}. */ /**
* The size in bytes of overhead for styles, if present, in {@link StringPoolChunk}.
*/
private static final int STYLE_OVERHEAD = 8; private static final int STYLE_OVERHEAD = 8;
/** /**
@@ -67,13 +71,17 @@ public class ResourceEntryStatsCollector {
computePackageSizes(); computePackageSizes();
} }
/** Returns entries for which there are computed stats. Must first call {@link #compute}. */ /**
* Returns entries for which there are computed stats. Must first call {@link #compute}.
*/
public Map<ResourceEntry, ResourceStatistics> getStats() { public Map<ResourceEntry, ResourceStatistics> getStats() {
Preconditions.checkState(!stats.isEmpty(), "Must call #compute() first."); Preconditions.checkState(!stats.isEmpty(), "Must call #compute() first.");
return Collections.unmodifiableMap(stats); return Collections.unmodifiableMap(stats);
} }
/** Returns computed stats for a given entry. Must first call {@link #compute}. */ /**
* Returns computed stats for a given entry. Must first call {@link #compute}.
*/
public ResourceStatistics getStats(ResourceEntry entry) { public ResourceStatistics getStats(ResourceEntry entry) {
Preconditions.checkState(!stats.isEmpty(), "Must call #compute() first."); Preconditions.checkState(!stats.isEmpty(), "Must call #compute() first.");
return stats.containsKey(entry) ? stats.get(entry) : ResourceStatistics.EMPTY; return stats.containsKey(entry) ? stats.get(entry) : ResourceStatistics.EMPTY;
@@ -185,7 +193,9 @@ public class ResourceEntryStatsCollector {
return computeStringSize(stringPool, index) + computeStyleSize(stringPool, index); return computeStringSize(stringPool, index) + computeStyleSize(stringPool, index);
} }
/** Given an {@code index} into a {@code stringPool}, return string's total size in bytes. */ /**
* Given an {@code index} into a {@code stringPool}, return string's total size in bytes.
*/
private int computeStringSize(StringPoolChunk stringPool, int index) { private int computeStringSize(StringPoolChunk stringPool, int index) {
String string = stringPool.getString(index); String string = stringPool.getString(index);
int result = BinaryResourceString.encodeString(string, stringPool.getStringType()).length; int result = BinaryResourceString.encodeString(string, stringPool.getStringType()).length;
@@ -238,29 +248,40 @@ public class ResourceEntryStatsCollector {
} }
} }
/** Stats for an individual {@link ResourceEntry}. */ /**
* Stats for an individual {@link ResourceEntry}.
*/
public static class ResourceStatistics { public static class ResourceStatistics {
/** The empty, immutable instance of ResourceStatistics which contains 0 for all values. */ /**
* The empty, immutable instance of ResourceStatistics which contains 0 for all values.
*/
public static final ResourceStatistics EMPTY = new ResourceStatistics(); public static final ResourceStatistics EMPTY = new ResourceStatistics();
private int privateSize = 0; private int privateSize = 0;
private int sharedSize = 0; private int sharedSize = 0;
private double proportionalSize = 0; private double proportionalSize = 0;
private ResourceStatistics() {} private ResourceStatistics() {
}
/** The number of bytes that would be freed if this resource was removed. */ /**
* The number of bytes that would be freed if this resource was removed.
*/
public int getPrivateSize() { public int getPrivateSize() {
return privateSize; return privateSize;
} }
/** The number of bytes taken up by this resource that are also shared with other resources. */ /**
* The number of bytes taken up by this resource that are also shared with other resources.
*/
public int getSharedSize() { public int getSharedSize() {
return sharedSize; return sharedSize;
} }
/** The total size this resource is responsible for. */ /**
* The total size this resource is responsible for.
*/
public double getProportionalSize() { public double getProportionalSize() {
return proportionalSize; return proportionalSize;
} }
@@ -16,9 +16,9 @@
package com.google.devrel.gmscore.tools.apk.arsc; package com.google.devrel.gmscore.tools.apk.arsc;
import androidx.annotation.Nullable;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import androidx.annotation.Nullable;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
@@ -36,10 +36,14 @@ import java.util.Map;
*/ */
public final class ResourceTableChunk extends ChunkWithChunks { public final class ResourceTableChunk extends ChunkWithChunks {
/** A string pool containing all string resource values in the entire resource table. */ /**
* A string pool containing all string resource values in the entire resource table.
*/
private StringPoolChunk stringPool; private StringPoolChunk stringPool;
/** The packages contained in this resource table. */ /**
* The packages contained in this resource table.
*/
private final Map<String, PackageChunk> packages = new HashMap<>(); private final Map<String, PackageChunk> packages = new HashMap<>();
protected ResourceTableChunk(ByteBuffer buffer, @Nullable Chunk parent) { protected ResourceTableChunk(ByteBuffer buffer, @Nullable Chunk parent) {
@@ -63,18 +67,24 @@ public final class ResourceTableChunk extends ChunkWithChunks {
Preconditions.checkNotNull(stringPool, "ResourceTableChunk must have a string pool."); Preconditions.checkNotNull(stringPool, "ResourceTableChunk must have a string pool.");
} }
/** Returns the string pool containing all string resource values in the resource table. */ /**
* Returns the string pool containing all string resource values in the resource table.
*/
public StringPoolChunk getStringPool() { public StringPoolChunk getStringPool() {
return stringPool; return stringPool;
} }
/** Returns the package with the given {@code packageName}. Else, returns null. */ /**
* Returns the package with the given {@code packageName}. Else, returns null.
*/
@Nullable @Nullable
public PackageChunk getPackage(String packageName) { public PackageChunk getPackage(String packageName) {
return packages.get(packageName); return packages.get(packageName);
} }
/** Returns the packages contained in this resource table. */ /**
* Returns the packages contained in this resource table.
*/
public Collection<PackageChunk> getPackages() { public Collection<PackageChunk> getPackages() {
return Collections.unmodifiableCollection(packages.values()); return Collections.unmodifiableCollection(packages.values());
} }
@@ -25,6 +25,7 @@ public interface SerializableResource {
/** /**
* Converts this resource into an array of bytes representation. * Converts this resource into an array of bytes representation.
*
* @return An array of bytes representing this resource. * @return An array of bytes representing this resource.
* @throws IOException * @throws IOException
*/ */
@@ -32,6 +33,7 @@ public interface SerializableResource {
/** /**
* Converts this resource into an array of bytes representation. * Converts this resource into an array of bytes representation.
*
* @param shrink True if, when converting to a byte array, this resource can modify the returned * @param shrink True if, when converting to a byte array, this resource can modify the returned
* bytes in an effort to reduce the size. * bytes in an effort to reduce the size.
* @return An array of bytes representing this resource. * @return An array of bytes representing this resource.
@@ -16,11 +16,11 @@
package com.google.devrel.gmscore.tools.apk.arsc; package com.google.devrel.gmscore.tools.apk.arsc;
import androidx.annotation.Nullable;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableList.Builder; import com.google.common.collect.ImmutableList.Builder;
import com.google.common.io.LittleEndianDataOutputStream; import com.google.common.io.LittleEndianDataOutputStream;
import androidx.annotation.Nullable;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.DataOutput; import java.io.DataOutput;
import java.io.IOException; import java.io.IOException;
@@ -28,23 +28,33 @@ import java.nio.ByteBuffer;
import java.nio.ByteOrder; import java.nio.ByteOrder;
import java.util.*; import java.util.*;
/** Represents a string pool structure. */ /**
* Represents a string pool structure.
*/
public final class StringPoolChunk extends Chunk { public final class StringPoolChunk extends Chunk {
// These are the defined flags for the "flags" field of ResourceStringPoolHeader // These are the defined flags for the "flags" field of ResourceStringPoolHeader
private static final int SORTED_FLAG = 1 << 0; private static final int SORTED_FLAG = 1 << 0;
private static final int UTF8_FLAG = 1 << 8; private static final int UTF8_FLAG = 1 << 8;
/** The offset from the start of the header that the stylesStart field is at. */ /**
* The offset from the start of the header that the stylesStart field is at.
*/
private static final int STYLE_START_OFFSET = 24; private static final int STYLE_START_OFFSET = 24;
/** Flags. */ /**
* Flags.
*/
private final int flags; private final int flags;
/** Index from header of the string data. */ /**
* Index from header of the string data.
*/
private final int stringsStart; private final int stringsStart;
/** Index from header of the style data. */ /**
* Index from header of the style data.
*/
private final int stylesStart; private final int stylesStart;
/** /**
@@ -120,7 +130,9 @@ public final class StringPoolChunk extends Chunk {
strings.set(index, value); strings.set(index, value);
} }
/** Returns the number of strings in this pool. */ /**
* Returns the number of strings in this pool.
*/
public int getStringCount() { public int getStringCount() {
return strings.size(); return strings.size();
} }
@@ -135,12 +147,16 @@ public final class StringPoolChunk extends Chunk {
return styles.get(index); return styles.get(index);
} }
/** Returns the number of styles in this pool. */ /**
* Returns the number of styles in this pool.
*/
public int getStyleCount() { public int getStyleCount() {
return styles.size(); return styles.size();
} }
/** Returns the type of strings in this pool. */ /**
* Returns the type of strings in this pool.
*/
public BinaryResourceString.Type getStringType() { public BinaryResourceString.Type getStringType() {
return isUTF8() ? BinaryResourceString.Type.UTF8 : BinaryResourceString.Type.UTF16; return isUTF8() ? BinaryResourceString.Type.UTF8 : BinaryResourceString.Type.UTF16;
} }
@@ -150,7 +166,9 @@ public final class StringPoolChunk extends Chunk {
return Type.STRING_POOL; return Type.STRING_POOL;
} }
/** Returns the number of bytes needed for offsets based on {@code strings} and {@code styles}. */ /**
* Returns the number of bytes needed for offsets based on {@code strings} and {@code styles}.
*/
private int getOffsetSize() { private int getOffsetSize() {
return (strings.size() + styles.size()) * 4; return (strings.size() + styles.size()) * 4;
} }
@@ -355,7 +373,9 @@ public final class StringPoolChunk extends Chunk {
} }
} }
/** Represents a styled span associated with a specific string. */ /**
* Represents a styled span associated with a specific string.
*/
private static class StringPoolSpan implements SerializableResource { private static class StringPoolSpan implements SerializableResource {
static final int SPAN_LENGTH = 12; static final int SPAN_LENGTH = 12;
@@ -16,11 +16,11 @@
package com.google.devrel.gmscore.tools.apk.arsc; package com.google.devrel.gmscore.tools.apk.arsc;
import androidx.annotation.Nullable;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import com.google.common.io.LittleEndianDataOutputStream; import com.google.common.io.LittleEndianDataOutputStream;
import com.google.common.primitives.UnsignedBytes; import com.google.common.primitives.UnsignedBytes;
import androidx.annotation.Nullable;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.DataOutput; import java.io.DataOutput;
import java.io.IOException; import java.io.IOException;
@@ -38,19 +38,29 @@ import java.util.*;
*/ */
public final class TypeChunk extends Chunk { public final class TypeChunk extends Chunk {
/** The type identifier of the resource type this chunk is holding. */ /**
* The type identifier of the resource type this chunk is holding.
*/
private final int id; private final int id;
/** The number of resources of this type at creation time. */ /**
* The number of resources of this type at creation time.
*/
private final int entryCount; private final int entryCount;
/** The offset (from {@code offset}) in the original buffer where {@code entries} start. */ /**
* The offset (from {@code offset}) in the original buffer where {@code entries} start.
*/
private final int entriesStart; private final int entriesStart;
/** The resource configuration that these resource entries correspond to. */ /**
* The resource configuration that these resource entries correspond to.
*/
private BinaryResourceConfiguration configuration; private BinaryResourceConfiguration configuration;
/** A sparse list of resource entries defined by this chunk. */ /**
* A sparse list of resource entries defined by this chunk.
*/
private final Map<Integer, Entry> entries = new TreeMap<>(); private final Map<Integer, Entry> entries = new TreeMap<>();
protected TypeChunk(ByteBuffer buffer, @Nullable Chunk parent) { protected TypeChunk(ByteBuffer buffer, @Nullable Chunk parent) {
@@ -73,12 +83,16 @@ public final class TypeChunk extends Chunk {
} }
} }
/** Returns the (1-based) type id of the resource types that this {@link TypeChunk} is holding. */ /**
* Returns the (1-based) type id of the resource types that this {@link TypeChunk} is holding.
*/
public int getId() { public int getId() {
return id; return id;
} }
/** Returns the name of the type this chunk represents (e.g. string, attr, id). */ /**
* Returns the name of the type this chunk represents (e.g. string, attr, id).
*/
public String getTypeName() { public String getTypeName() {
PackageChunk packageChunk = getPackageChunk(); PackageChunk packageChunk = getPackageChunk();
Preconditions.checkNotNull(packageChunk, "%s has no parent package.", getClass()); Preconditions.checkNotNull(packageChunk, "%s has no parent package.", getClass());
@@ -87,7 +101,9 @@ public final class TypeChunk extends Chunk {
return typePool.getString(getId() - 1); // - 1 here to convert to 0-based index return typePool.getString(getId() - 1); // - 1 here to convert to 0-based index
} }
/** Returns the resource configuration that these resource entries correspond to. */ /**
* Returns the resource configuration that these resource entries correspond to.
*/
public BinaryResourceConfiguration getConfiguration() { public BinaryResourceConfiguration getConfiguration() {
return configuration; return configuration;
} }
@@ -101,17 +117,23 @@ public final class TypeChunk extends Chunk {
this.configuration = configuration; this.configuration = configuration;
} }
/** Returns the total number of entries for this type + configuration, including null entries. */ /**
* Returns the total number of entries for this type + configuration, including null entries.
*/
public int getTotalEntryCount() { public int getTotalEntryCount() {
return entryCount; return entryCount;
} }
/** Returns a sparse list of 0-based indices to resource entries defined by this chunk. */ /**
* Returns a sparse list of 0-based indices to resource entries defined by this chunk.
*/
public Map<Integer, Entry> getEntries() { public Map<Integer, Entry> getEntries() {
return Collections.unmodifiableMap(entries); return Collections.unmodifiableMap(entries);
} }
/** Returns true if this chunk contains an entry for {@code resourceId}. */ /**
* Returns true if this chunk contains an entry for {@code resourceId}.
*/
public boolean containsResource(BinaryResourceIdentifier resourceId) { public boolean containsResource(BinaryResourceIdentifier resourceId) {
PackageChunk packageChunk = Preconditions.checkNotNull(getPackageChunk()); PackageChunk packageChunk = Preconditions.checkNotNull(getPackageChunk());
int packageId = packageChunk.getId(); int packageId = packageChunk.getId();
@@ -185,7 +207,9 @@ public final class TypeChunk extends Chunk {
return chunk != null ? (ResourceTableChunk) chunk : null; return chunk != null ? (ResourceTableChunk) chunk : null;
} }
/** Returns the package enclosing this chunk, if any. Else, returns null. */ /**
* Returns the package enclosing this chunk, if any. Else, returns null.
*/
@Nullable @Nullable
public PackageChunk getPackageChunk() { public PackageChunk getPackageChunk() {
Chunk chunk = getParent(); Chunk chunk = getParent();
@@ -200,7 +224,9 @@ public final class TypeChunk extends Chunk {
return Type.TABLE_TYPE; return Type.TABLE_TYPE;
} }
/** Returns the number of bytes needed for offsets based on {@code entries}. */ /**
* Returns the number of bytes needed for offsets based on {@code entries}.
*/
private int getOffsetSize() { private int getOffsetSize() {
return entryCount * 4; return entryCount * 4;
} }
@@ -244,16 +270,24 @@ public final class TypeChunk extends Chunk {
output.write(baos.toByteArray()); output.write(baos.toByteArray());
} }
/** An {@link Entry} in a {@link TypeChunk}. Contains one or more {@link BinaryResourceValue}. */ /**
* An {@link Entry} in a {@link TypeChunk}. Contains one or more {@link BinaryResourceValue}.
*/
public static class Entry implements SerializableResource { public static class Entry implements SerializableResource {
/** An entry offset that indicates that a given resource is not present. */ /**
* An entry offset that indicates that a given resource is not present.
*/
public static final int NO_ENTRY = 0xFFFFFFFF; public static final int NO_ENTRY = 0xFFFFFFFF;
/** Set if this is a complex resource. Otherwise, it's a simple resource. */ /**
* Set if this is a complex resource. Otherwise, it's a simple resource.
*/
private static final int FLAG_COMPLEX = 0x0001; private static final int FLAG_COMPLEX = 0x0001;
/** Size of a single resource id + value mapping entry. */ /**
* Size of a single resource id + value mapping entry.
*/
private static final int MAPPING_SIZE = 4 + BinaryResourceValue.SIZE; private static final int MAPPING_SIZE = 4 + BinaryResourceValue.SIZE;
private final int headerSize; private final int headerSize;
@@ -280,31 +314,54 @@ public final class TypeChunk extends Chunk {
this.parent = parent; this.parent = parent;
} }
/** Number of bytes in the header of the {@link Entry}. */ /**
public int headerSize() { return headerSize; } * Number of bytes in the header of the {@link Entry}.
*/
public int headerSize() {
return headerSize;
}
/** Resource entry flags. */ /**
public int flags() { return flags; } * Resource entry flags.
*/
public int flags() {
return flags;
}
/** Index into {@link PackageChunk#getKeyStringPool} identifying this entry. */ /**
public int keyIndex() { return keyIndex; } * Index into {@link PackageChunk#getKeyStringPool} identifying this entry.
*/
public int keyIndex() {
return keyIndex;
}
/** The value of this resource entry, if this is not a complex entry. Else, null. */ /**
* The value of this resource entry, if this is not a complex entry. Else, null.
*/
@Nullable @Nullable
public BinaryResourceValue value() { return value; } public BinaryResourceValue value() {
return value;
}
/** /**
* Update the value of this resource entry * Update the value of this resource entry
*
* @param value * @param value
*/ */
public void updateValue(@Nullable BinaryResourceValue value) { public void updateValue(@Nullable BinaryResourceValue value) {
this.value = value; this.value = value;
} }
/** The extra values in this resource entry if this {@link #isComplex}. */ /**
public Map<Integer, BinaryResourceValue> values() { return values; } * The extra values in this resource entry if this {@link #isComplex}.
*/
public Map<Integer, BinaryResourceValue> values() {
return values;
}
/** Update the value in this resource entry if this {@link #isComplex}. */ /**
* Update the value in this resource entry if this {@link #isComplex}.
*/
public void updateValue(int index, BinaryResourceValue value) { public void updateValue(int index, BinaryResourceValue value) {
if (index >= 0) { if (index >= 0) {
if (value != null) { if (value != null) {
@@ -319,32 +376,48 @@ public final class TypeChunk extends Chunk {
* Entry into {@link PackageChunk} that is the parent {@link Entry} to this entry. * Entry into {@link PackageChunk} that is the parent {@link Entry} to this entry.
* This value only makes sense when this is complex ({@link #isComplex} returns true). * This value only makes sense when this is complex ({@link #isComplex} returns true).
*/ */
public int parentEntry() { return parentEntry; } public int parentEntry() {
return parentEntry;
}
/** The {@link TypeChunk} that this resource entry belongs to. */ /**
public TypeChunk parent() { return parent; } * The {@link TypeChunk} that this resource entry belongs to.
*/
public TypeChunk parent() {
return parent;
}
/** Returns the name of the type this chunk represents (e.g. string, attr, id). */ /**
* Returns the name of the type this chunk represents (e.g. string, attr, id).
*/
public final String typeName() { public final String typeName() {
return parent().getTypeName(); return parent().getTypeName();
} }
/** The total number of bytes that this {@link Entry} takes up. */ /**
* The total number of bytes that this {@link Entry} takes up.
*/
public final int size() { public final int size() {
return headerSize() + (isComplex() ? values().size() * MAPPING_SIZE : BinaryResourceValue.SIZE); return headerSize() + (isComplex() ? values().size() * MAPPING_SIZE : BinaryResourceValue.SIZE);
} }
/** Returns the key name identifying this resource entry. */ /**
* Returns the key name identifying this resource entry.
*/
public final String key() { public final String key() {
return parent().getKeyName(keyIndex()); return parent().getKeyName(keyIndex());
} }
/** Update the key name in this resource entry. */ /**
* Update the key name in this resource entry.
*/
public final void updateKey(int keyIndex, String value) { public final void updateKey(int keyIndex, String value) {
parent().updateKey(keyIndex, value); parent().updateKey(keyIndex, value);
} }
/** Returns true if this is a complex resource. */ /**
* Returns true if this is a complex resource.
*/
public final boolean isComplex() { public final boolean isComplex() {
return (flags() & FLAG_COMPLEX) != 0; return (flags() & FLAG_COMPLEX) != 0;
} }
@@ -16,21 +16,27 @@
package com.google.devrel.gmscore.tools.apk.arsc; package com.google.devrel.gmscore.tools.apk.arsc;
import androidx.annotation.Nullable;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import com.google.common.primitives.UnsignedBytes; import com.google.common.primitives.UnsignedBytes;
import androidx.annotation.Nullable;
import java.io.DataOutput; import java.io.DataOutput;
import java.io.IOException; import java.io.IOException;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
/** A chunk that contains a collection of resource entries for a particular resource data type. */ /**
* A chunk that contains a collection of resource entries for a particular resource data type.
*/
public final class TypeSpecChunk extends Chunk { public final class TypeSpecChunk extends Chunk {
/** The id of the resource type that this type spec refers to. */ /**
* The id of the resource type that this type spec refers to.
*/
private final int id; private final int id;
/** Resource configuration masks. */ /**
* Resource configuration masks.
*/
private final int[] resources; private final int[] resources;
protected TypeSpecChunk(ByteBuffer buffer, @Nullable Chunk parent) { protected TypeSpecChunk(ByteBuffer buffer, @Nullable Chunk parent) {
@@ -53,7 +59,9 @@ public final class TypeSpecChunk extends Chunk {
return id; return id;
} }
/** Returns the number of resource entries that this chunk has configuration masks for. */ /**
* Returns the number of resource entries that this chunk has configuration masks for.
*/
public int getResourceCount() { public int getResourceCount() {
return resources.length; return resources.length;
} }
@@ -63,7 +71,9 @@ public final class TypeSpecChunk extends Chunk {
return Type.TABLE_TYPE_SPEC; return Type.TABLE_TYPE_SPEC;
} }
/** Returns the name of the type this chunk represents (e.g. string, attr, id). */ /**
* Returns the name of the type this chunk represents (e.g. string, attr, id).
*/
public String getTypeName() { public String getTypeName() {
PackageChunk packageChunk = getPackageChunk(); PackageChunk packageChunk = getPackageChunk();
Preconditions.checkNotNull(packageChunk, "%s has no parent package.", getClass()); Preconditions.checkNotNull(packageChunk, "%s has no parent package.", getClass());
@@ -72,7 +82,9 @@ public final class TypeSpecChunk extends Chunk {
return typePool.getString(getId() - 1); // - 1 here to convert to 0-based index return typePool.getString(getId() - 1); // - 1 here to convert to 0-based index
} }
/** Returns the package enclosing this chunk, if any. Else, returns null. */ /**
* Returns the package enclosing this chunk, if any. Else, returns null.
*/
@Nullable @Nullable
private PackageChunk getPackageChunk() { private PackageChunk getPackageChunk() {
Chunk chunk = getParent(); Chunk chunk = getParent();
@@ -17,6 +17,7 @@
package com.google.devrel.gmscore.tools.apk.arsc; package com.google.devrel.gmscore.tools.apk.arsc;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import java.io.DataOutput; import java.io.DataOutput;
import java.io.IOException; import java.io.IOException;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
@@ -20,10 +20,14 @@ import java.nio.ByteBuffer;
import java.nio.ByteOrder; import java.nio.ByteOrder;
import java.util.Objects; import java.util.Objects;
/** Represents an XML attribute and value. */ /**
* Represents an XML attribute and value.
*/
public class XmlAttribute implements SerializableResource { public class XmlAttribute implements SerializableResource {
/** The serialized size in bytes of an {@link XmlAttribute}. */ /**
* The serialized size in bytes of an {@link XmlAttribute}.
*/
public static final int SIZE = 12 + BinaryResourceValue.SIZE; public static final int SIZE = 12 + BinaryResourceValue.SIZE;
private final int namespaceIndex; private final int namespaceIndex;
@@ -58,42 +62,58 @@ public class XmlAttribute implements SerializableResource {
this.parent = parent; this.parent = parent;
} }
/** A string reference to the namespace URI, or -1 if not present. */ /**
* A string reference to the namespace URI, or -1 if not present.
*/
public int namespaceIndex() { public int namespaceIndex() {
return namespaceIndex; return namespaceIndex;
} }
/** A string reference to the attribute name. */ /**
* A string reference to the attribute name.
*/
public int nameIndex() { public int nameIndex() {
return nameIndex; return nameIndex;
} }
/** A string reference to a string containing the character value. */ /**
* A string reference to a string containing the character value.
*/
public int rawValueIndex() { public int rawValueIndex() {
return rawValueIndex; return rawValueIndex;
} }
/** A {@link BinaryResourceValue} instance containing the parsed value. */ /**
* A {@link BinaryResourceValue} instance containing the parsed value.
*/
public BinaryResourceValue typedValue() { public BinaryResourceValue typedValue() {
return typedValue; return typedValue;
} }
/** The parent of this XML attribute; used for dereferencing the namespace and name. */ /**
* The parent of this XML attribute; used for dereferencing the namespace and name.
*/
public XmlNodeChunk parent() { public XmlNodeChunk parent() {
return parent; return parent;
} }
/** The namespace URI, or the empty string if not present. */ /**
* The namespace URI, or the empty string if not present.
*/
public final String namespace() { public final String namespace() {
return getString(namespaceIndex()); return getString(namespaceIndex());
} }
/** The attribute name, or the empty string if not present. */ /**
* The attribute name, or the empty string if not present.
*/
public final String name() { public final String name() {
return getString(nameIndex()); return getString(nameIndex());
} }
/** The raw character value. */ /**
* The raw character value.
*/
public final String rawValue() { public final String rawValue() {
return getString(rawValueIndex()); return getString(rawValueIndex());
} }
@@ -17,17 +17,24 @@
package com.google.devrel.gmscore.tools.apk.arsc; package com.google.devrel.gmscore.tools.apk.arsc;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import java.io.DataOutput; import java.io.DataOutput;
import java.io.IOException; import java.io.IOException;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
/** Represents an XML cdata node. */ /**
* Represents an XML cdata node.
*/
public final class XmlCdataChunk extends XmlNodeChunk { public final class XmlCdataChunk extends XmlNodeChunk {
/** A string reference to a string containing the raw character data. */ /**
* A string reference to a string containing the raw character data.
*/
private final int rawValue; private final int rawValue;
/** A {@link BinaryResourceValue} instance containing the parsed value. */ /**
* A {@link BinaryResourceValue} instance containing the parsed value.
*/
private final BinaryResourceValue binaryResourceValue; private final BinaryResourceValue binaryResourceValue;
protected XmlCdataChunk(ByteBuffer buffer, @Nullable Chunk parent) { protected XmlCdataChunk(ByteBuffer buffer, @Nullable Chunk parent) {
@@ -36,12 +43,16 @@ public final class XmlCdataChunk extends XmlNodeChunk {
binaryResourceValue = BinaryResourceValue.create(buffer); binaryResourceValue = BinaryResourceValue.create(buffer);
} }
/** Returns a string containing the raw character data of this chunk. */ /**
* Returns a string containing the raw character data of this chunk.
*/
public String getRawValue() { public String getRawValue() {
return getString(rawValue); return getString(rawValue);
} }
/** Returns a {@link BinaryResourceValue} instance containing the parsed cdata value. */ /**
* Returns a {@link BinaryResourceValue} instance containing the parsed cdata value.
*/
public BinaryResourceValue getResourceValue() { public BinaryResourceValue getResourceValue() {
return binaryResourceValue; return binaryResourceValue;
} }
@@ -17,6 +17,7 @@
package com.google.devrel.gmscore.tools.apk.arsc; package com.google.devrel.gmscore.tools.apk.arsc;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
/** /**
@@ -36,7 +37,9 @@ public final class XmlChunk extends ChunkWithChunks {
return Type.XML; return Type.XML;
} }
/** Returns a string at the provided (0-based) index if the index exists in the string pool. */ /**
* Returns a string at the provided (0-based) index if the index exists in the string pool.
*/
public String getString(int index) { public String getString(int index) {
for (Chunk chunk : getChunks().values()) { for (Chunk chunk : getChunks().values()) {
if (chunk instanceof StringPoolChunk) { if (chunk instanceof StringPoolChunk) {
@@ -17,17 +17,24 @@
package com.google.devrel.gmscore.tools.apk.arsc; package com.google.devrel.gmscore.tools.apk.arsc;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import java.io.DataOutput; import java.io.DataOutput;
import java.io.IOException; import java.io.IOException;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
/** Represents the end of an XML node. */ /**
* Represents the end of an XML node.
*/
public final class XmlEndElementChunk extends XmlNodeChunk { public final class XmlEndElementChunk extends XmlNodeChunk {
/** A string reference to the namespace URI, or -1 if not present. */ /**
* A string reference to the namespace URI, or -1 if not present.
*/
private final int namespace; private final int namespace;
/** A string reference to the attribute name. */ /**
* A string reference to the attribute name.
*/
private final int name; private final int name;
protected XmlEndElementChunk(ByteBuffer buffer, @Nullable Chunk parent) { protected XmlEndElementChunk(ByteBuffer buffer, @Nullable Chunk parent) {
@@ -36,12 +43,16 @@ public final class XmlEndElementChunk extends XmlNodeChunk {
name = buffer.getInt(); name = buffer.getInt();
} }
/** Returns the namespace URI, or the empty string if no namespace is present. */ /**
* Returns the namespace URI, or the empty string if no namespace is present.
*/
public String getNamespace() { public String getNamespace() {
return getString(namespace); return getString(namespace);
} }
/** Returns the attribute name. */ /**
* Returns the attribute name.
*/
public String getName() { public String getName() {
return getString(name); return getString(name);
} }
@@ -17,17 +17,24 @@
package com.google.devrel.gmscore.tools.apk.arsc; package com.google.devrel.gmscore.tools.apk.arsc;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import java.io.DataOutput; import java.io.DataOutput;
import java.io.IOException; import java.io.IOException;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
/** Represents the start/end of a namespace in an XML document. */ /**
* Represents the start/end of a namespace in an XML document.
*/
public abstract class XmlNamespaceChunk extends XmlNodeChunk { public abstract class XmlNamespaceChunk extends XmlNodeChunk {
/** A string reference to the namespace prefix. */ /**
* A string reference to the namespace prefix.
*/
private final int prefix; private final int prefix;
/** A string reference to the namespace URI. */ /**
* A string reference to the namespace URI.
*/
private final int uri; private final int uri;
protected XmlNamespaceChunk(ByteBuffer buffer, @Nullable Chunk parent) { protected XmlNamespaceChunk(ByteBuffer buffer, @Nullable Chunk parent) {
@@ -36,12 +43,16 @@ public abstract class XmlNamespaceChunk extends XmlNodeChunk {
uri = buffer.getInt(); uri = buffer.getInt();
} }
/** Returns the namespace prefix. */ /**
* Returns the namespace prefix.
*/
public String getPrefix() { public String getPrefix() {
return getString(prefix); return getString(prefix);
} }
/** Returns the namespace URI. */ /**
* Returns the namespace URI.
*/
public String getUri() { public String getUri() {
return getString(uri); return getString(uri);
} }
@@ -17,9 +17,12 @@
package com.google.devrel.gmscore.tools.apk.arsc; package com.google.devrel.gmscore.tools.apk.arsc;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
/** Represents the ending tag of a namespace in an XML document. */ /**
* Represents the ending tag of a namespace in an XML document.
*/
public final class XmlNamespaceEndChunk extends XmlNamespaceChunk { public final class XmlNamespaceEndChunk extends XmlNamespaceChunk {
protected XmlNamespaceEndChunk(ByteBuffer buffer, @Nullable Chunk parent) { protected XmlNamespaceEndChunk(ByteBuffer buffer, @Nullable Chunk parent) {
@@ -17,9 +17,12 @@
package com.google.devrel.gmscore.tools.apk.arsc; package com.google.devrel.gmscore.tools.apk.arsc;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
/** Represents the starting tag of a namespace in an XML document. */ /**
* Represents the starting tag of a namespace in an XML document.
*/
public final class XmlNamespaceStartChunk extends XmlNamespaceChunk { public final class XmlNamespaceStartChunk extends XmlNamespaceChunk {
protected XmlNamespaceStartChunk(ByteBuffer buffer, @Nullable Chunk parent) { protected XmlNamespaceStartChunk(ByteBuffer buffer, @Nullable Chunk parent) {
@@ -17,15 +17,22 @@
package com.google.devrel.gmscore.tools.apk.arsc; package com.google.devrel.gmscore.tools.apk.arsc;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
/** The common superclass for the various types of XML nodes. */ /**
* The common superclass for the various types of XML nodes.
*/
public abstract class XmlNodeChunk extends Chunk { public abstract class XmlNodeChunk extends Chunk {
/** The line number in the original source at which this node appeared. */ /**
* The line number in the original source at which this node appeared.
*/
private final int lineNumber; private final int lineNumber;
/** A string reference of this node's comment. If this is -1, then there is no comment. */ /**
* A string reference of this node's comment. If this is -1, then there is no comment.
*/
private final int comment; private final int comment;
protected XmlNodeChunk(ByteBuffer buffer, @Nullable Chunk parent) { protected XmlNodeChunk(ByteBuffer buffer, @Nullable Chunk parent) {
@@ -34,17 +41,23 @@ public abstract class XmlNodeChunk extends Chunk {
comment = buffer.getInt(); comment = buffer.getInt();
} }
/** Returns true if this XML node contains a comment. Else, returns false. */ /**
* Returns true if this XML node contains a comment. Else, returns false.
*/
public boolean hasComment() { public boolean hasComment() {
return comment != -1; return comment != -1;
} }
/** Returns the line number in the original source at which this node appeared. */ /**
* Returns the line number in the original source at which this node appeared.
*/
public int getLineNumber() { public int getLineNumber() {
return lineNumber; return lineNumber;
} }
/** Returns the comment associated with this node, if any. Else, returns the empty string. */ /**
* Returns the comment associated with this node, if any. Else, returns the empty string.
*/
public String getComment() { public String getComment() {
return getString(comment); return getString(comment);
} }
@@ -17,6 +17,7 @@
package com.google.devrel.gmscore.tools.apk.arsc; package com.google.devrel.gmscore.tools.apk.arsc;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import java.io.DataOutput; import java.io.DataOutput;
import java.io.IOException; import java.io.IOException;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
@@ -31,7 +32,9 @@ import java.util.List;
*/ */
public class XmlResourceMapChunk extends Chunk { public class XmlResourceMapChunk extends Chunk {
/** The size of a resource reference for {@code resources} in bytes. */ /**
* The size of a resource reference for {@code resources} in bytes.
*/
private static final int RESOURCE_SIZE = 4; private static final int RESOURCE_SIZE = 4;
/** /**
@@ -65,7 +68,9 @@ public class XmlResourceMapChunk extends Chunk {
return result; return result;
} }
/** Returns the resource ID that this {@code attributeId} maps to. */ /**
* Returns the resource ID that this {@code attributeId} maps to.
*/
public BinaryResourceIdentifier getResourceId(int attributeId) { public BinaryResourceIdentifier getResourceId(int attributeId) {
return BinaryResourceIdentifier.create(resources.get(attributeId)); return BinaryResourceIdentifier.create(resources.get(attributeId));
} }
@@ -16,9 +16,9 @@
package com.google.devrel.gmscore.tools.apk.arsc; package com.google.devrel.gmscore.tools.apk.arsc;
import androidx.annotation.Nullable;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import androidx.annotation.Nullable;
import java.io.DataOutput; import java.io.DataOutput;
import java.io.IOException; import java.io.IOException;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
@@ -26,31 +26,49 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
/** Represents the beginning of an XML node. */ /**
* Represents the beginning of an XML node.
*/
public final class XmlStartElementChunk extends XmlNodeChunk { public final class XmlStartElementChunk extends XmlNodeChunk {
/** A string reference to the namespace URI, or -1 if not present. */ /**
* A string reference to the namespace URI, or -1 if not present.
*/
private final int namespace; private final int namespace;
/** A string reference to the element name that this chunk represents. */ /**
* A string reference to the element name that this chunk represents.
*/
private final int name; private final int name;
/** The offset to the start of the attributes payload. */ /**
* The offset to the start of the attributes payload.
*/
private final int attributeStart; private final int attributeStart;
/** The number of attributes in the original buffer. */ /**
* The number of attributes in the original buffer.
*/
private final int attributeCount; private final int attributeCount;
/** The (0-based) index of the id attribute, or -1 if not present. */ /**
* The (0-based) index of the id attribute, or -1 if not present.
*/
private final int idIndex; private final int idIndex;
/** The (0-based) index of the class attribute, or -1 if not present. */ /**
* The (0-based) index of the class attribute, or -1 if not present.
*/
private final int classIndex; private final int classIndex;
/** The (0-based) index of the style attribute, or -1 if not present. */ /**
* The (0-based) index of the style attribute, or -1 if not present.
*/
private final int styleIndex; private final int styleIndex;
/** The XML attributes associated with this element. */ /**
* The XML attributes associated with this element.
*/
private final List<XmlAttribute> attributes = new ArrayList<>(); private final List<XmlAttribute> attributes = new ArrayList<>();
protected XmlStartElementChunk(ByteBuffer buffer, @Nullable Chunk parent) { protected XmlStartElementChunk(ByteBuffer buffer, @Nullable Chunk parent) {
@@ -91,17 +109,23 @@ public final class XmlStartElementChunk extends XmlNodeChunk {
return result; return result;
} }
/** Returns the namespace URI, or the empty string if not present. */ /**
* Returns the namespace URI, or the empty string if not present.
*/
public String getNamespace() { public String getNamespace() {
return getString(namespace); return getString(namespace);
} }
/** Returns the element name that this chunk represents. */ /**
* Returns the element name that this chunk represents.
*/
public String getName() { public String getName() {
return getString(name); return getString(name);
} }
/** Returns an unmodifiable list of this XML element's attributes. */ /**
* Returns an unmodifiable list of this XML element's attributes.
*/
public List<XmlAttribute> getAttributes() { public List<XmlAttribute> getAttributes() {
return Collections.unmodifiableList(attributes); return Collections.unmodifiableList(attributes);
} }
@@ -7,7 +7,8 @@ import com.vk.dto.music.MusicTrack;
import com.vk.log.L; import com.vk.log.L;
import org.json.JSONObject; import org.json.JSONObject;
import ru.vtosters.lite.music.Genius; import ru.vtosters.lite.music.Genius;
import ru.vtosters.lite.utils.Preferences; import ru.vtosters.lite.utils.AndroidUtils;
import ru.vtosters.hooks.other.Preferences;
import java.util.ArrayList; import java.util.ArrayList;
@@ -65,7 +66,7 @@ public class AudioGetLyrics extends ApiRequest<AudioGetLyrics.a> {
return aVar; return aVar;
} catch (Exception e) { } catch (Exception e) {
L.e("vk", e); L.e("vk", e);
aVar.a = "Ошибка получения текста" + "\n\n" + "Ошибка: \n" + e.getLocalizedMessage(); aVar.a = AndroidUtils.getString("failed_to_get_text") + "\n\n" + AndroidUtils.getString("error") + ": \n" + e.getLocalizedMessage();
return aVar; return aVar;
} }
} }
@@ -1,10 +1,8 @@
package com.vk.api.gifts; package com.vk.api.gifts;
import android.content.Context; import android.content.Context;
import com.vk.api.base.ApiRequest; import com.vk.api.base.ApiRequest;
import com.vk.dto.gift.CatalogedGift; import com.vk.dto.gift.CatalogedGift;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
@@ -0,0 +1,128 @@
package com.vk.core.extensions;
import android.content.res.ColorStateList;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;
import androidx.annotation.AttrRes;
import androidx.annotation.ColorRes;
import androidx.annotation.DrawableRes;
import androidx.core.content.ContextCompat;
import androidx.core.graphics.drawable.DrawableCompat;
import b.h.v.InitialValueObservable;
import b.h.v.TextViewTextChangeEvent;
import b.h.v.TextViewTextChangeEventObservable;
import com.vk.core.util.ContextExtKt;
import ru.vtosters.hooks.other.ThemesUtils;
public final class TextViewExt {
public static void a(TextView textView, Drawable drawable) {
a(textView, null, drawable);
}
public static boolean b(TextView textView) {
return textView == null || TextUtils.isEmpty(textView.getEditableText());
}
public static InitialValueObservable<TextViewTextChangeEvent> c(TextView textView) {
return new TextViewTextChangeEventObservable(textView);
}
public static void d(TextView textView, @DrawableRes int i, @AttrRes int i2) {
b(textView, ThemesUtils.recolorDrawable(ContextExtKt.a(textView.getContext(), i, ContextExtKt.h(textView.getContext(), i2))));
}
public static void a(TextView textView, Drawable drawable, ColorStateList colorStateList) {
a(textView, null, a(drawable, colorStateList));
}
public static void b(TextView textView, Drawable drawable) {
a(textView, drawable, (Drawable) null);
}
public static void c(TextView textView, @DrawableRes int i, @ColorRes int i2) {
if (i == 0) {
b(textView, null);
} else if (i2 == 0) {
b(textView, ContextCompat.getDrawable(textView.getContext(), i));
} else {
b(textView, ContextCompat.getDrawable(textView.getContext(), i), ContextCompat.getColorStateList(textView.getContext(), i2));
}
}
public static void d(TextView textView, int i) {
textView.setTextSize(0, i);
}
public static void a(TextView textView, @DrawableRes int i) {
a(textView, i, 0);
}
public static void b(TextView textView, Drawable drawable, ColorStateList colorStateList) {
a(textView, a(drawable, colorStateList), (Drawable) null);
}
public static void a(TextView textView, @DrawableRes int i, @ColorRes int i2) {
if (i == 0) {
a(textView, (Drawable) null);
} else if (i2 == 0) {
a(textView, ContextCompat.getDrawable(textView.getContext(), i));
} else {
a(textView, ContextCompat.getDrawable(textView.getContext(), i), ContextCompat.getColorStateList(textView.getContext(), i2));
}
}
public static void b(TextView textView, @DrawableRes int i) {
c(textView, i, 0);
}
public static void b(TextView textView, @DrawableRes int i, @AttrRes int i2) {
if (i == 0) {
a(textView, (Drawable) null);
} else if (i2 == 0) {
a(textView, ContextCompat.getDrawable(textView.getContext(), i));
} else {
Drawable drawable = ContextCompat.getDrawable(textView.getContext(), i);
a(textView, drawable, ColorStateList.valueOf(ContextExtKt.h(textView.getContext(), i2)));
}
}
public static void c(TextView textView, @ColorRes int i) {
textView.setTextColor(ContextExtKt.a(textView.getContext(), i));
}
private static void a(TextView textView, Drawable drawable, Drawable drawable2) {
textView.setCompoundDrawablesRelativeWithIntrinsicBounds(drawable, null, drawable2, null);
}
public static void a(TextView textView) {
textView.setCompoundDrawablesRelativeWithIntrinsicBounds(null, null, null, null);
}
public static Drawable a(Drawable drawable, ColorStateList colorStateList) {
if (colorStateList == null) return drawable;
if (drawable != null) {
Drawable wrap = DrawableCompat.wrap(drawable.mutate());
DrawableCompat.setTintList(wrap, colorStateList);
return wrap;
}
return null;
}
public static void a(TextView textView, CharSequence charSequence) {
if (TextUtils.isEmpty(charSequence)) {
textView.setVisibility(View.GONE);
return;
}
textView.setVisibility(View.VISIBLE);
textView.setText(charSequence);
}
public static void a(TextView textView, float f) {
textView.setTextSize(0, f);
}
}
@@ -11,13 +11,15 @@ import android.net.Uri;
import android.os.Environment; import android.os.Environment;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import b.h.g.m.CameraUtils;
import b.h.g.m.FileUtils;
import com.facebook.common.i.MediaUtils; import com.facebook.common.i.MediaUtils;
import com.facebook.x.g.EncodedImage; import com.facebook.x.g.EncodedImage;
import com.vk.imageloader.VKImageLoader; import com.vk.imageloader.VKImageLoader;
import com.vk.log.L; import com.vk.log.L;
import com.vk.metrics.eventtracking.VkTracker; import com.vk.metrics.eventtracking.VkTracker;
import com.vtosters.lite.R; import com.vtosters.lite.R;
import ru.vtosters.lite.concurrent.VTExecutors;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
@@ -26,10 +28,6 @@ import java.io.InputStream;
import java.net.URI; import java.net.URI;
import java.util.HashSet; import java.util.HashSet;
import b.h.g.m.CameraUtils;
import b.h.g.m.FileUtils;
import ru.vtosters.lite.concurrent.VTExecutors;
public class DownloadUtils { public class DownloadUtils {
public static final HashSet<Long> a = new HashSet<>(); public static final HashSet<Long> a = new HashSet<>();
@@ -14,7 +14,7 @@ import com.vk.core.ui.themes.VKThemeHelper;
import com.vk.dto.common.VerifyInfo; import com.vk.dto.common.VerifyInfo;
import com.vk.extensions.ViewExtKt; import com.vk.extensions.ViewExtKt;
import com.vtosters.lite.R; import com.vtosters.lite.R;
import ru.vtosters.lite.utils.ThemesUtils; import ru.vtosters.hooks.other.ThemesUtils;
public final class VerifyInfoHelper { public final class VerifyInfoHelper {
@@ -0,0 +1,11 @@
package com.vk.extensions;
import android.widget.TextView;
import androidx.annotation.AttrRes;
import com.vk.core.ui.themes.VKThemeHelper;
public final class TextViewExt {
public static void a(TextView textView, @AttrRes int i) {
VKThemeHelper.a(textView, i);
}
}
@@ -186,8 +186,7 @@ public final class DialogGetMentionSuggestionCmd extends BaseImEngineCmd<Suggest
} }
}), a(b2))); }), a(b2)));
EntityValue entityValue = new EntityValue(z2 ? null : l, z3); EntityValue entityValue = new EntityValue(z2 ? null : l, z3);
switch (this.d) switch (this.d) {
{
case CACHE: case CACHE:
source = Source.CACHE; source = Source.CACHE;
break; break;
@@ -16,12 +16,18 @@ public enum MemberType {
public static MemberType a(int i) { public static MemberType a(int i) {
switch (i) { switch (i) {
case 0: return UNKNOWN; case 0:
case 1: return USER; return UNKNOWN;
case 2: return GROUP; case 1:
case 3: return EMAIL; return USER;
case 4: return CONTACT; case 2:
case 5: return CUSTOM_BOT; return GROUP;
case 3:
return EMAIL;
case 4:
return CONTACT;
case 5:
return CUSTOM_BOT;
} }
throw new IllegalArgumentException("Unknown member type value: " + i); throw new IllegalArgumentException("Unknown member type value: " + i);
} }
@@ -11,12 +11,11 @@ import com.vk.im.engine.models.dialogs.Dialog;
import com.vk.im.engine.models.groups.Group; import com.vk.im.engine.models.groups.Group;
import com.vk.im.engine.utils.DialogPermissionHelper; import com.vk.im.engine.utils.DialogPermissionHelper;
import com.vk.im.ui.p.ImBridge7; import com.vk.im.ui.p.ImBridge7;
import ru.vtosters.hooks.DialogMenuInjectors;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import ru.vtosters.lite.dnr.DNRInjector;
public final class DialogActionsHelper { public final class DialogActionsHelper {
public static final DialogActionsHelper a = new DialogActionsHelper(); public static final DialogActionsHelper a = new DialogActionsHelper();
@@ -28,7 +27,7 @@ public final class DialogActionsHelper {
boolean I1 = z1 != null && z1.I1(); boolean I1 = z1 != null && z1.I1();
ArrayList<DialogAction> arrayList = new ArrayList<>(); ArrayList<DialogAction> arrayList = new ArrayList<>();
DNRInjector.inject(dialog, arrayList); DialogMenuInjectors.inject(dialog, arrayList);
arrayList.add(DialogAction.SEARCH); arrayList.add(DialogAction.SEARCH);
@@ -97,7 +96,7 @@ public final class DialogActionsHelper {
ChatSettings z1 = dialog.z1(); ChatSettings z1 = dialog.z1();
ArrayList<DialogAction> arrayList = new ArrayList<>(); ArrayList<DialogAction> arrayList = new ArrayList<>();
DNRInjector.inject(dialog, arrayList); DialogMenuInjectors.inject(dialog, arrayList);
// if (dialog.hasUnread()) { // if (dialog.hasUnread()) {
arrayList.add(DialogAction.MARK_AS_READ); arrayList.add(DialogAction.MARK_AS_READ);
@@ -11,5 +11,6 @@ public enum MsgAction {
PIN, PIN,
UNPIN, UNPIN,
TRANSLATE, TRANSLATE,
READTO READTO,
KICK
} }
@@ -3,9 +3,11 @@ package com.vk.im.ui.components.common;
import com.vk.core.extensions.CollectionExt; import com.vk.core.extensions.CollectionExt;
import com.vk.im.engine.ImConfig; import com.vk.im.engine.ImConfig;
import com.vk.im.engine.ImEngine; import com.vk.im.engine.ImEngine;
import com.vk.im.engine.models.Member;
import com.vk.im.engine.models.dialogs.Dialog; import com.vk.im.engine.models.dialogs.Dialog;
import com.vk.im.engine.models.messages.Msg; import com.vk.im.engine.models.messages.Msg;
import com.vk.im.engine.utils.MsgPermissionHelper; import com.vk.im.engine.utils.MsgPermissionHelper;
import ru.vtosters.lite.utils.AccountManagerUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
@@ -35,6 +37,24 @@ public final class MsgActionHelper {
CollectionExt.a(arrayList, MsgAction.TRANSLATE, true); CollectionExt.a(arrayList, MsgAction.TRANSLATE, true);
CollectionExt.a(arrayList, MsgAction.READTO, true); CollectionExt.a(arrayList, MsgAction.READTO, true);
boolean isAdmin = false;
try {
if (aVar.a().z1().L0().t1() == AccountManagerUtils.getUserId()) { // is owner
isAdmin = true;
} else if (!aVar.a().z1().K1()) { // is you not kicked
for (Member admins : aVar.a().z1().t1()) { // admin list
if (admins.t1() == AccountManagerUtils.getUserId()) {
isAdmin = true;
break;
}
}
}
} catch (Exception ignored) {
}
CollectionExt.a(arrayList, MsgAction.KICK, isAdmin);
return arrayList; return arrayList;
} }
@@ -21,6 +21,7 @@ import com.vk.im.ui.q.h.VideoAutoPlayer;
import com.vk.im.ui.views.span.OnSpanClickListener; import com.vk.im.ui.views.span.OnSpanClickListener;
import com.vk.im.ui.views.span.OnSpanLongPressListener; import com.vk.im.ui.views.span.OnSpanLongPressListener;
import com.vk.im.ui.views.sticker.StickerAnimationState; import com.vk.im.ui.views.sticker.StickerAnimationState;
import java.util.List; import java.util.List;
@MainThread @MainThread
@@ -17,11 +17,7 @@ import com.vk.im.engine.models.ProfilesSimpleInfo;
import com.vk.im.engine.models.attaches.AttachAudioMsg; import com.vk.im.engine.models.attaches.AttachAudioMsg;
import com.vk.im.engine.models.dialogs.Dialog; import com.vk.im.engine.models.dialogs.Dialog;
import com.vk.im.engine.models.dialogs.DialogTheme; import com.vk.im.engine.models.dialogs.DialogTheme;
import com.vk.im.engine.models.messages.Msg; import com.vk.im.engine.models.messages.*;
import com.vk.im.engine.models.messages.MsgFromUser;
import com.vk.im.engine.models.messages.MsgIdType;
import com.vk.im.engine.models.messages.MsgSyncState;
import com.vk.im.engine.models.messages.WithUserContent;
import com.vk.im.engine.utils.collection.IntSet; import com.vk.im.engine.utils.collection.IntSet;
import com.vk.im.ui.components.viewcontrollers.msg_list.entry.AdapterEntry; import com.vk.im.ui.components.viewcontrollers.msg_list.entry.AdapterEntry;
import com.vk.im.ui.media.audio.AudioTrack; import com.vk.im.ui.media.audio.AudioTrack;
@@ -21,7 +21,7 @@ import com.vk.im.ui.views.msg.MsgPartIconTwoRowView;
import com.vtosters.lite.R; import com.vtosters.lite.R;
import kotlin.TypeCastException; import kotlin.TypeCastException;
import kotlin.jvm.internal.Intrinsics; import kotlin.jvm.internal.Intrinsics;
import ru.vtosters.lite.hooks.CallsHook; import ru.vtosters.hooks.CallsHook;
public final class MsgPartCallHolder extends MsgPartHolderBase<AttachCall> { public final class MsgPartCallHolder extends MsgPartHolderBase<AttachCall> {
public static final a I = new a(); public static final a I = new a();
@@ -28,7 +28,6 @@ import com.vk.im.engine.models.Profile;
import com.vk.im.engine.models.dialogs.BubbleColors; import com.vk.im.engine.models.dialogs.BubbleColors;
import com.vk.im.engine.models.dialogs.Dialog; import com.vk.im.engine.models.dialogs.Dialog;
import com.vk.im.engine.models.messages.Msg; import com.vk.im.engine.models.messages.Msg;
import com.vk.im.engine.models.messages.MsgSyncState;
import com.vk.im.engine.utils.MsgPermissionHelper; import com.vk.im.engine.utils.MsgPermissionHelper;
import com.vk.im.ui.components.viewcontrollers.msg_list.BombView; import com.vk.im.ui.components.viewcontrollers.msg_list.BombView;
import com.vk.im.ui.components.viewcontrollers.msg_list.SwipeToReplyItemTouchCallback; import com.vk.im.ui.components.viewcontrollers.msg_list.SwipeToReplyItemTouchCallback;
@@ -337,7 +336,8 @@ public class VhMsg extends VhBase implements SwipeToReplyItemTouchCallback.b {
if (args.w()) { if (args.w()) {
var12 = var11; var12 = var11;
if (args.k()) { if (args.k()) {
label30: { label30:
{
if (args.G()) { if (args.G()) {
var12 = Screen.a(4); var12 = Screen.a(4);
} else { } else {
@@ -832,7 +832,8 @@ public class VhMsg extends VhBase implements SwipeToReplyItemTouchCallback.b {
MsgBubbleView var8 = this.e; MsgBubbleView var8 = this.e;
boolean var6 = var4; boolean var6 = var4;
if (var5) { if (var5) {
label57: { label57:
{
if (!args.C()) { if (!args.C()) {
var6 = var4; var6 = var4;
if (!args.z()) { if (!args.z()) {
@@ -6,7 +6,6 @@ import android.os.Bundle;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.ViewStub; import android.view.ViewStub;
import android.widget.TextView;
import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.vk.core.ui.VkBottomSheetBehavior; import com.vk.core.ui.VkBottomSheetBehavior;
@@ -105,7 +104,7 @@ public final class MentionsController {
View inflate = ((ViewStub) this.j.findViewById(R.id.mentions_container_stub)).inflate(); View inflate = ((ViewStub) this.j.findViewById(R.id.mentions_container_stub)).inflate();
ViewGroup viewGroup = (ViewGroup) inflate.findViewById(R.id.mentions_container); ViewGroup viewGroup = (ViewGroup) inflate.findViewById(R.id.mentions_container);
viewGroup.addView(this.mDialogMentionComponent.a(viewGroup, (Bundle) null)); viewGroup.addView(this.mDialogMentionComponent.a(viewGroup, (Bundle) null));
this.mCoordinatorLayout = inflate.findViewById(R.id.mentions_cl);; this.mCoordinatorLayout = inflate.findViewById(R.id.mentions_cl);
this.mBottomSheetBehavior = (VkBottomSheetBehavior<RecyclerView>) ((CoordinatorLayout.LayoutParams) viewGroup.getLayoutParams()).getBehavior(); this.mBottomSheetBehavior = (VkBottomSheetBehavior<RecyclerView>) ((CoordinatorLayout.LayoutParams) viewGroup.getLayoutParams()).getBehavior();
this.mBottomSheetBehavior.a(new VkBottomSheetBehavior.b() { this.mBottomSheetBehavior.a(new VkBottomSheetBehavior.b() {
@Override @Override
@@ -9,7 +9,6 @@ import android.graphics.Shader;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import com.vk.im.ui.o; import com.vk.im.ui.o;
public class StoryBorderView extends View { public class StoryBorderView extends View {
@@ -1,8 +1,5 @@
package com.vk.im.ui.views.dialogs; package com.vk.im.ui.views.dialogs;
import static com.vk.im.ui.d.vkim_administration_title;
import static ru.vtosters.lite.utils.ThemesUtils.getAccentColor;
import android.content.Context; import android.content.Context;
import android.content.res.Resources; import android.content.res.Resources;
import android.content.res.TypedArray; import android.content.res.TypedArray;
@@ -17,10 +14,9 @@ import android.view.ViewGroup;
import android.view.ViewPropertyAnimator; import android.view.ViewPropertyAnimator;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.ColorInt; import androidx.annotation.ColorInt;
import androidx.appcompat.widget.AppCompatImageView; import androidx.appcompat.widget.AppCompatImageView;
import b.h.g.r.MathExt;
import com.vk.core.extensions.AnimationExtKt; import com.vk.core.extensions.AnimationExtKt;
import com.vk.core.util.ContextExtKt; import com.vk.core.util.ContextExtKt;
import com.vk.core.util.Screen; import com.vk.core.util.Screen;
@@ -42,7 +38,8 @@ import com.vk.im.ui.views.FixTextView;
import com.vk.im.ui.views.avatars.AvatarView; import com.vk.im.ui.views.avatars.AvatarView;
import com.vk.im.ui.views.avatars.StoryBorderView; import com.vk.im.ui.views.avatars.StoryBorderView;
import b.h.g.r.MathExt; import static com.vk.im.ui.d.vkim_administration_title;
import static ru.vtosters.hooks.other.ThemesUtils.getAccentColor;
public class DialogItemView extends ViewGroup { public class DialogItemView extends ViewGroup {
private final int B; private final int B;
@@ -0,0 +1,93 @@
package com.vk.medianative;
import android.graphics.Bitmap;
import android.graphics.Bitmap.CompressFormat;
import android.os.Build;
import android.util.Log;
import ru.vtosters.hooks.other.Preferences;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
public class MediaImageEncoder {
private static boolean compressBitmap(Bitmap bitmap, File file, CompressFormat format, int quality) {
try (FileOutputStream fileOutputStream = new FileOutputStream(file)) {
return bitmap.compress(format, quality, fileOutputStream);
} catch (IOException e) {
Log.e(MediaImageEncoder.class.getSimpleName(), "Bitmap compression error: " + e);
return false;
}
}
private static boolean compressBitmapJpeg(Bitmap bitmap, File file, int quality) {
return compressBitmap(bitmap, file, CompressFormat.JPEG, quality);
}
private static boolean compressBitmapLossless(Bitmap bitmap, File file) {
return compressBitmap(bitmap, file, CompressFormat.PNG, 100);
}
private static boolean compressBitmapNative(Bitmap bitmap, File file, int quality) {
if (MediaNative.isX86() || MediaNative.isAsus() || Build.VERSION.SDK_INT < 24) {
Log.e(MediaImageEncoder.class.getSimpleName(), "JPEG turbo not supported on this device!");
return compressBitmapJpeg(bitmap, file, quality);
}
byte[] jpegData = MediaNative.compressBitmapJpeg(bitmap, quality);
if (jpegData == null) {
return false;
}
try (FileOutputStream fileOutputStream = new FileOutputStream(file)) {
fileOutputStream.write(jpegData);
return true;
} catch (IOException e) {
Log.e(MediaImageEncoder.class.getSimpleName(), "JPEG compression error: " + e);
return false;
}
}
public static boolean encodePicture(Bitmap bitmap, File file, int quality) {
if (bitmap != null && !bitmap.isRecycled() && bitmap.getWidth() * bitmap.getHeight() != 0) {
switch (Preferences.getPreferences().getString("compression", "jpeg")) {
case "skip" -> {
return compressBitmapLossless(bitmap, file);
}
case "jpeg" -> {
return compressBitmapJpeg(bitmap, file, quality);
}
case "native" -> {
return compressBitmapNative(bitmap, file, quality);
}
}
}
return false;
}
public static boolean needToSkipCompression() {
return Preferences.getPreferences().getString("compression", "jpeg").equals("skip");
}
public static boolean needToCompress() {
return !needToSkipCompression();
}
public static boolean encodeJpeg(Bitmap bitmap, File file) {
return encodePicture(bitmap, file, 90);
}
public static boolean encodeJpegWithoutCompression(Bitmap bitmap, File file) {
return encodePicture(bitmap, file, 95);
}
public static boolean encodeJpeg(Bitmap bitmap, File file, int quality) {
if (bitmap != null && !bitmap.isRecycled() && bitmap.getWidth() * bitmap.getHeight() != 0) {
return needToCompress() ? compressBitmapNative(bitmap, file, quality) : compressBitmapJpeg(bitmap, file, quality);
} else {
return false;
}
}
}
@@ -0,0 +1,502 @@
package com.vk.medianative;
import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.os.Process;
import android.os.*;
import android.util.Log;
import androidx.annotation.Keep;
import androidx.annotation.Nullable;
import com.facebook.soloader.SoLoader;
import java.io.InputStream;
import java.lang.ref.WeakReference;
import java.nio.ByteBuffer;
import java.util.Scanner;
public final class MediaNative {
private static final String a = NativeMediaEncoder.class.getSimpleName();
private static final Object f17443d = new Object();
@SuppressLint("StaticFieldLeak")
@Keep
public static volatile Context context;
private static boolean isMediaLoaded = false;
private static boolean isMediaMasksLoaded = false;
public static int HSLToIntRGB(float f2, float f3, float f4) {
int[] iArr = new int[3];
waitForContext();
nativeHSLToRGB(f2, f3, f4, iArr);
return Color.argb(255, iArr[0], iArr[1], iArr[2]);
}
public static void HSLToRGB(float f2, float f3, float f4, int[] iArr) {
waitForContext();
nativeHSLToRGB(f2, f3, f4, iArr);
}
public static int HSVToIntRGB(float f2, float f3, float f4) {
int[] iArr = new int[3];
waitForContext();
nativeHSVToRGB(f2, f3, f4, iArr);
return Color.argb(255, iArr[0], iArr[1], iArr[2]);
}
public static void HSVToRGB(float f2, float f3, float f4, int[] iArr) {
waitForContext();
nativeHSVToRGB(f2, f3, f4, iArr);
}
public static int LabToIntRGB(float f2, float f3, float f4) {
int[] iArr = new int[3];
waitForContext();
nativeLabToRGB(f2, f3, f4, iArr);
return Color.argb(255, iArr[0], iArr[1], iArr[2]);
}
public static void LabToRGB(float f2, float f3, float f4, int[] iArr) {
waitForContext();
nativeLabToRGB(f2, f3, f4, iArr);
}
public static void RGBToHSL(int i, int i2, int i3, float[] fArr) {
waitForContext();
nativeRGBToHSL(i, i2, i3, fArr);
}
public static void RGBToHSV(int i, int i2, int i3, float[] fArr) {
waitForContext();
nativeRGBToHSV(i, i2, i3, fArr);
}
public static void RGBToLab(int i, int i2, int i3, float[] fArr) {
waitForContext();
nativeRGBToLab(i, i2, i3, fArr);
}
public static long animationPlayerCreate(String str, int i, int i2, boolean z) {
waitForContext();
return nativeAnimationPlayerCreate(str, i, i2, z);
}
public static int animationPlayerDecode(long j, Bitmap bitmap) {
waitForContext();
return nativeAnimationPlayerDecode(j, bitmap);
}
public static int animationPlayerGetSize(long j) {
waitForContext();
return nativeAnimationPlayerGetSize(j);
}
public static void animationPlayerRelease(long j) {
waitForContext();
nativeAnimationPlayerRelease(j);
}
public static boolean animationPlayerSeek(long j, int i) {
waitForContext();
return nativeAnimationPlayerSeek(j, i);
}
public static void applyCurveAndSaturationBitmap(Bitmap bitmap, int[] iArr, float f2) {
waitForContext();
nativeCurveSaturation(bitmap, iArr, f2, Runtime.getRuntime().availableProcessors());
}
public static long audioGetTotalPcmDuration() {
waitForContext();
return nativeAudioGetTotalPcmDuration();
}
public static byte[] audioGetWaveform(short[] sArr, int i) {
waitForContext();
return nativeAudioGetWaveform(sArr, i);
}
public static int audioIsOpusFile(String str) {
waitForContext();
return nativeAudioIsOpusFile(str);
}
public static void audioReadOpusFile(ByteBuffer byteBuffer, int i, int[] iArr) {
waitForContext();
nativeAudioReadOpusFile(byteBuffer, i, iArr);
}
public static int audioSeekOpusFile(float f2) {
waitForContext();
return nativeAudioSeekOpusFile(f2);
}
public static int audioStartRecord(String str) { // need to hack
waitForContext();
return nativeAudioStartRecord(str);
}
public static void audioStopRecord() { // need to hack
waitForContext();
nativeAudioStopRecord();
}
public static int audioWriteFrame(ByteBuffer byteBuffer, int i) { // need to hack
waitForContext();
return nativeAudioWriteFrame(byteBuffer, i);
}
private static void waitForContext() {
synchronized (f17443d) {
if (context == null) {
try {
f17443d.wait();
} catch (InterruptedException e2) {
Log.e(a, "Interrupted while waiting for context", e2);
}
}
}
}
public static void blurBitmap(Bitmap bitmap, int i) {
waitForContext();
nativeBlur(bitmap, i);
}
private static String c() {
return getProcMaps(String.valueOf(Process.myPid()));
}
public static void cameraProcessorCreate() {
waitForContext();
nativeProcessorCreate();
}
public static boolean cameraProcessorDo(byte[] bArr, long[] jArr) {
waitForContext();
return nativeProcessorDo(bArr, jArr);
}
public static int cameraProcessorGetVersion() {
waitForContext();
return nativeProcessorGetVersion();
}
public static boolean cameraProcessorInit(String str, int i, int i2) {
waitForContext();
return nativeProcessorInit(str, i, i2);
}
public static boolean cameraProcessorLoad(String str, boolean z) {
waitForContext();
return nativeProcessorLoad(str, z);
}
public static void cameraProcessorMouseTap(int i, float f2, float f3) {
waitForContext();
nativeProcessorMouseTap(i, f2, f3);
}
public static void cameraProcessorRelease() {
waitForContext();
nativeProcessorRelease();
}
public static void colorCorrectionBitmap(Bitmap bitmap, Bitmap bitmap2, float[] fArr) {
waitForContext();
nativeColorCorrection(bitmap, bitmap2, fArr, fArr.length, Runtime.getRuntime().availableProcessors());
}
public static byte[] compressBitmapJpeg(Bitmap bitmap, int i) {
waitForContext();
return nativeJpegTurboCompress(bitmap, i);
}
public static String createAllInOneShader() {
waitForContext();
return nativeAllInOneShader();
}
public static void createCurve(int[] iArr, int[] iArr2, int[] iArr3, int[] iArr4, int[] iArr5, float f2, float f3, float f4, float f5, float f6) {
waitForContext();
nativeCreateCurve(iArr, iArr2, iArr3, iArr4, iArr5, f2, f3, f4, f5, f6);
}
public static String createOneInAllShader() {
waitForContext();
return nativeOneInAllShader();
}
private static String d() {
return getProcMaps("self");
}
public static String dump() {
return "LD_LIBRARY_PATH:\n" + SoLoader.makeLdLibraryPath() + "\nSELF_MAPS:\n" + d() + "\nPID_MAPS:\n" + c() + "\n";
}
private static void e() {
isMediaMasksLoaded = NativeLibLoader.loadLibrary("vkmediamasks");
}
public static void enhanceBitmap(Bitmap bitmap, float f2) {
waitForContext();
nativeEnhance(bitmap, f2, Runtime.getRuntime().availableProcessors());
}
private static void loadVKMediaLibs() {
if (isMediaLoaded) {
return;
}
NativeLibLoader.loadLibrary("ffmpeg");
isMediaLoaded = NativeLibLoader.loadLibrary("vkmedia");
isMediaLoaded = NativeLibLoader.loadLibrary("vkmediaencoder");
}
public static void flipHorizontallyBitmap(Bitmap bitmap) {
waitForContext();
nativeFlipHorizontally(bitmap);
}
public static void flipVerticallyBitmap(Bitmap bitmap) {
waitForContext();
nativeFlipVertically(bitmap);
}
public static void generateHistogram(Bitmap bitmap, int[] iArr, int[] iArr2, int[] iArr3, int[] iArr4) {
waitForContext();
nativeHistogram(bitmap, iArr, iArr2, iArr3, iArr4);
}
public static void init(Context context2) {
synchronized (f17443d) {
context = context2;
SoLoader.init(context2, false);
NativeLibLoader.loadLibrary("gnustl_shared");
NativeLibLoader.loadLibrary("vkchronicle");
loadVKMediaLibs();
f17443d.notifyAll();
}
}
public static void intRGBToHSL(int i, float[] fArr) {
waitForContext();
nativeRGBToHSL(Color.red(i), Color.green(i), Color.blue(i), fArr);
}
public static void intRGBToHSV(int i, float[] fArr) {
waitForContext();
nativeRGBToHSV(Color.red(i), Color.green(i), Color.blue(i), fArr);
}
public static void intRGBToLab(int i, float[] fArr) {
waitForContext();
nativeRGBToLab(Color.red(i), Color.green(i), Color.blue(i), fArr);
}
public static boolean isAsus() {
return "asus".equalsIgnoreCase(Build.MANUFACTURER);
}
public static boolean isMediaSupported() {
if (!isMediaMasksLoaded) {
e();
}
return isMediaMasksLoaded;
}
public static boolean isX86() {
try {
String str = Build.SUPPORTED_ABIS[0];
if (str != null) {
return str.startsWith("x86");
}
return false;
} catch (Throwable unused) {
return false;
}
}
public static void lookupBitmap(Bitmap bitmap, Bitmap bitmap2) {
waitForContext();
nativeLookup(bitmap, bitmap2, Runtime.getRuntime().availableProcessors());
}
public static long mediaEncoderCreate(MediaEncoderSettings mediaEncoderSettings) {
waitForContext();
return nativeCreateEncoder(mediaEncoderSettings);
}
public static int mediaEncoderDoEncode(long j) {
waitForContext();
return nativeDoEncode(j);
}
public static void mediaEncoderDoRelease(long j) {
waitForContext();
nativeReleaseEncoder(j);
}
private static native String nativeAllInOneShader();
private static native long nativeAnimationPlayerCreate(String str, int i, int i2, boolean z);
private static native int nativeAnimationPlayerDecode(long j, Bitmap bitmap);
private static native int nativeAnimationPlayerGetSize(long j);
private static native void nativeAnimationPlayerRelease(long j);
private static native boolean nativeAnimationPlayerSeek(long j, int i);
private static native long nativeAudioGetTotalPcmDuration();
private static native byte[] nativeAudioGetWaveform(short[] sArr, int i);
private static native int nativeAudioIsOpusFile(String str);
private static native int nativeAudioOpenOpusFile(String str);
private static native void nativeAudioReadOpusFile(ByteBuffer byteBuffer, int i, int[] iArr);
private static native int nativeAudioSeekOpusFile(float f2);
private static native int nativeAudioStartRecord(String str);
private static native void nativeAudioStopRecord();
private static native int nativeAudioWriteFrame(ByteBuffer byteBuffer, int i);
private static native void nativeBlur(Bitmap bitmap, int i);
private static native void nativeColorCorrection(Bitmap bitmap, Bitmap bitmap2, float[] fArr, int i, int i2);
private static native String nativeCreateColorCorrectionShader(float[] fArr, int i, int i2);
private static native void nativeCreateCurve(int[] iArr, int[] iArr2, int[] iArr3, int[] iArr4, int[] iArr5, float f2, float f3, float f4, float f5, float f6);
private static native long nativeCreateEncoder(MediaEncoderSettings mediaEncoderSettings);
private static native void nativeCurveSaturation(Bitmap bitmap, int[] iArr, double d2, int i);
private static native int nativeDoEncode(long j);
private static native void nativeEnhance(Bitmap bitmap, double d2, int i);
private static native void nativeFlipHorizontally(Bitmap bitmap);
private static native void nativeFlipVertically(Bitmap bitmap);
private static native void nativeHSLToRGB(float f2, float f3, float f4, int[] iArr);
private static native void nativeHSVToRGB(float f2, float f3, float f4, int[] iArr);
private static native void nativeHistogram(Bitmap bitmap, int[] iArr, int[] iArr2, int[] iArr3, int[] iArr4);
private static native byte[] nativeJpegTurboCompress(Bitmap bitmap, int i);
private static native void nativeLabToRGB(float f2, float f3, float f4, int[] iArr);
private static native void nativeLookup(Bitmap bitmap, Bitmap bitmap2, int i);
private static native String nativeOneInAllShader();
private static native void nativePinBitmap(Bitmap bitmap);
private static native void nativeProcessorCreate();
private static native boolean nativeProcessorDo(byte[] bArr, long[] jArr);
private static native int nativeProcessorGetVersion();
private static native boolean nativeProcessorInit(String str, int i, int i2);
private static native boolean nativeProcessorLoad(String str, boolean z);
private static native void nativeProcessorMouseTap(int i, float f2, float f3);
private static native void nativeProcessorRelease();
private static native void nativeRGBToHSL(int i, int i2, int i3, float[] fArr);
private static native void nativeRGBToHSV(int i, int i2, int i3, float[] fArr);
private static native void nativeRGBToLab(int i, int i2, int i3, float[] fArr);
private static native void nativeReleaseEncoder(long j);
private static native void nativeResize(Bitmap bitmap, Bitmap bitmap2, int i);
public static int openOpusFile(String str) {
waitForContext();
return nativeAudioOpenOpusFile(str);
}
public static void pinBitmap(Bitmap bitmap) {
waitForContext();
nativePinBitmap(bitmap);
}
public static void resizeBitmap(Bitmap bitmap, Bitmap bitmap2) {
waitForContext();
nativeResize(bitmap, bitmap2, Runtime.getRuntime().availableProcessors());
}
private static String getProcMaps(String str) {
try (InputStream inputStream = Runtime.getRuntime().exec("cat /proc/" + str + "/maps").getInputStream()) {
return new Scanner(inputStream).useDelimiter("\\A").next();
} catch (Exception e) {
return "empty";
}
}
public static class EncoderHandler extends Handler {
private Callback a;
public EncoderHandler(Looper looper) {
super(looper);
}
@Keep
public static Object postEventFromNative(Object obj, int i, int i2, int i3) {
EncoderHandler encoderHandler;
if (obj != null && (encoderHandler = (EncoderHandler) ((WeakReference<?>) obj).get()) != null) {
if (i == 2) {
return encoderHandler.a.getLayerBitmap(i2, i3);
}
encoderHandler.sendMessage(encoderHandler.obtainMessage(i, i2, i3, null));
}
return null;
}
@Override // android.os.Handler
public void handleMessage(Message message) {
Callback callback = this.a;
if (callback == null) {
return;
}
int i = message.what;
if (i == 0) {
callback.onBytes(message.arg1);
} else if (i != 1) {
String str = MediaNative.a;
Log.e(str, "Unknown message type " + message.what);
} else {
callback.onProgress(message.arg1);
}
}
public void setCallback(Callback callback) {
this.a = callback;
}
public interface Callback {
@Nullable
Bitmap getLayerBitmap(int i, int i2);
void onBytes(int i);
void onProgress(int i);
}
}
}
@@ -11,7 +11,6 @@ import com.vk.api.sdk.exceptions.VKApiExecutionException;
import com.vk.common.k.PodcastTimeCodeClickListener; import com.vk.common.k.PodcastTimeCodeClickListener;
import com.vk.common.links.LinkParser; import com.vk.common.links.LinkParser;
import com.vk.core.util.ContextExtKt; import com.vk.core.util.ContextExtKt;
import com.vk.dto.music.Artist;
import com.vk.dto.music.MusicTrack; import com.vk.dto.music.MusicTrack;
import com.vk.music.artists.chooser.MusicArtistSelector; import com.vk.music.artists.chooser.MusicArtistSelector;
import com.vk.music.common.MusicPlaybackLaunchContext; import com.vk.music.common.MusicPlaybackLaunchContext;
@@ -24,6 +23,8 @@ import com.vtosters.lite.R;
import com.vtosters.lite.ViewUtils; import com.vtosters.lite.ViewUtils;
import com.vtosters.lite.ui.MusicErrorViewHelper; import com.vtosters.lite.ui.MusicErrorViewHelper;
import com.vtosters.lite.ui.holder.RecyclerHolder; import com.vtosters.lite.ui.holder.RecyclerHolder;
import ru.vtosters.lite.music.Genius;
import ru.vtosters.hooks.other.Preferences;
import java.util.Objects; import java.util.Objects;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
@@ -155,6 +156,14 @@ public class LyricsHolder extends RecyclerHolder<PlayerInfo> implements View.OnC
@Override // com.vk.api.base.ApiCallback @Override // com.vk.api.base.ApiCallback
public void a(VKApiExecutionException vKApiExecutionException) { public void a(VKApiExecutionException vKApiExecutionException) {
if (Preferences.getBoolValue("useGenius", false)) {
var text = Genius.getTextMusic(a);
var lyrics = new AudioGetLyrics.a();
lyrics.a = text;
a(lyrics);
return;
}
LyricsHolder.this.B.set(false); LyricsHolder.this.B.set(false);
LyricsHolder.this.f18328f.a(vKApiExecutionException); LyricsHolder.this.f18328f.a(vKApiExecutionException);
LyricsHolder.this.f18328f.b(0); LyricsHolder.this.f18328f.b(0);
@@ -6,7 +6,6 @@ import android.graphics.Canvas;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter; import android.graphics.PorterDuffColorFilter;
import android.util.AttributeSet; import android.util.AttributeSet;
import com.vk.core.ui.themes.Themable; import com.vk.core.ui.themes.Themable;
import com.vk.core.ui.themes.VKThemeHelper; import com.vk.core.ui.themes.VKThemeHelper;
import com.vk.core.util.ContextExtKt; import com.vk.core.util.ContextExtKt;
@@ -1,26 +1,13 @@
package com.vk.sharing.view; package com.vk.sharing.view;
import static b.h.z.f.roboto_medium;
import static ru.vtosters.lite.utils.ThemesUtils.getAccentColor;
import android.content.Context; import android.content.Context;
import android.content.res.TypedArray; import android.content.res.TypedArray;
import android.graphics.Bitmap; import android.graphics.*;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.LinearGradient;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.RectF;
import android.graphics.Shader;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.net.Uri; import android.net.Uri;
import android.util.AttributeSet; import android.util.AttributeSet;
import androidx.annotation.UiThread; import androidx.annotation.UiThread;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import com.facebook.drawee.drawable.ScalingUtils; import com.facebook.drawee.drawable.ScalingUtils;
import com.facebook.drawee.generic.GenericDraweeHierarchy; import com.facebook.drawee.generic.GenericDraweeHierarchy;
import com.facebook.drawee.view.DraweeHolder; import com.facebook.drawee.view.DraweeHolder;
@@ -31,10 +18,13 @@ import com.vk.imageloader.view.VKMultiImageView;
import com.vk.navigation.NavigatorKeys; import com.vk.navigation.NavigatorKeys;
import com.vtosters.lite.R; import com.vtosters.lite.R;
import com.vtosters.lite.a0; import com.vtosters.lite.a0;
import ru.vtosters.lite.utils.Preferences; import ru.vtosters.hooks.other.Preferences;
import java.util.Arrays; import java.util.Arrays;
import static b.h.z.f.roboto_medium;
import static ru.vtosters.hooks.other.ThemesUtils.getAccentColor;
@UiThread @UiThread
public class TargetImageView extends VKMultiImageView { public class TargetImageView extends VKMultiImageView {
private static final int I = Screen.a(2); private static final int I = Screen.a(2);
@@ -11,11 +11,9 @@ import android.graphics.drawable.Drawable;
import android.net.Uri; import android.net.Uri;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.ViewTreeObserver; import android.view.ViewTreeObserver;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import com.airbnb.lottie.LottieComposition; import com.airbnb.lottie.LottieComposition;
import com.airbnb.lottie.LottieCompositionFactory; import com.airbnb.lottie.LottieCompositionFactory;
import com.airbnb.lottie.LottieDrawable; import com.airbnb.lottie.LottieDrawable;
+138 -63
View File
@@ -222,8 +222,10 @@ public final class R {
public static final int undel_value = 0x7f030075; // 2130903157 public static final int undel_value = 0x7f030075; // 2130903157
public static final int wallpaper_change_dialog = 0x7f030076; // 2130903158 public static final int wallpaper_change_dialog = 0x7f030076; // 2130903158
public static final int accent_select_type = 0x7f030077; // 2130903159 public static final int accent_select_type = 0x7f030077; // 2130903159
public static final int theme_type_name = 0x7f030078; // 2130903160 public static final int compression = 0x7f030078; // 2130903160
public static final int theme_type_name_checkbox = 0x7f030079; // 2130903161 public static final int compression_value = 0x7f030079; // 2130903161
public static final int theme_type_name = 0x7f03007a; // 2130903162
public static final int theme_type_name_checkbox = 0x7f03007b; // 2130903163
} }
public static final class attr { public static final class attr {
@@ -4974,28 +4976,29 @@ public final class R {
public static final int ic_deepl_logo_icon = 0x7f080bcb; // 2131233739 public static final int ic_deepl_logo_icon = 0x7f080bcb; // 2131233739
public static final int ic_google_translate_logo = 0x7f080bcc; // 2131233740 public static final int ic_google_translate_logo = 0x7f080bcc; // 2131233740
public static final int ic_yandex_translate_icon = 0x7f080bd1; // 2131233745 public static final int ic_yandex_translate_icon = 0x7f080bd1; // 2131233745
public static final int microsoft = 0x7f080bd2; // 2131233746 public static final int $splash__0 = 0x7f080bd2; // 2131233746
public static final int roundmsg = 0x7f080bd3; // 2131233747 public static final int roundmsg = 0x7f080bd3; // 2131233747
public static final int tgs_entry_background = 0x7f080bd4; // 2131233748 public static final int tgs_entry_background = 0x7f080bd4; // 2131233748
public static final int yandex = 0x7f080bd7; // 2131233751 public static final int yandex = 0x7f080bd7; // 2131233751
public static final int $splash__0 = 0x7f080bd8; // 2131233752 public static final int $splash__1 = 0x7f080bd8; // 2131233752
public static final int $splash__1 = 0x7f080bd9; // 2131233753 public static final int $splash__10 = 0x7f080bd9; // 2131233753
public static final int $splash__10 = 0x7f080bda; // 2131233754 public static final int $splash__11 = 0x7f080bda; // 2131233754
public static final int $splash__11 = 0x7f080bdb; // 2131233755 public static final int $splash__12 = 0x7f080bdb; // 2131233755
public static final int $splash__12 = 0x7f080bdc; // 2131233756 public static final int $splash__13 = 0x7f080bdc; // 2131233756
public static final int $splash__13 = 0x7f080bdd; // 2131233757 public static final int $splash__14 = 0x7f080bdd; // 2131233757
public static final int $splash__14 = 0x7f080bde; // 2131233758 public static final int $splash__15 = 0x7f080bde; // 2131233758
public static final int $splash__15 = 0x7f080bdf; // 2131233759 public static final int $splash__2 = 0x7f080bdf; // 2131233759
public static final int $splash__2 = 0x7f080be0; // 2131233760 public static final int $splash__3 = 0x7f080be0; // 2131233760
public static final int $splash__3 = 0x7f080be1; // 2131233761 public static final int $splash__4 = 0x7f080be1; // 2131233761
public static final int $splash__4 = 0x7f080be2; // 2131233762 public static final int $splash__5 = 0x7f080be2; // 2131233762
public static final int $splash__5 = 0x7f080be3; // 2131233763 public static final int $splash__6 = 0x7f080be3; // 2131233763
public static final int $splash__6 = 0x7f080be4; // 2131233764 public static final int $splash__7 = 0x7f080be4; // 2131233764
public static final int $splash__7 = 0x7f080be5; // 2131233765 public static final int $splash__8 = 0x7f080be5; // 2131233765
public static final int $splash__8 = 0x7f080be6; // 2131233766 public static final int $splash__9 = 0x7f080be6; // 2131233766
public static final int $splash__9 = 0x7f080be7; // 2131233767
public static final int checker_background = 0x7f080be8; // 2131233768 public static final int checker_background = 0x7f080be8; // 2131233768
public static final int splash = 0x7f080be9; // 2131233769 public static final int custom_thumb_selector = 0x7f080be9; // 2131233769
public static final int custom_track_selector = 0x7f080bea; // 2131233770
public static final int splash = 0x7f080bec; // 2131233772
public static final int abc_control_background_material = 0x7f080032; // 2131230770 public static final int abc_control_background_material = 0x7f080032; // 2131230770
public static final int ic_action_close = 0x7f080322; // 2131231522 public static final int ic_action_close = 0x7f080322; // 2131231522
public static final int ic_camera_outline_28_new = 0x7f0803a0; // 2131231648 public static final int ic_camera_outline_28_new = 0x7f0803a0; // 2131231648
@@ -6793,6 +6796,9 @@ public final class R {
public static final int ic_telegram_24 = 0x7f080bcf; // 2131233743 public static final int ic_telegram_24 = 0x7f080bcf; // 2131233743
public static final int ic_telegram_outline_28 = 0x7f080bd0; // 2131233744 public static final int ic_telegram_outline_28 = 0x7f080bd0; // 2131233744
public static final int vtlogo = 0x7f080bd6; // 2131233750 public static final int vtlogo = 0x7f080bd6; // 2131233750
public static final int bing = 0x7f080be7; // 2131233767
public static final int sauceNAO = 0x7f080beb; // 2131233771
public static final int tracemoe = 0x7f080bed; // 2131233773
public static final int bg_music_play_button_white = 0x7f08015e; // 2131231070 public static final int bg_music_play_button_white = 0x7f08015e; // 2131231070
public static final int bg_poll_bg_thumb = 0x7f080181; // 2131231105 public static final int bg_poll_bg_thumb = 0x7f080181; // 2131231105
public static final int bg_stickers_suggestions_left = 0x7f0801ad; // 2131231149 public static final int bg_stickers_suggestions_left = 0x7f0801ad; // 2131231149
@@ -11054,6 +11060,8 @@ public final class R {
public static final int color_name = 0x7f0a1022; // 2131365922 public static final int color_name = 0x7f0a1022; // 2131365922
public static final int color_value = 0x7f0a1023; // 2131365923 public static final int color_value = 0x7f0a1023; // 2131365923
public static final int color_preview_border = 0x7f0a1024; // 2131365924 public static final int color_preview_border = 0x7f0a1024; // 2131365924
public static final int account_backup_view = 0x7f0a1025; // 2131365925
public static final int copy_image = 0x7f0a1026; // 2131365926
} }
public static final class integer { public static final class integer {
@@ -12993,6 +13001,30 @@ public final class R {
public static final int vt_changeable_foreground = 0x7f0f0044; // 2131689540 public static final int vt_changeable_foreground = 0x7f0f0044; // 2131689540
public static final int vt_launcher = 0x7f0f0045; // 2131689541 public static final int vt_launcher = 0x7f0f0045; // 2131689541
public static final int vt_party_foreground = 0x7f0f0047; // 2131689543 public static final int vt_party_foreground = 0x7f0f0047; // 2131689543
public static final int ic_launcher_balloon_pink = 0x7f0f0048; // 2131689544
public static final int ic_launcher_balloon_pink_background = 0x7f0f0049; // 2131689545
public static final int ic_launcher_balloon_pink_foreground = 0x7f0f004a; // 2131689546
public static final int ic_launcher_bubble_gum = 0x7f0f004b; // 2131689547
public static final int ic_launcher_bubble_gum_background = 0x7f0f004c; // 2131689548
public static final int ic_launcher_bubble_gum_foreground = 0x7f0f004d; // 2131689549
public static final int ic_launcher_comics = 0x7f0f004e; // 2131689550
public static final int ic_launcher_comics_background = 0x7f0f004f; // 2131689551
public static final int ic_launcher_comics_foreground = 0x7f0f0050; // 2131689552
public static final int ic_launcher_flowers = 0x7f0f0051; // 2131689553
public static final int ic_launcher_flowers_background = 0x7f0f0052; // 2131689554
public static final int ic_launcher_flowers_foreground = 0x7f0f0053; // 2131689555
public static final int ic_launcher_metal_dark = 0x7f0f0054; // 2131689556
public static final int ic_launcher_metal_dark_background = 0x7f0f0055; // 2131689557
public static final int ic_launcher_metal_dark_foreground = 0x7f0f0056; // 2131689558
public static final int ic_launcher_pin_blue = 0x7f0f0057; // 2131689559
public static final int ic_launcher_pin_blue_background = 0x7f0f0058; // 2131689560
public static final int ic_launcher_pin_blue_foreground = 0x7f0f0059; // 2131689561
public static final int ic_launcher_rabbit = 0x7f0f005a; // 2131689562
public static final int ic_launcher_rabbit_background = 0x7f0f005b; // 2131689563
public static final int ic_launcher_rabbit_foreground = 0x7f0f005c; // 2131689564
public static final int ic_launcher_shine = 0x7f0f005d; // 2131689565
public static final int ic_launcher_shine_background = 0x7f0f005e; // 2131689566
public static final int ic_launcher_shine_foreground = 0x7f0f005f; // 2131689567
public static final int vt_adaptive_launcher_foneground = 0x7f0f0043; // 2131689539 public static final int vt_adaptive_launcher_foneground = 0x7f0f0043; // 2131689539
public static final int vt_launcher_round = 0x7f0f0046; // 2131689542 public static final int vt_launcher_round = 0x7f0f0046; // 2131689542
public static final int ic_logo_facebook_28 = 0x7f0f0003; // 2131689475 public static final int ic_logo_facebook_28 = 0x7f0f0003; // 2131689475
@@ -19547,49 +19579,91 @@ public final class R {
public static final int accent_color_summ = 0x7f12183b; // 2131892283 public static final int accent_color_summ = 0x7f12183b; // 2131892283
public static final int accent_color_title = 0x7f12183c; // 2131892284 public static final int accent_color_title = 0x7f12183c; // 2131892284
public static final int accents = 0x7f12183d; // 2131892285 public static final int accents = 0x7f12183d; // 2131892285
public static final int add_to_ads_stories_whitelist = 0x7f12183e; // 2131892286 public static final int accounts_saved_by_path = 0x7f12183e; // 2131892286
public static final int amoledtheme_summ = 0x7f12183f; // 2131892287 public static final int add_to_ads_stories_whitelist = 0x7f12183f; // 2131892287
public static final int amoledtheme_title = 0x7f121840; // 2131892288 public static final int amoledtheme_summ = 0x7f121840; // 2131892288
public static final int app_open_by_default_settings = 0x7f121841; // 2131892289 public static final int amoledtheme_title = 0x7f121841; // 2131892289
public static final int audio_deleted_from_cache = 0x7f121842; // 2131892290 public static final int appLanguage = 0x7f121842; // 2131892290
public static final int blockminiapps_summ = 0x7f121843; // 2131892291 public static final int app_open_by_default_settings = 0x7f121843; // 2131892291
public static final int blockminiapps_title = 0x7f121844; // 2131892292 public static final int applying_accent = 0x7f121844; // 2131892292
public static final int businessDisabler_title = 0x7f121845; // 2131892293 public static final int audio_deleted_from_cache = 0x7f121845; // 2131892293
public static final int by_choice = 0x7f121846; // 2131892294 public static final int blockminiapps_summ = 0x7f121846; // 2131892294
public static final int calls_not_available = 0x7f121847; // 2131892295 public static final int blockminiapps_title = 0x7f121847; // 2131892295
public static final int cannot_write = 0x7f121848; // 2131892296 public static final int businessDisabler_title = 0x7f121848; // 2131892296
public static final int change_accent_color = 0x7f121849; // 2131892297 public static final int by_choice = 0x7f121849; // 2131892297
public static final int copydebuginfo_summ = 0x7f12184a; // 2131892298 public static final int calls_not_available = 0x7f12184a; // 2131892298
public static final int copydebuginfo_title = 0x7f12184b; // 2131892299 public static final int cannot_write = 0x7f12184b; // 2131892299
public static final int copyownlink_summ = 0x7f12184c; // 2131892300 public static final int change_accent_color = 0x7f12184c; // 2131892300
public static final int copyownlink_title = 0x7f12184d; // 2131892301 public static final int compression_types = 0x7f12184d; // 2131892301
public static final int crash_service_name = 0x7f12184e; // 2131892302 public static final int compression_types_selection = 0x7f12184e; // 2131892302
public static final int current_theme = 0x7f12184f; // 2131892303 public static final int copydebuginfo_summ = 0x7f12184f; // 2131892303
public static final int custom_links_warning = 0x7f121850; // 2131892304 public static final int copydebuginfo_title = 0x7f121850; // 2131892304
public static final int data_updated = 0x7f121851; // 2131892305 public static final int copyownlink_summ = 0x7f121851; // 2131892305
public static final int device_info = 0x7f121852; // 2131892306 public static final int copyownlink_title = 0x7f121852; // 2131892306
public static final int device_info_copied = 0x7f121853; // 2131892307 public static final int crash_service_name = 0x7f121853; // 2131892307
public static final int dialogstats = 0x7f121854; // 2131892308 public static final int currentLanguage = 0x7f121854; // 2131892308
public static final int downloading_update = 0x7f121855; // 2131892309 public static final int current_theme = 0x7f121855; // 2131892309
public static final int invalid_pack_link = 0x7f121856; // 2131892310 public static final int custom_links_warning = 0x7f121856; // 2131892310
public static final int maxquality_summ = 0x7f121857; // 2131892311 public static final int data = 0x7f121857; // 2131892311
public static final int maxquality_title = 0x7f121858; // 2131892312 public static final int data_updated = 0x7f121858; // 2131892312
public static final int monettheme_summ = 0x7f121859; // 2131892313 public static final int datasettings_title = 0x7f121859; // 2131892313
public static final int monettheme_title = 0x7f12185a; // 2131892314 public static final int device_info = 0x7f12185a; // 2131892314
public static final int newsfeed_notif_summ = 0x7f12185b; // 2131892315 public static final int device_info_copied = 0x7f12185b; // 2131892315
public static final int newsfeed_notif_title = 0x7f12185c; // 2131892316 public static final int dialogstats = 0x7f12185c; // 2131892316
public static final int open_bot = 0x7f12185d; // 2131892317 public static final int disable_analytics = 0x7f12185d; // 2131892317
public static final int promotedstickers_title = 0x7f12185e; // 2131892318 public static final int disable_analytics_summ = 0x7f12185e; // 2131892318
public static final int remove_from_ads_stories_whitelist = 0x7f12185f; // 2131892319 public static final int downloading_update = 0x7f12185f; // 2131892319
public static final int select_color = 0x7f121860; // 2131892320 public static final int error_applying_accent = 0x7f121860; // 2131892320
public static final int select_palette = 0x7f121861; // 2131892321 public static final int error_no_text = 0x7f121861; // 2131892321
public static final int sources = 0x7f121862; // 2131892322 public static final int error_saving_file = 0x7f121862; // 2131892322
public static final int updateverifdata_summ = 0x7f121863; // 2131892323 public static final int failed_to_get_text = 0x7f121863; // 2131892323
public static final int updateverifdata_title = 0x7f121864; // 2131892324 public static final int invalid_pack_link = 0x7f121864; // 2131892324
public static final int useOldAppVer_summ = 0x7f121865; // 2131892325 public static final int invalidate_theme_cache_title = 0x7f121865; // 2131892325
public static final int useOldAppVer_title = 0x7f121866; // 2131892326 public static final int logColors_title = 0x7f121866; // 2131892326
public static final int vkx_integration_enabled_info = 0x7f121867; // 2131892327 public static final int maxquality_summ = 0x7f121867; // 2131892327
public static final int writebar_ios_title = 0x7f121868; // 2131892328 public static final int maxquality_title = 0x7f121868; // 2131892328
public static final int microgsett = 0x7f121869; // 2131892329
public static final int monettheme_summ = 0x7f12186a; // 2131892330
public static final int monettheme_title = 0x7f12186b; // 2131892331
public static final int newsfeed_notif_summ = 0x7f12186c; // 2131892332
public static final int newsfeed_notif_title = 0x7f12186d; // 2131892333
public static final int open_bot = 0x7f12186e; // 2131892334
public static final int promotedstickers_title = 0x7f12186f; // 2131892335
public static final int remove_encryption_key = 0x7f121870; // 2131892336
public static final int remove_from_ads_stories_whitelist = 0x7f121871; // 2131892337
public static final int reset_accounts = 0x7f121872; // 2131892338
public static final int reset_all_settings = 0x7f121873; // 2131892339
public static final int restore_accounts = 0x7f121874; // 2131892340
public static final int restore_settings = 0x7f121875; // 2131892341
public static final int save_accounts = 0x7f121876; // 2131892342
public static final int save_online_data = 0x7f121877; // 2131892343
public static final int select_color = 0x7f121878; // 2131892344
public static final int select_palette = 0x7f121879; // 2131892345
public static final int sources = 0x7f12187a; // 2131892346
public static final int storiesGroupsAdBlock = 0x7f12187b; // 2131892347
public static final int storiesGroupsAdBlocksummary = 0x7f12187c; // 2131892348
public static final int systemtheme = 0x7f12187d; // 2131892349
public static final int systemtheme_enabled = 0x7f12187e; // 2131892350
public static final int systemtheme_summ = 0x7f12187f; // 2131892351
public static final int updateverifdata_summ = 0x7f121880; // 2131892352
public static final int updateverifdata_title = 0x7f121881; // 2131892353
public static final int useCustomPrefsStyle_summ = 0x7f121882; // 2131892354
public static final int useCustomPrefsStyle_title = 0x7f121883; // 2131892355
public static final int useGenius_summ = 0x7f121884; // 2131892356
public static final int useGenius_title = 0x7f121885; // 2131892357
public static final int useNewColorEngine_summ = 0x7f121886; // 2131892358
public static final int useNewColorEngine_title = 0x7f121887; // 2131892359
public static final int useOldAppVer_summ = 0x7f121888; // 2131892360
public static final int useOldAppVer_title = 0x7f121889; // 2131892361
public static final int vkx_integration_enabled_info = 0x7f12188a; // 2131892362
public static final int whitelisted_ad_groups_stories_title = 0x7f12188b; // 2131892363
public static final int writebar_ios_title = 0x7f12188c; // 2131892364
public static final int cache_size = 0x7f12188d; // 2131892365
public static final int cache_size_summ = 0x7f12188e; // 2131892366
public static final int clear_all_cache = 0x7f12188f; // 2131892367
public static final int invalidate_theme_cache_each_update_title = 0x7f121890; // 2131892368
public static final int invertFilters = 0x7f121891; // 2131892369
public static final int invertFilters_summ = 0x7f121892; // 2131892370
} }
public static final class style { public static final class style {
@@ -20786,5 +20860,6 @@ public final class R {
public static final int preferences_proxy = 0x7f15001c; // 2132082716 public static final int preferences_proxy = 0x7f15001c; // 2132082716
public static final int preferences_tgs = 0x7f15001d; // 2132082717 public static final int preferences_tgs = 0x7f15001d; // 2132082717
public static final int preferences_themes = 0x7f15001e; // 2132082718 public static final int preferences_themes = 0x7f15001e; // 2132082718
public static final int locales_config = 0x7f15001f; // 2132082719
} }
} }
@@ -1,8 +1,5 @@
package com.vtosters.lite.ui.bottomnavigation; package com.vtosters.lite.ui.bottomnavigation;
import static ru.vtosters.lite.utils.Preferences.vkme;
import static ru.vtosters.lite.utils.ThemesUtils.getCSTDock;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
import android.content.res.ColorStateList; import android.content.res.ColorStateList;
@@ -18,7 +15,6 @@ import android.view.View;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.appcompat.view.menu.MenuItemImpl; import androidx.appcompat.view.menu.MenuItemImpl;
@@ -26,12 +22,13 @@ import androidx.appcompat.view.menu.MenuView;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import androidx.core.graphics.drawable.DrawableCompat; import androidx.core.graphics.drawable.DrawableCompat;
import androidx.core.view.ViewCompat; import androidx.core.view.ViewCompat;
import com.vk.core.ui.themes.VKThemeHelper; import com.vk.core.ui.themes.VKThemeHelper;
import com.vtosters.lite.R; import com.vtosters.lite.R;
import me.grishka.appkit.utils.V; import me.grishka.appkit.utils.V;
import static ru.vtosters.hooks.other.Preferences.vkme;
import static ru.vtosters.hooks.other.ThemesUtils.getCSTDock;
public class BottomNavigationItemView extends FrameLayout implements MenuView.ItemView { public class BottomNavigationItemView extends FrameLayout implements MenuView.ItemView {
private final TextView mSmallLabel; private final TextView mSmallLabel;
private final TextView mLargeLabel; private final TextView mLargeLabel;
@@ -0,0 +1,34 @@
package ru.vtosters.hooks;
import android.view.View;
import com.vtosters.lite.R;
import ru.vtosters.hooks.other.Preferences;
import ru.vtosters.lite.utils.AndroidUtils;
import ru.vtosters.lite.utils.VersionReader;
import static ru.vtosters.hooks.other.Preferences.devmenu;
import static ru.vtosters.hooks.other.Preferences.getBuildName;
import static ru.vtosters.lite.utils.AndroidUtils.getApplicationName;
import static ru.vtosters.lite.utils.AndroidUtils.sendToast;
public class AboutHook {
public static void inject(View view) {
view.setOnLongClickListener(v -> {
if (devmenu()) {
sendToast(AndroidUtils.getString(R.string.debug_menu_already_activated));
} else {
Preferences.getPreferences().edit().putBoolean("devmenu", true).apply();
sendToast(AndroidUtils.getString(R.string.debug_menu_activated));
}
return true;
});
}
public static String getCommitLink() {
return "https://github.com/vtosters/lite/commit/" + VersionReader.getVersionCommit();
}
public static String getAppVersion() {
return getApplicationName() + " " + getBuildName() + " | " + VersionReader.getVersionFull();
}
}
@@ -0,0 +1,21 @@
package ru.vtosters.hooks;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import ru.vtosters.lite.utils.NewsFeedFiltersUtils;
public class AdBlockHook {
public static JSONObject discoverInject(JSONObject json) throws JSONException {
return NewsFeedFiltersUtils.discoverInject(json);
}
public static JSONArray feedInject(JSONArray items) {
return NewsFeedFiltersUtils.feedInject(items);
}
public static JSONObject storiesads(JSONObject json, boolean isDeleteFix) throws JSONException {
return NewsFeedFiltersUtils.storiesads(json, isDeleteFix);
}
}
@@ -1,9 +1,9 @@
package ru.vtosters.lite.hooks; package ru.vtosters.hooks;
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
import b.h.g.g.BuildInfo; import b.h.g.g.BuildInfo;
import static ru.vtosters.hooks.other.Preferences.getBoolValue;
public class AppVerHook { public class AppVerHook {
public static int appBuild() { public static int appBuild() {
return getBoolValue("useOldAppVer", false) ? 6561 : BuildInfo.i.e(); return getBoolValue("useOldAppVer", false) ? 6561 : BuildInfo.i.e();
@@ -0,0 +1,9 @@
package ru.vtosters.hooks;
import static ru.vtosters.hooks.other.Preferences.getBoolValue;
public class BusinessNotifHook {
public static boolean hook(boolean i) {
return !getBoolValue("businessDisabler", false) && i;
}
}
@@ -1,4 +1,4 @@
package ru.vtosters.lite.hooks; package ru.vtosters.hooks;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
@@ -0,0 +1,27 @@
package ru.vtosters.hooks;
import org.json.JSONException;
import org.json.JSONObject;
import ru.vtosters.lite.music.catalog.inject.CatalogJsonInjector;
public class CatalogsHook {
public static JSONObject injectCatalogGetAudio(JSONObject json) {
try {
return CatalogJsonInjector.music(json);
} catch (JSONException e) {
return json;
}
}
public static JSONObject injectCatalogGetAudioArtist(JSONObject json) {
try {
return CatalogJsonInjector.fixArtists(json);
} catch (JSONException e) {
return json;
}
}
public static JSONObject injectCatalogGetSection(JSONObject json) {
return CatalogJsonInjector.injectIntoCatalogs(json);
}
}
@@ -1,10 +1,4 @@
package ru.vtosters.lite.hooks; package ru.vtosters.hooks;
import static ru.vtosters.lite.dnr.DNRInjector.forceInvalidateDialogActions;
import static ru.vtosters.lite.utils.AndroidUtils.dp2px;
import static ru.vtosters.lite.utils.AndroidUtils.sendToast;
import static ru.vtosters.lite.utils.LifecycleUtils.getCurrentActivity;
import static ru.vtosters.lite.utils.ThemesUtils.getSTextAttr;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
@@ -13,17 +7,21 @@ import android.text.Editable;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.EditText; import android.widget.EditText;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import com.vk.core.dialogs.alert.VkAlertDialog; import com.vk.core.dialogs.alert.VkAlertDialog;
import com.vk.im.engine.models.dialogs.Dialog; import com.vk.im.engine.models.dialogs.Dialog;
import com.vtosters.lite.R; import com.vtosters.lite.R;
import ru.vtosters.lite.encryption.EncryptProvider;
import ru.vtosters.lite.encryption.base.IMProcessor;
import ru.vtosters.lite.utils.AndroidUtils;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import ru.vtosters.lite.encryption.EncryptProvider; import static ru.vtosters.hooks.DialogHeaderInjector.forceInvalidateDialogActions;
import ru.vtosters.lite.encryption.base.IMProcessor; import static ru.vtosters.hooks.other.ThemesUtils.getSTextAttr;
import ru.vtosters.lite.utils.AndroidUtils; import static ru.vtosters.lite.utils.AndroidUtils.dp2px;
import static ru.vtosters.lite.utils.AndroidUtils.sendToast;
import static ru.vtosters.lite.utils.LifecycleUtils.getCurrentActivity;
public class CryptImHook { public class CryptImHook {
public static boolean isPrivateProcessor(int peerID) { public static boolean isPrivateProcessor(int peerID) {
@@ -100,7 +98,7 @@ public class CryptImHook {
key = enabled.getEncryptionKeyFor(peerId); key = enabled.getEncryptionKeyFor(peerId);
} }
if (key.equals("VTAesDefault")) { if (Objects.equals(key, "VTAesDefault")) {
key = null; key = null;
} }
@@ -128,6 +126,9 @@ public class CryptImHook {
Editable edit = editText.getText(); Editable edit = editText.getText();
finalEnabled.setEncryptionKeyFor(peerId, edit == null ? null : edit.toString()); finalEnabled.setEncryptionKeyFor(peerId, edit == null ? null : edit.toString());
}).setNegativeButton(android.R.string.cancel, null) }).setNegativeButton(android.R.string.cancel, null)
.setNeutralButton(AndroidUtils.getString("remove_encryption_key"), (dialog, which) -> {
finalEnabled.removeEncryptionKeyFor(peerId);
})
.show(); .show();
} }
} }
@@ -1,17 +1,15 @@
package ru.vtosters.lite.hooks; package ru.vtosters.hooks;
import static ru.vtosters.lite.utils.Preferences.getString;
import static ru.vtosters.lite.utils.AndroidUtils.getStringDate;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import com.vtosters.lite.R; import com.vtosters.lite.R;
import ru.vtosters.lite.utils.AndroidUtils;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.Locale; import java.util.Locale;
import ru.vtosters.lite.utils.AndroidUtils; import static ru.vtosters.hooks.other.Preferences.getString;
import static ru.vtosters.lite.utils.AndroidUtils.getStringDate;
public class DateHook { public class DateHook {
public static boolean fulltime() { public static boolean fulltime() {
@@ -1,13 +1,8 @@
package ru.vtosters.lite.utils; package ru.vtosters.hooks;
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
import static ru.vtosters.lite.utils.Preferences.getString;
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.content.ContentValues; import android.content.ContentValues;
import android.database.Cursor; import android.database.Cursor;
import com.vk.im.engine.events.OnMsgUpdateEvent; import com.vk.im.engine.events.OnMsgUpdateEvent;
import com.vk.im.engine.internal.longpoll.tasks.MsgDeleteLpTask; import com.vk.im.engine.internal.longpoll.tasks.MsgDeleteLpTask;
import com.vk.im.engine.internal.storage.StorageEnvironment; import com.vk.im.engine.internal.storage.StorageEnvironment;
@@ -15,17 +10,18 @@ import com.vk.im.engine.models.messages.Msg;
import com.vk.im.engine.models.messages.MsgFromUser; import com.vk.im.engine.models.messages.MsgFromUser;
import com.vk.im.engine.models.messages.NestedMsg; import com.vk.im.engine.models.messages.NestedMsg;
import com.vk.libsqliteext.CustomSqliteExtensionsKt; import com.vk.libsqliteext.CustomSqliteExtensionsKt;
import io.requery.android.database.sqlite.SQLiteDatabase;
import io.requery.android.database.sqlite.SQLiteOpenHelper;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import io.requery.android.database.sqlite.SQLiteDatabase; import static ru.vtosters.hooks.other.Preferences.getBoolValue;
import io.requery.android.database.sqlite.SQLiteOpenHelper; import static ru.vtosters.hooks.other.Preferences.getString;
import ru.vtosters.lite.encryption.EncryptProvider; import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
public class DeletedMessagesHandler { public class DeletedMessagesHook {
private static List<Integer> sDeletedMessagesList = new ArrayList<>(); private static List<Integer> sDeletedMessagesList = new ArrayList<>();
private static SQLiteDatabase sVKSQLiteDatabase; private static SQLiteDatabase sVKSQLiteDatabase;
private static int sBodyIndex = -1; private static int sBodyIndex = -1;
private static DeletedMessagesDBHelper sVTDatabase; private static DeletedMessagesDBHelper sVTDatabase;
@@ -62,13 +58,13 @@ public class DeletedMessagesHandler {
for (NestedMsg nestedMsg : nestedMsgs) { for (NestedMsg nestedMsg : nestedMsgs) {
if (!nestedMsg.w0().isEmpty()) checkForNestedMsg(nestedMsg.w0()); if (!nestedMsg.w0().isEmpty()) checkForNestedMsg(nestedMsg.w0());
nestedMsg.d(EncryptProvider.decryptMessage(nestedMsg.f(), nestedMsg.getFrom().getId())); nestedMsg.d(EncryptionMessagesHook.decryptMessage(nestedMsg.f(), nestedMsg.getFrom().getId()));
} }
} }
private static void editTextOfMsg(MsgFromUser msgFromUser) { private static void editTextOfMsg(MsgFromUser msgFromUser) {
if (!msgFromUser.f().startsWith(getPrefixUndelete())) { if (!msgFromUser.f().startsWith(getPrefixUndelete())) {
msgFromUser.d(getPrefixUndelete() + EncryptProvider.decryptMessage(msgFromUser)); msgFromUser.d(getPrefixUndelete() + EncryptionMessagesHook.decryptMessage(msgFromUser));
} }
} }
@@ -89,7 +85,7 @@ public class DeletedMessagesHandler {
@SuppressLint("Range") @SuppressLint("Range")
int localId = cursor.getInt(cursor.getColumnIndex("local_id")); int localId = cursor.getInt(cursor.getColumnIndex("local_id"));
var className = DeletedMessagesHandler.class.getSimpleName(); var className = DeletedMessagesHook.class.getSimpleName();
var imEnvironment = msgDeleteLpTask.b; var imEnvironment = msgDeleteLpTask.b;
var cint = msgDeleteLpTask.c; var cint = msgDeleteLpTask.c;
imEnvironment.a(className, new OnMsgUpdateEvent(className, cint, localId)); imEnvironment.a(className, new OnMsgUpdateEvent(className, cint, localId));
@@ -1,14 +1,14 @@
package ru.vtosters.lite.hooks; package ru.vtosters.hooks;
import static ru.vtosters.lite.utils.AndroidUtils.MD5;
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.os.Build; import android.os.Build;
import android.provider.Settings; import android.provider.Settings;
import android.util.Log; import android.util.Log;
import static ru.vtosters.hooks.other.Preferences.getBoolValue;
import static ru.vtosters.lite.utils.AndroidUtils.MD5;
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
public class DeviceInfoHook { public class DeviceInfoHook {
public static String getDeviceInfo(String input) { public static String getDeviceInfo(String input) {
Log.d("DeviceInfoHook", "getDeviceInfo: " + input); Log.d("DeviceInfoHook", "getDeviceInfo: " + input);
@@ -40,7 +40,7 @@ public class DeviceInfoHook {
} }
@SuppressLint("HardwareIds") @SuppressLint("HardwareIds")
private static String findDeviceId() { public static String findDeviceId() {
return Settings.Secure.getString(getGlobalContext().getContentResolver(), "android_id"); return Settings.Secure.getString(getGlobalContext().getContentResolver(), Settings.Secure.ANDROID_ID);
} }
} }
@@ -0,0 +1,138 @@
package ru.vtosters.hooks;
import android.annotation.SuppressLint;
import android.os.Environment;
import com.vk.im.engine.ImEngine1;
import com.vk.im.engine.events.OnDialogUpdateEvent;
import com.vk.im.engine.models.EntityIntMap;
import com.vk.im.engine.models.dialogs.Dialog;
import com.vk.im.ui.components.common.DialogAction;
import com.vk.im.ui.views.dialog_actions.DialogActionsListView;
import ru.vtosters.lite.dialogs.Requests;
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.utils.AndroidUtils;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
public class DialogHeaderInjector {
public static boolean onClick(DialogAction action, Dialog dialog) { // header menu
int peerId;
try {
peerId = dialog.getId();
} catch (Exception e) {
return true;
}
switch (action) {
case MARK_AS_READ -> {
Requests.hookRead(dialog);
forceInvalidateDialogActions(dialog);
}
case DNR_ON, DNR_OFF -> {
MessagesActivityHook.hookDNR(peerId);
forceInvalidateDialogActions(dialog);
return true;
}
case DNT_ON, DNT_OFF -> {
MessagesActivityHook.hookDNT(peerId);
forceInvalidateDialogActions(dialog);
return true;
}
case ENCRYPT_SETT -> {
CryptImHook.hookPref(peerId);
return true;
}
case ENCRYPT -> {
CryptImHook.hook(peerId, dialog);
return true;
}
case DOWNLOAD -> {
File out = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), "dialog-" + peerId + ".html");
try {
new MessagesDownloader().downloadDialog(peerId, new HtmlDialogDownloaderFormatProvider(), out);
} catch (Exception e) {
AndroidUtils.sendToast(AndroidUtils.getString(com.vtosters.lite.R.string.download_dl_error));
e.printStackTrace();
}
return true;
}
case STAT -> {
Requests.hookDialogInfo(dialog);
return true;
}
}
return false;
}
public static List<DialogAction> injectToListAccess(List<DialogAction> actions, Dialog dialog) {
int peerId;
try {
peerId = dialog.getId();
} catch (Exception e) {
return actions;
}
actions.add(DialogAction.STAT);
actions.add(DialogAction.DOWNLOAD);
if (MessagesActivityHook.isDnrEnabledFor(peerId)) {
actions.add(DialogAction.DNR_OFF);
} else {
actions.add(DialogAction.DNR_ON);
}
if (MessagesActivityHook.isDntEnabledFor(peerId)) {
actions.add(DialogAction.DNT_OFF);
} else {
actions.add(DialogAction.DNT_ON);
}
actions.add(DialogAction.ENCRYPT);
IMProcessor prov = EncryptProvider.getProcessorFor(peerId);
if (prov != null && !prov.isPublic()) {
actions.add(DialogAction.ENCRYPT_SETT);
}
actions.add(DialogAction.MARK_AS_READ);
return actions;
}
@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, com.vtosters.lite.R.attr.im_ic_msgdl, com.vtosters.lite.R.string.download_dl)); // DialogAction, Int, Icon, String
list.add(new DialogActionsListView.b.a(DialogAction.DNR_ON, 2, com.vtosters.lite.R.attr.im_ic_pinned_msg_hide, com.vtosters.lite.R.string.DNR_ON)); // DialogAction, Int, Icon, String
list.add(new DialogActionsListView.b.a(DialogAction.DNR_OFF, 2, com.vtosters.lite.R.attr.im_ic_pinned_msg_show, com.vtosters.lite.R.string.DNR_OFF)); // DialogAction, Int, Icon, String
list.add(new DialogActionsListView.b.a(DialogAction.DNT_ON, 2, com.vtosters.lite.R.attr.im_ic_edit_msg, com.vtosters.lite.R.string.DNT_ON)); // DialogAction, Int, Icon, String
list.add(new DialogActionsListView.b.a(DialogAction.DNT_OFF, 2, com.vtosters.lite.R.attr.im_ic_edit_msg, com.vtosters.lite.R.string.DNT_OFF)); // DialogAction, Int, Icon, String
if (!AndroidUtils.isTablet()) {
list.add(new DialogActionsListView.b.a(DialogAction.ENCRYPT, 3, com.vtosters.lite.R.attr.im_ic_keyboard, com.vtosters.lite.R.string.encryption)); // DialogAction, Int, Icon, String
list.add(new DialogActionsListView.b.a(DialogAction.ENCRYPT_SETT, 3, com.vtosters.lite.R.attr.im_ic_more_vertical, com.vtosters.lite.R.string.encryption_sett)); // DialogAction, Int, Icon, String
}
list.add(new DialogActionsListView.b.a(DialogAction.MARK_AS_READ, 4, com.vtosters.lite.R.attr.im_ic_done, com.vtosters.lite.R.string.vkim_dialogs_list_option_mark_as_read)); // DialogAction, Int, Icon, String
return list;
}
public static void forceInvalidateDialogActions(Dialog d) {
EntityIntMap<Dialog> map = new EntityIntMap<>();
map.a(d.getId(), d);
ImEngine1.a().a(new OnDialogUpdateEvent(null, map));
}
}
@@ -0,0 +1,115 @@
package ru.vtosters.hooks;
import android.os.Environment;
import com.vk.im.engine.models.dialogs.Dialog;
import com.vk.im.ui.components.common.DialogAction;
import com.vtosters.lite.R;
import ru.vtosters.lite.dialogs.Requests;
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 java.io.File;
import java.util.LinkedHashMap;
import java.util.List;
public class DialogMenuInjectors {
public static void inject(Dialog dialog, List<DialogAction> list) {
int peerId;
try {
peerId = dialog.getId();
} catch (Exception e) {
return;
}
list.add(DialogAction.STAT);
list.add(DialogAction.DOWNLOAD);
list.add(DialogAction.pinmsg);
list.add(DialogAction.unpinmsg);
list.add(MessagesActivityHook.isDnrEnabledFor(peerId) ? DialogAction.DNR_OFF : DialogAction.DNR_ON);
list.add(MessagesActivityHook.isDntEnabledFor(peerId) ? DialogAction.DNT_OFF : DialogAction.DNT_ON);
list.add(DialogAction.ENCRYPT);
IMProcessor prov = EncryptProvider.getProcessorFor(peerId);
if (prov != null && !prov.isPublic())
list.add(DialogAction.ENCRYPT_SETT);
}
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);
hashMap.put(DialogAction.DNR_OFF, R.string.DNR_OFF);
hashMap.put(DialogAction.DNT_ON, R.string.DNT_ON);
hashMap.put(DialogAction.DNT_OFF, R.string.DNT_OFF);
hashMap.put(DialogAction.ENCRYPT, R.string.encryption);
hashMap.put(DialogAction.ENCRYPT_SETT, R.string.encryption_sett);
// hashMap.put(DialogAction.pinmsg, getIdentifier("pinmsg", "string"));
// hashMap.put(DialogAction.unpinmsg, getIdentifier("unpinmsg", "string"));
return hashMap;
}
public static boolean onClick(Dialog dialog, DialogAction action) { // popup menu in dialogs
int peerId;
try {
peerId = dialog.getId();
} catch (Exception e) {
return true;
}
switch (action) {
case MARK_AS_READ -> Requests.hookRead(dialog);
case STAT -> {
Requests.hookDialogInfo(dialog);
return true;
}
case DOWNLOAD -> {
File out = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), peerId + "-dialog.html");
try {
new MessagesDownloader().downloadDialog(peerId, new HtmlDialogDownloaderFormatProvider(), out);
} catch (Exception e) {
e.printStackTrace();
}
return true;
}
case DNR_ON, DNR_OFF -> {
MessagesActivityHook.hookDNR(peerId);
return true;
}
case DNT_ON, DNT_OFF -> {
MessagesActivityHook.hookDNT(peerId);
return true;
}
case pinmsg -> {
Requests.pinnedMsg(peerId, true);
return true;
}
case unpinmsg -> {
Requests.pinnedMsg(peerId, false);
return true;
}
case ENCRYPT_SETT -> {
CryptImHook.hookPref(peerId);
return true;
}
case ENCRYPT -> {
CryptImHook.hook(peerId, dialog);
return true;
}
}
return false;
}
}
@@ -0,0 +1,52 @@
package ru.vtosters.hooks;
import android.content.Context;
import com.vk.im.engine.models.messages.Msg;
import com.vk.im.engine.models.messages.MsgFromUser;
import com.vk.im.ui.components.common.MsgAction;
import com.vk.im.ui.components.viewcontrollers.popup.DelegateMsg;
import ru.vtosters.lite.dialogs.Requests;
import ru.vtosters.lite.ui.dialogs.Translate;
import ru.vtosters.lite.utils.AndroidUtils;
import java.util.LinkedHashMap;
public class DialogMessageInjector {
public static LinkedHashMap<MsgAction, DelegateMsg.a.a> injectToHashMap(LinkedHashMap<MsgAction, DelegateMsg.a.a> hashMap) {
hashMap.put(MsgAction.KICK, new DelegateMsg.a.a(com.vtosters.lite.R.string.vkim_accessibility_kick_from_chat));
hashMap.put(MsgAction.TRANSLATE, new DelegateMsg.a.a(com.vtosters.lite.R.string.translator));
hashMap.put(MsgAction.READTO, new DelegateMsg.a.a(com.vtosters.lite.R.string.readto));
return hashMap;
}
public static boolean onClick(Context context, MsgAction action, Msg msg) { // popup menu in chat
var peerId = msg.v1();
switch (action) {
case KICK -> {
Requests.hookKick(msg);
return true;
}
case READTO -> {
Requests.hookReadStartMsgTo(msg);
return true;
}
case TRANSLATE -> {
if (msg instanceof MsgFromUser) {
var text = ((MsgFromUser) msg).f();
var isTextExist = !text.isEmpty() && !text.equals(" ");
if (isTextExist) {
Translate.showTranslatedText(context, EncryptionMessagesHook.decryptMessage(text, peerId));
} else {
AndroidUtils.sendToast(context.getString(com.vtosters.lite.R.string.translator_no_text));
}
return true;
}
}
}
return false;
}
}
@@ -1,4 +1,4 @@
package ru.vtosters.lite.feature.discover; package ru.vtosters.hooks;
import com.vk.dto.discover.DiscoverItem; import com.vk.dto.discover.DiscoverItem;
@@ -1,34 +1,9 @@
package ru.vtosters.lite.hooks; package ru.vtosters.hooks;
import static com.vtosters.lite.R.id.menu_fave;
import static com.vtosters.lite.R.id.menu_feedback;
import static com.vtosters.lite.R.id.menu_friends;
import static com.vtosters.lite.R.id.menu_games;
import static com.vtosters.lite.R.id.menu_groups;
import static com.vtosters.lite.R.id.menu_messages;
import static com.vtosters.lite.R.id.menu_newsfeed;
import static com.vtosters.lite.R.id.menu_photos;
import static com.vtosters.lite.R.id.menu_search;
import static com.vtosters.lite.R.id.menu_videos;
import static com.vtosters.lite.R.id.menu_vk_pay;
import static com.vtosters.lite.R.id.tab_discover;
import static com.vtosters.lite.R.id.tab_feedback;
import static com.vtosters.lite.R.id.tab_menu;
import static com.vtosters.lite.R.id.tab_messages;
import static com.vtosters.lite.R.id.tab_news;
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
import static ru.vtosters.lite.utils.AndroidUtils.getResources;
import static ru.vtosters.lite.utils.Preferences.dockcounter;
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
import static ru.vtosters.lite.utils.Preferences.milkshake;
import static ru.vtosters.lite.utils.ThemesUtils.getCSTDock;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.graphics.drawable.Drawable;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.ViewGroup; import android.view.ViewGroup;
import com.vk.apps.AppsFragment; import com.vk.apps.AppsFragment;
import com.vk.core.drawable.RecoloredDrawable; import com.vk.core.drawable.RecoloredDrawable;
import com.vk.core.fragments.FragmentImpl; import com.vk.core.fragments.FragmentImpl;
@@ -37,22 +12,22 @@ import com.vk.navigation.right.RightMenu;
import com.vtosters.lite.MenuCountersState; import com.vtosters.lite.MenuCountersState;
import com.vtosters.lite.ui.bottomnavigation.BottomNavigationMenuView; import com.vtosters.lite.ui.bottomnavigation.BottomNavigationMenuView;
import com.vtosters.lite.ui.bottomnavigation.BottomNavigationView; import com.vtosters.lite.ui.bottomnavigation.BottomNavigationView;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import ru.vtosters.lite.ui.components.DockBarEditorManager;
import ru.vtosters.lite.ui.items.DockBarTab;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.*;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import ru.vtosters.lite.ui.components.DockBarEditorManager; import static com.vtosters.lite.R.id.*;
import ru.vtosters.lite.ui.items.DockBarTab; import static ru.vtosters.hooks.other.Preferences.*;
import static ru.vtosters.hooks.other.ThemesUtils.getCSTDock;
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
import static ru.vtosters.lite.utils.AndroidUtils.getResources;
public class DockBarInjector { public class DockBarInjector {
private static final DockBarEditorManager sManager = DockBarEditorManager.getInstance(); private static final DockBarEditorManager sManager = DockBarEditorManager.getInstance();
@@ -0,0 +1,40 @@
package ru.vtosters.hooks;
import android.content.Context;
import com.vk.core.dialogs.bottomsheet.MenuBottomSheetAction;
import com.vk.dto.common.VideoFile;
import com.vk.dto.music.MusicTrack;
import com.vk.dto.stories.model.StoryEntry;
import ru.vtosters.lite.downloaders.AudioDownloader;
import ru.vtosters.lite.downloaders.StoryDownloader;
import ru.vtosters.lite.downloaders.VideoDownloader;
import ru.vtosters.lite.utils.ExternalLinkParser;
import java.util.ArrayList;
public class DownloadersHook {
public static boolean onClickVideo(int id, VideoFile video, Context ctx) {
if (id == VideoDownloader.DOWNLOAD_ID) {
VideoDownloader.downloadVideo(video, ctx);
return true;
} else if (id == VideoDownloader.OPEN_EXTERNAL_LINK_ID) {
ExternalLinkParser.parseVideoFile(video, ctx, true);
}
return false;
}
public static void injectActionVideo(ArrayList<MenuBottomSheetAction> list, VideoFile video) {
if (!video.U && !video.I1()) {
VideoDownloader.addAction(list, VideoDownloader.DOWNLOAD_ID, com.vtosters.lite.R.drawable.ic_download_outline_24, com.vtosters.lite.R.string.download, 9);
VideoDownloader.addAction(list, VideoDownloader.OPEN_EXTERNAL_LINK_ID, com.vtosters.lite.R.drawable.ic_link_outline_28, com.vtosters.lite.R.string.interfacevideoext_short, 9);
}
}
public static Runnable injectActionStory(StoryEntry story) {
return () -> StoryDownloader.downloadStory(story);
}
public static void injectCacheAudio(MusicTrack mt) {
AudioDownloader.cacheTrack(mt);
}
}
@@ -0,0 +1,102 @@
package ru.vtosters.hooks;
import android.util.Log;
import com.vk.im.engine.models.messages.Msg;
import com.vk.im.engine.models.messages.MsgFromUser;
import com.vk.im.ui.components.msg_list.MsgListComponent;
import ru.vtosters.lite.encryption.EncryptProvider;
import ru.vtosters.lite.encryption.base.IMProcessor;
import static ru.vtosters.hooks.MessagesHook.injectOwnText;
import static ru.vtosters.hooks.MessagesHook.injectOwnTextAll;
public class EncryptionMessagesHook {
// For message editing
public static String decryptMessage(MsgFromUser msg, boolean showEmoji) {
var decryptedMessage = decryptMessage(EncryptProvider.getBody(msg), EncryptProvider.getPeerId(msg));
if (!showEmoji && !decryptedMessage.equals(injectOwnTextAll(EncryptProvider.getBody(msg))))
decryptedMessage = decryptedMessage.replaceAll("^\uD83D\uDD12 ", "");
return decryptedMessage;
}
public static String decryptMessage(String msg, MsgListComponent list) {
var peerid = list.G().getId();
var decryptedMessage = decryptMessage(msg, peerid);
if (!decryptedMessage.equals(injectOwnTextAll(msg)))
decryptedMessage = decryptedMessage.replaceAll("^\uD83D\uDD12 ", "");
return decryptedMessage;
}
public static CharSequence decryptMessage(CharSequence msg, int peerid) {
return decryptMessage(msg.toString(), peerid);
}
public static CharSequence decryptMessage(Msg msg, CharSequence orig) {
if (msg instanceof MsgFromUser) {
var decrypted = decryptMessage(((MsgFromUser) msg).f(), msg.v1());
if (decrypted.contains("\uD83D\uDD12")) {
return decrypted;
}
}
return orig;
}
public static String decryptMessages(String msgBody, int peer, boolean showEmoji) {
return (String) decryptMessage(msgBody, peer, showEmoji);
}
public static CharSequence decryptMessage(CharSequence msgBody, MsgFromUser msgFromUser, boolean showEmoji) {
try {
return decryptMessage((String) msgBody, msgFromUser.v1(), showEmoji);
} catch (Exception e) {
return decryptMessage((String) msgBody, 0, showEmoji);
}
}
// For MentionsFormatter that requires CharSequence
public static CharSequence decryptMessage(String msgBody, int peer, boolean showEmoji) {
var decryptedMessage = decryptMessage(msgBody, peer);
if (!showEmoji && !decryptedMessage.equals(injectOwnTextAll(msgBody)))
decryptedMessage = decryptedMessage.replaceAll("^\uD83D\uDD12 ", "");
return decryptedMessage;
}
// This will run through EVERY single processor available.
public static String decryptMessage(MsgFromUser msg) {
return decryptMessage(EncryptProvider.getBody(msg), EncryptProvider.getPeerId(msg));
}
public static String decryptMessage(String msgBody, int peer) {
try {
for (IMProcessor processor : EncryptProvider.processors) {
if ((processor.isUsed() || !processor.isPublic()) && processor.isEncrypted(msgBody) && (processor.isPublic() || EncryptProvider.getKeyForProcessor(processor, peer) != null))
return "\uD83D\uDD12 " + injectOwnTextAll(processor.decode(msgBody, EncryptProvider.getKeyForProcessor(processor, peer)));
}
} catch (Exception e) {
e.printStackTrace();
}
return injectOwnTextAll(msgBody);
}
// This will use only the processor which was chosen in chat menu
public static String encryptMessage(MsgFromUser msg) {
String msgBody = EncryptProvider.getBody(msg);
Log.d("EncryptProvider", "encryptMessage: msg = " + msg);
Log.d("EncryptProvider", "encryptMessage: body = " + msgBody);
Log.d("EncryptProvider", "encryptMessage: peerId = " + EncryptProvider.getPeerId(msg));
for (IMProcessor processor : EncryptProvider.processors) {
int peer = EncryptProvider.getPeerId(msg);
if (processor.isUsedToEncrypt(peer)) {
return injectOwnText(processor.encode(msgBody, EncryptProvider.getKeyForProcessor(processor, peer)));
}
}
return injectOwnText(msgBody);
}
}
@@ -1,10 +1,10 @@
package ru.vtosters.lite.hooks; package ru.vtosters.hooks;
import static ru.vtosters.lite.ui.components.FragAnimationKit.setAnimations;
import static ru.vtosters.lite.utils.Preferences.getString;
import androidx.fragment.app.FragmentTransaction; import androidx.fragment.app.FragmentTransaction;
import static ru.vtosters.hooks.other.Preferences.getString;
import static ru.vtosters.lite.ui.components.FragAnimationKit.setAnimations;
public class FragAnimationHook { public class FragAnimationHook {
public static boolean animateOpen(FragmentTransaction transaction) { public static boolean animateOpen(FragmentTransaction transaction) {
setAnimations(transaction); setAnimations(transaction);
@@ -1,23 +1,13 @@
package ru.vtosters.lite.hooks; package ru.vtosters.hooks;
import static ru.vtosters.lite.utils.Preferences.isValidSignature;
import android.os.Build; import android.os.Build;
import android.util.Base64; import android.util.Base64;
import java.io.BufferedReader; import javax.net.ssl.HttpsURLConnection;
import java.io.DataOutputStream; import java.io.*;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL; import java.net.URL;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.security.KeyPair; import java.security.*;
import java.security.KeyPairGenerator;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
import java.security.Signature;
import java.security.interfaces.RSAPrivateKey; import java.security.interfaces.RSAPrivateKey;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@@ -25,15 +15,12 @@ import java.util.List;
import java.util.Random; import java.util.Random;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import javax.net.ssl.HttpsURLConnection; import static ru.vtosters.hooks.other.Preferences.isValidSignature;
public class GcmHook { public class GcmHook {
private static final String agent = String.format("Android-GCM/1.5 (%s %s)", Build.MODEL, Build.MODEL); private static final String agent = String.format("Android-GCM/1.5 (%s %s)", Build.MODEL, Build.MODEL);
private static KeyPair pair; private static KeyPair pair;
private static int rid = 0; private static int rid = 0;
static { static {
@@ -45,15 +32,15 @@ public class GcmHook {
} }
public static String requestToken(String orig) { public static String requestToken(String orig) {
return "yssp9o9p9pamz5t-nvmq8spgwtin3e0=="; return isValidSignature() ? "yssp9o9p9pamz5t-nvmq8spgwtin3e0==" : requestToken();
} }
public static String requestToken() { public static String requestToken() {
String xappide;
try { try {
String aid = getRandomAid(); String aid = getRandomAid();
String pub2 = genNewKey(); String pub2 = genNewKey();
String sig = getSig(pub2); String sig = getSig(pub2);
String xappide;
try { try {
byte[] bytes = MessageDigest.getInstance("SHA1").digest(pair.getPublic().getEncoded()); byte[] bytes = MessageDigest.getInstance("SHA1").digest(pair.getPublic().getEncoded());
bytes[0] = (byte) (((bytes[0] & 15) + 112) & 255); bytes[0] = (byte) (((bytes[0] & 15) + 112) & 255);
@@ -210,7 +197,6 @@ public class GcmHook {
}).getBytes(StandardCharsets.UTF_8)); }).getBytes(StandardCharsets.UTF_8));
return Base64.encodeToString(sign.sign(), 0); return Base64.encodeToString(sign.sign(), 0);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace();
return null; return null;
} }
} }
@@ -0,0 +1,58 @@
package ru.vtosters.hooks;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.content.Context;
import android.os.Build;
import com.google.firebase.iid.FirebaseInstanceIdReceiver;
import com.google.firebase.iid.FirebaseInstanceIdReceiver2;
import com.vtosters.lite.R;
import ru.vtosters.lite.utils.AndroidUtils;
public class GmsHook {
private static final boolean needToSpoof = !isGmsInstalled() && isFakeGmsInstalled();
public static boolean isGmsInstalled() {
try {
AndroidUtils.getGlobalContext().getPackageManager().getPackageInfo("com.google.android.gms", 0);
return true;
} catch (Exception unused) {
return false;
}
} // Google Market Services check
public static boolean isFakeGmsInstalled() {
try {
AndroidUtils.getGlobalContext().getPackageManager().getPackageInfo("com.mgoogle.android.gms", 0);
return true;
} catch (Exception unused) {
return false;
}
} // Microg Google Market Services check
public static boolean isAnyServicesInstalled() {
return isGmsInstalled() || isFakeGmsInstalled();
}
public static void fixGapps() {
if (Build.VERSION.SDK_INT >= 26 && !isGmsInstalled()) {
NotificationManager notificationManager = (NotificationManager) AndroidUtils.getGlobalContext().getSystemService(Context.NOTIFICATION_SERVICE);
if (notificationManager.getNotificationChannel("audio_playback_channel") == null) {
notificationManager.createNotificationChannel(new NotificationChannel("audio_playback_channel", AndroidUtils.getResources().getString(R.string.audio_message_play_error), NotificationManager.IMPORTANCE_LOW));
}
}
} // Music channels fix
public static String replaceGMSPackage(String str) {
return needToSpoof ? str.replaceAll("com.google", "com.mgoogle") : str;
}
public static String getFirebaseInstanceIdReceiver() {
return getFirebaseInstanceIdReceiverClass().getName();
}
public static Class getFirebaseInstanceIdReceiverClass() {
return needToSpoof ? FirebaseInstanceIdReceiver2.class : FirebaseInstanceIdReceiver.class;
}
}
@@ -0,0 +1,92 @@
package ru.vtosters.hooks;
import android.util.Log;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import ru.vtosters.lite.utils.AndroidUtils;
import java.util.ArrayList;
public class GroupsCatalogInjector {
public static JSONObject injectIntoGetGroups(JSONObject jsonObject) {
var sections = jsonObject.optJSONObject("catalog").optJSONArray("sections");
if (sections == null) return jsonObject;
fixGroups(sections.optJSONObject(0));
return jsonObject;
}
public static void injectIntoCatalog(JSONObject jsonObject) {
var section = jsonObject.optJSONObject("section");
if (section == null) return; // early return if section is null
var blocks = section.optJSONArray("blocks");
if (blocks == null) return; // early return if blocks are null
var json = blocks.optJSONObject(1);
if (json == null) return; // early return if json is null
var data_type = json.optString("data_type");
if (!data_type.contains("groups")) return; // early return if data_type does not contain "groups"
fixGroups(section);
}
public static void fixGroups(JSONObject section) {
var blocks = section.optJSONArray("blocks");
if (blocks == null) return;
for (int i = 0; i < blocks.length(); i++) {
var currBlock = blocks.optJSONObject(i);
var badge = currBlock.optJSONObject("badge");
if (badge != null && badge.optString("type").equals("transparent")) {
addNewButton(currBlock, blocks.optJSONObject(i + 1));
break;
}
}
}
private static void addNewButton(JSONObject currBlock, JSONObject nextBlock) {
try {
var newButtons = new JSONArray();
var newButton = createNewButton(nextBlock);
newButtons.put(newButton);
currBlock.put("buttons", newButtons);
} catch (JSONException e) {
Log.d("CatalogButtonOpen", "Error: " + e);
}
}
private static JSONObject createNewButton(JSONObject nextBlock) throws JSONException {
var newButton = new JSONObject();
var type = new JSONObject();
type.put("type", "open_section");
newButton.put("action", type);
newButton.put("section_id", nextBlock.optString("id"));
newButton.put("title", AndroidUtils.getGlobalContext().getString(com.vtosters.lite.R.string.catalog_button_show_all));
newButton.put("ref_items_count", 30);
newButton.put("ref_layout_name", "list");
newButton.put("ref_data_type", "groups");
return newButton;
}
public static ArrayList<String> injectIntoJsonParser(JSONObject jsonObject, String str) {
JSONArray optJSONArray = jsonObject.optJSONArray(str);
if (optJSONArray != null) {
int length = optJSONArray.length();
ArrayList<String> arrayList = new ArrayList<>(length);
for (int i = 0; i < length; i++) {
String optString = optJSONArray.optString(i);
if (optString != null) {
arrayList.add(optString);
}
}
return arrayList;
}
return null;
}
}
@@ -0,0 +1,39 @@
package ru.vtosters.hooks;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import ru.vtosters.lite.utils.FriendsCatalogUtils;
import ru.vtosters.lite.utils.NewsFeedFiltersUtils;
import ru.vtosters.lite.utils.OnlineBypass;
import ru.vtosters.lite.utils.SuperAppUtils;
import java.io.IOException;
import java.text.ParseException;
public class JsonInjectors {
public static JSONObject menu(JSONObject orig) throws JSONException {
return SuperAppUtils.menu(orig);
}
public static JSONObject superapp(JSONObject json) throws JSONException {
return SuperAppUtils.superapp(json);
}
public static JSONObject setOnlineInfo(JSONObject json) throws JSONException {
return OnlineBypass.setOnlineInfo(json);
}
public static JSONArray setOnlineInfoUsers(JSONArray profiles) throws JSONException {
return OnlineBypass.setOnlineInfoUsers(profiles);
}
public static JSONArray newsfeedlist(JSONArray items) throws JSONException {
return NewsFeedFiltersUtils.newsfeedlist(items);
}
public static JSONObject friends(JSONObject json) throws JSONException, ParseException, IOException {
return FriendsCatalogUtils.inject(json);
}
}
@@ -0,0 +1,10 @@
package ru.vtosters.hooks;
import com.vk.dto.music.MusicTrack;
import ru.vtosters.lite.music.LastFMScrobbler;
public class LastFMHook {
public static void grabMusicTrack(MusicTrack musictrack) {
LastFMScrobbler.grabMusicTrack(musictrack);
}
}
@@ -1,11 +1,15 @@
package ru.vtosters.lite.hooks; package ru.vtosters.hooks;
import android.app.Activity; import android.app.Activity;
import android.content.Intent; import android.content.Intent;
import android.os.Build; import android.os.Build;
import b.h.g.k.VKProgressDialog; import b.h.g.k.VKProgressDialog;
import com.aefyr.tsg.g2.TelegramStickersService;
import com.vk.core.dialogs.alert.VkAlertDialog; import com.vk.core.dialogs.alert.VkAlertDialog;
import com.vtosters.lite.R; import com.vtosters.lite.R;
import ru.vtosters.hooks.other.Preferences;
import ru.vtosters.hooks.other.ThemesUtils;
import ru.vtosters.hooks.ui.SystemThemeChangerHook;
import ru.vtosters.lite.concurrent.VTExecutors; import ru.vtosters.lite.concurrent.VTExecutors;
import ru.vtosters.lite.downloaders.notifications.NotificationChannels; import ru.vtosters.lite.downloaders.notifications.NotificationChannels;
import ru.vtosters.lite.ssfs.UsersList; import ru.vtosters.lite.ssfs.UsersList;
@@ -14,19 +18,22 @@ import ru.vtosters.lite.ui.dialogs.DisableBattery;
import ru.vtosters.lite.ui.dialogs.InstallGMS; import ru.vtosters.lite.ui.dialogs.InstallGMS;
import ru.vtosters.lite.ui.dialogs.OTADialog; import ru.vtosters.lite.ui.dialogs.OTADialog;
import ru.vtosters.lite.ui.dialogs.Start; import ru.vtosters.lite.ui.dialogs.Start;
import ru.vtosters.lite.utils.*; import ru.vtosters.lite.utils.AndroidUtils;
import ru.vtosters.lite.utils.LifecycleUtils;
import ru.vtosters.lite.utils.NavigatorUtils;
import ru.vtosters.lite.utils.VTVerifications;
import static ru.vtosters.hooks.other.Preferences.checkupdates;
import static ru.vtosters.lite.ui.dialogs.ServerDialog.sendRequest; import static ru.vtosters.lite.ui.dialogs.ServerDialog.sendRequest;
import static ru.vtosters.lite.utils.CacheUtils.getInstance; import static ru.vtosters.lite.utils.CacheUtils.getInstance;
import static ru.vtosters.lite.utils.NewsFeedFiltersUtils.setupFilters; import static ru.vtosters.lite.utils.NewsFeedFiltersUtils.setupFilters;
import static ru.vtosters.lite.utils.Preferences.checkupdates;
import static ru.vtosters.lite.utils.ThemesUtils.setNeededTheme;
public class MainActivityInjector { public class MainActivityInjector {
public static void inject(Activity activity) { public static void inject(Activity activity) {
setNeededTheme(activity); SystemThemeChangerHook.themeOnStart(activity);
sendRequest(); sendRequest();
UsersList.getUsersList(); UsersList.getUsersList();
VTVerifications.load(activity);
if (checkupdates()) OTADialog.checkUpdates(activity); if (checkupdates()) OTADialog.checkUpdates(activity);
@@ -40,12 +47,15 @@ public class MainActivityInjector {
NotificationChannels.createChannels(); NotificationChannels.createChannels();
} }
if(Preferences.isNewBuild() && !ThemesUtils.isMonetTheme() && ThemesManager.canApplyCustomAccent()) { if (Preferences.isNewBuild()
&&!ThemesUtils.isMonetTheme()
&&ThemesManager.canApplyCustomAccent())
{
Preferences.updateBuildNumber(); Preferences.updateBuildNumber();
updateBinsAndTmpArchive(activity); updateBinsAndTmpArchive(activity);
} }
VTExecutors.getIoScheduler().a(DeletedMessagesHandler::reloadMessagesList); // ioScheduler VTExecutors.getIoScheduler().a(DeletedMessagesHook::reloadMessagesList); // ioScheduler
if (activity.getIntent().getAction() != null && Intent.ACTION_APPLICATION_PREFERENCES.equals(activity.getIntent().getAction())) { if (activity.getIntent().getAction() != null && Intent.ACTION_APPLICATION_PREFERENCES.equals(activity.getIntent().getAction())) {
NavigatorUtils.switchToSettings(activity); NavigatorUtils.switchToSettings(activity);
@@ -56,12 +66,14 @@ public class MainActivityInjector {
InstallGMS.alert(activity); InstallGMS.alert(activity);
DisableBattery.alert(activity); DisableBattery.alert(activity);
// VKIDProtection.alert(activity); // VKIDProtection.alert(activity);
//needs to show selected tgs pack count in settings after cold launch
TelegramStickersService.getInstance(activity);
} }
private static void updateBinsAndTmpArchive(Activity activity) { private static void updateBinsAndTmpArchive(Activity activity) {
final VKProgressDialog dialog = new VKProgressDialog(activity); final VKProgressDialog dialog = new VKProgressDialog(activity);
dialog.setMessage("Применение акцента"); dialog.setMessage(AndroidUtils.getString("applying_accent"));
dialog.show(); dialog.show();
VTExecutors.getIoExecutor().execute(() -> { VTExecutors.getIoExecutor().execute(() -> {
@@ -73,8 +85,8 @@ public class MainActivityInjector {
activity.runOnUiThread(() -> { activity.runOnUiThread(() -> {
dialog.cancel(); dialog.cancel();
new VkAlertDialog.Builder(activity) new VkAlertDialog.Builder(activity)
.setTitle("Ошикба") .setTitle(activity.getString(R.string.error))
.setMessage("Ошибка при применении акцента:\n" + e) .setMessage(AndroidUtils.getString("error_applying_accent") + ":\n" + e)
.setPositiveButton(R.string.ok, null) .setPositiveButton(R.string.ok, null)
.show(); .show();
}); });
@@ -0,0 +1,51 @@
package ru.vtosters.hooks;
import com.vk.im.engine.commands.messages.SetUserActivityCmd;
import com.vk.im.engine.models.dialogs.Dialog;
import ru.vtosters.lite.dialogs.helpers.DoNotReadDBHelper;
import ru.vtosters.lite.dialogs.helpers.DoNotTypeDBHelper;
import java.util.List;
public class MessagesActivityHook {
public static DoNotReadDBHelper mDoNotReadDBHelper = new DoNotReadDBHelper();
public static DoNotTypeDBHelper mDoNotTypeDBHelper = new DoNotTypeDBHelper();
public static boolean isDnrEnabledFor(int id) {
return mDoNotReadDBHelper.isEnabledForPeerId(id);
}
public static List<Integer> getDnrEnabled() {
return mDoNotReadDBHelper.get();
}
public static List<Integer> getDntEnabled() {
return mDoNotTypeDBHelper.get();
}
public static boolean isDntEnabledFor(int id) {
return mDoNotTypeDBHelper.isEnabledForPeerId(id);
}
public static boolean isDntEnabledFor(SetUserActivityCmd cmd) {
return isDntEnabledFor(cmd.b);
}
public static boolean isDnrEnabledFor(Dialog dialog) {
if (dialog == null) return false;
return isDnrEnabledFor(dialog.getId());
}
public static boolean isDntEnabledFor(Dialog dialog) {
if (dialog == null) return false;
return isDntEnabledFor(dialog.getId());
}
public static void hookDNR(int peerId) {
mDoNotReadDBHelper.setEnabledForPeerId(peerId, !mDoNotReadDBHelper.isEnabledForPeerId(peerId));
}
public static void hookDNT(int peerId) {
mDoNotTypeDBHelper.setEnabledForPeerId(peerId, !mDoNotTypeDBHelper.isEnabledForPeerId(peerId));
}
}
@@ -1,23 +1,22 @@
package ru.vtosters.lite.hooks; package ru.vtosters.hooks;
import static ru.vtosters.lite.ui.dialogs.MessageSettings.bombCount;
import static ru.vtosters.lite.ui.dialogs.MessageSettings.isSilentEnabled;
import static ru.vtosters.lite.utils.Preferences.autoalltranslate;
import static ru.vtosters.lite.utils.Preferences.autotranslate;
import static ru.vtosters.lite.utils.Preferences.savemsgsett;
import android.content.Context; import android.content.Context;
import android.text.TextUtils; import android.text.TextUtils;
import android.view.View; import android.view.View;
import com.vk.api.internal.MethodCall; import com.vk.api.internal.MethodCall;
import com.vk.im.ui.providers.audiomsg.ImAudioMsgPlayerProvider;
import com.vk.im.ui.providers.audiomsg.PlayerActionSources;
import com.vtosters.lite.im.ImEngineProvider;
import ru.vtosters.lite.translators.BaseTranslator;
import ru.vtosters.lite.ui.dialogs.MessageSettings;
import ru.vtosters.lite.utils.LifecycleUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import ru.vtosters.lite.translators.BaseTranslator; import static ru.vtosters.hooks.other.Preferences.*;
import ru.vtosters.lite.ui.dialogs.MessageSettings; import static ru.vtosters.lite.ui.dialogs.MessageSettings.bombCount;
import ru.vtosters.lite.utils.LifecycleUtils; import static ru.vtosters.lite.ui.dialogs.MessageSettings.isSilentEnabled;
public class MessagesHook { public class MessagesHook {
public static String injectOwnText(String oldText) { public static String injectOwnText(String oldText) {
@@ -46,7 +45,7 @@ public class MessagesHook {
var mentions = new ArrayList<String>(); var mentions = new ArrayList<String>();
while (matcher.find()) { while (matcher.find()) {
mentions.add(matcher.group()); mentions.add(matcher.group());
matcher.appendReplacement(textBuff, "vtl_mention" + mentionsCount + ""); matcher.appendReplacement(textBuff, "vtl_mention" + mentionsCount);
++mentionsCount; ++mentionsCount;
} }
matcher.appendTail(textBuff); matcher.appendTail(textBuff);
@@ -108,4 +107,10 @@ public class MessagesHook {
default -> 0; default -> 0;
}; };
} }
public static void reloadMessages() {
ImEngineProvider.b().a();
ImAudioMsgPlayerProvider.b().e(PlayerActionSources.a);
ImAudioMsgPlayerProvider.b().d(PlayerActionSources.a);
} // Delete and reload msg cache
} }
@@ -0,0 +1,16 @@
package ru.vtosters.hooks;
import ru.vtosters.lite.music.cache.CacheDatabaseDelegate;
import ru.vtosters.lite.music.cache.FileCacheImplementation;
import java.io.File;
public class MusicCacheFilesHook {
public static File getTrackFile(String trackId) {
return new File(FileCacheImplementation.getTrackFolder(trackId), "track.mp3");
}
public static boolean isTrackExist(String trackId) {
return CacheDatabaseDelegate.isCached(trackId);
}
}
@@ -0,0 +1,99 @@
package ru.vtosters.hooks;
import android.content.Context;
import android.os.PowerManager;
import androidx.recyclerview.widget.RecyclerView;
import com.vk.core.preference.Preference;
import com.vk.discover.DiscoverItemDecorator;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import static java.lang.Long.MAX_VALUE;
import static ru.vtosters.hooks.other.Preferences.*;
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
public class NewsfeedHook {
public static long getUpdateNewsfeed(boolean refresh_timeout) {
if (vkme()) {
return MAX_VALUE;
}
return switch (getString("newsupdate")) {
case "no_update" -> MAX_VALUE;
case "imd_update" -> 10000L;
default ->
Preference.b().getLong(refresh_timeout ? "refresh_timeout_top" : "refresh_timeout_recent", 600000L);
};
}
public static boolean samsungFixRem(RecyclerView recyclerView, DiscoverItemDecorator discoverItemDecorator) {
if (!recyclerView.isComputingLayout() && recyclerView.getScrollState() == RecyclerView.SCROLL_STATE_IDLE) {
recyclerView.removeItemDecoration(discoverItemDecorator);
return true;
}
return false;
}
public static boolean samsungFixAdd(RecyclerView recyclerView, DiscoverItemDecorator discoverItemDecorator) {
if (!recyclerView.isComputingLayout() && recyclerView.getScrollState() == RecyclerView.SCROLL_STATE_IDLE) {
recyclerView.addItemDecoration(discoverItemDecorator);
return true;
}
return false;
}
public static List hideElement(ArrayList list) {
if (!getBoolValue("whatsnew", true)) {
list.clear();
}
return list;
}
public static String[] feedParams() {
HashSet<String> params = new HashSet<>();
params.add("post");
params.add("photo");
params.add("photo_tag");
if (!friendsrecomm()) {
params.add("friends_recomm");
}
if (!ads()) {
params.add("app_widget");
params.add("promo_button");
}
if (!authorsrecomm()) {
params.add("authors_rec");
}
return params.toArray(new String[0]);
}
public static void adsParams(HashSet<String> hashSet) {
if (ads()) {
hashSet.add("ads_disabled");
} else {
hashSet.add("ads_app_slider");
hashSet.add("ads_site_slider");
}
hashSet.add("ads_app");
hashSet.add("ads_site");
hashSet.add("ads_post");
hashSet.add("ads_app_video");
hashSet.add("ads_post_pretty_cards");
hashSet.add("ads_post_snippet_video");
}
public static boolean isPowerSaveMode() {
var pw = (PowerManager) getGlobalContext().getSystemService(Context.POWER_SERVICE);
// return !getBoolValue("force_disable_psm", false) && pw.isPowerSaveMode();
return false;
}
}
@@ -1,27 +1,20 @@
package ru.vtosters.lite.hooks; package ru.vtosters.hooks;
import static ru.vtosters.lite.hooks.JsonInjectors.setOnlineInfo;
import static ru.vtosters.lite.hooks.JsonInjectors.setOnlineInfoUsers;
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.sendToast;
import static ru.vtosters.lite.utils.Preferences.dev;
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
import static ru.vtosters.lite.utils.Preferences.getPrefsFromFile;
import android.util.Log; import android.util.Log;
import com.vtosters.lite.R; import com.vtosters.lite.R;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import ru.vtosters.lite.utils.AndroidUtils;
import java.io.IOException; import java.io.IOException;
import java.text.ParseException; import java.text.ParseException;
import ru.vtosters.lite.utils.AndroidUtils; import static ru.vtosters.hooks.other.Preferences.*;
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.sendToast;
public class OnlineFormatterHook { public class OnlineFormatterHook {
private static String AppName; private static String AppName;
@@ -76,6 +69,7 @@ public class OnlineFormatterHook {
case 6614620 -> "Laney"; case 6614620 -> "Laney";
case 5632485 -> "SpaceVK"; case 5632485 -> "SpaceVK";
case 6287487 -> "vk.com"; case 6287487 -> "vk.com";
case 8202606 -> "VK Me Web";
case 4542624 -> "Black VK"; case 4542624 -> "Black VK";
case 3917910 -> "Miranda NG (bridge)"; case 3917910 -> "Miranda NG (bridge)";
case 8043814 -> "Quise"; case 8043814 -> "Quise";
@@ -122,7 +116,7 @@ public class OnlineFormatterHook {
} }
public static JSONObject onlineHook(JSONObject json) throws ParseException, IOException, JSONException { public static JSONObject onlineHook(JSONObject json) throws ParseException, IOException, JSONException {
if (getBoolValue("onlinefix", false)) setOnlineInfo(json); if (getBoolValue("onlinefix", false)) JsonInjectors.setOnlineInfo(json);
return json; return json;
} }
@@ -131,7 +125,7 @@ public class OnlineFormatterHook {
if (!getBoolValue("onlinefix", false)) return jsonArr; if (!getBoolValue("onlinefix", false)) return jsonArr;
try { try {
setOnlineInfoUsers(jsonArr); JsonInjectors.setOnlineInfoUsers(jsonArr);
} catch (Exception e) { } catch (Exception e) {
Log.e("onlineHookProfiles", e.getMessage()); Log.e("onlineHookProfiles", e.getMessage());
} }
@@ -139,25 +133,27 @@ public class OnlineFormatterHook {
return jsonArr; return jsonArr;
} }
public static JSONObject onlineHookProfiles(JSONObject json) throws ParseException, IOException, JSONException { public static JSONObject onlineHookProfiles(JSONObject json) {
if (!getBoolValue("onlinefix", false)) return json; if (!getBoolValue("onlinefix", false)) return json;
try { try {
setOnlineInfoUsers(json.optJSONArray("profiles")); JsonInjectors.setOnlineInfoUsers(json.optJSONArray("profiles"));
} catch (Exception e) { } catch (Exception e) {
Log.e("onlineHookProfiles", e.getMessage()); Log.e("onlineHookProfiles", e.getMessage());
} }
return json; return json;
} }
public static JSONObject onlineHookItems(JSONObject json) throws ParseException, IOException, JSONException { public static JSONObject onlineHookItems(JSONObject json) {
if (!getBoolValue("onlinefix", false)) return json; if (!getBoolValue("onlinefix", false)) return json;
try { try {
setOnlineInfoUsers(json.optJSONArray("items")); JsonInjectors.setOnlineInfoUsers(json.optJSONArray("items"));
} catch (Exception e) { } catch (Exception e) {
Log.e("onlineHookItems", e.getMessage()); Log.e("onlineHookItems", e.getMessage());
} }
return json; return json;
} }
@@ -165,22 +161,23 @@ public class OnlineFormatterHook {
if (!getBoolValue("onlinefix", false)) return json; if (!getBoolValue("onlinefix", false)) return json;
try { try {
setOnlineInfoUsers(json.optJSONObject("read_requests").optJSONArray("items")); JsonInjectors.setOnlineInfoUsers(json.optJSONObject("read_requests").optJSONArray("items"));
} catch (Exception e) { } catch (Exception e) {
Log.e("onlineHookItems", e.getMessage()); Log.e("onlineHookItems", e.getMessage());
} }
try { try {
setOnlineInfoUsers(json.optJSONObject("recommendations").optJSONArray("items")); JsonInjectors.setOnlineInfoUsers(json.optJSONObject("recommendations").optJSONArray("items"));
} catch (Exception e) { } catch (Exception e) {
Log.e("onlineHookItems", e.getMessage()); Log.e("onlineHookItems", e.getMessage());
} }
try { try {
setOnlineInfoUsers(json.optJSONArray("profiles")); JsonInjectors.setOnlineInfoUsers(json.optJSONArray("profiles"));
} catch (Exception e) { } catch (Exception e) {
Log.e("onlineHookItems", e.getMessage()); Log.e("onlineHookItems", e.getMessage());
} }
return json; return json;
} }
} }

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