This commit is contained in:
Milos Kozak 2021-10-15 13:24:22 +02:00
parent b10501e7b0
commit a963f140c6
11 changed files with 40 additions and 47 deletions

View file

@ -73,7 +73,7 @@ class MainApp : DaggerApplication() {
commitHash = null
}
disposable += repository.runTransaction(VersionChangeTransaction(BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE, gitRemote, commitHash)).subscribe()
disposable += repository.runTransaction(InsertIfNewByTimestampTherapyEventTransaction(timestamp = dateUtil.now(), type = TherapyEvent.Type.NOTE, note = getString(info.nightscout.androidaps.core.R.string.androidaps_start).toString() + " - " + Build.MANUFACTURER + " " + Build.MODEL, glucoseUnit = TherapyEvent.GlucoseUnit.MGDL)).subscribe()
disposable += repository.runTransaction(InsertIfNewByTimestampTherapyEventTransaction(timestamp = dateUtil.now(), type = TherapyEvent.Type.NOTE, note = getString(info.nightscout.androidaps.core.R.string.androidaps_start) + " - " + Build.MANUFACTURER + " " + Build.MODEL, glucoseUnit = TherapyEvent.GlucoseUnit.MGDL)).subscribe()
disposable += compatDBHelper.dbChangeDisposable()
registerActivityLifecycleCallbacks(activityMonitor)
JodaTimeAndroid.init(this)

View file

@ -58,7 +58,7 @@ class AndroidPermission @Inject constructor(
activity.callForBatteryOptimization.launch(null)
} catch (e: ActivityNotFoundException) {
permissionBatteryOptimizationFailed = true
OKDialog.show(activity, resourceHelper.gs(R.string.permission), resourceHelper.gs(R.string.alert_dialog_permission_battery_optimization_failed), Runnable { activity.recreate() })
OKDialog.show(activity, resourceHelper.gs(R.string.permission), resourceHelper.gs(R.string.alert_dialog_permission_battery_optimization_failed)) { activity.recreate() }
}
}
}

View file

@ -11,7 +11,7 @@ import javax.inject.Singleton
class Profiler @Inject constructor(val aapsLogger: AAPSLogger) {
fun log(lTag: LTag, function: String, start: Long) {
val msec = System.currentTimeMillis() - start
aapsLogger.debug(lTag, ">>> $function <<< executed in $msec miliseconds")
val milliseconds = System.currentTimeMillis() - start
aapsLogger.debug(lTag, ">>> $function <<< executed in $milliseconds milliseconds")
}
}

View file

