This commit is contained in:
Milos Kozak 2022-09-22 15:12:10 +02:00
commit 28c617aea2
7 changed files with 17 additions and 5 deletions

View file

@ -16,6 +16,7 @@ import info.nightscout.androidaps.core.R
import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification
import info.nightscout.androidaps.utils.resources.getThemeColor
object ToastUtils {
@ -76,7 +77,15 @@ object ToastUtils {
fun showToastInUiThread(ctx: Context?, string: String?) {
val mainThread = Handler(Looper.getMainLooper())
mainThread.post { Toast.makeText(ctx, string, Toast.LENGTH_SHORT).show() }
mainThread.post {
val toast: Toast =
Toast.makeText(
ctx,
HtmlHelper.fromHtml("<font color='" + ContextThemeWrapper(ctx, R.style.AppTheme).getThemeColor(R.attr.toastBaseTextColor) + "'>" + string + "</font>"),
Toast.LENGTH_SHORT
)
toast.show()
}
}
fun showToastInUiThread(

View file

@ -4,7 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/toast_border_ok">
android:background="?attr/toastBackgroundColor">
<ImageView
android:id="@android:id/icon"
@ -26,7 +26,7 @@
android:layout_marginTop="4dp"
android:layout_marginEnd="18dp"
android:layout_marginBottom="4dp"
android:textColor="?attr/toastBaseTextColor"
android:textColor="?attr/defaultTextColor"
android:textSize="18sp"
tools:ignore="RtlHardcoded"
tools:text="Toast goes here..." />

View file

@ -109,7 +109,7 @@
<!-- Toasts-->
<color name="toastBorder">#666666</color>
<color name="toastBase">#ffffff</color>
<color name="toastBase">#000000</color>
<color name="toastOk">#77dd77</color>
<color name="toastError">#ff0400</color>
<color name="toastWarn">#FF8C00</color>

View file

@ -95,6 +95,7 @@
<item name="defaultBackground">@color/defaultBackground</item>
<!---Toast -->
<item name="toastBaseTextColor">@color/toastBase</item>
<item name="toastBackgroundColor">@color/buttonBackground</item>
<!---Dialog Helper -->
<item name="materialAlertDialogTheme">@style/DialogTheme</item>
<item name="android:alertDialogTheme">@style/DialogTheme</item>

View file

@ -65,6 +65,7 @@
<attr name="defaultBackground" format="reference|color" />
<!---Toast -->
<attr name="toastBaseTextColor" format="reference|color" />
<attr name="toastBackgroundColor" format="reference|color" />
<declare-styleable name="NumberPicker">
<attr name="customContentDescription" format="string" />
</declare-styleable>

View file

@ -111,7 +111,7 @@
<!-- Toasts-->
<color name="toastBorder">#666666</color>
<color name="toastBase">#ffffff</color>
<color name="toastBase">#000000</color>
<color name="toastOk">#77dd77</color>
<color name="toastError">#ff0400</color>
<color name="toastWarn">#FF8C00</color>

View file

@ -100,6 +100,7 @@
<item name="defaultBackground">@color/white</item>
<!---Toast -->
<item name="toastBaseTextColor">@color/toastBase</item>
<item name="toastBackgroundColor">@color/colorLightGray</item>
<!---Dialog Helper -->
<item name="materialAlertDialogTheme">@style/DialogTheme</item>
<item name="android:alertDialogTheme">@style/DialogTheme</item>