reset time button

This commit is contained in:
Milos Kozak 2019-06-05 00:22:57 +02:00
parent e32801ca6b
commit 8ea5968f4d
4 changed files with 39 additions and 20 deletions

View file

@ -12,6 +12,7 @@ import info.nightscout.androidaps.plugins.common.SubscriberFragment;
import info.nightscout.androidaps.plugins.general.tidepool.comm.TidepoolUploader; 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.EventTidepoolDoUpload;
import info.nightscout.androidaps.plugins.general.tidepool.events.EventTidepoolResetData; import info.nightscout.androidaps.plugins.general.tidepool.events.EventTidepoolResetData;
import info.nightscout.androidaps.utils.SP;
public class TidepoolJavaFragment extends SubscriberFragment { public class TidepoolJavaFragment extends SubscriberFragment {
@Override @Override
@ -20,17 +21,19 @@ public class TidepoolJavaFragment extends SubscriberFragment {
View view = inflater.inflate(R.layout.tidepool_fragment, container, false); View view = inflater.inflate(R.layout.tidepool_fragment, container, false);
Button login = view.findViewById(R.id.tidepool_login); Button login = view.findViewById(R.id.tidepool_login);
login.setOnClickListener(v -> { login.setOnClickListener(v1 -> {
TidepoolUploader.INSTANCE.doLogin(); TidepoolUploader.INSTANCE.doLogin();
}); });
Button uploadnow = view.findViewById(R.id.tidepool_uploadnow); Button uploadnow = view.findViewById(R.id.tidepool_uploadnow);
uploadnow.setOnClickListener(v -> { uploadnow.setOnClickListener(v2 -> MainApp.bus().post(new EventTidepoolDoUpload()));
MainApp.bus().post(new EventTidepoolDoUpload());
});
Button removeall = view.findViewById(R.id.tidepool_removeall); Button removeall = view.findViewById(R.id.tidepool_removeall);
removeall.setOnClickListener(v -> { removeall.setOnClickListener(v3 -> {
MainApp.bus().post(new EventTidepoolResetData()); MainApp.bus().post(new EventTidepoolResetData());
}); });
Button resetStart = view.findViewById(R.id.tidepool_resertstart);
resetStart.setOnClickListener(v4 -> {
SP.putLong(R.string.key_tidepool_last_end, 0);
});
return view; return view;
} }

View file

@ -1,5 +1,6 @@
package info.nightscout.androidaps.plugins.general.tidepool package info.nightscout.androidaps.plugins.general.tidepool
import android.text.Html
import com.squareup.otto.Subscribe import com.squareup.otto.Subscribe
import info.nightscout.androidaps.MainApp import info.nightscout.androidaps.MainApp
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
@ -11,13 +12,14 @@ import info.nightscout.androidaps.interfaces.PluginType
import info.nightscout.androidaps.logging.L import info.nightscout.androidaps.logging.L
import info.nightscout.androidaps.plugins.general.tidepool.comm.Session 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.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.EventTidepoolDoUpload
import info.nightscout.androidaps.plugins.general.tidepool.events.EventTidepoolResetData import info.nightscout.androidaps.plugins.general.tidepool.events.EventTidepoolResetData
import info.nightscout.androidaps.plugins.general.tidepool.events.EventTidepoolStatus
import info.nightscout.androidaps.plugins.general.tidepool.utils.RateLimit import info.nightscout.androidaps.plugins.general.tidepool.utils.RateLimit
import info.nightscout.androidaps.receivers.ChargingStateReceiver import info.nightscout.androidaps.receivers.ChargingStateReceiver
import info.nightscout.androidaps.utils.SP import info.nightscout.androidaps.utils.SP
import org.slf4j.LoggerFactory import org.slf4j.LoggerFactory
import java.util.*
object TidepoolPlugin : PluginBase(PluginDescription() object TidepoolPlugin : PluginBase(PluginDescription()
.mainType(PluginType.GENERAL) .mainType(PluginType.GENERAL)
@ -32,6 +34,13 @@ object TidepoolPlugin : PluginBase(PluginDescription()
var session: Session? = null var session: Session? = null
private val listLog = ArrayList<EventTidepoolStatus>()
internal var textLog = Html.fromHtml("")
var paused: Boolean = false
internal var autoscroll: Boolean = false
var status = ""
override fun onStart() { override fun onStart() {
MainApp.bus().register(this) MainApp.bus().register(this)
super.onStart() super.onStart()

View file

@ -113,9 +113,9 @@ object UploadChunk {
val end = DateUtil.now() val end = DateUtil.now()
val bgReadingList = MainApp.getDbHelper().getBgreadingsDataFromTime(start, end, false) val bgReadingList = MainApp.getDbHelper().getBgreadingsDataFromTime(start, end, false)
return if (bgReadingList != null && bgReadingList.size > 0) { return if (bgReadingList.size > 0)
bgReadingList[0].date bgReadingList[0].date
} else -1 else -1
} }
@Suppress("UNUSED_PARAMETER") @Suppress("UNUSED_PARAMETER")

View file

@ -18,7 +18,6 @@
android:id="@+id/tidepool_uploadnow" android:id="@+id/tidepool_uploadnow"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="36dp"
android:text="Upload now" android:text="Upload now"
app:layout_constraintStart_toEndOf="@+id/tidepool_login" app:layout_constraintStart_toEndOf="@+id/tidepool_login"
tools:layout_editor_absoluteY="66dp" /> tools:layout_editor_absoluteY="66dp" />
@ -27,7 +26,6 @@
android:id="@+id/tidepool_removeall" android:id="@+id/tidepool_removeall"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:text="Remove all" android:text="Remove all"
app:layout_constraintStart_toEndOf="@+id/tidepool_uploadnow" app:layout_constraintStart_toEndOf="@+id/tidepool_uploadnow"
tools:layout_editor_absoluteY="66dp" /> tools:layout_editor_absoluteY="66dp" />
@ -48,4 +46,13 @@
android:text="Login" android:text="Login"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
tools:layout_editor_absoluteY="66dp" /> tools:layout_editor_absoluteY="66dp" />
<Button
android:id="@+id/tidepool_resertstart"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="308dp"
android:text="Reset start"
app:layout_constraintStart_toStartOf="parent"
tools:layout_editor_absoluteY="66dp" />
</android.support.constraint.ConstraintLayout> </android.support.constraint.ConstraintLayout>