From c0d3623a319c93da0b6e6287d0402a9a0ef19061 Mon Sep 17 00:00:00 2001 From: zhiping <47056144+ikws4@users.noreply.github.com> Date: Tue, 19 May 2020 22:17:54 +0800 Subject: [PATCH 1/5] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bc7a306..dd68c5c 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ allprojects { Step 2. Add the dependency ```gradle dependencies { - implementation 'com.github.ikws4:KXposedHelper:1.0' + implementation 'com.github.ikws4:KXposedHelper:1.1' } ``` From 80a7a3bcf8ce9ee755809ed30330e94b1e71f6c6 Mon Sep 17 00:00:00 2001 From: zhiping <47056144+ikws4@users.noreply.github.com> Date: Tue, 19 May 2020 22:34:51 +0800 Subject: [PATCH 2/5] Update README.md --- README.md | 46 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index dd68c5c..a345ed4 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,11 @@ dependencies { # Catalogue 1. [How to hook method?](#How-to-hook-method?) + 1. [Simple to use](#Simple-to-use) + 2. [Before and after hook](#Before-and-after-hook) + 3. [Replece method](#Replece-method) + 4. [Change return value](#Change-return-value) + 5. [Some utilities in hook](#Some-utilities-in-hook) 2. [How to use KXSharedPreferences?](#How-to-use-KXSharedPreferences?) 3. [How to use KXBroadcastReceiver?](#How-to-use-KXBroadcastReceiver?) @@ -39,7 +44,7 @@ KXposedHelpers.findAndHookMethod(Activity::class, "onCreate", parameterTypes = a }) ``` -#### Before and After Hook +#### Before and after hook ```kotlin KXposedHelpers.findAndHookMethod(Activity::class, "onStart", methodHook = MethodHook( beforeHookedMethod = { param-> @@ -62,6 +67,12 @@ KXposedHelpers.findAndHookMethod(TextView::class, "getText", methodHook = Method }) ``` +#### Some utilities in hook +```kotlin +// ActivityHookHelper + +``` + ### How to use KXSharedPreferences? In high Android version, because the security permission, and the XSharedPreferences not working very well, so I created the utility for SharedPreferences called KXSharedPreferences, it's use the ContentProvider to shared preferences across the applications. @@ -81,3 +92,36 @@ sp.getString("key","defValue") ### How to use KXBroadcastReceiver? Sometimes you need to receive some broadcasts from your app, so this can help you easily to receiver broadcasts. + +Step 1. you need to implement KXBroadcastReceiver. +```kotlin +class BarBroadReceiver : KXBroadcastReceiver() { + override val intentFilter: IntentFilter + get() = IntentFilter().apply { + addAction("Action1") + addAction("Action2") + } +} +``` + +Step 2. register, unregister and listening +```kotlin +val barBroadReceiver = BarBroadReceiver() + +barBroadReceiver.setOnReceiveListener { context, intent -> + when (intent.action) { + "Action1" -> { + } + "Action2" -> { + } + } +} + +ActivityHookHelper.onCreate { + barBroadReceiver.register(this) +} + +ActivityHookHelper.onDestroy { + barBroadReceiver.unRegister(this) +} +``` From dfc26e6573d227be72898bdc7cacce997069d086 Mon Sep 17 00:00:00 2001 From: zhiping <47056144+ikws4@users.noreply.github.com> Date: Tue, 19 May 2020 23:39:18 +0800 Subject: [PATCH 3/5] Update README.md --- README.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a345ed4..21efe34 100644 --- a/README.md +++ b/README.md @@ -69,8 +69,14 @@ KXposedHelpers.findAndHookMethod(TextView::class, "getText", methodHook = Method #### Some utilities in hook ```kotlin -// ActivityHookHelper - +// ActivityHookHelper for Activity lifecycle hook +ActivityHookHelper.onCreate { } +ActivityHookHelper.onDestroy { } +... + +// ApplicationHookHelper +ApplicationHookHelper.onCreate { } +ApplicationHookHelper.attach { } ``` ### How to use KXSharedPreferences? From 8566d5b7b93f3787ececb63898a82d7a08ab1d7f Mon Sep 17 00:00:00 2001 From: zhiping <47056144+ikws4@users.noreply.github.com> Date: Tue, 19 May 2020 23:41:36 +0800 Subject: [PATCH 4/5] Create LICENSE --- LICENSE | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..dfd9757 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 zhiping + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. From 2583aa389fb80ea55430f50625c380b510383803 Mon Sep 17 00:00:00 2001 From: zhiping <47056144+ikws4@users.noreply.github.com> Date: Tue, 19 May 2020 23:43:36 +0800 Subject: [PATCH 5/5] Update README.md --- README.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/README.md b/README.md index 21efe34..d81e118 100644 --- a/README.md +++ b/README.md @@ -131,3 +131,28 @@ ActivityHookHelper.onDestroy { barBroadReceiver.unRegister(this) } ``` + +## LICENSE +``` +MIT License + +Copyright (c) 2020 zhiping + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +```