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 commitHash = null
} }
disposable += repository.runTransaction(VersionChangeTransaction(BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE, gitRemote, commitHash)).subscribe() 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() disposable += compatDBHelper.dbChangeDisposable()
registerActivityLifecycleCallbacks(activityMonitor) registerActivityLifecycleCallbacks(activityMonitor)
JodaTimeAndroid.init(this) JodaTimeAndroid.init(this)

View file

@ -58,7 +58,7 @@ class AndroidPermission @Inject constructor(
activity.callForBatteryOptimization.launch(null) activity.callForBatteryOptimization.launch(null)
} catch (e: ActivityNotFoundException) { } catch (e: ActivityNotFoundException) {
permissionBatteryOptimizationFailed = true 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) { class Profiler @Inject constructor(val aapsLogger: AAPSLogger) {
fun log(lTag: LTag, function: String, start: Long) { fun log(lTag: LTag, function: String, start: Long) {
val msec = System.currentTimeMillis() - start val milliseconds = System.currentTimeMillis() - start
aapsLogger.debug(lTag, ">>> $function <<< executed in $msec miliseconds") 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.BackupAgentHelper
import android.app.backup.SharedPreferencesBackupHelper import android.app.backup.SharedPreferencesBackupHelper
@Suppress("LocalVariableName") @Suppress("LocalVariableName", "unused")
class SPBackupAgent : BackupAgentHelper() { class SPBackupAgent : BackupAgentHelper() {
override fun onCreate() { override fun onCreate() {

View file

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

View file

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

View file

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

View file

@ -1,7 +1,6 @@
package info.nightscout.androidaps.utils.buildHelper package info.nightscout.androidaps.utils.buildHelper
import info.nightscout.androidaps.BuildConfig import info.nightscout.androidaps.BuildConfig
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.androidaps.interfaces.Config import info.nightscout.androidaps.interfaces.Config
import info.nightscout.androidaps.plugins.general.maintenance.PrefFileListProvider import info.nightscout.androidaps.plugins.general.maintenance.PrefFileListProvider
import java.io.File 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 inRange() = run { inRange++; count++ }
fun above() = run { above++; count++ } fun above() = run { above++; count++ }
fun belowPct() = if (count > 0) (below.toDouble() / count * 100.0).roundToInt() else 0 private fun belowPct() = if (count > 0) (below.toDouble() / count * 100.0).roundToInt() else 0
fun inRangePct() = if (count > 0) 100 - belowPct() - abovePct() else 0 private 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 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()) 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 return result
} }
fun averageTIR(tirs: LongSparseArray<TIR>): TIR { private fun averageTIR(tirs: LongSparseArray<TIR>): TIR {
val totalTir = if (tirs.size() > 0) { val totalTir = if (tirs.size() > 0) {
TIR(tirs.valueAt(0).date, tirs.valueAt(0).lowThreshold, tirs.valueAt(0).highThreshold) TIR(tirs.valueAt(0).date, tirs.valueAt(0).lowThreshold, tirs.valueAt(0).highThreshold)
} else { } else {

View file

@ -28,8 +28,6 @@ import info.nightscout.androidaps.R;
import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.AAPSLogger;
import info.nightscout.androidaps.utils.DateUtil; import info.nightscout.androidaps.utils.DateUtil;
import info.nightscout.androidaps.utils.SafeParse; 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. * Created by mike on 29.12.2016.