AlertDialogs -> core

This commit is contained in:
Milos Kozak 2020-05-04 10:49:19 +02:00
parent 2fb0198418
commit ab9da6e2b6
25 changed files with 184 additions and 162 deletions

View file

@ -39,17 +39,9 @@
<color name="tempTargetConfirmation">#77dd77</color> <color name="tempTargetConfirmation">#77dd77</color>
<color name="colorPrimary">#212121</color>
<color name="colorPrimaryDark">#000000</color>
<color name="colorAccent">#40bbaa</color>
<color name="mdtp_accent_color">#40bbaa</color> <color name="mdtp_accent_color">#40bbaa</color>
<color name="colorInitializingBorder">#00695c</color> <color name="colorInitializingBorder">#00695c</color>
<color name="dialog_title_background">#303030</color>
<color name="activity_title_background">#121212</color>
<color name="dialog_title_color">#FFFFFF</color>
<color name="dialog_title_icon_tint">#FFFFFF</color>
<color name="cardColorBackground">#121212</color> <color name="cardColorBackground">#121212</color>
<color name="cardObjectiveText">#779ECB</color> <color name="cardObjectiveText">#779ECB</color>
@ -91,12 +83,6 @@
<color name="splashBackground">#2E2E2E</color> <color name="splashBackground">#2E2E2E</color>
<color name="warningAlertBackground">#FFFB8C00</color>
<color name="warningAlertHeaderText">#FF000000</color>
<color name="errorAlertBackground">#FFFF5555</color>
<color name="errorAlertHeaderText">#FF000000</color>
<color name="toastBorder">#666666</color> <color name="toastBorder">#666666</color>
<color name="toastBase">#ffffff</color> <color name="toastBase">#ffffff</color>
<color name="toastOk">#77dd77</color> <color name="toastOk">#77dd77</color>

View file

@ -250,7 +250,6 @@
<string name="openapsma_maxbasal_summary">This value is called max basal in OpenAPS context</string> <string name="openapsma_maxbasal_summary">This value is called max basal in OpenAPS context</string>
<string name="openapsma_maxiob_title">Maximum basal IOB OpenAPS can deliver [U]</string> <string name="openapsma_maxiob_title">Maximum basal IOB OpenAPS can deliver [U]</string>
<string name="openapsma_maxiob_summary">This value is called Max IOB in OpenAPS context\nThis is maximal insulin in [U] APS can deliver at once.</string> <string name="openapsma_maxiob_summary">This value is called Max IOB in OpenAPS context\nThis is maximal insulin in [U] APS can deliver at once.</string>
<string name="dismiss">DISMISS</string>
<string name="language" translatable="false">Language</string> <string name="language" translatable="false">Language</string>
<string name="password_preferences_encrypt_prompt">You will be asked for master password, which will be used to encrypt exported preferences.</string> <string name="password_preferences_encrypt_prompt">You will be asked for master password, which will be used to encrypt exported preferences.</string>
@ -1761,7 +1760,6 @@
<string name="timeformat24h">24h</string> <string name="timeformat24h">24h</string>
<string name="automation_event">Automation event</string> <string name="automation_event">Automation event</string>
<string name="alreadyset">Already set</string> <string name="alreadyset">Already set</string>
<string name="message">Message</string>
<string name="clearqueueconfirm">Clear queue? All data in queue will be lost!</string> <string name="clearqueueconfirm">Clear queue? All data in queue will be lost!</string>
<string name="key_xdripstatus_detailediob" translatable="false">xdripstatus_detailediob</string> <string name="key_xdripstatus_detailediob" translatable="false">xdripstatus_detailediob</string>
<string name="key_xdripstatus_showbgi" translatable="false">xdripstatus_showbgi</string> <string name="key_xdripstatus_showbgi" translatable="false">xdripstatus_showbgi</string>

View file

