layout improvement

This commit is contained in:
Milos Kozak 2019-06-06 23:25:21 +02:00
parent ba0b7ec83d
commit 5dbdd5e437
5 changed files with 54 additions and 38 deletions

View file

@ -21,6 +21,7 @@ import info.nightscout.androidaps.utils.SP;
public class TidepoolJavaFragment extends SubscriberFragment { public class TidepoolJavaFragment extends SubscriberFragment {
private TextView logTextView; private TextView logTextView;
private TextView statusTextView;
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
@ -43,6 +44,7 @@ public class TidepoolJavaFragment extends SubscriberFragment {
}); });
logTextView = view.findViewById(R.id.tidepool_log); logTextView = view.findViewById(R.id.tidepool_log);
statusTextView = view.findViewById(R.id.tidepool_status);
return view; return view;
} }
@ -58,6 +60,7 @@ public class TidepoolJavaFragment extends SubscriberFragment {
if (activity != null) if (activity != null)
activity.runOnUiThread(() -> { activity.runOnUiThread(() -> {
TidepoolPlugin.INSTANCE.updateLog(); TidepoolPlugin.INSTANCE.updateLog();
statusTextView.setText(TidepoolUploader.INSTANCE.getConnectionStatus().name());
logTextView.setText(TidepoolPlugin.INSTANCE.getTextLog()); logTextView.setText(TidepoolPlugin.INSTANCE.getTextLog());
}); });
} }

View file

@ -37,7 +37,6 @@ object TidepoolPlugin : PluginBase(PluginDescription()
private val listLog = ArrayList<EventTidepoolStatus>() private val listLog = ArrayList<EventTidepoolStatus>()
var textLog = Html.fromHtml("") var textLog = Html.fromHtml("")
var status = ""
var paused: Boolean = false var paused: Boolean = false

View file

@ -205,7 +205,7 @@ object TidepoolUploader {
} }
private fun status(status: String) { fun status(status: String) {
if (L.isEnabled(L.TIDEPOOL)) if (L.isEnabled(L.TIDEPOOL))
log.debug("New status: $status") log.debug("New status: $status")
MainApp.bus().post(EventTidepoolStatus(status)) MainApp.bus().post(EventTidepoolStatus(status))

View file

@ -35,9 +35,9 @@ object UploadChunk {
operator fun get(start: Long, end: Long): String { operator fun get(start: Long, end: Long): String {
if (L.isEnabled(L.TIDEPOOL)) log.debug("Syncing data between: " + DateUtil.dateAndTimeFullString(start) + " -> " + DateUtil.dateAndTimeFullString(end)) if (L.isEnabled(L.TIDEPOOL)) log.debug("Syncing data between: " + DateUtil.dateAndTimeString(start) + " -> " + DateUtil.dateAndTimeString(end))
if (end <= start) { if (end <= start) {
if (L.isEnabled(L.TIDEPOOL)) log.debug("End is <= start: " + DateUtil.dateAndTimeFullString(start) + " " + DateUtil.dateAndTimeFullString(end)) if (L.isEnabled(L.TIDEPOOL)) log.debug("End is <= start: " + DateUtil.dateAndTimeString(start) + " " + DateUtil.dateAndTimeString(end))
return "" return ""
} }
if (end - start > MAX_UPLOAD_SIZE) { if (end - start > MAX_UPLOAD_SIZE) {
@ -64,9 +64,11 @@ object UploadChunk {
fun setLastEnd(time: Long) { fun setLastEnd(time: Long) {
if (time > getLastEnd()) { if (time > getLastEnd()) {
SP.putLong(R.string.key_tidepool_last_end, time) SP.putLong(R.string.key_tidepool_last_end, time)
if (L.isEnabled(L.TIDEPOOL)) log.debug("Updating last end to: " + DateUtil.dateAndTimeFullString(time)) val friendlyEnd = DateUtil.dateAndTimeString(time)
TidepoolUploader.status("Marking uploaded data up to $friendlyEnd")
if (L.isEnabled(L.TIDEPOOL)) log.debug("Updating last end to: " + DateUtil.dateAndTimeString(time))
} else { } else {
if (L.isEnabled(L.TIDEPOOL)) log.debug("Cannot set last end to: " + DateUtil.dateAndTimeFullString(time) + " vs " + DateUtil.dateAndTimeFullString(getLastEnd())) if (L.isEnabled(L.TIDEPOOL)) log.debug("Cannot set last end to: " + DateUtil.dateAndTimeString(time) + " vs " + DateUtil.dateAndTimeString(getLastEnd()))
} }
} }

View file

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -10,49 +9,62 @@
android:id="@+id/tidepool_status" android:id="@+id/tidepool_status"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="1dp"
android:layout_marginTop="32dp"
android:text="-" android:text="-"
tools:layout_editor_absoluteX="1dp" app:layout_constraintStart_toStartOf="parent"
tools:layout_editor_absoluteY="32dp" /> app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/tidepool_uploadnow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Upload now"
app:layout_constraintStart_toEndOf="@+id/tidepool_login"
tools:layout_editor_absoluteY="66dp" />
<Button
android:id="@+id/tidepool_removeall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Remove all"
app:layout_constraintStart_toEndOf="@+id/tidepool_uploadnow"
tools:layout_editor_absoluteY="66dp" />
<TextView
android:id="@+id/tidepool_log"
android:layout_width="0dp"
android:layout_height="0dp"
android:text="-- logs --"
tools:layout_editor_absoluteX="1dp"
tools:layout_editor_absoluteY="128dp" />
<Button <Button
android:id="@+id/tidepool_login" android:id="@+id/tidepool_login"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="1dp" android:layout_marginTop="8dp"
android:text="Login" android:text="Login"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
tools:layout_editor_absoluteY="66dp" /> app:layout_constraintTop_toBottomOf="@+id/tidepool_status" />
<Button
android:id="@+id/tidepool_uploadnow"
android:layout_width="113dp"
android:layout_height="50dp"
android:layout_marginTop="8dp"
android:text="Upload now"
app:layout_constraintStart_toEndOf="@+id/tidepool_login"
app:layout_constraintTop_toBottomOf="@+id/tidepool_status" />
<Button
android:id="@+id/tidepool_removeall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:layout_marginTop="8dp"
android:text="Remove all"
app:layout_constraintStart_toEndOf="@+id/tidepool_uploadnow"
app:layout_constraintTop_toBottomOf="@+id/tidepool_status" />
<Button <Button
android:id="@+id/tidepool_resertstart" android:id="@+id/tidepool_resertstart"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="308dp" android:layout_marginStart="4dp"
android:layout_marginTop="8dp"
android:text="Reset start" android:text="Reset start"
app:layout_constraintStart_toEndOf="@+id/tidepool_removeall"
app:layout_constraintTop_toBottomOf="@+id/tidepool_status" />
<TextView
android:id="@+id/tidepool_log"
android:layout_width="395dp"
android:layout_height="608dp"
android:layout_marginTop="14dp"
android:layout_marginBottom="603dp"
android:text="-- logs --"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
tools:layout_editor_absoluteY="66dp" /> app:layout_constraintTop_toBottomOf="@+id/tidepool_login"
app:layout_constraintVertical_bias="0.023" />
</android.support.constraint.ConstraintLayout> </android.support.constraint.ConstraintLayout>