Textvalidator (#2343), Preference to jetpack

This commit is contained in:
Milos Kozak 2020-01-08 20:20:20 +01:00 committed by GitHub
parent e0f665383b
commit 5c8c263c17
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
82 changed files with 1418 additions and 496 deletions

View file

@ -244,8 +244,9 @@ dependencies {
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'androidx.gridlayout:gridlayout:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.percentlayout:percentlayout:1.0.0'
implementation "androidx.preference:preference-ktx:1.1.0"
implementation 'com.google.android.material:material:1.0.0'
implementation 'com.wdullaer:materialdatetimepicker:4.2.3'
implementation "io.reactivex.rxjava2:rxandroid:2.1.1"
@ -261,7 +262,6 @@ dependencies {
implementation "com.jjoe64:graphview:4.0.1"
implementation "com.joanzapata.iconify:android-iconify-fontawesome:2.2.2"
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation(name: "android-edittext-validator-v1.3.4-mod", ext: "aar")
implementation 'com.madgag.spongycastle:core:1.58.0.0'
implementation("com.google.android:flexbox:0.3.0") {

View file

@ -1,177 +0,0 @@
package info.nightscout.androidaps.activities;
import android.os.Bundle;
import android.preference.PreferenceFragment;
import javax.inject.Inject;
import dagger.android.AndroidInjection;
import dagger.android.AndroidInjector;
import dagger.android.DispatchingAndroidInjector;
import dagger.android.HasAndroidInjector;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin;
import info.nightscout.androidaps.plugins.aps.openAPSAMA.OpenAPSAMAPlugin;
import info.nightscout.androidaps.plugins.aps.openAPSMA.OpenAPSMAPlugin;
import info.nightscout.androidaps.plugins.aps.openAPSSMB.OpenAPSSMBPlugin;
import info.nightscout.androidaps.plugins.constraints.safety.SafetyPlugin;
import info.nightscout.androidaps.plugins.general.automation.AutomationPlugin;
import info.nightscout.androidaps.plugins.general.careportal.CareportalPlugin;
import info.nightscout.androidaps.plugins.general.nsclient.NSClientPlugin;
import info.nightscout.androidaps.plugins.general.smsCommunicator.SmsCommunicatorPlugin;
import info.nightscout.androidaps.plugins.general.tidepool.TidepoolPlugin;
import info.nightscout.androidaps.plugins.general.wear.WearPlugin;
import info.nightscout.androidaps.plugins.general.xdripStatusline.StatusLinePlugin;
import info.nightscout.androidaps.plugins.insulin.InsulinOrefFreePeakPlugin;
import info.nightscout.androidaps.plugins.pump.combo.ComboPlugin;
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPlugin;
import info.nightscout.androidaps.plugins.pump.danaRKorean.DanaRKoreanPlugin;
import info.nightscout.androidaps.plugins.pump.danaRS.DanaRSPlugin;
import info.nightscout.androidaps.plugins.pump.danaRv2.DanaRv2Plugin;
import info.nightscout.androidaps.plugins.pump.insight.LocalInsightPlugin;
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin;
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin;
import info.nightscout.androidaps.plugins.sensitivity.SensitivityAAPSPlugin;
import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref0Plugin;
import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin;
import info.nightscout.androidaps.plugins.sensitivity.SensitivityWeightedAveragePlugin;
import info.nightscout.androidaps.plugins.source.DexcomPlugin;
import info.nightscout.androidaps.plugins.source.EversensePlugin;
import info.nightscout.androidaps.plugins.source.GlimpPlugin;
import info.nightscout.androidaps.plugins.source.PoctechPlugin;
import info.nightscout.androidaps.plugins.source.TomatoPlugin;
/**
* Created by adrian on 2019-12-23.
*/
public class MyPreferenceFragment extends PreferenceFragment implements HasAndroidInjector {
private Integer id;
@Inject DispatchingAndroidInjector<Object> androidInjector;
@Inject AutomationPlugin automationPlugin;
@Inject DanaRPlugin danaRPlugin;
@Inject DanaRKoreanPlugin danaRKoreanPlugin;
@Inject DanaRv2Plugin danaRv2Plugin;
@Inject DanaRSPlugin danaRSPlugin;
@Inject CareportalPlugin careportalPlugin;
@Inject InsulinOrefFreePeakPlugin insulinOrefFreePeakPlugin;
@Inject LoopPlugin loopPlugin;
@Inject OpenAPSAMAPlugin openAPSAMAPlugin;
@Inject OpenAPSMAPlugin openAPSMAPlugin;
@Inject OpenAPSSMBPlugin openAPSSMBPlugin;
@Inject SafetyPlugin safetyPlugin;
@Inject DexcomPlugin dexcomPlugin;
@Inject EversensePlugin eversensePlugin;
@Inject GlimpPlugin glimpPlugin;
@Inject PoctechPlugin poctechPlugin;
@Inject TomatoPlugin tomatoPlugin;
@Inject SmsCommunicatorPlugin smsCommunicatorPlugin;
@Inject StatusLinePlugin statusLinePlugin;
@Inject TidepoolPlugin tidepoolPlugin;
@Inject VirtualPumpPlugin virtualPumpPlugin;
@Inject WearPlugin wearPlugin;
@Override
public void setArguments(Bundle args) {
super.setArguments(args);
id = args.getInt("id");
}
void addPreferencesFromResourceIfEnabled(PluginBase p, PluginType type) {
if (p.isEnabled(type) && p.getPreferencesId() != -1)
addPreferencesFromResource(p.getPreferencesId());
}
@Override
public AndroidInjector<Object> androidInjector() {
return androidInjector;
}
@Override
public void onCreate(final Bundle savedInstanceState) {
AndroidInjection.inject(this);
super.onCreate(savedInstanceState);
if (savedInstanceState != null && savedInstanceState.containsKey("id")) {
id = savedInstanceState.getInt("id");
}
AndroidInjection.inject(this);
if (id != -1) {
addPreferencesFromResource(id);
} else {
if (!Config.NSCLIENT) {
addPreferencesFromResource(R.xml.pref_password);
}
addPreferencesFromResource(R.xml.pref_general);
addPreferencesFromResource(R.xml.pref_age);
addPreferencesFromResource(R.xml.pref_overview);
addPreferencesFromResourceIfEnabled(eversensePlugin, PluginType.BGSOURCE);
addPreferencesFromResourceIfEnabled(dexcomPlugin, PluginType.BGSOURCE);
addPreferencesFromResourceIfEnabled(tomatoPlugin, PluginType.BGSOURCE);
addPreferencesFromResourceIfEnabled(poctechPlugin, PluginType.BGSOURCE);
addPreferencesFromResourceIfEnabled(glimpPlugin, PluginType.BGSOURCE);
addPreferencesFromResourceIfEnabled(careportalPlugin, PluginType.GENERAL);
addPreferencesFromResourceIfEnabled(safetyPlugin, PluginType.CONSTRAINTS);
if (Config.APS) {
addPreferencesFromResourceIfEnabled(loopPlugin, PluginType.LOOP);
addPreferencesFromResourceIfEnabled(openAPSMAPlugin, PluginType.APS);
addPreferencesFromResourceIfEnabled(openAPSAMAPlugin, PluginType.APS);
addPreferencesFromResourceIfEnabled(openAPSSMBPlugin, PluginType.APS);
}
addPreferencesFromResourceIfEnabled(SensitivityAAPSPlugin.getPlugin(), PluginType.SENSITIVITY);
addPreferencesFromResourceIfEnabled(SensitivityWeightedAveragePlugin.getPlugin(), PluginType.SENSITIVITY);
addPreferencesFromResourceIfEnabled(SensitivityOref0Plugin.getPlugin(), PluginType.SENSITIVITY);
addPreferencesFromResourceIfEnabled(SensitivityOref1Plugin.getPlugin(), PluginType.SENSITIVITY);
if (Config.PUMPDRIVERS) {
addPreferencesFromResourceIfEnabled(danaRPlugin, PluginType.PUMP);
addPreferencesFromResourceIfEnabled(danaRKoreanPlugin, PluginType.PUMP);
addPreferencesFromResourceIfEnabled(danaRv2Plugin, PluginType.PUMP);
addPreferencesFromResourceIfEnabled(danaRSPlugin, PluginType.PUMP);
addPreferencesFromResourceIfEnabled(LocalInsightPlugin.getPlugin(), PluginType.PUMP);
addPreferencesFromResourceIfEnabled(ComboPlugin.getPlugin(), PluginType.PUMP);
addPreferencesFromResourceIfEnabled(MedtronicPumpPlugin.getPlugin(), PluginType.PUMP);
}
if (!Config.NSCLIENT) {
addPreferencesFromResourceIfEnabled(virtualPumpPlugin, PluginType.PUMP);
}
addPreferencesFromResourceIfEnabled(insulinOrefFreePeakPlugin, PluginType.INSULIN);
addPreferencesFromResourceIfEnabled(NSClientPlugin.getPlugin(), PluginType.GENERAL);
addPreferencesFromResourceIfEnabled(tidepoolPlugin, PluginType.GENERAL);
addPreferencesFromResourceIfEnabled(smsCommunicatorPlugin, PluginType.GENERAL);
addPreferencesFromResourceIfEnabled(automationPlugin, PluginType.GENERAL);
addPreferencesFromResource(R.xml.pref_others);
addPreferencesFromResource(R.xml.pref_datachoices);
addPreferencesFromResourceIfEnabled(wearPlugin, PluginType.GENERAL);
addPreferencesFromResourceIfEnabled(statusLinePlugin, PluginType.GENERAL);
}
PreferencesActivity.initSummary(getPreferenceScreen());
for (PluginBase plugin : MainApp.getPluginsList()) {
plugin.preprocessPreferences(this);
}
}
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putInt("id", id);
}
}

View file

@ -0,0 +1,266 @@
package info.nightscout.androidaps.activities
import android.content.Context
import android.content.SharedPreferences
import android.content.SharedPreferences.OnSharedPreferenceChangeListener
import android.os.Bundle
import androidx.annotation.XmlRes
import androidx.preference.*
import dagger.android.AndroidInjector
import dagger.android.DispatchingAndroidInjector
import dagger.android.HasAndroidInjector
import dagger.android.support.AndroidSupportInjection
import info.nightscout.androidaps.Config
import info.nightscout.androidaps.MainApp
import info.nightscout.androidaps.R
import info.nightscout.androidaps.data.Profile
import info.nightscout.androidaps.events.EventPreferenceChange
import info.nightscout.androidaps.events.EventRebuildTabs
import info.nightscout.androidaps.interfaces.PluginBase
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
import info.nightscout.androidaps.plugins.aps.openAPSAMA.OpenAPSAMAPlugin
import info.nightscout.androidaps.plugins.aps.openAPSMA.OpenAPSMAPlugin
import info.nightscout.androidaps.plugins.aps.openAPSSMB.OpenAPSSMBPlugin
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.constraints.safety.SafetyPlugin
import info.nightscout.androidaps.plugins.general.automation.AutomationPlugin
import info.nightscout.androidaps.plugins.general.careportal.CareportalPlugin
import info.nightscout.androidaps.plugins.general.nsclient.NSClientPlugin
import info.nightscout.androidaps.plugins.general.smsCommunicator.SmsCommunicatorPlugin
import info.nightscout.androidaps.plugins.general.tidepool.TidepoolPlugin
import info.nightscout.androidaps.plugins.general.wear.WearPlugin
import info.nightscout.androidaps.plugins.general.xdripStatusline.StatusLinePlugin
import info.nightscout.androidaps.plugins.insulin.InsulinOrefFreePeakPlugin
import info.nightscout.androidaps.plugins.pump.combo.ComboPlugin
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPlugin
import info.nightscout.androidaps.plugins.pump.danaRKorean.DanaRKoreanPlugin
import info.nightscout.androidaps.plugins.pump.danaRS.DanaRSPlugin
import info.nightscout.androidaps.plugins.pump.danaRv2.DanaRv2Plugin
import info.nightscout.androidaps.plugins.pump.insight.LocalInsightPlugin
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin
import info.nightscout.androidaps.plugins.sensitivity.SensitivityAAPSPlugin
import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref0Plugin
import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin
import info.nightscout.androidaps.plugins.sensitivity.SensitivityWeightedAveragePlugin
import info.nightscout.androidaps.plugins.source.DexcomPlugin
import info.nightscout.androidaps.plugins.source.EversensePlugin
import info.nightscout.androidaps.plugins.source.GlimpPlugin
import info.nightscout.androidaps.plugins.source.PoctechPlugin
import info.nightscout.androidaps.plugins.source.TomatoPlugin
import info.nightscout.androidaps.utils.OKDialog.show
import info.nightscout.androidaps.utils.SafeParse
import info.nightscout.androidaps.utils.resources.ResourceHelper
import info.nightscout.androidaps.utils.sharedPreferences.SP
import java.util.*
import javax.inject.Inject
class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChangeListener, HasAndroidInjector {
private var pluginId = -1
@Inject lateinit var rxBus: RxBusWrapper
@Inject lateinit var resourceHelper: ResourceHelper
@Inject lateinit var sp: SP
@Inject lateinit var automationPlugin: AutomationPlugin
@Inject lateinit var danaRPlugin: DanaRPlugin
@Inject lateinit var danaRKoreanPlugin: DanaRKoreanPlugin
@Inject lateinit var danaRv2Plugin: DanaRv2Plugin
@Inject lateinit var danaRSPlugin: DanaRSPlugin
@Inject lateinit var careportalPlugin: CareportalPlugin
@Inject lateinit var insulinOrefFreePeakPlugin: InsulinOrefFreePeakPlugin
@Inject lateinit var loopPlugin: LoopPlugin
@Inject lateinit var openAPSAMAPlugin: OpenAPSAMAPlugin
@Inject lateinit var openAPSMAPlugin: OpenAPSMAPlugin
@Inject lateinit var openAPSSMBPlugin: OpenAPSSMBPlugin
@Inject lateinit var safetyPlugin: SafetyPlugin
@Inject lateinit var dexcomPlugin: DexcomPlugin
@Inject lateinit var eversensePlugin: EversensePlugin
@Inject lateinit var glimpPlugin: GlimpPlugin
@Inject lateinit var poctechPlugin: PoctechPlugin
@Inject lateinit var tomatoPlugin: TomatoPlugin
@Inject lateinit var smsCommunicatorPlugin: SmsCommunicatorPlugin
@Inject lateinit var statusLinePlugin: StatusLinePlugin
@Inject lateinit var tidepoolPlugin: TidepoolPlugin
@Inject lateinit var virtualPumpPlugin: VirtualPumpPlugin
@Inject lateinit var wearPlugin: WearPlugin
@Inject lateinit var androidInjector: DispatchingAndroidInjector<Any>
override fun androidInjector(): AndroidInjector<Any> = androidInjector
override fun onAttach(context: Context) {
AndroidSupportInjection.inject(this)
super.onAttach(context)
}
override fun setArguments(args: Bundle?) {
super.setArguments(args)
pluginId = args?.getInt("id") ?: -1
}
override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
outState.putInt("id", pluginId)
}
private fun addPreferencesFromResourceIfEnabled(p: PluginBase?, rootKey: String?) {
if (p!!.isEnabled() && p.preferencesId != -1)
addPreferencesFromResource(p.preferencesId, rootKey)
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
PreferenceManager
.getDefaultSharedPreferences(context)
.registerOnSharedPreferenceChangeListener(this)
}
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
if (savedInstanceState != null && savedInstanceState.containsKey("id")) {
pluginId = savedInstanceState.getInt("id")
}
if (arguments != null && arguments!!.containsKey("id")) {
pluginId = arguments!!.getInt("id")
}
if (pluginId != -1) {
addPreferencesFromResource(pluginId, rootKey)
} else {
if (!Config.NSCLIENT) {
addPreferencesFromResource(R.xml.pref_password, rootKey)
}
addPreferencesFromResource(R.xml.pref_general, rootKey)
addPreferencesFromResource(R.xml.pref_age, rootKey)
addPreferencesFromResource(R.xml.pref_overview, rootKey)
addPreferencesFromResourceIfEnabled(eversensePlugin, rootKey)
addPreferencesFromResourceIfEnabled(dexcomPlugin, rootKey)
addPreferencesFromResourceIfEnabled(tomatoPlugin, rootKey)
addPreferencesFromResourceIfEnabled(poctechPlugin, rootKey)
addPreferencesFromResourceIfEnabled(glimpPlugin, rootKey)
addPreferencesFromResourceIfEnabled(careportalPlugin, rootKey)
addPreferencesFromResourceIfEnabled(safetyPlugin, rootKey)
if (Config.APS) {
addPreferencesFromResourceIfEnabled(loopPlugin, rootKey)
addPreferencesFromResourceIfEnabled(openAPSMAPlugin, rootKey)
addPreferencesFromResourceIfEnabled(openAPSAMAPlugin, rootKey)
addPreferencesFromResourceIfEnabled(openAPSSMBPlugin, rootKey)
}
addPreferencesFromResourceIfEnabled(SensitivityAAPSPlugin.getPlugin(), rootKey)
addPreferencesFromResourceIfEnabled(SensitivityWeightedAveragePlugin.getPlugin(), rootKey)
addPreferencesFromResourceIfEnabled(SensitivityOref0Plugin.getPlugin(), rootKey)
addPreferencesFromResourceIfEnabled(SensitivityOref1Plugin.getPlugin(), rootKey)
if (Config.PUMPDRIVERS) {
addPreferencesFromResourceIfEnabled(danaRPlugin, rootKey)
addPreferencesFromResourceIfEnabled(danaRKoreanPlugin, rootKey)
addPreferencesFromResourceIfEnabled(danaRv2Plugin, rootKey)
addPreferencesFromResourceIfEnabled(danaRSPlugin, rootKey)
addPreferencesFromResourceIfEnabled(LocalInsightPlugin.getPlugin(), rootKey)
addPreferencesFromResourceIfEnabled(ComboPlugin.getPlugin(), rootKey)
addPreferencesFromResourceIfEnabled(MedtronicPumpPlugin.getPlugin(), rootKey)
}
if (!Config.NSCLIENT) {
addPreferencesFromResourceIfEnabled(virtualPumpPlugin, rootKey)
}
addPreferencesFromResourceIfEnabled(insulinOrefFreePeakPlugin, rootKey)
addPreferencesFromResourceIfEnabled(NSClientPlugin.getPlugin(), rootKey)
addPreferencesFromResourceIfEnabled(tidepoolPlugin, rootKey)
addPreferencesFromResourceIfEnabled(smsCommunicatorPlugin, rootKey)
addPreferencesFromResourceIfEnabled(automationPlugin, rootKey)
addPreferencesFromResource(R.xml.pref_others, rootKey)
addPreferencesFromResource(R.xml.pref_datachoices, rootKey)
addPreferencesFromResourceIfEnabled(wearPlugin, rootKey)
addPreferencesFromResourceIfEnabled(statusLinePlugin, rootKey)
}
initSummary(preferenceScreen)
for (plugin in MainApp.getPluginsList()) {
plugin.preprocessPreferences(this)
}
}
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) {
rxBus.send(EventPreferenceChange(key))
if (key == resourceHelper.gs(R.string.key_language)) {
rxBus.send(EventRebuildTabs(true))
//recreate() does not update language so better close settings
activity?.finish()
}
if (key == resourceHelper.gs(R.string.key_short_tabtitles)) {
rxBus.send(EventRebuildTabs())
}
if (key == resourceHelper.gs(R.string.key_units)) {
activity?.recreate()
return
}
if (key == resourceHelper.gs(R.string.key_openapsama_useautosens) && sp.getBoolean(R.string.key_openapsama_useautosens, false))
activity?.let {
show(it, resourceHelper.gs(R.string.configbuilder_sensitivity), resourceHelper.gs(R.string.sensitivity_warning))
}
updatePrefSummary(findPreference(key))
}
fun addPreferencesFromResource(@XmlRes preferencesResId: Int, key: String?) {
val xmlRoot = preferenceManager.inflateFromResource(context,
preferencesResId, null)
val root: Preference?
if (key != null) {
root = xmlRoot.findPreference(key)
if (root == null) return
require(root is PreferenceScreen) {
("Preference object with key " + key
+ " is not a PreferenceScreen")
}
preferenceScreen = root
} else {
addPreferencesFromResource(preferencesResId)
}
}
private fun adjustUnitDependentPrefs(pref: Preference) { // convert preferences values to current units
val unitDependent = arrayOf(
resourceHelper.gs(R.string.key_hypo_target),
resourceHelper.gs(R.string.key_activity_target),
resourceHelper.gs(R.string.key_eatingsoon_target),
resourceHelper.gs(R.string.key_high_mark),
resourceHelper.gs(R.string.key_low_mark)
)
if (Arrays.asList(*unitDependent).contains(pref.key)) {
val editTextPref = pref as EditTextPreference
val converted = Profile.toCurrentUnitsString(SafeParse.stringToDouble(editTextPref.text))
editTextPref.summary = converted
editTextPref.text = converted
}
}
private fun updatePrefSummary(pref: Preference?) {
if (pref is ListPreference) {
pref.setSummary(pref.entry)
}
if (pref is EditTextPreference) {
val editTextPref = pref
if (pref.getKey().contains("password") || pref.getKey().contains("secret")) {
pref.setSummary("******")
} else if (editTextPref.text != null) {
pref.dialogMessage = editTextPref.dialogMessage
pref.setSummary(editTextPref.text)
} else {
for (plugin in MainApp.getPluginsList()) {
plugin.updatePreferenceSummary(pref)
}
}
}
pref?.let { adjustUnitDependentPrefs(it) }
}
private fun initSummary(p: Preference) {
p.isIconSpaceReserved = false // remove extra spacing on left after migration to androidx
if (p is PreferenceGroup) {
val pGrp = p
for (i in 0 until pGrp.preferenceCount) {
initSummary(pGrp.getPreference(i))
}
} else {
updatePrefSummary(p)
}
}
}

