diff --git a/TMessagesProj/src/main/java/com/exteragram/messenger/ExteraConfig.java b/TMessagesProj/src/main/java/com/exteragram/messenger/ExteraConfig.java index 931e19cac..bbb2f7cba 100644 --- a/TMessagesProj/src/main/java/com/exteragram/messenger/ExteraConfig.java +++ b/TMessagesProj/src/main/java/com/exteragram/messenger/ExteraConfig.java @@ -14,6 +14,7 @@ public class ExteraConfig { private static final Object sync = new Object(); + public static boolean useSystemFonts; public static boolean blurForAllThemes; public static boolean hideAllChats; @@ -63,6 +64,7 @@ public class ExteraConfig { SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("exteraconfig", Activity.MODE_PRIVATE); + useSystemFonts = preferences.getBoolean("useSystemFonts", false); blurForAllThemes = preferences.getBoolean("blurForAllThemes", true); hideAllChats = preferences.getBoolean("hideAllChats", false); @@ -102,6 +104,14 @@ public class ExteraConfig { } } + public static void toggleUseSystemFonts() { + useSystemFonts = !useSystemFonts; + SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("exteraconfig", Activity.MODE_PRIVATE); + SharedPreferences.Editor editor = preferences.edit(); + editor.putBoolean("useSystemFonts", useSystemFonts); + editor.commit(); + } + public static void toggleBlurForAllThemes() { blurForAllThemes = !blurForAllThemes; SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("exteraconfig", Activity.MODE_PRIVATE); diff --git a/TMessagesProj/src/main/java/com/exteragram/messenger/preferences/AppearancePreferencesEntry.java b/TMessagesProj/src/main/java/com/exteragram/messenger/preferences/AppearancePreferencesEntry.java index 14733c5dc..8eb9d0df8 100644 --- a/TMessagesProj/src/main/java/com/exteragram/messenger/preferences/AppearancePreferencesEntry.java +++ b/TMessagesProj/src/main/java/com/exteragram/messenger/preferences/AppearancePreferencesEntry.java @@ -37,6 +37,7 @@ public class AppearancePreferencesEntry extends BaseFragment { private ValueAnimator statusBarColorAnimate; private int applicationHeaderRow; + private int useSystemFontsRow; private int transparentStatusBarRow; private int blurForAllThemesRow; private int applicationDividerRow; @@ -94,7 +95,13 @@ public class AppearancePreferencesEntry extends BaseFragment { frameLayout.addView(listView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); listView.setOnItemClickListener((view, position, x, y) -> { - if (position == transparentStatusBarRow) { + if (position == useSystemFontsRow) { + ExteraConfig.toggleUseSystemFonts(); + if (view instanceof TextCheckCell) { + ((TextCheckCell) view).setChecked(ExteraConfig.useSystemFonts); + } + restartTooltip.showWithAction(0, UndoView.ACTION_CACHE_WAS_CLEARED, null, null); + } else if (position == transparentStatusBarRow) { SharedConfig.toggleNoStatusBar(); if (view instanceof TextCheckCell) { ((TextCheckCell) view).setChecked(SharedConfig.noStatusBar); @@ -163,6 +170,7 @@ public class AppearancePreferencesEntry extends BaseFragment { rowCount = 0; applicationHeaderRow = rowCount++; + useSystemFontsRow = rowCount++; transparentStatusBarRow = rowCount++; blurForAllThemesRow = rowCount++; applicationDividerRow = rowCount++; @@ -221,6 +229,8 @@ public class AppearancePreferencesEntry extends BaseFragment { textCheckCell.setEnabled(true, null); if (position == transparentStatusBarRow) { textCheckCell.setTextAndCheck(LocaleController.getString("TransparentStatusBar", R.string.TransparentStatusBar), SharedConfig.noStatusBar, true); + } else if (position == useSystemFontsRow) { + textCheckCell.setTextAndCheck(LocaleController.getString("UseSystemFonts", R.string.UseSystemFonts), ExteraConfig.useSystemFonts, true); } else if (position == blurForAllThemesRow) { textCheckCell.setTextAndCheck(LocaleController.getString("BlurForAllThemes", R.string.BlurForAllThemes), ExteraConfig.blurForAllThemes, true); } else if (position == hideAllChatsRow) { @@ -273,9 +283,9 @@ public class AppearancePreferencesEntry extends BaseFragment { return 1; } else if (position == applicationHeaderRow || position == generalHeaderRow) { return 2; - } else if (position == transparentStatusBarRow || position == blurForAllThemesRow || position == hideAllChatsRow || - position == hideProxySponsorRow || position == hidePhoneNumberRow || position == showIDRow || - position == chatsOnTitleRow || position == forceTabletModeRow) { + } else if (position == useSystemFontsRow || position == transparentStatusBarRow || position == blurForAllThemesRow || + position == hideAllChatsRow || position == hideProxySponsorRow || position == hidePhoneNumberRow || + position == showIDRow || position == chatsOnTitleRow || position == forceTabletModeRow) { return 3; } return 1; diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/AndroidUtilities.java b/TMessagesProj/src/main/java/org/telegram/messenger/AndroidUtilities.java index 5b36f5680..950843c60 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/AndroidUtilities.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/AndroidUtilities.java @@ -1430,6 +1430,18 @@ public class AndroidUtilities { public static Typeface getTypeface(String assetPath) { synchronized (typefaceCache) { + if (ExteraConfig.useSystemFonts) { + if (assetPath.contains("medium") && assetPath.contains("italic")) { + return Typeface.create((Typeface) null, Typeface.BOLD_ITALIC); + } + if (assetPath.contains("medium")) { + return Typeface.create((Typeface) null, Typeface.BOLD); + } + if (assetPath.contains("italic")) { + return Typeface.create((Typeface) null, Typeface.ITALIC); + } + return Typeface.create((Typeface) null, Typeface.NORMAL); + } if (!typefaceCache.containsKey(assetPath)) { try { Typeface t; diff --git a/TMessagesProj/src/main/res/values/extera.xml b/TMessagesProj/src/main/res/values/extera.xml index a023b9f33..655a610be 100644 --- a/TMessagesProj/src/main/res/values/extera.xml +++ b/TMessagesProj/src/main/res/values/extera.xml @@ -21,6 +21,7 @@ Categories + Use system fonts Transparent Status Bar Blur for all themes