@@ -42,6 +42,7 @@ open class SettingStore(
4242 const val AUTO_LOCK_TIME = " auto_lock_time"
4343 const val DEVICE_SECURITY_PRESENT = " device_security_present"
4444 const val UNLOCK_WITH_FINGERPRINT_PENDING_AUTH = " unlock_with_fingerprint_pending_auth"
45+ const val USE_LOCAL_SERVICE = " use_local_service"
4546 }
4647
4748 private lateinit var preferences: SharedPreferences
@@ -53,6 +54,7 @@ open class SettingStore(
5354 private val _autoLockTime = ReplaySubject .createWithSize<Setting .AutoLockTime >(1 )
5455
5556 open val sendUsageData: Observable <Boolean > = ReplaySubject .createWithSize(1 )
57+ open val useLocalService: Observable <Boolean > = ReplaySubject .createWithSize(1 )
5658 open val itemListSortOrder: Observable <Setting .ItemListSort > = ReplaySubject .createWithSize(1 )
5759 open val unlockWithFingerprint: Observable <Boolean > = ReplaySubject .createWithSize(1 )
5860 open val autoLockTime: Observable <Setting .AutoLockTime >
@@ -86,6 +88,8 @@ open class SettingStore(
8688 when (it) {
8789 is SettingAction .SendUsageData ->
8890 edit.putBoolean(Keys .SEND_USAGE_DATA , it.sendUsageData)
91+ is SettingAction .UseLocalService ->
92+ edit.putBoolean(Keys .USE_LOCAL_SERVICE , it.useLocalService)
8993 is SettingAction .ItemListSortOrder ->
9094 edit.putString(Keys .ITEM_LIST_SORT_ORDER , it.sortOrder.name)
9195 is SettingAction .UnlockWithFingerprint ->
@@ -98,6 +102,7 @@ open class SettingStore(
98102 handleAutofill(it.enable)
99103 is SettingAction .Reset -> {
100104 edit.putBoolean(Keys .SEND_USAGE_DATA , Constant .SettingDefault .sendUsageData)
105+ edit.putBoolean(Keys .USE_LOCAL_SERVICE , Constant .SettingDefault .useLocalServiceFalse)
101106 edit.putString(Keys .ITEM_LIST_SORT_ORDER , Constant .SettingDefault .itemListSort.name)
102107 edit.putBoolean(Keys .UNLOCK_WITH_FINGERPRINT , Constant .SettingDefault .unlockWithFingerprint)
103108 edit.putString(Keys .AUTO_LOCK_TIME , Constant .SettingDefault .autoLockTime.name)
@@ -110,7 +115,15 @@ open class SettingStore(
110115 }
111116
112117 override fun injectContext (context : Context ) {
118+ val chinaBuild = context.resources.configuration.locales.get(0 ).toString().equals(" zh_CN_#Hans" ) &&
119+ context.resources.configuration.locales.get(0 ).displayLanguage.equals(" 中文" ) &&
120+ (! " com.android.vending" .equals(context.packageManager.getInstallerPackageName(context.packageName)))
113121 preferences = PreferenceManager .getDefaultSharedPreferences(context)
122+ if (chinaBuild) {
123+ preferences.edit().putBoolean(Keys .USE_LOCAL_SERVICE , Constant .SettingDefault .useLocalServiceTrue).apply ()
124+ } else {
125+ preferences.edit().putBoolean(Keys .USE_LOCAL_SERVICE , Constant .SettingDefault .useLocalServiceFalse).apply ()
126+ }
114127
115128 val rxPrefs = RxSharedPreferences .create(preferences)
116129
@@ -119,6 +132,18 @@ open class SettingStore(
119132 .asObservable()
120133 .subscribe(sendUsageData as Subject )
121134
135+ if (chinaBuild) {
136+ rxPrefs
137+ .getBoolean(Keys .USE_LOCAL_SERVICE , Constant .SettingDefault .useLocalServiceTrue)
138+ .asObservable()
139+ .subscribe(useLocalService as Subject )
140+ } else {
141+ rxPrefs
142+ .getBoolean(Keys .USE_LOCAL_SERVICE , Constant .SettingDefault .useLocalServiceFalse)
143+ .asObservable()
144+ .subscribe(useLocalService as Subject )
145+ }
146+
122147 rxPrefs
123148 .getString(Keys .ITEM_LIST_SORT_ORDER , Constant .SettingDefault .itemListSort.name)
124149 .asObservable()
0 commit comments