Add "Use system fonts"
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
<string name="Categories">Categories</string>
|
||||
|
||||
<!-- Appearance -->
|
||||
<string name="UseSystemFonts">Use system fonts</string>
|
||||
<string name="TransparentStatusBar">Transparent Status Bar</string>
|
||||
<string name="BlurForAllThemes">Blur for all themes</string>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user