@ -70,31 +70,7 @@
<item name="android:textColor">#ff0000</item> <item name="android:textColor">#ff0000</item>
</style> </style>
<style name="AppThemeWarningDialog" parent="AppTheme"> <style name="WizardPagePodContent">
<item name="alertDialogTheme">@style/AppThemeWarningDialogTheme</item>
<item name="dialogTitleBackground">@color/warningAlertBackground</item>
<item name="dialogTitleColor">@color/warningAlertHeaderText</item>
<item name="dialogTitleIconTint">@color/warningAlertHeaderText</item>
</style>
<style name="AppThemeWarningDialogTheme" parent="Theme.AppCompat.Dialog.MinWidth">
<item name="android:windowBackground">@drawable/alert_border_warning</item>
<item name="colorAccent">@color/warningAlertBackground</item>
</style>
<style name="AppThemeErrorDialog" parent="AppTheme">
<item name="alertDialogTheme">@style/AppThemeErrorDialogTheme</item>
<item name="dialogTitleBackground">@color/errorAlertBackground</item>
<item name="dialogTitleColor">@color/errorAlertHeaderText</item>
<item name="dialogTitleIconTint">@color/errorAlertHeaderText</item>
</style>
<style name="AppThemeErrorDialogTheme" parent="Theme.AppCompat.Dialog.MinWidth">
<item name="android:windowBackground">@drawable/alert_border_error</item>
<item name="colorAccent">@color/errorAlertBackground</item>
</style>
<style name="WizardPagePodContent">
<item name="android:layout_width">match_parent</item> <item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item> <item name="android:layout_height">wrap_content</item>
<item name="android:layout_marginBottom">8dp</item> <item name="android:layout_marginBottom">8dp</item>

View file

@ -14,7 +14,7 @@ import android.widget.Toast;
import androidx.annotation.DrawableRes; import androidx.annotation.DrawableRes;
import androidx.appcompat.view.ContextThemeWrapper; import androidx.appcompat.view.ContextThemeWrapper;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.core.R;
import info.nightscout.androidaps.plugins.bus.RxBusWrapper; import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification; import info.nightscout.androidaps.plugins.general.overview.notifications.Notification;

View file

@ -1,31 +1,31 @@
package info.nightscout.androidaps.utils.alertDialogs package info.nightscout.androidaps.utils.alertDialogs
import android.content.Context import android.content.Context
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.widget.ImageView import android.widget.ImageView
import android.widget.TextView import android.widget.TextView
import androidx.annotation.DrawableRes import androidx.annotation.DrawableRes
import androidx.annotation.LayoutRes import androidx.annotation.LayoutRes
import androidx.annotation.StyleRes import androidx.annotation.StyleRes
import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AlertDialog
import androidx.appcompat.view.ContextThemeWrapper import androidx.appcompat.view.ContextThemeWrapper
import info.nightscout.androidaps.R import info.nightscout.androidaps.core.R
object AlertDialogHelper { object AlertDialogHelper {
@Suppress("FunctionName") @Suppress("FunctionName")
fun Builder(context: Context, @StyleRes themeResId: Int = R.style.AppTheme) = fun Builder(context: Context, @StyleRes themeResId: Int = R.style.AppTheme) =
AlertDialog.Builder(ContextThemeWrapper(context, themeResId)) AlertDialog.Builder(ContextThemeWrapper(context, themeResId))
fun buildCustomTitle(context: Context, title: String, fun buildCustomTitle(context: Context, title: String,
@DrawableRes iconResource: Int = R.drawable.ic_check_while_48dp, @DrawableRes iconResource: Int = R.drawable.ic_check_while_48dp,
@StyleRes themeResId: Int = R.style.AppTheme, @StyleRes themeResId: Int = R.style.AppTheme,
@LayoutRes layoutResource: Int = R.layout.dialog_alert_custom): View? { @LayoutRes layoutResource: Int = R.layout.dialog_alert_custom): View? {
val titleLayout = LayoutInflater.from(ContextThemeWrapper(context, themeResId)).inflate(layoutResource, null) val titleLayout = LayoutInflater.from(ContextThemeWrapper(context, themeResId)).inflate(layoutResource, null)
(titleLayout.findViewById<View>(R.id.alertdialog_title) as TextView).text = title (titleLayout.findViewById<View>(R.id.alertdialog_title) as TextView).text = title
(titleLayout.findViewById<View>(R.id.alertdialog_icon) as ImageView).setImageResource(iconResource) (titleLayout.findViewById<View>(R.id.alertdialog_icon) as ImageView).setImageResource(iconResource)
return titleLayout return titleLayout
} }
} }

View file

