Merge branch 'dev' into dagger3

This commit is contained in:
Milos Kozak 2020-01-15 20:47:08 +01:00
commit ab51cb4d01
8 changed files with 102 additions and 56 deletions

View file

@ -313,6 +313,9 @@ dependencies {
implementation "com.squareup.retrofit2:adapter-rxjava2:2.6.2" implementation "com.squareup.retrofit2:adapter-rxjava2:2.6.2"
implementation "com.squareup.retrofit2:converter-gson: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.espresso:espresso-core:3.3.0-alpha03'
androidTestImplementation 'androidx.test.ext:junit:1.1.1' androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test:rules:1.3.0-alpha03' androidTestImplementation 'androidx.test:rules:1.3.0-alpha03'

View file

@ -1403,7 +1403,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
QueryBuilder<CareportalEvent, Long> queryBuilder = getDaoCareportalEvents().queryBuilder(); QueryBuilder<CareportalEvent, Long> queryBuilder = getDaoCareportalEvents().queryBuilder();
queryBuilder.orderBy("date", ascending); queryBuilder.orderBy("date", ascending);
Where where = queryBuilder.where(); Where where = queryBuilder.where();
where.ge("date", mills).and().isNotNull("json"); where.ge("date", mills).and().isNotNull("json").and().isNotNull("eventType");
PreparedQuery<CareportalEvent> preparedQuery = queryBuilder.prepare(); PreparedQuery<CareportalEvent> preparedQuery = queryBuilder.prepare();
careportalEvents = getDaoCareportalEvents().query(preparedQuery); careportalEvents = getDaoCareportalEvents().query(preparedQuery);
preprocessOpenAPSOfflineEvents(careportalEvents); preprocessOpenAPSOfflineEvents(careportalEvents);
@ -1420,7 +1420,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
QueryBuilder<CareportalEvent, Long> queryBuilder = getDaoCareportalEvents().queryBuilder(); QueryBuilder<CareportalEvent, Long> queryBuilder = getDaoCareportalEvents().queryBuilder();
queryBuilder.orderBy("date", ascending); queryBuilder.orderBy("date", ascending);
Where where = queryBuilder.where(); Where where = queryBuilder.where();
where.between("date", start, end); where.between("date", start, end).and().isNotNull("json").and().isNotNull("eventType");
PreparedQuery<CareportalEvent> preparedQuery = queryBuilder.prepare(); PreparedQuery<CareportalEvent> preparedQuery = queryBuilder.prepare();
careportalEvents = getDaoCareportalEvents().query(preparedQuery); careportalEvents = getDaoCareportalEvents().query(preparedQuery);
preprocessOpenAPSOfflineEvents(careportalEvents); preprocessOpenAPSOfflineEvents(careportalEvents);
@ -1447,7 +1447,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
QueryBuilder<CareportalEvent, Long> queryBuilder = getDaoCareportalEvents().queryBuilder(); QueryBuilder<CareportalEvent, Long> queryBuilder = getDaoCareportalEvents().queryBuilder();
queryBuilder.orderBy("date", ascending); queryBuilder.orderBy("date", ascending);
Where where = queryBuilder.where(); Where where = queryBuilder.where();
where.ge("date", mills).and().eq("eventType", type); where.ge("date", mills).and().eq("eventType", type).and().isNotNull("json");
PreparedQuery<CareportalEvent> preparedQuery = queryBuilder.prepare(); PreparedQuery<CareportalEvent> preparedQuery = queryBuilder.prepare();
careportalEvents = getDaoCareportalEvents().query(preparedQuery); careportalEvents = getDaoCareportalEvents().query(preparedQuery);
preprocessOpenAPSOfflineEvents(careportalEvents); preprocessOpenAPSOfflineEvents(careportalEvents);
@ -1463,6 +1463,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
List<CareportalEvent> careportalEvents; List<CareportalEvent> careportalEvents;
QueryBuilder<CareportalEvent, Long> queryBuilder = getDaoCareportalEvents().queryBuilder(); QueryBuilder<CareportalEvent, Long> queryBuilder = getDaoCareportalEvents().queryBuilder();
queryBuilder.orderBy("date", ascending); queryBuilder.orderBy("date", ascending);
Where where = queryBuilder.where();
where.isNotNull("json").and().isNotNull("eventType");
PreparedQuery<CareportalEvent> preparedQuery = queryBuilder.prepare(); PreparedQuery<CareportalEvent> preparedQuery = queryBuilder.prepare();
careportalEvents = getDaoCareportalEvents().query(preparedQuery); careportalEvents = getDaoCareportalEvents().query(preparedQuery);
preprocessOpenAPSOfflineEvents(careportalEvents); preprocessOpenAPSOfflineEvents(careportalEvents);

View file

@ -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()
}
}

