mac
2024-10-21 8f5fe758de9464a5118bd306814c170b768fe695
app/src/main/java/com/hdl/photovoltaic/ui/LoginActivity.java
@@ -4,7 +4,9 @@
import android.content.Intent;
import android.os.Bundle;
import android.text.Editable;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.TextPaint;
import android.text.TextUtils;
import android.text.TextWatcher;
@@ -12,6 +14,8 @@
import android.text.method.LinkMovementMethod;
import android.text.method.PasswordTransformationMethod;
import android.text.style.ClickableSpan;
import android.text.style.StyleSpan;
import android.util.Log;
import android.view.View;
import android.widget.TextView;
@@ -136,14 +140,9 @@
     */
    private void initEvent() {
        viewBinding.homeLoginMoreIv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                HdlThreadLogic.toast(_mActivity, getString(R.string.loading_not_supported));
            }
        });
        //语言选择
        viewBinding.homeLoginLanguageTv.setOnClickListener(new View.OnClickListener() {
        viewBinding.homeLoginLanguageLl.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ListDialog listDialog = new ListDialog(_mActivity);
@@ -440,6 +439,8 @@
     * @param textView 当前组件
     */
    private void setStringDifferentColors(TextView textView) {
        try {
        if (textView == null) {
            return;
@@ -449,12 +450,19 @@
        if (!s.contains("《")) {
            return;
        }
        int startIndex1 = s.indexOf("《");
        int endIndex1 = s.indexOf("》") + 1;
        int startIndex2 = s.lastIndexOf("《");
        int endIndex2 = s.lastIndexOf("》") + 1;
            if (UserConfigManage.getInstance().getCurrentAppLanguage().equals(LocalManageUtil.en)) {
                s = s.replace("《", "").replace("》", "");
                endIndex1 -= 1;
                startIndex2 -= 2;//移除"《"和"》"总长度发生变化,索引也改变;
                endIndex2 -= 4;//移除"《"和"》"总长度发生变化,索引也改变;
            }
        SpannableStringBuilder spannable = new SpannableStringBuilder(s);
        //设置文字的前景色
        if (textView.getTag() != null && textView.getTag().toString().equals("click")) {
@@ -479,6 +487,7 @@
            }, startIndex1, endIndex1, 0);
                spannable.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), startIndex1, endIndex1, 0);
            spannable.setSpan(new ClickableSpan() {
                @Override
@@ -501,6 +510,7 @@
            }, startIndex2, endIndex2, 0);
                spannable.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), startIndex2, endIndex2, 0);
        }
@@ -509,6 +519,8 @@
        textView.setHighlightColor(getResources().getColor(R.color.text_00000000, null));
        //最后设置可点击,必须实现,否则只能显示样式,无法实现点击效果
        textView.setMovementMethod(LinkMovementMethod.getInstance());
        } catch (Exception ignored) {
        }
    }