NSCv3: split preference xml

This commit is contained in:
Milos Kozak 2023-01-20 22:55:48 +01:00
parent 27e91182a1
commit f877bb5fb9
4 changed files with 218 additions and 12 deletions

View file

@ -156,7 +156,6 @@ class NSClientPlugin @Inject constructor(
if (activePlugin.activeBgSource is DoingOwnUploadSource) { if (activePlugin.activeBgSource is DoingOwnUploadSource) {
preferenceFragment.findPreference<SwitchPreference>(rh.gs(info.nightscout.core.utils.R.string.key_do_ns_upload))?.isVisible = false preferenceFragment.findPreference<SwitchPreference>(rh.gs(info.nightscout.core.utils.R.string.key_do_ns_upload))?.isVisible = false
} }
preferenceFragment.findPreference<ValidatingEditTextPreference>(rh.gs(R.string.key_ns_client_token))?.isVisible = false
} }
override val hasWritePermission: Boolean get() = nsClientService?.hasWriteAuth ?: false override val hasWritePermission: Boolean get() = nsClientService?.hasWriteAuth ?: false

View file

@ -111,7 +111,7 @@ class NSClientV3Plugin @Inject constructor(
.pluginIcon(info.nightscout.core.ui.R.drawable.ic_nightscout_syncs) .pluginIcon(info.nightscout.core.ui.R.drawable.ic_nightscout_syncs)
.pluginName(R.string.ns_client_v3) .pluginName(R.string.ns_client_v3)
.shortName(R.string.ns_client_v3_short_name) .shortName(R.string.ns_client_v3_short_name)
.preferencesId(R.xml.pref_ns_client) .preferencesId(R.xml.pref_ns_client_v3)
.description(R.string.description_ns_client_v3), .description(R.string.description_ns_client_v3),
aapsLogger, rh, injector aapsLogger, rh, injector
) { ) {
@ -239,7 +239,6 @@ class NSClientV3Plugin @Inject constructor(
preferenceFragment.findPreference<SwitchPreference>(rh.gs(info.nightscout.core.utils.R.string.key_ns_create_announcements_from_carbs_req))?.isVisible = false preferenceFragment.findPreference<SwitchPreference>(rh.gs(info.nightscout.core.utils.R.string.key_ns_create_announcements_from_carbs_req))?.isVisible = false
} }
preferenceFragment.findPreference<SwitchPreference>(rh.gs(R.string.key_ns_receive_tbr_eb))?.isVisible = config.isEngineeringMode() preferenceFragment.findPreference<SwitchPreference>(rh.gs(R.string.key_ns_receive_tbr_eb))?.isVisible = config.isEngineeringMode()
preferenceFragment.findPreference<ValidatingEditTextPreference>(rh.gs(info.nightscout.core.utils.R.string.key_nsclientinternal_api_secret))?.isVisible = false
} }
override val hasWritePermission: Boolean get() = nsAndroidClient?.lastStatus?.apiPermissions?.isFull() ?: false override val hasWritePermission: Boolean get() = nsAndroidClient?.lastStatus?.apiPermissions?.isFull() ?: false

View file

@ -26,15 +26,6 @@
validate:minLength="12" validate:minLength="12"
validate:testType="minLength"/> validate:testType="minLength"/>
<info.nightscout.core.validators.ValidatingEditTextPreference
android:dialogMessage="@string/nsclient_token_dialog_message"
android:dialogTitle="@string/nsclient_token_dialog_title"
android:inputType="textPassword"
android:key="@string/key_ns_client_token"
android:title="@string/nsclient_token_title"
validate:minLength="17"
validate:testType="minLength"/>
<androidx.preference.PreferenceScreen <androidx.preference.PreferenceScreen
android:key="@string/ns_sync_options" android:key="@string/ns_sync_options"
android:title="@string/ns_sync_options"> android:title="@string/ns_sync_options">

View file

