Skip to content

Commit

Permalink
🎉Release 1.3,添加我们的内测字体(BETA),调整方法内判断调用。
Browse files Browse the repository at this point in the history
  • Loading branch information
Hny0305Lin committed Jul 6, 2024
1 parent 80a2c1a commit ffb1068
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private class SentMessageHolder extends RecyclerView.ViewHolder {
messageText = itemView.findViewById(R.id.text_message_body);

// 设置自定义字体
ChatFontUtils.applyCustomFont(context, messageText, 0);
ChatFontUtils.applyCustomFont(context, messageText);
}

void bind(ChatMessage message) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,21 @@
import android.util.Log;
import android.widget.TextView;

import java.util.Random;

public class ChatFontUtils {

private static final String TAG = "ChatFontUtils & NLChat";

private static int fontPathNum = 0; //默认,思源字体

// getter and settertiao
public static int getFontPathNum() {
return fontPathNum;
}

public static void setFontPathNum(int fontPathNum) {
ChatFontUtils.fontPathNum = fontPathNum;
}

// 加载并应用自定义字体
public static void applyCustomFont(Context context, TextView textView, int fontType) {
String fontPath = getFontPath(fontType);
Expand All @@ -24,9 +33,10 @@ public static void applyCustomFont(Context context, TextView textView, int fontT
}
}

// 加载并应用自定义字体
public static void applyCustomFont(Context context, TextView textView) {
int fontType = new Random().nextInt(3) + 1; // 生成1到3之间的随机数
String fontPath = getFontPath(fontType);
//int fontType = new Random().nextInt(3) + 1; // 生成1到3之间的随机数
String fontPath = getFontPath(fontPathNum);
try {
Typeface customFont = Typeface.createFromAsset(context.getAssets(), fontPath);
textView.setTypeface(customFont);
Expand All @@ -45,6 +55,8 @@ private static String getFontPath(int fontType) {
return "fonts/alimama_dongfangdakai_regular.ttf";
case 3:
return "fonts/smileysans_oblique.ttf";
case 4:
return "fonts/haohanyhfont_regular.otf";// 浩瀚银河内测字体
default:
return "fonts/source_han_sans_sc_regular.otf"; // 默认字体
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<resources>
<string name="app_name">NLChat</string>
<string name="app_package">com.haohanyh.linmengjia.nearlink.nlchat.fun</string>
<string name="app_version">1.3.80.2024.0706</string>
<string name="app_version">1.3.88.2024.0706</string>

<string name="appwarn">NLChat,浩瀚银河宗旨为用爱和魔法创造Android APP。</string>
<string name="thanks3q">友情感谢</string>
Expand Down

0 comments on commit ffb1068

Please sign in to comment.