preferences, button

This commit is contained in:
Milos Kozak 2019-06-04 07:38:17 +02:00
parent 4a07e01b7d
commit e32801ca6b
5 changed files with 12 additions and 3 deletions

View file

@ -21,6 +21,7 @@ import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.plugins.general.careportal.CareportalPlugin;
import info.nightscout.androidaps.plugins.constraints.safety.SafetyPlugin;
import info.nightscout.androidaps.plugins.general.tidepool.TidepoolPlugin;
import info.nightscout.androidaps.plugins.insulin.InsulinOrefFreePeakPlugin;
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin;
import info.nightscout.androidaps.plugins.general.nsclient.NSClientPlugin;
@ -182,6 +183,7 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
addPreferencesFromResourceIfEnabled(InsulinOrefFreePeakPlugin.getPlugin(), PluginType.INSULIN);
addPreferencesFromResourceIfEnabled(NSClientPlugin.getPlugin(), PluginType.GENERAL);
addPreferencesFromResourceIfEnabled(TidepoolPlugin.INSTANCE, PluginType.GENERAL);
addPreferencesFromResourceIfEnabled(SmsCommunicatorPlugin.getPlugin(), PluginType.GENERAL);
addPreferencesFromResource(R.xml.pref_others);

View file

@ -10,6 +10,7 @@ import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.plugins.common.SubscriberFragment;
import info.nightscout.androidaps.plugins.general.tidepool.comm.TidepoolUploader;
import info.nightscout.androidaps.plugins.general.tidepool.events.EventTidepoolDoUpload;
import info.nightscout.androidaps.plugins.general.tidepool.events.EventTidepoolResetData;
public class TidepoolJavaFragment extends SubscriberFragment {
@ -22,6 +23,10 @@ public class TidepoolJavaFragment extends SubscriberFragment {
login.setOnClickListener(v -> {
TidepoolUploader.INSTANCE.doLogin();
});
Button uploadnow = view.findViewById(R.id.tidepool_uploadnow);
uploadnow.setOnClickListener(v -> {
MainApp.bus().post(new EventTidepoolDoUpload());
});
Button removeall = view.findViewById(R.id.tidepool_removeall);
removeall.setOnClickListener(v -> {
MainApp.bus().post(new EventTidepoolResetData());

View file

@ -11,6 +11,7 @@ import info.nightscout.androidaps.interfaces.PluginType
import info.nightscout.androidaps.logging.L
import info.nightscout.androidaps.plugins.general.tidepool.comm.Session
import info.nightscout.androidaps.plugins.general.tidepool.comm.TidepoolUploader
import info.nightscout.androidaps.plugins.general.tidepool.comm.UploadChunk
import info.nightscout.androidaps.plugins.general.tidepool.events.EventTidepoolDoUpload
import info.nightscout.androidaps.plugins.general.tidepool.events.EventTidepoolResetData
import info.nightscout.androidaps.plugins.general.tidepool.utils.RateLimit
@ -70,6 +71,7 @@ object TidepoolPlugin : PluginBase(PluginDescription()
session = TidepoolUploader.doLogin()
if (session != null) {
TidepoolUploader.deleteDataSet(session!!)
SP.putLong(R.string.key_tidepool_last_end, 0)
TidepoolUploader.doLogin()
}
}

View file

@ -81,8 +81,7 @@ object UploadChunk {
fun setLastEnd(time: Long) {
if (time > getLastEnd()) {
//TODO SP.putLong(R.string.key_tidepool_last_end, time)
SP.putLong(R.string.key_tidepool_last_end, 0)
SP.putLong(R.string.key_tidepool_last_end, time)
if (L.isEnabled(L.TIDEPOOL)) log.debug("Updating last end to: " + DateUtil.dateAndTimeFullString(time))
} else {
if (L.isEnabled(L.TIDEPOOL)) log.debug("Cannot set last end to: " + DateUtil.dateAndTimeFullString(time) + " vs " + DateUtil.dateAndTimeFullString(getLastEnd()))

View file

@ -30,7 +30,8 @@
android:summary=""
android:title="@string/title_tidepool_window_latency" />
<CheckBoxPreference
android:defaultValue="false"
android:defaultValue="true"
android:enabled="false"
android:key="@string/key_tidepool_dev_servers"
android:summary="@string/summary_tidepool_dev_servers"
android:title="@string/title_tidepool_dev_servers" />