diff --git a/app/build.gradle b/app/build.gradle index 5412be7fa1..a75c70b9ce 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -313,6 +313,9 @@ dependencies { implementation "com.squareup.retrofit2:adapter-rxjava2:2.6.2" implementation "com.squareup.retrofit2:converter-gson:2.6.2" + // Phone checker + implementation 'com.scottyab:rootbeer-lib:0.0.7' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0-alpha03' androidTestImplementation 'androidx.test.ext:junit:1.1.1' androidTestImplementation 'androidx.test:rules:1.3.0-alpha03' diff --git a/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java b/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java index 592cb6416e..67d1ab3609 100644 --- a/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java +++ b/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java @@ -1403,7 +1403,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { QueryBuilder queryBuilder = getDaoCareportalEvents().queryBuilder(); queryBuilder.orderBy("date", ascending); Where where = queryBuilder.where(); - where.ge("date", mills).and().isNotNull("json"); + where.ge("date", mills).and().isNotNull("json").and().isNotNull("eventType"); PreparedQuery preparedQuery = queryBuilder.prepare(); careportalEvents = getDaoCareportalEvents().query(preparedQuery); preprocessOpenAPSOfflineEvents(careportalEvents); @@ -1420,7 +1420,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { QueryBuilder queryBuilder = getDaoCareportalEvents().queryBuilder(); queryBuilder.orderBy("date", ascending); Where where = queryBuilder.where(); - where.between("date", start, end); + where.between("date", start, end).and().isNotNull("json").and().isNotNull("eventType"); PreparedQuery preparedQuery = queryBuilder.prepare(); careportalEvents = getDaoCareportalEvents().query(preparedQuery); preprocessOpenAPSOfflineEvents(careportalEvents); @@ -1447,7 +1447,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { QueryBuilder queryBuilder = getDaoCareportalEvents().queryBuilder(); queryBuilder.orderBy("date", ascending); Where where = queryBuilder.where(); - where.ge("date", mills).and().eq("eventType", type); + where.ge("date", mills).and().eq("eventType", type).and().isNotNull("json"); PreparedQuery preparedQuery = queryBuilder.prepare(); careportalEvents = getDaoCareportalEvents().query(preparedQuery); preprocessOpenAPSOfflineEvents(careportalEvents); @@ -1463,6 +1463,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { List careportalEvents; QueryBuilder queryBuilder = getDaoCareportalEvents().queryBuilder(); queryBuilder.orderBy("date", ascending); + Where where = queryBuilder.where(); + where.isNotNull("json").and().isNotNull("eventType"); PreparedQuery preparedQuery = queryBuilder.prepare(); careportalEvents = getDaoCareportalEvents().query(preparedQuery); preprocessOpenAPSOfflineEvents(careportalEvents); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/phoneChecker/PhoneCheckerPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/phoneChecker/PhoneCheckerPlugin.kt new file mode 100644 index 0000000000..0acdbce7e5 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/phoneChecker/PhoneCheckerPlugin.kt @@ -0,0 +1,45 @@ +package info.nightscout.androidaps.plugins.constraints.phoneChecker + +import android.content.Context +import android.os.Build +import com.scottyab.rootbeer.RootBeer +import info.nightscout.androidaps.R +import info.nightscout.androidaps.interfaces.ConstraintsInterface +import info.nightscout.androidaps.interfaces.PluginBase +import info.nightscout.androidaps.interfaces.PluginDescription +import info.nightscout.androidaps.interfaces.PluginType +import info.nightscout.androidaps.logging.AAPSLogger +import info.nightscout.androidaps.utils.resources.ResourceHelper +import javax.inject.Inject +import javax.inject.Singleton + +@Singleton +class PhoneCheckerPlugin @Inject constructor( + aapsLogger: AAPSLogger, + resourceHelper: ResourceHelper, + private val context: Context +) : PluginBase(PluginDescription() + .mainType(PluginType.CONSTRAINTS) + .neverVisible(true) + .alwaysEnabled(true) + .showInList(false) + .pluginName(R.string.phonechecker), + aapsLogger, resourceHelper +), ConstraintsInterface { + + var phoneRooted: Boolean = false + var devMode: Boolean = false + val phoneModel: String = Build.MODEL + val manufacturer: String = Build.MANUFACTURER + + private fun isDevModeEnabled(): Boolean { + return android.provider.Settings.Secure.getInt(context.contentResolver, + android.provider.Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0) != 0; + } + + override fun onStart() { + super.onStart() + phoneRooted = RootBeer(context).isRootedWithoutBusyBoxCheck() + devMode = isDevModeEnabled() + } +} \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/safety/SafetyPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/safety/SafetyPlugin.java index d942e6c78f..586a12fefb 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/safety/SafetyPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/safety/SafetyPlugin.java @@ -83,7 +83,7 @@ public class SafetyPlugin extends PluginBase implements ConstraintsInterface { } value.set(false, resourceHelper.gs(R.string.closed_loop_disabled_on_dev_branch), this); } - PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump(); + PumpInterface pump = activePlugin.getActivePumpPlugin(); if (pump != null && !pump.isFakingTempsByExtendedBoluses() && TreatmentsPlugin.getPlugin().isInHistoryExtendedBoluslInProgress()) { value.set(false, MainApp.gs(R.string.closed_loop_disabled_with_eb), this); } 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 0110d95cd0..9e7e483954 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 @@ -1195,23 +1195,19 @@ public class OverviewFragment extends DaggerFragment implements View.OnClickList final ExtendedBolus extendedBolus = treatmentsPlugin.getExtendedBolusFromHistory(System.currentTimeMillis()); String extendedBolusText = ""; if (extendedBolusView != null) { // must not exists in all layouts - if (shorttextmode) { - if (extendedBolus != null && !pump.isFakingTempsByExtendedBoluses()) { - extendedBolusText = DecimalFormatter.to2Decimal(extendedBolus.absoluteRate()) + "U/h"; - } - } else { - if (extendedBolus != null && !pump.isFakingTempsByExtendedBoluses()) { - extendedBolusText = extendedBolus.toStringMedium(); - } - } + if (extendedBolus != null && !pump.isFakingTempsByExtendedBoluses()) + extendedBolusText = shorttextmode ? DecimalFormatter.to2Decimal(extendedBolus.absoluteRate()) + "U/h" : extendedBolus.toStringMedium(); extendedBolusView.setText(extendedBolusText); - extendedBolusView.setOnClickListener(v -> OKDialog.show(getActivity(), resourceHelper.gs(R.string.extended_bolus), extendedBolus.toString())); - if (extendedBolusText.equals("")) { - extendedBolusLayout.setVisibility(View.GONE); - if (extendedBolusLayout != null) extendedBolusView.setVisibility(Config.NSCLIENT ? View.INVISIBLE : View.GONE); - } else { - extendedBolusView.setVisibility(View.VISIBLE); - if (extendedBolusLayout != null) extendedBolusLayout.setVisibility(View.VISIBLE); + extendedBolusView.setOnClickListener(v -> { + 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); } } diff --git a/app/src/main/res/layout/overview_fragment.xml b/app/src/main/res/layout/overview_fragment.xml index eb25059db2..223291a35c 100644 --- a/app/src/main/res/layout/overview_fragment.xml +++ b/app/src/main/res/layout/overview_fragment.xml @@ -107,11 +107,10 @@ @@ -175,10 +174,16 @@ + + @@ -190,7 +195,6 @@ @@ -208,7 +212,7 @@ android:layout_marginStart="14dp" android:text="" android:textSize="16sp" - android:textStyle="bold"/> + android:textStyle="bold" /> @@ -237,7 +240,7 @@ android:layout_marginStart="8dp" android:text="" android:textSize="16sp" - android:textStyle="bold"/> + android:textStyle="bold" /> @@ -249,7 +252,6 @@ @@ -267,7 +269,7 @@ android:layout_marginStart="10dp" android:text="0.50U/h @17:35 1/30min - 0.40U/h" android:textSize="16sp" - android:textStyle="bold"/> + android:textStyle="bold" /> @@ -297,7 +298,7 @@ android:layout_marginStart="10dp" android:text="0.50U/h @17:35 1/30min - 0.40U/h" android:textSize="16sp" - android:textStyle="bold"/> + android:textStyle="bold" /> @@ -309,7 +310,6 @@ @@ -327,10 +327,15 @@ android:layout_marginStart="20dp" android:text="" android:textSize="16sp" - android:textStyle="bold"/> + android:textStyle="bold" /> + + @@ -143,7 +140,6 @@ @@ -155,7 +151,6 @@ android:layout_marginStart="6dp" android:layout_marginTop="-2dp" android:paddingStart="2dp" - android:layout_weight="0.5" android:textSize="14sp" /> + android:textSize="12sp" /> @@ -193,7 +187,6 @@ @@ -211,7 +204,7 @@ android:layout_marginStart="12dp" android:text="" android:textSize="14sp" - android:textStyle="bold"/> + android:textStyle="bold" /> @@ -240,7 +232,7 @@ android:layout_marginStart="4dp" android:text="" android:textSize="14sp" - android:textStyle="bold"/> + android:textStyle="bold" /> @@ -252,7 +244,6 @@ @@ -270,7 +261,7 @@ android:layout_marginStart="6dp" android:text="0.50U/h @17:35 1/30min - 0.40U/h" android:textSize="14sp" - android:textStyle="bold"/> + android:textStyle="bold" /> @@ -300,7 +290,7 @@ android:layout_marginStart="6dp" android:text="0.50U/h @17:35 1/30min - 0.40U/h" android:textSize="14sp" - android:textStyle="bold"/> + android:textStyle="bold" /> @@ -329,10 +318,15 @@ android:layout_marginStart="18dp" android:text="" android:textSize="14sp" - android:textStyle="bold"/> + android:textStyle="bold" /> + + Use of Extended bolus feature will stop closed loop mode for the time of running extended bolus. Do you really want it? Closed loop disabled because of running Extended bolus EB + \"PhoneChecker\"