@ -6,7 +6,7 @@ import android.content.Context
import android.content.DialogInterface import android.content.DialogInterface
import android.os.SystemClock import android.os.SystemClock
import android.text.Spanned import android.text.Spanned
import info.nightscout.androidaps.R import info.nightscout.androidaps.core.R
import info.nightscout.androidaps.utils.extensions.runOnUiThread import info.nightscout.androidaps.utils.extensions.runOnUiThread
object OKDialog { object OKDialog {

View file

@ -5,7 +5,7 @@ import android.content.Context
import android.content.DialogInterface import android.content.DialogInterface
import android.os.SystemClock import android.os.SystemClock
import androidx.annotation.StringRes import androidx.annotation.StringRes
import info.nightscout.androidaps.R import info.nightscout.androidaps.core.R
import info.nightscout.androidaps.utils.extensions.runOnUiThread import info.nightscout.androidaps.utils.extensions.runOnUiThread
// if you need error dialog - duplicate to ErrorDialog and make it and use: AppThemeErrorDialog & R.drawable.ic_header_error instead // if you need error dialog - duplicate to ErrorDialog and make it and use: AppThemeErrorDialog & R.drawable.ic_header_error instead

View file

@ -1,16 +1,16 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" <vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="48dp" android:width="48dp"
android:height="48dp" android:height="48dp"
android:tint="#FFFFFF" android:tint="#FFFFFF"
android:viewportWidth="24" android:viewportWidth="24"
android:viewportHeight="24"> android:viewportHeight="24">
<group <group
android:pivotX="12" android:pivotX="12"
android:pivotY="12" android:pivotY="12"
android:scaleX="0.75" android:scaleX="0.75"
android:scaleY="0.75"> android:scaleY="0.75">
<path <path
android:fillColor="#000" android:fillColor="#000"
android:pathData="M12,2L1,21H23M12,6L19.53,19H4.47M11,10V14H13V10M11,16V18H13V16" /> android:pathData="M12,2L1,21H23M12,6L19.53,19H4.47M11,10V14H13V10M11,16V18H13V16" />
</group> </group>
</vector> </vector>

View file

@ -1,10 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" <vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp" android:width="24dp"
android:height="24dp" android:height="24dp"
android:tint="@color/toastInfo" android:tint="@color/toastInfo"
android:viewportWidth="24" android:viewportWidth="24"
android:viewportHeight="24"> android:viewportHeight="24">
<path <path
android:fillColor="#000" android:fillColor="#000"
android:pathData="M6,19A2,2 0 0,0 8,21H16A2,2 0 0,0 18,19V7H6V19M8.46,11.88L9.87,10.47L12,12.59L14.12,10.47L15.53,11.88L13.41,14L15.53,16.12L14.12,17.53L12,15.41L9.88,17.53L8.47,16.12L10.59,14L8.46,11.88M15.5,4L14.5,3H9.5L8.5,4H5V6H19V4H15.5Z" /> android:pathData="M6,19A2,2 0 0,0 8,21H16A2,2 0 0,0 18,19V7H6V19M8.46,11.88L9.87,10.47L12,12.59L14.12,10.47L15.53,11.88L13.41,14L15.53,16.12L14.12,17.53L12,15.41L9.88,17.53L8.47,16.12L10.59,14L8.46,11.88M15.5,4L14.5,3H9.5L8.5,4H5V6H19V4H15.5Z" />
</vector> </vector>

View file

@ -1,10 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" <vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp" android:width="24dp"
android:height="24dp" android:height="24dp"
android:tint="@color/toastError" android:tint="@color/toastError"
android:viewportWidth="24" android:viewportWidth="24"
android:viewportHeight="24"> android:viewportHeight="24">
<path <path
android:fillColor="#000" android:fillColor="#000"
android:pathData="M13,13H11V7H13M13,17H11V15H13M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2Z" /> android:pathData="M13,13H11V7H13M13,17H11V15H13M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2Z" />
</vector> </vector>

View file

@ -1,10 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" <vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp" android:width="24dp"
android:height="24dp" android:height="24dp"
android:tint="@color/toastInfo" android:tint="@color/toastInfo"
android:viewportWidth="24" android:viewportWidth="24"
android:viewportHeight="24"> android:viewportHeight="24">
<path <path
android:fillColor="#000" android:fillColor="#000"
android:pathData="M13,9H11V7H13M13,17H11V11H13M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2Z" /> android:pathData="M13,9H11V7H13M13,17H11V11H13M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2Z" />
</vector> </vector>

View file

@ -1,10 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" <vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp" android:width="24dp"
android:height="24dp" android:height="24dp"
android:tint="@color/toastWarn" android:tint="@color/toastWarn"
android:viewportWidth="24" android:viewportWidth="24"
android:viewportHeight="24"> android:viewportHeight="24">
<path <path
android:fillColor="#000" android:fillColor="#000"
android:pathData="M13,13H11V7H13M13,17H11V15H13M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2Z" /> android:pathData="M13,13H11V7H13M13,17H11V15H13M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2Z" />
</vector> </vector>

View file

@ -1,32 +1,32 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@drawable/toast_border_ok"> android:background="@drawable/toast_border_ok">
<ImageView <ImageView
android:id="@android:id/icon" android:id="@android:id/icon"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_marginLeft="6dp" android:layout_marginLeft="6dp"
android:layout_marginTop="6dp" android:layout_marginTop="6dp"
android:layout_marginBottom="6dp" android:layout_marginBottom="6dp"
android:src="@drawable/ic_toast_check" android:src="@drawable/ic_toast_check"
tools:ignore="RtlHardcoded" /> tools:ignore="RtlHardcoded" />
<TextView <TextView
android:id="@android:id/message" android:id="@android:id/message"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_marginLeft="6dp" android:layout_marginLeft="6dp"
android:layout_marginTop="4dp" android:layout_marginTop="4dp"
android:layout_marginRight="18dp" android:layout_marginRight="18dp"
android:layout_marginBottom="4dp" android:layout_marginBottom="4dp"
android:text="Toast goes here..." android:text="Toast goes here..."
android:textColor="@color/toastBase" android:textColor="@color/toastBase"
android:textSize="18sp" android:textSize="18sp"
tools:ignore="HardcodedText,RtlHardcoded" /> tools:ignore="HardcodedText,RtlHardcoded" />
</LinearLayout> </LinearLayout>

View file

@ -1,7 +1,7 @@
<resources> <resources>
<attr name="dialogTitleBackground" format="reference" /> <attr name="dialogTitleBackground" format="reference" />
<attr name="dialogTitleColor" format="reference" /> <attr name="dialogTitleColor" format="reference" />
<attr name="dialogTitleIconTint" format="reference" /> <attr name="dialogTitleIconTint" format="reference" />
</resources> </resources>

View file

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#212121</color>
<color name="colorPrimaryDark">#000000</color>
<color name="colorAccent">#40bbaa</color>
<color name="dialog_title_background">#303030</color>
<color name="activity_title_background">#121212</color>
<color name="dialog_title_color">#FFFFFF</color>
<color name="dialog_title_icon_tint">#FFFFFF</color>
<color name="warningAlertBackground">#FFFB8C00</color>
<color name="warningAlertHeaderText">#FF000000</color>
<color name="errorAlertBackground">#FFFF5555</color>
<color name="errorAlertHeaderText">#FF000000</color>
</resources>

View file

@ -1,4 +1,10 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<string name="key_enable_fabric" translatable="false">enable_fabric</string> <string name="key_enable_fabric" translatable="false">enable_fabric</string>
<string name="confirmation">Confirmation</string>
<string name="message">Message</string>
<string name="ok">OK</string>
<string name="cancel">Cancel</string>
<string name="dismiss">DISMISS</string>
</resources> </resources>

View file

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="Theme.AppCompat">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="dialogTitleBackground">@color/dialog_title_background</item>
<item name="dialogTitleColor">@color/dialog_title_color</item>
<item name="dialogTitleIconTint">@color/dialog_title_icon_tint</item>
</style>
<style name="AppThemeWarningDialog" parent="AppTheme">
<item name="alertDialogTheme">@style/AppThemeWarningDialogTheme</item>
<item name="dialogTitleBackground">@color/warningAlertBackground</item>
<item name="dialogTitleColor">@color/warningAlertHeaderText</item>
<item name="dialogTitleIconTint">@color/warningAlertHeaderText</item>
</style>
<style name="AppThemeWarningDialogTheme" parent="Theme.AppCompat.Dialog.MinWidth">
<item name="android:windowBackground">@drawable/alert_border_warning</item>
<item name="colorAccent">@color/warningAlertBackground</item>
</style>
<style name="AppThemeErrorDialog" parent="AppTheme">
<item name="alertDialogTheme">@style/AppThemeErrorDialogTheme</item>
<item name="dialogTitleBackground">@color/errorAlertBackground</item>
<item name="dialogTitleColor">@color/errorAlertHeaderText</item>
<item name="dialogTitleIconTint">@color/errorAlertHeaderText</item>
</style>
<style name="AppThemeErrorDialogTheme" parent="Theme.AppCompat.Dialog.MinWidth">
<item name="android:windowBackground">@drawable/alert_border_error</item>
<item name="colorAccent">@color/errorAlertBackground</item>
</style>
</resources>