@ -3,7 +3,7 @@ package info.nightscout.androidaps.utils
import android.app.backup.BackupAgentHelper
import android.app.backup.SharedPreferencesBackupHelper
@Suppress("LocalVariableName")
@Suppress("LocalVariableName", "unused")
class SPBackupAgent : BackupAgentHelper() {
override fun onCreate() {

View file

@ -15,7 +15,7 @@ import java.text.SimpleDateFormat
import java.util.*
import javax.inject.Inject
class XDripBroadcast @Inject constructor(
@Suppress("SpellCheckingInspection") class XDripBroadcast @Inject constructor(
private val context: Context,
private val aapsLogger: AAPSLogger,
private val sp: SP

View file

@ -17,10 +17,10 @@ import androidx.annotation.StringRes
import androidx.annotation.StyleRes
import androidx.appcompat.view.ContextThemeWrapper
import info.nightscout.androidaps.R
import info.nightscout.androidaps.extensions.runOnUiThread
import info.nightscout.androidaps.plugins.general.maintenance.formats.Prefs
import info.nightscout.androidaps.plugins.general.maintenance.formats.PrefsStatus
import info.nightscout.androidaps.utils.ToastUtils
import info.nightscout.androidaps.extensions.runOnUiThread
import java.util.*
object PrefImportSummaryDialog {
@ -83,17 +83,24 @@ object PrefImportSummaryDialog {
detailsBtn.visibility = View.VISIBLE
detailsBtn.setOnClickListener {
val detailsLayout = LayoutInflater.from(context).inflate(R.layout.import_summary_details, null)
val wview = detailsLayout.findViewById<View>(R.id.details_webview) as WebView
wview.loadData("<!doctype html><html><head><meta charset=\"utf-8\"><style>body { color: white; }</style></head><body>" + details.joinToString("<hr>"), "text/html; charset=utf-8", "utf-8")
wview.setBackgroundColor(Color.TRANSPARENT)
wview.setLayerType(WebView.LAYER_TYPE_SOFTWARE, null)
val webView = detailsLayout.findViewById<View>(R.id.details_webview) as WebView
webView.loadData(
"<!doctype html><html><head><meta charset=\"utf-8\"><style>body { color: white; }</style></head><body>" + details.joinToString("<hr>"),
"text/html; charset=utf-8",
"utf-8"
)
webView.setBackgroundColor(Color.TRANSPARENT)
webView.setLayerType(WebView.LAYER_TYPE_SOFTWARE, null)
AlertDialogHelper.Builder(context, R.style.AppTheme)
.setCustomTitle(AlertDialogHelper.buildCustomTitle(
.setCustomTitle(
AlertDialogHelper.buildCustomTitle(
context,
context.getString(R.string.check_preferences_details_title),
R.drawable.ic_header_log,
R.style.AppTheme))
R.style.AppTheme
)
)
.setView(detailsLayout)
.setPositiveButton(android.R.string.ok) { dialogInner: DialogInterface, _: Int ->
dialogInner.dismiss()
@ -110,11 +117,7 @@ object PrefImportSummaryDialog {
.setNegativeButton(android.R.string.cancel) { dialog: DialogInterface, _: Int ->
dialog.dismiss()
SystemClock.sleep(100)
if (cancel != null) {
runOnUiThread(Runnable {
cancel()
})
}
if (cancel != null) runOnUiThread { cancel() }
}
if (importPossible) {
@ -123,11 +126,7 @@ object PrefImportSummaryDialog {
) { dialog: DialogInterface, _: Int ->
dialog.dismiss()
SystemClock.sleep(100)
if (ok != null) {
runOnUiThread(Runnable {
ok()
})
}
if (ok != null) runOnUiThread { ok() }
}
}

View file

@ -21,26 +21,23 @@ object TwoMessagesAlertDialog {
val dialog = AlertDialogHelper.Builder(context)
.setMessage(message)
.setCustomTitle(AlertDialogHelper.buildCustomTitle(context, title, icon
?: R.drawable.ic_check_while_48dp))
.setCustomTitle(
AlertDialogHelper.buildCustomTitle(
context, title, icon
?: R.drawable.ic_check_while_48dp
)
)
.setView(secondMessageLayout)
.setPositiveButton(android.R.string.ok) { dialog: DialogInterface, _: Int ->
dialog.dismiss()
SystemClock.sleep(100)
if (ok != null) {
runOnUiThread(Runnable {
ok()
})
}
if (ok != null) runOnUiThread { ok() }
}
.setNegativeButton(android.R.string.cancel) { dialog: DialogInterface, _: Int ->
dialog.dismiss()
SystemClock.sleep(100)
if (cancel != null) {
runOnUiThread(Runnable {
cancel()
})
}
if (cancel != null) runOnUiThread { cancel() }
}
.show()
dialog.setCanceledOnTouchOutside(false)

View file

@ -1,7 +1,6 @@
package info.nightscout.androidaps.utils.buildHelper
import info.nightscout.androidaps.BuildConfig
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.androidaps.interfaces.Config
import info.nightscout.androidaps.plugins.general.maintenance.PrefFileListProvider
import java.io.File

View file

@ -17,9 +17,9 @@ class TIR(val date: Long, val lowThreshold: Double, val highThreshold: Double) {
fun inRange() = run { inRange++; count++ }
fun above() = run { above++; count++ }
fun belowPct() = if (count > 0) (below.toDouble() / count * 100.0).roundToInt() else 0
fun inRangePct() = if (count > 0) 100 - belowPct() - abovePct() else 0
fun abovePct() = if (count > 0) (above.toDouble() / count * 100.0).roundToInt() else 0
private fun belowPct() = if (count > 0) (below.toDouble() / count * 100.0).roundToInt() else 0
private fun inRangePct() = if (count > 0) 100 - belowPct() - abovePct() else 0
private fun abovePct() = if (count > 0) (above.toDouble() / count * 100.0).roundToInt() else 0
fun toText(resourceHelper: ResourceHelper, dateUtil: DateUtil): String = resourceHelper.gs(R.string.tirformat, dateUtil.dateStringShort(date), belowPct(), inRangePct(), abovePct())

View file

@ -46,7 +46,7 @@ class TirCalculator @Inject constructor(
return result
}
fun averageTIR(tirs: LongSparseArray<TIR>): TIR {
private fun averageTIR(tirs: LongSparseArray<TIR>): TIR {
val totalTir = if (tirs.size() > 0) {
TIR(tirs.valueAt(0).date, tirs.valueAt(0).lowThreshold, tirs.valueAt(0).highThreshold)
} else {

View file

@ -28,8 +28,6 @@ import info.nightscout.androidaps.R;
import info.nightscout.androidaps.logging.AAPSLogger;
import info.nightscout.androidaps.utils.DateUtil;
import info.nightscout.androidaps.utils.SafeParse;
import info.nightscout.androidaps.utils.ui.NumberPicker;
import info.nightscout.androidaps.utils.ui.SpinnerHelper;
/**
* Created by mike on 29.12.2016.