Dana: migrate to jetpack bindings

This commit is contained in:
Milos Kozak 2020-12-05 23:23:06 +01:00
parent 30624053e3
commit 4bbba779aa
18 changed files with 219 additions and 242 deletions

View file

@ -19,7 +19,9 @@ android {
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures {
viewBinding true
}
buildTypes {
release {
minifyEnabled false

View file

@ -1,6 +1,5 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
android {
@ -19,7 +18,9 @@ android {
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures {
viewBinding true
}
buildTypes {
release {
minifyEnabled false

View file

@ -8,6 +8,7 @@ import android.view.View
import android.view.ViewGroup
import dagger.android.support.DaggerFragment
import info.nightscout.androidaps.activities.TDDStatsActivity
import info.nightscout.androidaps.dana.databinding.DanarFragmentBinding
import info.nightscout.androidaps.dialogs.ProfileViewerDialog
import info.nightscout.androidaps.events.EventExtendedBolusChange
import info.nightscout.androidaps.events.EventInitializationChanged
@ -32,7 +33,6 @@ import info.nightscout.androidaps.utils.resources.ResourceHelper
import info.nightscout.androidaps.utils.sharedPreferences.SP
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.CompositeDisposable
import kotlinx.android.synthetic.main.danar_fragment.*
import javax.inject.Inject
class DanaFragment : DaggerFragment() {
@ -53,6 +53,12 @@ class DanaFragment : DaggerFragment() {
private val loopHandler = Handler()
private lateinit var refreshLoop: Runnable
private var _binding: DanarFragmentBinding? = null
// This property is only valid between onCreateView and
// onDestroyView.
private val binding get() = _binding!!
init {
refreshLoop = Runnable {
activity?.runOnUiThread { updateGUI() }
@ -61,17 +67,18 @@ class DanaFragment : DaggerFragment() {
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.danar_fragment, container, false)
savedInstanceState: Bundle?): View {
_binding = DanarFragmentBinding.inflate(inflater, container, false)
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
dana_pumpstatus.setBackgroundColor(resourceHelper.gc(R.color.colorInitializingBorder))
binding.danaPumpstatus.setBackgroundColor(resourceHelper.gc(R.color.colorInitializingBorder))
danar_history.setOnClickListener { startActivity(Intent(context, info.nightscout.androidaps.dana.activities.DanaHistoryActivity::class.java)) }
danar_viewprofile.setOnClickListener {
binding.history.setOnClickListener { startActivity(Intent(context, info.nightscout.androidaps.dana.activities.DanaHistoryActivity::class.java)) }
binding.viewprofile.setOnClickListener {
val profile = danaPump.createConvertedProfile()?.getDefaultProfile()
?: return@setOnClickListener
val profileName = danaPump.createConvertedProfile()?.getDefaultProfileName()
@ -86,17 +93,17 @@ class DanaFragment : DaggerFragment() {
pvd.arguments = args
pvd.show(childFragmentManager, "ProfileViewDialog")
}
danar_stats.setOnClickListener { startActivity(Intent(context, TDDStatsActivity::class.java)) }
danar_user_options.setOnClickListener { startActivity(Intent(context, info.nightscout.androidaps.dana.activities.DanaUserOptionsActivity::class.java)) }
danar_btconnection.setOnClickListener {
binding.stats.setOnClickListener { startActivity(Intent(context, TDDStatsActivity::class.java)) }
binding.userOptions.setOnClickListener { startActivity(Intent(context, info.nightscout.androidaps.dana.activities.DanaUserOptionsActivity::class.java)) }
binding.btconnection.setOnClickListener {
aapsLogger.debug(LTag.PUMP, "Clicked connect to pump")
danaPump.lastConnection = 0
commandQueue.readStatus("Clicked connect to pump", null)
}
if (activePlugin.activePump.pumpDescription.pumpType == PumpType.DanaRS)
danar_btconnection.setOnLongClickListener {
binding.btconnection.setOnLongClickListener {
activity?.let {
OKDialog.showConfirmation(it, resourceHelper.gs(R.string.resetpairing), Runnable {
OKDialog.showConfirmation(it, resourceHelper.gs(R.string.resetpairing), {
aapsLogger.error("USER ENTRY: Clearing pairing keys !!!")
(activePlugin.activePump as DanaPumpInterface).clearPairing()
})
@ -136,19 +143,19 @@ class DanaFragment : DaggerFragment() {
when {
it.status == EventPumpStatusChanged.Status.CONNECTING ->
@Suppress("SetTextI18n")
danar_btconnection?.text = "{fa-bluetooth-b spin} ${it.secondsElapsed}s"
binding.btconnection.text = "{fa-bluetooth-b spin} ${it.secondsElapsed}s"
it.status == EventPumpStatusChanged.Status.CONNECTED ->
@Suppress("SetTextI18n")
danar_btconnection?.text = "{fa-bluetooth}"
binding.btconnection.text = "{fa-bluetooth}"
it.status == EventPumpStatusChanged.Status.DISCONNECTED ->
@Suppress("SetTextI18n")
danar_btconnection?.text = "{fa-bluetooth-b}"
binding.btconnection.text = "{fa-bluetooth-b}"
}
if (it.getStatus(resourceHelper) != "") {
dana_pumpstatus?.text = it.getStatus(resourceHelper)
dana_pumpstatuslayout?.visibility = View.VISIBLE
binding.danaPumpstatus.text = it.getStatus(resourceHelper)
binding.danaPumpstatuslayout.visibility = View.VISIBLE
} else {
dana_pumpstatuslayout?.visibility = View.GONE
binding.danaPumpstatuslayout.visibility = View.GONE
}
}, { fabricPrivacy.logException(it) })
updateGUI()
@ -164,57 +171,56 @@ class DanaFragment : DaggerFragment() {
// GUI functions
@Synchronized
fun updateGUI() {
if (danar_dailyunits == null) return
val pump = danaPump
val plugin: PumpInterface = activePlugin.activePump
if (pump.lastConnection != 0L) {
val agoMsec = System.currentTimeMillis() - pump.lastConnection
val agoMin = (agoMsec.toDouble() / 60.0 / 1000.0).toInt()
danar_lastconnection?.text = dateUtil.timeString(pump.lastConnection) + " (" + resourceHelper.gs(R.string.minago, agoMin) + ")"
warnColors.setColor(danar_lastconnection, agoMin.toDouble(), 16.0, 31.0)
binding.lastconnection.text = dateUtil.timeString(pump.lastConnection) + " (" + resourceHelper.gs(R.string.minago, agoMin) + ")"
warnColors.setColor(binding.lastconnection, agoMin.toDouble(), 16.0, 31.0)
}
if (pump.lastBolusTime != 0L) {
val agoMsec = System.currentTimeMillis() - pump.lastBolusTime
val agoHours = agoMsec.toDouble() / 60.0 / 60.0 / 1000.0
if (agoHours < 6)
// max 6h back
danar_lastbolus?.text = dateUtil.timeString(pump.lastBolusTime) + " " + DateUtil.sinceString(pump.lastBolusTime, resourceHelper) + " " + resourceHelper.gs(R.string.formatinsulinunits, pump.lastBolusAmount)
binding.lastbolus.text = dateUtil.timeString(pump.lastBolusTime) + " " + DateUtil.sinceString(pump.lastBolusTime, resourceHelper) + " " + resourceHelper.gs(R.string.formatinsulinunits, pump.lastBolusAmount)
else
danar_lastbolus?.text = ""
binding.lastbolus.text = ""
}
danar_dailyunits?.text = resourceHelper.gs(R.string.reservoirvalue, pump.dailyTotalUnits, pump.maxDailyTotalUnits)
warnColors.setColor(danar_dailyunits, pump.dailyTotalUnits, pump.maxDailyTotalUnits * 0.75, pump.maxDailyTotalUnits * 0.9)
danar_basabasalrate?.text = "( " + (pump.activeProfile + 1) + " ) " + resourceHelper.gs(R.string.pump_basebasalrate, plugin.baseBasalRate)
binding.dailyunits.text = resourceHelper.gs(R.string.reservoirvalue, pump.dailyTotalUnits, pump.maxDailyTotalUnits)
warnColors.setColor(binding.dailyunits, pump.dailyTotalUnits, pump.maxDailyTotalUnits * 0.75, pump.maxDailyTotalUnits * 0.9)
binding.basabasalrate.text = "( " + (pump.activeProfile + 1) + " ) " + resourceHelper.gs(R.string.pump_basebasalrate, plugin.baseBasalRate)
// DanaRPlugin, DanaRKoreanPlugin
if (activePlugin.activePump.isFakingTempsByExtendedBoluses == true) {
danar_tempbasal?.text = activePlugin.activeTreatments.getRealTempBasalFromHistory(System.currentTimeMillis())?.toStringFull()
binding.tempbasal.text = activePlugin.activeTreatments.getRealTempBasalFromHistory(System.currentTimeMillis())?.toStringFull()
?: ""
} else {
// v2 plugin
danar_tempbasal?.text = activePlugin.activeTreatments.getTempBasalFromHistory(System.currentTimeMillis())?.toStringFull()
binding.tempbasal.text = activePlugin.activeTreatments.getTempBasalFromHistory(System.currentTimeMillis())?.toStringFull()
?: ""
}
danar_extendedbolus?.text = activePlugin.activeTreatments.getExtendedBolusFromHistory(System.currentTimeMillis())?.toString()
binding.extendedbolus.text = activePlugin.activeTreatments.getExtendedBolusFromHistory(System.currentTimeMillis())?.toString()
?: ""
danar_reservoir?.text = resourceHelper.gs(R.string.reservoirvalue, pump.reservoirRemainingUnits, 300)
warnColors.setColorInverse(danar_reservoir, pump.reservoirRemainingUnits, 50.0, 20.0)
danar_battery?.text = "{fa-battery-" + pump.batteryRemaining / 25 + "}"
warnColors.setColorInverse(danar_battery, pump.batteryRemaining.toDouble(), 51.0, 26.0)
danar_iob?.text = resourceHelper.gs(R.string.formatinsulinunits, pump.iob)
danar_firmware?.text = resourceHelper.gs(R.string.dana_model, pump.modelFriendlyName(), pump.hwModel, pump.protocol, pump.productCode)
danar_basalstep?.text = pump.basalStep.toString()
danar_bolusstep?.text = pump.bolusStep.toString()
danar_serialnumber?.text = pump.serialNumber
binding.reservoir.text = resourceHelper.gs(R.string.reservoirvalue, pump.reservoirRemainingUnits, 300)
warnColors.setColorInverse(binding.reservoir, pump.reservoirRemainingUnits, 50.0, 20.0)
binding.battery.text = "{fa-battery-" + pump.batteryRemaining / 25 + "}"
warnColors.setColorInverse(binding.battery, pump.batteryRemaining.toDouble(), 51.0, 26.0)
binding.iob.text = resourceHelper.gs(R.string.formatinsulinunits, pump.iob)
binding.firmware.text = resourceHelper.gs(R.string.dana_model, pump.modelFriendlyName(), pump.hwModel, pump.protocol, pump.productCode)
binding.basalstep.text = pump.basalStep.toString()
binding.bolusstep.text = pump.bolusStep.toString()
binding.serialNumber.text = pump.serialNumber
val status = commandQueue.spannedStatus()
if (status.toString() == "") {
danar_queue?.visibility = View.GONE
binding.queue.visibility = View.GONE
} else {
danar_queue?.visibility = View.VISIBLE
danar_queue?.text = status
binding.queue.visibility = View.VISIBLE
binding.queue.text = status
}
//hide user options button if not an RS pump or old firmware
// also excludes pump with model 03 because of untested error
danar_user_options?.visibility = (pump.hwModel != 1 && pump.protocol != 0x00).toVisibility()
binding.userOptions.visibility = (pump.hwModel != 1 && pump.protocol != 0x00).toVisibility()
}
}

View file

@ -13,8 +13,10 @@ import info.nightscout.androidaps.Constants
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity
import info.nightscout.androidaps.dana.R
import info.nightscout.androidaps.dana.comm.RecordTypes
import info.nightscout.androidaps.dana.databinding.DanarHistoryActivityBinding
import info.nightscout.androidaps.data.Profile
import info.nightscout.androidaps.db.DanaRHistoryRecord
import info.nightscout.androidaps.events.EventDanaRSyncStatus
import info.nightscout.androidaps.events.EventPumpStatusChanged
import info.nightscout.androidaps.interfaces.ActivePluginProvider
import info.nightscout.androidaps.interfaces.CommandQueueProvider
@ -24,7 +26,6 @@ import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType
import info.nightscout.androidaps.events.EventDanaRSyncStatus
import info.nightscout.androidaps.queue.Callback
import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.DecimalFormatter
@ -33,11 +34,11 @@ import info.nightscout.androidaps.utils.extensions.plusAssign
import info.nightscout.androidaps.utils.resources.ResourceHelper
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.CompositeDisposable
import kotlinx.android.synthetic.main.danar_historyactivity.*
import java.util.*
import javax.inject.Inject
class DanaHistoryActivity : NoSplashAppCompatActivity() {
@Inject lateinit var rxBus: RxBusWrapper
@Inject lateinit var aapsLogger: AAPSLogger
@Inject lateinit var resourceHelper: ResourceHelper
@ -54,21 +55,24 @@ class DanaHistoryActivity : NoSplashAppCompatActivity() {
private var historyList: List<DanaRHistoryRecord> = ArrayList()
class TypeList internal constructor(var type: Byte, var name: String) {
override fun toString(): String = name
}
private lateinit var binding: DanarHistoryActivityBinding
override fun onResume() {
super.onResume()
disposable += rxBus
.toObservable(EventPumpStatusChanged::class.java)
.observeOn(AndroidSchedulers.mainThread())
.subscribe({ danar_history_status.text = it.getStatus(resourceHelper) }) { fabricPrivacy.logException(it) }
.subscribe({ binding.status.text = it.getStatus(resourceHelper) }) { fabricPrivacy.logException(it) }
disposable += rxBus
.toObservable(EventDanaRSyncStatus::class.java)
.observeOn(AndroidSchedulers.mainThread())
.subscribe({
aapsLogger.debug(LTag.PUMP, "EventDanaRSyncStatus: " + it.message)
danar_history_status.text = it.message
binding.status.text = it.message
}) { fabricPrivacy.logException(it) }
}
@ -79,12 +83,13 @@ class DanaHistoryActivity : NoSplashAppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.danar_historyactivity)
binding = DanarHistoryActivityBinding.inflate(layoutInflater)
setContentView(binding.root)
danar_history_recyclerview.setHasFixedSize(true)
danar_history_recyclerview.layoutManager = LinearLayoutManager(this)
danar_history_recyclerview.adapter = RecyclerViewAdapter(historyList)
danar_history_status.visibility = View.GONE
binding.recyclerview.setHasFixedSize(true)
binding.recyclerview.layoutManager = LinearLayoutManager(this)
binding.recyclerview.adapter = RecyclerViewAdapter(historyList)
binding.status.visibility = View.GONE
val pump = activePlugin.activePump
val isKorean = pump.pumpDescription.pumpType == PumpType.DanaRKorean
@ -106,26 +111,27 @@ class DanaHistoryActivity : NoSplashAppCompatActivity() {
typeList.add(TypeList(RecordTypes.RECORD_TYPE_REFILL, resourceHelper.gs(R.string.danar_history_refill)))
typeList.add(TypeList(RecordTypes.RECORD_TYPE_SUSPEND, resourceHelper.gs(R.string.danar_history_syspend)))
}
danar_history_spinner.adapter = ArrayAdapter(this, R.layout.spinner_centered, typeList)
binding.spinner.adapter = ArrayAdapter(this, R.layout.spinner_centered, typeList)
danar_history_reload.setOnClickListener {
val selected = danar_history_spinner.selectedItem as TypeList? ?: return@setOnClickListener
binding.reload.setOnClickListener {
val selected = binding.spinner.selectedItem as TypeList?
?: return@setOnClickListener
runOnUiThread {
danar_history_reload?.visibility = View.GONE
danar_history_status?.visibility = View.VISIBLE
binding.reload.visibility = View.GONE
binding.status.visibility = View.VISIBLE
}
clearCardView()
commandQueue.loadHistory(selected.type, object : Callback() {
override fun run() {
loadDataFromDB(selected.type)
runOnUiThread {
danar_history_reload?.visibility = View.VISIBLE
danar_history_status?.visibility = View.GONE
binding.reload.visibility = View.VISIBLE
binding.status.visibility = View.GONE
}
}
})
}
danar_history_spinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
binding.spinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
val selected = typeList[position]
loadDataFromDB(selected.type)
@ -139,6 +145,7 @@ class DanaHistoryActivity : NoSplashAppCompatActivity() {
}
inner class RecyclerViewAdapter internal constructor(private var historyList: List<DanaRHistoryRecord>) : RecyclerView.Adapter<RecyclerViewAdapter.HistoryViewHolder>() {
override fun onCreateViewHolder(viewGroup: ViewGroup, viewType: Int): HistoryViewHolder =
HistoryViewHolder(LayoutInflater.from(viewGroup.context).inflate(R.layout.danar_history_item, viewGroup, false))
@ -235,6 +242,7 @@ class DanaHistoryActivity : NoSplashAppCompatActivity() {
}
inner class HistoryViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
var time: TextView = itemView.findViewById(R.id.danar_history_time)
var value: TextView = itemView.findViewById(R.id.danar_history_value)
var bolusType: TextView = itemView.findViewById(R.id.danar_history_bolustype)
@ -249,11 +257,11 @@ class DanaHistoryActivity : NoSplashAppCompatActivity() {
private fun loadDataFromDB(type: Byte) {
historyList = databaseHelper.getDanaRHistoryRecordsByType(type)
runOnUiThread { danar_history_recyclerview?.swapAdapter(RecyclerViewAdapter(historyList), false) }
runOnUiThread { binding.recyclerview.swapAdapter(RecyclerViewAdapter(historyList), false) }
}
private fun clearCardView() {
historyList = ArrayList()
runOnUiThread { danar_history_recyclerview?.swapAdapter(RecyclerViewAdapter(historyList), false) }
runOnUiThread { binding.recyclerview.swapAdapter(RecyclerViewAdapter(historyList), false) }
}
}

View file

@ -8,6 +8,7 @@ import info.nightscout.androidaps.activities.ErrorHelperActivity
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity
import info.nightscout.androidaps.dana.DanaPump
import info.nightscout.androidaps.dana.R
import info.nightscout.androidaps.dana.databinding.DanarUserOptionsActivityBinding
import info.nightscout.androidaps.events.EventInitializationChanged
import info.nightscout.androidaps.interfaces.ActivePluginProvider
import info.nightscout.androidaps.interfaces.CommandQueueProvider
@ -21,7 +22,6 @@ import info.nightscout.androidaps.utils.extensions.plusAssign
import info.nightscout.androidaps.utils.resources.ResourceHelper
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.CompositeDisposable
import kotlinx.android.synthetic.main.danar_user_options_activity.*
import java.text.DecimalFormat
import javax.inject.Inject
import kotlin.math.max
@ -47,6 +47,8 @@ class DanaUserOptionsActivity : NoSplashAppCompatActivity() {
var minBacklight = 1
private lateinit var binding: DanarUserOptionsActivityBinding
@Synchronized
override fun onResume() {
super.onResume()
@ -64,9 +66,10 @@ class DanaUserOptionsActivity : NoSplashAppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.danar_user_options_activity)
binding = DanarUserOptionsActivityBinding.inflate(layoutInflater)
setContentView(binding.root)
save_user_options.setOnClickListener { onSaveClick() }
binding.saveUserOptions.setOnClickListener { onSaveClick() }
minBacklight = if (danaPump.hwModel < 7) 1 else 0 // Dana-i allows zero
@ -80,28 +83,28 @@ class DanaUserOptionsActivity : NoSplashAppCompatActivity() {
+ "\npumpUnits:" + danaPump.units
+ "\nlowReservoir:" + danaPump.lowReservoirRate)
danar_screentimeout.setParams(danaPump.lcdOnTimeSec.toDouble(), 5.0, 240.0, 5.0, DecimalFormat("1"), false, save_user_options)
danar_backlight.setParams(danaPump.backlightOnTimeSec.toDouble(), minBacklight.toDouble(), 60.0, 1.0, DecimalFormat("1"), false, save_user_options)
danar_shutdown.setParams(danaPump.shutdownHour.toDouble(), 0.0, 24.0, 1.0, DecimalFormat("1"), true, save_user_options)
danar_lowreservoir.setParams(danaPump.lowReservoirRate.toDouble(), 10.0, 50.0, 10.0, DecimalFormat("10"), false, save_user_options)
binding.screentimeout.setParams(danaPump.lcdOnTimeSec.toDouble(), 5.0, 240.0, 5.0, DecimalFormat("1"), false, binding.saveUserOptions)
binding.backlight.setParams(danaPump.backlightOnTimeSec.toDouble(), minBacklight.toDouble(), 60.0, 1.0, DecimalFormat("1"), false, binding.saveUserOptions)
binding.shutdown.setParams(danaPump.shutdownHour.toDouble(), 0.0, 24.0, 1.0, DecimalFormat("1"), true, binding.saveUserOptions)
binding.lowreservoir.setParams(danaPump.lowReservoirRate.toDouble(), 10.0, 50.0, 10.0, DecimalFormat("10"), false, binding.saveUserOptions)
when (danaPump.beepAndAlarm) {
0b01 -> danar_pumpalarm_sound.isChecked = true
0b10 -> danar_pumpalarm_vibrate.isChecked = true
0b11 -> danar_pumpalarm_both.isChecked = true
0b01 -> binding.pumpalarmSound.isChecked = true
0b10 -> binding.pumpalarmVibrate.isChecked = true
0b11 -> binding.pumpalarmBoth.isChecked = true
0b101 -> {
danar_pumpalarm_sound.isChecked = true
danar_beep.isChecked = true
binding.pumpalarmSound.isChecked = true
binding.beep.isChecked = true
}
0b110 -> {
danar_pumpalarm_vibrate.isChecked = true
danar_beep.isChecked = true
binding.pumpalarmVibrate.isChecked = true
binding.beep.isChecked = true
}
0b111 -> {
danar_pumpalarm_both.isChecked = true
danar_beep.isChecked = true
binding.pumpalarmBoth.isChecked = true
binding.beep.isChecked = true
}
}
if (danaPump.lastSettingsRead == 0L && danaPump.hwModel < 0x05) // RS+ doesn't use lastSettingsRead
@ -112,42 +115,42 @@ class DanaUserOptionsActivity : NoSplashAppCompatActivity() {
fun setData() {
// in DanaRS timeDisplay values are reversed
danar_timeformat.isChecked = danaPump.timeDisplayType24
danar_buttonscroll.isChecked = danaPump.buttonScrollOnOff
danar_beep.isChecked = danaPump.beepAndAlarm > 4
danar_screentimeout.value = danaPump.lcdOnTimeSec.toDouble()
danar_backlight.value = danaPump.backlightOnTimeSec.toDouble()
danar_units.isChecked = danaPump.getUnits() == Constants.MMOL
danar_shutdown.value = danaPump.shutdownHour.toDouble()
danar_lowreservoir.value = danaPump.lowReservoirRate.toDouble()
binding.timeformat.isChecked = danaPump.timeDisplayType24
binding.buttonscroll.isChecked = danaPump.buttonScrollOnOff
binding.beep.isChecked = danaPump.beepAndAlarm > 4
binding.screentimeout.value = danaPump.lcdOnTimeSec.toDouble()
binding.backlight.value = danaPump.backlightOnTimeSec.toDouble()
binding.units.isChecked = danaPump.getUnits() == Constants.MMOL
binding.shutdown.value = danaPump.shutdownHour.toDouble()
binding.lowreservoir.value = danaPump.lowReservoirRate.toDouble()
}
private fun onSaveClick() {
//exit if pump is not DanaRS, DanaR, or DanaR with upgraded firmware
if (!isRS() && !isDanaR() && !isDanaRv2()) return
danaPump.timeDisplayType24 = danar_timeformat.isChecked
danaPump.timeDisplayType24 = binding.timeformat.isChecked
danaPump.buttonScrollOnOff = danar_buttonscroll.isChecked
danaPump.buttonScrollOnOff = binding.buttonscroll.isChecked
danaPump.beepAndAlarm = when {
danar_pumpalarm_sound.isChecked -> 1
danar_pumpalarm_vibrate.isChecked -> 2
danar_pumpalarm_both.isChecked -> 3
binding.pumpalarmSound.isChecked -> 1
binding.pumpalarmVibrate.isChecked -> 2
binding.pumpalarmBoth.isChecked -> 3
else -> 1
}
if (danar_beep.isChecked) danaPump.beepAndAlarm += 4
if (binding.beep.isChecked) danaPump.beepAndAlarm += 4
// step is 5 seconds, 5 to 240
danaPump.lcdOnTimeSec = min(max(danar_screentimeout.value.toInt() / 5 * 5, 5), 240)
danaPump.lcdOnTimeSec = min(max(binding.screentimeout.value.toInt() / 5 * 5, 5), 240)
// 1 to 60
danaPump.backlightOnTimeSec = min(max(danar_backlight.value.toInt(), minBacklight), 60)
danaPump.backlightOnTimeSec = min(max(binding.backlight.value.toInt(), minBacklight), 60)
danaPump.units = if (danar_units.isChecked) 1 else 0
danaPump.units = if (binding.units.isChecked) 1 else 0
danaPump.shutdownHour = min(danar_shutdown.value.toInt(), 24)
danaPump.shutdownHour = min(binding.shutdown.value.toInt(), 24)
// 10 to 50
danaPump.lowReservoirRate = min(max(danar_lowreservoir.value.toInt() * 10 / 10, 10), 50)
danaPump.lowReservoirRate = min(max(binding.lowreservoir.value.toInt() * 10 / 10, 10), 50)
commandQueue.setUserOptions(object : Callback() {
override fun run() {

View file

@ -13,7 +13,7 @@
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/danar_buttons"
android:layout_above="@+id/buttons"
android:fillViewport="true">
<LinearLayout
@ -66,7 +66,7 @@
android:textSize="14sp" />
<TextView
android:id="@+id/danar_serialnumber"
android:id="@+id/serial_number"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
@ -112,7 +112,7 @@
android:textSize="14sp" />
<com.joanzapata.iconify.widget.IconTextView
android:id="@+id/danar_btconnection"
android:id="@+id/btconnection"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
@ -126,7 +126,7 @@
</LinearLayout>
<TextView
android:id="@+id/danar_queue"
android:id="@+id/queue"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="content"
@ -166,7 +166,7 @@
android:textSize="14sp" />
<com.joanzapata.iconify.widget.IconTextView
android:id="@+id/danar_battery"
android:id="@+id/battery"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
@ -212,7 +212,7 @@
android:textSize="14sp" />
<TextView
android:id="@+id/danar_lastconnection"
android:id="@+id/lastconnection"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
@ -257,7 +257,7 @@
android:textSize="14sp" />
<TextView
android:id="@+id/danar_lastbolus"
android:id="@+id/lastbolus"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
@ -302,7 +302,7 @@
android:textSize="14sp" />
<TextView
android:id="@+id/danar_dailyunits"
android:id="@+id/dailyunits"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
@ -347,7 +347,7 @@
android:textSize="14sp" />
<TextView
android:id="@+id/danar_basabasalrate"
android:id="@+id/basabasalrate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
@ -392,7 +392,7 @@
android:textSize="14sp" />
<TextView
android:id="@+id/danar_tempbasal"
android:id="@+id/tempbasal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
@ -437,7 +437,7 @@
android:textSize="14sp" />
<TextView
android:id="@+id/danar_extendedbolus"
android:id="@+id/extendedbolus"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
@ -482,7 +482,7 @@
android:textSize="14sp" />
<TextView
android:id="@+id/danar_reservoir"
android:id="@+id/reservoir"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
@ -527,7 +527,7 @@
android:textSize="14sp" />
<TextView
android:id="@+id/danar_iob"
android:id="@+id/iob"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
@ -572,7 +572,7 @@
android:textSize="14sp" />
<TextView
android:id="@+id/danar_basalstep"
android:id="@+id/basalstep"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
@ -617,7 +617,7 @@
android:textSize="14sp" />
<TextView
android:id="@+id/danar_bolusstep"
android:id="@+id/bolusstep"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
@ -662,7 +662,7 @@
android:textSize="14sp" />
<TextView
android:id="@+id/danar_firmware"
android:id="@+id/firmware"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
@ -687,7 +687,7 @@
</ScrollView>
<LinearLayout
android:id="@+id/danar_buttons"
android:id="@+id/buttons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
@ -699,7 +699,7 @@
android:orientation="horizontal">
<Button
android:id="@+id/danar_viewprofile"
android:id="@+id/viewprofile"
style="@style/ButtonSmallFontStyle"
android:layout_width="match_parent"
android:layout_height="match_parent"
@ -711,7 +711,7 @@
<Button
android:id="@+id/danar_history"
android:id="@+id/history"
style="@style/ButtonSmallFontStyle"
android:layout_width="match_parent"
android:layout_height="match_parent"
@ -722,7 +722,7 @@
android:text="@string/pumphistory" />
<Button
android:id="@+id/danar_stats"
android:id="@+id/stats"
style="@style/ButtonSmallFontStyle"
android:layout_width="match_parent"
android:layout_height="match_parent"
@ -733,7 +733,7 @@
android:text="@string/stats" />
<Button
android:id="@+id/danar_user_options"
android:id="@+id/user_options"
style="@style/ButtonSmallFontStyle"
android:layout_width="match_parent"
android:layout_height="match_parent"

View file

@ -8,7 +8,7 @@
<RelativeLayout
android:id="@+id/danar_header"
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
@ -40,12 +40,12 @@
android:id="@+id/spacer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/danar_header"
android:layout_below="@+id/header"
android:orientation="horizontal"
android:padding="5dp" />
<LinearLayout
android:id="@+id/danar_history_spinner_layout"
android:id="@+id/spinner_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/spacer"
@ -60,7 +60,7 @@
android:textAppearance="?android:attr/textAppearanceSmall" />
<Spinner
android:id="@+id/danar_history_spinner"
android:id="@+id/spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="20dp" />
@ -68,22 +68,22 @@
</LinearLayout>
<TextView
android:id="@+id/danar_history_status"
android:id="@+id/status"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/danar_history_spinner_layout"
android:layout_below="@id/spinner_layout"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/danar_history_recyclerview"
android:id="@+id/recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/danar_history_reload"
android:layout_below="@+id/danar_history_status" />
android:layout_above="@id/reload"
android:layout_below="@+id/status" />
<Button
android:id="@+id/danar_history_reload"
android:id="@+id/reload"
style="@style/Widget.AppCompat.Button"
android:layout_width="match_parent"
android:layout_height="wrap_content"

View file

@ -15,7 +15,7 @@
android:orientation="vertical">
<RelativeLayout
android:id="@+id/danar_header"
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
@ -50,7 +50,7 @@
android:padding="5dp" />
<Switch
android:id="@+id/danar_timeformat"
android:id="@+id/timeformat"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
@ -70,7 +70,7 @@
android:background="@color/listdelimiter" />
<Switch
android:id="@+id/danar_buttonscroll"
android:id="@+id/buttonscroll"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
@ -89,7 +89,7 @@
android:background="@color/listdelimiter" />
<Switch
android:id="@+id/danar_beep"
android:id="@+id/beep"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
@ -123,26 +123,26 @@
android:textSize="14sp" />
<RadioGroup
android:id="@+id/danar_pumpalarm"
android:id="@+id/pumpalarm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checkedButton="@+id/danar_pumpalarm_sound"
android:checkedButton="@+id/pumpalarm_sound"
android:orientation="horizontal">
<RadioButton
android:id="@+id/danar_pumpalarm_sound"
android:id="@+id/pumpalarm_sound"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/danar_pumpalarm_sound" />
<RadioButton
android:id="@+id/danar_pumpalarm_vibrate"
android:id="@+id/pumpalarm_vibrate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/danar_pumpalarm_vibrate" />
<RadioButton
android:id="@+id/danar_pumpalarm_both"
android:id="@+id/pumpalarm_both"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/danar_pumpalarm_both" />
@ -177,7 +177,7 @@
android:textSize="14sp" />
<info.nightscout.androidaps.utils.ui.NumberPicker
android:id="@+id/danar_screentimeout"
android:id="@+id/screentimeout"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_gravity="end"
@ -214,7 +214,7 @@
android:textSize="14sp" />
<info.nightscout.androidaps.utils.ui.NumberPicker
android:id="@+id/danar_backlight"
android:id="@+id/backlight"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_gravity="end"
@ -233,7 +233,7 @@
android:background="@color/listdelimiter" />
<Switch
android:id="@+id/danar_units"
android:id="@+id/units"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
@ -270,7 +270,7 @@
android:textSize="14sp" />
<info.nightscout.androidaps.utils.ui.NumberPicker
android:id="@+id/danar_shutdown"
android:id="@+id/shutdown"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_gravity="end"
@ -307,7 +307,7 @@
android:textSize="14sp" />
<info.nightscout.androidaps.utils.ui.NumberPicker
android:id="@+id/danar_lowreservoir"
android:id="@+id/lowreservoir"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_gravity="end"

View file

@ -1,6 +1,5 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
android {
@ -19,7 +18,9 @@ android {
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures {
viewBinding true
}
buildTypes {
release {
minifyEnabled false

View file

@ -1,6 +1,5 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
android {
@ -19,7 +18,9 @@ android {
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures {
viewBinding true
}
buildTypes {
release {
minifyEnabled false

View file

@ -15,11 +15,11 @@ import android.widget.BaseAdapter
import android.widget.TextView
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity
import info.nightscout.androidaps.danars.R
import info.nightscout.androidaps.danars.databinding.DanarsBlescannerActivityBinding
import info.nightscout.androidaps.danars.events.EventDanaRSDeviceChange
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.pump.common.ble.BlePreCheck
import info.nightscout.androidaps.utils.sharedPreferences.SP
import kotlinx.android.synthetic.main.danars_blescanner_activity.*
import java.util.*
import java.util.regex.Pattern
import javax.inject.Inject
@ -34,17 +34,20 @@ class BLEScanActivity : NoSplashAppCompatActivity() {
private val devices = ArrayList<BluetoothDeviceItem>()
private var bluetoothLeScanner: BluetoothLeScanner? = null
private lateinit var binding: DanarsBlescannerActivityBinding
@SuppressLint("SourceLockedOrientationActivity")
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.danars_blescanner_activity)
binding = DanarsBlescannerActivityBinding.inflate(layoutInflater)
setContentView(binding.root)
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
blePreCheck.prerequisitesCheck(this)
listAdapter = ListAdapter()
danars_blescanner_listview.emptyView = findViewById(R.id.danars_blescanner_nodevice)
danars_blescanner_listview.adapter = listAdapter
binding.blescannerListview.emptyView = binding.blescannerNodevice
binding.blescannerListview.adapter = listAdapter
listAdapter?.notifyDataSetChanged()
}
@ -115,7 +118,7 @@ class BLEScanActivity : NoSplashAppCompatActivity() {
return v!!
}
private inner class ViewHolder internal constructor(v: View) : View.OnClickListener {
private inner class ViewHolder(v: View) : View.OnClickListener {
private lateinit var item: BluetoothDeviceItem
private val name: TextView = v.findViewById(R.id.ble_name)

View file

@ -3,11 +3,12 @@ package info.nightscout.androidaps.danars.activities
import android.os.Bundle
import android.util.Base64
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity
import info.nightscout.androidaps.danars.DanaRSPlugin
import info.nightscout.androidaps.danars.R
import info.nightscout.androidaps.danars.databinding.DanarsEnterPinActivityBinding
import info.nightscout.androidaps.danars.services.BLEComm
import info.nightscout.androidaps.events.EventPumpStatusChanged
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.danars.DanaRSPlugin
import info.nightscout.androidaps.danars.services.BLEComm
import info.nightscout.androidaps.utils.FabricPrivacy
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
import info.nightscout.androidaps.utils.extensions.hexStringToByteArray
@ -17,8 +18,6 @@ import info.nightscout.androidaps.utils.textValidator.DefaultEditTextValidator
import info.nightscout.androidaps.utils.textValidator.EditTextValidator
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.CompositeDisposable
import kotlinx.android.synthetic.main.danars_enter_pin_activity.*
import kotlinx.android.synthetic.main.okcancel.*
import javax.inject.Inject
import kotlin.experimental.xor
@ -33,25 +32,28 @@ class EnterPinActivity : NoSplashAppCompatActivity() {
private val disposable = CompositeDisposable()
private lateinit var binding: DanarsEnterPinActivityBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.danars_enter_pin_activity)
binding = DanarsEnterPinActivityBinding.inflate(layoutInflater)
setContentView(binding.root)
val p1 = DefaultEditTextValidator(rs_v3_pin1, this)
val p1 = DefaultEditTextValidator(binding.rsV3Pin1, this)
.setTestErrorString(resourceHelper.gs(R.string.error_mustbe12hexadidits), this)
.setCustomRegexp(resourceHelper.gs(R.string.twelvehexanumber), this)
.setTestType(EditTextValidator.TEST_REGEXP, this)
val p2 = DefaultEditTextValidator(rs_v3_pin2, this)
val p2 = DefaultEditTextValidator(binding.rsV3Pin2, this)
.setTestErrorString(resourceHelper.gs(R.string.error_mustbe8hexadidits), this)
.setCustomRegexp(resourceHelper.gs(R.string.eighthexanumber), this)
.setTestType(EditTextValidator.TEST_REGEXP, this)
ok.setOnClickListener {
binding.okcancel.ok.setOnClickListener {
if (p1.testValidity(false) && p2.testValidity(false)) {
val result = checkPairingCheckSum(
rs_v3_pin1.text.toString().hexStringToByteArray(),
rs_v3_pin2.text.toString().substring(0..5).hexStringToByteArray(),
rs_v3_pin2.text.toString().substring(6..7).hexStringToByteArray())
binding.rsV3Pin1.text.toString().hexStringToByteArray(),
binding.rsV3Pin2.text.toString().substring(0..5).hexStringToByteArray(),
binding.rsV3Pin2.text.toString().substring(6..7).hexStringToByteArray())
if (result) {
bleComm.finishV3Pairing()
finish()
@ -59,7 +61,7 @@ class EnterPinActivity : NoSplashAppCompatActivity() {
else OKDialog.show(this, resourceHelper.gs(R.string.error), resourceHelper.gs(R.string.invalidinput))
}
}
cancel.setOnClickListener { finish() }
binding.okcancel.cancel.setOnClickListener { finish() }
}
override fun onResume() {

View file

@ -16,7 +16,7 @@ class PairingHelperActivity : NoSplashAppCompatActivity() {
dialog = PairingProgressDialog()
.setHelperActivity(this)
dialog?.show(supportFragmentManager, "PairingProgress")
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
}
override fun onDestroy() {

View file

@ -1,7 +1,6 @@
package info.nightscout.androidaps.danars.dialogs;
import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.os.HandlerThread;
@ -10,9 +9,6 @@ import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.ProgressBar;
import android.widget.TextView;
import androidx.fragment.app.FragmentActivity;
@ -20,6 +16,7 @@ import javax.inject.Inject;
import dagger.android.support.DaggerDialogFragment;
import info.nightscout.androidaps.danars.R;
import info.nightscout.androidaps.danars.databinding.DanarsPairingProgressDialogBinding;
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
import info.nightscout.androidaps.danars.activities.PairingHelperActivity;
import info.nightscout.androidaps.danars.events.EventDanaRSPairingSuccess;
@ -37,9 +34,6 @@ public class PairingProgressDialog extends DaggerDialogFragment {
private CompositeDisposable disposable = new CompositeDisposable();
private TextView statusView;
private ProgressBar progressBar;
private Button button;
private PairingHelperActivity helperActivity;
private static boolean pairingEnded = false;
@ -49,6 +43,8 @@ public class PairingProgressDialog extends DaggerDialogFragment {
private static Runnable runnable;
private DanarsPairingProgressDialogBinding binding;
public PairingProgressDialog() {
super();
// Required empty public constructor
@ -64,8 +60,8 @@ public class PairingProgressDialog extends DaggerDialogFragment {
FragmentActivity activity = getActivity();
if (activity != null) {
activity.runOnUiThread(() -> {
progressBar.setProgress(100);
statusView.setText(R.string.danars_pairingok);
binding.danarsPairingprogressProgressbar.setProgress(100);
binding.danarsPairingprogressStatus.setText(R.string.danars_pairingok);
try {
Thread.sleep(1000);
} catch (InterruptedException ignored) {
@ -76,7 +72,7 @@ public class PairingProgressDialog extends DaggerDialogFragment {
dismiss();
return;
}
progressBar.setProgress(i * 5);
binding.danarsPairingprogressProgressbar.setProgress(i * 5);
try {
Thread.sleep(1000);
} catch (InterruptedException ignored) {
@ -85,9 +81,9 @@ public class PairingProgressDialog extends DaggerDialogFragment {
FragmentActivity activity = getActivity();
if (activity != null) {
activity.runOnUiThread(() -> {
progressBar.setProgress(100);
statusView.setText(R.string.danars_pairingtimedout);
button.setVisibility(View.VISIBLE);
binding.danarsPairingprogressProgressbar.setProgress(100);
binding.danarsPairingprogressStatus.setText(R.string.danars_pairingtimedout);
binding.ok.setVisibility(View.VISIBLE);
});
}
};
@ -97,20 +93,16 @@ public class PairingProgressDialog extends DaggerDialogFragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.danars_pairingprogressdialog, container, false);
binding = DanarsPairingProgressDialogBinding.inflate(inflater, container, false);
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
setCancelable(false);
getDialog().setCanceledOnTouchOutside(false);
statusView = view.findViewById(R.id.danars_pairingprogress_status);
progressBar = view.findViewById(R.id.danars_pairingprogress_progressbar);
button = view.findViewById(R.id.ok);
setViews();
return view;
return binding.getRoot();
}
@Override
@ -140,11 +132,11 @@ public class PairingProgressDialog extends DaggerDialogFragment {
}
private void setViews() {
progressBar.setMax(100);
progressBar.setProgress(0);
statusView.setText(resourceHelper.gs(R.string.danars_waitingforpairing));
button.setVisibility(View.GONE);
button.setOnClickListener(v -> dismiss());
binding.danarsPairingprogressProgressbar.setMax(100);
binding.danarsPairingprogressProgressbar.setProgress(0);
binding.danarsPairingprogressStatus.setText(resourceHelper.gs(R.string.danars_waitingforpairing));
binding.ok.setVisibility(View.GONE);
binding.ok.setOnClickListener(v -> dismiss());
handler.post(runnable);
}

View file

@ -35,12 +35,12 @@
</RelativeLayout>
<ListView
android:id="@+id/danars_blescanner_listview"
android:id="@+id/blescanner_listview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<TextView
android:id="@+id/danars_blescanner_nodevice"
android:id="@+id/blescanner_nodevice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"

View file

@ -86,6 +86,8 @@
android:text="@string/press_ok_on_the_pump"
android:textAppearance="@style/TextAppearance.AppCompat.Large" />
<include layout="@layout/okcancel" />
<include
android:id="@+id/okcancel"
layout="@layout/okcancel" />
</LinearLayout>

View file

@ -1,44 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2013 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/done_background"
android:layout_width="match_parent"
android:layout_height="56dp"
android:orientation="horizontal"
android:background="@android:color/transparent"
android:gravity="end|right"
android:layout_gravity="center_vertical"
android:paddingBottom="8dp">
<Button
android:id="@+id/cancel"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_marginRight="8dp"
android:layout_marginEnd="8dp"
style="@style/mdtp_ActionButton.Text"
android:text="@string/cancel" />
<Button
android:id="@+id/ok"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="16dp"
android:layout_marginEnd="16dp"
style="@style/mdtp_ActionButton.Text"
android:text="@string/ok" />
</LinearLayout>
<!-- From: file:/Users/wdullaer/Documents/Programming%20Projects/MaterialDateTimePicker/library/src/main/res/layout/mdtp_done_button.xml -->