View file

@ -1,133 +0,0 @@
package info.nightscout.androidaps.activities;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.EditTextPreference;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.PreferenceGroup;
import android.preference.PreferenceManager;
import java.util.Arrays;
import javax.inject.Inject;
import dagger.android.AndroidInjection;
import dagger.android.AndroidInjector;
import dagger.android.DispatchingAndroidInjector;
import dagger.android.HasAndroidInjector;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.events.EventPreferenceChange;
import info.nightscout.androidaps.events.EventRebuildTabs;
import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.plugins.bus.RxBus;
import info.nightscout.androidaps.utils.LocaleHelper;
import info.nightscout.androidaps.utils.OKDialog;
import info.nightscout.androidaps.utils.SP;
import info.nightscout.androidaps.utils.SafeParse;
public class PreferencesActivity extends PreferenceActivity implements SharedPreferences.OnSharedPreferenceChangeListener, HasAndroidInjector {
MyPreferenceFragment myPreferenceFragment;
@Inject
DispatchingAndroidInjector<Object> androidInjector;
@Override
protected void onCreate(Bundle savedInstanceState) {
AndroidInjection.inject(this);
setTheme(R.style.AppTheme_NoActionBar);
super.onCreate(savedInstanceState);
myPreferenceFragment = new MyPreferenceFragment();
Bundle args = new Bundle();
args.putInt("id", getIntent().getIntExtra("id", -1));
myPreferenceFragment.setArguments(args);
getFragmentManager().beginTransaction().replace(android.R.id.content, myPreferenceFragment).commit();
PreferenceManager.getDefaultSharedPreferences(this).registerOnSharedPreferenceChangeListener(this);
}
@Override
public AndroidInjector<Object> androidInjector() {
return androidInjector;
}
@Override
public void attachBaseContext(Context newBase) {
super.attachBaseContext(LocaleHelper.INSTANCE.wrap(newBase));
}
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
RxBus.Companion.getINSTANCE().send(new EventPreferenceChange(key));
if (key.equals(MainApp.gs(R.string.key_language))) {
RxBus.Companion.getINSTANCE().send(new EventRebuildTabs(true));
//recreate() does not update language so better close settings
finish();
}
if (key.equals(MainApp.gs(R.string.key_short_tabtitles))) {
RxBus.Companion.getINSTANCE().send(new EventRebuildTabs());
}
if (key.equals(MainApp.gs(R.string.key_units))) {
recreate();
return;
}
if (key.equals(MainApp.gs(R.string.key_openapsama_useautosens)) && SP.getBoolean(R.string.key_openapsama_useautosens, false)) {
OKDialog.show(this, MainApp.gs(R.string.configbuilder_sensitivity), MainApp.gs(R.string.sensitivity_warning));
}
updatePrefSummary(myPreferenceFragment.findPreference(key));
}
private static void adjustUnitDependentPrefs(Preference pref) {
// convert preferences values to current units
String[] unitDependent = new String[]{
MainApp.gs(R.string.key_hypo_target),
MainApp.gs(R.string.key_activity_target),
MainApp.gs(R.string.key_eatingsoon_target),
MainApp.gs(R.string.key_high_mark),
MainApp.gs(R.string.key_low_mark)
};
if (Arrays.asList(unitDependent).contains(pref.getKey())) {
EditTextPreference editTextPref = (EditTextPreference) pref;
String converted = Profile.toCurrentUnitsString(SafeParse.stringToDouble(editTextPref.getText()));
editTextPref.setSummary(converted);
editTextPref.setText(converted);
}
}
private static void updatePrefSummary(Preference pref) {
if (pref instanceof ListPreference) {
ListPreference listPref = (ListPreference) pref;
pref.setSummary(listPref.getEntry());
}
if (pref instanceof EditTextPreference) {
EditTextPreference editTextPref = (EditTextPreference) pref;
if (pref.getKey().contains("password") || pref.getKey().contains("secret")) {
pref.setSummary("******");
} else if (editTextPref.getText() != null) {
((EditTextPreference) pref).setDialogMessage(editTextPref.getDialogMessage());
pref.setSummary(editTextPref.getText());
} else {
for (PluginBase plugin : MainApp.getPluginsList()) {
plugin.updatePreferenceSummary(pref);
}
}
}
if (pref != null)
adjustUnitDependentPrefs(pref);
}
public static void initSummary(Preference p) {
if (p instanceof PreferenceGroup) {
PreferenceGroup pGrp = (PreferenceGroup) p;
for (int i = 0; i < pGrp.getPreferenceCount(); i++) {
initSummary(pGrp.getPreference(i));
}
} else {
updatePrefSummary(p);
}
}
}

