rounded dialogs like in android 12

This commit is contained in:
osodebailar 2022-03-23 16:25:02 +01:00 committed by Andries Smit
parent 884947331b
commit 91467b1f49
20 changed files with 75 additions and 14 deletions

View file

@ -27,7 +27,6 @@ import javax.inject.Inject
class CalibrationDialog : DialogFragmentWithDate() { class CalibrationDialog : DialogFragmentWithDate() {
@Inject lateinit var injector: HasAndroidInjector @Inject lateinit var injector: HasAndroidInjector
@Inject lateinit var rh: ResourceHelper
@Inject lateinit var profileFunction: ProfileFunction @Inject lateinit var profileFunction: ProfileFunction
@Inject lateinit var xDripBroadcast: XDripBroadcast @Inject lateinit var xDripBroadcast: XDripBroadcast
@Inject lateinit var uel: UserEntryLogger @Inject lateinit var uel: UserEntryLogger

View file

@ -41,7 +41,6 @@ import kotlin.math.max
class CarbsDialog : DialogFragmentWithDate() { class CarbsDialog : DialogFragmentWithDate() {
@Inject lateinit var ctx: Context @Inject lateinit var ctx: Context
@Inject lateinit var rh: ResourceHelper
@Inject lateinit var constraintChecker: ConstraintChecker @Inject lateinit var constraintChecker: ConstraintChecker
@Inject lateinit var defaultValueHelper: DefaultValueHelper @Inject lateinit var defaultValueHelper: DefaultValueHelper
@Inject lateinit var profileFunction: ProfileFunction @Inject lateinit var profileFunction: ProfileFunction

View file

@ -41,7 +41,6 @@ class CareDialog : DialogFragmentWithDate() {
@Inject lateinit var injector: HasAndroidInjector @Inject lateinit var injector: HasAndroidInjector
@Inject lateinit var ctx: Context @Inject lateinit var ctx: Context
@Inject lateinit var rh: ResourceHelper
@Inject lateinit var profileFunction: ProfileFunction @Inject lateinit var profileFunction: ProfileFunction
@Inject lateinit var translator: Translator @Inject lateinit var translator: Translator
@Inject lateinit var uel: UserEntryLogger @Inject lateinit var uel: UserEntryLogger

View file

@ -35,7 +35,6 @@ import kotlin.math.abs
class ExtendedBolusDialog : DialogFragmentWithDate() { class ExtendedBolusDialog : DialogFragmentWithDate() {
@Inject lateinit var ctx: Context @Inject lateinit var ctx: Context
@Inject lateinit var rh: ResourceHelper
@Inject lateinit var constraintChecker: ConstraintChecker @Inject lateinit var constraintChecker: ConstraintChecker
@Inject lateinit var commandQueue: CommandQueue @Inject lateinit var commandQueue: CommandQueue
@Inject lateinit var activePlugin: ActivePlugin @Inject lateinit var activePlugin: ActivePlugin

View file

@ -41,7 +41,6 @@ import kotlin.math.abs
class FillDialog : DialogFragmentWithDate() { class FillDialog : DialogFragmentWithDate() {
@Inject lateinit var constraintChecker: ConstraintChecker @Inject lateinit var constraintChecker: ConstraintChecker
@Inject lateinit var rh: ResourceHelper
@Inject lateinit var ctx: Context @Inject lateinit var ctx: Context
@Inject lateinit var commandQueue: CommandQueue @Inject lateinit var commandQueue: CommandQueue
@Inject lateinit var activePlugin: ActivePlugin @Inject lateinit var activePlugin: ActivePlugin

View file

@ -44,7 +44,6 @@ import kotlin.math.max
class InsulinDialog : DialogFragmentWithDate() { class InsulinDialog : DialogFragmentWithDate() {
@Inject lateinit var constraintChecker: ConstraintChecker @Inject lateinit var constraintChecker: ConstraintChecker
@Inject lateinit var rh: ResourceHelper
@Inject lateinit var defaultValueHelper: DefaultValueHelper @Inject lateinit var defaultValueHelper: DefaultValueHelper
@Inject lateinit var profileFunction: ProfileFunction @Inject lateinit var profileFunction: ProfileFunction
@Inject lateinit var commandQueue: CommandQueue @Inject lateinit var commandQueue: CommandQueue

View file

@ -46,7 +46,6 @@ import kotlin.collections.ArrayList
class ProfileSwitchDialog : DialogFragmentWithDate() { class ProfileSwitchDialog : DialogFragmentWithDate() {
@Inject lateinit var rh: ResourceHelper
@Inject lateinit var profileFunction: ProfileFunction @Inject lateinit var profileFunction: ProfileFunction
@Inject lateinit var activePlugin: ActivePlugin @Inject lateinit var activePlugin: ActivePlugin
@Inject lateinit var repository: AppRepository @Inject lateinit var repository: AppRepository

View file

@ -33,7 +33,6 @@ import kotlin.math.abs
class TempBasalDialog : DialogFragmentWithDate() { class TempBasalDialog : DialogFragmentWithDate() {
@Inject lateinit var constraintChecker: ConstraintChecker @Inject lateinit var constraintChecker: ConstraintChecker
@Inject lateinit var rh: ResourceHelper
@Inject lateinit var profileFunction: ProfileFunction @Inject lateinit var profileFunction: ProfileFunction
@Inject lateinit var activePlugin: ActivePlugin @Inject lateinit var activePlugin: ActivePlugin
@Inject lateinit var commandQueue: CommandQueue @Inject lateinit var commandQueue: CommandQueue

View file

@ -42,7 +42,6 @@ import javax.inject.Inject
class TempTargetDialog : DialogFragmentWithDate() { class TempTargetDialog : DialogFragmentWithDate() {
@Inject lateinit var constraintChecker: ConstraintChecker @Inject lateinit var constraintChecker: ConstraintChecker
@Inject lateinit var rh: ResourceHelper
@Inject lateinit var profileFunction: ProfileFunction @Inject lateinit var profileFunction: ProfileFunction
@Inject lateinit var defaultValueHelper: DefaultValueHelper @Inject lateinit var defaultValueHelper: DefaultValueHelper
@Inject lateinit var uel: UserEntryLogger @Inject lateinit var uel: UserEntryLogger

View file

@ -43,7 +43,6 @@ import kotlin.math.abs
class TreatmentDialog : DialogFragmentWithDate() { class TreatmentDialog : DialogFragmentWithDate() {
@Inject lateinit var constraintChecker: ConstraintChecker @Inject lateinit var constraintChecker: ConstraintChecker
@Inject lateinit var rh: ResourceHelper
@Inject lateinit var activePlugin: ActivePlugin @Inject lateinit var activePlugin: ActivePlugin
@Inject lateinit var commandQueue: CommandQueue @Inject lateinit var commandQueue: CommandQueue
@Inject lateinit var ctx: Context @Inject lateinit var ctx: Context

View file

@ -2,6 +2,9 @@ package info.nightscout.androidaps.dialogs
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.content.Context import android.content.Context
import android.graphics.PorterDuff
import android.graphics.PorterDuffColorFilter
import android.graphics.drawable.Drawable
import android.os.Bundle import android.os.Bundle
import android.text.Editable import android.text.Editable
import android.text.TextWatcher import android.text.TextWatcher
@ -13,6 +16,7 @@ import android.view.WindowManager
import android.widget.AdapterView import android.widget.AdapterView
import android.widget.ArrayAdapter import android.widget.ArrayAdapter
import android.widget.CompoundButton import android.widget.CompoundButton
import androidx.core.content.ContextCompat
import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentManager
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import dagger.android.support.DaggerDialogFragment import dagger.android.support.DaggerDialogFragment
@ -120,6 +124,11 @@ class WizardDialog : DaggerDialogFragment() {
isCancelable = true isCancelable = true
dialog?.setCanceledOnTouchOutside(false) dialog?.setCanceledOnTouchOutside(false)
val drawable: Drawable? = context?.let { ContextCompat.getDrawable(it, info.nightscout.androidaps.core.R.drawable.dialog) }
drawable?.setColorFilter(PorterDuffColorFilter((context?.let { rh.gac(it, info.nightscout.androidaps.core.R.attr.dialogFragmentBackground) }!!), PorterDuff.Mode.SRC_IN))
dialog?.window?.setBackgroundDrawable(drawable)
_binding = DialogWizardBinding.inflate(inflater, container, false) _binding = DialogWizardBinding.inflate(inflater, container, false)
return binding.root return binding.root
} }

View file

@ -13,8 +13,6 @@ import javax.inject.Inject
class ChooseOperationDialog : DialogFragmentWithDate() { class ChooseOperationDialog : DialogFragmentWithDate() {
@Inject lateinit var rh: ResourceHelper
private var checkedIndex = -1 private var checkedIndex = -1
private var _binding: AutomationDialogChooseOperationBinding? = null private var _binding: AutomationDialogChooseOperationBinding? = null

View file

@ -1,5 +1,9 @@
package info.nightscout.androidaps.dialogs package info.nightscout.androidaps.dialogs
import android.content.Context
import android.graphics.PorterDuff
import android.graphics.PorterDuffColorFilter
import android.graphics.drawable.Drawable
import android.os.Bundle import android.os.Bundle
import android.os.SystemClock import android.os.SystemClock
import android.view.LayoutInflater import android.view.LayoutInflater
@ -7,6 +11,7 @@ import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.view.Window import android.view.Window
import android.view.WindowManager import android.view.WindowManager
import androidx.core.content.ContextCompat
import dagger.android.support.DaggerDialogFragment import dagger.android.support.DaggerDialogFragment
import info.nightscout.androidaps.activities.BolusProgressHelperActivity import info.nightscout.androidaps.activities.BolusProgressHelperActivity
import info.nightscout.androidaps.core.R import info.nightscout.androidaps.core.R
@ -24,6 +29,7 @@ import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewB
import info.nightscout.androidaps.utils.FabricPrivacy import info.nightscout.androidaps.utils.FabricPrivacy
import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.resources.ResourceHelper
import info.nightscout.androidaps.utils.rx.AapsSchedulers import info.nightscout.androidaps.utils.rx.AapsSchedulers
import info.nightscout.shared.sharedPreferences.SP
import io.reactivex.rxjava3.disposables.CompositeDisposable import io.reactivex.rxjava3.disposables.CompositeDisposable
import io.reactivex.rxjava3.kotlin.plusAssign import io.reactivex.rxjava3.kotlin.plusAssign
import javax.inject.Inject import javax.inject.Inject
@ -37,6 +43,7 @@ class BolusProgressDialog : DaggerDialogFragment() {
@Inject lateinit var fabricPrivacy: FabricPrivacy @Inject lateinit var fabricPrivacy: FabricPrivacy
@Inject lateinit var aapsSchedulers: AapsSchedulers @Inject lateinit var aapsSchedulers: AapsSchedulers
@Inject lateinit var uel: UserEntryLogger @Inject lateinit var uel: UserEntryLogger
@Inject lateinit var sp: SP
private val disposable = CompositeDisposable() private val disposable = CompositeDisposable()
@ -83,6 +90,15 @@ class BolusProgressDialog : DaggerDialogFragment() {
isCancelable = false isCancelable = false
dialog?.setCanceledOnTouchOutside(false) dialog?.setCanceledOnTouchOutside(false)
val drawable: Drawable? = context?.let { ContextCompat.getDrawable(it, R.drawable.dialog) }
if ( sp.getBoolean(R.string.key_use_dark_mode, true)) {
drawable?.setColorFilter(PorterDuffColorFilter((rh.gc(R.color.background_dark)), PorterDuff.Mode.SRC_IN))
} else {
drawable?.setColorFilter(PorterDuffColorFilter((rh.gc(R.color.background_light)), PorterDuff.Mode.SRC_IN))
}
dialog?.window?.setBackgroundDrawable(drawable)
_binding = DialogBolusprogressBinding.inflate(inflater, container, false) _binding = DialogBolusprogressBinding.inflate(inflater, container, false)
return binding.root return binding.root
} }

View file

@ -2,6 +2,9 @@ package info.nightscout.androidaps.dialogs
import android.app.DatePickerDialog import android.app.DatePickerDialog
import android.app.TimePickerDialog import android.app.TimePickerDialog
import android.graphics.PorterDuff
import android.graphics.PorterDuffColorFilter
import android.graphics.drawable.Drawable
import android.os.Bundle import android.os.Bundle
import android.text.format.DateFormat import android.text.format.DateFormat
import android.view.View import android.view.View
@ -10,6 +13,7 @@ import android.view.Window
import android.view.WindowManager import android.view.WindowManager
import android.widget.Button import android.widget.Button
import android.widget.TextView import android.widget.TextView
import androidx.core.content.ContextCompat
import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentManager
import dagger.android.support.DaggerDialogFragment import dagger.android.support.DaggerDialogFragment
import info.nightscout.androidaps.core.R import info.nightscout.androidaps.core.R
@ -17,6 +21,7 @@ import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag import info.nightscout.shared.logging.LTag
import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.extensions.toVisibility import info.nightscout.androidaps.extensions.toVisibility
import info.nightscout.androidaps.utils.resources.ResourceHelper
import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.sharedPreferences.SP
import java.util.* import java.util.*
import javax.inject.Inject import javax.inject.Inject
@ -26,6 +31,7 @@ abstract class DialogFragmentWithDate : DaggerDialogFragment() {
@Inject lateinit var aapsLogger: AAPSLogger @Inject lateinit var aapsLogger: AAPSLogger
@Inject lateinit var sp: SP @Inject lateinit var sp: SP
@Inject lateinit var dateUtil: DateUtil @Inject lateinit var dateUtil: DateUtil
@Inject lateinit var rh: ResourceHelper
fun interface OnValueChangedListener { fun interface OnValueChangedListener {
fun onValueChanged(value: Long) fun onValueChanged(value: Long)
@ -68,6 +74,11 @@ abstract class DialogFragmentWithDate : DaggerDialogFragment() {
dialog?.window?.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) dialog?.window?.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN)
isCancelable = true isCancelable = true
dialog?.setCanceledOnTouchOutside(false) dialog?.setCanceledOnTouchOutside(false)
val drawable: Drawable? = context?.let { ContextCompat.getDrawable(it, info.nightscout.androidaps.core.R.drawable.dialog) }
drawable?.setColorFilter(PorterDuffColorFilter((context?.let { rh.gac(it, info.nightscout.androidaps.core.R.attr.dialogFragmentBackground) }!!), PorterDuff.Mode.SRC_IN))
dialog?.window?.setBackgroundDrawable(drawable)
} }
fun updateDateTime(timeMs: Long) { fun updateDateTime(timeMs: Long) {

View file

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list
xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:right="10dp"
android:left="10dp"
android:bottom="10dp"
android:top="10dp"
>
<shape >
<padding
android:top="10dp"
android:bottom="2dp"
android:left="10dp"
android:right="10dp"
/>
<solid android:color="#303030" />
<corners android:radius="12dp" />
</shape>
</item>
</layer-list>

View file

@ -25,9 +25,13 @@
<color name="overviewPillColorDefault">#1c171c</color> <color name="overviewPillColorDefault">#1c171c</color>
<color name="colorOnPrimaryDefault">#FFFFFF</color> <color name="colorOnPrimaryDefault">#FFFFFF</color>
<color name="defaultbackground">#424242</color> <color name="defaultbackground">#000000</color>
<color name="defaulttextcolor">#B3FFFFFF</color> <color name="defaulttextcolor">#B3FFFFFF</color>
<!---Android Dark ans Light Theme Base colors-->
<color name="background_dark">#262626</color>
<color name="background_light">#FFFFFF</color>
<!-- Tabs--> <!-- Tabs-->
<color name="tabText">#d0d0d0</color> <color name="tabText">#d0d0d0</color>
<color name="tabSelectedText">@color/white</color> <color name="tabSelectedText">@color/white</color>

View file

@ -113,6 +113,9 @@
<item name="splashBackgroundColor">@color/splashBackground</item> <item name="splashBackgroundColor">@color/splashBackground</item>
<!---Application Background Color --> <!---Application Background Color -->
<item name="android:windowBackground">@color/black</item> <item name="android:windowBackground">@color/black</item>
<!---Dialogfragment Background Color -->
<item name="dialogFragmentBackground">@color/background_dark</item>
<item name="android:dialogCornerRadius">12dp</item>
</style> </style>
<style name="Theme.MaterialComponents.DayNight.DarkActionBar" parent="Theme.MaterialComponents.DayNight.Bridge"/> <style name="Theme.MaterialComponents.DayNight.DarkActionBar" parent="Theme.MaterialComponents.DayNight.Bridge"/>
@ -203,7 +206,7 @@
<!-- Alert Dialogs --> <!-- Alert Dialogs -->
<style name="DialogTheme" parent="ThemeOverlay.MaterialComponents.Dialog.Alert"> <style name="DialogTheme" parent="ThemeOverlay.MaterialComponents.Dialog.Alert">
<item name="backgroundColor">@color/dialog_title_background</item> <item name="backgroundColor">@color/background_dark</item>
<item name="buttonBarNegativeButtonStyle">@style/DialogOkCancelButtonStyle</item> <item name="buttonBarNegativeButtonStyle">@style/DialogOkCancelButtonStyle</item>
<item name="buttonBarPositiveButtonStyle">@style/DialogOkCancelButtonStyle</item> <item name="buttonBarPositiveButtonStyle">@style/DialogOkCancelButtonStyle</item>
<item name="buttonBarNeutralButtonStyle">@style/DialogOkCancelButtonStyle</item> <item name="buttonBarNeutralButtonStyle">@style/DialogOkCancelButtonStyle</item>

View file

@ -86,5 +86,7 @@
<attr name="splashBackgroundColor" format="reference|color" /> <attr name="splashBackgroundColor" format="reference|color" />
<!---Disabled Text Color --> <!---Disabled Text Color -->
<attr name="disabledTextColor" format="reference|color" /> <attr name="disabledTextColor" format="reference|color" />
<!---Dialogfragment Background Color -->
<attr name="dialogFragmentBackground" format="reference|color" />
</resources> </resources>

View file

@ -28,6 +28,10 @@
<color name="defaultbackground">#424242</color> <color name="defaultbackground">#424242</color>
<color name="defaulttextcolor">#B3FFFFFF</color> <color name="defaulttextcolor">#B3FFFFFF</color>
<!---Android Dark ans Light Theme Base colors-->
<color name="background_dark">#262626</color>
<color name="background_light">#FFFFFF</color>
<!-- Tabs--> <!-- Tabs-->
<color name="tabText">#d0d0d0</color> <color name="tabText">#d0d0d0</color>
<color name="tabSelectedText">@color/white</color> <color name="tabSelectedText">@color/white</color>

View file

@ -112,6 +112,9 @@
<item name="splashBackgroundColor">@color/splashBackground</item> <item name="splashBackgroundColor">@color/splashBackground</item>
<!---Application Background Color --> <!---Application Background Color -->
<item name="android:windowBackground">@color/white</item> <item name="android:windowBackground">@color/white</item>
<!---Dialogfragment Background Color -->
<item name="dialogFragmentBackground">@color/background_light</item>
<item name="android:dialogCornerRadius">12dp</item>
</style> </style>
<style name="Theme.MaterialComponents.DayNight.DarkActionBar" parent="Theme.MaterialComponents.DayNight.Bridge"/> <style name="Theme.MaterialComponents.DayNight.DarkActionBar" parent="Theme.MaterialComponents.DayNight.Bridge"/>