Repository: JingMatrix/LSPosed
Branch: master
Commit: 8db19217d300
Files: 560
Total size: 2.5 MB
Directory structure:
gitextract_f3szflt5/
├── .gitattributes
├── .github/
│ ├── ISSUE_TEMPLATE/
│ │ ├── bug_report.yml
│ │ ├── config.yml
│ │ └── feature_request.yml
│ ├── dependabot.yml
│ └── workflows/
│ ├── core.yml
│ └── crowdin.yml
├── .gitignore
├── .gitmodules
├── LICENSE
├── README.md
├── app/
│ ├── .gitignore
│ ├── build.gradle.kts
│ ├── proguard-rules.pro
│ └── src/
│ └── main/
│ ├── AndroidManifest.xml
│ ├── assets/
│ │ └── webview/
│ │ ├── colors_dark.css
│ │ ├── colors_light.css
│ │ ├── markdown.css
│ │ ├── syntax.css
│ │ ├── syntax_dark.css
│ │ ├── template.html
│ │ └── template_dark.html
│ ├── java/
│ │ ├── com/
│ │ │ └── google/
│ │ │ └── android/
│ │ │ └── material/
│ │ │ ├── appbar/
│ │ │ │ └── SubtitleCollapsingToolbarLayout.java
│ │ │ └── internal/
│ │ │ └── SubtitleCollapsingTextHelper.java
│ │ └── org/
│ │ └── lsposed/
│ │ └── manager/
│ │ ├── App.java
│ │ ├── ConfigManager.java
│ │ ├── Constants.java
│ │ ├── adapters/
│ │ │ ├── AppHelper.java
│ │ │ └── ScopeAdapter.java
│ │ ├── receivers/
│ │ │ └── LSPManagerServiceHolder.java
│ │ ├── repo/
│ │ │ ├── RepoLoader.java
│ │ │ └── model/
│ │ │ ├── Collaborator.java
│ │ │ ├── OnlineModule.java
│ │ │ ├── Release.java
│ │ │ └── ReleaseAsset.java
│ │ ├── ui/
│ │ │ ├── activity/
│ │ │ │ ├── MainActivity.java
│ │ │ │ └── base/
│ │ │ │ └── BaseActivity.java
│ │ │ ├── dialog/
│ │ │ │ ├── BlurBehindDialogBuilder.java
│ │ │ │ ├── FlashDialogBuilder.java
│ │ │ │ └── WelcomeDialog.java
│ │ │ ├── fragment/
│ │ │ │ ├── AppListFragment.java
│ │ │ │ ├── BaseFragment.java
│ │ │ │ ├── CompileDialogFragment.java
│ │ │ │ ├── HomeFragment.java
│ │ │ │ ├── LogsFragment.java
│ │ │ │ ├── ModulesFragment.java
│ │ │ │ ├── RecyclerViewDialogFragment.java
│ │ │ │ ├── RepoFragment.java
│ │ │ │ ├── RepoItemFragment.java
│ │ │ │ └── SettingsFragment.java
│ │ │ └── widget/
│ │ │ ├── EmptyStateRecyclerView.java
│ │ │ ├── ExpandableTextView.java
│ │ │ ├── LinkifyTextView.java
│ │ │ ├── ScrollWebView.java
│ │ │ └── StatefulRecyclerView.java
│ │ └── util/
│ │ ├── AccessibilityUtils.java
│ │ ├── AppIconModelLoader.java
│ │ ├── AppModule.java
│ │ ├── BackupUtils.java
│ │ ├── CloudflareDNS.java
│ │ ├── EmptyAccessibilityDelegate.java
│ │ ├── ModuleUtil.java
│ │ ├── NavUtil.java
│ │ ├── NoSniFactory.java
│ │ ├── ShortcutUtil.java
│ │ ├── SimpleStatefulAdaptor.java
│ │ ├── ThemeUtil.java
│ │ ├── UpdateUtil.java
│ │ └── chrome/
│ │ ├── CustomTabsURLSpan.java
│ │ └── LinkTransformationMethod.java
│ └── res/
│ ├── anim/
│ │ ├── fragment_enter.xml
│ │ ├── fragment_enter_pop.xml
│ │ ├── fragment_exit.xml
│ │ └── fragment_exit_pop.xml
│ ├── drawable/
│ │ ├── ic_assignment_checkable.xml
│ │ ├── ic_attach_file.xml
│ │ ├── ic_baseline_add_24.xml
│ │ ├── ic_baseline_arrow_back_24.xml
│ │ ├── ic_baseline_assignment_24.xml
│ │ ├── ic_baseline_chat_24.xml
│ │ ├── ic_baseline_extension_24.xml
│ │ ├── ic_baseline_get_app_24.xml
│ │ ├── ic_baseline_home_24.xml
│ │ ├── ic_baseline_info_24.xml
│ │ ├── ic_baseline_search_24.xml
│ │ ├── ic_baseline_settings_24.xml
│ │ ├── ic_baseline_settings_backup_restore_24.xml
│ │ ├── ic_extension_checkable.xml
│ │ ├── ic_get_app_checkable.xml
│ │ ├── ic_home_checkable.xml
│ │ ├── ic_keyboard_arrow_down.xml
│ │ ├── ic_launcher.xml
│ │ ├── ic_launcher_foreground.xml
│ │ ├── ic_launcher_round.xml
│ │ ├── ic_open_in_browser.xml
│ │ ├── ic_outline_android_24.xml
│ │ ├── ic_outline_app_shortcut_24.xml
│ │ ├── ic_outline_assignment_24.xml
│ │ ├── ic_outline_dark_mode_24.xml
│ │ ├── ic_outline_dns_24.xml
│ │ ├── ic_outline_extension_24.xml
│ │ ├── ic_outline_format_color_fill_24.xml
│ │ ├── ic_outline_get_app_24.xml
│ │ ├── ic_outline_groups_24.xml
│ │ ├── ic_outline_home_24.xml
│ │ ├── ic_outline_invert_colors_24.xml
│ │ ├── ic_outline_language_24.xml
│ │ ├── ic_outline_merge_type_24.xml
│ │ ├── ic_outline_palette_24.xml
│ │ ├── ic_outline_restore_24.xml
│ │ ├── ic_outline_settings_24.xml
│ │ ├── ic_outline_shield_24.xml
│ │ ├── ic_outline_speaker_notes_24.xml
│ │ ├── ic_outline_translate_24.xml
│ │ ├── ic_round_bug_report_24.xml
│ │ ├── ic_round_check_circle_24.xml
│ │ ├── ic_round_error_outline_24.xml
│ │ ├── ic_round_settings_24.xml
│ │ ├── ic_round_update_24.xml
│ │ ├── ic_round_warning_24.xml
│ │ ├── ic_save.xml
│ │ ├── ic_settings_checkable.xml
│ │ ├── shortcut_ic_logs.xml
│ │ ├── shortcut_ic_modules.xml
│ │ ├── shortcut_ic_repo.xml
│ │ ├── shortcut_ic_settings.xml
│ │ └── simple_menu_background.xml
│ ├── layout/
│ │ ├── activity_main.xml
│ │ ├── dialog_about.xml
│ │ ├── dialog_item.xml
│ │ ├── dialog_title.xml
│ │ ├── fragment_app_list.xml
│ │ ├── fragment_compile_dialog.xml
│ │ ├── fragment_home.xml
│ │ ├── fragment_pager.xml
│ │ ├── fragment_repo.xml
│ │ ├── fragment_settings.xml
│ │ ├── item_log_textview.xml
│ │ ├── item_master_switch.xml
│ │ ├── item_module.xml
│ │ ├── item_onlinemodule.xml
│ │ ├── item_repo_loadmore.xml
│ │ ├── item_repo_readme.xml
│ │ ├── item_repo_recyclerview.xml
│ │ ├── item_repo_release.xml
│ │ ├── item_repo_title_description.xml
│ │ ├── preference_recyclerview.xml
│ │ ├── scrollable_dialog.xml
│ │ └── swiperefresh_recyclerview.xml
│ ├── layout-sw600dp/
│ │ └── activity_main.xml
│ ├── menu/
│ │ ├── context_menu_modules.xml
│ │ ├── menu_app_item.xml
│ │ ├── menu_app_list.xml
│ │ ├── menu_home.xml
│ │ ├── menu_logs.xml
│ │ ├── menu_modules.xml
│ │ ├── menu_repo.xml
│ │ ├── menu_repo_item.xml
│ │ └── navigation_menu.xml
│ ├── menu-sw600dp/
│ │ └── navigation_menu.xml
│ ├── navigation/
│ │ ├── main_nav.xml
│ │ ├── modules_nav.xml
│ │ └── repo_nav.xml
│ ├── values/
│ │ ├── arrays.xml
│ │ ├── attrs.xml
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── integer.xml
│ │ ├── settings.xml
│ │ ├── strings.xml
│ │ ├── strings_untranslatable.xml
│ │ ├── styles.xml
│ │ ├── themes.xml
│ │ ├── themes_custom.xml
│ │ ├── themes_overlay.xml
│ │ └── themes_override.xml
│ ├── values-af/
│ │ └── strings.xml
│ ├── values-ar/
│ │ └── strings.xml
│ ├── values-bg/
│ │ └── strings.xml
│ ├── values-bn/
│ │ └── strings.xml
│ ├── values-ca/
│ │ └── strings.xml
│ ├── values-cs/
│ │ └── strings.xml
│ ├── values-da/
│ │ └── strings.xml
│ ├── values-de/
│ │ └── strings.xml
│ ├── values-el/
│ │ └── strings.xml
│ ├── values-es/
│ │ └── strings.xml
│ ├── values-et/
│ │ └── strings.xml
│ ├── values-fa/
│ │ └── strings.xml
│ ├── values-fi/
│ │ └── strings.xml
│ ├── values-fr/
│ │ └── strings.xml
│ ├── values-hi/
│ │ └── strings.xml
│ ├── values-hr/
│ │ └── strings.xml
│ ├── values-hu/
│ │ └── strings.xml
│ ├── values-in/
│ │ └── strings.xml
│ ├── values-it/
│ │ └── strings.xml
│ ├── values-iw/
│ │ └── strings.xml
│ ├── values-ja/
│ │ └── strings.xml
│ ├── values-ko/
│ │ └── strings.xml
│ ├── values-ku/
│ │ └── strings.xml
│ ├── values-lt/
│ │ └── strings.xml
│ ├── values-night/
│ │ ├── colors.xml
│ │ └── styles.xml
│ ├── values-night-v31/
│ │ └── colors.xml
│ ├── values-nl/
│ │ └── strings.xml
│ ├── values-no/
│ │ └── strings.xml
│ ├── values-pl/
│ │ └── strings.xml
│ ├── values-pt/
│ │ └── strings.xml
│ ├── values-pt-rBR/
│ │ └── strings.xml
│ ├── values-ro/
│ │ └── strings.xml
│ ├── values-ru/
│ │ └── strings.xml
│ ├── values-si/
│ │ └── strings.xml
│ ├── values-sk/
│ │ └── strings.xml
│ ├── values-sv/
│ │ └── strings.xml
│ ├── values-sw600dp/
│ │ └── integer.xml
│ ├── values-th/
│ │ └── strings.xml
│ ├── values-tr/
│ │ └── strings.xml
│ ├── values-uk/
│ │ └── strings.xml
│ ├── values-ur/
│ │ └── strings.xml
│ ├── values-v28/
│ │ ├── dimens.xml
│ │ └── themes.xml
│ ├── values-v29/
│ │ └── settings.xml
│ ├── values-v30/
│ │ └── themes.xml
│ ├── values-v31/
│ │ └── colors.xml
│ ├── values-vi/
│ │ └── strings.xml
│ ├── values-zh-rCN/
│ │ └── strings.xml
│ ├── values-zh-rHK/
│ │ └── strings.xml
│ ├── values-zh-rTW/
│ │ └── strings.xml
│ └── xml/
│ ├── prefs.xml
│ └── shortcuts.xml
├── build.gradle.kts
├── core/
│ ├── .gitignore
│ ├── build.gradle.kts
│ ├── proguard-rules.pro
│ └── src/
│ └── main/
│ └── java/
│ ├── android/
│ │ ├── app/
│ │ │ └── AndroidAppHelper.java
│ │ └── content/
│ │ └── res/
│ │ ├── XModuleResources.java
│ │ ├── XResForwarder.java
│ │ └── XResources.java
│ ├── de/
│ │ └── robv/
│ │ └── android/
│ │ └── xposed/
│ │ ├── IXposedHookCmdInit.java
│ │ ├── IXposedHookInitPackageResources.java
│ │ ├── IXposedHookLoadPackage.java
│ │ ├── IXposedHookZygoteInit.java
│ │ ├── IXposedMod.java
│ │ ├── SELinuxHelper.java
│ │ ├── XC_MethodHook.java
│ │ ├── XC_MethodReplacement.java
│ │ ├── XSharedPreferences.java
│ │ ├── XposedBridge.java
│ │ ├── XposedHelpers.java
│ │ ├── XposedInit.java
│ │ ├── callbacks/
│ │ │ ├── IXUnhook.java
│ │ │ ├── XC_InitPackageResources.java
│ │ │ ├── XC_LayoutInflated.java
│ │ │ ├── XC_LoadPackage.java
│ │ │ └── XCallback.java
│ │ └── services/
│ │ ├── BaseService.java
│ │ ├── DirectAccessService.java
│ │ └── FileResult.java
│ └── org/
│ └── lsposed/
│ └── lspd/
│ ├── core/
│ │ ├── ApplicationServiceClient.java
│ │ └── Startup.java
│ ├── deopt/
│ │ ├── InlinedMethodCallers.java
│ │ └── PrebuiltMethodsDeopter.java
│ ├── hooker/
│ │ ├── AttachHooker.java
│ │ ├── CrashDumpHooker.java
│ │ ├── HandleSystemServerProcessHooker.java
│ │ ├── LoadedApkCreateCLHooker.java
│ │ ├── LoadedApkCtorHooker.java
│ │ ├── OpenDexFileHooker.java
│ │ └── StartBootstrapServicesHooker.java
│ ├── impl/
│ │ ├── LSPosedBridge.java
│ │ ├── LSPosedContext.java
│ │ ├── LSPosedHelper.java
│ │ ├── LSPosedHookCallback.java
│ │ └── LSPosedRemotePreferences.java
│ └── util/
│ ├── ClassPathURLStreamHandler.java
│ ├── Hookers.java
│ ├── LspModuleClassLoader.java
│ └── MetaDataReader.java
├── crowdin.yml
├── daemon/
│ ├── .gitignore
│ ├── build.gradle.kts
│ ├── proguard-rules.pro
│ └── src/
│ └── main/
│ ├── AndroidManifest.xml
│ ├── java/
│ │ └── org/
│ │ └── lsposed/
│ │ └── lspd/
│ │ ├── Main.java
│ │ ├── service/
│ │ │ ├── ActivityManagerService.java
│ │ │ ├── BridgeService.java
│ │ │ ├── ConfigFileManager.java
│ │ │ ├── ConfigManager.java
│ │ │ ├── Dex2OatService.java
│ │ │ ├── LSPApplicationService.java
│ │ │ ├── LSPInjectedModuleService.java
│ │ │ ├── LSPManagerService.java
│ │ │ ├── LSPModuleService.java
│ │ │ ├── LSPNotificationManager.java
│ │ │ ├── LSPSystemServerService.java
│ │ │ ├── LSPosedService.java
│ │ │ ├── LogcatService.java
│ │ │ ├── ObfuscationManager.java
│ │ │ ├── PackageService.java
│ │ │ ├── PowerService.java
│ │ │ ├── ServiceManager.java
│ │ │ └── UserService.java
│ │ └── util/
│ │ ├── FakeContext.java
│ │ └── InstallerVerifier.java
│ ├── jni/
│ │ ├── CMakeLists.txt
│ │ ├── dex2oat.cpp
│ │ ├── logcat.cpp
│ │ ├── logcat.h
│ │ ├── logging.h
│ │ ├── obfuscation.cpp
│ │ └── obfuscation.h
│ └── res/
│ ├── drawable/
│ │ ├── ic_baseline_block_24.xml
│ │ ├── ic_baseline_check_24.xml
│ │ ├── ic_baseline_close_24.xml
│ │ └── ic_notification.xml
│ ├── values/
│ │ └── strings.xml
│ ├── values-af/
│ │ └── strings.xml
│ ├── values-ar/
│ │ └── strings.xml
│ ├── values-bg/
│ │ └── strings.xml
│ ├── values-bn/
│ │ └── strings.xml
│ ├── values-ca/
│ │ └── strings.xml
│ ├── values-cs/
│ │ └── strings.xml
│ ├── values-da/
│ │ └── strings.xml
│ ├── values-de/
│ │ └── strings.xml
│ ├── values-el/
│ │ └── strings.xml
│ ├── values-es/
│ │ └── strings.xml
│ ├── values-et/
│ │ └── strings.xml
│ ├── values-fa/
│ │ └── strings.xml
│ ├── values-fi/
│ │ └── strings.xml
│ ├── values-fr/
│ │ └── strings.xml
│ ├── values-hi/
│ │ └── strings.xml
│ ├── values-hr/
│ │ └── strings.xml
│ ├── values-hu/
│ │ └── strings.xml
│ ├── values-in/
│ │ └── strings.xml
│ ├── values-it/
│ │ └── strings.xml
│ ├── values-iw/
│ │ └── strings.xml
│ ├── values-ja/
│ │ └── strings.xml
│ ├── values-ko/
│ │ └── strings.xml
│ ├── values-ku/
│ │ └── strings.xml
│ ├── values-lt/
│ │ └── strings.xml
│ ├── values-nl/
│ │ └── strings.xml
│ ├── values-no/
│ │ └── strings.xml
│ ├── values-pl/
│ │ └── strings.xml
│ ├── values-pt/
│ │ └── strings.xml
│ ├── values-pt-rBR/
│ │ └── strings.xml
│ ├── values-ro/
│ │ └── strings.xml
│ ├── values-ru/
│ │ └── strings.xml
│ ├── values-si/
│ │ └── strings.xml
│ ├── values-sk/
│ │ └── strings.xml
│ ├── values-sv/
│ │ └── strings.xml
│ ├── values-th/
│ │ └── strings.xml
│ ├── values-tr/
│ │ └── strings.xml
│ ├── values-uk/
│ │ └── strings.xml
│ ├── values-ur/
│ │ └── strings.xml
│ ├── values-vi/
│ │ └── strings.xml
│ ├── values-zh-rCN/
│ │ └── strings.xml
│ ├── values-zh-rHK/
│ │ └── strings.xml
│ └── values-zh-rTW/
│ └── strings.xml
├── dex2oat/
│ ├── .gitignore
│ ├── README.md
│ ├── build.gradle.kts
│ └── src/
│ └── main/
│ └── cpp/
│ ├── CMakeLists.txt
│ ├── dex2oat.cpp
│ ├── include/
│ │ ├── base_macros.h
│ │ ├── logging.h
│ │ ├── macros.h
│ │ └── oat.h
│ └── oat_hook.cpp
├── external/
│ ├── CMakeLists.txt
│ ├── README.md
│ ├── apache/
│ │ ├── .gitignore
│ │ ├── build.gradle.kts
│ │ └── local/
│ │ └── MemberUtilsX.java
│ └── axml/
│ └── build.gradle.kts
├── gradle/
│ ├── libs.versions.toml
│ └── wrapper/
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradle.properties
├── gradlew
├── gradlew.bat
├── hiddenapi/
│ ├── bridge/
│ │ ├── .gitignore
│ │ ├── build.gradle.kts
│ │ └── src/
│ │ └── main/
│ │ └── java/
│ │ └── hidden/
│ │ ├── ByteBufferDexClassLoader.java
│ │ └── HiddenApiBridge.java
│ └── stubs/
│ ├── .gitignore
│ ├── build.gradle.kts
│ └── src/
│ └── main/
│ └── java/
│ ├── android/
│ │ ├── annotation/
│ │ │ ├── NonNull.java
│ │ │ └── Nullable.java
│ │ ├── app/
│ │ │ ├── ActivityManager.java
│ │ │ ├── ActivityThread.java
│ │ │ ├── Application.java
│ │ │ ├── ContentProviderHolder.java
│ │ │ ├── ContextImpl.java
│ │ │ ├── IActivityController.java
│ │ │ ├── IActivityManager.java
│ │ │ ├── IApplicationThread.java
│ │ │ ├── INotificationManager.java
│ │ │ ├── IServiceConnection.java
│ │ │ ├── IUidObserver.java
│ │ │ ├── LoadedApk.java
│ │ │ ├── Notification.java
│ │ │ ├── NotificationChannel.java
│ │ │ ├── ProfilerInfo.java
│ │ │ └── ResourcesManager.java
│ │ ├── content/
│ │ │ ├── AttributionSource.java
│ │ │ ├── BroadcastReceiver.java
│ │ │ ├── ComponentName.java
│ │ │ ├── Context.java
│ │ │ ├── IContentProvider.java
│ │ │ ├── IIntentReceiver.java
│ │ │ ├── IIntentSender.java
│ │ │ ├── Intent.java
│ │ │ ├── IntentFilter.java
│ │ │ ├── IntentSender.java
│ │ │ ├── pm/
│ │ │ │ ├── ApplicationInfo.java
│ │ │ │ ├── BaseParceledListSlice.java
│ │ │ │ ├── IPackageInstaller.java
│ │ │ │ ├── IPackageManager.java
│ │ │ │ ├── PackageInfo.java
│ │ │ │ ├── PackageInstaller.java
│ │ │ │ ├── PackageManager.java
│ │ │ │ ├── PackageParser.java
│ │ │ │ ├── ParceledListSlice.java
│ │ │ │ ├── ResolveInfo.java
│ │ │ │ ├── UserInfo.java
│ │ │ │ └── VersionedPackage.java
│ │ │ └── res/
│ │ │ ├── AssetManager.java
│ │ │ ├── CompatibilityInfo.java
│ │ │ ├── Configuration.java
│ │ │ ├── Resources.java
│ │ │ ├── ResourcesImpl.java
│ │ │ ├── ResourcesKey.java
│ │ │ └── TypedArray.java
│ │ ├── ddm/
│ │ │ └── DdmHandleAppName.java
│ │ ├── graphics/
│ │ │ ├── Movie.java
│ │ │ └── drawable/
│ │ │ └── Drawable.java
│ │ ├── os/
│ │ │ ├── Binder.java
│ │ │ ├── Build.java
│ │ │ ├── Bundle.java
│ │ │ ├── Environment.java
│ │ │ ├── Handler.java
│ │ │ ├── IBinder.java
│ │ │ ├── IInterface.java
│ │ │ ├── IPowerManager.java
│ │ │ ├── IServiceCallback.java
│ │ │ ├── IServiceManager.java
│ │ │ ├── IUserManager.java
│ │ │ ├── Parcel.java
│ │ │ ├── Parcelable.java
│ │ │ ├── PersistableBundle.java
│ │ │ ├── RemoteException.java
│ │ │ ├── ResultReceiver.java
│ │ │ ├── SELinux.java
│ │ │ ├── ServiceManager.java
│ │ │ ├── ShellCallback.java
│ │ │ ├── ShellCommand.java
│ │ │ ├── SystemProperties.java
│ │ │ ├── UserHandle.java
│ │ │ └── UserManager.java
│ │ ├── permission/
│ │ │ └── IPermissionManager.java
│ │ ├── system/
│ │ │ ├── ErrnoException.java
│ │ │ ├── Int32Ref.java
│ │ │ └── Os.java
│ │ ├── util/
│ │ │ ├── DisplayMetrics.java
│ │ │ ├── MutableInt.java
│ │ │ └── TypedValue.java
│ │ ├── view/
│ │ │ └── IWindowManager.java
│ │ └── webkit/
│ │ ├── WebViewDelegate.java
│ │ ├── WebViewFactory.java
│ │ └── WebViewFactoryProvider.java
│ ├── androidx/
│ │ └── annotation/
│ │ ├── IntRange.java
│ │ └── RequiresApi.java
│ ├── com/
│ │ └── android/
│ │ ├── internal/
│ │ │ ├── os/
│ │ │ │ ├── BinderInternal.java
│ │ │ │ └── ZygoteInit.java
│ │ │ └── util/
│ │ │ └── XmlUtils.java
│ │ └── server/
│ │ ├── LocalServices.java
│ │ ├── SystemService.java
│ │ ├── SystemServiceManager.java
│ │ └── am/
│ │ ├── ActivityManagerService.java
│ │ └── ProcessRecord.java
│ ├── dalvik/
│ │ └── system/
│ │ ├── BaseDexClassLoader.java
│ │ └── VMRuntime.java
│ ├── org/
│ │ └── xmlpull/
│ │ └── v1/
│ │ └── XmlPullParserException.java
│ ├── sun/
│ │ ├── misc/
│ │ │ └── CompoundEnumeration.java
│ │ └── net/
│ │ └── www/
│ │ ├── ParseUtil.java
│ │ └── protocol/
│ │ └── jar/
│ │ └── Handler.java
│ └── xposed/
│ └── dummy/
│ ├── XResourcesSuperClass.java
│ └── XTypedArraySuperClass.java
├── magisk-loader/
│ └── update/
│ ├── changelog.md
│ └── zygisk.json
├── native/
│ ├── CMakeLists.txt
│ ├── README.md
│ ├── include/
│ │ ├── common/
│ │ │ ├── config.h
│ │ │ └── logging.h
│ │ ├── core/
│ │ │ ├── config_bridge.h
│ │ │ ├── context.h
│ │ │ └── native_api.h
│ │ ├── elf/
│ │ │ ├── elf_image.h
│ │ │ └── symbol_cache.h
│ │ ├── framework/
│ │ │ └── android_types.h
│ │ └── jni/
│ │ ├── jni_bridge.h
│ │ └── jni_hooks.h
│ └── src/
│ ├── core/
│ │ ├── context.cpp
│ │ └── native_api.cpp
│ ├── elf/
│ │ ├── elf_image.cpp
│ │ └── symbol_cache.cpp
│ └── jni/
│ ├── dex_parser_bridge.cpp
│ ├── hook_bridge.cpp
│ ├── native_api_bridge.cpp
│ └── resources_hook.cpp
├── services/
│ ├── daemon-service/
│ │ ├── .gitignore
│ │ ├── build.gradle.kts
│ │ └── src/
│ │ └── main/
│ │ ├── AndroidManifest.xml
│ │ ├── aidl/
│ │ │ └── org/
│ │ │ └── lsposed/
│ │ │ └── lspd/
│ │ │ ├── models/
│ │ │ │ ├── Module.aidl
│ │ │ │ └── PreLoadedApk.aidl
│ │ │ └── service/
│ │ │ ├── ILSPApplicationService.aidl
│ │ │ ├── ILSPInjectedModuleService.aidl
│ │ │ ├── ILSPSystemServerService.aidl
│ │ │ ├── ILSPosedService.aidl
│ │ │ └── IRemotePreferenceCallback.aidl
│ │ └── java/
│ │ └── org/
│ │ └── lsposed/
│ │ └── lspd/
│ │ └── util/
│ │ └── Utils.java
│ └── manager-service/
│ ├── .gitignore
│ ├── build.gradle.kts
│ └── src/
│ └── main/
│ ├── AndroidManifest.xml
│ └── aidl/
│ └── org/
│ └── lsposed/
│ └── lspd/
│ ├── ILSPManagerService.aidl
│ └── models/
│ ├── Application.aidl
│ └── UserInfo.aidl
├── settings.gradle.kts
├── xposed/
│ ├── README.md
│ ├── build.gradle.kts
│ └── src/
│ └── main/
│ └── kotlin/
│ └── org/
│ └── matrix/
│ └── vector/
│ ├── impl/
│ │ └── utils/
│ │ └── VectorDexParser.kt
│ └── nativebridge/
│ ├── DexParserBridge.kt
│ ├── HookBridge.kt
│ ├── NativeAPI.kt
│ └── ResourcesHook.kt
└── zygisk/
├── .gitignore
├── README.md
├── build.gradle.kts
├── module/
│ ├── META-INF/
│ │ └── com/
│ │ └── google/
│ │ └── android/
│ │ ├── update-binary
│ │ └── updater-script
│ ├── action.sh
│ ├── customize.sh
│ ├── daemon
│ ├── module.prop
│ ├── sepolicy.rule
│ ├── service.sh
│ ├── system.prop
│ └── uninstall.sh
├── proguard-rules.pro
├── src/
│ └── main/
│ ├── AndroidManifest.xml
│ ├── cpp/
│ │ ├── CMakeLists.txt
│ │ ├── include/
│ │ │ ├── ipc_bridge.h
│ │ │ └── zygisk.hpp
│ │ ├── ipc_bridge.cpp
│ │ └── module.cpp
│ └── kotlin/
│ └── org/
│ └── matrix/
│ └── vector/
│ ├── ParasiticManagerHooker.kt
│ ├── ParasiticManagerSystemHooker.kt
│ ├── core/
│ │ └── Main.kt
│ └── service/
│ ├── BridgeService.kt
│ └── ParcelUtils.kt
└── zygisk.json
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitattributes
================================================
# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto eol=lf
# Declare files that will always have CRLF line endings on checkout.
*.cmd text eol=crlf
*.bat text eol=crlf
# Denote all files that are truly binary and should not be modified.
*.so binary
*.dex binary
*.jar binary
*.png binary
================================================
FILE: .github/ISSUE_TEMPLATE/bug_report.yml
================================================
name: Bug report/反馈 Bug
description: Report errors or unexpected behavior./反馈错误或异常行为。
labels: [bug]
body:
- type: markdown
attributes:
value: |
Thanks for reporting issues of LSPosed!
To make it easier for us to help you, please read all pinned issues and provide the following details.
感谢给 LSPosed 汇报问题!
为了使我们更好地帮助你,请务必阅读所有已置顶的 Issues 并提供以下细节。
为了防止重复汇报,标题请务必使用英文。
- type: textarea
attributes:
label: Steps to reproduce/复现步骤
placeholder: |
1.
2.
3.
validations:
required: true
- type: textarea
attributes:
label: Expected behaviour/预期行为
placeholder: Tell us what should happen/正常情况下应该发生什么
validations:
required: true
- type: textarea
attributes:
label: Actual behaviour/实际行为
placeholder: Tell us what happens instead/实际上发生了什么
validations:
required: true
- type: textarea
attributes:
label: Xposed Module List/Xposed 模块列表
render: shell
validations:
required: true
- type: input
attributes:
label: Root implementation/Root 方案
description: Common root implementations include Magisk, KernelSU or APatch. Please specify your current implementation with exact version./常见的 Root 方案有 Magisk,KernelSU 以及 APatch。请注明您当前的方案以及详细版本。
validations:
required: true
- type: textarea
attributes:
label: System Module List/系统模块列表
description: Modules installed through your root implementation manager/通过您 Root 方案的管理器所安装的模块
render: shell
validations:
required: true
- type: input
attributes:
label: LSPosed version/LSPosed 版本
description: Don't use 'latest'. Specify actual version with 4 digits, otherwise your issue will be closed./不要填用“最新版”。给出四位版本号,不然 issue 会被关闭。
validations:
required: true
- type: input
attributes:
label: Android version/Android 版本
description: If you are running a custom OS, please also note it./如果使用了非官方的操作系统,请一并注明。
validations:
required: true
- type: checkboxes
id: latest
attributes:
label: Version requirement/版本要求
options:
- label: I am using the latest debug build from [GitHub Actions](https://github.com/JingMatrix/LSPosed/actions?query=branch%3Amaster)./我正在使用 [GitHub Actions](https://github.com/JingMatrix/LSPosed/actions?query=branch%3Amaster) 中最新的调试版本。
required: true
- type: textarea
attributes:
label: Logs/日志
description: For usage issues, please provide the log zip saved from manager; for activation issues, please provide [bugreport](https://developer.android.com/studio/debug/bug-report). Without logs zip, the issue will be closed. /使用问题请提供从管理器保存的日志压缩包;激活问题请提供 [bugreport](https://developer.android.google.cn/studio/debug/bug-report?hl=zh-cn) 日志。没有日志附件的问题会被关闭。
placeholder: Upload logs zip by clicking the bar on the bottom. Uploading logs to other websites or using external links is prohibited. /点击文本框底栏上传日志压缩包,禁止上传到其它网站或使用外链提供日志。
validations:
required: true
================================================
FILE: .github/ISSUE_TEMPLATE/config.yml
================================================
blank_issues_enabled: false
contact_links:
- name: Ask a question/提问
url: https://github.com/JingMatrix/LSPosed/discussions/new?category=Q-A
about: Please ask and answer questions here./如果有任何疑问请在这里提问
================================================
FILE: .github/ISSUE_TEMPLATE/feature_request.yml
================================================
---
name: Feature request/新特性请求
description: Suggest an idea./提出建议
labels: [enhancement]
body:
- type: textarea
attributes:
label: Is your feature request related to a problem?/你的请求是否与某个问题相关?
placeholder: A clear and concise description of what the problem is./请清晰准确表述该问题。
validations:
required: true
- type: textarea
attributes:
label: Describe the solution you'd like/描述你想要的解决方案
placeholder: A clear and concise description of what you want to happen./请清晰准确描述新特性的预期行为
validations:
required: true
- type: textarea
attributes:
label: Additional context/其他信息
placeholder: Add any other context or screenshots about the feature request here./其他关于新特性的信息或者截图
validations:
required: false
================================================
FILE: .github/dependabot.yml
================================================
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: monthly
groups:
actions:
patterns:
- "*"
- package-ecosystem: gitsubmodule
directory: /
schedule:
interval: monthly
groups:
submodule:
patterns:
- "*"
- package-ecosystem: gradle
directory: /
schedule:
interval: daily
groups:
maven:
patterns:
- "*"
================================================
FILE: .github/workflows/core.yml
================================================
name: Core
on:
workflow_dispatch:
push:
branches: [ master ]
tags: [ v* ]
pull_request:
merge_group:
jobs:
build:
runs-on: ubuntu-latest
env:
CCACHE_COMPILERCHECK: "%compiler% -dumpmachine; %compiler% -dumpversion"
CCACHE_NOHASHDIR: "true"
CCACHE_HARDLINK: "true"
CCACHE_BASEDIR: "${{ github.workspace }}"
steps:
- name: Checkout
uses: actions/checkout@v6
with:
submodules: recursive
fetch-depth: 0
- name: Write key
if: ${{ ( github.event_name != 'pull_request' && github.ref == 'refs/heads/master' ) || github.ref_type == 'tag' }}
run: |
if [ ! -z "${{ secrets.KEY_STORE }}" ]; then
echo androidStorePassword='${{ secrets.KEY_STORE_PASSWORD }}' >> gradle.properties
echo androidKeyAlias='${{ secrets.ALIAS }}' >> gradle.properties
echo androidKeyPassword='${{ secrets.KEY_PASSWORD }}' >> gradle.properties
echo androidStoreFile='key.jks' >> gradle.properties
echo ${{ secrets.KEY_STORE }} | base64 --decode > key.jks
fi
- name: Setup Java
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: 21
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v5
- name: Configure Gradle properties
run: |
echo 'android.native.buildOutput=verbose' >> ~/.gradle/gradle.properties
echo 'org.gradle.parallel=true' >> ~/.gradle/gradle.properties
echo 'org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 -XX:+UseParallelGC' >> ~/.gradle/gradle.properties
echo 'android.native.buildOutput=verbose' >> ~/.gradle/gradle.properties
- name: Setup ninja
uses: seanmiddleditch/gha-setup-ninja@v6
with:
version: 1.12.1
- name: Setup ccache
uses: actions/cache@v5
with:
path: |
~/.ccache
${{ github.workspace }}/.ccache
key: ${{ runner.os }}-ccache-${{ hashFiles('**/build.gradle') }}-${{ hashFiles('**/CMakeLists.txt') }}
restore-keys: |
${{ runner.os }}-ccache-
- name: Setup Android SDK
uses: android-actions/setup-android@v3
- name: Remove Android's cmake
shell: bash
run: rm -rf $ANDROID_HOME/cmake
- name: Build with Gradle
run: |
./gradlew zipAll
- name: Prepare artifact
if: success()
id: prepareArtifact
run: |
zygiskReleaseName=`ls zygisk/release/Vector-v*-Release.zip | awk -F '(/|.zip)' '{print $3}'` && echo "zygiskReleaseName=$zygiskReleaseName" >> $GITHUB_OUTPUT
zygiskDebugName=`ls zygisk/release/Vector-v*-Debug.zip | awk -F '(/|.zip)' '{print $3}'` && echo "zygiskDebugName=$zygiskDebugName" >> $GITHUB_OUTPUT
unzip zygisk/release/Vector-v*-Release.zip -d Vector-Release
unzip zygisk/release/Vector-v*-Debug.zip -d Vector-Debug
- name: Upload zygisk release
uses: actions/upload-artifact@v6
with:
name: ${{ steps.prepareArtifact.outputs.zygiskReleaseName }}
path: "./Vector-Release/*"
- name: Upload zygisk debug
uses: actions/upload-artifact@v6
with:
name: ${{ steps.prepareArtifact.outputs.zygiskDebugName }}
path: "./Vector-Debug/*"
- name: Upload mappings
uses: actions/upload-artifact@v6
with:
name: mappings
path: |
zygisk/build/outputs/mapping
app/build/outputs/mapping
- name: Upload symbols
uses: actions/upload-artifact@v6
with:
name: symbols
path: build/symbols
================================================
FILE: .github/workflows/crowdin.yml
================================================
name: Crowdin Action
on:
workflow_dispatch:
push:
branches: [ master ]
paths:
- app/src/main/res/values/strings.xml
- daemon/src/main/res/values/strings.xml
jobs:
synchronize-with-crowdin:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@main
- name: crowdin action
uses: crowdin/github-action@master
with:
upload_translations: true
download_translations: false
upload_sources: true
config: 'crowdin.yml'
crowdin_branch_name: master
env:
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
CROWDIN_API_TOKEN: ${{ secrets.CROWDIN_API_TOKEN }}
================================================
FILE: .gitignore
================================================
.project
.settings
.cache
*.iml
.gradle
/local.properties
/.idea
.DS_Store
build
/captures
bin/
================================================
FILE: .gitmodules
================================================
[submodule "external/lsplant"]
path = external/lsplant
url = https://github.com/JingMatrix/LSPlant.git
[submodule "external/dobby"]
path = external/dobby
url = https://github.com/JingMatrix/Dobby.git
[submodule "external/fmt"]
path = external/fmt
url = https://github.com/fmtlib/fmt.git
[submodule "external/xz-embedded"]
path = external/xz-embedded
url = https://github.com/tukaani-project/xz-embedded.git
[submodule "external/lsplt"]
path = external/lsplt
url = https://github.com/JingMatrix/LSPlt
[submodule "services/libxposed"]
path = services/libxposed
url = https://github.com/libxposed/service.git
[submodule "xposed/libxposed"]
path = xposed/libxposed
url = https://github.com/libxposed/api.git
[submodule "external/apache/commons-lang"]
path = external/apache/commons-lang
url = https://github.com/apache/commons-lang.git
[submodule "external/axml/manifest-editor"]
path = external/axml/manifest-editor
url = https://github.com/JingMatrix/ManifestEditor.git
================================================
FILE: LICENSE
================================================
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
Copyright (C)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
Copyright (C)
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
.
================================================
FILE: README.md
================================================
# LSPosed Framework
[](https://github.com/JingMatrix/LSPosed/actions/workflows/core.yml?query=event%3Apush+branch%3Amaster+is%3Acompleted) [](https://crowdin.com/project/lsposed_jingmatrix) [](https://github.com/JingMatrix/LSPosed/releases/latest) [](https://github.com/JingMatrix/LSPosed/releases)
## Introduction
A Zygisk module trying to provide an ART hooking framework which delivers consistent APIs with the OG Xposed, leveraging LSPlant hooking framework.
> Xposed is a framework for modules that can change the behavior of the system and apps without touching any APKs. That's great because it means that modules can work for different versions and even ROMs without any changes (as long as the original code was not changed too much). It's also easy to undo. As all changes are done in the memory, you just need to deactivate the module and reboot to get your original system back. There are many other advantages, but here is just one more: multiple modules can do changes to the same part of the system or app. With modified APKs, you have to choose one. No way to combine them, unless the author builds multiple APKs with different combinations.
## Supported Versions
Android 8.1 ~ 16
## Install
1. Install Magisk v26+
2. [Download](#download) and install LSPosed in Magisk app
3. Reboot
4. Open LSPosed manager from notification
5. Have fun :)
## Download
- For stable releases, please go to [Github Releases page](https://github.com/JingMatrix/LSPosed/releases)
- For canary build, please check [Github Actions](https://github.com/JingMatrix/LSPosed/actions/workflows/core.yml?query=branch%3Amaster)
Note: debug builds are only available in Github Actions.
## Get Help
**Only bug reports from **THE LATEST DEBUG BUILD** will be accepted.**
- GitHub issues: [Issues](https://github.com/JingMatrix/LSPosed/issues/)
- (For Chinese speakers) 本项目只接受英语**标题**的issue。如果您不懂英语,请使用[翻译工具](https://www.deepl.com/zh/translator)
## For Developers
Developers are welcome to write Xposed modules with hooks based on LSPosed Framework. A module based on LSPosed framework is fully compatible with the original Xposed Framework, and vice versa, a Xposed Framework-based module will work well with LSPosed framework too.
- [Xposed Framework API](https://api.xposed.info/)
We use our own module repository. We welcome developers to submit modules to our repository, and then modules can be downloaded in LSPosed.
- [LSPosed Module Repository](https://github.com/Xposed-Modules-Repo)
## Community Discussion
[Troubleshooting guide](https://github.com/JingMatrix/LSPosed/issues/123) and [Disscusions](https://github.com/JingMatrix/LSPosed/discussions).
## Translation Contributing
You can contribute translation [here](https://crowdin.com/project/lsposed_jingmatrix).
## Credits
- [Magisk](https://github.com/topjohnwu/Magisk/): makes all these possible
- [XposedBridge](https://github.com/rovo89/XposedBridge): the OG Xposed framework APIs
- [LSPlant](https://github.com/JingMatrix/LSPlant): the core ART hooking framework
- [Dobby](https://github.com/JingMatrix/Dobby): inline hooker for `LSPlant` and `native_api` implement
- [EdXposed](https://github.com/ElderDrivers/EdXposed): fork source
- [xz-embedded](https://github.com/tukaani-project/xz-embedded): decompress `.gnu_debugdata` header section of stripped `libart.so`
- ~~[Riru](https://github.com/RikkaApps/Riru): provides a way to inject code into zygote process~~
- ~[SandHook](https://github.com/ganyao114/SandHook/): ART hooking framework for SandHook variant~
- ~[YAHFA](https://github.com/rk700/YAHFA): previous ART hooking framework~
- ~[dexmaker](https://github.com/linkedin/dexmaker) and [dalvikdx](https://github.com/JakeWharton/dalvik-dx): to dynamically generate YAHFA hooker classes~
- ~[DexBuilder](https://github.com/LSPosed/DexBuilder): to dynamically generate YAHFA hooker classes~
## License
LSPosed is licensed under the **GNU General Public License v3 (GPL-3)** (http://www.gnu.org/copyleft/gpl.html).
================================================
FILE: app/.gitignore
================================================
/build
================================================
FILE: app/build.gradle.kts
================================================
/*
* This file is part of LSPosed.
*
* LSPosed is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LSPosed is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LSPosed. If not, see .
*
* Copyright (C) 2021 LSPosed Contributors
*/
import java.time.Instant
plugins {
alias(libs.plugins.agp.app)
alias(libs.plugins.nav.safeargs)
alias(libs.plugins.autoresconfig)
alias(libs.plugins.materialthemebuilder)
alias(libs.plugins.lsplugin.resopt)
alias(libs.plugins.lsplugin.apksign)
}
apksign {
storeFileProperty = "androidStoreFile"
storePasswordProperty = "androidStorePassword"
keyAliasProperty = "androidKeyAlias"
keyPasswordProperty = "androidKeyPassword"
}
val defaultManagerPackageName: String by rootProject.extra
android {
buildFeatures {
viewBinding = true
buildConfig = true
}
defaultConfig {
applicationId = defaultManagerPackageName
buildConfigField("long", "BUILD_TIME", Instant.now().epochSecond.toString())
}
packaging {
resources {
excludes += "META-INF/**"
excludes += "okhttp3/**"
excludes += "kotlin/**"
excludes += "org/**"
excludes += "**.properties"
excludes += "**.bin"
}
}
dependenciesInfo.includeInApk = false
buildTypes {
release {
isMinifyEnabled = true
isShrinkResources = true
proguardFiles("proguard-rules.pro")
}
}
sourceSets { named("main") { res { srcDirs("src/common/res") } } }
namespace = defaultManagerPackageName
}
autoResConfig {
generateClass = true
generateRes = false
generatedClassFullName = "org.lsposed.manager.util.LangList"
generatedArrayFirstItem = "SYSTEM"
}
materialThemeBuilder {
themes {
for ((name, color) in
listOf(
"Red" to "F44336",
"Pink" to "E91E63",
"Purple" to "9C27B0",
"DeepPurple" to "673AB7",
"Indigo" to "3F51B5",
"Blue" to "2196F3",
"LightBlue" to "03A9F4",
"Cyan" to "00BCD4",
"Teal" to "009688",
"Green" to "4FAF50",
"LightGreen" to "8BC3A4",
"Lime" to "CDDC39",
"Yellow" to "FFEB3B",
"Amber" to "FFC107",
"Orange" to "FF9800",
"DeepOrange" to "FF5722",
"Brown" to "795548",
"BlueGrey" to "607D8F",
"Sakura" to "FF9CA8",
)) {
create("Material$name") {
lightThemeFormat = "ThemeOverlay.Light.%s"
darkThemeFormat = "ThemeOverlay.Dark.%s"
primaryColor = "#$color"
}
}
}
// Add Material Design 3 color tokens (such as palettePrimary100) in generated theme
// rikka.material:material >= 2.0.0 provides such attributes
// Enable this if your are using rikka.material:material
generatePalette = true
}
dependencies {
annotationProcessor(libs.glide.compiler)
implementation(libs.androidx.activity)
implementation(libs.androidx.browser)
implementation(libs.androidx.constraintlayout)
implementation(libs.androidx.core)
implementation(libs.androidx.fragment)
implementation(libs.androidx.navigation.fragment)
implementation(libs.androidx.navigation.ui)
implementation(libs.androidx.preference)
implementation(libs.androidx.recyclerview)
implementation(libs.androidx.swiperefreshlayout)
implementation(libs.glide)
implementation(libs.material)
implementation(libs.gson)
implementation(libs.okhttp)
implementation(libs.okhttp.dnsoverhttps)
implementation(libs.okhttp.logging.interceptor)
implementation(libs.rikkax.appcompat)
implementation(libs.rikkax.core)
implementation(libs.rikkax.insets)
implementation(libs.rikkax.material)
implementation(libs.rikkax.material.preference)
implementation(libs.rikkax.recyclerview)
implementation(libs.rikkax.widget.borderview)
implementation(libs.rikkax.widget.mainswitchbar)
implementation(libs.rikkax.layoutinflater)
implementation(libs.appiconloader)
implementation(libs.hiddenapibypass)
implementation(libs.kotlin.stdlib)
implementation(libs.kotlinx.coroutines.core)
implementation(projects.services.managerService)
}
configurations.all {
exclude("org.jetbrains", "annotations")
exclude("androidx.appcompat", "appcompat")
exclude("org.jetbrains.kotlin", "kotlin-stdlib-jdk7")
exclude("org.jetbrains.kotlin", "kotlin-stdlib-jdk8")
}
================================================
FILE: app/proguard-rules.pro
================================================
-keep class org.lsposed.manager.Constants {
public static boolean setBinder(android.os.IBinder);
}
-assumenosideeffects class kotlin.jvm.internal.Intrinsics {
public static void check*(...);
public static void throw*(...);
}
-assumenosideeffects class android.util.Log {
public static *** v(...);
public static *** d(...);
}
-keepclasseswithmembers,allowobfuscation class * {
@com.google.gson.annotations.SerializedName ;
}
-repackageclasses
-allowaccessmodification
-overloadaggressively
# Gson uses generic type information stored in a class file when working with fields. Proguard
# removes such information by default, so configure it to keep all of it.
-keepattributes Signature,InnerClasses,EnclosingMethod
-dontwarn org.jetbrains.annotations.NotNull
-dontwarn org.jetbrains.annotations.Nullable
-dontwarn org.bouncycastle.jsse.BCSSLParameters
-dontwarn org.bouncycastle.jsse.BCSSLSocket
-dontwarn org.bouncycastle.jsse.provider.BouncyCastleJsseProvider
-dontwarn org.conscrypt.Conscrypt*
-dontwarn org.conscrypt.ConscryptHostnameVerifier
-dontwarn org.openjsse.javax.net.ssl.SSLParameters
-dontwarn org.openjsse.javax.net.ssl.SSLSocket
-dontwarn org.openjsse.net.ssl.OpenJSSE
-keepclassmembers class * implements android.os.Parcelable {
public static final ** CREATOR;
}
================================================
FILE: app/src/main/AndroidManifest.xml
================================================
================================================
FILE: app/src/main/assets/webview/colors_dark.css
================================================
/* Primer Colors */
/* Please also update colors_light.css with light mode appropriate colors when modifying this file. */
:root {
--blue-900: #082a52;
--blue-800: #063366;
--blue-700: #0b498f;
--blue-600: #0c65c9;
--blue-500: #0d6edb;
--blue-400: #2e8fff;
--blue-300: #85beff;
--blue-200: #d1e6ff;
--blue-100: #e5f2ff;
--blue-000: #f5faff;
--gray-1000: #050505;
--gray-950: #0b0b0d;
--gray-900: #17181a;
--gray-850: #242528;
--gray-800: #2e2f37;
--gray-750: #383a42;
--gray-700: #41434e;
--gray-650: #4b4d58;
--gray-600: #525560;
--gray-550: #5e616e;
--gray-500: #6c6f7e;
--gray-450: #787c8c;
--gray-400: #9194a1;
--gray-350: #a9abb6;
--gray-300: #bfc1c9;
--gray-250: #d6d7dc;
--gray-200: #e3e4e8;
--gray-150: #eff0f5;
--gray-100: #f7f7f9;
--gray-050: #fbfbfc;
--gray-000: #ffffff;
--green-900: #184d25;
--green-800: #1b612b;
--green-700: #1e7533;
--green-600: #2b8f43;
--green-500: #32b24f;
--green-400: #40d663;
--green-300: #95f0ab;
--green-200: #cbf7d5;
--green-100: #e5ffeb;
--green-000: #f5fff8;
--yellow-900: #755f13;
--yellow-800: #b89007;
--yellow-700: #e0b112;
--yellow-600: #ffcb1a;
--yellow-500: #ffd74d;
--yellow-400: #ffe166;
--yellow-300: #ffec8a;
--yellow-200: #fff6b8;
--yellow-100: #fffce5;
--yellow-000: #fffef5;
--orange-900: #a84603;
--orange-800: #c75204;
--orange-700: #d65c09;
--orange-600: #eb680e;
--orange-500: #fa6f0f;
--orange-400: #ff8a38;
--orange-300: #ffae75;
--orange-200: #ffd5b2;
--orange-100: #ffeee0;
--orange-000: #fffaf5;
--red-900: #8f1d22;
--red-800: #a82229;
--red-700: #bd222d;
--red-600: #d62b38;
--red-500: #e04352;
--red-400: #f55363;
--red-300: #ff808d;
--red-200: #ffb2bb;
--red-100: #ffe0e4;
--red-000: #fff0f2;
--pink-900: #702653;
--pink-800: #9e3674;
--pink-700: #c2428e;
--pink-600: #d63c99;
--pink-500: #f051b0;
--pink-400: #f576c2;
--pink-300: #fa9bd4;
--pink-200: #ffbde4;
--pink-100: #fee0f2;
--pink-000: #fff0f9;
--purple-900: #2e1757;
--purple-800: #3f2175;
--purple-700: #522e8f;
--purple-600: #6139a8;
--purple-500: #7548c7;
--purple-400: #916bd6;
--purple-300: #b899f0;
--purple-200: #dac7ff;
--purple-100: #eae0ff;
--purple-000: #f6f2ff;
--textPrimary: var(--gray-050);
--textSecondary: var(--gray-300);
--textTertiary: var(--gray-400);
--textPlaceholder: rgba(145, 148, 161, 0.5);
--link: var(--blue-400);
--appBackground: var(--gray-1000);
--backgroundSecondary: var(--gray-900);
--backgroundTertiary: var(--gray-850);
--border: rgba(191, 193, 201, 0.16);
--borderOpaque: var(--gray-700);
--iconPrimary: var(--gray-300);
--iconSecondary: var(--gray-500);
--inputBackground: rgba(191, 193, 201, 0.12);
--backgroundPrimary: var(--gray-1000);
--backgroundElevatedPrimary: var(--gray-900);
--backgroundElevatedSecondary: rgba(191, 193, 201, 0.04);
--backgroundElevatedTertiary: rgba(191, 193, 201, 0.08);
--backgroundInset: var(--gray-900);
--link-hover: var(--gray-800);
--color-icon-success: var(--green-600);
--color-text-danger: var(--red-600);
--diffLineNumberAdditionBackground: #08260f;
--diffLineNumberAdditionText: #95f0ab;
--diffLineAdditionBackground: #061c0b;
--diffLineNumberDeletionBackground: #3b0507;
--diffLineNumberDeletionText: #ff808d;
--diffLineDeletionBackground: #300406;
--suggestedChangeDeletionText: #ffffff;
--suggestedChangeAdditionText: #ffffff;
--suggestedChangeDeletionBackground: rgba(218,54,51,0.6);
--suggestedChangeAdditionBackground: rgba(46,160,67,0.6);
--videoBackground: #000000;
}
/* Custom Base Styles */
:root {
--link-highlight: rgba(46, 143, 255, 0.08);
--pre-background: var(--backgroundElevatedTertiary);
--code-background: var(--pre-background);
--hr-background: var(--borderOpaque);
--thead-background: var(--pre-background);
--thead-border: var(--hr-background);
--tr-border: var(--gray-300);
--tr-alt-background: var(--pre-background);
--kbd-background: var(--pre-background);
--kbd-color: var(--gray-350);
--kbd-border: var(--gray-750);
--blockquote-color: var(--gray-400);
--blockquote-border: var(--hr-background);
--heading-color: var(--gray-100);
--h6-color: var(--gray-500);
--frame-border: var(--hr-background);
--frame-color: var(--gray-200);
--mention-color: var(--textPrimary);
--email-toggle-color: var(--kbd-color);
--email-toggle-background: var(--blockquote-border);
--email-quoted-color: var(--blockquote-color);
--keyword-color: var(--gray-600);
--code-font: ui-monospace, Menlo, monospace;
}
================================================
FILE: app/src/main/assets/webview/colors_light.css
================================================
/* Primer Colors */
/* Please also update colors_dark.css with dark mode appropriate colors when modifying this file. */
:root {
--blue-900: #05264c;
--blue-800: #032f62;
--blue-700: #044289;
--blue-600: #005cc5;
--blue-500: #0366d6;
--blue-400: #2188ff;
--blue-300: #79b8ff;
--blue-200: #c8e1ff;
--blue-100: #dbedff;
--blue-000: #f1f8ff;
--gray-1000: #050505;
--gray-950: #0b0b0d;
--gray-900: #17181a;
--gray-850: #242528;
--gray-800: #2f3037;
--gray-750: #383a42;
--gray-700: #41434e;
--gray-650: #4b4d58;
--gray-600: #525560;
--gray-550: #5e616e;
--gray-500: #6a6d7c;
--gray-450: #787c8c;
--gray-400: #9194a1;
--gray-350: #a9abb6;
--gray-300: #bfc1c9;
--gray-250: #d6d7dc;
--gray-200: #e3e4e8;
--gray-150: #eff0f5;
--gray-100: #f7f7f9;
--gray-050: #fbfbfc;
--gray-000: #ffffff;
--green-900: #144620;
--green-800: #165c26;
--green-700: #176f2c;
--green-600: #22863a;
--green-500: #28a745;
--green-400: #34d058;
--green-300: #85e89d;
--green-200: #bef5cb;
--green-100: #dcffe4;
--green-000: #f0fff4;
--yellow-900: #735c0f;
--yellow-800: #b08800;
--yellow-700: #dbab09;
--yellow-600: #f9c513;
--yellow-500: #ffd33d;
--yellow-400: #ffdf5d;
--yellow-300: #ffea7f;
--yellow-200: #fff5b1;
--yellow-100: #fffbdd;
--yellow-000: #fffdef;
--orange-900: #a04100;
--orange-800: #c24e00;
--orange-700: #d15704;
--orange-600: #e36209;
--orange-500: #f66a0a;
--orange-400: #fb8532;
--orange-300: #ffab70;
--orange-200: #ffd1ac;
--orange-100: #ffebda;
--orange-000: #fff8f2;
--red-900: #86181d;
--red-800: #9e1c23;
--red-700: #b31d28;
--red-600: #cb2431;
--red-500: #d73a49;
--red-400: #ea4a5a;
--red-300: #f97583;
--red-200: #fdaeb7;
--red-100: #ffdce0;
--red-000: #ffeef0;
--pink-900: #6d224f;
--pink-800: #99306f;
--pink-700: #b93a86;
--pink-600: #d03592;
--pink-500: #ea4aaa;
--pink-400: #ec6cb9;
--pink-300: #f692ce;
--pink-200: #f9b3dd;
--pink-100: #fedbf0;
--pink-000: #ffeef8;
--purple-900: #29134e;
--purple-800: #3a1d6e;
--purple-700: #4c2888;
--purple-600: #5a32a3;
--purple-500: #6f42c1;
--purple-400: #8a63d2;
--purple-300: #b392f0;
--purple-200: #d1bcf9;
--purple-100: #e6dcfd;
--purple-000: #f5f0ff;
--textPrimary: var(--gray-1000);
--textSecondary: var(--gray-700);
--textTertiary: var(--gray-500);
--textPlaceholder: rgba(82, 85, 96, 0.5);
--link: var(--blue-500);
--appBackground: var(--gray-000);
--backgroundSecondary: var(--gray-000);
--backgroundTertiary: var(--gray-000);
--border: rgba(65, 67, 78, 0.25);
--borderOpaque: var(--gray-300);
--iconPrimary: var(--gray-600);
--iconSecondary: var(--gray-400);
--inputBackground: rgba(65, 67, 78, 0.12);
--backgroundPrimary: var(--gray-150);
--backgroundElevatedPrimary: var(--gray-150);
--backgroundElevatedSecondary: var(--gray-000);
--backgroundElevatedTertiary: var(--gray-000);
--backgroundInset: var(--gray-200);
--link-hover: var(--gray-200);
--color-icon-success: var(--green-600);
--color-text-danger: var(--red-600);
--diffLineNumberAdditionBackground: #dcffe4;
--diffLineNumberAdditionText: #22863a;
--diffLineAdditionBackground: #f0fff4;
--diffLineNumberDeletionBackground: #ffdce0;
--diffLineNumberDeletionText: #cb2431;
--diffLineDeletionBackground: #ffeef0;
--suggestedChangeDeletionText: #ffffff;
--suggestedChangeAdditionText: #ffffff;
--suggestedChangeDeletionBackground: rgba(218,54,51,0.6);
--suggestedChangeAdditionBackground: rgba(46,160,67,0.6);
--videoBackground: #000000;
}
/* Custom Base Styles */
:root {
--link-highlight: rgba(3, 102, 214, 0.08);
--pre-background: var(--gray-100);
--code-background: var(--pre-background);
--hr-background: var(--gray-200);
--thead-background: var(--pre-background);
--thead-border: var(--hr-background);
--tr-border: var(--gray-300);
--tr-alt-background: var(--pre-background);
--kbd-background: var(--pre-background);
--kbd-color: var(--gray-650);
--kbd-border: var(--gray-250);
--blockquote-color: var(--gray-500);
--blockquote-border: var(--hr-background);
--heading-color: var(--gray-900);
--h6-color: var(--gray-500);
--frame-border: var(--hr-background);
--frame-color: var(--gray-850);
--mention-color: var(--gray-850);
--email-toggle-color: var(--kbd-color);
--email-toggle-background: var(--blockquote-border);
--email-quoted-color: var(--blockquote-color);
--keyword-color: var(--gray-400);
--code-font: ui-monospace, Menlo, monospace;
}
================================================
FILE: app/src/main/assets/webview/markdown.css
================================================
/* Shared styles between light & dark mode so all colors should be variables */
* {
box-sizing: border-box;
}
input:disabled {
touch-action: none;
}
html {
-webkit-text-size-adjust: none;
text-size-adjust: none;
font: -apple-system-body;
}
body {
color: var(--textPrimary);
background-color: var(--background);
}
a {
color: var(--link);
text-decoration: none;
-webkit-tap-highlight-color: var(--link-highlight);
word-break: break-word;
}
a:not([target]):hover {
border-radius: 5px;
background-color: var(--link-hover);
transition-duration: 0.2s;
transform: scale(1.015);
}
/*
Web views hold on to their hover event if the app is backgrounded. We need to disable custom hover effects by setting a
class on body and overriding them in CSS when we apply this workaround. When the mouse enters the web view again, we
can disable our override.
*/
body.hover-override a:not([target]) {
background-color: transparent;
transform: scale(1);
}
details summary {
outline: 0;
}
table {
border-spacing: 0;
border-collapse: collapse;
}
blockquote {
margin: 0;
}
table, table *, pre {
touch-action: pan-x;
}
.markdown-body ul.contains-task-list {
list-style: none;
padding-left: 0;
}
.task-list-item {
padding-left: 40px;
margin-left: -16px;
}
.task-list-item-checkbox {
margin-left: -24px
}
pre, code, kbd {
font-size: 1em;
font-family: var(--code-font);
}
.issue-keyword {
border-bottom: 1px dotted var(--keyword-color);
}
.team-mention, .user-mention {
font-weight: 600;
color: var(--mention-color);
white-space: nowrap;
}
.email-hidden-toggle, .email-hidden-reply {
display: none;
}
/* Fix checkboxes looking cut off when they render larger than the default size */
input[type="checkbox"] {
transform: translate(0px);
}
/* --- */
.markdown-body {
font-size: inherit;
line-height: 1.5;
word-wrap: break-word;
}
.markdown-body kbd {
display: inline-block;
padding: 0.18em 0.31em;
font-size: 0.7em;
line-height: 1.2em;
color: var(--kbd-color);
vertical-align: middle;
background-color: var(--kbd-background);
border: 1px solid var(--kbd-border);
border-radius: 0.25em;
box-shadow: inset 0 -1px 0 var(--kbd-border);
margin-right: 2px;
}
.markdown-body:after, .markdown-body:before {
display: table;
content: ""
}
.markdown-body:after {
clear: both;
}
.markdown-body > :first-child {
margin-top: 0 !important;
}
.markdown-body > :last-child {
margin-bottom: 0 !important;
}
.markdown-body a:not([href]) {
color: inherit;
text-decoration: none;
}
.markdown-body .absent {
color: var(--red-600);
}
.markdown-body .anchor {
float: left;
padding-right: 4px;
margin-left: -20px;
line-height: 1;
}
.markdown-body .anchor:focus {
outline: none;
}
.markdown-body blockquote, .markdown-body details, .markdown-body dl, .markdown-body ol, .markdown-body p, .markdown-body pre, .markdown-body table, .markdown-body ul {
margin-top: 0;
margin-bottom: 16px;
}
.markdown-body hr {
height: .25em;
padding: 0;
margin: 24px 0;
background-color: var(--hr-background);
border: 0;
}
.markdown-body blockquote {
padding-left: 1em;
color: var(--blockquote-color);
position: relative;
}
.markdown-body blockquote::before {
content: '';
width: 2px;
position: absolute;
top: 0;
bottom: 0;
left: 0;
background-color: var(--blockquote-border);
border-radius: 2px;
}
.markdown-body blockquote > :first-child {
margin-top: 0;
}
.markdown-body blockquote > :last-child {
margin-bottom: 0;
}
.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4, .markdown-body h5, .markdown-body h6 {
margin-top: 24px;
margin-bottom: 16px;
font-weight: 600;
line-height: 1.25;
}
.markdown-body h1 .octicon-link, .markdown-body h2 .octicon-link, .markdown-body h3 .octicon-link, .markdown-body h4 .octicon-link, .markdown-body h5 .octicon-link, .markdown-body h6 .octicon-link {
color: var(--heading-color);
vertical-align: middle;
visibility: hidden;
}
.markdown-body h1:hover .anchor, .markdown-body h2:hover .anchor, .markdown-body h3:hover .anchor, .markdown-body h4:hover .anchor, .markdown-body h5:hover .anchor, .markdown-body h6:hover .anchor {
text-decoration: none;
}
.markdown-body h1:hover .anchor .octicon-link, .markdown-body h2:hover .anchor .octicon-link, .markdown-body h3:hover .anchor .octicon-link, .markdown-body h4:hover .anchor .octicon-link, .markdown-body h5:hover .anchor .octicon-link, .markdown-body h6:hover .anchor .octicon-link {
visibility: visible;
}
.markdown-body h1 code, .markdown-body h1 tt, .markdown-body h2 code, .markdown-body h2 tt, .markdown-body h3 code, .markdown-body h3 tt, .markdown-body h4 code, .markdown-body h4 tt, .markdown-body h5 code, .markdown-body h5 tt, .markdown-body h6 code, .markdown-body h6 tt {
font-size: inherit;
}
.markdown-body h1 {
font-size: 2em;
}
.markdown-body h1, .markdown-body h2 {
padding-bottom: .3em;
border-bottom: 1px solid var(--border);
}
.markdown-body h2 {
font-size: 1.5em;
}
.markdown-body h3 {
font-size: 1.25em;
}
.markdown-body h4 {
font-size: 1em;
}
.markdown-body h5 {
font-size: .875em;
}
.markdown-body h6 {
font-size: .85em;
color: var(--h6-color);
}
.markdown-body ul {
padding-left: 1.5em;
}
.markdown-body ol.no-list, .markdown-body ul.no-list {
padding: 0;
list-style-type: none;
}
.markdown-body ol ol, .markdown-body ol ul, .markdown-body ul ol, .markdown-body ul ul {
margin-top: 0;
margin-bottom: 0;
}
.markdown-body li {
word-wrap: break-all;
}
.markdown-body li > p {
margin-top: 16px;
}
.markdown-body li + li {
margin-top: .25em;
}
.markdown-body dl {
padding: 0;
}
.markdown-body dl dt {
padding: 0;
margin-top: 16px;
font-size: 1em;
font-style: italic;
font-weight: 600;
}
.markdown-body dl dd {
padding: 0 16px;
margin-bottom: 16px;
}
.markdown-body table {
display: block;
width: 100%;
overflow: auto;
}
.markdown-body table th {
font-weight: 600;
}
.markdown-body table td, .markdown-body table th {
padding: 6px 13px;
border: 1px solid var(--thead-border);
}
.markdown-body table tr {
background-color: var(--background);
border-top: 1px solid var(--tr-border);
}
.markdown-body table tr:nth-child(2n) {
background-color: var(--tr-alt-background);
}
.markdown-body table img {
background-color: initial;
}
.markdown-body img {
max-width: 100%;
box-sizing: initial;
background-color: var(--background);
}
.markdown-body img[align=right] {
padding-left: 20px;
}
.markdown-body img[align=left] {
padding-right: 20px;
}
.markdown-body video {
max-width: 100%;
box-sizing: initial;
background-color: var(--videoBackground);
}
.markdown-body .emoji {
max-width: none;
vertical-align: text-top;
background-color: initial;
}
.markdown-body span.frame {
display: block;
overflow: hidden;
}
.markdown-body span.frame > span {
display: block;
float: left;
width: auto;
padding: 7px;
margin: 13px 0 0;
overflow: hidden;
border: 1px solid var(--frame-border);
}
.markdown-body span.frame span img {
display: block;
float: left;
}
.markdown-body span.frame span span {
display: block;
padding: 5px 0 0;
clear: both;
color: var(--frame-color);
}
.markdown-body span.align-center {
display: block;
overflow: hidden;
clear: both;
}
.markdown-body span.align-center > span {
display: block;
margin: 13px auto 0;
overflow: hidden;
text-align: center;
}
.markdown-body span.align-center span img {
margin: 0 auto;
text-align: center;
}
.markdown-body span.align-right {
display: block;
overflow: hidden;
clear: both;
}
.markdown-body span.align-right > span {
display: block;
margin: 13px 0 0;
overflow: hidden;
text-align: right;
}
.markdown-body span.align-right span img {
margin: 0;
text-align: right;
}
.markdown-body span.float-left {
display: block;
float: left;
margin-right: 13px;
overflow: hidden;
}
.markdown-body span.float-left span {
margin: 13px 0 0;
}
.markdown-body span.float-right {
display: block;
float: right;
margin-left: 13px;
overflow: hidden;
}
.markdown-body span.float-right > span {
display: block;
margin: 13px auto 0;
overflow: hidden;
text-align: right;
}
.markdown-body code, .markdown-body tt {
padding: .2em .4em;
margin: 0;
font-size: 85%;
background-color: var(--code-background);
border-radius: 6px;
}
.markdown-body code br, .markdown-body tt br {
display: none;
}
.markdown-body del code {
text-decoration: inherit;
}
.markdown-body pre {
word-wrap: normal;
}
.markdown-body pre > code {
padding: 0;
margin: 0;
font-size: 100%;
word-break: normal;
white-space: pre;
background: transparent;
border: 0;
}
.markdown-body .highlight {
margin-bottom: 16px;
}
.markdown-body .highlight pre {
margin-bottom: 0;
word-break: normal;
}
.markdown-body .highlight pre, .markdown-body pre {
padding: 16px;
overflow: auto;
font-size: 85%;
line-height: 1.45;
background-color: var(--pre-background);
border-radius: 6px;
}
.markdown-body pre code, .markdown-body pre tt {
display: inline;
max-width: auto;
padding: 0;
margin: 0;
overflow: visible;
line-height: inherit;
word-wrap: normal;
background-color: initial;
border: 0;
}
.markdown-body .csv-data td, .markdown-body .csv-data th {
padding: 5px;
overflow: hidden;
font-size: 12px;
line-height: 1;
text-align: left;
white-space: nowrap;
}
.markdown-body .csv-data .blob-num {
padding: 10px 8px 9px;
text-align: right;
background: var(--background);
border: 0;
}
.markdown-body .csv-data tr {
border-top: 0;
}
.markdown-body .csv-data th {
font-weight: 600;
background: var(--thead-background);
border-top: 0;
}
.open.octicon, .draft.octicon, .closed.octicon, .merged.octicon, .color-text-secondary.octicon {
display: inline-block;
margin-top: 0.15em;
vertical-align: text-top;
fill: currentColor;
width: 1em;
height: 1em;
font: -apple-system-body;
}
.open.octicon {
color: var(--color-icon-success);
}
.draft.octicon {
color: var(--textTertiary);
}
.closed.octicon {
color: var(--color-text-danger);
}
.merged.octicon {
color: var(--purple-500);
}
.color-text-secondary.octicon {
color: var(--textSecondary);
}
.reference {
white-space: nowrap;
}
.issue-link {
font-weight: 600;
color: var(--mention-color);
white-space: normal;
}
.issue-shorthand {
font-weight: 400;
color: var(--textTertiary);
}
.mr-1 {
margin-right: 4px;
}
.ml-1 {
margin-left: 4px;
}
.d-inline-block {
display: inline-block;
}
.v-align-middle {
vertical-align: middle;
}
.Box {
border-radius: 6px;
}
================================================
FILE: app/src/main/assets/webview/syntax.css
================================================
/* From https://github.com/primer/github-syntax-light/blob/master/lib/github-light.css */
.pl-c /* comment, punctuation.definition.comment, string.comment */ {
color: #6a737d;
}
.pl-c1 /* constant, entity.name.constant, variable.other.constant, variable.language, support, meta.property-name, support.constant, support.variable, meta.module-reference, markup.raw, meta.diff.header, meta.output */,
.pl-s .pl-v /* string variable */ {
color: #005cc5;
}
.pl-e /* entity */,
.pl-en /* entity.name */ {
color: #6f42c1;
}
.pl-smi /* variable.parameter.function, storage.modifier.package, storage.modifier.import, storage.type.java, variable.other */,
.pl-s .pl-s1 /* string source */ {
color: #24292e;
}
.pl-ent /* entity.name.tag, markup.quote */ {
color: #22863a;
}
.pl-k /* keyword, storage, storage.type */ {
color: #d73a49;
}
.pl-s /* string */,
.pl-pds /* punctuation.definition.string, source.regexp, string.regexp.character-class */,
.pl-s .pl-pse .pl-s1 /* string punctuation.section.embedded source */,
.pl-sr /* string.regexp */,
.pl-sr .pl-cce /* string.regexp constant.character.escape */,
.pl-sr .pl-sre /* string.regexp source.ruby.embedded */,
.pl-sr .pl-sra /* string.regexp string.regexp.arbitrary-repitition */ {
color: #032f62;
}
.pl-v /* variable */,
.pl-smw /* sublimelinter.mark.warning */ {
color: #e36209;
}
.pl-bu /* invalid.broken, invalid.deprecated, invalid.unimplemented, message.error, brackethighlighter.unmatched, sublimelinter.mark.error */ {
color: #b31d28;
}
.pl-ii /* invalid.illegal */ {
color: #fafbfc;
background-color: #b31d28;
}
.pl-c2 /* carriage-return */ {
color: #fafbfc;
background-color: #d73a49;
}
.pl-c2::before /* carriage-return */ {
content: "^M";
}
.pl-sr .pl-cce /* string.regexp constant.character.escape */ {
font-weight: bold;
color: #22863a;
}
.pl-ml /* markup.list */ {
color: #735c0f;
}
.pl-mh /* markup.heading */,
.pl-mh .pl-en /* markup.heading entity.name */,
.pl-ms /* meta.separator */ {
font-weight: bold;
color: #005cc5;
}
.pl-mi /* markup.italic */ {
font-style: italic;
color: #24292e;
}
.pl-mb /* markup.bold */ {
font-weight: bold;
color: #24292e;
}
.pl-md /* markup.deleted, meta.diff.header.from-file, punctuation.definition.deleted */ {
color: #b31d28;
background-color: #ffeef0;
}
.pl-mi1 /* markup.inserted, meta.diff.header.to-file, punctuation.definition.inserted */ {
color: #22863a;
background-color: #f0fff4;
}
.pl-mc /* markup.changed, punctuation.definition.changed */ {
color: #e36209;
background-color: #ffebda;
}
.pl-mi2 /* markup.ignored, markup.untracked */ {
color: #f6f8fa;
background-color: #005cc5;
}
.pl-mdr /* meta.diff.range */ {
font-weight: bold;
color: #6f42c1;
}
.pl-ba /* brackethighlighter.tag, brackethighlighter.curly, brackethighlighter.round, brackethighlighter.square, brackethighlighter.angle, brackethighlighter.quote */ {
color: #586069;
}
.pl-sg /* sublimelinter.gutter-mark */ {
color: #959da5;
}
.pl-corl /* constant.other.reference.link, string.other.link */ {
text-decoration: underline;
color: #032f62;
}
================================================
FILE: app/src/main/assets/webview/syntax_dark.css
================================================
/* From https://github.com/primer/github-syntax-dark/blob/master/lib/github-dark.css */
.pl-c /* comment, punctuation.definition.comment, string.comment */ {
color: #959da5;
}
.pl-c1 /* constant, entity.name.constant, variable.other.constant, variable.language, support, meta.property-name, support.constant, support.variable, meta.module-reference, markup.quote, markup.raw, meta.diff.header */,
.pl-s .pl-v /* string variable */ {
color: #c8e1ff;
}
.pl-e /* entity */,
.pl-en /* entity.name */ {
color: #b392f0;
}
.pl-smi /* variable.parameter.function, storage.modifier.package, storage.modifier.import, storage.type.java, variable.other */,
.pl-s .pl-s1 /* string source */ {
color: #f6f8fa;
}
.pl-ent /* entity.name.tag */ {
color: #7bcc72;
}
.pl-k /* keyword, storage, storage.type */ {
color: #ea4a5a;
}
.pl-s /* string */,
.pl-pds /* punctuation.definition.string, source.regexp, string.regexp.character-class */,
.pl-s .pl-pse .pl-s1 /* string punctuation.section.embedded source */,
.pl-sr /* string.regexp */,
.pl-sr .pl-cce /* string.regexp constant.character.escape */,
.pl-sr .pl-sre /* string.regexp source.ruby.embedded */,
.pl-sr .pl-sra /* string.regexp string.regexp.arbitrary-repitition */ {
color: #79b8ff;
}
.pl-v /* variable */,
.pl-ml /* markup.list, sublimelinter.mark.warning */ {
color: #fb8532;
}
.pl-bu /* invalid.broken, invalid.deprecated, invalid.unimplemented, message.error, brackethighlighter.unmatched, sublimelinter.mark.error */ {
color: #d73a49;
}
.pl-ii /* invalid.illegal */ {
color: #fafbfc;
background-color: #d73a49;
}
.pl-c2 /* carriage-return */ {
color: #fafbfc;
background-color: #d73a49;
}
.pl-c2::before /* carriage-return */ {
content: "^M";
}
.pl-sr .pl-cce /* string.regexp constant.character.escape */ {
font-weight: bold;
color: #7bcc72;
}
.pl-mh /* markup.heading */,
.pl-mh .pl-en /* markup.heading entity.name */,
.pl-ms /* meta.separator */ {
font-weight: bold;
color: #0366d6;
}
.pl-mi /* markup.italic */ {
font-style: italic;
color: #f6f8fa;
}
.pl-mb /* markup.bold */ {
font-weight: bold;
color: #f6f8fa;
}
.pl-md /* markup.deleted, meta.diff.header.from-file, punctuation.definition.deleted */ {
color: #ffdcd7;
background-color: #67060c;
}
.pl-mi1 /* markup.inserted, meta.diff.header.to-file, punctuation.definition.inserted */ {
color: #aff5b4;
background-color: #033a16;
}
.pl-mc /* markup.changed, punctuation.definition.changed */ {
color: #b08800;
background-color: #fffdef;
}
.pl-mi2 /* markup.ignored, markup.untracked */ {
color: #2f363d;
background-color: #959da5;
}
.pl-mdr /* meta.diff.range */ {
font-weight: bold;
color: #b392f0;
}
.pl-mo /* meta.output */ {
color: #0366d6;
}
.pl-ba /* brackethighlighter.tag, brackethighlighter.curly, brackethighlighter.round, brackethighlighter.square, brackethighlighter.angle, brackethighlighter.quote */ {
color: #ffeef0;
}
.pl-sg /* sublimelinter.gutter-mark */ {
color: #6a737d;
}
.pl-corl /* constant.other.reference.link, string.other.link */ {
text-decoration: underline;
color: #79b8ff;
}
================================================
FILE: app/src/main/assets/webview/template.html
================================================
@body@
================================================
FILE: app/src/main/assets/webview/template_dark.html
================================================
@body@
================================================
FILE: app/src/main/java/com/google/android/material/appbar/SubtitleCollapsingToolbarLayout.java
================================================
package com.google.android.material.appbar;
import android.animation.ValueAnimator;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.Typeface;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.widget.FrameLayout;
import androidx.annotation.ColorInt;
import androidx.annotation.DrawableRes;
import androidx.annotation.IntRange;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.annotation.StyleRes;
import androidx.appcompat.widget.Toolbar;
import androidx.core.content.ContextCompat;
import androidx.core.graphics.drawable.DrawableCompat;
import androidx.core.math.MathUtils;
import androidx.core.view.GravityCompat;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import com.google.android.material.animation.AnimationUtils;
import com.google.android.material.internal.DescendantOffsetUtils;
import com.google.android.material.internal.SubtitleCollapsingTextHelper;
import com.google.android.material.internal.ThemeEnforcement;
import org.lsposed.manager.R;
/**
* @see CollapsingToolbarLayout
*/
public class SubtitleCollapsingToolbarLayout extends FrameLayout {
private static final int DEFAULT_SCRIM_ANIMATION_DURATION = 600;
private boolean refreshToolbar = true;
private int toolbarId;
@Nullable
private Toolbar toolbar;
@Nullable
private View toolbarDirectChild;
private View dummyView;
private int expandedMarginStart;
private int expandedMarginTop;
private int expandedMarginEnd;
private int expandedMarginBottom;
private final Rect tmpRect = new Rect();
@NonNull
final SubtitleCollapsingTextHelper collapsingTextHelper;
private boolean collapsingTitleEnabled;
private boolean drawCollapsingTitle;
@Nullable
private Drawable contentScrim;
@Nullable
Drawable statusBarScrim;
private int scrimAlpha;
private boolean scrimsAreShown;
private ValueAnimator scrimAnimator;
private long scrimAnimationDuration;
private int scrimVisibleHeightTrigger = -1;
private AppBarLayout.OnOffsetChangedListener onOffsetChangedListener;
int currentOffset;
@Nullable
WindowInsetsCompat lastInsets;
public SubtitleCollapsingToolbarLayout(@NonNull Context context) {
this(context, null);
}
public SubtitleCollapsingToolbarLayout(@NonNull Context context, @Nullable AttributeSet attrs) {
this(context, attrs, 0);
}
public SubtitleCollapsingToolbarLayout(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
collapsingTextHelper = new SubtitleCollapsingTextHelper(this);
collapsingTextHelper.setTextSizeInterpolator(AnimationUtils.DECELERATE_INTERPOLATOR);
collapsingTextHelper.setRtlTextDirectionHeuristicsEnabled(false);
TypedArray a = ThemeEnforcement.obtainStyledAttributes(
context,
attrs,
R.styleable.SubtitleCollapsingToolbarLayout,
defStyleAttr,
R.style.Widget_Design_SubtitleCollapsingToolbar);
collapsingTextHelper.setExpandedTextGravity(a.getInt(
R.styleable.SubtitleCollapsingToolbarLayout_expandedTitleGravity,
GravityCompat.START | Gravity.BOTTOM));
collapsingTextHelper.setCollapsedTextGravity(a.getInt(
R.styleable.SubtitleCollapsingToolbarLayout_collapsedTitleGravity,
GravityCompat.START | Gravity.CENTER_VERTICAL));
expandedMarginStart = expandedMarginTop = expandedMarginEnd = expandedMarginBottom =
a.getDimensionPixelSize(R.styleable.SubtitleCollapsingToolbarLayout_expandedTitleMargin, 0);
if (a.hasValue(R.styleable.SubtitleCollapsingToolbarLayout_expandedTitleMarginStart)) {
expandedMarginStart =
a.getDimensionPixelSize(R.styleable.SubtitleCollapsingToolbarLayout_expandedTitleMarginStart, 0);
}
if (a.hasValue(R.styleable.SubtitleCollapsingToolbarLayout_expandedTitleMarginEnd)) {
expandedMarginEnd =
a.getDimensionPixelSize(R.styleable.SubtitleCollapsingToolbarLayout_expandedTitleMarginEnd, 0);
}
if (a.hasValue(R.styleable.SubtitleCollapsingToolbarLayout_expandedTitleMarginTop)) {
expandedMarginTop =
a.getDimensionPixelSize(R.styleable.SubtitleCollapsingToolbarLayout_expandedTitleMarginTop, 0);
}
if (a.hasValue(R.styleable.SubtitleCollapsingToolbarLayout_expandedTitleMarginBottom)) {
expandedMarginBottom =
a.getDimensionPixelSize(R.styleable.SubtitleCollapsingToolbarLayout_expandedTitleMarginBottom, 0);
}
collapsingTitleEnabled = a.getBoolean(R.styleable.SubtitleCollapsingToolbarLayout_titleEnabled, true);
setTitle(a.getText(R.styleable.SubtitleCollapsingToolbarLayout_title));
setSubtitle(a.getText(R.styleable.SubtitleCollapsingToolbarLayout_subtitle));
// First load the default text appearances
collapsingTextHelper.setExpandedTitleTextAppearance(
R.style.TextAppearance_Design_SubtitleCollapsingToolbar_ExpandedTitle);
collapsingTextHelper.setCollapsedTitleTextAppearance(
androidx.appcompat.R.style.TextAppearance_AppCompat_Widget_ActionBar_Title);
collapsingTextHelper.setExpandedSubtitleTextAppearance(
R.style.TextAppearance_Design_SubtitleCollapsingToolbar_ExpandedSubtitle);
collapsingTextHelper.setCollapsedSubtitleTextAppearance(
androidx.appcompat.R.style.TextAppearance_AppCompat_Widget_ActionBar_Subtitle);
// Now overlay any custom text appearances
if (a.hasValue(R.styleable.SubtitleCollapsingToolbarLayout_expandedTitleTextAppearance)) {
collapsingTextHelper.setExpandedTitleTextAppearance(
a.getResourceId(R.styleable.SubtitleCollapsingToolbarLayout_expandedTitleTextAppearance, 0));
}
if (a.hasValue(R.styleable.SubtitleCollapsingToolbarLayout_collapsedTitleTextAppearance)) {
collapsingTextHelper.setCollapsedTitleTextAppearance(
a.getResourceId(R.styleable.SubtitleCollapsingToolbarLayout_collapsedTitleTextAppearance, 0));
}
if (a.hasValue(R.styleable.SubtitleCollapsingToolbarLayout_expandedSubtitleTextAppearance)) {
collapsingTextHelper.setExpandedSubtitleTextAppearance(
a.getResourceId(R.styleable.SubtitleCollapsingToolbarLayout_expandedSubtitleTextAppearance, 0));
}
if (a.hasValue(R.styleable.SubtitleCollapsingToolbarLayout_collapsedSubtitleTextAppearance)) {
collapsingTextHelper.setCollapsedSubtitleTextAppearance(
a.getResourceId(R.styleable.SubtitleCollapsingToolbarLayout_collapsedSubtitleTextAppearance, 0));
}
scrimVisibleHeightTrigger = a
.getDimensionPixelSize(R.styleable.SubtitleCollapsingToolbarLayout_scrimVisibleHeightTrigger, -1);
scrimAnimationDuration = a.getInt(
R.styleable.SubtitleCollapsingToolbarLayout_scrimAnimationDuration,
DEFAULT_SCRIM_ANIMATION_DURATION);
setContentScrim(a.getDrawable(R.styleable.SubtitleCollapsingToolbarLayout_contentScrim));
setStatusBarScrim(a.getDrawable(R.styleable.SubtitleCollapsingToolbarLayout_statusBarScrim));
toolbarId = a.getResourceId(R.styleable.SubtitleCollapsingToolbarLayout_toolbarId, -1);
a.recycle();
setWillNotDraw(false);
}
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
// Add an OnOffsetChangedListener if possible
final ViewParent parent = getParent();
if (parent instanceof AppBarLayout) {
// Copy over from the ABL whether we should fit system windows
ViewCompat.setFitsSystemWindows(this, ViewCompat.getFitsSystemWindows((View) parent));
if (onOffsetChangedListener == null) {
onOffsetChangedListener = new OffsetUpdateListener();
}
((AppBarLayout) parent).addOnOffsetChangedListener(onOffsetChangedListener);
// We're attached, so lets request an inset dispatch
ViewCompat.requestApplyInsets(this);
}
}
@Override
protected void onDetachedFromWindow() {
// Remove our OnOffsetChangedListener if possible and it exists
final ViewParent parent = getParent();
if (onOffsetChangedListener != null && parent instanceof AppBarLayout) {
((AppBarLayout) parent).removeOnOffsetChangedListener(onOffsetChangedListener);
}
super.onDetachedFromWindow();
}
@Override
public void draw(@NonNull Canvas canvas) {
super.draw(canvas);
// If we don't have a toolbar, the scrim will be not be drawn in drawChild() below.
// Instead, we draw it here, before our collapsing text.
ensureToolbar();
if (toolbar == null && contentScrim != null && scrimAlpha > 0) {
contentScrim.mutate().setAlpha(scrimAlpha);
contentScrim.draw(canvas);
}
// Let the collapsing text helper draw its text
if (collapsingTitleEnabled && drawCollapsingTitle) {
collapsingTextHelper.draw(canvas);
}
// Now draw the status bar scrim
if (statusBarScrim != null && scrimAlpha > 0) {
final int topInset = lastInsets != null ? lastInsets.getSystemWindowInsetTop() : 0;
if (topInset > 0) {
statusBarScrim.setBounds(0, -currentOffset, getWidth(), topInset - currentOffset);
statusBarScrim.mutate().setAlpha(scrimAlpha);
statusBarScrim.draw(canvas);
}
}
}
@Override
protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
// This is a little weird. Our scrim needs to be behind the Toolbar (if it is present),
// but in front of any other children which are behind it. To do this we intercept the
// drawChild() call, and draw our scrim just before the Toolbar is drawn
boolean invalidated = false;
if (contentScrim != null && scrimAlpha > 0 && isToolbarChild(child)) {
contentScrim.mutate().setAlpha(scrimAlpha);
contentScrim.draw(canvas);
invalidated = true;
}
return super.drawChild(canvas, child, drawingTime) || invalidated;
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
if (contentScrim != null) {
contentScrim.setBounds(0, 0, w, h);
}
}
private void ensureToolbar() {
if (!refreshToolbar) {
return;
}
// First clear out the current Toolbar
this.toolbar = null;
toolbarDirectChild = null;
if (toolbarId != -1) {
// If we have an ID set, try and find it and it's direct parent to us
this.toolbar = findViewById(toolbarId);
if (this.toolbar != null) {
toolbarDirectChild = findDirectChild(this.toolbar);
}
}
if (this.toolbar == null) {
// If we don't have an ID, or couldn't find a Toolbar with the correct ID, try and find
// one from our direct children
Toolbar toolbar = null;
for (int i = 0, count = getChildCount(); i < count; i++) {
final View child = getChildAt(i);
if (child instanceof Toolbar) {
toolbar = (Toolbar) child;
break;
}
}
this.toolbar = toolbar;
}
updateDummyView();
refreshToolbar = false;
}
private boolean isToolbarChild(View child) {
return (toolbarDirectChild == null || toolbarDirectChild == this)
? child == toolbar
: child == toolbarDirectChild;
}
/**
* Returns the direct child of this layout, which itself is the ancestor of the given view.
*/
@NonNull
private View findDirectChild(@NonNull final View descendant) {
View directChild = descendant;
for (ViewParent p = descendant.getParent(); p != this && p != null; p = p.getParent()) {
if (p instanceof View) {
directChild = (View) p;
}
}
return directChild;
}
private void updateDummyView() {
if (!collapsingTitleEnabled && dummyView != null) {
// If we have a dummy view and we have our title disabled, remove it from its parent
final ViewParent parent = dummyView.getParent();
if (parent instanceof ViewGroup) {
((ViewGroup) parent).removeView(dummyView);
}
}
if (collapsingTitleEnabled && toolbar != null) {
if (dummyView == null) {
dummyView = new View(getContext());
}
if (dummyView.getParent() == null) {
toolbar.addView(dummyView, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
}
}
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
ensureToolbar();
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
final int mode = MeasureSpec.getMode(heightMeasureSpec);
final int topInset = lastInsets != null ? lastInsets.getSystemWindowInsetTop() : 0;
if (mode == MeasureSpec.UNSPECIFIED && topInset > 0) {
// If we have a top inset and we're set to wrap_content height we need to make sure
// we add the top inset to our height, therefore we re-measure
heightMeasureSpec = MeasureSpec.makeMeasureSpec(getMeasuredHeight() + topInset, MeasureSpec.EXACTLY);
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
// Set our minimum height to enable proper AppBarLayout collapsing
if (toolbar != null) {
if (toolbarDirectChild == null || toolbarDirectChild == this) {
setMinimumHeight(getHeightWithMargins(toolbar));
} else {
setMinimumHeight(getHeightWithMargins(toolbarDirectChild));
}
}
}
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
if (lastInsets != null) {
// Shift down any views which are not set to fit system windows
final int insetTop = lastInsets.getSystemWindowInsetTop();
for (int i = 0, z = getChildCount(); i < z; i++) {
final View child = getChildAt(i);
if (!ViewCompat.getFitsSystemWindows(child)) {
if (child.getTop() < insetTop) {
// If the child isn't set to fit system windows but is drawing within
// the inset offset it down
ViewCompat.offsetTopAndBottom(child, insetTop);
}
}
}
}
// Update our child view offset helpers so that they track the correct layout coordinates
for (int i = 0, z = getChildCount(); i < z; i++) {
getViewOffsetHelper(getChildAt(i)).onViewLayout();
}
// Update the collapsed bounds by getting its transformed bounds
if (collapsingTitleEnabled && dummyView != null) {
// We only draw the title if the dummy view is being displayed (Toolbar removes
// views if there is no space)
drawCollapsingTitle = ViewCompat.isAttachedToWindow(dummyView) && dummyView.getVisibility() == VISIBLE;
if (drawCollapsingTitle) {
final boolean isRtl = ViewCompat.getLayoutDirection(this) == ViewCompat.LAYOUT_DIRECTION_RTL;
// Update the collapsed bounds
final int maxOffset =
getMaxOffsetForPinChild(toolbarDirectChild != null ? toolbarDirectChild : toolbar);
DescendantOffsetUtils.getDescendantRect(this, dummyView, tmpRect);
collapsingTextHelper.setCollapsedBounds(
tmpRect.left + (isRtl ? toolbar.getTitleMarginEnd() : toolbar.getTitleMarginStart()),
tmpRect.top + maxOffset + toolbar.getTitleMarginTop(),
tmpRect.right - (isRtl ? toolbar.getTitleMarginStart() : toolbar.getTitleMarginEnd()),
tmpRect.bottom + maxOffset - toolbar.getTitleMarginBottom());
// Update the expanded bounds
collapsingTextHelper.setExpandedBounds(
isRtl ? expandedMarginEnd : expandedMarginStart,
tmpRect.top + expandedMarginTop,
right - left - (isRtl ? expandedMarginStart : expandedMarginEnd),
bottom - top - expandedMarginBottom);
// Now recalculate using the new bounds
collapsingTextHelper.recalculate();
}
}
if (toolbar != null) {
if (collapsingTitleEnabled && TextUtils.isEmpty(collapsingTextHelper.getTitle())) {
// If we do not currently have a title, try and grab it from the Toolbar
setTitle(toolbar.getTitle());
setSubtitle(toolbar.getSubtitle());
}
}
updateScrimVisibility();
// Apply any view offsets, this should be done at the very end of layout
for (int i = 0, z = getChildCount(); i < z; i++) {
getViewOffsetHelper(getChildAt(i)).applyOffsets();
}
}
private static int getHeightWithMargins(@NonNull final View view) {
final ViewGroup.LayoutParams lp = view.getLayoutParams();
if (lp instanceof MarginLayoutParams) {
final MarginLayoutParams mlp = (MarginLayoutParams) lp;
return view.getMeasuredHeight() + mlp.topMargin + mlp.bottomMargin;
}
return view.getMeasuredHeight();
}
static ViewOffsetHelper getViewOffsetHelper(View view) {
ViewOffsetHelper offsetHelper = (ViewOffsetHelper) view.getTag(com.google.android.material.R.id.view_offset_helper);
if (offsetHelper == null) {
offsetHelper = new ViewOffsetHelper(view);
view.setTag(com.google.android.material.R.id.view_offset_helper, offsetHelper);
}
return offsetHelper;
}
/**
* Sets the title to be displayed by this view, if enabled.
*
* @attr ref R.styleable#SubtitleCollapsingToolbarLayout_title
* @see #setTitleEnabled(boolean)
* @see #getTitle()
*/
public void setTitle(@Nullable CharSequence title) {
collapsingTextHelper.setTitle(title);
updateContentDescriptionFromTitle();
}
/**
* Returns the title currently being displayed by this view. If the title is not enabled, then
* this will return {@code null}.
*
* @attr ref R.styleable#SubtitleCollapsingToolbarLayout_title
*/
@Nullable
public CharSequence getTitle() {
return collapsingTitleEnabled ? collapsingTextHelper.getTitle() : null;
}
/**
* Sets the subtitle to be displayed by this view, if enabled.
*
* @attr ref R.styleable#SubtitleCollapsingToolbarLayout_subtitle
* @see #setTitleEnabled(boolean)
* @see #getSubtitle()
*/
public void setSubtitle(@Nullable CharSequence subtitle) {
collapsingTextHelper.setSubtitle(subtitle);
updateContentDescriptionFromTitle();
}
/**
* Returns the subtitle currently being displayed by this view. If the title is not enabled, then
* this will return {@code null}.
*
* @attr ref R.styleable#SubtitleCollapsingToolbarLayout_subtitle
*/
@Nullable
public CharSequence getSubtitle() {
return collapsingTitleEnabled ? collapsingTextHelper.getSubtitle() : null;
}
/**
* Sets whether this view should display its own title and subtitle.
*
*
The title and subtitle displayed by this view will shrink and grow based on the scroll offset.
*
* @attr ref R.styleable#SubtitleCollapsingToolbarLayout_titleEnabled
* @see #setTitle(CharSequence)
* @see #setSubtitle(CharSequence)
* @see #isTitleEnabled()
*/
public void setTitleEnabled(boolean enabled) {
if (enabled != collapsingTitleEnabled) {
collapsingTitleEnabled = enabled;
updateContentDescriptionFromTitle();
updateDummyView();
requestLayout();
}
}
/**
* Returns whether this view is currently displaying its own title and subtitle.
*
* @attr ref R.styleable#SubtitleCollapsingToolbarLayout_titleEnabled
* @see #setTitleEnabled(boolean)
*/
public boolean isTitleEnabled() {
return collapsingTitleEnabled;
}
/**
* Set whether the content scrim and/or status bar scrim should be shown or not. Any change in the
* vertical scroll may overwrite this value. Any visibility change will be animated if this view
* has already been laid out.
*
* @param shown whether the scrims should be shown
* @see #getStatusBarScrim()
* @see #getContentScrim()
*/
public void setScrimsShown(boolean shown) {
setScrimsShown(shown, ViewCompat.isLaidOut(this) && !isInEditMode());
}
/**
* Set whether the content scrim and/or status bar scrim should be shown or not. Any change in the
* vertical scroll may overwrite this value.
*
* @param shown whether the scrims should be shown
* @param animate whether to animate the visibility change
* @see #getStatusBarScrim()
* @see #getContentScrim()
*/
public void setScrimsShown(boolean shown, boolean animate) {
if (scrimsAreShown != shown) {
if (animate) {
animateScrim(shown ? 0xFF : 0x0);
} else {
setScrimAlpha(shown ? 0xFF : 0x0);
}
scrimsAreShown = shown;
}
}
private void animateScrim(int targetAlpha) {
ensureToolbar();
if (scrimAnimator == null) {
scrimAnimator = new ValueAnimator();
scrimAnimator.setDuration(scrimAnimationDuration);
scrimAnimator.setInterpolator(targetAlpha > scrimAlpha
? AnimationUtils.FAST_OUT_LINEAR_IN_INTERPOLATOR
: AnimationUtils.LINEAR_OUT_SLOW_IN_INTERPOLATOR);
scrimAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animator) {
setScrimAlpha((int) animator.getAnimatedValue());
}
});
} else if (scrimAnimator.isRunning()) {
scrimAnimator.cancel();
}
scrimAnimator.setIntValues(scrimAlpha, targetAlpha);
scrimAnimator.start();
}
void setScrimAlpha(int alpha) {
if (alpha != scrimAlpha) {
final Drawable contentScrim = this.contentScrim;
if (contentScrim != null && toolbar != null) {
ViewCompat.postInvalidateOnAnimation(toolbar);
}
scrimAlpha = alpha;
ViewCompat.postInvalidateOnAnimation(SubtitleCollapsingToolbarLayout.this);
}
}
int getScrimAlpha() {
return scrimAlpha;
}
/**
* Set the drawable to use for the content scrim from resources. Providing null will disable the
* scrim functionality.
*
* @param drawable the drawable to display
* @attr ref R.styleable#SubtitleCollapsingToolbarLayout_contentScrim
* @see #getContentScrim()
*/
public void setContentScrim(@Nullable Drawable drawable) {
if (contentScrim != drawable) {
if (contentScrim != null) {
contentScrim.setCallback(null);
}
contentScrim = drawable != null ? drawable.mutate() : null;
if (contentScrim != null) {
contentScrim.setBounds(0, 0, getWidth(), getHeight());
contentScrim.setCallback(this);
contentScrim.setAlpha(scrimAlpha);
}
ViewCompat.postInvalidateOnAnimation(this);
}
}
/**
* Set the color to use for the content scrim.
*
* @param color the color to display
* @attr ref R.styleable#SubtitleCollapsingToolbarLayout_contentScrim
* @see #getContentScrim()
*/
public void setContentScrimColor(@ColorInt int color) {
setContentScrim(new ColorDrawable(color));
}
/**
* Set the drawable to use for the content scrim from resources.
*
* @param resId drawable resource id
* @attr ref R.styleable#SubtitleCollapsingToolbarLayout_contentScrim
* @see #getContentScrim()
*/
public void setContentScrimResource(@DrawableRes int resId) {
setContentScrim(ContextCompat.getDrawable(getContext(), resId));
}
/**
* Returns the drawable which is used for the foreground scrim.
*
* @attr ref R.styleable#SubtitleCollapsingToolbarLayout_contentScrim
* @see #setContentScrim(Drawable)
*/
@Nullable
public Drawable getContentScrim() {
return contentScrim;
}
/**
* Set the drawable to use for the status bar scrim from resources. Providing null will disable
* the scrim functionality.
*
*
This scrim is only shown when we have been given a top system inset.
*
* @param drawable the drawable to display
* @attr ref R.styleable#SubtitleCollapsingToolbarLayout_statusBarScrim
* @see #getStatusBarScrim()
*/
public void setStatusBarScrim(@Nullable Drawable drawable) {
if (statusBarScrim != drawable) {
if (statusBarScrim != null) {
statusBarScrim.setCallback(null);
}
statusBarScrim = drawable != null ? drawable.mutate() : null;
if (statusBarScrim != null) {
if (statusBarScrim.isStateful()) {
statusBarScrim.setState(getDrawableState());
}
DrawableCompat.setLayoutDirection(statusBarScrim, ViewCompat.getLayoutDirection(this));
statusBarScrim.setVisible(getVisibility() == VISIBLE, false);
statusBarScrim.setCallback(this);
statusBarScrim.setAlpha(scrimAlpha);
}
ViewCompat.postInvalidateOnAnimation(this);
}
}
@Override
protected void drawableStateChanged() {
super.drawableStateChanged();
final int[] state = getDrawableState();
boolean changed = false;
Drawable d = statusBarScrim;
if (d != null && d.isStateful()) {
changed |= d.setState(state);
}
d = contentScrim;
if (d != null && d.isStateful()) {
changed |= d.setState(state);
}
if (collapsingTextHelper != null) {
changed |= collapsingTextHelper.setState(state);
}
if (changed) {
invalidate();
}
}
@Override
protected boolean verifyDrawable(Drawable who) {
return super.verifyDrawable(who) || who == contentScrim || who == statusBarScrim;
}
@Override
public void setVisibility(int visibility) {
super.setVisibility(visibility);
final boolean visible = visibility == VISIBLE;
if (statusBarScrim != null && statusBarScrim.isVisible() != visible) {
statusBarScrim.setVisible(visible, false);
}
if (contentScrim != null && contentScrim.isVisible() != visible) {
contentScrim.setVisible(visible, false);
}
}
/**
* Set the color to use for the status bar scrim.
*
*
This scrim is only shown when we have been given a top system inset.
*
* @param color the color to display
* @attr ref R.styleable#SubtitleCollapsingToolbarLayout_statusBarScrim
* @see #getStatusBarScrim()
*/
public void setStatusBarScrimColor(@ColorInt int color) {
setStatusBarScrim(new ColorDrawable(color));
}
/**
* Set the drawable to use for the content scrim from resources.
*
* @param resId drawable resource id
* @attr ref R.styleable#SubtitleCollapsingToolbarLayout_statusBarScrim
* @see #getStatusBarScrim()
*/
public void setStatusBarScrimResource(@DrawableRes int resId) {
setStatusBarScrim(ContextCompat.getDrawable(getContext(), resId));
}
/**
* Returns the drawable which is used for the status bar scrim.
*
* @attr ref R.styleable#SubtitleCollapsingToolbarLayout_statusBarScrim
* @see #setStatusBarScrim(Drawable)
*/
@Nullable
public Drawable getStatusBarScrim() {
return statusBarScrim;
}
/**
* Sets the text color and size for the collapsed title from the specified TextAppearance
* resource.
*
* @attr ref com.google.android.material.R.styleable#SubtitleCollapsingToolbarLayout_collapsedTitleTextAppearance
*/
public void setCollapsedTitleTextAppearance(@StyleRes int resId) {
collapsingTextHelper.setCollapsedTitleTextAppearance(resId);
}
/**
* Sets the text color of the collapsed title.
*
* @param color The new text color in ARGB format
*/
public void setCollapsedTitleTextColor(@ColorInt int color) {
setCollapsedTitleTextColor(ColorStateList.valueOf(color));
}
/**
* Sets the text colors of the collapsed title.
*
* @param colors ColorStateList containing the new text colors
*/
public void setCollapsedTitleTextColor(@NonNull ColorStateList colors) {
collapsingTextHelper.setCollapsedTitleTextColor(colors);
}
/**
* Sets the text color and size for the collapsed subtitle from the specified TextAppearance
* resource.
*
* @attr ref com.google.android.material.R.styleable#SubtitleCollapsingToolbarLayout_collapsedSubtitleTextAppearance
*/
public void setCollapsedSubtitleTextAppearance(@StyleRes int resId) {
collapsingTextHelper.setCollapsedSubtitleTextAppearance(resId);
}
/**
* Sets the text color of the collapsed subtitle.
*
* @param color The new text color in ARGB format
*/
public void setCollapsedSubtitleTextColor(@ColorInt int color) {
setCollapsedSubtitleTextColor(ColorStateList.valueOf(color));
}
/**
* Sets the text colors of the collapsed subtitle.
*
* @param colors ColorStateList containing the new text colors
*/
public void setCollapsedSubtitleTextColor(@NonNull ColorStateList colors) {
collapsingTextHelper.setCollapsedSubtitleTextColor(colors);
}
/**
* Sets the horizontal alignment of the collapsed title and the vertical gravity that will be used
* when there is extra space in the collapsed bounds beyond what is required for the title itself.
*
* @attr ref com.google.android.material.R.styleable#SubtitleCollapsingToolbarLayout_collapsedTitleGravity
*/
public void setCollapsedTitleGravity(int gravity) {
collapsingTextHelper.setCollapsedTextGravity(gravity);
}
/**
* Returns the horizontal and vertical alignment for title when collapsed.
*
* @attr ref com.google.android.material.R.styleable#SubtitleCollapsingToolbarLayout_collapsedTitleGravity
*/
public int getCollapsedTitleGravity() {
return collapsingTextHelper.getCollapsedTextGravity();
}
/**
* Sets the text color and size for the expanded title from the specified TextAppearance resource.
*
* @attr ref com.google.android.material.R.styleable#SubtitleCollapsingToolbarLayout_expandedTitleTextAppearance
*/
public void setExpandedTitleTextAppearance(@StyleRes int resId) {
collapsingTextHelper.setExpandedTitleTextAppearance(resId);
}
/**
* Sets the text color of the expanded title.
*
* @param color The new text color in ARGB format
*/
public void setExpandedTitleTextColor(@ColorInt int color) {
setExpandedTitleTextColor(ColorStateList.valueOf(color));
}
/**
* Sets the text colors of the expanded title.
*
* @param colors ColorStateList containing the new text colors
*/
public void setExpandedTitleTextColor(@NonNull ColorStateList colors) {
collapsingTextHelper.setExpandedTitleTextColor(colors);
}
/**
* Sets the text color and size for the expanded subtitle from the specified TextAppearance resource.
*
* @attr ref com.google.android.material.R.styleable#SubtitleCollapsingToolbarLayout_expandedSubtitleTextAppearance
*/
public void setExpandedSubtitleTextAppearance(@StyleRes int resId) {
collapsingTextHelper.setExpandedSubtitleTextAppearance(resId);
}
/**
* Sets the text color of the expanded subtitle.
*
* @param color The new text color in ARGB format
*/
public void setExpandedSubtitleTextColor(@ColorInt int color) {
setExpandedSubtitleTextColor(ColorStateList.valueOf(color));
}
/**
* Sets the text colors of the expanded subtitle.
*
* @param colors ColorStateList containing the new text colors
*/
public void setExpandedSubtitleTextColor(@NonNull ColorStateList colors) {
collapsingTextHelper.setExpandedSubtitleTextColor(colors);
}
/**
* Sets the horizontal alignment of the expanded title and the vertical gravity that will be used
* when there is extra space in the expanded bounds beyond what is required for the title itself.
*
* @attr ref com.google.android.material.R.styleable#SubtitleCollapsingToolbarLayout_expandedTitleGravity
*/
public void setExpandedTitleGravity(int gravity) {
collapsingTextHelper.setExpandedTextGravity(gravity);
}
/**
* Returns the horizontal and vertical alignment for title when expanded.
*
* @attr ref com.google.android.material.R.styleable#SubtitleCollapsingToolbarLayout_expandedTitleGravity
*/
public int getExpandedTitleGravity() {
return collapsingTextHelper.getExpandedTextGravity();
}
/**
* Set the typeface to use for the collapsed title.
*
* @param typeface typeface to use, or {@code null} to use the default.
*/
public void setCollapsedTitleTypeface(@Nullable Typeface typeface) {
collapsingTextHelper.setCollapsedTitleTypeface(typeface);
}
/**
* Returns the typeface used for the collapsed title.
*/
@NonNull
public Typeface getCollapsedTitleTypeface() {
return collapsingTextHelper.getCollapsedTitleTypeface();
}
/**
* Set the typeface to use for the expanded title.
*
* @param typeface typeface to use, or {@code null} to use the default.
*/
public void setExpandedTitleTypeface(@Nullable Typeface typeface) {
collapsingTextHelper.setExpandedTitleTypeface(typeface);
}
/**
* Returns the typeface used for the expanded title.
*/
@NonNull
public Typeface getExpandedTitleTypeface() {
return collapsingTextHelper.getExpandedTitleTypeface();
}
/**
* Set the typeface to use for the collapsed title.
*
* @param typeface typeface to use, or {@code null} to use the default.
*/
public void setCollapsedSubtitleTypeface(@Nullable Typeface typeface) {
collapsingTextHelper.setCollapsedSubtitleTypeface(typeface);
}
/**
* Returns the typeface used for the collapsed title.
*/
@NonNull
public Typeface getCollapsedSubtitleTypeface() {
return collapsingTextHelper.getCollapsedSubtitleTypeface();
}
/**
* Set the typeface to use for the expanded title.
*
* @param typeface typeface to use, or {@code null} to use the default.
*/
public void setExpandedSubtitleTypeface(@Nullable Typeface typeface) {
collapsingTextHelper.setExpandedSubtitleTypeface(typeface);
}
/**
* Returns the typeface used for the expanded title.
*/
@NonNull
public Typeface getExpandedSubtitleTypeface() {
return collapsingTextHelper.getExpandedSubtitleTypeface();
}
/**
* Sets the expanded title margins.
*
* @param start the starting title margin in pixels
* @param top the top title margin in pixels
* @param end the ending title margin in pixels
* @param bottom the bottom title margin in pixels
* @attr ref com.google.android.material.R.styleable#SubtitleCollapsingToolbarLayout_expandedTitleMargin
* @see #getExpandedTitleMarginStart()
* @see #getExpandedTitleMarginTop()
* @see #getExpandedTitleMarginEnd()
* @see #getExpandedTitleMarginBottom()
*/
public void setExpandedTitleMargin(int start, int top, int end, int bottom) {
expandedMarginStart = start;
expandedMarginTop = top;
expandedMarginEnd = end;
expandedMarginBottom = bottom;
requestLayout();
}
/**
* @return the starting expanded title margin in pixels
* @attr ref com.google.android.material.R.styleable#SubtitleCollapsingToolbarLayout_expandedTitleMarginStart
* @see #setExpandedTitleMarginStart(int)
*/
public int getExpandedTitleMarginStart() {
return expandedMarginStart;
}
/**
* Sets the starting expanded title margin in pixels.
*
* @param margin the starting title margin in pixels
* @attr ref com.google.android.material.R.styleable#SubtitleCollapsingToolbarLayout_expandedTitleMarginStart
* @see #getExpandedTitleMarginStart()
*/
public void setExpandedTitleMarginStart(int margin) {
expandedMarginStart = margin;
requestLayout();
}
/**
* @return the top expanded title margin in pixels
* @attr ref com.google.android.material.R.styleable#SubtitleCollapsingToolbarLayout_expandedTitleMarginTop
* @see #setExpandedTitleMarginTop(int)
*/
public int getExpandedTitleMarginTop() {
return expandedMarginTop;
}
/**
* Sets the top expanded title margin in pixels.
*
* @param margin the top title margin in pixels
* @attr ref com.google.android.material.R.styleable#SubtitleCollapsingToolbarLayout_expandedTitleMarginTop
* @see #getExpandedTitleMarginTop()
*/
public void setExpandedTitleMarginTop(int margin) {
expandedMarginTop = margin;
requestLayout();
}
/**
* @return the ending expanded title margin in pixels
* @attr ref com.google.android.material.R.styleable#SubtitleCollapsingToolbarLayout_expandedTitleMarginEnd
* @see #setExpandedTitleMarginEnd(int)
*/
public int getExpandedTitleMarginEnd() {
return expandedMarginEnd;
}
/**
* Sets the ending expanded title margin in pixels.
*
* @param margin the ending title margin in pixels
* @attr ref com.google.android.material.R.styleable#SubtitleCollapsingToolbarLayout_expandedTitleMarginEnd
* @see #getExpandedTitleMarginEnd()
*/
public void setExpandedTitleMarginEnd(int margin) {
expandedMarginEnd = margin;
requestLayout();
}
/**
* @return the bottom expanded title margin in pixels
* @attr ref com.google.android.material.R.styleable#SubtitleCollapsingToolbarLayout_expandedTitleMarginBottom
* @see #setExpandedTitleMarginBottom(int)
*/
public int getExpandedTitleMarginBottom() {
return expandedMarginBottom;
}
/**
* Sets the bottom expanded title margin in pixels.
*
* @param margin the bottom title margin in pixels
* @attr ref com.google.android.material.R.styleable#SubtitleCollapsingToolbarLayout_expandedTitleMarginBottom
* @see #getExpandedTitleMarginBottom()
*/
public void setExpandedTitleMarginBottom(int margin) {
expandedMarginBottom = margin;
requestLayout();
}
/**
* Sets whether {@code TextDirectionHeuristics} should be used to determine whether the title text
* is RTL. Experimental Feature.
*/
public void setRtlTextDirectionHeuristicsEnabled(boolean rtlTextDirectionHeuristicsEnabled) {
collapsingTextHelper.setRtlTextDirectionHeuristicsEnabled(rtlTextDirectionHeuristicsEnabled);
}
/**
* Gets whether {@code TextDirectionHeuristics} should be used to determine whether the title text
* is RTL. Experimental Feature.
*/
public boolean isRtlTextDirectionHeuristicsEnabled() {
return collapsingTextHelper.isRtlTextDirectionHeuristicsEnabled();
}
/**
* Set the amount of visible height in pixels used to define when to trigger a scrim visibility
* change.
*
*
If the visible height of this view is less than the given value, the scrims will be made
* visible, otherwise they are hidden.
*
* @param height value in pixels used to define when to trigger a scrim visibility change
* @attr ref com.google.android.material.R.styleable#SubtitleCollapsingToolbarLayout_expandedTitleMarginEnd
*/
public void setScrimVisibleHeightTrigger(@IntRange(from = 0) final int height) {
if (scrimVisibleHeightTrigger != height) {
scrimVisibleHeightTrigger = height;
// Update the scrim visibility
updateScrimVisibility();
}
}
/**
* Returns the amount of visible height in pixels used to define when to trigger a scrim
* visibility change.
*
* @see #setScrimVisibleHeightTrigger(int)
*/
public int getScrimVisibleHeightTrigger() {
if (scrimVisibleHeightTrigger >= 0) {
// If we have one explicitly set, return it
return scrimVisibleHeightTrigger;
}
// Otherwise we'll use the default computed value
final int insetTop = lastInsets != null ? lastInsets.getSystemWindowInsetTop() : 0;
final int minHeight = ViewCompat.getMinimumHeight(this);
if (minHeight > 0) {
// If we have a minHeight set, lets use 2 * minHeight (capped at our height)
return Math.min((minHeight * 2) + insetTop, getHeight());
}
// If we reach here then we don't have a min height set. Instead we'll take a
// guess at 1/3 of our height being visible
return getHeight() / 3;
}
/**
* Set the duration used for scrim visibility animations.
*
* @param duration the duration to use in milliseconds
* @attr ref com.google.android.material.R.styleable#SubtitleCollapsingToolbarLayout_scrimAnimationDuration
*/
public void setScrimAnimationDuration(@IntRange(from = 0) final long duration) {
scrimAnimationDuration = duration;
}
/**
* Returns the duration in milliseconds used for scrim visibility animations.
*/
public long getScrimAnimationDuration() {
return scrimAnimationDuration;
}
@Override
protected boolean checkLayoutParams(ViewGroup.LayoutParams p) {
return p instanceof LayoutParams;
}
@Override
protected LayoutParams generateDefaultLayoutParams() {
return new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
}
@Override
public FrameLayout.LayoutParams generateLayoutParams(AttributeSet attrs) {
return new LayoutParams(getContext(), attrs);
}
@Override
protected FrameLayout.LayoutParams generateLayoutParams(ViewGroup.LayoutParams p) {
return new LayoutParams(p);
}
public static class LayoutParams extends CollapsingToolbarLayout.LayoutParams {
public LayoutParams(Context c, AttributeSet attrs) {
super(c, attrs);
}
public LayoutParams(int width, int height) {
super(width, height);
}
public LayoutParams(int width, int height, int gravity) {
super(width, height, gravity);
}
public LayoutParams(ViewGroup.LayoutParams p) {
super(p);
}
public LayoutParams(MarginLayoutParams source) {
super(source);
}
@RequiresApi(19)
public LayoutParams(FrameLayout.LayoutParams source) {
super(source);
}
}
/**
* Show or hide the scrims if needed
*/
final void updateScrimVisibility() {
if (contentScrim != null || statusBarScrim != null) {
setScrimsShown(getHeight() + currentOffset < getScrimVisibleHeightTrigger());
}
}
final int getMaxOffsetForPinChild(View child) {
final ViewOffsetHelper offsetHelper = getViewOffsetHelper(child);
final LayoutParams lp = (LayoutParams) child.getLayoutParams();
return getHeight() - offsetHelper.getLayoutTop() - child.getHeight() - lp.bottomMargin;
}
private void updateContentDescriptionFromTitle() {
// Set this layout's contentDescription to match the title if it's shown by CollapsingTextHelper
setContentDescription(getTitle());
}
private class OffsetUpdateListener implements AppBarLayout.OnOffsetChangedListener {
OffsetUpdateListener() {
}
@Override
public void onOffsetChanged(AppBarLayout layout, int verticalOffset) {
currentOffset = verticalOffset;
final int insetTop = lastInsets != null ? lastInsets.getSystemWindowInsetTop() : 0;
for (int i = 0, z = getChildCount(); i < z; i++) {
final View child = getChildAt(i);
final LayoutParams lp = (LayoutParams) child.getLayoutParams();
final ViewOffsetHelper offsetHelper = getViewOffsetHelper(child);
switch (lp.collapseMode) {
case LayoutParams.COLLAPSE_MODE_PIN:
offsetHelper.setTopAndBottomOffset(
MathUtils.clamp(-verticalOffset, 0, getMaxOffsetForPinChild(child)));
break;
case LayoutParams.COLLAPSE_MODE_PARALLAX:
offsetHelper.setTopAndBottomOffset(Math.round(-verticalOffset * lp.parallaxMult));
break;
default:
break;
}
}
// Show or hide the scrims if needed
updateScrimVisibility();
if (statusBarScrim != null && insetTop > 0) {
ViewCompat.postInvalidateOnAnimation(SubtitleCollapsingToolbarLayout.this);
}
// Update the collapsing text's fraction
final int expandRange = getHeight()
- ViewCompat.getMinimumHeight(SubtitleCollapsingToolbarLayout.this)
- insetTop;
collapsingTextHelper.setExpansionFraction(Math.abs(verticalOffset) / (float) expandRange);
}
}
}
================================================
FILE: app/src/main/java/com/google/android/material/internal/SubtitleCollapsingTextHelper.java
================================================
package com.google.android.material.internal;
import android.animation.TimeInterpolator;
import android.content.res.ColorStateList;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Typeface;
import android.os.Build;
import android.text.TextPaint;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.View;
import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.math.MathUtils;
import androidx.core.text.TextDirectionHeuristicsCompat;
import androidx.core.view.GravityCompat;
import androidx.core.view.ViewCompat;
import com.google.android.material.animation.AnimationUtils;
import com.google.android.material.resources.CancelableFontCallback;
import com.google.android.material.resources.TextAppearance;
/**
* Helper class for {@link com.google.android.material.appbar.SubtitleCollapsingToolbarLayout}.
*
* @see CollapsingTextHelper
*/
public final class SubtitleCollapsingTextHelper {
// Pre-JB-MR2 doesn't support HW accelerated canvas scaled title so we will workaround it
// by using our own texture
private static final boolean USE_SCALING_TEXTURE = Build.VERSION.SDK_INT < 18;
private static final boolean DEBUG_DRAW = false;
@NonNull
private static final Paint DEBUG_DRAW_PAINT;
static {
DEBUG_DRAW_PAINT = DEBUG_DRAW ? new Paint() : null;
if (DEBUG_DRAW_PAINT != null) {
DEBUG_DRAW_PAINT.setAntiAlias(true);
DEBUG_DRAW_PAINT.setColor(Color.MAGENTA);
}
}
private final View view;
private boolean drawTitle;
private float expandedFraction;
@NonNull
private final Rect expandedBounds;
@NonNull
private final Rect collapsedBounds;
@NonNull
private final RectF currentBounds;
private int expandedTextGravity = Gravity.CENTER_VERTICAL;
private int collapsedTextGravity = Gravity.CENTER_VERTICAL;
private float expandedTitleTextSize, expandedSubtitleTextSize = 15;
private float collapsedTitleTextSize, collapsedSubtitleTextSize = 15;
private ColorStateList expandedTitleTextColor, expandedSubtitleTextColor;
private ColorStateList collapsedTitleTextColor, collapsedSubtitleTextColor;
private float expandedTitleDrawY, expandedSubtitleDrawY;
private float collapsedTitleDrawY, collapsedSubtitleDrawY;
private float expandedTitleDrawX, expandedSubtitleDrawX;
private float collapsedTitleDrawX, collapsedSubtitleDrawX;
private float currentTitleDrawX, currentSubtitleDrawX;
private float currentTitleDrawY, currentSubtitleDrawY;
private Typeface collapsedTitleTypeface, collapsedSubtitleTypeface;
private Typeface expandedTitleTypeface, expandedSubtitleTypeface;
private Typeface currentTitleTypeface, currentSubtitleTypeface;
private CancelableFontCallback expandedTitleFontCallback, expandedSubtitleFontCallback;
private CancelableFontCallback collapsedTitleFontCallback, collapsedSubtitleFontCallback;
@Nullable
private CharSequence title, subtitle;
@Nullable
private CharSequence titleToDraw, subtitleToDraw;
private boolean isRtl;
private boolean isRtlTextDirectionHeuristicsEnabled = true;
private boolean useTexture;
@Nullable
private Bitmap expandedTitleTexture, expandedSubtitleTexture;
private Paint titleTexturePaint, subtitleTexturePaint;
private float titleTextureAscent, subtitleTextureAscent;
private float titleTextureDescent, subtitleTextureDescent;
private float titleScale, subtitleScale;
private float currentTitleTextSize, currentSubtitleTextSize;
private int[] state;
private boolean boundsChanged;
@NonNull
private final TextPaint titleTextPaint, subtitleTextPaint;
@NonNull
private final TextPaint titleTmpPaint, subtitleTmpPaint;
private TimeInterpolator positionInterpolator;
private TimeInterpolator textSizeInterpolator;
private float collapsedTitleShadowRadius, collapsedSubtitleShadowRadius;
private float collapsedTitleShadowDx, collapsedSubtitleShadowDx;
private float collapsedTitleShadowDy, collapsedSubtitleShadowDy;
private ColorStateList collapsedTitleShadowColor, collapsedSubtitleShadowColor;
private float expandedTitleShadowRadius, expandedSubtitleShadowRadius;
private float expandedTitleShadowDx, expandedSubtitleShadowDx;
private float expandedTitleShadowDy, expandedSubtitleShadowDy;
private ColorStateList expandedTitleShadowColor, expandedSubtitleShadowColor;
public SubtitleCollapsingTextHelper(View view) {
this.view = view;
titleTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
titleTmpPaint = new TextPaint(titleTextPaint);
subtitleTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
subtitleTmpPaint = new TextPaint(subtitleTextPaint);
collapsedBounds = new Rect();
expandedBounds = new Rect();
currentBounds = new RectF();
}
public void setTextSizeInterpolator(TimeInterpolator interpolator) {
textSizeInterpolator = interpolator;
recalculate();
}
public void setPositionInterpolator(TimeInterpolator interpolator) {
positionInterpolator = interpolator;
recalculate();
}
public void setExpandedTitleTextSize(float textSize) {
if (expandedTitleTextSize != textSize) {
expandedTitleTextSize = textSize;
recalculate();
}
}
public void setCollapsedTitleTextSize(float textSize) {
if (collapsedTitleTextSize != textSize) {
collapsedTitleTextSize = textSize;
recalculate();
}
}
public void setExpandedSubtitleTextSize(float textSize) {
if (expandedSubtitleTextSize != textSize) {
expandedSubtitleTextSize = textSize;
recalculate();
}
}
public void setCollapsedSubtitleTextSize(float textSize) {
if (collapsedSubtitleTextSize != textSize) {
collapsedSubtitleTextSize = textSize;
recalculate();
}
}
public void setCollapsedTitleTextColor(ColorStateList textColor) {
if (collapsedTitleTextColor != textColor) {
collapsedTitleTextColor = textColor;
recalculate();
}
}
public void setExpandedTitleTextColor(ColorStateList textColor) {
if (expandedTitleTextColor != textColor) {
expandedTitleTextColor = textColor;
recalculate();
}
}
public void setCollapsedSubtitleTextColor(ColorStateList textColor) {
if (collapsedSubtitleTextColor != textColor) {
collapsedSubtitleTextColor = textColor;
recalculate();
}
}
public void setExpandedSubtitleTextColor(ColorStateList textColor) {
if (expandedSubtitleTextColor != textColor) {
expandedSubtitleTextColor = textColor;
recalculate();
}
}
public void setExpandedBounds(int left, int top, int right, int bottom) {
if (!rectEquals(expandedBounds, left, top, right, bottom)) {
expandedBounds.set(left, top, right, bottom);
boundsChanged = true;
onBoundsChanged();
}
}
public void setExpandedBounds(@NonNull Rect bounds) {
setExpandedBounds(bounds.left, bounds.top, bounds.right, bounds.bottom);
}
public void setCollapsedBounds(int left, int top, int right, int bottom) {
if (!rectEquals(collapsedBounds, left, top, right, bottom)) {
collapsedBounds.set(left, top, right, bottom);
boundsChanged = true;
onBoundsChanged();
}
}
public void setCollapsedBounds(@NonNull Rect bounds) {
setCollapsedBounds(bounds.left, bounds.top, bounds.right, bounds.bottom);
}
public void getCollapsedTitleTextActualBounds(@NonNull RectF bounds) {
boolean isRtl = calculateIsRtl(title);
bounds.left = !isRtl ? collapsedBounds.left : collapsedBounds.right - calculateCollapsedTitleTextWidth();
bounds.top = collapsedBounds.top;
bounds.right = !isRtl ? bounds.left + calculateCollapsedTitleTextWidth() : collapsedBounds.right;
bounds.bottom = collapsedBounds.top + getCollapsedTitleTextHeight();
}
public float calculateCollapsedTitleTextWidth() {
if (title == null) {
return 0;
}
getTitleTextPaintCollapsed(titleTmpPaint);
return titleTmpPaint.measureText(title, 0, title.length());
}
public void getCollapsedSubtitleTextActualBounds(@NonNull RectF bounds) {
boolean isRtl = calculateIsRtl(subtitle);
bounds.left = !isRtl ? collapsedBounds.left : collapsedBounds.right - calculateCollapsedSubtitleTextWidth();
bounds.top = collapsedBounds.top;
bounds.right = !isRtl ? bounds.left + calculateCollapsedSubtitleTextWidth() : collapsedBounds.right;
bounds.bottom = collapsedBounds.top + getCollapsedSubtitleTextHeight();
}
public float calculateCollapsedSubtitleTextWidth() {
if (subtitle == null) {
return 0;
}
getSubtitleTextPaintCollapsed(subtitleTmpPaint);
return subtitleTmpPaint.measureText(subtitle, 0, subtitle.length());
}
public float getExpandedTitleTextHeight() {
getTitleTextPaintExpanded(titleTmpPaint);
// Return expanded height measured from the baseline.
return -titleTmpPaint.ascent();
}
public float getCollapsedTitleTextHeight() {
getTitleTextPaintCollapsed(titleTmpPaint);
// Return collapsed height measured from the baseline.
return -titleTmpPaint.ascent();
}
public float getExpandedSubtitleTextHeight() {
getSubtitleTextPaintExpanded(subtitleTmpPaint);
// Return expanded height measured from the baseline.
return -subtitleTmpPaint.ascent();
}
public float getCollapsedSubtitleTextHeight() {
getSubtitleTextPaintCollapsed(subtitleTmpPaint);
// Return collapsed height measured from the baseline.
return -subtitleTmpPaint.ascent();
}
private void getTitleTextPaintExpanded(@NonNull TextPaint textPaint) {
textPaint.setTextSize(expandedTitleTextSize);
textPaint.setTypeface(expandedTitleTypeface);
}
private void getTitleTextPaintCollapsed(@NonNull TextPaint textPaint) {
textPaint.setTextSize(collapsedTitleTextSize);
textPaint.setTypeface(collapsedTitleTypeface);
}
private void getSubtitleTextPaintExpanded(@NonNull TextPaint textPaint) {
textPaint.setTextSize(expandedSubtitleTextSize);
textPaint.setTypeface(expandedSubtitleTypeface);
}
private void getSubtitleTextPaintCollapsed(@NonNull TextPaint textPaint) {
textPaint.setTextSize(collapsedSubtitleTextSize);
textPaint.setTypeface(collapsedSubtitleTypeface);
}
void onBoundsChanged() {
drawTitle = collapsedBounds.width() > 0
&& collapsedBounds.height() > 0
&& expandedBounds.width() > 0
&& expandedBounds.height() > 0;
}
public void setExpandedTextGravity(int gravity) {
if (expandedTextGravity != gravity) {
expandedTextGravity = gravity;
recalculate();
}
}
public int getExpandedTextGravity() {
return expandedTextGravity;
}
public void setCollapsedTextGravity(int gravity) {
if (collapsedTextGravity != gravity) {
collapsedTextGravity = gravity;
recalculate();
}
}
public int getCollapsedTextGravity() {
return collapsedTextGravity;
}
public void setCollapsedTitleTextAppearance(int resId) {
TextAppearance textAppearance = new TextAppearance(view.getContext(), resId);
if (textAppearance.getTextColor() != null) {
collapsedTitleTextColor = textAppearance.getTextColor();
}
if (textAppearance.getTextSize() != 0) {
collapsedTitleTextSize = textAppearance.getTextSize();
}
if (textAppearance.shadowColor != null) {
collapsedTitleShadowColor = textAppearance.shadowColor;
}
collapsedTitleShadowDx = textAppearance.shadowDx;
collapsedTitleShadowDy = textAppearance.shadowDy;
collapsedTitleShadowRadius = textAppearance.shadowRadius;
// Cancel pending async fetch, if any, and replace with a new one.
if (collapsedTitleFontCallback != null) {
collapsedTitleFontCallback.cancel();
}
collapsedTitleFontCallback = new CancelableFontCallback(new CancelableFontCallback.ApplyFont() {
@Override
public void apply(Typeface font) {
setCollapsedTitleTypeface(font);
}
}, textAppearance.getFallbackFont());
textAppearance.getFontAsync(view.getContext(), collapsedTitleFontCallback);
recalculate();
}
public void setExpandedTitleTextAppearance(int resId) {
TextAppearance textAppearance = new TextAppearance(view.getContext(), resId);
if (textAppearance.getTextColor() != null) {
expandedTitleTextColor = textAppearance.getTextColor();
}
if (textAppearance.getTextSize() != 0) {
expandedTitleTextSize = textAppearance.getTextSize();
}
if (textAppearance.shadowColor != null) {
expandedTitleShadowColor = textAppearance.shadowColor;
}
expandedTitleShadowDx = textAppearance.shadowDx;
expandedTitleShadowDy = textAppearance.shadowDy;
expandedTitleShadowRadius = textAppearance.shadowRadius;
// Cancel pending async fetch, if any, and replace with a new one.
if (expandedTitleFontCallback != null) {
expandedTitleFontCallback.cancel();
}
expandedTitleFontCallback = new CancelableFontCallback(new CancelableFontCallback.ApplyFont() {
@Override
public void apply(Typeface font) {
setExpandedTitleTypeface(font);
}
}, textAppearance.getFallbackFont());
textAppearance.getFontAsync(view.getContext(), expandedTitleFontCallback);
recalculate();
}
public void setCollapsedSubtitleTextAppearance(int resId) {
TextAppearance textAppearance = new TextAppearance(view.getContext(), resId);
if (textAppearance.getTextColor() != null) {
collapsedSubtitleTextColor = textAppearance.getTextColor();
}
if (textAppearance.getTextSize() != 0) {
collapsedSubtitleTextSize = textAppearance.getTextSize();
}
if (textAppearance.shadowColor != null) {
collapsedSubtitleShadowColor = textAppearance.shadowColor;
}
collapsedSubtitleShadowDx = textAppearance.shadowDx;
collapsedSubtitleShadowDy = textAppearance.shadowDy;
collapsedSubtitleShadowRadius = textAppearance.shadowRadius;
// Cancel pending async fetch, if any, and replace with a new one.
if (collapsedSubtitleFontCallback != null) {
collapsedSubtitleFontCallback.cancel();
}
collapsedSubtitleFontCallback = new CancelableFontCallback(new CancelableFontCallback.ApplyFont() {
@Override
public void apply(Typeface font) {
setCollapsedSubtitleTypeface(font);
}
}, textAppearance.getFallbackFont());
textAppearance.getFontAsync(view.getContext(), collapsedSubtitleFontCallback);
recalculate();
}
public void setExpandedSubtitleTextAppearance(int resId) {
TextAppearance textAppearance = new TextAppearance(view.getContext(), resId);
if (textAppearance.getTextColor() != null) {
expandedSubtitleTextColor = textAppearance.getTextColor();
}
if (textAppearance.getTextSize() != 0) {
expandedSubtitleTextSize = textAppearance.getTextSize();
}
if (textAppearance.shadowColor != null) {
expandedSubtitleShadowColor = textAppearance.shadowColor;
}
expandedSubtitleShadowDx = textAppearance.shadowDx;
expandedSubtitleShadowDy = textAppearance.shadowDy;
expandedSubtitleShadowRadius = textAppearance.shadowRadius;
// Cancel pending async fetch, if any, and replace with a new one.
if (expandedSubtitleFontCallback != null) {
expandedSubtitleFontCallback.cancel();
}
expandedSubtitleFontCallback = new CancelableFontCallback(new CancelableFontCallback.ApplyFont() {
@Override
public void apply(Typeface font) {
if (font != null) setExpandedSubtitleTypeface(font);
}
}, null);
textAppearance.getFontAsync(view.getContext(), expandedSubtitleFontCallback);
recalculate();
}
public void setCollapsedTitleTypeface(Typeface typeface) {
if (setCollapsedTitleTypefaceInternal(typeface)) {
recalculate();
}
}
public void setExpandedTitleTypeface(Typeface typeface) {
if (setExpandedTitleTypefaceInternal(typeface)) {
recalculate();
}
}
public void setCollapsedSubtitleTypeface(Typeface typeface) {
if (setCollapsedSubtitleTypefaceInternal(typeface)) {
recalculate();
}
}
public void setExpandedSubtitleTypeface(Typeface typeface) {
if (setExpandedSubtitleTypefaceInternal(typeface)) {
recalculate();
}
}
public void setTitleTypefaces(Typeface typeface) {
boolean collapsedFontChanged = setCollapsedTitleTypefaceInternal(typeface);
boolean expandedFontChanged = setExpandedTitleTypefaceInternal(typeface);
if (collapsedFontChanged || expandedFontChanged) {
recalculate();
}
}
public void setSubtitleTypefaces(Typeface typeface) {
boolean collapsedFontChanged = setCollapsedSubtitleTypefaceInternal(typeface);
boolean expandedFontChanged = setExpandedSubtitleTypefaceInternal(typeface);
if (collapsedFontChanged || expandedFontChanged) {
recalculate();
}
}
@SuppressWarnings("ReferenceEquality") // Matches the Typeface comparison in TextView
private boolean setCollapsedTitleTypefaceInternal(Typeface typeface) {
// Explicit Typeface setting cancels pending async fetch, if any, to avoid old font overriding
// already updated one when async op comes back after a while.
if (collapsedTitleFontCallback != null) {
collapsedTitleFontCallback.cancel();
}
if (collapsedTitleTypeface != typeface) {
collapsedTitleTypeface = typeface;
return true;
}
return false;
}
@SuppressWarnings("ReferenceEquality") // Matches the Typeface comparison in TextView
private boolean setExpandedTitleTypefaceInternal(Typeface typeface) {
// Explicit Typeface setting cancels pending async fetch, if any, to avoid old font overriding
// already updated one when async op comes back after a while.
if (expandedTitleFontCallback != null) {
expandedTitleFontCallback.cancel();
}
if (expandedTitleTypeface != typeface) {
expandedTitleTypeface = typeface;
return true;
}
return false;
}
@SuppressWarnings("ReferenceEquality") // Matches the Typeface comparison in TextView
private boolean setCollapsedSubtitleTypefaceInternal(Typeface typeface) {
// Explicit Typeface setting cancels pending async fetch, if any, to avoid old font overriding
// already updated one when async op comes back after a while.
if (collapsedSubtitleFontCallback != null) {
collapsedSubtitleFontCallback.cancel();
}
if (collapsedSubtitleTypeface != typeface) {
collapsedSubtitleTypeface = typeface;
return true;
}
return false;
}
@SuppressWarnings("ReferenceEquality") // Matches the Typeface comparison in TextView
private boolean setExpandedSubtitleTypefaceInternal(Typeface typeface) {
// Explicit Typeface setting cancels pending async fetch, if any, to avoid old font overriding
// already updated one when async op comes back after a while.
if (expandedSubtitleFontCallback != null) {
expandedSubtitleFontCallback.cancel();
}
if (expandedSubtitleTypeface != typeface) {
expandedSubtitleTypeface = typeface;
return true;
}
return false;
}
public Typeface getCollapsedTitleTypeface() {
return collapsedTitleTypeface != null ? collapsedTitleTypeface : Typeface.DEFAULT;
}
public Typeface getExpandedTitleTypeface() {
return expandedTitleTypeface != null ? expandedTitleTypeface : Typeface.DEFAULT;
}
public Typeface getCollapsedSubtitleTypeface() {
return collapsedSubtitleTypeface != null ? collapsedSubtitleTypeface : Typeface.DEFAULT;
}
public Typeface getExpandedSubtitleTypeface() {
return expandedSubtitleTypeface != null ? expandedSubtitleTypeface : Typeface.DEFAULT;
}
/**
* Set the value indicating the current scroll value. This decides how much of the background will
* be displayed, as well as the title metrics/positioning.
*
*
A value of {@code 0.0} indicates that the layout is fully expanded. A value of {@code 1.0}
* indicates that the layout is fully collapsed.
*/
public void setExpansionFraction(float fraction) {
fraction = MathUtils.clamp(fraction, 0f, 1f);
if (fraction != expandedFraction) {
expandedFraction = fraction;
calculateCurrentOffsets();
}
}
public final boolean setState(final int[] state) {
this.state = state;
if (isStateful()) {
recalculate();
return true;
}
return false;
}
public final boolean isStateful() {
return (collapsedTitleTextColor != null && collapsedTitleTextColor.isStateful())
|| (expandedTitleTextColor != null && expandedTitleTextColor.isStateful());
}
public float getExpansionFraction() {
return expandedFraction;
}
public float getCollapsedTitleTextSize() {
return collapsedTitleTextSize;
}
public float getExpandedTitleTextSize() {
return expandedTitleTextSize;
}
public float getCollapsedSubtitleTextSize() {
return collapsedSubtitleTextSize;
}
public float getExpandedSubtitleTextSize() {
return expandedSubtitleTextSize;
}
public void setRtlTextDirectionHeuristicsEnabled(boolean rtlTextDirectionHeuristicsEnabled) {
isRtlTextDirectionHeuristicsEnabled = rtlTextDirectionHeuristicsEnabled;
}
public boolean isRtlTextDirectionHeuristicsEnabled() {
return isRtlTextDirectionHeuristicsEnabled;
}
private void calculateCurrentOffsets() {
calculateOffsets(expandedFraction);
}
private void calculateOffsets(final float fraction) {
interpolateBounds(fraction);
currentTitleDrawX = lerp(expandedTitleDrawX, collapsedTitleDrawX, fraction, positionInterpolator);
currentTitleDrawY = lerp(expandedTitleDrawY, collapsedTitleDrawY, fraction, positionInterpolator);
currentSubtitleDrawX = lerp(expandedSubtitleDrawX, collapsedSubtitleDrawX, fraction, positionInterpolator);
currentSubtitleDrawY = lerp(expandedSubtitleDrawY, collapsedSubtitleDrawY, fraction, positionInterpolator);
setInterpolatedTitleTextSize(lerp(expandedTitleTextSize, collapsedTitleTextSize, fraction, textSizeInterpolator));
setInterpolatedSubtitleTextSize(lerp(expandedSubtitleTextSize, collapsedSubtitleTextSize, fraction, textSizeInterpolator));
if (collapsedTitleTextColor != expandedTitleTextColor) {
// If the collapsed and expanded title colors are different, blend them based on the
// fraction
titleTextPaint.setColor(blendColors(getCurrentExpandedTitleTextColor(), getCurrentCollapsedTitleTextColor(), fraction));
} else {
titleTextPaint.setColor(getCurrentCollapsedTitleTextColor());
}
titleTextPaint.setShadowLayer(
lerp(expandedTitleShadowRadius, collapsedTitleShadowRadius, fraction, null),
lerp(expandedTitleShadowDx, collapsedTitleShadowDx, fraction, null),
lerp(expandedTitleShadowDy, collapsedTitleShadowDy, fraction, null),
blendColors(getCurrentColor(expandedTitleShadowColor), getCurrentColor(collapsedTitleShadowColor), fraction));
if (collapsedSubtitleTextColor != expandedSubtitleTextColor) {
// If the collapsed and expanded title colors are different, blend them based on the
// fraction
subtitleTextPaint.setColor(blendColors(getCurrentExpandedSubtitleTextColor(), getCurrentCollapsedSubtitleTextColor(), fraction));
} else {
subtitleTextPaint.setColor(getCurrentCollapsedSubtitleTextColor());
}
subtitleTextPaint.setShadowLayer(
lerp(expandedSubtitleShadowRadius, collapsedSubtitleShadowRadius, fraction, null),
lerp(expandedSubtitleShadowDx, collapsedSubtitleShadowDx, fraction, null),
lerp(expandedSubtitleShadowDy, collapsedSubtitleShadowDy, fraction, null),
blendColors(getCurrentColor(expandedSubtitleShadowColor), getCurrentColor(collapsedSubtitleShadowColor), fraction));
ViewCompat.postInvalidateOnAnimation(view);
}
@ColorInt
private int getCurrentExpandedTitleTextColor() {
return getCurrentColor(expandedTitleTextColor);
}
@ColorInt
private int getCurrentExpandedSubtitleTextColor() {
return getCurrentColor(expandedSubtitleTextColor);
}
@ColorInt
public int getCurrentCollapsedTitleTextColor() {
return getCurrentColor(collapsedTitleTextColor);
}
@ColorInt
public int getCurrentCollapsedSubtitleTextColor() {
return getCurrentColor(collapsedSubtitleTextColor);
}
@ColorInt
private int getCurrentColor(@Nullable ColorStateList colorStateList) {
if (colorStateList == null) {
return 0;
}
if (state != null) {
return colorStateList.getColorForState(state, 0);
}
return colorStateList.getDefaultColor();
}
private void calculateBaseOffsets() {
final float currentTitleSize = this.currentTitleTextSize;
final float currentSubtitleSize = this.currentSubtitleTextSize;
final boolean isTitleOnly = TextUtils.isEmpty(subtitle);
// We then calculate the collapsed title size, using the same logic
calculateUsingTitleTextSize(collapsedTitleTextSize);
calculateUsingSubtitleTextSize(collapsedSubtitleTextSize);
float titleWidth = titleToDraw != null ? titleTextPaint.measureText(titleToDraw, 0, titleToDraw.length()) : 0;
float subtitleWidth = subtitleToDraw != null ? subtitleTextPaint.measureText(subtitleToDraw, 0, subtitleToDraw.length()) : 0;
final int collapsedAbsGravity =
GravityCompat.getAbsoluteGravity(
collapsedTextGravity,
isRtl ? ViewCompat.LAYOUT_DIRECTION_RTL : ViewCompat.LAYOUT_DIRECTION_LTR);
// reusable dimension
float titleHeight = titleTextPaint.descent() - titleTextPaint.ascent();
float titleOffset = titleHeight / 2 - titleTextPaint.descent();
float subtitleHeight = subtitleTextPaint.descent() - subtitleTextPaint.ascent();
float subtitleOffset = subtitleHeight / 2 - subtitleTextPaint.descent();
if (isTitleOnly) {
switch (collapsedAbsGravity & Gravity.VERTICAL_GRAVITY_MASK) {
case Gravity.BOTTOM:
collapsedTitleDrawY = collapsedBounds.bottom;
break;
case Gravity.TOP:
collapsedTitleDrawY = collapsedBounds.top - titleTextPaint.ascent();
break;
case Gravity.CENTER_VERTICAL:
default:
float textHeight = titleTextPaint.descent() - titleTextPaint.ascent();
float textOffset = (textHeight / 2) - titleTextPaint.descent();
collapsedTitleDrawY = collapsedBounds.centerY() + textOffset;
break;
}
} else {
final float offset = (collapsedBounds.height() - (titleHeight + subtitleHeight)) / 3;
collapsedTitleDrawY = collapsedBounds.top + offset - titleTextPaint.ascent();
collapsedSubtitleDrawY = collapsedBounds.top + offset * 2 + titleHeight - subtitleTextPaint.ascent();
}
switch (collapsedAbsGravity & GravityCompat.RELATIVE_HORIZONTAL_GRAVITY_MASK) {
case Gravity.CENTER_HORIZONTAL:
collapsedTitleDrawX = collapsedBounds.centerX() - (titleWidth / 2);
collapsedSubtitleDrawX = collapsedBounds.centerX() - (subtitleWidth / 2);
break;
case Gravity.RIGHT:
collapsedTitleDrawX = collapsedBounds.right - titleWidth;
collapsedSubtitleDrawX = collapsedBounds.right - subtitleWidth;
break;
case Gravity.LEFT:
default:
collapsedTitleDrawX = collapsedBounds.left;
collapsedSubtitleDrawX = collapsedBounds.left;
break;
}
calculateUsingTitleTextSize(expandedTitleTextSize);
calculateUsingSubtitleTextSize(expandedSubtitleTextSize);
titleWidth = titleToDraw != null ? titleTextPaint.measureText(titleToDraw, 0, titleToDraw.length()) : 0;
subtitleWidth = subtitleToDraw != null ? subtitleTextPaint.measureText(subtitleToDraw, 0, subtitleToDraw.length()) : 0;
// dimension modification
titleHeight = titleTextPaint.descent() - titleTextPaint.ascent();
titleOffset = titleHeight / 2 - titleTextPaint.descent();
subtitleHeight = subtitleTextPaint.descent() - subtitleTextPaint.ascent();
subtitleOffset = subtitleHeight / 2 - subtitleTextPaint.descent();
final int expandedAbsGravity = GravityCompat.getAbsoluteGravity(
expandedTextGravity,
isRtl ? ViewCompat.LAYOUT_DIRECTION_RTL : ViewCompat.LAYOUT_DIRECTION_LTR
);
if (isTitleOnly) {
switch (expandedAbsGravity & Gravity.VERTICAL_GRAVITY_MASK) {
case Gravity.BOTTOM:
expandedTitleDrawY = expandedBounds.bottom;
break;
case Gravity.TOP:
expandedTitleDrawY = expandedBounds.top - titleTextPaint.ascent();
break;
case Gravity.CENTER_VERTICAL:
default:
float textHeight = titleTextPaint.descent() - titleTextPaint.ascent();
float textOffset = (textHeight / 2) - titleTextPaint.descent();
expandedTitleDrawY = expandedBounds.centerY() + textOffset;
break;
}
} else {
switch (expandedAbsGravity & Gravity.VERTICAL_GRAVITY_MASK) {
case Gravity.BOTTOM:
expandedTitleDrawY = expandedBounds.bottom - subtitleHeight - titleOffset;
expandedSubtitleDrawY = expandedBounds.bottom;
break;
case Gravity.TOP:
expandedTitleDrawY = expandedBounds.top - titleTextPaint.ascent();
expandedSubtitleDrawY = expandedTitleDrawY + subtitleHeight + titleOffset;
break;
case Gravity.CENTER_VERTICAL:
default:
expandedTitleDrawY = expandedBounds.centerY() + titleOffset;
expandedSubtitleDrawY = expandedTitleDrawY + subtitleHeight + titleOffset;
break;
}
}
switch (expandedAbsGravity & GravityCompat.RELATIVE_HORIZONTAL_GRAVITY_MASK) {
case Gravity.CENTER_HORIZONTAL:
expandedTitleDrawX = expandedBounds.centerX() - (titleWidth / 2);
expandedSubtitleDrawX = expandedBounds.centerX() - (subtitleWidth / 2);
break;
case Gravity.RIGHT:
expandedTitleDrawX = expandedBounds.right - titleWidth;
expandedSubtitleDrawX = expandedBounds.right - subtitleWidth;
break;
case Gravity.LEFT:
default:
expandedTitleDrawX = expandedBounds.left;
expandedSubtitleDrawX = expandedBounds.left;
break;
}
// The bounds have changed so we need to clear the texture
clearTexture();
// Now reset the title size back to the original
setInterpolatedTitleTextSize(currentTitleSize);
setInterpolatedSubtitleTextSize(currentSubtitleSize);
}
private void interpolateBounds(float fraction) {
currentBounds.left = lerp(expandedBounds.left, collapsedBounds.left, fraction, positionInterpolator);
currentBounds.top = lerp(expandedTitleDrawY, collapsedTitleDrawY, fraction, positionInterpolator);
currentBounds.right = lerp(expandedBounds.right, collapsedBounds.right, fraction, positionInterpolator);
currentBounds.bottom = lerp(expandedBounds.bottom, collapsedBounds.bottom, fraction, positionInterpolator);
}
public void draw(@NonNull Canvas canvas) {
final int saveCount = canvas.save();
if (drawTitle && titleToDraw != null) {
float titleX = currentTitleDrawX;
float titleY = currentTitleDrawY;
float subtitleX = currentSubtitleDrawX;
float subtitleY = currentSubtitleDrawY;
final boolean drawTitleTexture = useTexture && expandedTitleTexture != null;
final boolean drawSubtitleTexture = useTexture && expandedSubtitleTexture != null;
final float titleAscent;
final float titleDescent;
if (drawTitleTexture) {
titleAscent = titleTextureAscent * titleScale;
titleDescent = titleTextureDescent * titleScale;
} else {
titleAscent = titleTextPaint.ascent() * titleScale;
titleDescent = titleTextPaint.descent() * titleScale;
}
if (DEBUG_DRAW) {
// Just a debug tool, which drawn a magenta rect in the text bounds
canvas.drawRect(currentBounds.left, titleY + titleAscent, currentBounds.right, titleY + titleDescent, DEBUG_DRAW_PAINT);
}
if (drawTitleTexture) {
titleY += titleAscent;
}
// additional canvas save for subtitle
if (subtitleToDraw != null) {
final int subtitleSaveCount = canvas.save();
if (subtitleScale != 1f) {
canvas.scale(subtitleScale, subtitleScale, subtitleX, subtitleY);
}
if (drawSubtitleTexture) {
// If we should use a texture, draw it instead of title
canvas.drawBitmap(expandedSubtitleTexture, subtitleX, subtitleY, subtitleTexturePaint);
} else {
canvas.drawText(subtitleToDraw, 0, subtitleToDraw.length(), subtitleX, subtitleY, subtitleTextPaint);
}
canvas.restoreToCount(subtitleSaveCount);
}
if (titleScale != 1f) {
canvas.scale(titleScale, titleScale, titleX, titleY);
}
if (drawTitleTexture) {
// If we should use a texture, draw it instead of text
canvas.drawBitmap(expandedTitleTexture, titleX, titleY, titleTexturePaint);
} else {
canvas.drawText(titleToDraw, 0, titleToDraw.length(), titleX, titleY, titleTextPaint);
}
}
canvas.restoreToCount(saveCount);
}
private boolean calculateIsRtl(@NonNull CharSequence text) {
final boolean defaultIsRtl = isDefaultIsRtl();
return isRtlTextDirectionHeuristicsEnabled
? isTextDirectionHeuristicsIsRtl(text, defaultIsRtl)
: defaultIsRtl;
}
private boolean isDefaultIsRtl() {
return ViewCompat.getLayoutDirection(view) == ViewCompat.LAYOUT_DIRECTION_RTL;
}
private boolean isTextDirectionHeuristicsIsRtl(@NonNull CharSequence text, boolean defaultIsRtl) {
return (defaultIsRtl
? TextDirectionHeuristicsCompat.FIRSTSTRONG_RTL
: TextDirectionHeuristicsCompat.FIRSTSTRONG_LTR)
.isRtl(text, 0, text.length());
}
private void setInterpolatedTitleTextSize(float textSize) {
calculateUsingTitleTextSize(textSize);
// Use our texture if the scale isn't 1.0
useTexture = USE_SCALING_TEXTURE && titleScale != 1f;
if (useTexture) {
// Make sure we have an expanded texture if needed
ensureExpandedTitleTexture();
}
ViewCompat.postInvalidateOnAnimation(view);
}
private void setInterpolatedSubtitleTextSize(float textSize) {
calculateUsingSubtitleTextSize(textSize);
// Use our texture if the scale isn't 1.0
useTexture = USE_SCALING_TEXTURE && subtitleScale != 1f;
if (useTexture) {
// Make sure we have an expanded texture if needed
ensureExpandedSubtitleTexture();
}
ViewCompat.postInvalidateOnAnimation(view);
}
@SuppressWarnings("ReferenceEquality") // Matches the Typeface comparison in TextView
private void calculateUsingTitleTextSize(final float size) {
if (title == null) {
return;
}
final float collapsedWidth = collapsedBounds.width();
final float expandedWidth = expandedBounds.width();
final float availableWidth;
final float newTextSize;
boolean updateDrawText = false;
if (isClose(size, collapsedTitleTextSize)) {
newTextSize = collapsedTitleTextSize;
titleScale = 1f;
if (currentTitleTypeface != collapsedTitleTypeface) {
currentTitleTypeface = collapsedTitleTypeface;
updateDrawText = true;
}
availableWidth = collapsedWidth;
} else {
newTextSize = expandedTitleTextSize;
if (currentTitleTypeface != expandedTitleTypeface) {
currentTitleTypeface = expandedTitleTypeface;
updateDrawText = true;
}
if (isClose(size, expandedTitleTextSize)) {
// If we're close to the expanded title size, snap to it and use a scale of 1
titleScale = 1f;
} else {
// Else, we'll scale down from the expanded title size
titleScale = size / expandedTitleTextSize;
}
final float textSizeRatio = collapsedTitleTextSize / expandedTitleTextSize;
// This is the size of the expanded bounds when it is scaled to match the
// collapsed title size
final float scaledDownWidth = expandedWidth * textSizeRatio;
if (scaledDownWidth > collapsedWidth) {
// If the scaled down size is larger than the actual collapsed width, we need to
// cap the available width so that when the expanded title scales down, it matches
// the collapsed width
availableWidth = Math.min(collapsedWidth / textSizeRatio, expandedWidth);
} else {
// Otherwise we'll just use the expanded width
availableWidth = expandedWidth;
}
}
if (availableWidth > 0) {
updateDrawText = (currentTitleTextSize != newTextSize) || boundsChanged || updateDrawText;
currentTitleTextSize = newTextSize;
boundsChanged = false;
}
if (titleToDraw == null || updateDrawText) {
titleTextPaint.setTextSize(currentTitleTextSize);
titleTextPaint.setTypeface(currentTitleTypeface);
// Use linear title scaling if we're scaling the canvas
titleTextPaint.setLinearText(titleScale != 1f);
// If we don't currently have title to draw, or the title size has changed, ellipsize...
final CharSequence text =
TextUtils
.ellipsize(this.title, titleTextPaint, availableWidth, TextUtils.TruncateAt.END);
if (!TextUtils.equals(text, titleToDraw)) {
titleToDraw = text;
isRtl = calculateIsRtl(titleToDraw);
}
}
}
@SuppressWarnings("ReferenceEquality") // Matches the Typeface comparison in TextView
private void calculateUsingSubtitleTextSize(final float size) {
if (subtitle == null) {
return;
}
final float collapsedWidth = collapsedBounds.width();
final float expandedWidth = expandedBounds.width();
final float availableWidth;
final float newTextSize;
boolean updateDrawText = false;
if (isClose(size, collapsedSubtitleTextSize)) {
newTextSize = collapsedSubtitleTextSize;
subtitleScale = 1f;
if (currentSubtitleTypeface != collapsedSubtitleTypeface) {
currentSubtitleTypeface = collapsedSubtitleTypeface;
updateDrawText = true;
}
availableWidth = collapsedWidth;
} else {
newTextSize = expandedSubtitleTextSize;
if (currentSubtitleTypeface != expandedSubtitleTypeface) {
currentSubtitleTypeface = expandedSubtitleTypeface;
updateDrawText = true;
}
if (isClose(size, expandedSubtitleTextSize)) {
// If we're close to the expanded title size, snap to it and use a scale of 1
subtitleScale = 1f;
} else {
// Else, we'll scale down from the expanded title size
subtitleScale = size / expandedSubtitleTextSize;
}
final float textSizeRatio = collapsedSubtitleTextSize / expandedSubtitleTextSize;
// This is the size of the expanded bounds when it is scaled to match the
// collapsed title size
final float scaledDownWidth = expandedWidth * textSizeRatio;
if (scaledDownWidth > collapsedWidth) {
// If the scaled down size is larger than the actual collapsed width, we need to
// cap the available width so that when the expanded title scales down, it matches
// the collapsed width
availableWidth = Math.min(collapsedWidth / textSizeRatio, expandedWidth);
} else {
// Otherwise we'll just use the expanded width
availableWidth = expandedWidth;
}
}
if (availableWidth > 0) {
updateDrawText = (currentSubtitleTextSize != newTextSize) || boundsChanged || updateDrawText;
currentSubtitleTextSize = newTextSize;
boundsChanged = false;
}
if (subtitleToDraw == null || updateDrawText) {
subtitleTextPaint.setTextSize(currentSubtitleTextSize);
subtitleTextPaint.setTypeface(currentSubtitleTypeface);
// Use linear title scaling if we're scaling the canvas
subtitleTextPaint.setLinearText(subtitleScale != 1f);
// If we don't currently have title to draw, or the title size has changed, ellipsize...
final CharSequence text =
TextUtils.ellipsize(this.subtitle, subtitleTextPaint, availableWidth, TextUtils.TruncateAt.END);
if (!TextUtils.equals(text, subtitleToDraw)) {
subtitleToDraw = text;
isRtl = calculateIsRtl(subtitleToDraw);
}
}
}
private void ensureExpandedTitleTexture() {
if (expandedTitleTexture != null || expandedBounds.isEmpty() || TextUtils.isEmpty(titleToDraw)) {
return;
}
calculateOffsets(0f);
titleTextureAscent = titleTextPaint.ascent();
titleTextureDescent = titleTextPaint.descent();
final int w = Math.round(titleTextPaint.measureText(titleToDraw, 0, titleToDraw.length()));
final int h = Math.round(titleTextureDescent - titleTextureAscent);
if (w <= 0 || h <= 0) {
return; // If the width or height are 0, return
}
expandedTitleTexture = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(expandedTitleTexture);
c.drawText(titleToDraw, 0, titleToDraw.length(), 0, h - titleTextPaint.descent(), titleTextPaint);
if (titleTexturePaint == null) {
// Make sure we have a paint
titleTexturePaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
}
}
private void ensureExpandedSubtitleTexture() {
if (expandedSubtitleTexture != null || expandedBounds.isEmpty() || TextUtils.isEmpty(subtitleToDraw)) {
return;
}
calculateOffsets(0f);
subtitleTextureAscent = subtitleTextPaint.ascent();
subtitleTextureDescent = subtitleTextPaint.descent();
final int w = Math.round(subtitleTextPaint.measureText(subtitleToDraw, 0, subtitleToDraw.length()));
final int h = Math.round(subtitleTextureDescent - subtitleTextureAscent);
if (w <= 0 || h <= 0) {
return; // If the width or height are 0, return
}
expandedSubtitleTexture = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(expandedSubtitleTexture);
c.drawText(subtitleToDraw, 0, subtitleToDraw.length(), 0, h - subtitleTextPaint.descent(), subtitleTextPaint);
if (subtitleTexturePaint == null) {
// Make sure we have a paint
subtitleTexturePaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
}
}
public void recalculate() {
if (view.getHeight() > 0 && view.getWidth() > 0) {
// If we've already been laid out, calculate everything now otherwise we'll wait
// until a layout
calculateBaseOffsets();
calculateCurrentOffsets();
}
}
/**
* Set the title to display
*
* @param title
*/
public void setTitle(@Nullable CharSequence title) {
if (title == null || !title.equals(this.title)) {
this.title = title;
titleToDraw = null;
clearTexture();
recalculate();
}
}
@Nullable
public CharSequence getTitle() {
return title;
}
/**
* Set the subtitle to display
*
* @param subtitle
*/
public void setSubtitle(@Nullable CharSequence subtitle) {
if (subtitle == null || !subtitle.equals(this.subtitle)) {
this.subtitle = subtitle;
subtitleToDraw = null;
clearTexture();
recalculate();
}
}
@Nullable
public CharSequence getSubtitle() {
return subtitle;
}
private void clearTexture() {
if (expandedTitleTexture != null) {
expandedTitleTexture.recycle();
expandedTitleTexture = null;
}
if (expandedSubtitleTexture != null) {
expandedSubtitleTexture.recycle();
expandedSubtitleTexture = null;
}
}
/**
* Returns true if {@code value} is 'close' to it's closest decimal value. Close is currently
* defined as it's difference being < 0.001.
*/
private static boolean isClose(float value, float targetValue) {
return Math.abs(value - targetValue) < 0.001f;
}
public ColorStateList getExpandedTitleTextColor() {
return expandedTitleTextColor;
}
public ColorStateList getExpandedSubtitleTextColor() {
return expandedSubtitleTextColor;
}
public ColorStateList getCollapsedTitleTextColor() {
return collapsedTitleTextColor;
}
public ColorStateList getCollapsedSubtitleTextColor() {
return collapsedSubtitleTextColor;
}
/**
* Blend {@code color1} and {@code color2} using the given ratio.
*
* @param ratio of which to blend. 0.0 will return {@code color1}, 0.5 will give an even blend,
* 1.0 will return {@code color2}.
*/
private static int blendColors(int color1, int color2, float ratio) {
final float inverseRatio = 1f - ratio;
float a = (Color.alpha(color1) * inverseRatio) + (Color.alpha(color2) * ratio);
float r = (Color.red(color1) * inverseRatio) + (Color.red(color2) * ratio);
float g = (Color.green(color1) * inverseRatio) + (Color.green(color2) * ratio);
float b = (Color.blue(color1) * inverseRatio) + (Color.blue(color2) * ratio);
return Color.argb((int) a, (int) r, (int) g, (int) b);
}
private static float lerp(
float startValue, float endValue, float fraction, @Nullable TimeInterpolator interpolator) {
if (interpolator != null) {
fraction = interpolator.getInterpolation(fraction);
}
return AnimationUtils.lerp(startValue, endValue, fraction);
}
private static boolean rectEquals(@NonNull Rect r, int left, int top, int right, int bottom) {
return !(r.left != left || r.top != top || r.right != right || r.bottom != bottom);
}
}
================================================
FILE: app/src/main/java/org/lsposed/manager/App.java
================================================
/*
* This file is part of LSPosed.
*
* LSPosed is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LSPosed is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LSPosed. If not, see .
*
* Copyright (C) 2020 EdXposed Contributors
* Copyright (C) 2021 LSPosed Contributors
*/
package org.lsposed.manager;
import android.app.ActivityManager;
import android.app.Application;
import android.content.BroadcastReceiver;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Environment;
import android.os.Handler;
import android.os.Looper;
import android.os.Process;
import android.provider.MediaStore;
import android.provider.Settings;
import android.system.Os;
import android.text.TextUtils;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.preference.PreferenceManager;
import org.lsposed.hiddenapibypass.HiddenApiBypass;
import org.lsposed.manager.adapters.AppHelper;
import org.lsposed.manager.receivers.LSPManagerServiceHolder;
import org.lsposed.manager.repo.RepoLoader;
import org.lsposed.manager.util.CloudflareDNS;
import org.lsposed.manager.util.ModuleUtil;
import org.lsposed.manager.util.ThemeUtil;
import org.lsposed.manager.util.UpdateUtil;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.nio.charset.StandardCharsets;
import java.time.OffsetDateTime;
import java.util.HashMap;
import java.util.Locale;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.FutureTask;
import okhttp3.Cache;
import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;
import rikka.core.os.FileUtils;
import rikka.material.app.LocaleDelegate;
public class App extends Application {
public static final int PER_USER_RANGE = 100000;
public static final FutureTask HTML_TEMPLATE = new FutureTask<>(() -> readWebviewHTML("template.html"));
public static final FutureTask HTML_TEMPLATE_DARK = new FutureTask<>(() -> readWebviewHTML("template_dark.html"));
private static String readWebviewHTML(String name) {
try {
var input = App.getInstance().getAssets().open("webview/" + name);
var result = new ByteArrayOutputStream(1024);
FileUtils.copy(input, result);
return result.toString(StandardCharsets.UTF_8.name());
} catch (IOException e) {
Log.e(App.TAG, "read webview HTML", e);
return "@body@";
}
}
static {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
HiddenApiBypass.addHiddenApiExemptions("");
}
Looper.myQueue().addIdleHandler(() -> {
if (App.getInstance() == null || App.getExecutorService() == null) return true;
App.getExecutorService().submit(() -> {
var list = AppHelper.getAppList(false);
var pm = App.getInstance().getPackageManager();
list.parallelStream().forEach(i -> AppHelper.getAppLabel(i, pm));
AppHelper.getDenyList(false);
ModuleUtil.getInstance();
RepoLoader.getInstance();
});
App.getExecutorService().submit(HTML_TEMPLATE);
App.getExecutorService().submit(HTML_TEMPLATE_DARK);
return false;
});
}
public static final String TAG = "LSPosedManager";
private static final String ACTION_USER_ADDED = "android.intent.action.USER_ADDED";
private static final String ACTION_USER_REMOVED = "android.intent.action.USER_REMOVED";
private static final String ACTION_USER_INFO_CHANGED = "android.intent.action.USER_INFO_CHANGED";
private static final String EXTRA_REMOVED_FOR_ALL_USERS = "android.intent.extra.REMOVED_FOR_ALL_USERS";
private static App instance = null;
private static OkHttpClient okHttpClient;
private static Cache okHttpCache;
private SharedPreferences pref;
private static final ExecutorService executorService = Executors.newCachedThreadPool();
private static final Handler MainHandler = new Handler(Looper.getMainLooper());
public static App getInstance() {
return instance;
}
public static SharedPreferences getPreferences() {
return instance.pref;
}
public static ExecutorService getExecutorService() {
return executorService;
}
public static final boolean isParasitic = !Process.isApplicationUid(Process.myUid());
public static Handler getMainHandler() {
return MainHandler;
}
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
var map = new HashMap(1);
map.put("isParasitic", String.valueOf(isParasitic));
var am = getSystemService(ActivityManager.class);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
map.clear();
var reasons = am.getHistoricalProcessExitReasons(null, 0, 1);
if (reasons.size() == 1) {
map.put("description", reasons.get(0).getDescription());
map.put("importance", String.valueOf(reasons.get(0).getImportance()));
map.put("process", reasons.get(0).getProcessName());
map.put("reason", String.valueOf(reasons.get(0).getReason()));
map.put("status", String.valueOf(reasons.get(0).getStatus()));
}
}
}
private void setCrashReport() {
var handler = Thread.getDefaultUncaughtExceptionHandler();
Thread.setDefaultUncaughtExceptionHandler((thread, throwable) -> {
var time = OffsetDateTime.now();
var dir = new File(getCacheDir(), "crash");
//noinspection ResultOfMethodCallIgnored
dir.mkdir();
var file = new File(dir, time.toEpochSecond() + ".log");
try (var pw = new PrintWriter(file)) {
pw.println(BuildConfig.VERSION_NAME + " (" + BuildConfig.VERSION_CODE + ")");
pw.println(time);
pw.println("pid: " + Os.getpid() + " uid: " + Os.getuid());
throwable.printStackTrace(pw);
} catch (IOException ignored) {
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
var table = MediaStore.Downloads.getContentUri(MediaStore.VOLUME_EXTERNAL_PRIMARY);
var values = new ContentValues();
values.put(MediaStore.Downloads.DISPLAY_NAME, "LSPosed_crash_report" + time.toEpochSecond() + ".zip");
values.put(MediaStore.Downloads.RELATIVE_PATH, Environment.DIRECTORY_DOCUMENTS);
var cr = getContentResolver();
var uri = cr.insert(table, values);
if (uri == null) return;
try (var zipFd = cr.openFileDescriptor(uri, "wt")) {
LSPManagerServiceHolder.getService().getLogs(zipFd);
} catch (Exception ignored) {
cr.delete(uri, null, null);
}
}
if (handler != null) {
handler.uncaughtException(thread, throwable);
}
});
}
@Override
public void onCreate() {
super.onCreate();
instance = this;
setCrashReport();
pref = PreferenceManager.getDefaultSharedPreferences(this);
if (!pref.contains("doh")) {
var name = "private_dns_mode";
if ("hostname".equals(Settings.Global.getString(getContentResolver(), name))) {
pref.edit().putBoolean("doh", false).apply();
} else {
pref.edit().putBoolean("doh", true).apply();
}
}
AppCompatDelegate.setDefaultNightMode(ThemeUtil.getDarkTheme());
LocaleDelegate.setDefaultLocale(getLocale());
var res = getResources();
var config = res.getConfiguration();
config.setLocale(LocaleDelegate.getDefaultLocale());
//noinspection deprecation
res.updateConfiguration(config, res.getDisplayMetrics());
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction("org.lsposed.manager.NOTIFICATION");
registerReceiver(new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent inIntent) {
var intent = (Intent) inIntent.getParcelableExtra(Intent.EXTRA_INTENT);
Log.d(TAG, "onReceive: " + intent);
switch (intent.getAction()) {
case Intent.ACTION_PACKAGE_ADDED, Intent.ACTION_PACKAGE_CHANGED, Intent.ACTION_PACKAGE_FULLY_REMOVED, Intent.ACTION_UID_REMOVED -> {
var userId = intent.getIntExtra(Intent.EXTRA_USER, 0);
var packageName = intent.getStringExtra("android.intent.extra.PACKAGES");
var packageRemovedForAllUsers = intent.getBooleanExtra(EXTRA_REMOVED_FOR_ALL_USERS, false);
var isXposedModule = intent.getBooleanExtra("isXposedModule", false);
if (packageName != null) {
if (isXposedModule)
ModuleUtil.getInstance().reloadSingleModule(packageName, userId, packageRemovedForAllUsers);
else
App.getExecutorService().submit(() -> AppHelper.getAppList(true));
}
}
case ACTION_USER_ADDED, ACTION_USER_REMOVED, ACTION_USER_INFO_CHANGED -> App.getExecutorService().submit(() -> ModuleUtil.getInstance().reloadInstalledModules());
}
}
}, intentFilter, Context.RECEIVER_NOT_EXPORTED);
UpdateUtil.loadRemoteVersion();
}
@NonNull
public static OkHttpClient getOkHttpClient() {
if (okHttpClient != null) return okHttpClient;
var builder = new OkHttpClient.Builder()
.cache(getOkHttpCache())
.dns(new CloudflareDNS());
if (BuildConfig.DEBUG) {
var log = new HttpLoggingInterceptor();
log.setLevel(HttpLoggingInterceptor.Level.HEADERS);
builder.addInterceptor(log);
}
okHttpClient = builder.build();
return okHttpClient;
}
@NonNull
public static Cache getOkHttpCache() {
if (okHttpCache != null) return okHttpCache;
long size50MiB = 50 * 1024 * 1024;
okHttpCache = new Cache(new File(instance.getCacheDir(), "http_cache"), size50MiB);
return okHttpCache;
}
public static Locale getLocale(String tag) {
if (TextUtils.isEmpty(tag) || "SYSTEM".equals(tag)) {
return LocaleDelegate.getSystemLocale();
}
return Locale.forLanguageTag(tag);
}
public static Locale getLocale() {
String tag = getPreferences().getString("language", null);
return getLocale(tag);
}
}
================================================
FILE: app/src/main/java/org/lsposed/manager/ConfigManager.java
================================================
/*
* This file is part of LSPosed.
*
* LSPosed is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LSPosed is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LSPosed. If not, see .
*
* Copyright (C) 2021 LSPosed Contributors
*/
package org.lsposed.manager;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.ParcelFileDescriptor;
import android.os.RemoteException;
import android.util.Log;
import org.lsposed.lspd.ILSPManagerService;
import org.lsposed.lspd.models.Application;
import org.lsposed.lspd.models.UserInfo;
import org.lsposed.manager.adapters.ScopeAdapter;
import org.lsposed.manager.receivers.LSPManagerServiceHolder;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
public class ConfigManager {
public static boolean isBinderAlive() {
return LSPManagerServiceHolder.getService() != null;
}
public static int getXposedApiVersion() {
try {
return LSPManagerServiceHolder.getService().getXposedApiVersion();
} catch (RemoteException e) {
Log.e(App.TAG, Log.getStackTraceString(e));
return -1;
}
}
public static String getXposedVersionName() {
try {
return LSPManagerServiceHolder.getService().getXposedVersionName();
} catch (RemoteException e) {
Log.e(App.TAG, Log.getStackTraceString(e));
return "";
}
}
public static int getXposedVersionCode() {
try {
return LSPManagerServiceHolder.getService().getXposedVersionCode();
} catch (RemoteException e) {
Log.e(App.TAG, Log.getStackTraceString(e));
return -1;
}
}
public static List getInstalledPackagesFromAllUsers(int flags, boolean filterNoProcess) {
List list = new ArrayList<>();
try {
list.addAll(LSPManagerServiceHolder.getService().getInstalledPackagesFromAllUsers(flags, filterNoProcess).getList());
} catch (RemoteException e) {
Log.e(App.TAG, Log.getStackTraceString(e));
}
return list;
}
public static String[] getEnabledModules() {
try {
return LSPManagerServiceHolder.getService().enabledModules();
} catch (RemoteException e) {
Log.e(App.TAG, Log.getStackTraceString(e));
return new String[0];
}
}
public static boolean setModuleEnabled(String packageName, boolean enable) {
try {
return enable ? LSPManagerServiceHolder.getService().enableModule(packageName) : LSPManagerServiceHolder.getService().disableModule(packageName);
} catch (RemoteException e) {
Log.e(App.TAG, Log.getStackTraceString(e));
return false;
}
}
public static boolean setModuleScope(String packageName, boolean legacy, Set applications) {
try {
List list = new ArrayList<>();
applications.forEach(application -> {
Application app = new Application();
app.userId = application.userId;
app.packageName = application.packageName;
list.add(app);
});
if (legacy) {
Application app = new Application();
app.userId = 0;
app.packageName = packageName;
list.add(app);
}
return LSPManagerServiceHolder.getService().setModuleScope(packageName, list);
} catch (RemoteException e) {
Log.e(App.TAG, Log.getStackTraceString(e));
return false;
}
}
public static List getModuleScope(String packageName) {
List list = new ArrayList<>();
try {
var applications = LSPManagerServiceHolder.getService().getModuleScope(packageName);
if (applications == null) {
return list;
}
applications.forEach(application -> {
if (!application.packageName.equals(packageName)) {
list.add(new ScopeAdapter.ApplicationWithEquals(application));
}
});
} catch (RemoteException e) {
Log.e(App.TAG, Log.getStackTraceString(e));
}
return list;
}
public static boolean enableStatusNotification() {
try {
return LSPManagerServiceHolder.getService().enableStatusNotification();
} catch (RemoteException e) {
Log.e(App.TAG, Log.getStackTraceString(e));
return false;
}
}
public static boolean setEnableStatusNotification(boolean enabled) {
try {
LSPManagerServiceHolder.getService().setEnableStatusNotification(enabled);
return true;
} catch (RemoteException e) {
Log.e(App.TAG, Log.getStackTraceString(e));
return false;
}
}
public static boolean isVerboseLogEnabled() {
try {
return LSPManagerServiceHolder.getService().isVerboseLog();
} catch (RemoteException e) {
Log.e(App.TAG, Log.getStackTraceString(e));
return false;
}
}
public static boolean setVerboseLogEnabled(boolean enabled) {
try {
LSPManagerServiceHolder.getService().setVerboseLog(enabled);
return true;
} catch (RemoteException e) {
Log.e(App.TAG, Log.getStackTraceString(e));
return false;
}
}
public static boolean isLogWatchdogEnabled() {
try {
return LSPManagerServiceHolder.getService().isLogWatchdogEnabled();
} catch (RemoteException e) {
Log.e(App.TAG, Log.getStackTraceString(e));
return false;
}
}
public static boolean setLogWatchdog(boolean enabled) {
try {
LSPManagerServiceHolder.getService().setLogWatchdog(enabled);
return true;
} catch (RemoteException e) {
Log.e(App.TAG, Log.getStackTraceString(e));
return false;
}
}
public static ParcelFileDescriptor getLog(boolean verbose) {
try {
return verbose ? LSPManagerServiceHolder.getService().getVerboseLog() : LSPManagerServiceHolder.getService().getModulesLog();
} catch (RemoteException e) {
Log.e(App.TAG, Log.getStackTraceString(e));
return null;
}
}
public static boolean clearLogs(boolean verbose) {
try {
return LSPManagerServiceHolder.getService().clearLogs(verbose);
} catch (RemoteException e) {
Log.e(App.TAG, Log.getStackTraceString(e));
return false;
}
}
public static PackageInfo getPackageInfo(String packageName, int flags, int userId) throws PackageManager.NameNotFoundException {
try {
var info = LSPManagerServiceHolder.getService().getPackageInfo(packageName, flags, userId);
if (info == null) throw new PackageManager.NameNotFoundException();
return info;
} catch (RemoteException e) {
Log.e(App.TAG, Log.getStackTraceString(e));
throw new PackageManager.NameNotFoundException();
}
}
public static boolean forceStopPackage(String packageName, int userId) {
try {
LSPManagerServiceHolder.getService().forceStopPackage(packageName, userId);
return true;
} catch (RemoteException e) {
Log.e(App.TAG, Log.getStackTraceString(e));
return false;
}
}
public static boolean reboot() {
try {
LSPManagerServiceHolder.getService().reboot();
return true;
} catch (RemoteException e) {
Log.e(App.TAG, Log.getStackTraceString(e));
return false;
}
}
public static boolean uninstallPackage(String packageName, int userId) {
try {
return LSPManagerServiceHolder.getService().uninstallPackage(packageName, userId);
} catch (RemoteException e) {
Log.e(App.TAG, Log.getStackTraceString(e));
return false;
}
}
public static boolean isSepolicyLoaded() {
try {
return LSPManagerServiceHolder.getService().isSepolicyLoaded();
} catch (RemoteException e) {
Log.e(App.TAG, Log.getStackTraceString(e));
return false;
}
}
public static List getUsers() {
try {
return LSPManagerServiceHolder.getService().getUsers();
} catch (RemoteException e) {
Log.e(App.TAG, Log.getStackTraceString(e));
return null;
}
}
public static boolean installExistingPackageAsUser(String packageName, int userId) {
final int INSTALL_SUCCEEDED = 1;
try {
var ret = LSPManagerServiceHolder.getService().installExistingPackageAsUser(packageName, userId);
return ret == INSTALL_SUCCEEDED;
} catch (RemoteException e) {
Log.e(App.TAG, Log.getStackTraceString(e));
return false;
}
}
public static boolean isMagiskInstalled() {
var path = System.getenv("PATH");
if (path == null) return false;
else return Arrays.stream(path.split(File.pathSeparator))
.anyMatch(str -> new File(str, "magisk").exists());
}
public static boolean systemServerRequested() {
try {
return LSPManagerServiceHolder.getService().systemServerRequested();
} catch (RemoteException e) {
return false;
}
}
public static boolean dex2oatFlagsLoaded() {
try {
return LSPManagerServiceHolder.getService().dex2oatFlagsLoaded();
} catch (RemoteException e) {
return false;
}
}
public static int startActivityAsUserWithFeature(Intent intent, int userId) {
try {
return LSPManagerServiceHolder.getService().startActivityAsUserWithFeature(intent, userId);
} catch (RemoteException e) {
Log.e(App.TAG, Log.getStackTraceString(e));
return -1;
}
}
public static List queryIntentActivitiesAsUser(Intent intent, int flags, int userId) {
List list = new ArrayList<>();
try {
list.addAll(LSPManagerServiceHolder.getService().queryIntentActivitiesAsUser(intent, flags, userId).getList());
} catch (RemoteException e) {
Log.e(App.TAG, Log.getStackTraceString(e));
}
return list;
}
public static boolean setHiddenIcon(boolean hide) {
try {
LSPManagerServiceHolder.getService().setHiddenIcon(hide);
return true;
} catch (RemoteException e) {
Log.e(App.TAG, Log.getStackTraceString(e));
return false;
}
}
public static String getApi() {
try {
return LSPManagerServiceHolder.getService().getApi();
} catch (RemoteException e) {
Log.e(App.TAG, Log.getStackTraceString(e));
return e.toString();
}
}
public static List getDenyListPackages() {
List list = new ArrayList<>();
try {
list.addAll(LSPManagerServiceHolder.getService().getDenyListPackages());
} catch (RemoteException e) {
Log.e(App.TAG, Log.getStackTraceString(e));
}
return list;
}
public static void flashZip(String zipPath, ParcelFileDescriptor outputStream) {
try {
LSPManagerServiceHolder.getService().flashZip(zipPath, outputStream);
} catch (RemoteException e) {
Log.e(App.TAG, Log.getStackTraceString(e));
}
}
public static boolean isDexObfuscateEnabled() {
try {
return LSPManagerServiceHolder.getService().getDexObfuscate();
} catch (RemoteException e) {
Log.e(App.TAG, Log.getStackTraceString(e));
return false;
}
}
public static boolean setDexObfuscateEnabled(boolean enabled) {
try {
LSPManagerServiceHolder.getService().setDexObfuscate(enabled);
return true;
} catch (RemoteException e) {
Log.e(App.TAG, Log.getStackTraceString(e));
return false;
}
}
public static int getDex2OatWrapperCompatibility() {
try {
return LSPManagerServiceHolder.getService().getDex2OatWrapperCompatibility();
} catch (RemoteException e) {
Log.e(App.TAG, Log.getStackTraceString(e));
return ILSPManagerService.DEX2OAT_CRASHED;
}
}
public static boolean getAutoInclude(String packageName) {
try {
return LSPManagerServiceHolder.getService().getAutoInclude(packageName);
} catch (RemoteException e) {
Log.e(App.TAG, Log.getStackTraceString(e));
return false;
}
}
public static boolean setAutoInclude(String packageName, boolean enable) {
try {
LSPManagerServiceHolder.getService().setAutoInclude(packageName, enable);
return true;
} catch (RemoteException e) {
Log.e(App.TAG, Log.getStackTraceString(e));
return false;
}
}
}
================================================
FILE: app/src/main/java/org/lsposed/manager/Constants.java
================================================
/*
* This file is part of LSPosed.
*
* LSPosed is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LSPosed is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LSPosed. If not, see .
*
* Copyright (C) 2020 EdXposed Contributors
* Copyright (C) 2021 LSPosed Contributors
*/
package org.lsposed.manager;
import android.os.IBinder;
import org.lsposed.manager.receivers.LSPManagerServiceHolder;
public class Constants {
public static boolean setBinder(IBinder binder) {
LSPManagerServiceHolder.init(binder);
return LSPManagerServiceHolder.getService().asBinder().isBinderAlive();
}
}
================================================
FILE: app/src/main/java/org/lsposed/manager/adapters/AppHelper.java
================================================
/*
* This file is part of LSPosed.
*
* LSPosed is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LSPosed is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LSPosed. If not, see .
*
* Copyright (C) 2020 EdXposed Contributors
* Copyright (C) 2021 LSPosed Contributors
*/
package org.lsposed.manager.adapters;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.Parcel;
import android.view.MenuItem;
import org.lsposed.manager.ConfigManager;
import org.lsposed.manager.R;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
public class AppHelper {
public static final String SETTINGS_CATEGORY = "de.robv.android.xposed.category.MODULE_SETTINGS";
public static final int FLAG_SHOW_FOR_ALL_USERS = 0x0400;
private static List denyList;
private static List appList;
private static final ConcurrentHashMap appLabel = new ConcurrentHashMap<>();
@SuppressLint("WrongConstant")
public static Intent getSettingsIntent(String packageName, int userId) {
Intent intentToResolve = new Intent(Intent.ACTION_MAIN);
intentToResolve.addCategory(SETTINGS_CATEGORY);
intentToResolve.setPackage(packageName);
List ris = ConfigManager.queryIntentActivitiesAsUser(intentToResolve, 0, userId);
if (ris.size() == 0) {
return getLaunchIntentForPackage(packageName, userId);
}
Intent intent = new Intent(intentToResolve);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setClassName(ris.get(0).activityInfo.packageName,
ris.get(0).activityInfo.name);
intent.putExtra("lsp_no_switch_to_user", (ris.get(0).activityInfo.flags & FLAG_SHOW_FOR_ALL_USERS) != 0);
return intent;
}
@SuppressLint("WrongConstant")
public static Intent getLaunchIntentForPackage(String packageName, int userId) {
Intent intentToResolve = new Intent(Intent.ACTION_MAIN);
intentToResolve.addCategory(Intent.CATEGORY_INFO);
intentToResolve.setPackage(packageName);
List ris = ConfigManager.queryIntentActivitiesAsUser(intentToResolve, 0, userId);
if (ris.size() == 0) {
intentToResolve.removeCategory(Intent.CATEGORY_INFO);
intentToResolve.addCategory(Intent.CATEGORY_LAUNCHER);
intentToResolve.setPackage(packageName);
ris = ConfigManager.queryIntentActivitiesAsUser(intentToResolve, 0, userId);
}
if (ris.size() == 0) {
return null;
}
Intent intent = new Intent(intentToResolve);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setClassName(ris.get(0).activityInfo.packageName,
ris.get(0).activityInfo.name);
intent.putExtra("lsp_no_switch_to_user", (ris.get(0).activityInfo.flags & FLAG_SHOW_FOR_ALL_USERS) != 0);
return intent;
}
public static boolean onOptionsItemSelected(MenuItem item, SharedPreferences preferences) {
int itemId = item.getItemId();
int i = preferences.getInt("list_sort", 0);
if (itemId == R.id.item_sort_by_name) {
i = (i % 2 == 0) ? 0 : 1;
} else if (itemId == R.id.item_sort_by_package_name) {
i = (i % 2 == 0) ? 2 : 3;
} else if (itemId == R.id.item_sort_by_install_time) {
i = (i % 2 == 0) ? 4 : 5;
} else if (itemId == R.id.item_sort_by_update_time) {
i = (i % 2 == 0) ? 6 : 7;
} else if (itemId == R.id.reverse) {
if (i % 2 == 0) i++;
else i--;
} else {
return false;
}
preferences.edit().putInt("list_sort", i).apply();
if (item.isCheckable())
item.setChecked(!item.isChecked());
return true;
}
public static Comparator getAppListComparator(int sort, PackageManager pm) {
ApplicationInfo.DisplayNameComparator displayNameComparator = new ApplicationInfo.DisplayNameComparator(pm);
return switch (sort) {
case 7 ->
Collections.reverseOrder(Comparator.comparingLong((PackageInfo a) -> a.lastUpdateTime));
case 6 -> Comparator.comparingLong((PackageInfo a) -> a.lastUpdateTime);
case 5 ->
Collections.reverseOrder(Comparator.comparingLong((PackageInfo a) -> a.firstInstallTime));
case 4 -> Comparator.comparingLong((PackageInfo a) -> a.firstInstallTime);
case 3 -> Collections.reverseOrder(Comparator.comparing(a -> a.packageName));
case 2 -> Comparator.comparing(a -> a.packageName);
case 1 ->
Collections.reverseOrder((PackageInfo a, PackageInfo b) -> displayNameComparator.compare(a.applicationInfo, b.applicationInfo));
default ->
(PackageInfo a, PackageInfo b) -> displayNameComparator.compare(a.applicationInfo, b.applicationInfo);
};
}
synchronized public static List getAppList(boolean force) {
if (appList == null || force) {
appList = ConfigManager.getInstalledPackagesFromAllUsers(PackageManager.GET_META_DATA | PackageManager.MATCH_UNINSTALLED_PACKAGES, true);
PackageInfo system = null;
for (var app : appList) {
if ("android".equals(app.packageName)) {
var p = Parcel.obtain();
app.writeToParcel(p, 0);
p.setDataPosition(0);
system = PackageInfo.CREATOR.createFromParcel(p);
system.packageName = "system";
system.applicationInfo.packageName = system.packageName;
break;
}
}
if (system != null) {
appList.add(system);
}
}
return appList;
}
synchronized public static List getDenyList(boolean force) {
if (denyList == null || force) {
denyList = ConfigManager.getDenyListPackages();
}
return denyList;
}
public static CharSequence getAppLabel(PackageInfo info, PackageManager pm) {
if (info == null || info.applicationInfo == null) return null;
return appLabel.computeIfAbsent(info, i -> i.applicationInfo.loadLabel(pm));
}
}
================================================
FILE: app/src/main/java/org/lsposed/manager/adapters/ScopeAdapter.java
================================================
/*
* This file is part of LSPosed.
*
* LSPosed is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LSPosed is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LSPosed. If not, see .
*
* Copyright (C) 2020 EdXposed Contributors
* Copyright (C) 2021 LSPosed Contributors
*/
package org.lsposed.manager.adapters;
import static android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import android.text.style.ForegroundColorSpan;
import android.text.style.StyleSpan;
import android.text.style.TypefaceSpan;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CompoundButton;
import android.widget.Filter;
import android.widget.Filterable;
import android.widget.ImageView;
import android.widget.Switch;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.SearchView;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.request.target.CustomTarget;
import com.bumptech.glide.request.transition.Transition;
import com.google.android.material.checkbox.MaterialCheckBox;
import org.lsposed.lspd.models.Application;
import org.lsposed.manager.App;
import org.lsposed.manager.BuildConfig;
import org.lsposed.manager.ConfigManager;
import org.lsposed.manager.R;
import org.lsposed.manager.databinding.ItemMasterSwitchBinding;
import org.lsposed.manager.databinding.ItemModuleBinding;
import org.lsposed.manager.ui.dialog.BlurBehindDialogBuilder;
import org.lsposed.manager.ui.fragment.AppListFragment;
import org.lsposed.manager.ui.fragment.CompileDialogFragment;
import org.lsposed.manager.ui.widget.EmptyStateRecyclerView;
import org.lsposed.manager.util.GlideApp;
import org.lsposed.manager.util.ModuleUtil;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import rikka.core.util.ResourceUtils;
import rikka.material.app.LocaleDelegate;
import rikka.widget.mainswitchbar.MainSwitchBar;
import rikka.widget.mainswitchbar.OnMainSwitchChangeListener;
public class ScopeAdapter extends EmptyStateRecyclerView.EmptyStateAdapter implements Filterable {
private final Activity activity;
private final AppListFragment fragment;
private final PackageManager pm;
private final SharedPreferences preferences;
private final ModuleUtil moduleUtil;
private final ModuleUtil.InstalledModule module;
private Set recommendedList = new HashSet<>();
private Set checkedList = new HashSet<>();
private List searchList = new ArrayList<>();
private List showList = new ArrayList<>();
private List denyList = new ArrayList<>();
public RecyclerView.Adapter switchAdaptor = new RecyclerView.Adapter<>() {
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return new RecyclerView.ViewHolder(ItemMasterSwitchBinding.inflate(activity.getLayoutInflater(), parent, false).masterSwitch) {
};
}
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
var mainSwitchBar = (MainSwitchBar) holder.itemView;
mainSwitchBar.setChecked(enabled);
mainSwitchBar.addOnSwitchChangeListener(switchBarOnCheckedChangeListener);
}
@Override
public int getItemCount() {
return 1;
}
};
private final OnMainSwitchChangeListener switchBarOnCheckedChangeListener = new OnMainSwitchChangeListener() {
@Override
public void onSwitchChanged(Switch view, boolean isChecked) {
enabled = isChecked;
if (!moduleUtil.setModuleEnabled(module.packageName, isChecked)) {
view.setChecked(!isChecked);
enabled = !isChecked;
}
var tmpChkList = new HashSet<>(checkedList);
if (isChecked && !tmpChkList.isEmpty() && !ConfigManager.setModuleScope(module.packageName, module.legacy, tmpChkList)) {
view.setChecked(false);
enabled = false;
}
fragment.runOnUiThread(ScopeAdapter.this::notifyDataSetChanged);
}
};
private ApplicationInfo selectedApplicationInfo;
private boolean isLoaded = false;
private boolean enabled = true;
public ScopeAdapter(AppListFragment fragment, ModuleUtil.InstalledModule module) {
this.fragment = fragment;
this.activity = fragment.requireActivity();
this.module = module;
moduleUtil = ModuleUtil.getInstance();
preferences = App.getPreferences();
pm = activity.getPackageManager();
}
@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return new ViewHolder(ItemModuleBinding.inflate(activity.getLayoutInflater(), parent, false));
}
private boolean shouldHideApp(PackageInfo info, ApplicationWithEquals app, HashSet tmpChkList) {
if (info.packageName.equals("system")) {
return false;
}
if (tmpChkList.contains(app)) {
return false;
}
if (preferences.getBoolean("filter_denylist", false)) {
if (denyList.contains(info.packageName)) {
return true;
}
}
if (preferences.getBoolean("filter_modules", true)) {
if (ModuleUtil.getInstance().getModule(info.packageName, info.applicationInfo.uid / App.PER_USER_RANGE) != null) {
return true;
}
}
if (preferences.getBoolean("filter_games", true)) {
if (info.applicationInfo.category == ApplicationInfo.CATEGORY_GAME) {
return true;
}
//noinspection deprecation
if ((info.applicationInfo.flags & ApplicationInfo.FLAG_IS_GAME) != 0) {
return true;
}
}
return preferences.getBoolean("filter_system_apps", true) && (info.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0;
}
private int sortApps(AppInfo x, AppInfo y) {
Comparator comparator = AppHelper.getAppListComparator(preferences.getInt("list_sort", 0), pm);
Comparator frameworkComparator = (a, b) -> {
if (a.packageName.equals("system") == b.packageName.equals("system")) {
return comparator.compare(a.packageInfo, b.packageInfo);
} else if (a.packageName.equals("system")) {
return -1;
} else {
return 1;
}
};
Comparator recommendedComparator = (a, b) -> {
boolean aRecommended = !recommendedList.isEmpty() && recommendedList.contains(a.application);
boolean bRecommended = !recommendedList.isEmpty() && recommendedList.contains(b.application);
if (aRecommended == bRecommended) {
return frameworkComparator.compare(a, b);
} else if (aRecommended) {
return -1;
} else {
return 1;
}
};
boolean aChecked = checkedList.contains(x.application);
boolean bChecked = checkedList.contains(y.application);
if (aChecked == bChecked) {
return recommendedComparator.compare(x, y);
} else if (aChecked) {
return -1;
} else {
return 1;
}
}
private void checkRecommended() {
if (!enabled) {
fragment.showHint(R.string.module_is_not_activated_yet, false);
return;
}
fragment.runAsync(() -> {
var tmpChkList = new HashSet<>(checkedList);
tmpChkList.removeIf(i -> i.userId == module.userId);
tmpChkList.addAll(recommendedList);
ConfigManager.setModuleScope(module.packageName, module.legacy, tmpChkList);
checkedList = tmpChkList;
fragment.runOnUiThread(this::notifyDataSetChanged);
});
}
@SuppressLint("NotifyDataSetChanged")
private void setLoaded(List list, boolean loaded) {
fragment.runOnUiThread(() -> {
if (list != null) showList = list;
isLoaded = loaded;
notifyDataSetChanged();
});
}
public boolean onOptionsItemSelected(MenuItem item) {
int itemId = item.getItemId();
if (itemId == R.id.use_recommended) {
if (!checkedList.isEmpty()) {
new BlurBehindDialogBuilder(activity, R.style.ThemeOverlay_MaterialAlertDialog_Centered_FullWidthButtons)
.setMessage(R.string.use_recommended_message)
.setPositiveButton(android.R.string.ok, (dialog, which) -> checkRecommended())
.setNegativeButton(android.R.string.cancel, null)
.show();
} else {
checkRecommended();
}
return true;
} else if (itemId == R.id.item_filter_system) {
item.setChecked(!item.isChecked());
preferences.edit().putBoolean("filter_system_apps", item.isChecked()).apply();
} else if (itemId == R.id.item_filter_games) {
item.setChecked(!item.isChecked());
preferences.edit().putBoolean("filter_games", item.isChecked()).apply();
} else if (itemId == R.id.item_filter_modules) {
item.setChecked(!item.isChecked());
preferences.edit().putBoolean("filter_modules", item.isChecked()).apply();
} else if (itemId == R.id.item_filter_denylist) {
item.setChecked(!item.isChecked());
preferences.edit().putBoolean("filter_denylist", item.isChecked()).apply();
} else if (itemId == R.id.backup) {
LocalDateTime now = LocalDateTime.now();
try {
fragment.backupLauncher.launch(String.format(LocaleDelegate.getDefaultLocale(),
"%s_%s.lsp", module.getAppName(), now.toString()));
return true;
} catch (ActivityNotFoundException e) {
fragment.showHint(R.string.enable_documentui, true);
return false;
}
} else if (itemId == R.id.restore) {
try {
fragment.restoreLauncher.launch(new String[]{"*/*"});
return true;
} catch (ActivityNotFoundException e) {
fragment.showHint(R.string.enable_documentui, true);
return false;
}
} else if (itemId == R.id.select_all) {
var tmpChkList = new HashSet(ConfigManager.getModuleScope(module.packageName));
for (AppInfo info : searchList) {
if (info.packageName.equals("android")) {
fragment.showHint(R.string.reboot_required, true, R.string.reboot, v -> ConfigManager.reboot());
}
tmpChkList.add(info.application);
}
ConfigManager.setModuleScope(module.packageName, module.legacy, tmpChkList);
} else if (itemId == R.id.select_none) {
var tmpChkList = new HashSet(ConfigManager.getModuleScope(module.packageName));
for (AppInfo info : searchList) {
if (tmpChkList.remove(info.application) && info.packageName.equals("android")) {
fragment.showHint(R.string.reboot_required, true, R.string.reboot, v -> ConfigManager.reboot());
}
}
ConfigManager.setModuleScope(module.packageName, module.legacy, tmpChkList);
} else if (itemId == R.id.auto_include) {
item.setChecked(!item.isChecked());
ConfigManager.setAutoInclude(module.packageName, item.isChecked());
} else if (!AppHelper.onOptionsItemSelected(item, preferences)) {
return false;
}
refresh();
return true;
}
public boolean onContextItemSelected(@NonNull MenuItem item) {
var info = selectedApplicationInfo;
if (info == null) {
return false;
}
int itemId = item.getItemId();
if (itemId == R.id.menu_launch) {
Intent launchIntent = AppHelper.getLaunchIntentForPackage(info.packageName, info.uid / App.PER_USER_RANGE);
if (launchIntent != null) {
ConfigManager.startActivityAsUserWithFeature(launchIntent, module.userId);
}
} else if (itemId == R.id.menu_compile_speed) {
CompileDialogFragment.speed(fragment.getChildFragmentManager(), info);
} else if (itemId == R.id.menu_other_app) {
var intent = new Intent(Intent.ACTION_SHOW_APP_INFO);
intent.putExtra(Intent.EXTRA_PACKAGE_NAME, module.packageName);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
ConfigManager.startActivityAsUserWithFeature(intent, module.userId);
} else if (itemId == R.id.menu_app_info) {
ConfigManager.startActivityAsUserWithFeature(new Intent(ACTION_APPLICATION_DETAILS_SETTINGS, Uri.fromParts("package", info.packageName, null)), module.userId);
} else if (itemId == R.id.menu_force_stop) {
if (info.packageName.equals("system")) {
new BlurBehindDialogBuilder(activity, R.style.ThemeOverlay_MaterialAlertDialog_Centered_FullWidthButtons)
.setTitle(R.string.reboot)
.setPositiveButton(android.R.string.ok, (dialog, which) -> ConfigManager.reboot())
.setNegativeButton(android.R.string.cancel, null)
.show();
} else {
new BlurBehindDialogBuilder(activity, R.style.ThemeOverlay_MaterialAlertDialog_Centered_FullWidthButtons)
.setTitle(R.string.force_stop_dlg_title)
.setMessage(R.string.force_stop_dlg_text)
.setPositiveButton(android.R.string.ok, (dialog, which) -> ConfigManager.forceStopPackage(info.packageName, info.uid / 100000))
.setNegativeButton(android.R.string.cancel, null)
.show();
}
} else {
return false;
}
return true;
}
public void onPrepareOptionsMenu(@NonNull Menu menu) {
List scopeList = module.getScopeList();
if (scopeList == null || scopeList.isEmpty()) {
menu.removeItem(R.id.use_recommended);
}
menu.findItem(R.id.item_filter_system).setChecked(preferences.getBoolean("filter_system_apps", true));
menu.findItem(R.id.item_filter_games).setChecked(preferences.getBoolean("filter_games", true));
menu.findItem(R.id.item_filter_modules).setChecked(preferences.getBoolean("filter_modules", true));
menu.findItem(R.id.item_filter_denylist).setChecked(preferences.getBoolean("filter_denylist", false));
switch (preferences.getInt("list_sort", 0)) {
case 7 -> {
menu.findItem(R.id.item_sort_by_update_time).setChecked(true);
menu.findItem(R.id.reverse).setChecked(true);
}
case 6 -> menu.findItem(R.id.item_sort_by_update_time).setChecked(true);
case 5 -> {
menu.findItem(R.id.item_sort_by_install_time).setChecked(true);
menu.findItem(R.id.reverse).setChecked(true);
}
case 4 -> menu.findItem(R.id.item_sort_by_install_time).setChecked(true);
case 3 -> {
menu.findItem(R.id.item_sort_by_package_name).setChecked(true);
menu.findItem(R.id.reverse).setChecked(true);
}
case 2 -> menu.findItem(R.id.item_sort_by_package_name).setChecked(true);
case 1 -> {
menu.findItem(R.id.item_sort_by_name).setChecked(true);
menu.findItem(R.id.reverse).setChecked(true);
}
case 0 -> menu.findItem(R.id.item_sort_by_name).setChecked(true);
}
menu.findItem(R.id.auto_include).setChecked(ConfigManager.getAutoInclude(module.packageName));
}
@Override
public void onViewRecycled(@NonNull ViewHolder holder) {
if (holder.checkbox != null) {
holder.checkbox.setOnCheckedChangeListener(null);
}
super.onViewRecycled(holder);
}
@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
AppInfo appInfo = showList.get(position);
boolean deny = denyList.contains(appInfo.packageName);
holder.root.setAlpha(!deny && enabled ? 1.0f : .5f);
boolean system = appInfo.packageName.equals("system");
CharSequence appName;
int userId = appInfo.applicationInfo.uid / App.PER_USER_RANGE;
appName = system ? activity.getString(R.string.android_framework) : appInfo.label;
holder.appName.setText(appName);
GlideApp.with(holder.appIcon).load(appInfo.packageInfo).into(new CustomTarget() {
@Override
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition super Drawable> transition) {
holder.appIcon.setImageDrawable(resource);
}
@Override
public void onLoadCleared(@Nullable Drawable placeholder) {
}
@Override
public void onLoadFailed(@Nullable Drawable errorDrawable) {
holder.appIcon.setImageDrawable(pm.getDefaultActivityIcon());
}
});
if (system) {
//noinspection SetTextI18n
holder.appPackageName.setText("system");
holder.appVersionName.setVisibility(View.GONE);
} else {
holder.appVersionName.setVisibility(View.VISIBLE);
holder.appPackageName.setText(appInfo.packageName);
}
holder.appPackageName.setVisibility(View.VISIBLE);
holder.appVersionName.setText(activity.getString(R.string.app_version, appInfo.packageInfo.versionName));
var sb = new SpannableStringBuilder();
if (!recommendedList.isEmpty() && recommendedList.contains(appInfo.application)) {
String recommended = activity.getString(R.string.requested_by_module);
sb.append(recommended);
final ForegroundColorSpan foregroundColorSpan = new ForegroundColorSpan(ResourceUtils.resolveColor(activity.getTheme(), com.google.android.material.R.attr.colorPrimary));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
final TypefaceSpan typefaceSpan = new TypefaceSpan(Typeface.create("sans-serif-medium", Typeface.NORMAL));
sb.setSpan(typefaceSpan, sb.length() - recommended.length(), sb.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
} else {
final StyleSpan styleSpan = new StyleSpan(Typeface.BOLD);
sb.setSpan(styleSpan, sb.length() - recommended.length(), sb.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
}
sb.setSpan(foregroundColorSpan, sb.length() - recommended.length(), sb.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
}
if (deny) {
if (sb.length() != 0) sb.append("\n");
String denylist = activity.getString(R.string.deny_list_info);
sb.append(denylist);
final ForegroundColorSpan foregroundColorSpan = new ForegroundColorSpan(ResourceUtils.resolveColor(activity.getTheme(), com.google.android.material.R.attr.colorError));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
final TypefaceSpan typefaceSpan = new TypefaceSpan(Typeface.create("sans-serif-medium", Typeface.NORMAL));
sb.setSpan(typefaceSpan, sb.length() - denylist.length(), sb.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
} else {
final StyleSpan styleSpan = new StyleSpan(Typeface.BOLD);
sb.setSpan(styleSpan, sb.length() - denylist.length(), sb.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
}
sb.setSpan(foregroundColorSpan, sb.length() - denylist.length(), sb.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
}
if (sb.length() == 0) {
holder.hint.setVisibility(View.GONE);
} else {
holder.hint.setText(sb);
holder.hint.setVisibility(View.VISIBLE);
}
holder.itemView.setOnCreateContextMenuListener((menu, v, menuInfo) -> {
activity.getMenuInflater().inflate(R.menu.menu_app_item, menu);
menu.setHeaderTitle(appName);
Intent launchIntent = AppHelper.getLaunchIntentForPackage(appInfo.packageName, userId);
if (launchIntent == null) {
menu.removeItem(R.id.menu_launch);
}
if (system) {
menu.findItem(R.id.menu_force_stop).setTitle(R.string.reboot);
menu.removeItem(R.id.menu_compile_speed);
menu.removeItem(R.id.menu_other_app);
menu.removeItem(R.id.menu_app_info);
}
});
holder.checkbox.setChecked(checkedList.contains(appInfo.application));
holder.checkbox.setOnCheckedChangeListener((v, isChecked) -> onCheckedChange(v, isChecked, appInfo));
holder.itemView.setOnClickListener(v -> {
if (enabled) holder.checkbox.toggle();
});
holder.itemView.setOnLongClickListener(v -> {
fragment.searchView.clearFocus();
selectedApplicationInfo = appInfo.applicationInfo;
return false;
});
}
@Override
public long getItemId(int position) {
PackageInfo info = showList.get(position).packageInfo;
return (info.packageName + "!" + info.applicationInfo.uid / App.PER_USER_RANGE).hashCode();
}
@Override
public Filter getFilter() {
return new ApplicationFilter();
}
@Override
public int getItemCount() {
return showList.size();
}
public void refresh() {
refresh(false);
}
public void refresh(boolean force) {
setLoaded(null, false);
enabled = moduleUtil.isModuleEnabled(module.packageName);
fragment.runAsync(() -> {
List appList = AppHelper.getAppList(force);
denyList = AppHelper.getDenyList(force);
var tmpRecList = new HashSet();
var tmpChkList = new HashSet<>(ConfigManager.getModuleScope(module.packageName));
final var tmpList = new ArrayList();
final HashSet installedList = new HashSet<>();
List scopeList = module.getScopeList();
boolean emptyCheckedList = tmpChkList.isEmpty();
appList.parallelStream().forEach(info -> {
int userId = info.applicationInfo.uid / App.PER_USER_RANGE;
String packageName = info.packageName;
if (packageName.equals("system") && userId != 0 ||
packageName.equals(module.packageName) ||
packageName.equals(BuildConfig.APPLICATION_ID)) {
return;
}
ApplicationWithEquals application = new ApplicationWithEquals(packageName, userId);
synchronized (installedList) {
installedList.add(application);
}
if (userId != module.userId) {
return;
}
if (scopeList != null && scopeList.contains(packageName)) {
synchronized (tmpRecList) {
tmpRecList.add(application);
}
} else if (shouldHideApp(info, application, tmpChkList)) {
return;
}
AppInfo appInfo = new AppInfo();
appInfo.packageInfo = info;
appInfo.label = AppHelper.getAppLabel(info, pm);
appInfo.application = application;
appInfo.packageName = info.packageName;
appInfo.applicationInfo = info.applicationInfo;
synchronized (tmpList) {
tmpList.add(appInfo);
}
});
tmpChkList.retainAll(installedList);
checkedList = tmpChkList;
recommendedList = tmpRecList;
searchList = tmpList.parallelStream().sorted(this::sortApps).collect(Collectors.toList());
String queryStr = fragment.searchView != null ? fragment.searchView.getQuery().toString() : "";
fragment.runOnUiThread(() -> getFilter().filter(queryStr));
});
}
protected void onCheckedChange(CompoundButton buttonView, boolean isChecked, AppInfo appInfo) {
var tmpChkList = new HashSet<>(checkedList);
if (isChecked) {
tmpChkList.add(appInfo.application);
} else {
tmpChkList.remove(appInfo.application);
}
if (!ConfigManager.setModuleScope(module.packageName, module.legacy, tmpChkList)) {
fragment.showHint(R.string.failed_to_save_scope_list, true);
if (!isChecked) {
tmpChkList.add(appInfo.application);
} else {
tmpChkList.remove(appInfo.application);
}
buttonView.setChecked(!isChecked);
} else if (appInfo.packageName.equals("system")) {
fragment.showHint(R.string.reboot_required, true, R.string.reboot, v -> ConfigManager.reboot());
} else if (denyList.contains(appInfo.packageName)) {
fragment.showHint(activity.getString(R.string.deny_list, appInfo.label), true);
}
checkedList = tmpChkList;
}
@Override
public boolean isLoaded() {
return isLoaded;
}
public static class ViewHolder extends RecyclerView.ViewHolder {
ConstraintLayout root;
ImageView appIcon;
TextView appName;
TextView appPackageName;
TextView appVersionName;
TextView hint;
MaterialCheckBox checkbox;
ViewHolder(ItemModuleBinding binding) {
super(binding.getRoot());
root = binding.itemRoot;
appIcon = binding.appIcon;
appName = binding.appName;
appPackageName = binding.appPackageName;
appVersionName = binding.appVersionName;
checkbox = binding.checkbox;
hint = binding.hint;
checkbox.setVisibility(View.VISIBLE);
}
}
private class ApplicationFilter extends Filter {
private boolean lowercaseContains(String s, String filter) {
return !TextUtils.isEmpty(s) && s.toLowerCase().contains(filter);
}
@Override
protected FilterResults performFiltering(CharSequence constraint) {
FilterResults filterResults = new FilterResults();
List filtered = new ArrayList<>();
String filter = constraint.toString().toLowerCase();
for (AppInfo info : searchList) {
if (lowercaseContains(info.label.toString(), filter)
|| lowercaseContains(info.packageName, filter)) {
filtered.add(info);
}
}
filterResults.values = filtered;
filterResults.count = filtered.size();
return filterResults;
}
@Override
protected void publishResults(CharSequence constraint, FilterResults results) {
//noinspection unchecked
setLoaded((List) results.values, true);
}
}
public SearchView.OnQueryTextListener getSearchListener() {
return new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
getFilter().filter(query);
return true;
}
@Override
public boolean onQueryTextChange(String query) {
getFilter().filter(query);
return true;
}
};
}
public void onBackPressed() {
fragment.searchView.clearFocus();
if (isLoaded && enabled && checkedList.isEmpty()) {
var builder = new BlurBehindDialogBuilder(activity, R.style.ThemeOverlay_MaterialAlertDialog_Centered_FullWidthButtons);
builder.setMessage(!recommendedList.isEmpty() ? R.string.no_scope_selected_has_recommended : R.string.no_scope_selected);
if (!recommendedList.isEmpty()) {
builder.setPositiveButton(android.R.string.ok, (dialog, which) -> checkRecommended());
} else {
builder.setPositiveButton(android.R.string.cancel, null);
}
builder.setNegativeButton(!recommendedList.isEmpty() ? android.R.string.cancel : android.R.string.ok, (dialog, which) -> {
moduleUtil.setModuleEnabled(module.packageName, false);
Toast.makeText(activity, activity.getString(R.string.module_disabled_no_selection, module.getAppName()), Toast.LENGTH_LONG).show();
fragment.navigateUp();
});
builder.show();
} else {
fragment.navigateUp();
}
}
public static class AppInfo {
public PackageInfo packageInfo;
public ApplicationWithEquals application;
public ApplicationInfo applicationInfo;
public String packageName;
public CharSequence label = null;
}
public static class ApplicationWithEquals extends Application {
public ApplicationWithEquals(String packageName, int userId) {
this.packageName = packageName;
this.userId = userId;
}
public ApplicationWithEquals(Application application) {
packageName = application.packageName;
userId = application.userId;
}
@Override
public boolean equals(@Nullable Object obj) {
if (!(obj instanceof Application)) {
return false;
}
return packageName.equals(((Application) obj).packageName) && userId == ((Application) obj).userId;
}
@Override
public int hashCode() {
return Objects.hash(packageName, userId);
}
}
}
================================================
FILE: app/src/main/java/org/lsposed/manager/receivers/LSPManagerServiceHolder.java
================================================
/*
* This file is part of LSPosed.
*
* LSPosed is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LSPosed is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LSPosed. If not, see .
*
* Copyright (C) 2021 LSPosed Contributors
*/
package org.lsposed.manager.receivers;
import android.os.IBinder;
import android.os.Process;
import android.os.RemoteException;
import android.system.Os;
import org.lsposed.lspd.ILSPManagerService;
public class LSPManagerServiceHolder implements IBinder.DeathRecipient {
private static LSPManagerServiceHolder holder = null;
private static ILSPManagerService service = null;
public static void init(IBinder binder) {
if (holder == null) {
holder = new LSPManagerServiceHolder(binder);
}
}
public static ILSPManagerService getService() {
return service;
}
private LSPManagerServiceHolder(IBinder binder) {
linkToDeath(binder);
service = ILSPManagerService.Stub.asInterface(binder);
}
private void linkToDeath(IBinder binder) {
try {
binder.linkToDeath(this, 0);
} catch (RemoteException e) {
binderDied();
}
}
@Override
public void binderDied() {
System.exit(0);
Process.killProcess(Os.getpid());
}
}
================================================
FILE: app/src/main/java/org/lsposed/manager/repo/RepoLoader.java
================================================
/*
* This file is part of LSPosed.
*
* LSPosed is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LSPosed is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LSPosed. If not, see .
*
* Copyright (C) 2020 EdXposed Contributors
* Copyright (C) 2021 LSPosed Contributors
*/
package org.lsposed.manager.repo;
import android.content.res.Resources;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.google.gson.Gson;
import org.lsposed.manager.App;
import org.lsposed.manager.R;
import org.lsposed.manager.repo.model.OnlineModule;
import org.lsposed.manager.repo.model.Release;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.ResponseBody;
public class RepoLoader {
private static RepoLoader instance = null;
private Map onlineModules = new HashMap<>();
private Map latestVersion = new ConcurrentHashMap<>();
public static class ModuleVersion {
public String versionName;
public long versionCode;
private ModuleVersion(long versionCode, String versionName) {
this.versionName = versionName;
this.versionCode = versionCode;
}
public boolean upgradable(long versionCode, String versionName) {
return this.versionCode > versionCode || (this.versionCode == versionCode && !versionName.replace(' ', '_').equals(this.versionName));
}
}
private final Path repoFile = Paths.get(App.getInstance().getFilesDir().getAbsolutePath(), "repo.json");
private final Set listeners = ConcurrentHashMap.newKeySet();
private boolean repoLoaded = false;
private static final String originRepoUrl = "https://modules.lsposed.org/";
private static final String backupRepoUrl = "https://modules-blogcdn.lsposed.org/";
private static final String secondBackupRepoUrl = "https://modules-cloudflare.lsposed.org/";
private static String repoUrl = originRepoUrl;
private final Resources resources = App.getInstance().getResources();
private final String[] channels = resources.getStringArray(R.array.update_channel_values);
public boolean isRepoLoaded() {
return repoLoaded;
}
public static synchronized RepoLoader getInstance() {
if (instance == null) {
instance = new RepoLoader();
App.getExecutorService().submit(() -> instance.loadLocalData(true));
}
return instance;
}
synchronized public void loadRemoteData() {
repoLoaded = false;
try {
try (var response = App.getOkHttpClient().newCall(new Request.Builder().url(repoUrl + "modules.json").build()).execute()) {
if (response.isSuccessful()) {
ResponseBody body = response.body();
if (body != null) {
try {
String bodyString = body.string();
Files.write(repoFile, bodyString.getBytes(StandardCharsets.UTF_8));
loadLocalData(false);
} catch (Throwable t) {
Log.e(App.TAG, Log.getStackTraceString(t));
for (RepoListener listener : listeners) {
listener.onThrowable(t);
}
}
}
}
}
} catch (Throwable e) {
Log.e(App.TAG, "load remote data", e);
for (RepoListener listener : listeners) {
listener.onThrowable(e);
}
if (repoUrl.equals(originRepoUrl)) {
repoUrl = backupRepoUrl;
loadRemoteData();
} else if (repoUrl.equals(backupRepoUrl)) {
repoUrl = secondBackupRepoUrl;
loadRemoteData();
}
}
}
synchronized public void loadLocalData(boolean updateRemoteRepo) {
repoLoaded = false;
try {
if (Files.notExists(repoFile)) {
loadRemoteData();
updateRemoteRepo = false;
}
byte[] encoded = Files.readAllBytes(repoFile);
String bodyString = new String(encoded, StandardCharsets.UTF_8);
Gson gson = new Gson();
Map modules = new HashMap<>();
OnlineModule[] repoModules = gson.fromJson(bodyString, OnlineModule[].class);
Arrays.stream(repoModules).forEach(onlineModule -> modules.put(onlineModule.getName(), onlineModule));
var channel = App.getPreferences().getString("update_channel", channels[0]);
updateLatestVersion(repoModules, channel);
onlineModules = modules;
} catch (Throwable t) {
Log.e(App.TAG, Log.getStackTraceString(t));
for (RepoListener listener : listeners) {
listener.onThrowable(t);
}
} finally {
repoLoaded = true;
for (RepoListener listener : listeners) {
listener.onRepoLoaded();
}
if (updateRemoteRepo) loadRemoteData();
}
}
synchronized private void updateLatestVersion(OnlineModule[] onlineModules, String channel) {
repoLoaded = false;
Map versions = new ConcurrentHashMap<>();
for (var module : onlineModules) {
String release = module.getLatestRelease();
if (channel.equals(channels[1]) && module.getLatestBetaRelease() != null && !module.getLatestBetaRelease().isEmpty()) {
release = module.getLatestBetaRelease();
} else if (channel.equals(channels[2])) {
if (module.getLatestSnapshotRelease() != null && !module.getLatestSnapshotRelease().isEmpty())
release = module.getLatestSnapshotRelease();
else if (module.getLatestBetaRelease() != null && !module.getLatestBetaRelease().isEmpty())
release = module.getLatestBetaRelease();
}
if (release == null || release.isEmpty()) continue;
var splits = release.split("-", 2);
if (splits.length < 2) continue;
long verCode;
String verName;
try {
verCode = Long.parseLong(splits[0]);
verName = splits[1];
} catch (NumberFormatException ignored) {
continue;
}
String pkgName = module.getName();
versions.put(pkgName, new ModuleVersion(verCode, verName));
}
latestVersion = versions;
repoLoaded = true;
for (RepoListener listener : listeners) {
listener.onRepoLoaded();
}
}
public void updateLatestVersion(String channel) {
if (repoLoaded)
updateLatestVersion(onlineModules.keySet().parallelStream().map(onlineModules::get).toArray(OnlineModule[]::new), channel);
}
@Nullable
public ModuleVersion getModuleLatestVersion(String packageName) {
return repoLoaded ? latestVersion.getOrDefault(packageName, null) : null;
}
@Nullable
public List getReleases(String packageName) {
var channel = App.getPreferences().getString("update_channel", channels[0]);
List releases = new ArrayList<>();
if (repoLoaded) {
var module = onlineModules.get(packageName);
if (module != null) {
releases = module.getReleases();
if (!module.releasesLoaded) {
if (channel.equals(channels[1]) && !(module.getBetaReleases() != null && module.getBetaReleases().isEmpty())) {
releases = module.getBetaReleases();
} else if (channel.equals(channels[2]))
if (!(module.getSnapshotReleases() != null && module.getSnapshotReleases().isEmpty()))
releases = module.getSnapshotReleases();
else if (!(module.getBetaReleases() != null && module.getBetaReleases().isEmpty()))
releases = module.getBetaReleases();
}
}
}
return releases;
}
@Nullable
public String getLatestReleaseTime(String packageName, String channel) {
String releaseTime = null;
if (repoLoaded) {
var module = onlineModules.get(packageName);
if (module != null) {
releaseTime = module.getLatestReleaseTime();
if (channel.equals(channels[1]) && module.getLatestBetaReleaseTime() != null) {
releaseTime = module.getLatestBetaReleaseTime();
} else if (channel.equals(channels[2]))
if (module.getLatestSnapshotReleaseTime() != null)
releaseTime = module.getLatestSnapshotReleaseTime();
else if (module.getLatestBetaReleaseTime() != null)
releaseTime = module.getLatestBetaReleaseTime();
}
}
return releaseTime;
}
public void loadRemoteReleases(String packageName) {
App.getOkHttpClient().newCall(new Request.Builder().url(String.format(repoUrl + "module/%s.json", packageName)).build()).enqueue(new Callback() {
@Override
public void onFailure(@NonNull Call call, @NonNull IOException e) {
Log.e(App.TAG, call.request().url() + e.getMessage());
if (repoUrl.equals(originRepoUrl)) {
repoUrl = backupRepoUrl;
loadRemoteReleases(packageName);
} else if (repoUrl.equals(backupRepoUrl)) {
repoUrl = secondBackupRepoUrl;
loadRemoteReleases(packageName);
} else {
for (RepoListener listener : listeners) {
listener.onThrowable(e);
}
}
}
@Override
public void onResponse(@NonNull Call call, @NonNull Response response) {
if (response.isSuccessful()) {
ResponseBody body = response.body();
if (body != null) {
try {
String bodyString = body.string();
Gson gson = new Gson();
OnlineModule module = gson.fromJson(bodyString, OnlineModule.class);
module.releasesLoaded = true;
onlineModules.replace(packageName, module);
for (RepoListener listener : listeners) {
listener.onModuleReleasesLoaded(module);
}
} catch (Throwable t) {
Log.e(App.TAG, Log.getStackTraceString(t));
for (RepoListener listener : listeners) {
listener.onThrowable(t);
}
}
}
}
}
});
}
public void addListener(RepoListener listener) {
listeners.add(listener);
}
public void removeListener(RepoListener listener) {
listeners.remove(listener);
}
@Nullable
public OnlineModule getOnlineModule(String packageName) {
return repoLoaded && packageName != null ? onlineModules.get(packageName) : null;
}
@Nullable
public Collection getOnlineModules() {
return repoLoaded ? onlineModules.values() : null;
}
public interface RepoListener {
default void onRepoLoaded() {
}
default void onModuleReleasesLoaded(OnlineModule module) {
}
default void onThrowable(Throwable t) {
Log.e(App.TAG, "load repo failed", t);
}
}
}
================================================
FILE: app/src/main/java/org/lsposed/manager/repo/model/Collaborator.java
================================================
/*
* This file is part of LSPosed.
*
* LSPosed is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LSPosed is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LSPosed. If not, see .
*
* Copyright (C) 2020 EdXposed Contributors
* Copyright (C) 2021 LSPosed Contributors
*/
package org.lsposed.manager.repo.model;
import androidx.annotation.Nullable;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class Collaborator {
@SerializedName("login")
@Expose
private String login;
@SerializedName("name")
@Expose
private String name;
@Nullable
public String getLogin() {
return login;
}
public void setLogin(String login) {
this.login = login;
}
@Nullable
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
================================================
FILE: app/src/main/java/org/lsposed/manager/repo/model/OnlineModule.java
================================================
/*
* This file is part of LSPosed.
*
* LSPosed is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LSPosed is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LSPosed. If not, see .
*
* Copyright (C) 2020 EdXposed Contributors
* Copyright (C) 2021 LSPosed Contributors
*/
package org.lsposed.manager.repo.model;
import androidx.annotation.Nullable;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import java.util.ArrayList;
import java.util.List;
public class OnlineModule {
@SerializedName("name")
@Expose
private String name;
@SerializedName("description")
@Expose
private String description;
@SerializedName("url")
@Expose
private String url;
@SerializedName("homepageUrl")
@Expose
private String homepageUrl;
@SerializedName("collaborators")
@Expose
private List collaborators = new ArrayList<>();
@SerializedName("latestRelease")
@Expose
private String latestRelease;
@SerializedName("latestReleaseTime")
@Expose
private String latestReleaseTime;
@SerializedName("latestBetaRelease")
@Expose
private String latestBetaRelease;
@SerializedName("latestBetaReleaseTime")
@Expose
private String latestBetaReleaseTime;
@SerializedName("latestSnapshotRelease")
@Expose
private String latestSnapshotRelease;
@SerializedName("latestSnapshotReleaseTime")
@Expose
private String latestSnapshotReleaseTime;
@SerializedName("releases")
@Expose
private List releases = new ArrayList<>();
@SerializedName("betaReleases")
@Expose
private final List betaReleases = new ArrayList<>();
@SerializedName("snapshotReleases")
@Expose
private final List snapshotReleases = new ArrayList<>();
@SerializedName("readme")
@Expose
private String readme;
@SerializedName("readmeHTML")
@Expose
private String readmeHTML;
@SerializedName("summary")
@Expose
private String summary;
@SerializedName("scope")
@Expose
private List scope = new ArrayList<>();
@SerializedName("sourceUrl")
@Expose
private String sourceUrl;
@SerializedName("hide")
@Expose
private Boolean hide;
@SerializedName("additionalAuthors")
@Expose
private List