View file

@ -0,0 +1,47 @@
package info.nightscout.androidaps.activities
import android.content.Context
import android.os.Bundle
import androidx.preference.PreferenceFragmentCompat
import androidx.preference.PreferenceScreen
import info.nightscout.androidaps.R
import info.nightscout.androidaps.utils.LocaleHelper
import info.nightscout.androidaps.utils.resources.ResourceHelper
import javax.inject.Inject
class PreferencesActivity : NoSplashAppCompatActivity(), PreferenceFragmentCompat.OnPreferenceStartScreenCallback {
@Inject lateinit var resourceHelper: ResourceHelper
var preferenceId = 0
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_single_fragment)
title = resourceHelper.gs(R.string.nav_preferences)
supportActionBar?.setDisplayHomeAsUpEnabled(true)
supportActionBar?.setDisplayShowHomeEnabled(true)
val myPreferenceFragment = MyPreferenceFragment()
preferenceId = intent.getIntExtra("id", -1)
val args = Bundle()
args.putInt("id", preferenceId)
myPreferenceFragment.arguments = args
supportFragmentManager.beginTransaction().replace(R.id.frame_layout, myPreferenceFragment).commit()
}
override fun onPreferenceStartScreen(caller: PreferenceFragmentCompat, pref: PreferenceScreen): Boolean {
val fragment = MyPreferenceFragment()
val args = Bundle()
args.putString(PreferenceFragmentCompat.ARG_PREFERENCE_ROOT, pref.key)
args.putInt("id", preferenceId)
fragment.arguments = args
supportFragmentManager.beginTransaction()
.replace(R.id.frame_layout, fragment, pref.key)
.addToBackStack(pref.key)
.commit()
return true
}
override fun attachBaseContext(newBase: Context) {
super.attachBaseContext(LocaleHelper.wrap(newBase))
}
}

View file

@ -1,7 +1,7 @@
package info.nightscout.androidaps.dependencyInjection
import android.content.Context
import android.preference.PreferenceManager
import androidx.preference.PreferenceManager
import dagger.Binds
import dagger.Module
import dagger.Provides

View file

