MDT refactor pass 14

This commit is contained in:
Milos Kozak 2020-04-27 21:14:45 +02:00
parent dbb7570de7
commit 975f61563c
6 changed files with 18 additions and 59 deletions

View file

@ -275,13 +275,13 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang
} else if (pref.text != null) {
pref.dialogMessage = pref.dialogMessage
pref.setSummary(pref.text)
} else {
for (plugin in pluginStore.plugins) {
plugin.updatePreferenceSummary(pref)
}
}
}
for (plugin in pluginStore.plugins) {
pref?.let { plugin.updatePreferenceSummary(it) }
}
val hmacPasswords = arrayOf(
resourceHelper.gs(R.string.key_bolus_password),
resourceHelper.gs(R.string.key_master_password),

View file

@ -110,8 +110,6 @@ public class RileyLinkBLEScanActivity extends NoSplashAppCompatActivity {
sp.putString(RileyLinkConst.Prefs.RileyLinkAddress, bleAddress);
rileyLinkUtil.getRileyLinkSelectPreference().setSummary(bleAddress);
medtronicPumpPlugin.getRileyLinkService().verifyConfiguration(); // force reloading of address
rxBus.send(new EventMedtronicPumpConfigurationChanged());

View file

@ -23,7 +23,6 @@ import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.data.RLHistor
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.data.ServiceResult;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.data.ServiceTransport;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks.ServiceTask;
import info.nightscout.androidaps.plugins.pump.common.ui.RileyLinkSelectPreference;
/**
* Created by andy on 17/05/2018.
@ -38,7 +37,6 @@ public class RileyLinkUtil {
static ServiceTask currentTask;
private RileyLinkEncodingType encoding;
private RileyLinkSelectPreference rileyLinkSelectPreference;
private Encoding4b6b encoding4b6b;
@Inject
@ -168,14 +166,6 @@ public class RileyLinkUtil {
return historyRileyLink;
}
public void setRileyLinkSelectPreference(RileyLinkSelectPreference rileyLinkSelectPreference) {
this.rileyLinkSelectPreference = rileyLinkSelectPreference;
}
public RileyLinkSelectPreference getRileyLinkSelectPreference() {
return rileyLinkSelectPreference;
}
public Encoding4b6b getEncoding4b6b() {
return encoding4b6b;
}

View file

@ -1,41 +0,0 @@
package info.nightscout.androidaps.plugins.pump.common.ui;
import android.content.Context;
import android.util.AttributeSet;
import androidx.preference.Preference;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil;
import info.nightscout.androidaps.utils.SP;
/**
* Created by andy on 10/18/18.
*/
public class RileyLinkSelectPreference extends Preference {
public RileyLinkSelectPreference(Context context) {
super(context);
setInitialSummaryValue();
RileyLinkUtil.getInstance().setRileyLinkSelectPreference(this);
}
public RileyLinkSelectPreference(Context context, AttributeSet attrs) {
super(context, attrs);
setInitialSummaryValue();
RileyLinkUtil.getInstance().setRileyLinkSelectPreference(this);
}
private void setInitialSummaryValue() {
String value = SP.getString("pref_rileylink_mac_address", null);
setSummary(value == null ? MainApp.gs(R.string.rileylink_error_address_not_set_short) : value);
}
}

View file

@ -9,7 +9,9 @@ import android.os.SystemClock;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.preference.Preference;
import org.jetbrains.annotations.NotNull;
import org.joda.time.LocalDateTime;
import java.util.ArrayList;
@ -197,6 +199,16 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
}
@Override
public void updatePreferenceSummary(@NotNull Preference pref) {
super.updatePreferenceSummary(pref);
if (pref.getKey().equals(getResourceHelper().gs(R.string.key_rileylink_mac_address))) {
String value = sp.getStringOrNull(R.string.key_rileylink_mac_address, null);
pref.setSummary(value == null ? getResourceHelper().gs(R.string.rileylink_error_address_not_set_short) : value);
}
}
private String getLogPrefix() {
return "MedtronicPumpPlugin::";
}

View file

@ -90,13 +90,13 @@
android:selectable="true"
android:title="@string/medtronic_bolus_debugging" />
<info.nightscout.androidaps.plugins.pump.common.ui.RileyLinkSelectPreference
<Preference
android:enabled="true"
android:key="@string/key_rileylink_mac_address"
android:summary=""
android:title="RileyLink Configuration">
<intent android:action="info.nightscout.androidaps.plugins.PumpCommon.dialog.RileyLinkBLEScanActivity" />
</info.nightscout.androidaps.plugins.pump.common.ui.RileyLinkSelectPreference>
</Preference>
</PreferenceCategory>