View file

@ -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); 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()) { if (pump != null && !pump.isFakingTempsByExtendedBoluses() && TreatmentsPlugin.getPlugin().isInHistoryExtendedBoluslInProgress()) {
value.set(false, MainApp.gs(R.string.closed_loop_disabled_with_eb), this); value.set(false, MainApp.gs(R.string.closed_loop_disabled_with_eb), this);
} }

View file

@ -1195,23 +1195,19 @@ public class OverviewFragment extends DaggerFragment implements View.OnClickList
final ExtendedBolus extendedBolus = treatmentsPlugin.getExtendedBolusFromHistory(System.currentTimeMillis()); final ExtendedBolus extendedBolus = treatmentsPlugin.getExtendedBolusFromHistory(System.currentTimeMillis());
String extendedBolusText = ""; String extendedBolusText = "";
if (extendedBolusView != null) { // must not exists in all layouts if (extendedBolusView != null) { // must not exists in all layouts
if (shorttextmode) { if (extendedBolus != null && !pump.isFakingTempsByExtendedBoluses())
if (extendedBolus != null && !pump.isFakingTempsByExtendedBoluses()) { extendedBolusText = shorttextmode ? DecimalFormatter.to2Decimal(extendedBolus.absoluteRate()) + "U/h" : extendedBolus.toStringMedium();
extendedBolusText = DecimalFormatter.to2Decimal(extendedBolus.absoluteRate()) + "U/h";
}
} else {
if (extendedBolus != null && !pump.isFakingTempsByExtendedBoluses()) {
extendedBolusText = extendedBolus.toStringMedium();
}
}
extendedBolusView.setText(extendedBolusText); extendedBolusView.setText(extendedBolusText);
extendedBolusView.setOnClickListener(v -> OKDialog.show(getActivity(), resourceHelper.gs(R.string.extended_bolus), extendedBolus.toString())); extendedBolusView.setOnClickListener(v -> {
if (extendedBolusText.equals("")) { if (extendedBolus != null)
extendedBolusLayout.setVisibility(View.GONE); OKDialog.show(getActivity(), MainApp.gs(R.string.extended_bolus), extendedBolus.toString());
if (extendedBolusLayout != null) extendedBolusView.setVisibility(Config.NSCLIENT ? View.INVISIBLE : View.GONE); });
} else { // hide whole line for APS mode
extendedBolusView.setVisibility(View.VISIBLE); if (extendedBolusLayout != null) {
if (extendedBolusLayout != null) extendedBolusLayout.setVisibility(View.VISIBLE); if (extendedBolusText.equals(""))
extendedBolusLayout.setVisibility(View.GONE);
else
extendedBolusLayout.setVisibility(View.VISIBLE);
} }
} }

View file