@ -1,9 +1,9 @@
package info.nightscout.androidaps.interfaces
import android.os.SystemClock
import android.preference.Preference
import android.preference.PreferenceFragment
import androidx.fragment.app.FragmentActivity
import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
import info.nightscout.androidaps.MainApp
import info.nightscout.androidaps.R
import info.nightscout.androidaps.events.EventConfigBuilderChange
@ -22,7 +22,7 @@ import org.slf4j.LoggerFactory
/**
* Created by mike on 09.06.2016.
*/
abstract class PluginBase(val pluginDescription: PluginDescription, val rxBus: RxBusWrapper, val aapsLogger: AAPSLogger ) {
abstract class PluginBase(val pluginDescription: PluginDescription, val rxBus: RxBusWrapper, val aapsLogger: AAPSLogger) {
companion object {
private val log = LoggerFactory.getLogger(L.CORE)
@ -173,6 +173,6 @@ abstract class PluginBase(val pluginDescription: PluginDescription, val rxBus: R
protected open fun onStop() {}
protected open fun onStateChange(type: PluginType?, oldState: State?, newState: State?) {}
open fun preprocessPreferences(preferenceFragment: PreferenceFragment) {}
open fun preprocessPreferences(preferenceFragment: PreferenceFragmentCompat) {}
open fun updatePreferenceSummary(pref: Preference) {}
}

View file

@ -6,7 +6,7 @@ import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.os.Environment;
import android.preference.PreferenceManager;
import androidx.preference.PreferenceManager;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;

View file

@ -7,11 +7,12 @@ import android.content.ServiceConnection;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.IBinder;
import android.preference.PreferenceFragment;
import android.preference.PreferenceScreen;
import android.text.Html;
import android.text.Spanned;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceScreen;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -77,12 +78,12 @@ public class NSClientPlugin extends PluginBase {
private NSClientPlugin() {
super(new PluginDescription()
.mainType(PluginType.GENERAL)
.fragmentClass(NSClientFragment.class.getName())
.pluginName(R.string.nsclientinternal)
.shortName(R.string.nsclientinternal_shortname)
.preferencesId(R.xml.pref_nsclientinternal)
.description(R.string.description_ns_client),
.mainType(PluginType.GENERAL)
.fragmentClass(NSClientFragment.class.getName())
.pluginName(R.string.nsclientinternal)
.shortName(R.string.nsclientinternal_shortname)
.preferencesId(R.xml.pref_nsclientinternal)
.description(R.string.description_ns_client),
new RxBusWrapper(), new AAPSLoggerProduction() // TODO: dagger
);
@ -166,7 +167,7 @@ public class NSClientPlugin extends PluginBase {
}
@Override
public void preprocessPreferences(@NotNull PreferenceFragment preferenceFragment) {
public void preprocessPreferences(@NotNull PreferenceFragmentCompat preferenceFragment) {
super.preprocessPreferences(preferenceFragment);
if (Config.NSCLIENT) {

View file

@ -5,7 +5,7 @@ import android.content.SharedPreferences;
import android.content.pm.ResolveInfo;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceManager;
import androidx.preference.PreferenceManager;
import androidx.annotation.Nullable;

View file

@ -1,14 +1,12 @@
package info.nightscout.androidaps.plugins.general.smsCommunicator
import android.content.Intent
import android.preference.EditTextPreference
import android.preference.Preference
import android.preference.Preference.OnPreferenceChangeListener
import android.preference.PreferenceFragment
import android.telephony.SmsManager
import android.telephony.SmsMessage
import android.text.TextUtils
import com.andreabaccega.widget.ValidatingEditTextPreference
import androidx.preference.EditTextPreference
import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
import info.nightscout.androidaps.Constants
import info.nightscout.androidaps.R
import info.nightscout.androidaps.data.DetailedBolusInfo
@ -38,6 +36,7 @@ import info.nightscout.androidaps.utils.*
import info.nightscout.androidaps.utils.extensions.plusAssign
import info.nightscout.androidaps.utils.resources.ResourceHelper
import info.nightscout.androidaps.utils.sharedPreferences.SP
import info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
import io.reactivex.disposables.CompositeDisposable
import io.reactivex.schedulers.Schedulers
import org.apache.commons.lang3.StringUtils
@ -107,7 +106,7 @@ class SmsCommunicatorPlugin @Inject constructor(
super.onStop()
}
override fun preprocessPreferences(preferenceFragment: PreferenceFragment) {
override fun preprocessPreferences(preferenceFragment: PreferenceFragmentCompat) {
super.preprocessPreferences(preferenceFragment)
val distance = preferenceFragment.findPreference(resourceHelper.gs(R.string.key_smscommunicator_remotebolusmindistance)) as ValidatingEditTextPreference?
?: return
@ -122,7 +121,7 @@ class SmsCommunicatorPlugin @Inject constructor(
distance.title = resourceHelper.gs(R.string.smscommunicator_remotebolusmindistance)
distance.isEnabled = true
}
allowedNumbers.onPreferenceChangeListener = OnPreferenceChangeListener { _: Preference?, newValue: Any ->
allowedNumbers.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _: Preference?, newValue: Any ->
if (!areMoreNumbers(newValue as String)) {
distance.text = (Constants.remoteBolusMinDistance / (60 * 1000L)).toString()
distance.title = (resourceHelper.gs(R.string.smscommunicator_remotebolusmindistance)

View file

@ -1,7 +1,8 @@
package info.nightscout.androidaps.plugins.general.tidepool
import android.preference.PreferenceFragment
import android.text.Spanned
import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
import info.nightscout.androidaps.Constants
import info.nightscout.androidaps.MainApp
import info.nightscout.androidaps.R
@ -131,12 +132,14 @@ class TidepoolPlugin @Inject constructor(
super.onStop()
}
override fun preprocessPreferences(preferenceFragment: PreferenceFragment) {
override fun preprocessPreferences(preferenceFragment: PreferenceFragmentCompat) {
super.preprocessPreferences(preferenceFragment)
val tidepoolTestLogin = preferenceFragment.findPreference(resourceHelper.gs(R.string.key_tidepool_test_login))
val tidepoolTestLogin : Preference? = preferenceFragment.findPreference(resourceHelper.gs(R.string.key_tidepool_test_login))
tidepoolTestLogin?.setOnPreferenceClickListener {
tidepoolUploader.testLogin(preferenceFragment.getActivity())
preferenceFragment.context?.let {
tidepoolUploader.testLogin(it)
}
false
}
}

View file

@ -1,7 +1,7 @@
package info.nightscout.androidaps.plugins.pump.common.ui;
import android.content.Context;
import android.preference.Preference;
import androidx.preference.Preference;
import android.util.AttributeSet;
import info.nightscout.androidaps.MainApp;

View file

@ -2,7 +2,7 @@ package info.nightscout.androidaps.plugins.pump.danaR;
import android.bluetooth.*;
import android.content.Context;
import android.preference.ListPreference;
import androidx.preference.ListPreference;
import android.util.AttributeSet;
import java.util.Set;

View file

@ -5,7 +5,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.IBinder;
import android.preference.Preference;
import androidx.preference.Preference;
import androidx.annotation.NonNull;
import androidx.fragment.app.FragmentActivity;

View file

@ -0,0 +1,235 @@
package info.nightscout.androidaps.utils.textValidator
import android.content.Context
import android.content.res.TypedArray
import android.text.Editable
import android.text.TextUtils
import android.text.TextWatcher
import android.widget.EditText
import com.google.android.material.textfield.TextInputLayout
import info.nightscout.androidaps.R
import info.nightscout.androidaps.utils.textValidator.validators.*
class DefaultEditTextValidator : EditTextValidator {
protected var mValidator: MultiValidator? = null
protected var testErrorString: String? = null
protected var emptyAllowed = false
protected lateinit var editTextView: EditText
protected var testType: Int
protected var classType: String? = null
protected var customRegexp: String? = null
protected var customFormat: String? = null
protected var emptyErrorStringActual: String? = null
protected var emptyErrorStringDef: String? = null
protected var minNumber = 0
protected var maxNumber = 0
protected var floatminNumber = 0f
protected var floatmaxNumber = 0f
private var tw: TextWatcher? = null
private var defaultEmptyErrorString: String? = null
@Suppress("unused")
constructor(editTextView: EditText, context: Context) {
testType = EditTextValidator.TEST_NOCHECK
setEditText(editTextView)
resetValidators(context)
}
constructor(editTextView: EditText, typedArray: TypedArray, context: Context) {
emptyAllowed = typedArray.getBoolean(R.styleable.FormEditText_emptyAllowed, false)
testType = typedArray.getInt(R.styleable.FormEditText_testType, EditTextValidator.TEST_NOCHECK)
testErrorString = typedArray.getString(R.styleable.FormEditText_testErrorString)
classType = typedArray.getString(R.styleable.FormEditText_classType)
customRegexp = typedArray.getString(R.styleable.FormEditText_customRegexp)
emptyErrorStringDef = typedArray.getString(R.styleable.FormEditText_emptyErrorString)
customFormat = typedArray.getString(R.styleable.FormEditText_customFormat)
if (testType == EditTextValidator.TEST_NUMERIC_RANGE) {
minNumber = typedArray.getInt(R.styleable.FormEditText_minNumber, Int.MIN_VALUE)
maxNumber = typedArray.getInt(R.styleable.FormEditText_maxNumber, Int.MAX_VALUE)
}
if (testType == EditTextValidator.TEST_FLOAT_NUMERIC_RANGE) {
floatminNumber = typedArray.getFloat(R.styleable.FormEditText_floatminNumber, Float.MIN_VALUE)
floatmaxNumber = typedArray.getFloat(R.styleable.FormEditText_floatmaxNumber, Float.MAX_VALUE)
}
typedArray.recycle()
setEditText(editTextView)
resetValidators(context)
}
@Throws(IllegalArgumentException::class)
override fun addValidator(theValidator: Validator) {
requireNotNull(theValidator) { "theValidator argument should not be null" }
mValidator!!.enqueue(theValidator)
}
private fun setEditText(editText: EditText) {
//editTextView?.removeTextChangedListener(textWatcher)
editTextView = editText
editText.addTextChangedListener(textWatcher)
}
override fun getTextWatcher(): TextWatcher {
if (tw == null) {
tw = object : TextWatcher {
override fun afterTextChanged(s: Editable) {
testValidity()
}
override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {}
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {
if (!TextUtils.isEmpty(s) && isErrorShown) {
try {
val textInputLayout = editTextView.parent as TextInputLayout
textInputLayout.isErrorEnabled = false
} catch (e: Throwable) {
editTextView.error = null
}
}
}
}
}
return tw!!
}
override fun isEmptyAllowed(): Boolean {
return emptyAllowed
}
override fun resetValidators(context: Context) {
// its possible the context may have changed so re-get the defaultEmptyErrorString
defaultEmptyErrorString = context.getString(R.string.error_field_must_not_be_empty)
setEmptyErrorString(emptyErrorStringDef)
mValidator = AndValidator()
val toAdd: Validator
when (testType) {
EditTextValidator.TEST_NOCHECK -> toAdd = DummyValidator()
EditTextValidator.TEST_ALPHA -> toAdd = AlphaValidator(if (TextUtils.isEmpty(testErrorString)) context.getString(R.string.error_only_standard_letters_are_allowed) else testErrorString)
EditTextValidator.TEST_ALPHANUMERIC -> toAdd = AlphaNumericValidator(
if (TextUtils.isEmpty(testErrorString)) context.getString(R.string.error_this_field_cannot_contain_special_character) else testErrorString)
EditTextValidator.TEST_NUMERIC -> toAdd = NumericValidator(if (TextUtils.isEmpty(testErrorString)) context.getString(R.string.error_only_numeric_digits_allowed) else testErrorString)
EditTextValidator.TEST_NUMERIC_RANGE -> toAdd = NumericRangeValidator(if (TextUtils.isEmpty(testErrorString)) context.getString(R.string.error_only_numeric_digits_range_allowed, Integer.toString(minNumber), Integer.toString(maxNumber)) else testErrorString, minNumber, maxNumber)
EditTextValidator.TEST_FLOAT_NUMERIC_RANGE -> toAdd = FloatNumericRangeValidator(if (TextUtils.isEmpty(testErrorString)) context.getString(R.string.error_only_numeric_digits_range_allowed, java.lang.Float.toString(floatminNumber), java.lang.Float.toString(floatmaxNumber)) else testErrorString, floatminNumber, floatmaxNumber)
EditTextValidator.TEST_REGEXP -> toAdd = RegexpValidator(testErrorString, customRegexp)
EditTextValidator.TEST_CREDITCARD -> toAdd = CreditCardValidator(if (TextUtils.isEmpty(testErrorString)) context.getString(R.string.error_creditcard_number_not_valid) else testErrorString)
EditTextValidator.TEST_EMAIL -> toAdd = EmailValidator(if (TextUtils.isEmpty(testErrorString)) context.getString(R.string.error_email_address_not_valid) else testErrorString)
EditTextValidator.TEST_PHONE -> toAdd = PhoneValidator(if (TextUtils.isEmpty(testErrorString)) context.getString(R.string.error_phone_not_valid) else testErrorString)
EditTextValidator.TEST_DOMAINNAME -> toAdd = DomainValidator(if (TextUtils.isEmpty(testErrorString)) context.getString(R.string.error_domain_not_valid) else testErrorString)
EditTextValidator.TEST_IPADDRESS -> toAdd = IpAddressValidator(if (TextUtils.isEmpty(testErrorString)) context.getString(R.string.error_ip_not_valid) else testErrorString)
EditTextValidator.TEST_WEBURL -> toAdd = WebUrlValidator(if (TextUtils.isEmpty(testErrorString)) context.getString(R.string.error_url_not_valid) else testErrorString)
EditTextValidator.TEST_PERSONNAME -> toAdd = PersonNameValidator(if (TextUtils.isEmpty(testErrorString)) context.getString(R.string.error_notvalid_personname) else testErrorString)
EditTextValidator.TEST_PERSONFULLNAME -> toAdd = PersonFullNameValidator(if (TextUtils.isEmpty(testErrorString)) context.getString(R.string.error_notvalid_personfullname) else testErrorString)
EditTextValidator.TEST_CUSTOM -> {
// must specify the fully qualified class name & an error message
if (classType == null)
throw RuntimeException("Trying to create a custom validator but no classType has been specified.")
if (TextUtils.isEmpty(testErrorString))
throw RuntimeException(String.format("Trying to create a custom validator (%s) but no error string specified.", classType))
val customValidatorClass: Class<out Validator> = try {
this.javaClass.classLoader?.loadClass(classType)?.let {
if (!Validator::class.java.isAssignableFrom(it)) {
throw RuntimeException(String.format("Custom validator (%s) does not extend %s", classType, Validator::class.java.name))
}
@Suppress("Unchecked_Cast")
it as Class<out Validator>
}!!
} catch (e: ClassNotFoundException) {
throw RuntimeException(String.format("Unable to load class for custom validator (%s).", classType))
}
toAdd = try {
customValidatorClass.getConstructor(String::class.java).newInstance(testErrorString)
} catch (e: Exception) {
throw RuntimeException(String.format("Unable to construct custom validator (%s) with argument: %s", classType,
testErrorString))
}
}
EditTextValidator.TEST_DATE -> toAdd = DateValidator(if (TextUtils.isEmpty(testErrorString)) context.getString(R.string.error_date_not_valid) else testErrorString, customFormat)
else -> toAdd = DummyValidator()
}
val tmpValidator: MultiValidator
if (!emptyAllowed) { // If the xml tells us that this is a required field, we will add the EmptyValidator.
tmpValidator = AndValidator()
tmpValidator.enqueue(EmptyValidator(emptyErrorStringActual))
tmpValidator.enqueue(toAdd)
} else {
tmpValidator = OrValidator(toAdd.errorMessage, NotValidator(null, EmptyValidator(null)), toAdd)
}
addValidator(tmpValidator)
}
@Suppress("unused")
fun setClassType(classType: String?, testErrorString: String?, context: Context) {
testType = EditTextValidator.TEST_CUSTOM
this.classType = classType
this.testErrorString = testErrorString
resetValidators(context)
}
@Suppress("unused")
fun setCustomRegexp(customRegexp: String?, context: Context) {
testType = EditTextValidator.TEST_REGEXP
this.customRegexp = customRegexp
resetValidators(context)
}
@Suppress("unused")
fun setEmptyAllowed(emptyAllowed: Boolean, context: Context) {
this.emptyAllowed = emptyAllowed
resetValidators(context)
}
fun setEmptyErrorString(emptyErrorString: String?) {
emptyErrorStringActual = if (!TextUtils.isEmpty(emptyErrorString)) {
emptyErrorString
} else {
defaultEmptyErrorString
}
}
@Suppress("unused")
fun setTestErrorString(testErrorString: String?, context: Context) {
this.testErrorString = testErrorString
resetValidators(context)
}
@Suppress("unused")
fun setTestType(testType: Int, context: Context) {
this.testType = testType
resetValidators(context)
}
override fun testValidity(): Boolean {
return testValidity(true)
}
override fun testValidity(showUIError: Boolean): Boolean {
val isValid = mValidator?.isValid(editTextView) ?: false
if (!isValid && showUIError) {
showUIError()
}
return isValid
}
override fun showUIError() {
if (mValidator!!.hasErrorMessage()) {
try {
val parent = editTextView.parent as TextInputLayout
parent.isErrorEnabled = true
parent.error = mValidator!!.errorMessage
} catch (e: Throwable) {
editTextView.error = mValidator!!.errorMessage
}
}
}
// might sound like a bug. but there's no way to know if the error is shown (not with public api)
val isErrorShown: Boolean
get() = try {
editTextView.parent as TextInputLayout
true // might sound like a bug. but there's no way to know if the error is shown (not with public api)
} catch (e: Throwable) {
!TextUtils.isEmpty(editTextView.error)
}
}

View file

@ -0,0 +1,90 @@
package info.nightscout.androidaps.utils.textValidator;
import android.content.Context;
import android.text.TextWatcher;
import android.widget.EditText;
import info.nightscout.androidaps.utils.textValidator.validators.Validator;
/**
* Interface for encapsulating validation of an EditText control
*/
public interface EditTextValidator {
/**
* Add a validator to this FormEditText. The validator will be added in the
* queue of the current validators.
*
* @param theValidator
* @throws IllegalArgumentException if the validator is null
*/
void addValidator(Validator theValidator)
throws IllegalArgumentException;
/**
* This should be used with {@link #addTextChangedListener(TextWatcher)}. It
* fixes the non-hiding error popup behaviour.
*/
TextWatcher getTextWatcher();
boolean isEmptyAllowed();
/**
* Resets the {@link Validator}s
*/
void resetValidators(Context context);
/**
* Calling *testValidity()* will cause the EditText to go through
* customValidators and call {@link #Validator.isValid(EditText)}
* Same as {@link #testValidity(boolean)} with first parameter true
*
* @return true if the validity passes false otherwise.
*/
boolean testValidity();
/**
* Calling *testValidity()* will cause the EditText to go through
* customValidators and call {@link #Validator.isValid(EditText)}
*
* @param showUIError determines if this call should show the UI error.
* @return true if the validity passes false otherwise.
*/
boolean testValidity(boolean showUIError);
void showUIError();
int TEST_REGEXP = 0;
int TEST_NUMERIC = 1;
int TEST_ALPHA = 2;
int TEST_ALPHANUMERIC = 3;
int TEST_EMAIL = 4;
int TEST_CREDITCARD = 5;
int TEST_PHONE = 6;
int TEST_DOMAINNAME = 7;
int TEST_IPADDRESS = 8;
int TEST_WEBURL = 9;
int TEST_NOCHECK = 10;
int TEST_CUSTOM = 11;
int TEST_PERSONNAME = 12;
int TEST_PERSONFULLNAME = 13;
int TEST_DATE = 14;
int TEST_NUMERIC_RANGE = 15;
int TEST_FLOAT_NUMERIC_RANGE = 16;
}

View file

@ -0,0 +1,37 @@
package info.nightscout.androidaps.utils.textValidator
import android.content.Context
import android.util.AttributeSet
import androidx.core.content.res.TypedArrayUtils
import androidx.preference.EditTextPreference
import androidx.preference.EditTextPreference.OnBindEditTextListener
import androidx.preference.PreferenceViewHolder
import info.nightscout.androidaps.R
class ValidatingEditTextPreference(private val ctx: Context, val attrs: AttributeSet, private val defStyleAttr: Int, private val defStyleRes: Int)
: EditTextPreference(ctx, attrs, defStyleAttr, defStyleRes) {
init {
dialogLayoutResource = R.layout.dialog_preference
val typedArray = context.obtainStyledAttributes(attrs, R.styleable.FormEditText, 0, 0)
val onBindEditTextListener = OnBindEditTextListener { editText ->
editTextValidator = DefaultEditTextValidator(editText, typedArray, context)
}
setOnBindEditTextListener(onBindEditTextListener)
}
constructor(ctx: Context, attrs: AttributeSet, defStyle: Int)
: this(ctx, attrs, defStyle, 0)
constructor(ctx: Context, attrs: AttributeSet)
: this(ctx, attrs, TypedArrayUtils.getAttr(ctx, R.attr.editTextPreferenceStyle,
R.attr.editTextPreferenceStyle))
lateinit var editTextValidator: EditTextValidator
override fun onBindViewHolder(holder: PreferenceViewHolder?) {
super.onBindViewHolder(holder)
holder?.isDividerAllowedAbove = false
holder?.isDividerAllowedBelow = false
}
}

View file

@ -0,0 +1,3 @@
package info.nightscout.androidaps.utils.textValidator.validators
class AlphaNumericValidator(message: String?) : RegexpValidator(message, "[a-zA-Z0-9\u00C0-\u00FF \\./-\\?]*")

View file

@ -0,0 +1,3 @@
package info.nightscout.androidaps.utils.textValidator.validators
class AlphaValidator(message: String?) : RegexpValidator(message, "[A-z\u00C0-\u00ff \\./-\\?]*")

View file

@ -0,0 +1,23 @@
package info.nightscout.androidaps.utils.textValidator.validators
import android.widget.EditText
/**
* The AND validator checks if all of the passed validators is returning true.<br></br>
* Note: the message that will be shown is the one of the first failing validator
*/
class AndValidator : MultiValidator {
constructor(vararg validators: Validator?) : super(null, *validators)
constructor() : super(null)
override fun isValid(editText: EditText): Boolean {
for (v in validators) {
if (!v.isValid(editText)) {
errorMessage = v.errorMessage
return false
}
}
return true
}
}

View file

@ -0,0 +1,47 @@
package info.nightscout.androidaps.utils.textValidator.validators
import android.widget.EditText
/**
* This validator takes care of validating the edittext. The input will be valid only if the number is a valid credit card.
*/
class CreditCardValidator(_customErrorMessage: String?) : Validator(_customErrorMessage) {
override fun isValid(editText: EditText): Boolean {
return try {
validateCardNumber(editText.text.toString())
} catch (e: Exception) {
false
}
}
companion object {
/**
* Validates the credit card number using the Luhn algorithm
*
* @param cardNumber the credit card number
* @return
*/
@Throws(NumberFormatException::class)
fun validateCardNumber(cardNumber: String): Boolean {
var sum = 0
var digit: Int
var addend: Int
var doubled = false
for (i in cardNumber.length - 1 downTo 0) {
digit = cardNumber.substring(i, i + 1).toInt()
if (doubled) {
addend = digit * 2
if (addend > 9) {
addend -= 9
}
} else {
addend = digit
}
sum += addend
doubled = !doubled
}
return sum % 10 == 0
}
}
}

View file

@ -0,0 +1,51 @@
package info.nightscout.androidaps.utils.textValidator.validators
import android.annotation.SuppressLint
import android.text.TextUtils
import android.widget.EditText
import java.text.DateFormat
import java.text.ParseException
import java.text.SimpleDateFormat
import java.util.*
class DateValidator(_customErrorMessage: String?, _format: String?) : Validator(_customErrorMessage) {
private val formats: Array<String> = if (_format == null || TextUtils.isEmpty(_format))
arrayOf("DefaultDate", "DefaultTime", "DefaultDateTime")
else
_format.split(";").toTypedArray()
@SuppressLint("SimpleDateFormat")
override fun isValid(editText: EditText): Boolean {
if (TextUtils.isEmpty(editText.text)) return true
val value = editText.text.toString()
for (_format in formats) {
val format: DateFormat = when {
"DefaultDate".equals(_format, ignoreCase = true) -> {
SimpleDateFormat.getDateInstance()
}
"DefaultTime".equals(_format, ignoreCase = true) -> {
SimpleDateFormat.getTimeInstance()
}
"DefaultDateTime".equals(_format, ignoreCase = true) -> {
SimpleDateFormat.getDateTimeInstance()
}
else -> {
SimpleDateFormat(_format)
}
}
var date: Date?
date = try {
format.parse(value)
} catch (e: ParseException) {
return false
}
if (date != null) {
return true
}
}
return false
}
}

View file

@ -0,0 +1,23 @@
package info.nightscout.androidaps.utils.textValidator.validators
import android.widget.EditText
/**
* Digits Length Validator for number of allowed characters in string/numbers.
* Range is [min;max[
*
* @author Andrea Baccega <me></me>@andreabaccega.com>
* @author Emanuele Tessore <me></me>@emanueletessore.com>
*
*
* By reading this you'll get smarter. We'd love to know how many people got smarter thanks to this clever class
* Please send **us** an email with the following subject: "42 is the answer to ultimate question of life..."
*/
abstract class DigitLengthRangeValidator(message: String?, private val min: Int, private val max: Int) : Validator(message) {
override fun isValid(editText: EditText): Boolean {
val length = editText.text.toString().length
return length >= min && length < max
}
}

View file

@ -0,0 +1,5 @@
package info.nightscout.androidaps.utils.textValidator.validators
import android.util.Patterns
class DomainValidator(_customErrorMessage: String?) : PatternValidator(_customErrorMessage, Patterns.DOMAIN_NAME)

View file

@ -0,0 +1,15 @@
package info.nightscout.androidaps.utils.textValidator.validators
import android.widget.EditText
/**
* This is a dummy validator. It just returns true on each input.
*
* @author Andrea Baccega <me></me>@andreabaccega.com>
*/
class DummyValidator : Validator(null) {
override fun isValid(editText: EditText): Boolean {
return true
}
}

View file

@ -0,0 +1,11 @@
package info.nightscout.androidaps.utils.textValidator.validators
import android.util.Patterns
/**
* This validates an email using regexps.
* Note that if an email passes the validation with this validator it doesn't mean it's a valid email - it means it's a valid email <storng>format
*
* @author Andrea Baccega <me></me>@andreabaccega.com>
</storng> */
class EmailValidator(_customErrorMessage: String?) : PatternValidator(_customErrorMessage, Patterns.EMAIL_ADDRESS)

View file

@ -0,0 +1,16 @@
package info.nightscout.androidaps.utils.textValidator.validators
import android.text.TextUtils
import android.widget.EditText
/**
* A simple validator that validates the field only if the field is not empty.
*
* @author Andrea Baccega <me></me>@andreabaccega.com>
*/
class EmptyValidator(message: String?) : Validator(message) {
override fun isValid(editText: EditText): Boolean {
return TextUtils.getTrimmedLength(editText.text) > 0
}
}

View file

@ -0,0 +1,22 @@
package info.nightscout.androidaps.utils.textValidator.validators
import android.widget.EditText
/**
* A validator that returns true only if the input field contains only numbers
* and the number is within the given range.
*
* @author Said Tahsin Dane <tasomaniac></tasomaniac>@gmail.com>
*/
class FloatNumericRangeValidator(_customErrorMessage: String?, private val floatMin: Float, private val floatMax: Float) : Validator(_customErrorMessage) {
override fun isValid(editText: EditText): Boolean {
return try {
val value = editText.text.toString().toFloat()
value in floatMin..floatMax
} catch (e: NumberFormatException) {
false
}
}
}

View file

@ -0,0 +1,10 @@
package info.nightscout.androidaps.utils.textValidator.validators
import android.util.Patterns
/**
* Validates the ipaddress. The regexp was taken from the android source code.
*
* @author Andrea Baccega <me></me>@andreabaccega.com>
*/
class IpAddressValidator(_customErrorMessage: String?) : PatternValidator(_customErrorMessage, Patterns.IP_ADDRESS)

View file

@ -0,0 +1,28 @@
package info.nightscout.androidaps.utils.textValidator.validators
import java.util.*
/**
* Abstract class for a multivalidator.
*
* @author Andrea Baccega <me></me>@andreabaccega.com>
* @see AndValidator
*
* @see OrValidator
*/
abstract class MultiValidator : Validator {
protected val validators: MutableList<Validator>
constructor(message: String?, vararg validators: Validator?) : super(message) {
this.validators = ArrayList<Validator>(Arrays.asList(*validators))
}
constructor(message: String?) : super(message) {
validators = ArrayList()
}
fun enqueue(newValidator: Validator) {
validators.add(newValidator)
}
}

View file

@ -0,0 +1,15 @@
package info.nightscout.androidaps.utils.textValidator.validators
import android.widget.EditText
/**
* It's a validator that applies the "NOT" logical operator to the validator passed in the constructor.
*
* @author Andrea Baccega <me></me>@andreabaccega.com>
*/
class NotValidator(errorMessage: String?, private val v: Validator) : Validator(errorMessage) {
override fun isValid(editText: EditText): Boolean {
return !v.isValid(editText)
}
}

View file

@ -0,0 +1,22 @@
package info.nightscout.androidaps.utils.textValidator.validators
import android.widget.EditText
/**
* A validator that returns true only if the input field contains only numbers
* and the number is within the given range.
*
* @author Said Tahsin Dane <tasomaniac></tasomaniac>@gmail.com>
*/
class NumericRangeValidator(_customErrorMessage: String?, private val min: Int, private val max: Int) : Validator(_customErrorMessage) {
override fun isValid(editText: EditText): Boolean {
return try {
val value = editText.text.toString().toInt()
value in min..max
} catch (e: NumberFormatException) {
false
}
}
}

View file

@ -0,0 +1,16 @@
package info.nightscout.androidaps.utils.textValidator.validators
import android.text.TextUtils
import android.widget.EditText
/**
* A validator that returns true only if the input field contains only numbers.
*
* @author Andrea Baccega <me></me>@andreabaccega.com>
*/
class NumericValidator(_customErrorMessage: String?) : Validator(_customErrorMessage) {
override fun isValid(editText: EditText): Boolean {
return TextUtils.isDigitsOnly(editText.text)
}
}

View file

@ -0,0 +1,21 @@
package info.nightscout.androidaps.utils.textValidator.validators
import android.widget.EditText
/**
* The or validator checks if one of passed validators is returning true.<br></br>
* Note: the message that will be shown is the one passed to the Constructor
*
* @author Andrea B.
*/
class OrValidator(message: String?, vararg validators: Validator?) : MultiValidator(message, *validators) {
override fun isValid(editText: EditText): Boolean {
for (v in validators) {
if (v.isValid(editText)) {
return true // Remember :) We're acting like an || operator.
}
}
return false
}
}

View file

@ -0,0 +1,27 @@
package info.nightscout.androidaps.utils.textValidator.validators
import android.widget.EditText
import java.util.regex.Pattern
/**
* Base class for regexp based validators.
*
* @author Andrea Baccega <me></me>@andreabaccega.com>
* @see DomainValidator
*
* @see EmailValidator
*
* @see IpAddressValidator
*
* @see PhoneValidator
*
* @see WebUrlValidator
*
* @see RegexpValidator
*/
open class PatternValidator(_customErrorMessage: String?, val pattern: Pattern) : Validator(_customErrorMessage) {
override fun isValid(editText: EditText): Boolean {
return pattern.matcher(editText.text).matches()
}
}

View file

@ -0,0 +1,3 @@
package info.nightscout.androidaps.utils.textValidator.validators
class PersonFullNameValidator(message: String?) : RegexpValidator(message, "[\\p{L}- ]+")

View file

@ -0,0 +1,3 @@
package info.nightscout.androidaps.utils.textValidator.validators
class PersonNameValidator(message: String?) : RegexpValidator(message, "[\\p{L}-]+")

View file

@ -0,0 +1,13 @@
package info.nightscout.androidaps.utils.textValidator.validators
import android.os.Build
import android.util.Patterns
import java.util.regex.Pattern
/**
* It validates phone numbers.
* Regexp was taken from the android source code.
*
* @author Andrea Baccega <me></me>@andreabaccega.com>
*/
class PhoneValidator(_customErrorMessage: String?) : PatternValidator(_customErrorMessage, Patterns.PHONE)

View file

@ -0,0 +1,10 @@
package info.nightscout.androidaps.utils.textValidator.validators
import java.util.regex.Pattern
/**
* Used for validating the user input using a regexp.
*
* @author Andrea Baccega <me></me>@andreabaccega.com>
*/
open class RegexpValidator(message: String?, _regexp: String?) : PatternValidator(message, Pattern.compile(_regexp))

View file

@ -0,0 +1,17 @@
package info.nightscout.androidaps.utils.textValidator.validators
import android.text.TextUtils
import android.widget.EditText
/**
* A simple validator that validates the field only if the value is the same as another one.
*
* @author Andrea Baccega <me></me>@andreabaccega.com>
*/
class SameValueValidator(private val otherEditText: EditText, errorMessage: String?) : Validator(errorMessage) {
override fun isValid(editText: EditText): Boolean {
return TextUtils.equals(editText.text, otherEditText.text)
}
}

View file

@ -0,0 +1,24 @@
package info.nightscout.androidaps.utils.textValidator.validators
import android.widget.EditText
/**
* Validator abstract class. To be used with FormEditText
*
* @author Andrea Baccega <me></me>@andreabaccega.com>
*/
abstract class Validator(var errorMessage: String?) {
/**
* Should check if the EditText is valid.
*
* @param the edittext under evaluation
* @return true if the edittext is valid, false otherwise
*/
abstract fun isValid(editText: EditText): Boolean
fun hasErrorMessage(): Boolean {
return errorMessage != null
}
}

View file

@ -0,0 +1,11 @@
package info.nightscout.androidaps.utils.textValidator.validators
import android.util.Patterns
/**
* Validates a web url in the format:
* scheme + authority + path
*
* @author Andrea Baccega <me></me>@andreabaccega.com>
*/
class WebUrlValidator(_customErrorMessage: String?) : PatternValidator(_customErrorMessage, Patterns.WEB_URL)

View file

@ -27,6 +27,7 @@
app:srcCompat="@mipmap/ic_launcher" />
<TextView
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"

View file

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="48dp"
android:layout_marginBottom="48dp"
android:overScrollMode="ifContentScrolls">
<LinearLayout
android:id="@+id/edittext_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="20dp">
<EditText
android:id="@android:id/edit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="4dp"
android:paddingEnd="4dp" />
</LinearLayout>
</ScrollView>

View file

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="FormEditText">
<attr name="testType">
<enum name="regexp" value="0" />
<enum name="numeric" value="1" />
<enum name="alpha" value="2" />
<enum name="alphaNumeric" value="3" />
<enum name="email" value="4" />
<enum name="creditCard" value="5" />
<enum name="phone" value="6" />
<enum name="domainName" value="7" />
<enum name="ipAddress" value="8" />
<enum name="webUrl" value="9" />
<enum name="nocheck" value="10" />
<enum name="custom" value="11" />
<enum name="personName" value="12" />
<enum name="personFullName" value="13" />
<enum name="date" value="14" />
<enum name="numericRange" value="15" />
<enum name="floatNumericRange" value="16" />
</attr>
<attr name="testErrorString" format="string" />
<attr name="emptyErrorString" format="string" />
<attr name="customRegexp" format="string" />
<attr name="customFormat" format="string" />
<attr name="emptyAllowed" format="boolean" />
<attr name="classType" format="string" />
<attr name="minNumber" format="integer" />
<attr name="maxNumber" format="integer" />
<attr name="floatminNumber" format="float" />
<attr name="floatmaxNumber" format="float" />
</declare-styleable>
</resources>

View file

@ -501,10 +501,6 @@
<string name="openapsama_min_5m_carbimpact_summary">Default value: 3.0 (AMA) or 8.0 (SMB). This is a setting for default carb absorption impact per 5 minutes. The default is an expected 3mg/dl/5min. This affects how fast COB are decayed, and how much carb absorption is assumed in calculating future predicted BG, when BG is falling more than expected, or not rising as much as expected.</string>
<string name="openapsama_link_to_preferncejson_doc_txt">Attention!\nNormally you do not have to change these values below. Please CLICK HERE and READ the text and make sure you UNDERSTAND it before change any of these values.</string>
<string name="openapsama_link_to_preferncejson_doc" translatable="false">http://openaps.readthedocs.io/en/latest/docs/walkthrough/phase-3/beyond-low-glucose-suspend.html</string>
<string name="error_only_numeric_digits_allowed">Only numeric digits are allowed.</string>
<string name="error_only_numeric_digits_range_allowed">Only numeric digits within the range %1$s - %2$s are allowed.</string>
<string name="error_field_must_not_be_empty">The field must not be empty</string>
<string name="error_phone_not_valid">Phone number not valid</string>
<string name="smscommunicator_invalidphonennumber">Invalid SMS phone number</string>
<string name="overview_calibration">Calibration</string>
<string name="send_calibration">Send calibration %1$.1f to xDrip?</string>

View file

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="error_only_numeric_digits_allowed">Only numeric digits are allowed.</string>
<string name="error_only_numeric_digits_range_allowed">Only numeric digits within the range %1$s - %2$s are allowed.</string>
<string name="error_this_field_cannot_contain_special_character">This field cannot contain any special character</string>
<string name="error_only_standard_letters_are_allowed">Only standard letters are allowed</string>
<string name="error_field_must_not_be_empty">The field must not be empty</string>
<string name="error_email_address_not_valid">Email address not valid</string>
<string name="error_creditcard_number_not_valid">Credit card number is not valid</string>
<string name="error_phone_not_valid">Phone number not valid</string>
<string name="error_domain_not_valid">Domain name not valid</string>
<string name="error_ip_not_valid">IP Address not valid</string>
<string name="error_url_not_valid">Web Url is not valid</string>
<string name="error_notvalid_personname">Not a valid first or last name.</string>
<string name="error_notvalid_personfullname">Not a valid full name.</string>
<string name="error_date_not_valid">Format not valid</string>
</resources>

View file

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:validate="http://schemas.android.com/apk/res-auto">
<PreferenceCategory
android:key="absorption"
android:title="@string/absorptionsettings_title">
<com.andreabaccega.widget.ValidatingEditTextPreference
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
android:defaultValue="6"
android:dialogMessage="@string/absorption_maxtime_summary"
android:digits="0123456789.,"
@ -19,7 +19,7 @@
validate:minNumber="4"
validate:testType="numericRange" />
<com.andreabaccega.widget.ValidatingEditTextPreference
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
android:defaultValue="24"
android:dialogMessage="@string/openapsama_autosens_period_summary"
android:digits="0123456789"
@ -33,9 +33,11 @@
validate:minNumber="4"
validate:testType="numericRange" />
<PreferenceScreen android:title="@string/advancedsettings_title">
<androidx.preference.PreferenceScreen
android:key="absorption_aaps_advanced"
android:title="@string/advancedsettings_title">
<com.andreabaccega.widget.ValidatingEditTextPreference
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
android:defaultValue="1.2"
android:dialogMessage="@string/openapsama_autosens_max_summary"
android:digits="0123456789.,"
@ -49,7 +51,7 @@
validate:floatminNumber="0.5"
validate:testType="floatNumericRange" />
<com.andreabaccega.widget.ValidatingEditTextPreference
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
android:defaultValue="0.7"
android:dialogMessage="@string/openapsama_autosens_min_summary"
android:inputType="numberDecimal"
@ -62,8 +64,8 @@
validate:floatminNumber="0.1"
validate:testType="floatNumericRange" />
</PreferenceScreen>
</androidx.preference.PreferenceScreen>
</PreferenceCategory>
</PreferenceScreen>
</androidx.preference.PreferenceScreen>

View file

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:validate="http://schemas.android.com/apk/res-auto">
<PreferenceCategory
android:key="absorption"
android:title="@string/absorptionsettings_title">
<com.andreabaccega.widget.ValidatingEditTextPreference
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
android:defaultValue="8.0"
android:dialogMessage="@string/openapsama_min_5m_carbimpact_summary"
android:inputType="numberDecimal"
@ -19,7 +19,7 @@
validate:floatminNumber="0.1"
validate:testType="floatNumericRange" />
<com.andreabaccega.widget.ValidatingEditTextPreference
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
android:defaultValue="6"
android:dialogMessage="@string/absorption_cutoff_summary"
android:digits="0123456789.,"
@ -32,9 +32,11 @@
validate:minNumber="4"
validate:testType="numericRange" />
<PreferenceScreen android:title="@string/advancedsettings_title">
<androidx.preference.PreferenceScreen
android:key="absorption_oref0_advanced"
android:title="@string/advancedsettings_title">
<com.andreabaccega.widget.ValidatingEditTextPreference
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
android:defaultValue="1.2"
android:dialogMessage="@string/openapsama_autosens_max_summary"
android:digits="0123456789.,"
@ -48,7 +50,7 @@
validate:floatminNumber="0.5"
validate:testType="floatNumericRange" />
<com.andreabaccega.widget.ValidatingEditTextPreference
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
android:defaultValue="0.7"
android:dialogMessage="@string/openapsama_autosens_min_summary"
android:inputType="numberDecimal"
@ -61,8 +63,8 @@
validate:floatminNumber="0.1"
validate:testType="floatNumericRange" />
</PreferenceScreen>
</androidx.preference.PreferenceScreen>
</PreferenceCategory>
</PreferenceScreen>
</androidx.preference.PreferenceScreen>

View file

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:validate="http://schemas.android.com/apk/res-auto">
<PreferenceCategory
android:key="absorption"
android:title="@string/absorptionsettings_title">
<com.andreabaccega.widget.ValidatingEditTextPreference
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
android:defaultValue="8.0"
android:dialogMessage="@string/openapsama_min_5m_carbimpact_summary"
android:inputType="numberDecimal"
@ -19,7 +19,7 @@
validate:floatminNumber="0.1"
validate:testType="floatNumericRange" />
<com.andreabaccega.widget.ValidatingEditTextPreference
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
android:defaultValue="6"
android:dialogMessage="@string/absorption_cutoff_summary"
android:digits="0123456789.,"
@ -32,9 +32,11 @@
validate:minNumber="4"
validate:testType="numericRange" />
<PreferenceScreen android:title="@string/advancedsettings_title">
<androidx.preference.PreferenceScreen
android:key="absorption_oref1_advanced"
android:title="@string/advancedsettings_title">
<com.andreabaccega.widget.ValidatingEditTextPreference
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
android:defaultValue="1.2"
android:dialogMessage="@string/openapsama_autosens_max_summary"
android:digits="0123456789.,"
@ -48,7 +50,7 @@
validate:floatminNumber="0.5"
validate:testType="floatNumericRange" />
<com.andreabaccega.widget.ValidatingEditTextPreference
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
android:defaultValue="0.7"
android:dialogMessage="@string/openapsama_autosens_min_summary"
android:inputType="numberDecimal"
@ -61,8 +63,8 @@
validate:floatminNumber="0.1"
validate:testType="floatNumericRange" />
</PreferenceScreen>
</androidx.preference.PreferenceScreen>
</PreferenceCategory>
</PreferenceScreen>
</androidx.preference.PreferenceScreen>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory android:title="@string/patientage">
<ListPreference
@ -10,4 +10,4 @@
android:summary="@string/patientage_summary"
android:title="@string/patientage" />
</PreferenceCategory>
</PreferenceScreen>
</androidx.preference.PreferenceScreen>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory android:title="@string/automation">
@ -12,4 +12,4 @@
</PreferenceCategory>
</PreferenceScreen>
</androidx.preference.PreferenceScreen>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory
android:title="@string/bgsource_upload">
@ -16,4 +16,4 @@
</PreferenceCategory>
</PreferenceScreen>
</androidx.preference.PreferenceScreen>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory
android:title="@string/bgsource_upload">
@ -22,4 +22,4 @@
</PreferenceCategory>
</PreferenceScreen>
</androidx.preference.PreferenceScreen>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory
android:title="@string/danar_pump_settings">
@ -32,7 +32,9 @@
android:key="@string/key_danar_visualizeextendedaspercentage"
android:title="@string/danar_visualizeextendedaspercentage_title" />
<PreferenceScreen android:title="@string/advancedsettings_title">
<androidx.preference.PreferenceScreen
android:key="absorption_danar_advanced"
android:title="@string/advancedsettings_title">
<PreferenceCategory android:title="@string/bluetooth">
@ -44,8 +46,8 @@
</PreferenceCategory>
</PreferenceScreen>
</androidx.preference.PreferenceScreen>
</PreferenceCategory>
</PreferenceScreen>
</androidx.preference.PreferenceScreen>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory
android:title="@string/danar_pump_settings">
@ -25,7 +25,9 @@
android:key="@string/key_danar_visualizeextendedaspercentage"
android:title="@string/danar_visualizeextendedaspercentage_title" />
<PreferenceScreen android:title="@string/advancedsettings_title">
<androidx.preference.PreferenceScreen
android:key="absorption_danarkorean_advanced"
android:title="@string/advancedsettings_title">
<PreferenceCategory android:title="@string/bluetooth">
@ -37,8 +39,8 @@
</PreferenceCategory>
</PreferenceScreen>
</androidx.preference.PreferenceScreen>
</PreferenceCategory>
</PreferenceScreen>
</androidx.preference.PreferenceScreen>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory android:title="@string/danarspump">
@ -28,7 +28,9 @@
android:key="@string/key_danars_bolusspeed"
android:title="@string/bolusspeed" />
<PreferenceScreen android:title="@string/advancedsettings_title">
<androidx.preference.PreferenceScreen
android:key="absorption_danars_advanced"
android:title="@string/advancedsettings_title">
<PreferenceCategory android:title="@string/bluetooth">
@ -40,8 +42,8 @@
</PreferenceCategory>
</PreferenceScreen>
</androidx.preference.PreferenceScreen>
</PreferenceCategory>
</PreferenceScreen>
</androidx.preference.PreferenceScreen>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory
android:title="@string/danar_pump_settings">
@ -21,7 +21,9 @@
android:key="@string/key_danars_bolusspeed"
android:title="@string/bolusspeed" />
<PreferenceScreen android:title="@string/advancedsettings_title">
<androidx.preference.PreferenceScreen
android:key="absorption_danarv2_advanced"
android:title="@string/advancedsettings_title">
<PreferenceCategory android:title="@string/bluetooth">
@ -33,8 +35,8 @@
</PreferenceCategory>
</PreferenceScreen>
</androidx.preference.PreferenceScreen>
</PreferenceCategory>
</PreferenceScreen>
</androidx.preference.PreferenceScreen>

View file

@ -1,9 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory
android:title="@string/data_choices">
<PreferenceScreen android:title="@string/advancedsettings_title">
<androidx.preference.PreferenceScreen
android:key="absorption_datachoices_advanced"
android:title="@string/advancedsettings_title">
<PreferenceCategory android:title="@string/data_choices">
@ -15,8 +17,8 @@
</PreferenceCategory>
</PreferenceScreen>
</androidx.preference.PreferenceScreen>
</PreferenceCategory>
</PreferenceScreen>
</androidx.preference.PreferenceScreen>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory
android:title="@string/configbuilder_general">
@ -20,4 +20,4 @@
</PreferenceCategory>
</PreferenceScreen>
</androidx.preference.PreferenceScreen>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory android:title="@string/insight_local">
<Preference android:title="@string/insight_pairing">
@ -62,4 +62,4 @@
android:key="insight_disconnect_delay"
android:title="@string/disconnect_delay" />
</PreferenceCategory>
</PreferenceScreen>
</androidx.preference.PreferenceScreen>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory android:title="@string/insight_local">
<Preference android:title="@string/insight_pairing">
@ -62,4 +62,4 @@
android:key="insight_disconnect_delay"
android:title="@string/disconnect_delay" />
</PreferenceCategory>
</PreferenceScreen>
</androidx.preference.PreferenceScreen>

View file

@ -1,11 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:validate="http://schemas.android.com/apk/res-auto">
<PreferenceCategory
android:key="InsulinOrefFreePeak"
android:title="@string/insulin_oref_peak">
<com.andreabaccega.widget.ValidatingEditTextPreference
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
validate:testType="numericRange"
validate:minNumber="35"
validate:maxNumber="120"
@ -18,4 +18,4 @@
android:key="@string/key_insulin_oref_peak" />
</PreferenceCategory>
</PreferenceScreen>
</androidx.preference.PreferenceScreen>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:validate="http://schemas.android.com/apk/res-auto">
<PreferenceCategory
@ -13,7 +13,7 @@
android:entries="@array/aps_modeArray"
android:entryValues="@array/aps_modeValues"/>
<com.andreabaccega.widget.ValidatingEditTextPreference
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
android:defaultValue="20"
android:dialogMessage="@string/loop_openmode_min_change_summary"
android:digits="0123456789"
@ -28,4 +28,4 @@
validate:testType="numericRange" />
</PreferenceCategory>
</PreferenceScreen>
</androidx.preference.PreferenceScreen>

View file

@ -1,11 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory
android:key="maintenance"
android:title="@string/maintenance_settings">
<com.andreabaccega.widget.ValidatingEditTextPreference
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
android:defaultValue="logs@androidaps.org"
android:dialogMessage="@string/maintenance_email"
android:inputType="textEmailAddress"
@ -30,4 +30,4 @@
</PreferenceCategory>
</PreferenceScreen>
</androidx.preference.PreferenceScreen>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory android:title="@string/medtronic_name">
@ -85,4 +85,4 @@
</info.nightscout.androidaps.plugins.pump.common.ui.RileyLinkSelectPreference>
</PreferenceCategory>
</PreferenceScreen>
</androidx.preference.PreferenceScreen>

View file

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:validate="http://schemas.android.com/apk/res-auto">
<PreferenceCategory android:title="@string/nsclientinternal_title">
<com.andreabaccega.widget.ValidatingEditTextPreference
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
android:defaultValue="https://{YOUR-SITE}.azurewebsites.net/"
android:dialogMessage="@string/nsclientinternal_url_dialogmessage"
android:inputType="textUri"
@ -30,7 +30,9 @@
android:key="@string/key_ns_uploadlocalprofile"
android:title="@string/ns_ploadlocalprofile" />
<PreferenceScreen android:title="@string/ns_alarmoptions">
<androidx.preference.PreferenceScreen
android:key="@string/ns_alarmoptions"
android:title="@string/ns_alarmoptions">
<SwitchPreference
android:defaultValue="false"
@ -57,7 +59,7 @@
android:key="@string/key_nsalarm_staledata"
android:title="@string/nsalarm_staledata" />
<com.andreabaccega.widget.ValidatingEditTextPreference
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
android:defaultValue="16"
android:digits="0123456789"
android:inputType="number"
@ -75,7 +77,7 @@
android:key="@string/key_nsalarm_urgent_staledata"
android:title="@string/nsalarm_urgentstaledata" />
<com.andreabaccega.widget.ValidatingEditTextPreference
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
android:defaultValue="31"
android:digits="0123456789"
android:inputType="number"
@ -88,9 +90,11 @@
validate:minNumber="30"
validate:testType="numericRange" />
</PreferenceScreen>
</androidx.preference.PreferenceScreen>
<PreferenceScreen android:title="@string/connectionsettings_title">
<androidx.preference.PreferenceScreen
android:key="@string/connectionsettings_title"
android:title="@string/connectionsettings_title">
<SwitchPreference
android:defaultValue="false"
@ -115,9 +119,11 @@
android:key="@string/key_ns_chargingonly"
android:title="@string/ns_chargingonly" />
</PreferenceScreen>
</androidx.preference.PreferenceScreen>
<PreferenceScreen android:title="@string/advancedsettings_title">
<androidx.preference.PreferenceScreen
android:key="absorption_nsclient_advanced"
android:title="@string/advancedsettings_title">
<SwitchPreference
android:defaultValue="true"
@ -154,8 +160,8 @@
android:key="ns_sync_use_absolute"
android:title="@string/ns_sync_use_absolute_title" />
</PreferenceScreen>
</androidx.preference.PreferenceScreen>
</PreferenceCategory>
</PreferenceScreen>
</androidx.preference.PreferenceScreen>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:validate="http://schemas.android.com/apk/res-auto">
<PreferenceCategory
android:key="openapsama"
@ -30,7 +30,7 @@
android:summary="@string/openapsama_autosens_adjusttargets_summary"
android:title="@string/openapsama_autosens_adjusttargets" />
<com.andreabaccega.widget.ValidatingEditTextPreference
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
android:defaultValue="3.0"
android:dialogMessage="@string/openapsama_min_5m_carbimpact_summary"
android:inputType="numberDecimal"
@ -43,7 +43,9 @@
validate:floatminNumber="0.1"
validate:testType="floatNumericRange" />
<PreferenceScreen android:title="@string/advancedsettings_title">
<androidx.preference.PreferenceScreen
android:key="absorption_ama_advanced"
android:title="@string/advancedsettings_title">
<Preference android:summary="@string/openapsama_link_to_preferncejson_doc_txt">
<intent
@ -57,7 +59,7 @@
android:summary="@string/always_use_shortavg_summary"
android:title="@string/always_use_shortavg" />
<com.andreabaccega.widget.ValidatingEditTextPreference
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
android:defaultValue="3"
android:dialogMessage="@string/openapsama_max_daily_safety_multiplier_summary"
android:digits="0123456789.,"
@ -70,7 +72,7 @@
validate:minNumber="1"
validate:testType="numericRange" />
<com.andreabaccega.widget.ValidatingEditTextPreference
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
android:defaultValue="4"
android:dialogMessage="@string/openapsama_current_basal_safety_multiplier_summary"
android:digits="0123456789.,"
@ -84,7 +86,7 @@
validate:floatminNumber="1"
validate:testType="floatNumericRange" />
<com.andreabaccega.widget.ValidatingEditTextPreference
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
android:defaultValue="2"
android:dialogMessage="@string/openapsama_bolussnooze_dia_divisor_summary"
android:digits="0123456789.,"
@ -98,8 +100,8 @@
validate:minNumber="1"
validate:testType="floatNumericRange" />
</PreferenceScreen>
</androidx.preference.PreferenceScreen>
</PreferenceCategory>
</PreferenceScreen>
</androidx.preference.PreferenceScreen>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:validate="http://schemas.android.com/apk/res-auto">
<PreferenceCategory
android:key="openaps"
@ -19,7 +19,9 @@
android:numeric="decimal"
android:title="@string/openapsma_maxiob_title" />
<PreferenceScreen android:title="@string/advancedsettings_title">
<androidx.preference.PreferenceScreen
android:key="absorption_ma_advanced"
android:title="@string/advancedsettings_title">
<Preference android:summary="@string/openapsama_link_to_preferncejson_doc_txt">
<intent
@ -33,7 +35,7 @@
android:summary="@string/always_use_shortavg_summary"
android:title="@string/always_use_shortavg" />
<com.andreabaccega.widget.ValidatingEditTextPreference
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
android:defaultValue="2"
android:dialogMessage="@string/openapsama_bolussnooze_dia_divisor_summary"
android:digits="0123456789.,"
@ -46,8 +48,8 @@
validate:maxNumber="10"
validate:minNumber="1"
validate:testType="floatNumericRange" />
</PreferenceScreen>
</androidx.preference.PreferenceScreen>
</PreferenceCategory>
</PreferenceScreen>
</androidx.preference.PreferenceScreen>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:validate="http://schemas.android.com/apk/res-auto">
<PreferenceCategory
android:key="openapssmb"
@ -97,7 +97,9 @@
android:enabled="false"
/>
<PreferenceScreen android:title="@string/advancedsettings_title">
<androidx.preference.PreferenceScreen
android:key="absorption_smb_advanced"
android:title="@string/advancedsettings_title">
<Preference android:summary="@string/openapsama_link_to_preferncejson_doc_txt">
<intent
@ -111,7 +113,7 @@
android:summary="@string/always_use_shortavg_summary"
android:title="@string/always_use_shortavg" />
<com.andreabaccega.widget.ValidatingEditTextPreference
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
android:defaultValue="3"
android:dialogMessage="@string/openapsama_max_daily_safety_multiplier_summary"
android:digits="0123456789.,"
@ -124,7 +126,7 @@
validate:minNumber="1"
validate:testType="numericRange" />
<com.andreabaccega.widget.ValidatingEditTextPreference
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
android:defaultValue="4"
android:dialogMessage="@string/openapsama_current_basal_safety_multiplier_summary"
android:digits="0123456789.,"
@ -138,8 +140,8 @@
validate:floatminNumber="1"
validate:testType="floatNumericRange" />
</PreferenceScreen>
</androidx.preference.PreferenceScreen>
</PreferenceCategory>
</PreferenceScreen>
</androidx.preference.PreferenceScreen>

View file

@ -1,10 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:validate="http://schemas.android.com/apk/res-auto">
<PreferenceCategory
android:key="others"
android:title="@string/othersettings_title">
<PreferenceScreen android:title="@string/default_temptargets">
<androidx.preference.PreferenceScreen
android:key="@string/default_temptargets"
android:title="@string/default_temptargets">
<EditTextPreference
android:defaultValue="0"
android:inputType="number"
@ -35,8 +37,11 @@
android:inputType="numberDecimal"
android:key="@string/key_hypo_target"
android:title="@string/hypo_target" />
</PreferenceScreen>
<PreferenceScreen android:title="@string/fillbolus_title">
</androidx.preference.PreferenceScreen>
<androidx.preference.PreferenceScreen
android:key="@string/fillbolus_title"
android:title="@string/fillbolus_title">
<EditTextPreference
android:defaultValue="0.3"
android:inputType="numberDecimal"
@ -52,9 +57,11 @@
android:inputType="numberDecimal"
android:key="fill_button3"
android:title="@string/button3" />
</PreferenceScreen>
<PreferenceScreen
</androidx.preference.PreferenceScreen>
<androidx.preference.PreferenceScreen
android:summary="@string/prefs_range_summary"
android:key="@string/prefs_range_title"
android:title="@string/prefs_range_title">
<EditTextPreference
android:defaultValue="0"
@ -66,13 +73,16 @@
android:inputType="numberDecimal"
android:key="@string/key_high_mark"
android:title="@string/high_mark" />
</PreferenceScreen>
</androidx.preference.PreferenceScreen>
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_short_tabtitles"
android:title="@string/short_tabtitles" />
</PreferenceCategory>
<PreferenceScreen android:title="@string/localalertsettings_title">
<androidx.preference.PreferenceScreen
android:key="@string/localalertsettings_title"
android:title="@string/localalertsettings_title">
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_enable_missed_bg_readings_alert"
@ -87,7 +97,7 @@
android:defaultValue="true"
android:key="@string/key_enable_pump_unreachable_alert"
android:title="@string/enable_pump_unreachable_alert" />
<com.andreabaccega.widget.ValidatingEditTextPreference
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
validate:testType="numericRange"
validate:minNumber="30"
validate:maxNumber="300"
@ -96,10 +106,10 @@
android:inputType="number"
android:key="@string/key_pump_unreachable_threshold"
android:title="@string/pump_unreachable_threshold">
</com.andreabaccega.widget.ValidatingEditTextPreference>
</PreferenceScreen>
</info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference>
</androidx.preference.PreferenceScreen>
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_raise_notifications_as_android_notifications"
android:title="@string/raise_notifications_as_android_notifications" />
</PreferenceScreen>
</androidx.preference.PreferenceScreen>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:validate="http://schemas.android.com/apk/res-auto">
<PreferenceCategory android:title="@string/overview">
@ -10,7 +10,9 @@
android:title="@string/keep_screen_on_title"
android:summary="@string/keep_screen_on_summary"/>
<PreferenceScreen android:title="@string/overview_buttons_selection">
<androidx.preference.PreferenceScreen
android:key="@string/overview_buttons_selection"
android:title="@string/overview_buttons_selection">
<SwitchPreference
android:defaultValue="false"
@ -27,7 +29,7 @@
android:key="@string/key_show_insulin_button"
android:title="@string/configbuilder_insulin" />
<com.andreabaccega.widget.ValidatingEditTextPreference
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
android:defaultValue="0.5"
android:dependency="@string/key_show_insulin_button"
android:dialogMessage="@string/insulin_increment_button_message"
@ -41,7 +43,7 @@
validate:floatminNumber="-5.0"
validate:testType="floatNumericRange" />
<com.andreabaccega.widget.ValidatingEditTextPreference
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
android:defaultValue="1.0"
android:dependency="@string/key_show_insulin_button"
android:dialogMessage="@string/insulin_increment_button_message"
@ -55,7 +57,7 @@
validate:floatminNumber="-5.0"
validate:testType="floatNumericRange" />
<com.andreabaccega.widget.ValidatingEditTextPreference
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
android:defaultValue="2.0"
android:dependency="@string/key_show_insulin_button"
android:dialogMessage="@string/insulin_increment_button_message"
@ -74,7 +76,7 @@
android:key="@string/key_show_carbs_button"
android:title="@string/carbs" />
<com.andreabaccega.widget.ValidatingEditTextPreference
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
android:defaultValue="5"
android:dependency="@string/key_show_carbs_button"
android:dialogMessage="@string/carb_increment_button_message"
@ -88,7 +90,7 @@
validate:minNumber="-50"
validate:testType="numericRange" />
<com.andreabaccega.widget.ValidatingEditTextPreference
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
android:defaultValue="10"
android:dependency="@string/key_show_carbs_button"
android:dialogMessage="@string/carb_increment_button_message"
@ -102,7 +104,7 @@
validate:minNumber="-50"
validate:testType="numericRange" />
<com.andreabaccega.widget.ValidatingEditTextPreference
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
android:defaultValue="20"
android:dependency="@string/key_show_carbs_button"
android:dialogMessage="@string/carb_increment_button_message"
@ -128,7 +130,7 @@
android:summary="@string/show_calibration_button_summary"
android:title="@string/overview_calibration" />
</PreferenceScreen>
</androidx.preference.PreferenceScreen>
<Preference
android:key="quickwizard"
@ -141,9 +143,11 @@
android:key="@string/key_show_notes_entry_dialogs"
android:title="@string/overview_show_notes_field_in_dialogs_title" />
<PreferenceScreen android:title="@string/advancedsettings_title" android:key="@string/key_advancedsettings">
<androidx.preference.PreferenceScreen
android:key="absorption_overview_advanced"
android:title="@string/advancedsettings_title">
<com.andreabaccega.widget.ValidatingEditTextPreference
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
android:defaultValue="100"
android:dialogMessage="@string/deliverpartofboluswizard"
android:inputType="number"
@ -174,7 +178,7 @@
android:summary="@string/show_statuslights_extended_summary"
android:title="@string/show_statuslights_extended" />
<com.andreabaccega.widget.ValidatingEditTextPreference
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
android:defaultValue="80"
android:dependency="@string/key_show_statuslights"
android:inputType="numberSigned"
@ -187,7 +191,7 @@
validate:minNumber="0"
validate:testType="numericRange" />
<com.andreabaccega.widget.ValidatingEditTextPreference
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
android:defaultValue="10"
android:dependency="@string/key_show_statuslights"
android:inputType="numberSigned"
@ -200,7 +204,7 @@
validate:minNumber="0"
validate:testType="numericRange" />
<com.andreabaccega.widget.ValidatingEditTextPreference
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
android:defaultValue="25"
android:dependency="@string/key_show_statuslights"
android:inputType="numberSigned"
@ -213,7 +217,7 @@
validate:minNumber="0"
validate:testType="numericRange" />
<com.andreabaccega.widget.ValidatingEditTextPreference
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
android:defaultValue="5"
android:dependency="@string/key_show_statuslights"
android:inputType="numberSigned"
@ -226,8 +230,8 @@
validate:minNumber="0"
validate:testType="numericRange" />
</PreferenceScreen>
</androidx.preference.PreferenceScreen>
</PreferenceCategory>
</PreferenceScreen>
</androidx.preference.PreferenceScreen>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory
android:key="password"
android:title="@string/settings_password">
@ -11,4 +11,4 @@
</EditTextPreference>
</PreferenceCategory>
</PreferenceScreen>
</androidx.preference.PreferenceScreen>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory
android:key="treatmentssafety"
android:title="@string/treatmentssafety_title">
@ -17,4 +17,4 @@
android:inputType="numberDecimal">
</EditTextPreference>
</PreferenceCategory>
</PreferenceScreen>
</androidx.preference.PreferenceScreen>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:validate="http://schemas.android.com/apk/res-auto">
<PreferenceCategory
android:key="smscommunicator"
@ -9,7 +9,7 @@
android:key="@string/key_smscommunicator_allowednumbers"
android:summary="@string/smscommunicator_allowednumbers_summary"
android:title="@string/smscommunicator_allowednumbers" />
<com.andreabaccega.widget.ValidatingEditTextPreference
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
android:key="@string/key_smscommunicator_remotebolusmindistance"
android:defaultValue="15"
android:summary="@string/smscommunicator_remotebolusmindistance_summary"
@ -26,4 +26,4 @@
</PreferenceCategory>
</PreferenceScreen>
</androidx.preference.PreferenceScreen>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory
android:key="tidepool_upload_screen"
@ -56,5 +56,5 @@
</PreferenceCategory>
</PreferenceScreen>
</androidx.preference.PreferenceScreen>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory
android:key="virtualpump"
android:title="@string/virtualpump_settings">
@ -18,4 +18,4 @@
</PreferenceCategory>
</PreferenceScreen>
</androidx.preference.PreferenceScreen>

View file

@ -1,10 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory
android:key="wearplugin"
android:title="@string/wear_settings">
<PreferenceScreen
<androidx.preference.PreferenceScreen
android:key="@string/wear_settings"
android:title="@string/wear_settings">
<SwitchPreference
@ -91,6 +92,6 @@
android:summary="@string/wear_notifysmb_summary"
android:title="@string/wear_notifysmb_title" />
</PreferenceCategory>
</PreferenceScreen>
</androidx.preference.PreferenceScreen>
</PreferenceCategory>
</PreferenceScreen>
</androidx.preference.PreferenceScreen>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory
android:key="xdripstatus"
android:title="@string/xdripstatus_settings">
@ -16,4 +16,4 @@
android:summary="@string/wear_showbgi_summary"/>
</PreferenceCategory>
</PreferenceScreen>
</androidx.preference.PreferenceScreen>

View file

@ -1,7 +1,6 @@
package info.nightscout.androidaps.interaction.actions;
import android.app.Activity;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.os.Bundle;
@ -23,8 +22,6 @@ import info.nightscout.androidaps.data.ListenerService;
import info.nightscout.androidaps.interaction.utils.PlusMinusEditText;
import info.nightscout.androidaps.interaction.utils.SafeParse;
import static android.preference.PreferenceManager.getDefaultSharedPreferences;
/**
* Created by adrian on 09/02/17.
*/

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<CheckBoxPreference
@ -244,4 +244,4 @@
android:key="version_number"
android:summary="Input Design"
android:title="@string/pref_version" />
</PreferenceScreen>
</androidx.preference.PreferenceScreen>