Commit 82aa8edf by 刘鹏

feat : 修改文案,扩展弹窗文字加粗样式

parent 56476718
......@@ -19,8 +19,8 @@ import java.util.List;
*/
public final class DemoGlobalConfig implements IConfigModule {
String APP_DOMAIN = "https://api.github.com/";
// public static String appEnv = YDLConstants.ENV_TEST;
public static String appEnv = YDLConstants.ENV_NEW_TEST;
public static String appEnv = YDLConstants.ENV_TEST;
// public static String appEnv = YDLConstants.ENV_NEW_TEST;
// public static String appEnv = YDLConstants.ENV_PROD;
@Override
......
......@@ -10,7 +10,7 @@ ext {
"m-fm" : "0.0.30.03",
"m-user" : "0.0.61.89",
"m-home" : "0.0.22.70",
"m-im" : "0.0.20.72",
"m-im" : "0.0.20.73",
"m-dynamic" : "0.0.7.28",
"m-article" : "0.0.0.10",
......@@ -33,7 +33,7 @@ ext {
//-------------- 功能组件 --------------
//第一步
"ydl-platform" : "0.0.40.63",
"ydl-platform" : "0.0.40.66",
//第二步 若干
"ydl-webview" : "0.0.38.56",
......@@ -94,7 +94,7 @@ ext {
"m-fm" : "0.0.30.01",
"m-user" : "0.0.61.89",
"m-home" : "0.0.22.70",
"m-im" : "0.0.20.72",
"m-im" : "0.0.20.73",
"m-dynamic" : "0.0.7.28",
"m-article" : "0.0.0.8",
......@@ -116,7 +116,7 @@ ext {
//-------------- 功能组件 --------------
//第一步
"ydl-platform" : "0.0.40.63",
"ydl-platform" : "0.0.40.66",
//第二步 若干
"ydl-webview" : "0.0.38.56",
......
......@@ -3,11 +3,13 @@ package com.yidianling.medical.archives
import android.annotation.SuppressLint
import android.content.Context
import android.content.Intent
import android.view.*
import com.ydl.ydlcommon.base.BaseActivity
import com.ydl.ydlcommon.utils.StatusBarUtils
import com.ydl.ydlcommon.view.dialog.NormalDialog
import com.yidianling.common.tools.ToastUtil
import com.yidianling.im.R
import com.yidianling.medical.utils.EditTextUtils
import com.yidianling.uikit.custom.http.ServiceImpl
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
......@@ -36,6 +38,8 @@ class MedicalAddNewArchivesActivity : BaseActivity() {
}
override fun initDataAndEvent() {
mMarried = -1
mRelation = -1
initStatus()
group_merried.setOnCheckedChangeListener { group, checkedId ->
//婚姻状态
......@@ -102,6 +106,8 @@ class MedicalAddNewArchivesActivity : BaseActivity() {
checkInfo()
}
EditTextUtils.disableCopyAndPaste(et_name)
iv_back.setOnClickListener { finish() }
showDialogTip()
......@@ -110,10 +116,10 @@ class MedicalAddNewArchivesActivity : BaseActivity() {
private fun showDialogTip() {
val builder = NormalDialog.Builder(this@MedicalAddNewArchivesActivity, "center", false)
builder.setTitle("")
builder.setMessage("\n为向您添加的就诊人提供问诊服务,您需要向我们提供该就诊人的身份证号码,并确保在提供前已取得该就诊人的授权同意;若该就诊人为儿童的,您需要在提供前征得该儿童监护人的同意。\n")
builder.setMessageEndBold(
"\n为向您添加的就诊人提供问诊服务,您需要向我们提供该",
"就诊人的身份证号码,并确保在提供前已取得该就诊人的授权同意;若该就诊人为儿童的,您需要在提供前征得该儿童监护人的同意。\n"
var strs = arrayOf("就诊人的身份证号码", "就诊人的授权同意", "您需要在提供前征得该儿童监护人的同意")
builder.setMessageAndBolds(
"\n为向您添加的就诊人提供问诊服务,您需要向我们提供该就诊人的身份证号码,并确保在提供前已取得该就诊人的授权同意;若该就诊人为儿童的,您需要在提供前征得该儿童监护人的同意。\n",
strs
)
builder.setPositiveButton(
"同意"
......@@ -185,4 +191,5 @@ class MedicalAddNewArchivesActivity : BaseActivity() {
StatusBarUtils.setTransparentForImageView(this@MedicalAddNewArchivesActivity, null)
StatusBarUtils.statusBarLightMode(this@MedicalAddNewArchivesActivity)
}
}
\ No newline at end of file
package com.yidianling.medical.utils
import android.view.*
import android.widget.EditText
import android.widget.TextView
import java.lang.reflect.Field
class EditTextUtils {
companion object{
/**
* 禁止输入框复制粘贴菜单
*/
fun disableCopyAndPaste(editText: EditText?) {
try {
if (editText == null) {
return
}
editText.setOnLongClickListener(object : View.OnLongClickListener {
override fun onLongClick(v: View?): Boolean {
return true
}
})
editText.setLongClickable(false)
editText.setOnTouchListener(object : View.OnTouchListener {
override fun onTouch(v: View?, event: MotionEvent): Boolean {
if (event.getAction() === MotionEvent.ACTION_DOWN) {
// setInsertionDisabled when user touches the view
setInsertionDisabled(editText)
}
return false
}
})
editText.setCustomSelectionActionModeCallback(object : ActionMode.Callback {
override fun onCreateActionMode(mode: ActionMode?, menu: Menu?): Boolean {
return false
}
override fun onPrepareActionMode(mode: ActionMode?, menu: Menu?): Boolean {
return false
}
override fun onActionItemClicked(mode: ActionMode?, item: MenuItem?): Boolean {
return false
}
override fun onDestroyActionMode(mode: ActionMode?) {}
})
} catch (e: Exception) {
e.printStackTrace()
}
}
private fun setInsertionDisabled(editText: EditText) {
try {
val editorField: Field = TextView::class.java.getDeclaredField("mEditor")
editorField.setAccessible(true)
val editorObject: Any = editorField.get(editText)
// if this view supports insertion handles
val editorClass = Class.forName("android.widget.Editor")
val mInsertionControllerEnabledField: Field =
editorClass.getDeclaredField("mInsertionControllerEnabled")
mInsertionControllerEnabledField.setAccessible(true)
mInsertionControllerEnabledField.set(editorObject, false)
// if this view supports selection handles
val mSelectionControllerEnabledField: Field =
editorClass.getDeclaredField("mSelectionControllerEnabled")
mSelectionControllerEnabledField.setAccessible(true)
mSelectionControllerEnabledField.set(editorObject, false)
} catch (e: java.lang.Exception) {
e.printStackTrace()
}
}
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#1a3464ec"/>
<corners android:radius="4dp"/>
<solid android:color="#1a3464ec" />
<corners android:radius="4dp" />
<stroke
android:width="1px"
android:color="@color/medical_color_3464ec" />
</shape>
\ No newline at end of file
......@@ -5,8 +5,8 @@
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="@dimen/platform_dp_12"
android:background="#cce7ecf0"
app:cardBackgroundColor="#cce7ecf0"
android:background="#e7ecf0"
app:cardBackgroundColor="#e7ecf0"
android:elevation="0dp"
android:maxWidth="263dp"
android:minWidth="263dp"
......@@ -21,8 +21,9 @@
android:layout_marginTop="8dp"
android:layout_marginRight="12dp"
android:layout_marginBottom="8dp"
android:textStyle="bold"
android:text="本次诊断结束,如有问题可联系客服或再次向医生问诊"
android:textColor="#ff8595a9"
android:textSize="13sp" />
android:textColor="@color/medical_color_0c1d31"
android:textSize="16sp" />
</androidx.cardview.widget.CardView>
\ No newline at end of file
......@@ -28,7 +28,6 @@
android:text="图文问诊"
android:textColor="#ff0c1d31"
android:textSize="18sp"
android:textStyle="bold"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
......
......@@ -2,7 +2,8 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
......@@ -70,6 +71,9 @@
android:background="@null"
android:textStyle="bold"
android:hint="请输入真实姓名"
android:maxEms="15"
android:maxLength="15"
tools:text="123456789012345678910111212"
android:textColor="@color/medical_color_0c1d31"
android:textColorHint="@color/medical_color_c0c9d4"
android:textSize="16sp"
......
......@@ -272,7 +272,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="13dp"
android:text="上传检查报告或患处照片(最多9张)"
android:text="上传检查报告照片(最多9张)"
android:textColor="@color/medical_color_0c1d31"
app:layout_constraintBottom_toTopOf="@id/camera_text_bottom"
app:layout_constraintLeft_toRightOf="@id/camera_bg"
......
package com.ydl.ydlcommon.utils
import android.content.Context
import android.graphics.Typeface
import android.text.SpannableString
import android.text.Spanned
import android.text.style.StyleSpan
class FontUtils {
companion object {
fun getMultiFontText(
text: String,
wordsToBold: Array<String>
): SpannableString? {
val spannableString = SpannableString(text)
for (word in wordsToBold) {
var startIndex = text.indexOf(word)
while (startIndex >= 0) {
val endIndex = startIndex + word.length
spannableString.setSpan(
StyleSpan(Typeface.BOLD),
startIndex,
endIndex,
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
)
startIndex = text.indexOf(word, endIndex + 1)
}
}
return spannableString
}
}
}
\ No newline at end of file
......@@ -6,10 +6,7 @@ import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.Color;
import android.graphics.Typeface;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.style.StyleSpan;
import android.text.SpannableString;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
......@@ -18,6 +15,7 @@ import android.widget.LinearLayout;
import android.widget.TextView;
import com.ydl.ydlcommon.R;
import com.ydl.ydlcommon.utils.FontUtils;
/**
......@@ -42,8 +40,7 @@ public class NormalDialog extends Dialog {
private Context context; //上下文对象
private String title; //对话框标题
private String message; //对话框内容
private String messageStar; //对话框内容开始
private String messageEnd; //对话框内容加粗部分
private String[] wordsToBold; //对话框需要加粗字体
private String confirm_btnText; //按钮名称“确定”
private String cancel_btnText; //按钮名称“取消”
private View contentView; //对话框中间加载的其他布局界面
......@@ -96,9 +93,9 @@ public class NormalDialog extends Dialog {
return this;
}
public Builder setMessageEndBold(String strStart, String strEnd) {
this.messageStar = strStart;
this.messageEnd = strEnd;
public Builder setMessageAndBolds(String message, String[] wordsToBold) {
this.message = message;
this.wordsToBold = wordsToBold;
return this;
}
......@@ -267,6 +264,7 @@ public class NormalDialog extends Dialog {
right_btn.setText(confirm_btnText);
if (confirm_btnClickListener != null) {
right_btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
confirm_btnClickListener.onClick(dialog,
DialogInterface.BUTTON_POSITIVE);
......@@ -286,6 +284,7 @@ public class NormalDialog extends Dialog {
left_btn.setText(cancel_btnText);
if (cancel_btnClickListener != null) {
left_btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
cancel_btnClickListener.onClick(dialog,
DialogInterface.BUTTON_NEGATIVE);
......@@ -309,10 +308,9 @@ public class NormalDialog extends Dialog {
message_tv.setTextColor(Color.parseColor(content_color));
}
if (messageStar != null) {
SpannableStringBuilder builder = new SpannableStringBuilder(messageStar + messageEnd);
builder.setSpan(new StyleSpan(Typeface.BOLD), messageStar.length(), messageStar.length() + messageEnd.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
message_tv.setText(builder);
if (wordsToBold != null && wordsToBold.length > 0) {
SpannableString multiFontText = FontUtils.Companion.getMultiFontText(message, wordsToBold);
message_tv.setText(multiFontText);
} else {
message_tv.setText(message);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment