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: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'

View file

@ -1403,7 +1403,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
QueryBuilder<CareportalEvent, Long> 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<CareportalEvent> preparedQuery = queryBuilder.prepare();
careportalEvents = getDaoCareportalEvents().query(preparedQuery);
preprocessOpenAPSOfflineEvents(careportalEvents);
@ -1420,7 +1420,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
QueryBuilder<CareportalEvent, Long> 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<CareportalEvent> preparedQuery = queryBuilder.prepare();
careportalEvents = getDaoCareportalEvents().query(preparedQuery);
preprocessOpenAPSOfflineEvents(careportalEvents);
@ -1447,7 +1447,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
QueryBuilder<CareportalEvent, Long> 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<CareportalEvent> preparedQuery = queryBuilder.prepare();
careportalEvents = getDaoCareportalEvents().query(preparedQuery);
preprocessOpenAPSOfflineEvents(careportalEvents);
@ -1463,6 +1463,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
List<CareportalEvent> careportalEvents;
QueryBuilder<CareportalEvent, Long> queryBuilder = getDaoCareportalEvents().queryBuilder();
queryBuilder.orderBy("date", ascending);
Where where = queryBuilder.where();
where.isNotNull("json").and().isNotNull("eventType");
PreparedQuery<CareportalEvent> preparedQuery = queryBuilder.prepare();
careportalEvents = getDaoCareportalEvents().query(preparedQuery);
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);
}
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);
}

View file

@ -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("")) {
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);
if (extendedBolusLayout != null) extendedBolusView.setVisibility(Config.NSCLIENT ? View.INVISIBLE : View.GONE);
} else {
extendedBolusView.setVisibility(View.VISIBLE);
if (extendedBolusLayout != null) extendedBolusLayout.setVisibility(View.VISIBLE);
else
extendedBolusLayout.setVisibility(View.VISIBLE);
}
}

View file

@ -107,11 +107,10 @@
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
@ -175,10 +174,16 @@
</LinearLayout>
</LinearLayout>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"/>
<LinearLayout
android:layout_width="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:orientation="vertical">
@ -190,7 +195,6 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginEnd="1dp"
android:text="@string/iob"
android:textSize="16sp" />
@ -219,7 +223,6 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginEnd="1dp"
android:text="@string/cob"
android:textSize="16sp" />
@ -249,7 +252,6 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginEnd="1dp"
android:text="@string/basal_short"
android:textSize="16sp" />
@ -279,7 +281,6 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginEnd="1dp"
android:text="@string/extended_bolus_short"
android:textSize="16sp" />
@ -309,7 +310,6 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginEnd="1dp"
android:text="AS"
android:textSize="16sp" />
@ -331,6 +331,11 @@
</LinearLayout>
</LinearLayout>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"/>
</LinearLayout>
<LinearLayout

View file

@ -97,21 +97,18 @@
</LinearLayout>
<LinearLayout
android:baselineAligned="false"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:layout_weight="0"
android:baselineAligned="false"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
@ -143,7 +140,6 @@
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginTop="2dp"
android:layout_marginBottom="10dp"
android:orientation="vertical">
@ -155,7 +151,6 @@
android:layout_marginStart="6dp"
android:layout_marginTop="-2dp"
android:paddingStart="2dp"
android:layout_weight="0.5"
android:textSize="14sp" />
<TextView
@ -164,8 +159,8 @@
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="-2dp"
android:paddingStart="2dp"
android:layout_weight="0.5"
android:paddingStart="2dp"
android:textSize="12sp" />
<TextView
@ -173,15 +168,14 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_weight="0.5"
android:textSize="12sp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="2"
android:layout_marginLeft="5dp"
android:layout_marginTop="6dp"
android:orientation="vertical">
@ -193,7 +187,6 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="18dp"
android:layout_marginEnd="1dp"
android:text="@string/iob"
android:textSize="14sp" />
@ -222,7 +215,6 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="18dp"
android:layout_marginEnd="1dp"
android:text="@string/cob"
android:textSize="16sp" />
@ -252,7 +244,6 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="18dp"
android:layout_marginEnd="1dp"
android:text="@string/basal_short"
android:textSize="14sp" />
@ -282,7 +273,6 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="18dp"
android:layout_marginEnd="1dp"
android:text="@string/extended_bolus_short"
android:textSize="14sp" />
@ -311,7 +301,6 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="18dp"
android:layout_marginEnd="1dp"
android:text="AS"
android:textSize="14sp" />
@ -333,6 +322,11 @@
</LinearLayout>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"/>
</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="closed_loop_disabled_with_eb">Closed loop disabled because of running Extended bolus</string>
<string name="extended_bolus_short">EB</string>
<string name="phonechecker">\"PhoneChecker\"</string>
</resources>