rounded dialogs like in android 12
This commit is contained in:
parent
884947331b
commit
91467b1f49
20 changed files with 75 additions and 14 deletions
|
@ -27,7 +27,6 @@ import javax.inject.Inject
|
|||
class CalibrationDialog : DialogFragmentWithDate() {
|
||||
|
||||
@Inject lateinit var injector: HasAndroidInjector
|
||||
@Inject lateinit var rh: ResourceHelper
|
||||
@Inject lateinit var profileFunction: ProfileFunction
|
||||
@Inject lateinit var xDripBroadcast: XDripBroadcast
|
||||
@Inject lateinit var uel: UserEntryLogger
|
||||
|
|
|
@ -41,7 +41,6 @@ import kotlin.math.max
|
|||
class CarbsDialog : DialogFragmentWithDate() {
|
||||
|
||||
@Inject lateinit var ctx: Context
|
||||
@Inject lateinit var rh: ResourceHelper
|
||||
@Inject lateinit var constraintChecker: ConstraintChecker
|
||||
@Inject lateinit var defaultValueHelper: DefaultValueHelper
|
||||
@Inject lateinit var profileFunction: ProfileFunction
|
||||
|
|
|
@ -41,7 +41,6 @@ class CareDialog : DialogFragmentWithDate() {
|
|||
|
||||
@Inject lateinit var injector: HasAndroidInjector
|
||||
@Inject lateinit var ctx: Context
|
||||
@Inject lateinit var rh: ResourceHelper
|
||||
@Inject lateinit var profileFunction: ProfileFunction
|
||||
@Inject lateinit var translator: Translator
|
||||
@Inject lateinit var uel: UserEntryLogger
|
||||
|
|
|
@ -35,7 +35,6 @@ import kotlin.math.abs
|
|||
class ExtendedBolusDialog : DialogFragmentWithDate() {
|
||||
|
||||
@Inject lateinit var ctx: Context
|
||||
@Inject lateinit var rh: ResourceHelper
|
||||
@Inject lateinit var constraintChecker: ConstraintChecker
|
||||
@Inject lateinit var commandQueue: CommandQueue
|
||||
@Inject lateinit var activePlugin: ActivePlugin
|
||||
|
|
|
@ -41,7 +41,6 @@ import kotlin.math.abs
|
|||
class FillDialog : DialogFragmentWithDate() {
|
||||
|
||||
@Inject lateinit var constraintChecker: ConstraintChecker
|
||||
@Inject lateinit var rh: ResourceHelper
|
||||
@Inject lateinit var ctx: Context
|
||||
@Inject lateinit var commandQueue: CommandQueue
|
||||
@Inject lateinit var activePlugin: ActivePlugin
|
||||
|
|
|
@ -44,7 +44,6 @@ import kotlin.math.max
|
|||
class InsulinDialog : DialogFragmentWithDate() {
|
||||
|
||||
@Inject lateinit var constraintChecker: ConstraintChecker
|
||||
@Inject lateinit var rh: ResourceHelper
|
||||
@Inject lateinit var defaultValueHelper: DefaultValueHelper
|
||||
@Inject lateinit var profileFunction: ProfileFunction
|
||||
@Inject lateinit var commandQueue: CommandQueue
|
||||
|
|
|
@ -46,7 +46,6 @@ import kotlin.collections.ArrayList
|
|||
|
||||
class ProfileSwitchDialog : DialogFragmentWithDate() {
|
||||
|
||||
@Inject lateinit var rh: ResourceHelper
|
||||
@Inject lateinit var profileFunction: ProfileFunction
|
||||
@Inject lateinit var activePlugin: ActivePlugin
|
||||
@Inject lateinit var repository: AppRepository
|
||||
|
|
|
@ -33,7 +33,6 @@ import kotlin.math.abs
|
|||
class TempBasalDialog : DialogFragmentWithDate() {
|
||||
|
||||
@Inject lateinit var constraintChecker: ConstraintChecker
|
||||
@Inject lateinit var rh: ResourceHelper
|
||||
@Inject lateinit var profileFunction: ProfileFunction
|
||||
@Inject lateinit var activePlugin: ActivePlugin
|
||||
@Inject lateinit var commandQueue: CommandQueue
|
||||
|
|
|
@ -42,7 +42,6 @@ import javax.inject.Inject
|
|||
class TempTargetDialog : DialogFragmentWithDate() {
|
||||
|
||||
@Inject lateinit var constraintChecker: ConstraintChecker
|
||||
@Inject lateinit var rh: ResourceHelper
|
||||
@Inject lateinit var profileFunction: ProfileFunction
|
||||
@Inject lateinit var defaultValueHelper: DefaultValueHelper
|
||||
@Inject lateinit var uel: UserEntryLogger
|
||||
|
|
|
@ -43,7 +43,6 @@ import kotlin.math.abs
|
|||
class TreatmentDialog : DialogFragmentWithDate() {
|
||||
|
||||
@Inject lateinit var constraintChecker: ConstraintChecker
|
||||
@Inject lateinit var rh: ResourceHelper
|
||||
@Inject lateinit var activePlugin: ActivePlugin
|
||||
@Inject lateinit var commandQueue: CommandQueue
|
||||
@Inject lateinit var ctx: Context
|
||||
|
|
|
@ -2,6 +2,9 @@ package info.nightscout.androidaps.dialogs
|
|||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.graphics.PorterDuff
|
||||
import android.graphics.PorterDuffColorFilter
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.os.Bundle
|
||||
import android.text.Editable
|
||||
import android.text.TextWatcher
|
||||
|
@ -13,6 +16,7 @@ import android.view.WindowManager
|
|||
import android.widget.AdapterView
|
||||
import android.widget.ArrayAdapter
|
||||
import android.widget.CompoundButton
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.fragment.app.FragmentManager
|
||||
import dagger.android.HasAndroidInjector
|
||||
import dagger.android.support.DaggerDialogFragment
|
||||
|
@ -120,6 +124,11 @@ class WizardDialog : DaggerDialogFragment() {
|
|||
isCancelable = true
|
||||
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)
|
||||
return binding.root
|
||||
}
|
||||
|
|
|
@ -13,8 +13,6 @@ import javax.inject.Inject
|
|||
|
||||
class ChooseOperationDialog : DialogFragmentWithDate() {
|
||||
|
||||
@Inject lateinit var rh: ResourceHelper
|
||||
|
||||
private var checkedIndex = -1
|
||||
|
||||
private var _binding: AutomationDialogChooseOperationBinding? = null
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
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.SystemClock
|
||||
import android.view.LayoutInflater
|
||||
|
@ -7,6 +11,7 @@ import android.view.View
|
|||
import android.view.ViewGroup
|
||||
import android.view.Window
|
||||
import android.view.WindowManager
|
||||
import androidx.core.content.ContextCompat
|
||||
import dagger.android.support.DaggerDialogFragment
|
||||
import info.nightscout.androidaps.activities.BolusProgressHelperActivity
|
||||
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.resources.ResourceHelper
|
||||
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||
import info.nightscout.shared.sharedPreferences.SP
|
||||
import io.reactivex.rxjava3.disposables.CompositeDisposable
|
||||
import io.reactivex.rxjava3.kotlin.plusAssign
|
||||
import javax.inject.Inject
|
||||
|
@ -37,6 +43,7 @@ class BolusProgressDialog : DaggerDialogFragment() {
|
|||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
||||
@Inject lateinit var aapsSchedulers: AapsSchedulers
|
||||
@Inject lateinit var uel: UserEntryLogger
|
||||
@Inject lateinit var sp: SP
|
||||
|
||||
private val disposable = CompositeDisposable()
|
||||
|
||||
|
@ -83,6 +90,15 @@ class BolusProgressDialog : DaggerDialogFragment() {
|
|||
isCancelable = 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)
|
||||
return binding.root
|
||||
}
|
||||
|
|
|
@ -2,6 +2,9 @@ package info.nightscout.androidaps.dialogs
|
|||
|
||||
import android.app.DatePickerDialog
|
||||
import android.app.TimePickerDialog
|
||||
import android.graphics.PorterDuff
|
||||
import android.graphics.PorterDuffColorFilter
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.os.Bundle
|
||||
import android.text.format.DateFormat
|
||||
import android.view.View
|
||||
|
@ -10,6 +13,7 @@ import android.view.Window
|
|||
import android.view.WindowManager
|
||||
import android.widget.Button
|
||||
import android.widget.TextView
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.fragment.app.FragmentManager
|
||||
import dagger.android.support.DaggerDialogFragment
|
||||
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.androidaps.utils.DateUtil
|
||||
import info.nightscout.androidaps.extensions.toVisibility
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import info.nightscout.shared.sharedPreferences.SP
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
|
@ -26,6 +31,7 @@ abstract class DialogFragmentWithDate : DaggerDialogFragment() {
|
|||
@Inject lateinit var aapsLogger: AAPSLogger
|
||||
@Inject lateinit var sp: SP
|
||||
@Inject lateinit var dateUtil: DateUtil
|
||||
@Inject lateinit var rh: ResourceHelper
|
||||
|
||||
fun interface OnValueChangedListener {
|
||||
fun onValueChanged(value: Long)
|
||||
|
@ -68,6 +74,11 @@ abstract class DialogFragmentWithDate : DaggerDialogFragment() {
|
|||
dialog?.window?.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN)
|
||||
isCancelable = true
|
||||
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) {
|
||||
|
|
21
core/src/main/res/drawable-hdpi/dialog.xml
Normal file
21
core/src/main/res/drawable-hdpi/dialog.xml
Normal 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>
|
|
@ -25,9 +25,13 @@
|
|||
<color name="overviewPillColorDefault">#1c171c</color>
|
||||
<color name="colorOnPrimaryDefault">#FFFFFF</color>
|
||||
|
||||
<color name="defaultbackground">#424242</color>
|
||||
<color name="defaultbackground">#000000</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-->
|
||||
<color name="tabText">#d0d0d0</color>
|
||||
<color name="tabSelectedText">@color/white</color>
|
||||
|
|
|
@ -113,6 +113,9 @@
|
|||
<item name="splashBackgroundColor">@color/splashBackground</item>
|
||||
<!---Application Background Color -->
|
||||
<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 name="Theme.MaterialComponents.DayNight.DarkActionBar" parent="Theme.MaterialComponents.DayNight.Bridge"/>
|
||||
|
@ -203,7 +206,7 @@
|
|||
|
||||
<!-- Alert Dialogs -->
|
||||
<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="buttonBarPositiveButtonStyle">@style/DialogOkCancelButtonStyle</item>
|
||||
<item name="buttonBarNeutralButtonStyle">@style/DialogOkCancelButtonStyle</item>
|
||||
|
|
|
@ -86,5 +86,7 @@
|
|||
<attr name="splashBackgroundColor" format="reference|color" />
|
||||
<!---Disabled Text Color -->
|
||||
<attr name="disabledTextColor" format="reference|color" />
|
||||
<!---Dialogfragment Background Color -->
|
||||
<attr name="dialogFragmentBackground" format="reference|color" />
|
||||
|
||||
</resources>
|
|
@ -28,6 +28,10 @@
|
|||
<color name="defaultbackground">#424242</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-->
|
||||
<color name="tabText">#d0d0d0</color>
|
||||
<color name="tabSelectedText">@color/white</color>
|
||||
|
|
|
@ -112,6 +112,9 @@
|
|||
<item name="splashBackgroundColor">@color/splashBackground</item>
|
||||
<!---Application Background Color -->
|
||||
<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 name="Theme.MaterialComponents.DayNight.DarkActionBar" parent="Theme.MaterialComponents.DayNight.Bridge"/>
|
||||
|
|
Loading…
Reference in a new issue