@ -107,11 +107,10 @@
<LinearLayout <LinearLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal"> android:orientation="horizontal">
@ -175,10 +174,16 @@
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"/>
<LinearLayout <LinearLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_gravity="center_vertical"
android:layout_marginStart="5dp"
android:layout_marginTop="6dp" android:layout_marginTop="6dp"
android:orientation="vertical"> android:orientation="vertical">
@ -190,7 +195,6 @@
<TextView <TextView
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:layout_marginEnd="1dp" android:layout_marginEnd="1dp"
android:text="@string/iob" android:text="@string/iob"
android:textSize="16sp" /> android:textSize="16sp" />
@ -208,7 +212,7 @@
android:layout_marginStart="14dp" android:layout_marginStart="14dp"
android:text="" android:text=""
android:textSize="16sp" android:textSize="16sp"
android:textStyle="bold"/> android:textStyle="bold" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -219,7 +223,6 @@
<TextView <TextView
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:layout_marginEnd="1dp" android:layout_marginEnd="1dp"
android:text="@string/cob" android:text="@string/cob"
android:textSize="16sp" /> android:textSize="16sp" />
@ -237,7 +240,7 @@
android:layout_marginStart="8dp" android:layout_marginStart="8dp"
android:text="" android:text=""
android:textSize="16sp" android:textSize="16sp"
android:textStyle="bold"/> android:textStyle="bold" />
</LinearLayout> </LinearLayout>
@ -249,7 +252,6 @@
<TextView <TextView
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:layout_marginEnd="1dp" android:layout_marginEnd="1dp"
android:text="@string/basal_short" android:text="@string/basal_short"
android:textSize="16sp" /> android:textSize="16sp" />
@ -267,7 +269,7 @@
android:layout_marginStart="10dp" android:layout_marginStart="10dp"
android:text="0.50U/h @17:35 1/30min - 0.40U/h" android:text="0.50U/h @17:35 1/30min - 0.40U/h"
android:textSize="16sp" android:textSize="16sp"
android:textStyle="bold"/> android:textStyle="bold" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -279,7 +281,6 @@
<TextView <TextView
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:layout_marginEnd="1dp" android:layout_marginEnd="1dp"
android:text="@string/extended_bolus_short" android:text="@string/extended_bolus_short"
android:textSize="16sp" /> android:textSize="16sp" />
@ -297,7 +298,7 @@
android:layout_marginStart="10dp" android:layout_marginStart="10dp"
android:text="0.50U/h @17:35 1/30min - 0.40U/h" android:text="0.50U/h @17:35 1/30min - 0.40U/h"
android:textSize="16sp" android:textSize="16sp"
android:textStyle="bold"/> android:textStyle="bold" />
</LinearLayout> </LinearLayout>
@ -309,7 +310,6 @@
<TextView <TextView
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:layout_marginEnd="1dp" android:layout_marginEnd="1dp"
android:text="AS" android:text="AS"
android:textSize="16sp" /> android:textSize="16sp" />
@ -327,10 +327,15 @@
android:layout_marginStart="20dp" android:layout_marginStart="20dp"
android:text="" android:text=""
android:textSize="16sp" android:textSize="16sp"
android:textStyle="bold"/> android:textStyle="bold" />
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"/>
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout

View file

