Skip to content

Commit 390ee9e

Browse files
committed
Modify change YukiHookModulePrefs name to YukiHookPrefsBridge and make it support native storage usage in YukiHookPrefsBridge
1 parent e298f19 commit 390ee9e

File tree

23 files changed

+448
-184
lines changed

23 files changed

+448
-184
lines changed

docs-source/src/.vuepress/configs/template.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const navigationLinks = {
2929
baseApiPath + 'hook/param/HookParam',
3030
baseApiPath + 'annotation/xposed/InjectYukiHookWithXposed',
3131
baseApiPath + 'hook/xposed/proxy/IYukiHookXposedInit',
32-
baseApiPath + 'hook/xposed/prefs/YukiHookModulePrefs',
32+
baseApiPath + 'hook/xposed/prefs/YukiHookPrefsBridge',
3333
baseApiPath + 'hook/xposed/prefs/ui/ModulePreferenceFragment',
3434
baseApiPath + 'hook/xposed/prefs/data/PrefsData',
3535
baseApiPath + 'hook/xposed/channel/YukiHookDataChannel',

docs-source/src/en/about/future.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
> Here are the unresolved issues with `YukiHookAPI`.
88
9-
### YukiHookModulePrefs
9+
### YukiHookPrefsBridge
1010

1111
Currently only supports LSPosed perfectly, other Xposed Framework need to downgrade the module target api.
1212

docs-source/src/en/api/public/com/highcapable/yukihookapi/YukiHookAPI.md

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -404,23 +404,33 @@ var isDebug: Boolean
404404

405405
请转移到 `YukiHookLogger.Configs.isEnable`
406406

407-
### isEnableModulePrefsCache <span class="symbol">- field</span>
407+
<h3 class="deprecated">isEnableModulePrefsCache - field</h3>
408+
409+
**Change Records**
410+
411+
`v1.0.5` `added`
412+
413+
`v1.1.9` `deprecated`
414+
415+
请转移到 `isEnablePrefsBridgeCache`
416+
417+
### isEnablePrefsBridgeCache <span class="symbol">- field</span>
408418

409419
```kotlin:no-line-numbers
410-
var isEnableModulePrefsCache: Boolean
420+
var isEnablePrefsBridgeCache: Boolean
411421
```
412422

413423
**Change Records**
414424

415-
`v1.0.5` `added`
425+
`v1.1.9` `added`
416426

417427
**Function Illustrate**
418428

419-
> 是否启用 `YukiHookModulePrefs` 的键值缓存功能。
429+
> 是否启用 `YukiHookPrefsBridge` 的键值缓存功能。
420430
421431
为防止内存复用过高问题,此功能默认启用。
422432

423-
你可以手动在 `YukiHookModulePrefs` 中自由开启和关闭缓存功能以及清除缓存。
433+
你可以手动在 `YukiHookPrefsBridge` 中自由开启和关闭缓存功能以及清除缓存。
424434

425435
### isEnableModuleAppResourcesCache <span class="symbol">- field</span>
426436

@@ -488,7 +498,7 @@ var isEnableHookSharedPreferences: Boolean
488498

489499
这是一个可选的实验性功能,此功能默认不启用。
490500

491-
仅用于修复某些系统可能会出现在启用了 **New XSharedPreferences** 后依然出现文件权限错误问题,若你能正常使用 **YukiHookModulePrefs** 就不建议启用此功能。
501+
仅用于修复某些系统可能会出现在启用了 **New XSharedPreferences** 后依然出现文件权限错误问题,若你能正常使用 **YukiHookPrefsBridge** 就不建议启用此功能。
492502

493503
:::
494504

@@ -572,7 +582,7 @@ object HookEntry : IYukiHookXposedInit {
572582
elements(TAG, PRIORITY, PACKAGE_NAME, USER_ID)
573583
}
574584
isDebug = BuildConfig.DEBUG
575-
isEnableModulePrefsCache = true
585+
isEnablePrefsBridgeCache = true
576586
isEnableModuleAppResourcesCache = true
577587
isEnableHookModuleStatus = true
578588
isEnableHookSharedPreferences = false
@@ -602,7 +612,7 @@ object HookEntry : IYukiHookXposedInit {
602612
elements(TAG, PRIORITY, PACKAGE_NAME, USER_ID)
603613
}
604614
isDebug = BuildConfig.DEBUG
605-
isEnableModulePrefsCache = true
615+
isEnablePrefsBridgeCache = true
606616
isEnableModuleAppResourcesCache = true
607617
isEnableHookModuleStatus = true
608618
isEnableHookSharedPreferences = false
@@ -634,7 +644,7 @@ object HookEntry : IYukiHookXposedInit {
634644
YukiHookLogger.Configs.USER_ID
635645
)
636646
YukiHookAPI.Configs.isDebug = BuildConfig.DEBUG
637-
YukiHookAPI.Configs.isEnableModulePrefsCache = true
647+
YukiHookAPI.Configs.isEnablePrefsBridgeCache = true
638648
YukiHookAPI.Configs.isEnableModuleAppResourcesCache = true
639649
YukiHookAPI.Configs.isEnableHookModuleStatus = true
640650
YukiHookAPI.Configs.isEnableHookSharedPreferences = false

docs-source/src/en/api/public/com/highcapable/yukihookapi/hook/factory/YukiHookFactory.md

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,33 +64,45 @@ fun IYukiHookXposedInit.encase(vararg hooker: YukiBaseHooker)
6464

6565
> `IYukiHookXposedInit` 中调用 `YukiHookAPI`
6666
67-
## Context.modulePrefs <span class="symbol">- ext-field</span>
67+
<h2 class="deprecated">Context.modulePrefs - ext-field</h2>
6868

69-
```kotlin:no-line-numbers
70-
val Context.modulePrefs: YukiHookModulePrefs
71-
```
69+
**Change Records**
70+
71+
`v1.0` `first`
72+
73+
`v1.1.9` `deprecated`
74+
75+
请转移到 `prefs` 方法
76+
77+
<h2 class="deprecated">Context.modulePrefs - ext-method</h2>
7278

7379
**Change Records**
7480

7581
`v1.0` `first`
7682

77-
**Function Illustrate**
83+
`v1.1.9` `deprecated`
7884

79-
> 获取模块的存取对象。
85+
请转移到 `prefs` 方法
8086

81-
## Context.modulePrefs <span class="symbol">- ext-method</span>
87+
## Context.prefs <span class="symbol">- ext-method</span>
8288

8389
```kotlin:no-line-numbers
84-
fun Context.modulePrefs(name: String): YukiHookModulePrefs
90+
fun Context.prefs(name: String): YukiHookPrefsBridge
8591
```
8692

8793
**Change Records**
8894

89-
`v1.0` `first`
95+
`v1.1.9` `added`
9096

9197
**Function Illustrate**
9298

93-
> 获取模块的存取对象,可设置 `name` 为自定义 Sp 存储名称。
99+
> 获取 `YukiHookPrefsBridge` 对象。
100+
101+
可以同时在模块与 (Xposed) 宿主环境中使用。
102+
103+
如果你想在 (Xposed) 宿主环境将数据存入当前宿主的私有空间,请使用 `YukiHookPrefsBridge.native` 方法。
104+
105+
在未声明任何条件的情况下 (Xposed) 宿主环境默认读取模块中的数据。
94106

95107
## Context.dataChannel <span class="symbol">- ext-method</span>
96108

docs-source/src/en/api/public/com/highcapable/yukihookapi/hook/param/PackageParam.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ val moduleAppResources: YukiModuleResources
243243
## prefs <span class="symbol">- field</span>
244244

245245
```kotlin:no-line-numbers
246-
val prefs: YukiHookModulePrefs
246+
val prefs: YukiHookPrefsBridge
247247
```
248248

249249
**Change Records**
@@ -263,7 +263,7 @@ val prefs: YukiHookModulePrefs
263263
## prefs <span class="symbol">- method</span>
264264

265265
```kotlin:no-line-numbers
266-
fun prefs(name: String): YukiHookModulePrefs
266+
fun prefs(name: String): YukiHookPrefsBridge
267267
```
268268

269269
**Change Records**

docs-source/src/en/api/public/com/highcapable/yukihookapi/hook/xposed/prefs/YukiHookModulePrefs.md renamed to docs-source/src/en/api/public/com/highcapable/yukihookapi/hook/xposed/prefs/YukiHookPrefsBridge.md

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,29 @@ You can use the **Chrome Translation Plugin** to translate entire pages for refe
1010

1111
:::
1212

13-
# YukiHookModulePrefs <span class="symbol">- class</span>
13+
# YukiHookPrefsBridge <span class="symbol">- class</span>
1414

1515
```kotlin:no-line-numbers
16-
class YukiHookModulePrefs private constructor(private var context: Context?)
16+
class YukiHookPrefsBridge private constructor(private var context: Context?)
1717
```
1818

1919
**Change Records**
2020

2121
`v1.0` `first`
2222

23+
`v1.1.9` `modified`
24+
25+
~~`YukiHookModulePrefs`~~ 更名为 `YukiHookPrefsBridge`
26+
2327
**Function Illustrate**
2428

25-
> 实现 Xposed 模块的数据存取,对接 `SharedPreferences``XSharedPreferences`
29+
> `YukiHookAPI``SharedPreferences``XSharedPreferences` 的扩展存储桥实现
2630
2731
在不同环境智能选择存取使用的对象。
2832

2933
::: danger
3034

31-
此功能为实验性功能,仅在 LSPosed 环境测试通过,EdXposed 理论也可以使用但不再推荐。
35+
模块与宿主之前共享数据存储为实验性功能,仅在 LSPosed 环境测试通过,EdXposed 理论也可以使用但不再推荐。
3236

3337
:::
3438

@@ -42,13 +46,7 @@ class YukiHookModulePrefs private constructor(private var context: Context?)
4246

4347
太极请参阅 [文件权限/配置/XSharedPreference](https://taichi.cool/zh/doc/for-xposed-dev.html#文件权限-配置-xsharedpreference)
4448

45-
::: danger
46-
47-
当你在 Xposed 模块中存取数据的时候 **context** 必须不能是空的。
48-
49-
:::
50-
51-
若你正在使用 `PreferenceFragmentCompat`,请迁移到 `ModulePreferenceFragment` 以适配上述功能特性。
49+
对于在模块环境中使用 `PreferenceFragmentCompat``YukiHookAPI` 提供了 `ModulePreferenceFragment` 来实现同样的功能。
5250

5351
**Optional Configuration**
5452

@@ -96,7 +94,7 @@ val isPreferencesAvailable: Boolean
9694

9795
**Function Illustrate**
9896

99-
> 获取当前 `YukiHookModulePrefs` 的可用状态。
97+
> 获取当前 `YukiHookPrefsBridge` 的可用状态。
10098
10199
在 (Xposed) 宿主环境中返回 `XSharedPreferences` 可用状态 (可读)。
102100

@@ -105,7 +103,7 @@ val isPreferencesAvailable: Boolean
105103
## name <span class="symbol">- method</span>
106104

107105
```kotlin:no-line-numbers
108-
fun name(name: String): YukiHookModulePrefs
106+
fun name(name: String): YukiHookPrefsBridge
109107
```
110108

111109
**Change Records**
@@ -123,7 +121,7 @@ fun name(name: String): YukiHookModulePrefs
123121
> The following example
124122
125123
```kotlin
126-
modulePrefs("custom_name").getString("custom_key")
124+
prefs("custom_name").getString("custom_key")
127125
```
128126

129127
在 (Xposed) 宿主环境 `PackageParam` 中的使用方法。
@@ -137,7 +135,7 @@ prefs("custom_name").getString("custom_key")
137135
## direct <span class="symbol">- method</span>
138136

139137
```kotlin:no-line-numbers
140-
fun direct(): YukiHookModulePrefs
138+
fun direct(): YukiHookPrefsBridge
141139
```
142140

143141
**Change Records**
@@ -148,10 +146,24 @@ fun direct(): YukiHookModulePrefs
148146

149147
> 忽略缓存直接读取键值。
150148
151-
无论是否开启 `YukiHookAPI.Configs.isEnableModulePrefsCache`
149+
无论是否开启 `YukiHookAPI.Configs.isEnablePrefsBridgeCache`
152150

153151
仅在 `XSharedPreferences` 下生效。
154152

153+
## native <span class="symbol">- method</span>
154+
155+
```kotlin:no-line-numbers
156+
fun native(): YukiHookPrefsBridge
157+
```
158+
159+
**Change Records**
160+
161+
`v1.1.9` `added`
162+
163+
**Function Illustrate**
164+
165+
> 忽略当前环境直接使用 `Context.getSharedPreferences` 存取数据。
166+
155167
## getString <span class="symbol">- method</span>
156168

157169
```kotlin:no-line-numbers
@@ -434,7 +446,7 @@ fun clearCache()
434446

435447
> 清除 `XSharedPreferences` 中缓存的键值数据。
436448
437-
无论是否开启 `YukiHookAPI.Configs.isEnableModulePrefsCache`
449+
无论是否开启 `YukiHookAPI.Configs.isEnablePrefsBridgeCache`
438450

439451
调用此方法将清除当前存储的全部键值缓存。
440452

@@ -454,7 +466,7 @@ inner class Editor internal constructor()
454466

455467
**Function Illustrate**
456468

457-
> `YukiHookModulePrefs` 的存储代理类。
469+
> `YukiHookPrefsBridge` 的存储代理类。
458470
459471
请使用 `edit` 方法来获取 `Editor`
460472

docs-source/src/en/api/public/com/highcapable/yukihookapi/hook/xposed/prefs/data/PrefsData.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ data class PrefsData<T>(var key: String, var value: T) : Serializable
2828

2929
> 键值对存储构造类。
3030
31-
这个类是对 `YukiHookModulePrefs` 的一个扩展用法。
31+
这个类是对 `YukiHookPrefsBridge` 的一个扩展用法。
3232

3333
**Function Example**
3434

@@ -51,9 +51,9 @@ object DataConst {
5151
5252
```kotlin
5353
// 读取
54-
val data = modulePrefs.get(DataConst.TEST_KV_DATA_1)
54+
val data = prefs().get(DataConst.TEST_KV_DATA_1)
5555
// 写入
56-
modulePrefs.put(DataConst.TEST_KV_DATA_1, "written value")
56+
prefs().edit { put(DataConst.TEST_KV_DATA_1, "written value") }
5757
```
5858

5959
> 宿主示例如下

0 commit comments

Comments
 (0)