From 75fad1b18e88a86f78be1fda81537b163a9143bc Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sat, 25 Jan 2020 21:31:13 +0100 Subject: [PATCH] convert layouts to Constraint --- .../general/overview/OverviewFragment.java | 63 +- .../careportal_stats_fragment_short.xml | 106 -- app/src/main/res/layout/overview_fragment.xml | 1096 +++++++++-------- .../res/layout/overview_fragment_nsclient.xml | 1075 ++++++++-------- .../overview_fragment_nsclient_tablet.xml | 58 +- .../layout/overview_fragment_smallheight.xml | 565 --------- app/src/main/res/values/strings.xml | 2 + 7 files changed, 1186 insertions(+), 1779 deletions(-) delete mode 100644 app/src/main/res/layout/careportal_stats_fragment_short.xml delete mode 100644 app/src/main/res/layout/overview_fragment_smallheight.xml diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.java index 9bffc90892..dcce040759 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.java @@ -25,6 +25,7 @@ import android.widget.LinearLayout; import android.widget.TextView; import androidx.appcompat.widget.PopupMenu; +import androidx.constraintlayout.widget.ConstraintLayout; import androidx.core.content.res.ResourcesCompat; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentActivity; @@ -118,6 +119,7 @@ import info.nightscout.androidaps.utils.T; import info.nightscout.androidaps.utils.ToastUtils; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.disposables.CompositeDisposable; +import io.reactivex.schedulers.Schedulers; import static info.nightscout.androidaps.utils.DateUtil.now; @@ -137,7 +139,6 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, TextView avgdeltaView; TextView baseBasalView; TextView extendedBolusView; - LinearLayout extendedBolusLayout; TextView activeProfileView; TextView iobView; TextView cobView; @@ -148,7 +149,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, TextView openapsDeviceStatusView; TextView uploaderDeviceStatusView; TextView iobCalculationProgressView; - LinearLayout loopStatusLayout; + ConstraintLayout loopStatusLayout; LinearLayout pumpStatusLayout; GraphView bgGraph; GraphView iobGraph; @@ -169,7 +170,6 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, RecyclerView notificationsView; LinearLayoutManager llm; - LinearLayout acceptTempLayout; SingleClickButton acceptTempButton; SingleClickButton treatmentButton; @@ -221,8 +221,8 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, } else if (Config.NSCLIENT) { view = inflater.inflate(R.layout.overview_fragment_nsclient, container, false); shorttextmode = true; - } else if (smallHeight || landscape) { - view = inflater.inflate(R.layout.overview_fragment_smallheight, container, false); + } else if (smallHeight || landscape) { // now testing the same layout for small displays as well + view = inflater.inflate(R.layout.overview_fragment, container, false); } else { view = inflater.inflate(R.layout.overview_fragment, container, false); } @@ -241,14 +241,13 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, avgdeltaView = (TextView) view.findViewById(R.id.overview_avgdelta); baseBasalView = (TextView) view.findViewById(R.id.overview_basebasal); extendedBolusView = (TextView) view.findViewById(R.id.overview_extendedbolus); - extendedBolusLayout = view.findViewById(R.id.overview_extendedbolus_layout); activeProfileView = (TextView) view.findViewById(R.id.overview_activeprofile); pumpStatusView = (TextView) view.findViewById(R.id.overview_pumpstatus); pumpDeviceStatusView = (TextView) view.findViewById(R.id.overview_pump); openapsDeviceStatusView = (TextView) view.findViewById(R.id.overview_openaps); uploaderDeviceStatusView = (TextView) view.findViewById(R.id.overview_uploader); iobCalculationProgressView = (TextView) view.findViewById(R.id.overview_iobcalculationprogess); - loopStatusLayout = (LinearLayout) view.findViewById(R.id.overview_looplayout); + loopStatusLayout = view.findViewById(R.id.overview_looplayout); pumpStatusLayout = (LinearLayout) view.findViewById(R.id.overview_pumpstatuslayout); pumpStatusView.setBackgroundColor(MainApp.gc(R.color.colorInitializingBorder)); @@ -296,8 +295,6 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, if (cgmButton != null) cgmButton.setOnClickListener(this); - acceptTempLayout = (LinearLayout) view.findViewById(R.id.overview_accepttemplayout); - notificationsView = (RecyclerView) view.findViewById(R.id.overview_notifications); notificationsView.setHasFixedSize(false); llm = new LinearLayoutManager(view.getContext()); @@ -358,80 +355,80 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, super.onResume(); disposable.add(RxBus.INSTANCE .toObservable(EventRefreshOverview.class) - .observeOn(AndroidSchedulers.mainThread()) + .observeOn(Schedulers.io()) .subscribe(eventOpenAPSUpdateGui -> scheduleUpdateGUI(eventOpenAPSUpdateGui.getFrom()), FabricPrivacy::logException )); disposable.add(RxBus.INSTANCE .toObservable(EventExtendedBolusChange.class) - .observeOn(AndroidSchedulers.mainThread()) + .observeOn(Schedulers.io()) .subscribe(event -> scheduleUpdateGUI("EventExtendedBolusChange"), FabricPrivacy::logException )); disposable.add(RxBus.INSTANCE .toObservable(EventTempBasalChange.class) - .observeOn(AndroidSchedulers.mainThread()) + .observeOn(Schedulers.io()) .subscribe(event -> scheduleUpdateGUI("EventTempBasalChange"), FabricPrivacy::logException )); disposable.add(RxBus.INSTANCE .toObservable(EventTreatmentChange.class) - .observeOn(AndroidSchedulers.mainThread()) + .observeOn(Schedulers.io()) .subscribe(event -> scheduleUpdateGUI("EventTreatmentChange"), FabricPrivacy::logException )); disposable.add(RxBus.INSTANCE .toObservable(EventTempTargetChange.class) - .observeOn(AndroidSchedulers.mainThread()) + .observeOn(Schedulers.io()) .subscribe(event -> scheduleUpdateGUI("EventTempTargetChange"), FabricPrivacy::logException )); disposable.add(RxBus.INSTANCE .toObservable(EventAcceptOpenLoopChange.class) - .observeOn(AndroidSchedulers.mainThread()) + .observeOn(Schedulers.io()) .subscribe(event -> scheduleUpdateGUI("EventAcceptOpenLoopChange"), FabricPrivacy::logException )); disposable.add(RxBus.INSTANCE .toObservable(EventCareportalEventChange.class) - .observeOn(AndroidSchedulers.mainThread()) + .observeOn(Schedulers.io()) .subscribe(event -> scheduleUpdateGUI("EventCareportalEventChange"), FabricPrivacy::logException )); disposable.add(RxBus.INSTANCE .toObservable(EventInitializationChanged.class) - .observeOn(AndroidSchedulers.mainThread()) + .observeOn(Schedulers.io()) .subscribe(event -> scheduleUpdateGUI("EventInitializationChanged"), FabricPrivacy::logException )); disposable.add(RxBus.INSTANCE .toObservable(EventAutosensCalculationFinished.class) - .observeOn(AndroidSchedulers.mainThread()) + .observeOn(Schedulers.io()) .subscribe(event -> scheduleUpdateGUI("EventAutosensCalculationFinished"), FabricPrivacy::logException )); disposable.add(RxBus.INSTANCE .toObservable(EventProfileNeedsUpdate.class) - .observeOn(AndroidSchedulers.mainThread()) + .observeOn(Schedulers.io()) .subscribe(event -> scheduleUpdateGUI("EventProfileNeedsUpdate"), FabricPrivacy::logException )); disposable.add(RxBus.INSTANCE .toObservable(EventPreferenceChange.class) - .observeOn(AndroidSchedulers.mainThread()) + .observeOn(Schedulers.io()) .subscribe(event -> scheduleUpdateGUI("EventPreferenceChange"), FabricPrivacy::logException )); disposable.add(RxBus.INSTANCE .toObservable(EventNewOpenLoopNotification.class) - .observeOn(AndroidSchedulers.mainThread()) + .observeOn(Schedulers.io()) .subscribe(event -> scheduleUpdateGUI("EventNewOpenLoopNotification"), FabricPrivacy::logException )); disposable.add(RxBus.INSTANCE .toObservable(EventPumpStatusChanged.class) .observeOn(AndroidSchedulers.mainThread()) - .subscribe(event -> updatePumpStatus(event.getStatus()), + .subscribe(event -> updatePumpStatus(event), FabricPrivacy::logException )); disposable.add(RxBus.INSTANCE @@ -946,8 +943,8 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, Activity activity = getActivity(); if (activity != null) activity.runOnUiThread(() -> { - if (acceptTempLayout != null) - acceptTempLayout.setVisibility(View.GONE); + if (acceptTempButton != null) + acceptTempButton.setVisibility(View.GONE); }); } @@ -959,7 +956,8 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, ActionStringHandler.handleInitiate("cancelChangeRequest"); } - private void updatePumpStatus(String status) { + private void updatePumpStatus(EventPumpStatusChanged event) { + String status = event.getStatus(); if (!status.equals("")) { pumpStatusView.setText(status); pumpStatusLayout.setVisibility(View.VISIBLE); @@ -1104,27 +1102,25 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, if (tempTarget != null) { tempTargetView.setTextColor(MainApp.gc(R.color.ribbonTextWarning)); tempTargetView.setBackgroundColor(MainApp.gc(R.color.ribbonWarning)); - tempTargetView.setVisibility(View.VISIBLE); tempTargetView.setText(Profile.toTargetRangeString(tempTarget.low, tempTarget.high, Constants.MGDL, units) + " " + DateUtil.untilString(tempTarget.end())); } else { tempTargetView.setTextColor(MainApp.gc(R.color.ribbonTextDefault)); tempTargetView.setBackgroundColor(MainApp.gc(R.color.ribbonDefault)); tempTargetView.setText(Profile.toTargetRangeString(profile.getTargetLowMgdl(), profile.getTargetHighMgdl(), Constants.MGDL, units)); - tempTargetView.setVisibility(View.VISIBLE); } // **** Temp button **** - if (acceptTempLayout != null) { + if (acceptTempButton != null) { boolean showAcceptButton = !closedLoopEnabled.value(); // Open mode needed showAcceptButton = showAcceptButton && finalLastRun != null && finalLastRun.lastAPSRun != null; // aps result must exist showAcceptButton = showAcceptButton && (finalLastRun.lastOpenModeAccept == null || finalLastRun.lastOpenModeAccept.getTime() < finalLastRun.lastAPSRun.getTime()); // never accepted or before last result showAcceptButton = showAcceptButton && finalLastRun.constraintsProcessed.isChangeRequested(); // change is requested if (showAcceptButton && pump.isInitialized() && !pump.isSuspended() && LoopPlugin.getPlugin().isEnabled(PluginType.LOOP)) { - acceptTempLayout.setVisibility(View.VISIBLE); + acceptTempButton.setVisibility(View.VISIBLE); acceptTempButton.setText(MainApp.gs(R.string.setbasalquestion) + "\n" + finalLastRun.constraintsProcessed); } else { - acceptTempLayout.setVisibility(View.GONE); + acceptTempButton.setVisibility(View.GONE); } } @@ -1190,13 +1186,6 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, if (extendedBolus != null) OKDialog.show(getActivity(), MainApp.gs(R.string.extended_bolus), extendedBolus.toString()); }); - // hide whole line for APS mode - if (extendedBolusLayout != null) { - if (extendedBolusText.equals("")) - extendedBolusLayout.setVisibility(View.GONE); - else - extendedBolusLayout.setVisibility(View.VISIBLE); - } } activeProfileView.setText(ProfileFunctions.getInstance().getProfileNameWithDuration()); diff --git a/app/src/main/res/layout/careportal_stats_fragment_short.xml b/app/src/main/res/layout/careportal_stats_fragment_short.xml deleted file mode 100644 index 4fc42d4d68..0000000000 --- a/app/src/main/res/layout/careportal_stats_fragment_short.xml +++ /dev/null @@ -1,106 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/overview_fragment.xml b/app/src/main/res/layout/overview_fragment.xml index 223291a35c..eaaef99ebe 100644 --- a/app/src/main/res/layout/overview_fragment.xml +++ b/app/src/main/res/layout/overview_fragment.xml @@ -1,575 +1,583 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + app:layout_constraintBottom_toTopOf="@+id/bg_tbr_layout" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/overview_looplayout"> - + android:layout_marginLeft="5dp" + android:layout_marginRight="5dp" + android:gravity="center_vertical|center_horizontal" + android:paddingTop="3dp" + android:paddingBottom="3dp" + android:text="@string/initializing" + android:textAppearance="?android:attr/textAppearanceSmall" /> + - + app:layout_constraintBottom_toTopOf="@+id/overview_statuslights" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/overview_pumpstatuslayout"> - + - + - + - - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/overview_fragment_nsclient.xml b/app/src/main/res/layout/overview_fragment_nsclient.xml index 2bb210d78a..4b834e08d6 100644 --- a/app/src/main/res/layout/overview_fragment_nsclient.xml +++ b/app/src/main/res/layout/overview_fragment_nsclient.xml @@ -1,580 +1,651 @@ - + - - + android:id="@+id/overview_toppart_scrollbar" + android:layout_width="0dp" + android:layout_height="0dp" + app:layout_constraintBottom_toTopOf="@id/overview_buttons_layout" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent"> - + android:layout_width="0dp" + android:layout_height="0dp" + app:layout_constraintBottom_toTopOf="@+id/overview_looplayout" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent"> - + app:layout_constraintBottom_toTopOf="@+id/overview_pumpstatuslayout" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/overview_notifications"> + android:paddingBottom="3dp" + android:text="@string/openloop" + android:textAppearance="?android:attr/textAppearanceSmall" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toStartOf="@+id/overview_activeprofile" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" /> + android:paddingBottom="3dp" + android:text="@string/profile" + android:textAppearance="?android:attr/textAppearanceSmall" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toStartOf="@+id/overview_temptarget" + app:layout_constraintStart_toEndOf="@+id/overview_apsmode" + app:layout_constraintTop_toTopOf="parent" /> + android:textColor="@color/mdtp_white" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toEndOf="@+id/overview_activeprofile" + app:layout_constraintTop_toTopOf="parent" /> - + + app:layout_constraintBottom_toTopOf="@+id/bg_tbr_layout" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/overview_looplayout"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + android:orientation="horizontal" + app:layout_constraintBottom_toTopOf="@+id/overview_statuslights_nscl" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/overview_pumpstatuslayout"> - + android:layout_height="wrap_content" + android:text="00.0" + android:textSize="42sp" + android:textStyle="bold" + app:layout_constraintEnd_toStartOf="@+id/overview_arrow" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" /> - - - - - - - - - + android:layout_height="wrap_content" + android:layout_marginTop="5dp" + android:paddingStart="-2dp" + android:paddingEnd="0dp" + android:text="→" + android:textSize="28sp" + android:textStyle="bold" + app:layout_constraintEnd_toStartOf="@+id/overview_bg_guideline" + app:layout_constraintStart_toEndOf="@+id/overview_bg" + app:layout_constraintTop_toTopOf="@+id/overview_bg" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + android:orientation="horizontal" + android:paddingStart="0dp" + android:paddingEnd="5dp" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@id/overview_toppart_scrollbar"> - + - + - + - + - + - - + - - - + + + + + diff --git a/app/src/main/res/layout/overview_fragment_nsclient_tablet.xml b/app/src/main/res/layout/overview_fragment_nsclient_tablet.xml index 6dd854c0a6..07f3324f4b 100644 --- a/app/src/main/res/layout/overview_fragment_nsclient_tablet.xml +++ b/app/src/main/res/layout/overview_fragment_nsclient_tablet.xml @@ -27,54 +27,62 @@ - + app:layout_constraintBottom_toTopOf="@+id/overview_pumpstatuslayout" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/overview_notifications"> + android:paddingBottom="3dp" + android:text="@string/openloop" + android:textAppearance="?android:attr/textAppearanceSmall" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toStartOf="@+id/overview_activeprofile" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" /> + android:paddingBottom="3dp" + android:text="@string/profile" + android:textAppearance="?android:attr/textAppearanceSmall" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toStartOf="@+id/overview_temptarget" + app:layout_constraintStart_toEndOf="@+id/overview_apsmode" + app:layout_constraintTop_toTopOf="parent" /> + android:textColor="@color/mdtp_white" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toEndOf="@+id/overview_activeprofile" + app:layout_constraintTop_toTopOf="parent" /> - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 9bd5ae7254..16783a882b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1691,5 +1691,7 @@ Closed loop disabled because of running Extended bolus EB \"PhoneChecker\" + Chart menu + AS