use system font

This commit is contained in:
Riko Sakurauchi 2019-12-14 12:19:38 +08:00
parent 4547880436
commit 4278f99a79
No known key found for this signature in database
GPG Key ID: 25AC0345B92902AF
7 changed files with 47 additions and 11 deletions

View File

@ -904,6 +904,18 @@ public class AndroidUtilities {
public static Typeface getTypeface(String assetPath) {
synchronized (typefaceCache) {
if (NekoConfig.typeface == 1) {
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;

View File

@ -15,6 +15,7 @@ public class NekoConfig {
public static boolean hidePhone = true;
public static boolean ignoreBlocked = false;
public static boolean forceTablet = false;
public static int typeface = 0;
public static int nameOrder = 1;
public static boolean transparentStatusBar = true;
public static boolean navigationBarTint = true;
@ -43,6 +44,7 @@ public class NekoConfig {
editor.putBoolean("hidePhone", hidePhone);
editor.putBoolean("ignoreBlocked", ignoreBlocked);
editor.putBoolean("forceTablet", forceTablet);
editor.putInt("typeface", typeface);
editor.putInt("nameOrder", nameOrder);
editor.putBoolean("transparentStatusBar", transparentStatusBar);
editor.putBoolean("navigationBarTint", navigationBarTint);
@ -72,6 +74,7 @@ public class NekoConfig {
hidePhone = preferences.getBoolean("hidePhone", true);
ignoreBlocked = preferences.getBoolean("ignoreBlocked", false);
forceTablet = preferences.getBoolean("forceTablet", false);
typeface = preferences.getInt("typeface", 0);
nameOrder = preferences.getInt("nameOrder", 1);
transparentStatusBar = preferences.getBoolean("transparentStatusBar", true);
navigationBarTint = preferences.getBoolean("navigationBarTint", true);
@ -160,6 +163,14 @@ public class NekoConfig {
editor.commit();
}
public static void toogleTypeface() {
typeface = typeface == 0 ? 1 : 0;
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putInt("typeface", typeface);
editor.commit();
}
public static void setNameOrder(int order) {
nameOrder = order;
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE);

View File

@ -62,13 +62,14 @@ public class NekoSettingsActivity extends BaseFragment {
private int messageMenu2Row;
private int chatRow;
private int inappCameraRow;
private int useSystemEmojiRow;
private int ignoreBlockedRow;
private int chat2Row;
private int settingsRow;
private int typefaceRow;
private int hidePhoneRow;
private int inappCameraRow;
private int useSystemEmojiRow;
private int nameOrderRow;
private int transparentStatusBarRow;
private int navigationBarTintRow;
@ -218,6 +219,11 @@ public class NekoSettingsActivity extends BaseFragment {
if (view instanceof TextCheckCell) {
((TextCheckCell) view).setChecked(SharedConfig.useSystemEmoji);
}
} else if (position == typefaceRow) {
NekoConfig.toogleTypeface();
if (view instanceof TextCheckCell) {
((TextCheckCell) view).setChecked(NekoConfig.typeface == 1);
}
} else if (position == nameOrderRow) {
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setTitle(LocaleController.getString("NameOrder", R.string.NameOrder));
@ -250,6 +256,8 @@ public class NekoSettingsActivity extends BaseFragment {
ipv6Row = rowCount++;
connection2Row = rowCount++;
chatRow = rowCount++;
inappCameraRow = rowCount++;
useSystemEmojiRow = rowCount++;
ignoreBlockedRow = rowCount++;
chat2Row = rowCount++;
messageMenuRow = rowCount++;
@ -261,8 +269,7 @@ public class NekoSettingsActivity extends BaseFragment {
messageMenu2Row = rowCount++;
settingsRow = rowCount++;
hidePhoneRow = rowCount++;
inappCameraRow = rowCount++;
useSystemEmojiRow = rowCount++;
typefaceRow = rowCount++;
navigationBarTintRow = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O ? rowCount++ : -1;
transparentStatusBarRow = Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ? rowCount++ : -1;
navigationBarColorRow = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O ? rowCount++ : -1;
@ -388,6 +395,8 @@ public class NekoSettingsActivity extends BaseFragment {
textCell.setTextAndCheck(LocaleController.getString("NavigationBarTint", R.string.NavigationBarTint), NekoConfig.navigationBarTint, true);
} else if (position == useSystemEmojiRow) {
textCell.setTextAndCheck(LocaleController.getString("EmojiUseDefault", R.string.EmojiUseDefault), SharedConfig.useSystemEmoji, true);
} else if (position == typefaceRow) {
textCell.setTextAndCheck(LocaleController.getString("TypefaceUseDefault", R.string.TypefaceUseDefault), NekoConfig.typeface == 1, true);
} else if (position == ignoreBlockedRow) {
textCell.setTextAndCheck(LocaleController.getString("IgnoreBlocked", R.string.IgnoreBlocked), NekoConfig.ignoreBlocked, false);
} else if (position == forceTabletRow) {
@ -398,7 +407,7 @@ public class NekoSettingsActivity extends BaseFragment {
case 4: {
HeaderCell headerCell = (HeaderCell) holder.itemView;
if (position == settingsRow) {
headerCell.setText(LocaleController.getString("Settings", R.string.Settings));
headerCell.setText(LocaleController.getString("General", R.string.General));
} else if (position == messageMenuRow) {
headerCell.setText(LocaleController.getString("MessageMenu", R.string.MessageMenu));
} else if (position == connectionRow) {
@ -415,7 +424,7 @@ public class NekoSettingsActivity extends BaseFragment {
public boolean isEnabled(RecyclerView.ViewHolder holder) {
int position = holder.getAdapterPosition();
return position == hidePhoneRow || position == inappCameraRow || position == ignoreBlockedRow || position == navigationBarTintRow ||
position == useSystemEmojiRow || position == ipv6Row ||
position == useSystemEmojiRow || position == ipv6Row || position == typefaceRow ||
position == showChangePermissionsRow || position == showAdminActionsRow || position == showReportRow ||
position == showPrPrRow || position == showAddToSavedMessagesRow ||
position == nameOrderRow || position == forceTabletRow ||
@ -465,7 +474,7 @@ public class NekoSettingsActivity extends BaseFragment {
position == showAddToSavedMessagesRow || position == showPrPrRow || position == showReportRow ||
position == showAdminActionsRow || position == showChangePermissionsRow ||
position == transparentStatusBarRow || position == navigationBarTintRow ||
position == ignoreBlockedRow || position == useSystemEmojiRow ||
position == ignoreBlockedRow || position == useSystemEmojiRow || position == typefaceRow ||
position == forceTabletRow) {
return 3;
} else if (position == settingsRow || position == connectionRow || position == messageMenuRow || position == chatRow) {

View File

@ -15,6 +15,7 @@
<string name="NameOrder">名前順</string>
<string name="FirstLast">名前 姓氏</string>
<string name="LastFirst">姓氏 名前</string>
<string name="TypefaceUseDefault">システムのフォントを使う</string>
<string name="NoQuoteForward">見積もりなしで転送</string>
<string name="Repeat">繰り返す</string>
<string name="AddToSavedMessages">保存用メッセージに追加</string>

View File

@ -12,14 +12,15 @@
<string name="IgnoreBlocked">忽略渣滓们在群里说的话</string>
<string name="Connection">连接</string>
<string name="Chat">聊天</string>
<string name="NameOrder">姓名顺序(重启生效</string>
<string name="NameOrder">姓名顺序(需要重启)</string>
<string name="FirstLast">名字 姓氏</string>
<string name="LastFirst">姓氏 名字</string>
<string name="TypefaceUseDefault">使用系统默认字体(需要重启)</string>
<string name="NoQuoteForward">无引用转发</string>
<string name="AddToSavedMessages">拿去自嗨</string>
<string name="Repeat">复读</string>
<string name="CreateMention">创建\@</string>
<string name="ForceTabletMode">假装是平板(重启生效</string>
<string name="ForceTabletMode">假装是平板(需要重启)</string>
<string name="All">全部</string>
<string name="Users">用户</string>
<string name="Groups">群组</string>

View File

@ -12,14 +12,15 @@
<string name="IgnoreBlocked">忽略被封鎖的使用者在群組內的發言</string>
<string name="Connection">連線</string>
<string name="Chat">聊天</string>
<string name="NameOrder">姓名順序(重啟生效</string>
<string name="NameOrder">姓名順序(需要重啟)</string>
<string name="FirstLast">名字 姓氏</string>
<string name="LastFirst">姓氏 名字</string>
<string name="TypefaceUseDefault">使用系統默認字體(需要重啟)</string>
<string name="NoQuoteForward">無引用轉發</string>
<string name="AddToSavedMessages">拿去自嗨</string>
<string name="Repeat">复讀</string>
<string name="CreateMention">提及使用者</string>
<string name="ForceTabletMode">強制平板模式(重啟生效</string>
<string name="ForceTabletMode">強制平板模式(需要重啟)</string>
<string name="All">全部</string>
<string name="Users">用戶</string>
<string name="Groups">群組</string>

View File

@ -15,6 +15,7 @@
<string name="NameOrder">Name order</string>
<string name="FirstLast">First Last</string>
<string name="LastFirst">Last First</string>
<string name="TypefaceUseDefault">Use system default font</string>
<string name="NoQuoteForward">NoQuote forward</string>
<string name="Repeat">Repeat</string>
<string name="AddToSavedMessages">Add to Saved Messages</string>