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 --- .../de/pixart/messenger/ui/ShareLocationActivity.java | 3 ++- .../java/de/pixart/messenger/utils/ThemeHelper.java | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/main/java/de/pixart/messenger/ui/ShareLocationActivity.java b/src/main/java/de/pixart/messenger/ui/ShareLocationActivity.java index 0abfd1708..bb07a0885 100644 --- a/src/main/java/de/pixart/messenger/ui/ShareLocationActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ShareLocationActivity.java @@ -26,6 +26,7 @@ import java.util.Locale; import de.pixart.messenger.R; import de.pixart.messenger.utils.LocationHelper; +import de.pixart.messenger.utils.ThemeHelper; public class ShareLocationActivity extends LocationActivity implements LocationListener { @@ -86,7 +87,7 @@ public class ShareLocationActivity extends LocationActivity implements LocationL setResult(RESULT_CANCELED); finish(); }); - + ThemeHelper.fixTextSize(this.snackBar); mShareButton = findViewById(R.id.share_button); mShareButton.setOnClickListener(view -> { if (mLastLocation != null) { 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