@ -0,0 +1,217 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:validate="http://schemas.android.com/apk/res-auto">
<PreferenceCategory
android:key="@string/key_ns_client_settings"
android:title="@string/ns_client_internal_title"
app:initialExpandedChildrenCount="0">
<info.nightscout.core.validators.ValidatingEditTextPreference
android:defaultValue="https://{YOUR-SITE}.azurewebsites.net/"
android:dialogMessage="@string/ns_client_url_dialog_message"
android:inputType="textUri"
android:key="@string/key_nsclientinternal_url"
android:selectAllOnFocus="true"
android:title="@string/ns_client_url_title"
validate:testType="httpsUrl" />
<info.nightscout.core.validators.ValidatingEditTextPreference
android:dialogMessage="@string/nsclient_token_dialog_message"
android:dialogTitle="@string/nsclient_token_dialog_title"
android:inputType="textPassword"
android:key="@string/key_ns_client_token"
android:title="@string/nsclient_token_title"
validate:minLength="17"
validate:testType="minLength"/>
<androidx.preference.PreferenceScreen
android:key="@string/ns_sync_options"
android:title="@string/ns_sync_options">
<SwitchPreference
android:defaultValue="true"
android:key="@string/key_ns_upload"
android:summary="@string/ns_upload_summary"
android:title="@string/ns_upload" />
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_do_ns_upload"
android:title="@string/do_ns_upload_title" />
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_ns_receive_cgm"
android:summary="@string/ns_receive_cgm_summary"
android:title="@string/ns_receive_cgm" />
<SwitchPreference
android:defaultValue="true"
android:key="@string/key_ns_receive_profile_store"
android:summary="@string/ns_receive_profile_store_summary"
android:title="@string/ns_receive_profile_store" />
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_ns_receive_temp_target"
android:summary="@string/ns_receive_temp_target_summary"
android:title="@string/ns_receive_temp_target" />
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_ns_receive_profile_switch"
android:summary="@string/ns_receive_profile_switch_summary"
android:title="@string/ns_receive_profile_switch" />
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_ns_receive_insulin"
android:summary="@string/ns_receive_insulin_summary"
android:title="@string/ns_receive_insulin" />
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_ns_receive_carbs"
android:summary="@string/ns_receive_carbs_summary"
android:title="@string/ns_receive_carbs" />
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_ns_receive_therapy_events"
android:summary="@string/ns_receive_therapy_events_summary"
android:title="@string/ns_receive_therapy_events" />
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_ns_receive_offline_event"
android:summary="@string/ns_receive_offline_event_summary"
android:title="@string/ns_receive_offline_event" />
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_ns_receive_tbr_eb"
android:summary="@string/ns_receive_tbr_eb_summary"
android:title="@string/ns_receive_tbr_eb" />
</androidx.preference.PreferenceScreen>>
<androidx.preference.PreferenceScreen
android:key="@string/ns_alarm_options"
android:title="@string/ns_alarm_options">
<SwitchPreference
android:key="@string/key_ns_alarms"
android:title="@string/ns_alarms" />
<SwitchPreference
android:key="@string/key_ns_announcements"
android:title="@string/ns_announcements" />
<info.nightscout.core.validators.ValidatingEditTextPreference
android:defaultValue="16"
android:digits="0123456789"
android:inputType="number"
android:key="@string/key_ns_alarm_stale_data_value"
android:maxLines="20"
android:selectAllOnFocus="true"
android:singleLine="true"
android:title="@string/ns_alarm_stale_data_value_label"
validate:maxNumber="120"
validate:minNumber="15"
validate:testType="numericRange" />
<info.nightscout.core.validators.ValidatingEditTextPreference
android:defaultValue="31"
android:digits="0123456789"
android:inputType="number"
android:key="@string/key_ns_alarm_urgent_stale_data_value"
android:maxLines="20"
android:selectAllOnFocus="true"
android:singleLine="true"
android:title="@string/ns_alarm_urgent_stale_data_value_label"
validate:maxNumber="180"
validate:minNumber="30"
validate:testType="numericRange" />
</androidx.preference.PreferenceScreen>
<androidx.preference.PreferenceScreen
android:key="@string/connection_settings_title"
android:title="@string/connection_settings_title">
<SwitchPreference
android:defaultValue="true"
android:key="@string/key_ns_cellular"
android:title="@string/ns_cellular" />
<SwitchPreference
android:defaultValue="true"
android:dependency="@string/key_ns_cellular"
android:key="@string/key_ns_allow_roaming"
android:title="@string/ns_allow_roaming" />
<SwitchPreference
android:defaultValue="true"
android:key="@string/key_ns_wifi"
android:title="@string/ns_wifi" />
<EditTextPreference
android:dialogMessage="@string/ns_wifi_allowed_ssids"
android:dependency="@string/key_ns_wifi"
android:inputType="text"
android:key="@string/key_ns_wifi_ssids"
android:title="@string/ns_wifi_ssids" />
<SwitchPreference
android:defaultValue="true"
android:key="@string/key_ns_battery"
android:title="@string/ns_battery" />
<SwitchPreference
android:defaultValue="true"
android:key="@string/key_ns_charging"
android:title="@string/ns_charging" />
</androidx.preference.PreferenceScreen>
<androidx.preference.PreferenceScreen
android:key="nsclient_advanced"
android:title="@string/advancedsettings_title">
<SwitchPreference
android:defaultValue="true"
android:key="@string/key_ns_log_app_started_event"
android:title="@string/ns_log_app_started_event"
android:summary="@string/ns_log_app_started_event"
/>
<SwitchPreference
android:defaultValue="true"
android:key="@string/key_ns_create_announcements_from_errors"
android:summary="@string/ns_create_announcements_from_errors_summary"
android:title="@string/ns_create_announcements_from_errors_title" />
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_ns_create_announcements_from_carbs_req"
android:summary="@string/ns_create_announcements_from_carbs_req_summary"
android:title="@string/ns_create_announcements_from_carbs_req_title" />
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_nsclient_localbroadcasts"
android:summary="@string/ns_local_broadcasts"
android:title="@string/ns_local_broadcasts_title" />
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_ns_sync_slow"
android:title="@string/ns_sync_slow" />
</androidx.preference.PreferenceScreen>
</PreferenceCategory>
</androidx.preference.PreferenceScreen>