From 52436756a938327da0dcc0a4d800fb9fd763bac5 Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Sun, 29 Apr 2018 22:35:39 +0200 Subject: fix text size in snackbars --- .../java/de/pixart/messenger/utils/ThemeHelper.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/main/java/de/pixart/messenger/utils') diff --git a/src/main/java/de/pixart/messenger/utils/ThemeHelper.java b/src/main/java/de/pixart/messenger/utils/ThemeHelper.java index c14e1e25d..3568a488a 100644 --- a/src/main/java/de/pixart/messenger/utils/ThemeHelper.java +++ b/src/main/java/de/pixart/messenger/utils/ThemeHelper.java @@ -32,8 +32,12 @@ package de.pixart.messenger.utils; import android.content.Context; import android.content.SharedPreferences; import android.content.res.Resources; +import android.content.res.TypedArray; import android.preference.PreferenceManager; import android.support.annotation.StyleRes; +import android.support.design.widget.Snackbar; +import android.util.TypedValue; +import android.widget.TextView; import de.pixart.messenger.R; import de.pixart.messenger.ui.SettingsActivity; @@ -65,4 +69,18 @@ public class ThemeHelper { return false; } } + + public static void fixTextSize(Snackbar snackbar) { + TypedArray typedArray = snackbar.getContext().obtainStyledAttributes(new int[]{R.attr.TextSizeBody1}); + final float size = typedArray.getDimension(0, 0f); + typedArray.recycle(); + if (size != 0f) { + final TextView text = snackbar.getView().findViewById(android.support.design.R.id.snackbar_text); + final TextView action = snackbar.getView().findViewById(android.support.design.R.id.snackbar_action); + if (text != null && action != null) { + text.setTextSize(TypedValue.COMPLEX_UNIT_PX, size); + action.setTextSize(TypedValue.COMPLEX_UNIT_PX, size); + } + } + } } \ No newline at end of file -- cgit v1.2.3