Merge pull request #2093 from osodebailar/bugfix/toast-text-color
fix toast text color especially on android 11 and above
This commit is contained in:
commit
c031770ab1
|
@ -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(
|
||||
|
|
|
@ -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..." />
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue