diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/wearintegration/DataHandlerMobile.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/wearintegration/DataHandlerMobile.kt index 25017bfa3b..4ddbd962cd 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/wearintegration/DataHandlerMobile.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/wearintegration/DataHandlerMobile.kt @@ -697,10 +697,10 @@ class DataHandlerMobile @Inject constructor( bolusPercentage = sp.getInt(R.string.key_boluswizard_percentage, 100), maxCarbs = sp.getInt(R.string.key_treatmentssafety_maxcarbs, 48), maxBolus = sp.getDouble(R.string.key_treatmentssafety_maxbolus, 3.0), - insulin_button_increment_1 = sp.getDouble(R.string.key_insulin_button_increment_1, InsulinDialog.PLUS1_DEFAULT), - insulin_button_increment_2 = sp.getDouble(R.string.key_insulin_button_increment_2, InsulinDialog.PLUS2_DEFAULT), - carbs_button_increment_1 = sp.getInt(R.string.key_carbs_button_increment_1, CarbsDialog.FAV1_DEFAULT), - carbs_button_increment_2 = sp.getInt(R.string.key_carbs_button_increment_2, CarbsDialog.FAV2_DEFAULT) + insulinButtonIncrement1 = sp.getDouble(R.string.key_insulin_button_increment_1, InsulinDialog.PLUS1_DEFAULT), + insulinButtonIncrement2 = sp.getDouble(R.string.key_insulin_button_increment_2, InsulinDialog.PLUS2_DEFAULT), + carbsButtonIncrement1 = sp.getInt(R.string.key_carbs_button_increment_1, CarbsDialog.FAV1_DEFAULT), + carbsButtonIncrement2 = sp.getInt(R.string.key_carbs_button_increment_2, CarbsDialog.FAV2_DEFAULT) ) ) ) diff --git a/shared/src/main/java/info/nightscout/shared/weardata/EventData.kt b/shared/src/main/java/info/nightscout/shared/weardata/EventData.kt index bd0d06711b..b0fe71d4aa 100644 --- a/shared/src/main/java/info/nightscout/shared/weardata/EventData.kt +++ b/shared/src/main/java/info/nightscout/shared/weardata/EventData.kt @@ -209,10 +209,10 @@ sealed class EventData : Event() { val bolusPercentage: Int, val maxCarbs: Int, val maxBolus: Double, - val insulin_button_increment_1: Double, - val insulin_button_increment_2: Double, - val carbs_button_increment_1: Int, - val carbs_button_increment_2: Int + val insulinButtonIncrement1: Double, + val insulinButtonIncrement2: Double, + val carbsButtonIncrement1: Int, + val carbsButtonIncrement2: Int ) : EventData() @Serializable diff --git a/wear/src/main/java/info/nightscout/androidaps/comm/DataHandlerWear.kt b/wear/src/main/java/info/nightscout/androidaps/comm/DataHandlerWear.kt index 3a05c06cf0..321ccefeeb 100644 --- a/wear/src/main/java/info/nightscout/androidaps/comm/DataHandlerWear.kt +++ b/wear/src/main/java/info/nightscout/androidaps/comm/DataHandlerWear.kt @@ -162,10 +162,10 @@ class DataHandlerWear @Inject constructor( sp.putInt(R.string.key_bolus_wizard_percentage, it.bolusPercentage) sp.putInt(R.string.key_treatments_safety_max_carbs, it.maxCarbs) sp.putDouble(R.string.key_treatments_safety_max_bolus, it.maxBolus) - sp.putDouble(R.string.key_insulin_button_increment_1, it.insulin_button_increment_1) - sp.putDouble(R.string.key_insulin_button_increment_2, it.insulin_button_increment_2) - sp.putInt(R.string.key_carbs_button_increment_1, it.carbs_button_increment_1) - sp.putInt(R.string.key_carbs_button_increment_2, it.carbs_button_increment_2) + sp.putDouble(R.string.key_insulin_button_increment_1, it.insulinButtonIncrement1) + sp.putDouble(R.string.key_insulin_button_increment_2, it.insulinButtonIncrement2) + sp.putInt(R.string.key_carbs_button_increment_1, it.carbsButtonIncrement1) + sp.putInt(R.string.key_carbs_button_increment_2, it.carbsButtonIncrement2) } disposable += rxBus .toObservable(EventData.QuickWizard::class.java) diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/TempTargetActivity.kt b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/TempTargetActivity.kt index 26570a6bdd..80180d850a 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/TempTargetActivity.kt +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/TempTargetActivity.kt @@ -74,7 +74,6 @@ class TempTargetActivity : ViewSelectorActivity() { if (lowRange != null) def = SafeParse.stringToDouble(lowRange?.editText?.text.toString()) lowRange = PlusMinusEditText(viewAdapter, def, 4.0, 10.0, 0.1, DecimalFormat("#0.0"), false, title) } - container.addView(view) view } diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/utils/EditPlusMinusViewAdapter.kt b/wear/src/main/java/info/nightscout/androidaps/interaction/utils/EditPlusMinusViewAdapter.kt index df13d69b8a..4bb22f95e4 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/utils/EditPlusMinusViewAdapter.kt +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/utils/EditPlusMinusViewAdapter.kt @@ -14,7 +14,7 @@ import info.nightscout.androidaps.databinding.ActionEditplusminViktoriaBinding import info.nightscout.shared.sharedPreferences.SP /** - * EditPlusMinusViewAdapter binds both ActionEditplusminusItemBinding variants shared attributes to one common view adapter. + * EditPlusMinusViewAdapter binds both ActionEditplusminBinding variants shared attributes to one common view adapter. * Requires at least one of the ViewBinding as a parameter. Recommended to use the factory object to create the binding. */ class EditPlusMinusViewAdapter( @@ -32,28 +32,28 @@ class EditPlusMinusViewAdapter( throw IllegalArgumentException("Require at least on Binding parameter") } } - + private val errorMessage = "Missing require View Binding parameter" val editText = eD?.editText ?: eDP?.editText ?: eQL?.editText ?: eQLP?.editText ?: eQR?.editText ?: eQRP?.editText ?: eV?.editText - ?: throw IllegalArgumentException("Missing require View Binding parameter display") + ?: throw IllegalArgumentException(errorMessage) val minButton = eD?.minButton ?: eDP?.minButton ?: eQL?.minButton ?: eQLP?.minButton ?: eQR?.minButton ?: eQRP?.minButton ?: eV?.minButton - ?: throw IllegalArgumentException("Missing require View Binding parameter display") + ?: throw IllegalArgumentException(errorMessage) val plusButton1 = eD?.plusButton1 ?: eDP?.plusButton1 ?: eQL?.plusButton1 ?: eQLP?.plusButton1 ?: eQR?.plusButton1 ?: eQRP?.plusButton1 ?: eV?.plusButton1 - ?: throw IllegalArgumentException("Missing require View Binding parameter display") + ?: throw IllegalArgumentException(errorMessage) val label = eD?.label ?: eDP?.label ?: eQL?.label ?: eQLP?.label ?: eQR?.label ?: eQRP?.label ?: eV?.label - ?: throw IllegalArgumentException("Missing require View Binding parameter display") + ?: throw IllegalArgumentException(errorMessage) val plusButton2 = eDP?.plusButton2 ?: eQLP?.plusButton2 ?: eQRP?.plusButton2 val plusButton3 = eDP?.plusButton3 ?: eQLP?.plusButton3 ?: eQRP?.plusButton3 val root = eD?.root ?: eDP?.root ?: eQL?.root ?: eQLP?.root ?: eQR?.root ?: eQRP?.root ?: eV?.root - ?: throw IllegalArgumentException("Missing require View Binding parameter display") + ?: throw IllegalArgumentException(errorMessage) companion object { - fun getViewAdapter(sp: SP, context: Context, container: ViewGroup?, multiple: Boolean = false): EditPlusMinusViewAdapter { + fun getViewAdapter(sp: SP, context: Context, container: ViewGroup, multiple: Boolean = false): EditPlusMinusViewAdapter { val inflater = LayoutInflater.from(context) return when (sp.getInt(R.string.key_input_design, 1)) { diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/utils/PlusMinusEditText.kt b/wear/src/main/java/info/nightscout/androidaps/interaction/utils/PlusMinusEditText.kt index f3af7a89eb..d6933c1a13 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/utils/PlusMinusEditText.kt +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/utils/PlusMinusEditText.kt @@ -1,6 +1,5 @@ package info.nightscout.androidaps.interaction.utils -import android.annotation.SuppressLint import android.content.Context import android.os.* import android.view.KeyEvent @@ -20,7 +19,7 @@ import java.util.concurrent.TimeUnit /** * Created by mike on 28.06.2016. */ -@SuppressLint("SetTextI18n") class PlusMinusEditText @JvmOverloads constructor( +class PlusMinusEditText @JvmOverloads constructor( private val binding: EditPlusMinusViewAdapter, initValue: Double, private val minValue: Double, @@ -106,9 +105,7 @@ import java.util.concurrent.TimeUnit private fun vibrateDevice() { val vibrator = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { - val vibratorManager = - binding.root.context.getSystemService(Context.VIBRATOR_MANAGER_SERVICE) as VibratorManager - vibratorManager.defaultVibrator + (binding.root.context.getSystemService(Context.VIBRATOR_MANAGER_SERVICE) as VibratorManager).defaultVibrator } else { @Suppress("DEPRECATION") binding.root.context.getSystemService(Context.VIBRATOR_SERVICE) as Vibrator