diff options
author | Christian Schneppe <christian@pix-art.de> | 2018-04-29 22:35:39 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2018-04-29 22:35:39 +0200 |
commit | 52436756a938327da0dcc0a4d800fb9fd763bac5 (patch) | |
tree | c029ba8b3c9eaf21ead6c55f303f4f06f027a59e /src | |
parent | 82657e7bf6287759bc037b7de68f8901702473e7 (diff) |
fix text size in snackbars
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/ShareLocationActivity.java | 3 | ||||
-rw-r--r-- | src/main/java/de/pixart/messenger/utils/ThemeHelper.java | 18 |
2 files changed, 20 insertions, 1 deletions
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 |