classes -> :core:ui
This commit is contained in:
parent
b6b3600410
commit
d8bfcad7e9
15 changed files with 83 additions and 49 deletions
|
@ -29,10 +29,10 @@ import info.nightscout.androidaps.logging.UserEntryLogger
|
|||
import info.nightscout.androidaps.plugins.general.maintenance.formats.EncryptedPrefsFormat
|
||||
import info.nightscout.androidaps.utils.ToastUtils
|
||||
import info.nightscout.androidaps.utils.alertDialogs.PrefImportSummaryDialog
|
||||
import info.nightscout.androidaps.utils.alertDialogs.TwoMessagesAlertDialog
|
||||
import info.nightscout.androidaps.utils.protection.PasswordCheck
|
||||
import info.nightscout.androidaps.utils.userEntry.UserEntryPresentationHelper
|
||||
import info.nightscout.core.ui.dialogs.OKDialog
|
||||
import info.nightscout.core.ui.dialogs.TwoMessagesAlertDialog
|
||||
import info.nightscout.database.entities.UserEntry
|
||||
import info.nightscout.database.entities.UserEntry.Action
|
||||
import info.nightscout.database.entities.UserEntry.Sources
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
@file:Suppress("SpellCheckingInspection")
|
||||
|
||||
package info.nightscout.androidaps.utils.ui
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
package info.nightscout.androidaps.utils
|
||||
|
||||
import android.widget.TextView
|
||||
import info.nightscout.androidaps.extensions.isOlderThan
|
||||
import info.nightscout.core.main.R
|
||||
import info.nightscout.database.entities.TherapyEvent
|
||||
import info.nightscout.shared.interfaces.ResourceHelper
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Singleton
|
||||
class WarnColors @Inject constructor(val rh: ResourceHelper) {
|
||||
|
||||
fun setColor(view: TextView?, value: Double, warnLevel: Double, urgentLevel: Double) =
|
||||
view?.setTextColor( rh.gac( view.context ,when {
|
||||
value >= urgentLevel -> R.attr.urgentColor
|
||||
value >= warnLevel -> R.attr.warnColor
|
||||
else -> R.attr.defaultTextColor
|
||||
}))
|
||||
|
||||
fun setColorInverse(view: TextView?, value: Double, warnLevel: Double, urgentLevel: Double) =
|
||||
view?.setTextColor( rh.gac( view.context , when {
|
||||
value <= urgentLevel -> R.attr.urgentColor
|
||||
value <= warnLevel -> R.attr.warnColor
|
||||
else -> R.attr.defaultTextColor
|
||||
}))
|
||||
|
||||
fun setColorByAge(view: TextView?, therapyEvent: TherapyEvent, warnThreshold: Double, urgentThreshold: Double) =
|
||||
view?.setTextColor( rh.gac( view.context , when {
|
||||
therapyEvent.isOlderThan(urgentThreshold) -> R.attr.lowColor
|
||||
therapyEvent.isOlderThan(warnThreshold) -> R.attr.highColor
|
||||
else -> R.attr.defaultTextColor
|
||||
}))
|
||||
}
|
|
@ -1,19 +1,24 @@
|
|||
package info.nightscout.androidaps.utils.alertDialogs
|
||||
package info.nightscout.core.ui.dialogs
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.content.DialogInterface
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.os.SystemClock
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.widget.TextView
|
||||
import androidx.annotation.DrawableRes
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.shared.extensions.runOnUiThread
|
||||
import info.nightscout.core.ui.R
|
||||
|
||||
object TwoMessagesAlertDialog {
|
||||
|
||||
private fun runOnUiThread(theRunnable: Runnable?) = theRunnable?.let {
|
||||
Handler(Looper.getMainLooper()).post(it)
|
||||
}
|
||||
|
||||
@SuppressLint("InflateParams")
|
||||
fun showAlert(context: Context, title: String, message: String, secondMessage: String, ok: (() -> Unit)?, cancel: (() -> Unit)? = null, @DrawableRes icon: Int? = null) {
|
||||
|
||||
|
@ -23,7 +28,7 @@ object TwoMessagesAlertDialog {
|
|||
MaterialAlertDialogBuilder(context, R.style.DialogTheme)
|
||||
.setMessage(message)
|
||||
.setCustomTitle(
|
||||
info.nightscout.core.ui.dialogs.AlertDialogHelper.buildCustomTitle(
|
||||
AlertDialogHelper.buildCustomTitle(
|
||||
context, title, icon
|
||||
?: R.drawable.ic_check_white_48dp
|
||||
)
|
|
@ -1,4 +1,4 @@
|
|||
package info.nightscout.plugins.ui
|
||||
package info.nightscout.core.ui.elements
|
||||
|
||||
import android.view.MotionEvent
|
||||
import android.view.View
|
|
@ -6,7 +6,9 @@ import dagger.Provides
|
|||
import info.nightscout.core.fabric.FabricPrivacy
|
||||
import info.nightscout.database.impl.AppRepository
|
||||
import info.nightscout.implementation.HardLimitsImpl
|
||||
import info.nightscout.implementation.pump.WarnColorsImpl
|
||||
import info.nightscout.implementation.resources.ResourceHelperImpl
|
||||
import info.nightscout.interfaces.pump.WarnColors
|
||||
import info.nightscout.interfaces.utils.HardLimits
|
||||
import info.nightscout.rx.bus.RxBus
|
||||
import info.nightscout.rx.logging.AAPSLogger
|
||||
|
@ -32,4 +34,8 @@ open class ImplementationModule {
|
|||
@Singleton
|
||||
fun provideHardLimits(aapsLogger: AAPSLogger, rxBus: RxBus, sp: SP, rh: ResourceHelper, context: Context, repository: AppRepository): HardLimits =
|
||||
HardLimitsImpl(aapsLogger, rxBus, sp, rh, context, repository)
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun provideWarnColors(rh: ResourceHelper): WarnColors = WarnColorsImpl(rh)
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package info.nightscout.implementation.pump
|
||||
|
||||
import android.widget.TextView
|
||||
import info.nightscout.androidaps.extensions.isOlderThan
|
||||
import info.nightscout.core.main.R
|
||||
import info.nightscout.database.entities.TherapyEvent
|
||||
import info.nightscout.interfaces.pump.WarnColors
|
||||
import info.nightscout.shared.interfaces.ResourceHelper
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Singleton
|
||||
class WarnColorsImpl @Inject constructor(val rh: ResourceHelper): WarnColors {
|
||||
|
||||
override fun setColor(view: TextView?, value: Double, warnLevel: Double, urgentLevel: Double) {
|
||||
view?.setTextColor(
|
||||
rh.gac(
|
||||
view.context, when {
|
||||
value >= urgentLevel -> R.attr.urgentColor
|
||||
value >= warnLevel -> R.attr.warnColor
|
||||
else -> R.attr.defaultTextColor
|
||||
}
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun setColorInverse(view: TextView?, value: Double, warnLevel: Double, urgentLevel: Double) {
|
||||
view?.setTextColor(
|
||||
rh.gac(
|
||||
view.context, when {
|
||||
value <= urgentLevel -> R.attr.urgentColor
|
||||
value <= warnLevel -> R.attr.warnColor
|
||||
else -> R.attr.defaultTextColor
|
||||
}
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun setColorByAge(view: TextView?, therapyEvent: TherapyEvent, warnThreshold: Double, urgentThreshold: Double) {
|
||||
view?.setTextColor(
|
||||
rh.gac(
|
||||
view.context, when {
|
||||
therapyEvent.isOlderThan(urgentThreshold) -> R.attr.lowColor
|
||||
therapyEvent.isOlderThan(warnThreshold) -> R.attr.highColor
|
||||
else -> R.attr.defaultTextColor
|
||||
}
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package info.nightscout.interfaces.pump
|
||||
|
||||
import android.widget.TextView
|
||||
import info.nightscout.database.entities.TherapyEvent
|
||||
|
||||
interface WarnColors {
|
||||
fun setColor(view: TextView?, value: Double, warnLevel: Double, urgentLevel: Double)
|
||||
fun setColorInverse(view: TextView?, value: Double, warnLevel: Double, urgentLevel: Double)
|
||||
fun setColorByAge(view: TextView?, therapyEvent: TherapyEvent, warnThreshold: Double, urgentThreshold: Double)
|
||||
}
|
|
@ -3,12 +3,12 @@ package info.nightscout.plugins.ui
|
|||
import android.widget.TextView
|
||||
import androidx.annotation.StringRes
|
||||
import info.nightscout.androidaps.utils.DecimalFormatter
|
||||
import info.nightscout.androidaps.utils.WarnColors
|
||||
import info.nightscout.database.entities.TherapyEvent
|
||||
import info.nightscout.database.impl.AppRepository
|
||||
import info.nightscout.database.impl.ValueWrapper
|
||||
import info.nightscout.interfaces.Config
|
||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
||||
import info.nightscout.interfaces.pump.WarnColors
|
||||
import info.nightscout.interfaces.pump.defs.PumpType
|
||||
import info.nightscout.plugins.R
|
||||
import info.nightscout.plugins.sync.nsclient.extensions.age
|
||||
|
|
|
@ -24,11 +24,12 @@ import java.text.NumberFormat;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import info.nightscout.shared.utils.DateUtil;
|
||||
import info.nightscout.androidaps.utils.ui.NumberPicker;
|
||||
import info.nightscout.core.ui.elements.SpinnerHelper;
|
||||
import info.nightscout.plugins.R;
|
||||
import info.nightscout.rx.logging.AAPSLogger;
|
||||
import info.nightscout.shared.SafeParse;
|
||||
import info.nightscout.shared.utils.DateUtil;
|
||||
|
||||
/**
|
||||
* Created by mike on 29.12.2016.
|
||||
|
|
|
@ -15,7 +15,6 @@ import info.nightscout.androidaps.dana.activities.DanaUserOptionsActivity
|
|||
import info.nightscout.androidaps.dana.databinding.DanarFragmentBinding
|
||||
import info.nightscout.androidaps.dana.events.EventDanaRNewStatus
|
||||
import info.nightscout.androidaps.logging.UserEntryLogger
|
||||
import info.nightscout.androidaps.utils.WarnColors
|
||||
import info.nightscout.androidaps.utils.userEntry.UserEntryMapper.Action
|
||||
import info.nightscout.androidaps.utils.userEntry.UserEntryMapper.Sources
|
||||
import info.nightscout.core.fabric.FabricPrivacy
|
||||
|
@ -23,6 +22,7 @@ import info.nightscout.core.ui.dialogs.OKDialog
|
|||
import info.nightscout.interfaces.plugin.ActivePlugin
|
||||
import info.nightscout.interfaces.pump.Dana
|
||||
import info.nightscout.interfaces.pump.Pump
|
||||
import info.nightscout.interfaces.pump.WarnColors
|
||||
import info.nightscout.interfaces.pump.defs.PumpType
|
||||
import info.nightscout.interfaces.queue.CommandQueue
|
||||
import info.nightscout.interfaces.ui.ActivityNames
|
||||
|
|
|
@ -13,10 +13,10 @@ import info.nightscout.androidaps.diaconn.activities.DiaconnG8HistoryActivity
|
|||
import info.nightscout.androidaps.diaconn.activities.DiaconnG8UserOptionsActivity
|
||||
import info.nightscout.androidaps.diaconn.databinding.DiaconnG8FragmentBinding
|
||||
import info.nightscout.androidaps.diaconn.events.EventDiaconnG8NewStatus
|
||||
import info.nightscout.androidaps.utils.WarnColors
|
||||
import info.nightscout.core.fabric.FabricPrivacy
|
||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
||||
import info.nightscout.interfaces.pump.Pump
|
||||
import info.nightscout.interfaces.pump.WarnColors
|
||||
import info.nightscout.interfaces.queue.CommandQueue
|
||||
import info.nightscout.interfaces.ui.ActivityNames
|
||||
import info.nightscout.rx.AapsSchedulers
|
||||
|
|
|
@ -22,11 +22,11 @@ import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpSta
|
|||
import info.nightscout.androidaps.plugins.pump.medtronic.events.EventMedtronicPumpConfigurationChanged
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.events.EventMedtronicPumpValuesChanged
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil
|
||||
import info.nightscout.androidaps.utils.WarnColors
|
||||
import info.nightscout.core.fabric.FabricPrivacy
|
||||
import info.nightscout.core.ui.dialogs.OKDialog
|
||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
||||
import info.nightscout.interfaces.pump.PumpSync
|
||||
import info.nightscout.interfaces.pump.WarnColors
|
||||
import info.nightscout.interfaces.queue.Callback
|
||||
import info.nightscout.interfaces.queue.CommandQueue
|
||||
import info.nightscout.pump.core.defs.PumpDeviceState
|
||||
|
|
Loading…
Reference in a new issue