@ -97,21 +97,18 @@
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:baselineAligned="false"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center_horizontal" android:baselineAligned="false"
android:layout_weight="0"
android:orientation="horizontal"> android:orientation="horizontal">
<LinearLayout <LinearLayout
android:layout_width="0dp" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal"> android:orientation="horizontal">
@ -143,7 +140,6 @@
<LinearLayout <LinearLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginTop="2dp" android:layout_marginTop="2dp"
android:layout_marginBottom="10dp" android:layout_marginBottom="10dp"
android:orientation="vertical"> android:orientation="vertical">
@ -155,7 +151,6 @@
android:layout_marginStart="6dp" android:layout_marginStart="6dp"
android:layout_marginTop="-2dp" android:layout_marginTop="-2dp"
android:paddingStart="2dp" android:paddingStart="2dp"
android:layout_weight="0.5"
android:textSize="14sp" /> android:textSize="14sp" />
<TextView <TextView
@ -164,8 +159,8 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="8dp" android:layout_marginStart="8dp"
android:layout_marginTop="-2dp" android:layout_marginTop="-2dp"
android:paddingStart="2dp"
android:layout_weight="0.5" android:layout_weight="0.5"
android:paddingStart="2dp"
android:textSize="12sp" /> android:textSize="12sp" />
<TextView <TextView
@ -173,15 +168,14 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="10dp" android:layout_marginLeft="10dp"
android:layout_weight="0.5" android:textSize="12sp" />
android:textSize="12sp"/>
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:layout_width="0dp" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="2" android:layout_marginLeft="5dp"
android:layout_marginTop="6dp" android:layout_marginTop="6dp"
android:orientation="vertical"> android:orientation="vertical">
@ -193,7 +187,6 @@
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="18dp"
android:layout_marginEnd="1dp" android:layout_marginEnd="1dp"
android:text="@string/iob" android:text="@string/iob"
android:textSize="14sp" /> android:textSize="14sp" />
@ -211,7 +204,7 @@
android:layout_marginStart="12dp" android:layout_marginStart="12dp"
android:text="" android:text=""
android:textSize="14sp" android:textSize="14sp"
android:textStyle="bold"/> android:textStyle="bold" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -222,7 +215,6 @@
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="18dp"
android:layout_marginEnd="1dp" android:layout_marginEnd="1dp"
android:text="@string/cob" android:text="@string/cob"
android:textSize="16sp" /> android:textSize="16sp" />
@ -240,7 +232,7 @@
android:layout_marginStart="4dp" android:layout_marginStart="4dp"
android:text="" android:text=""
android:textSize="14sp" android:textSize="14sp"
android:textStyle="bold"/> android:textStyle="bold" />
</LinearLayout> </LinearLayout>
@ -252,7 +244,6 @@
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="18dp"
android:layout_marginEnd="1dp" android:layout_marginEnd="1dp"
android:text="@string/basal_short" android:text="@string/basal_short"
android:textSize="14sp" /> android:textSize="14sp" />
@ -270,7 +261,7 @@
android:layout_marginStart="6dp" android:layout_marginStart="6dp"
android:text="0.50U/h @17:35 1/30min - 0.40U/h" android:text="0.50U/h @17:35 1/30min - 0.40U/h"
android:textSize="14sp" android:textSize="14sp"
android:textStyle="bold"/> android:textStyle="bold" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -282,7 +273,6 @@
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="18dp"
android:layout_marginEnd="1dp" android:layout_marginEnd="1dp"
android:text="@string/extended_bolus_short" android:text="@string/extended_bolus_short"
android:textSize="14sp" /> android:textSize="14sp" />
@ -300,7 +290,7 @@
android:layout_marginStart="6dp" android:layout_marginStart="6dp"
android:text="0.50U/h @17:35 1/30min - 0.40U/h" android:text="0.50U/h @17:35 1/30min - 0.40U/h"
android:textSize="14sp" android:textSize="14sp"
android:textStyle="bold"/> android:textStyle="bold" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -311,7 +301,6 @@
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="18dp"
android:layout_marginEnd="1dp" android:layout_marginEnd="1dp"
android:text="AS" android:text="AS"
android:textSize="14sp" /> android:textSize="14sp" />
@ -329,10 +318,15 @@
android:layout_marginStart="18dp" android:layout_marginStart="18dp"
android:text="" android:text=""
android:textSize="14sp" android:textSize="14sp"
android:textStyle="bold"/> android:textStyle="bold" />
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"/>
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout

View file

@ -1691,5 +1691,6 @@
<string name="ebstopsloop">Use of Extended bolus feature will stop closed loop mode for the time of running extended bolus. Do you really want it?</string> <string name="ebstopsloop">Use of Extended bolus feature will stop closed loop mode for the time of running extended bolus. Do you really want it?</string>
<string name="closed_loop_disabled_with_eb">Closed loop disabled because of running Extended bolus</string> <string name="closed_loop_disabled_with_eb">Closed loop disabled because of running Extended bolus</string>
<string name="extended_bolus_short">EB</string> <string name="extended_bolus_short">EB</string>
<string name="phonechecker">\"PhoneChecker\"</string>
</resources> </resources>