删除确认对话框
This commit is contained in:
parent
7c4691a1ed
commit
19cd98cea5
|
|
@ -6,8 +6,10 @@ import android.text.method.ScrollingMovementMethod
|
|||
import android.view.Gravity
|
||||
import android.view.ViewGroup
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.core.view.isVisible
|
||||
import com.remax.visualnovel.R
|
||||
import com.remax.visualnovel.databinding.DialogConfirmBinding
|
||||
import com.remax.visualnovel.databinding.DialogDoubleBtnBinding
|
||||
import com.remax.visualnovel.databinding.DialogSingleBtnLayout2Binding
|
||||
import com.remax.visualnovel.databinding.DialogSingleBtnLayoutBinding
|
||||
|
|
@ -22,9 +24,48 @@ import com.remax.visualnovel.widget.uitoken.changeTextStyle
|
|||
import com.remax.visualnovel.widget.uitoken.view.UITokenTextView
|
||||
import kotlin.math.min
|
||||
|
||||
|
||||
/**
|
||||
* Created by HJW on 2025/7/18
|
||||
* 底部水平布局 两个按钮的dialog
|
||||
*/
|
||||
fun Activity.showConfirmDialog(
|
||||
@DrawableRes dialogBg: Int? = null,
|
||||
@StringRes title: Int? = null,
|
||||
@StringRes description: Int? = null,
|
||||
@DrawableRes topBtnIconRes: Int? = null,
|
||||
topBtnClick: (() -> Unit)? = null,
|
||||
@StringRes bottomLeftStrRes: Int? = null,
|
||||
@StringRes bottomRightStrRes: Int? = null,
|
||||
bottomRightClick: (() -> Unit)? = null,
|
||||
): LBindingDialog<DialogConfirmBinding> {
|
||||
|
||||
val dialog = LBindingDialog(this, DialogConfirmBinding::inflate)
|
||||
.with()
|
||||
.setCenter()
|
||||
|
||||
dialog.setCanceledOnTouchOutside(false)
|
||||
dialog.setCancelable(false)
|
||||
|
||||
dialog.binding.run {
|
||||
setOnClick(ivTop, tvRight, tvLeft) {
|
||||
when (this) {
|
||||
tvRight -> bottomRightClick?.invoke()
|
||||
ivTop -> topBtnClick?.invoke()
|
||||
}
|
||||
dialog.dismiss()
|
||||
}
|
||||
|
||||
if (dialogBg != null) root.background = getDrawable(dialogBg)
|
||||
if (topBtnIconRes != null) ivTop.setImageResource(topBtnIconRes) else tvTitle.isVisible = false
|
||||
if (title != null) tvTitle.text = getString(title) else tvTitle.isVisible = false
|
||||
if (description != null) tvDescription.text = getString(description) else tvDescription.isVisible = false
|
||||
if (bottomLeftStrRes != null) tvLeft.text = getString(bottomLeftStrRes) else tvLeft.isVisible = false
|
||||
if (bottomRightStrRes != null) tvRight.text = getString(bottomRightStrRes) else tvRight.isVisible = false
|
||||
}
|
||||
|
||||
dialog.show()
|
||||
return dialog
|
||||
}
|
||||
|
||||
/**
|
||||
* 双按钮的全局统一的dialog样式
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ import android.util.AttributeSet
|
|||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.widget.LinearLayout
|
||||
import androidx.core.content.ContextCompat.getString
|
||||
import androidx.core.graphics.toColorInt
|
||||
import com.remax.visualnovel.R
|
||||
import com.remax.visualnovel.databinding.LayoutChatMenuViewBinding
|
||||
|
|
@ -16,7 +15,7 @@ import com.remax.visualnovel.entity.response.ChatBubble
|
|||
import com.remax.visualnovel.entity.response.ChatHistory
|
||||
import com.remax.visualnovel.entity.response.ChatMode
|
||||
import com.remax.visualnovel.entity.response.ChatSound
|
||||
import com.remax.visualnovel.extension.showDoubleBtnDialog
|
||||
import com.remax.visualnovel.extension.showConfirmDialog
|
||||
import com.remax.visualnovel.ui.chat.ui.expandableSelector.ExpandAiModelSelectView
|
||||
import com.remax.visualnovel.ui.chat.ui.expandableSelector.ExpandBubbleSelectView
|
||||
import com.remax.visualnovel.ui.chat.ui.expandableSelector.ExpandChatModeSelectView
|
||||
|
|
@ -55,12 +54,15 @@ class ChatSettingView @JvmOverloads constructor(
|
|||
private fun initOtherClickEvent() {
|
||||
with (mBinding) {
|
||||
llDelete.setOnClickListener {
|
||||
activity?.showDoubleBtnDialog(
|
||||
getString(context, R.string.delete_chat),
|
||||
getString(context, R.string.delete_chat_hint),
|
||||
isDel = true,
|
||||
topBtnText = getString(context, R.string.sure),
|
||||
topBtnClick = {
|
||||
activity?.showConfirmDialog (
|
||||
dialogBg = R.drawable.chat_delete_bg,
|
||||
R.string.delete_chat,
|
||||
R.string.delete_chat_hint,
|
||||
R.mipmap.setting_delete,
|
||||
null,
|
||||
R.string.no,
|
||||
R.string.sure,
|
||||
{
|
||||
// TODO - do delete the chat
|
||||
}
|
||||
)
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ class ExpandSoundSubView @JvmOverloads constructor(
|
|||
}
|
||||
|
||||
tvSoundName.text = item.name
|
||||
itemRoot.setBgColorDirectly(bgColor = ResUtil.getColor(if (item.isMale) R.color.male_bg else R.color.female_bg), radius = ResUtil.getPixelSize(R.dimen.dp_10).toFloat())
|
||||
itemRoot.setBgColorDirectly(bgColor = ResUtil.getColor(if (item.isMale) R.color.male_bg else R.color.female_bg), radius = ResUtil.getPixelSize(R.dimen.dp_10).toFloat(), bgDrawable = null)
|
||||
tvSoundDescrible.setTextColor(ResUtil.getColor(if (item.isMale) R.color.male_text_color else R.color.female_text_color))
|
||||
tvSoundDescrible.text = item.description
|
||||
ivSelect.setImageResource(if (item.select) R.drawable.sound_item_selected else R.drawable.sound_item_unselected)
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import android.graphics.Outline
|
|||
import android.graphics.Shader
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.graphics.drawable.GradientDrawable
|
||||
import android.graphics.drawable.LayerDrawable
|
||||
import android.graphics.drawable.StateListDrawable
|
||||
import android.os.Build
|
||||
import android.util.TypedValue
|
||||
|
|
@ -184,10 +185,12 @@ fun View.changeBackground(customViewToken: CustomViewToken) {
|
|||
customViewToken.run {
|
||||
if (advRadius > 0 || advStrokeWidth > 0 ||
|
||||
advTopRightRadius > 0 || advTopLeftRadius > 0 ||
|
||||
advBottomLeftRadius > 0 || advBottomRightRadius > 0) {
|
||||
advBottomLeftRadius > 0 || advBottomRightRadius > 0
|
||||
|| advBgDrawable != null) {
|
||||
setBgColorDirectly(
|
||||
bgColor = advBgColor,
|
||||
radius = advRadius,
|
||||
bgDrawable = advBgDrawable,
|
||||
topLeftRadius = if (advTopLeftRadius > 0F) advTopLeftRadius else advRadius,
|
||||
topRightRadius = if (advTopRightRadius > 0F) advTopRightRadius else advRadius,
|
||||
bottomRightRadius = if (advBottomRightRadius > 0F) advBottomRightRadius else advRadius,
|
||||
|
|
@ -522,6 +525,7 @@ fun View.getGradientDrawable(
|
|||
fun View.setBgColorDirectly(
|
||||
bgColor: Int = 0,
|
||||
radius: Float = 0F,
|
||||
bgDrawable: Drawable?,
|
||||
topLeftRadius: Float = radius,
|
||||
topRightRadius: Float = radius,
|
||||
bottomRightRadius: Float = radius,
|
||||
|
|
@ -532,6 +536,7 @@ fun View.setBgColorDirectly(
|
|||
val resDrawable = StateListDrawable()
|
||||
val normalDrawable = getGradientDrawableDirectly(
|
||||
bgColor,
|
||||
bgDrawable,
|
||||
topLeftRadius,
|
||||
topRightRadius,
|
||||
bottomRightRadius,
|
||||
|
|
@ -546,6 +551,7 @@ fun View.setBgColorDirectly(
|
|||
|
||||
fun View.getGradientDrawableDirectly(
|
||||
bgColor: Int = 0,
|
||||
bgDrawable: Drawable?,
|
||||
topLeftRadius: Float = 0F,
|
||||
topRightRadius: Float = 0F,
|
||||
bottomRightRadius: Float = 0F,
|
||||
|
|
@ -571,6 +577,6 @@ fun View.getGradientDrawableDirectly(
|
|||
bottomLeftRadius,
|
||||
bottomLeftRadius
|
||||
)
|
||||
return gradientDrawable
|
||||
}
|
||||
|
||||
return if (bgDrawable != null) LayerDrawable(arrayOf(bgDrawable, gradientDrawable)) else gradientDrawable
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.remax.visualnovel.widget.uitoken.bean
|
||||
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.Drawable
|
||||
|
||||
/**
|
||||
* Created by HJW on 2022/9/1
|
||||
|
|
@ -47,6 +48,7 @@ data class CustomViewToken(
|
|||
|
||||
//---------------------- New added -----------------------
|
||||
var advBgColor:Int = Color.TRANSPARENT,
|
||||
var advBgDrawable: Drawable? = null,
|
||||
var advRadius:Float = 0F,
|
||||
var advTopLeftRadius:Float = 0F,
|
||||
var advTopRightRadius:Float = 0F,
|
||||
|
|
|
|||
|
|
@ -81,6 +81,7 @@ open class UITokenTextView @JvmOverloads constructor(context: Context, private v
|
|||
|
||||
//<!-- new added 2025.10.29 -->
|
||||
advBgColor = getColor(R.styleable.UITokenTextView_advBgColor, advBgColor)
|
||||
advBgDrawable = getDrawable(R.styleable.UITokenTextView_advBgDrawable)
|
||||
advRadius = getDimension(R.styleable.UITokenTextView_advRadius, advRadius)
|
||||
advTopLeftRadius = getDimension(R.styleable.UITokenTextView_advTopLeftRadius, advTopLeftRadius)
|
||||
advTopRightRadius = getDimension(R.styleable.UITokenTextView_advTopRightRadius, advTopRightRadius)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,107 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.remax.visualnovel.widget.uitoken.view.UITokenConstraintLayout
|
||||
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="wrap_content"
|
||||
android:padding="@dimen/dp_20"
|
||||
app:advRadius="@dimen/dp_25"
|
||||
app:advBgDrawable="@drawable/chat_delete_bg">
|
||||
|
||||
|
||||
<com.remax.visualnovel.widget.uitoken.view.UITokenImageView
|
||||
android:id="@+id/iv_top"
|
||||
android:layout_width="@dimen/dp_98"
|
||||
android:layout_height="@dimen/dp_98"
|
||||
android:padding="@dimen/dp_20"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:src="@mipmap/setting_delete"
|
||||
android:tint="@color/white"
|
||||
app:advBgColor="@color/red_ff3b30"
|
||||
app:advRadius="@dimen/dp_49"
|
||||
android:scaleType="fitCenter"
|
||||
/>
|
||||
|
||||
<com.remax.visualnovel.widget.uitoken.view.UITokenTextView
|
||||
android:id="@+id/tv_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/iv_top"
|
||||
android:layout_marginTop="@dimen/dp_10"
|
||||
android:text="title"
|
||||
android:textStyle="bold"
|
||||
android:textSize="@dimen/sp_18"
|
||||
android:textColor="@color/black"
|
||||
/>
|
||||
|
||||
<com.remax.visualnovel.widget.uitoken.view.UITokenTextView
|
||||
android:id="@+id/tv_description"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tv_title"
|
||||
android:layout_marginTop="@dimen/dp_20"
|
||||
android:text="des"
|
||||
android:textSize="@dimen/sp_14"
|
||||
android:textColor="@color/gray9"
|
||||
/>
|
||||
|
||||
|
||||
<com.remax.visualnovel.widget.uitoken.view.UITokenLinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tv_description"
|
||||
android:layout_marginTop="@dimen/dp_50"
|
||||
android:orientation="horizontal">
|
||||
<com.remax.visualnovel.widget.uitoken.view.UITokenTextView
|
||||
android:id="@+id/tv_left"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="@dimen/dp_10"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tv_title"
|
||||
android:layout_marginTop="@dimen/dp_20"
|
||||
android:text="@string/no"
|
||||
android:textSize="@dimen/sp_15"
|
||||
android:textStyle="bold"
|
||||
android:textColor="@color/black"
|
||||
android:padding="@dimen/dp_15"
|
||||
app:advStrokeColor="@color/gray9"
|
||||
app:advStrokeWidth="@dimen/dp_2"
|
||||
app:advRadius="@dimen/dp_25"
|
||||
/>
|
||||
|
||||
<com.remax.visualnovel.widget.uitoken.view.UITokenTextView
|
||||
android:id="@+id/tv_right"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="@dimen/dp_10"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tv_title"
|
||||
android:layout_marginTop="@dimen/dp_20"
|
||||
android:text="@string/sure"
|
||||
android:textSize="@dimen/sp_15"
|
||||
android:textStyle="bold"
|
||||
android:textColor="@color/white"
|
||||
android:padding="@dimen/dp_15"
|
||||
app:advBgColor="@color/red_ff3b30"
|
||||
app:advRadius="@dimen/dp_25"
|
||||
/>
|
||||
</com.remax.visualnovel.widget.uitoken.view.UITokenLinearLayout>
|
||||
|
||||
|
||||
</com.remax.visualnovel.widget.uitoken.view.UITokenConstraintLayout>
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.remax.visualnovel.widget.uitoken.view.UITokenConstraintLayout
|
||||
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="wrap_content"
|
||||
android:padding="@dimen/dp_20"
|
||||
app:advRadius="@dimen/dp_25"
|
||||
app:advBgColor="@color/blue_6f">
|
||||
|
||||
|
||||
|
||||
|
||||
</com.remax.visualnovel.widget.uitoken.view.UITokenConstraintLayout>
|
||||
|
|
@ -61,6 +61,7 @@
|
|||
|
||||
<!-- new added 2025.10.29 -->
|
||||
<attr name="advBgColor" format="color" />
|
||||
<attr name="advBgDrawable" format="reference" />
|
||||
<attr name="advRadius" format="dimension" />
|
||||
<attr name="advTopLeftRadius" format="dimension" />
|
||||
<attr name="advTopRightRadius" format="dimension" />
|
||||
|
|
@ -112,6 +113,7 @@
|
|||
|
||||
<!-- new added 2025.10.29 -->
|
||||
<attr name="advBgColor" />
|
||||
<attr name="advBgDrawable" />
|
||||
<attr name="advRadius" />
|
||||
<attr name="advTopLeftRadius" />
|
||||
<attr name="advTopRightRadius" />
|
||||
|
|
@ -150,6 +152,7 @@
|
|||
|
||||
<!-- new added 2025.10.29 -->
|
||||
<attr name="advBgColor" />
|
||||
<attr name="advBgDrawable" />
|
||||
<attr name="advRadius" />
|
||||
<attr name="advTopLeftRadius" />
|
||||
<attr name="advTopRightRadius" />
|
||||
|
|
@ -183,6 +186,7 @@
|
|||
|
||||
<!-- new added 2025.10.29 -->
|
||||
<attr name="advBgColor" />
|
||||
<attr name="advBgDrawable" />
|
||||
<attr name="advRadius" />
|
||||
<attr name="advTopLeftRadius" />
|
||||
<attr name="advTopRightRadius" />
|
||||
|
|
@ -216,6 +220,7 @@
|
|||
|
||||
<!-- new added 2025.10.29 -->
|
||||
<attr name="advBgColor" />
|
||||
<attr name="advBgDrawable" />
|
||||
<attr name="advRadius" />
|
||||
<attr name="advTopLeftRadius" />
|
||||
<attr name="advTopRightRadius" />
|
||||
|
|
@ -249,6 +254,7 @@
|
|||
|
||||
<!-- new added 2025.10.29 -->
|
||||
<attr name="advBgColor" />
|
||||
<attr name="advBgDrawable" />
|
||||
<attr name="advRadius" />
|
||||
<attr name="advTopLeftRadius" />
|
||||
<attr name="advTopRightRadius" />
|
||||
|
|
@ -282,6 +288,7 @@
|
|||
|
||||
<!-- new added 2025.10.29 -->
|
||||
<attr name="advBgColor" />
|
||||
<attr name="advBgDrawable" />
|
||||
<attr name="advRadius" />
|
||||
<attr name="advTopLeftRadius" />
|
||||
<attr name="advTopRightRadius" />
|
||||
|
|
@ -315,6 +322,7 @@
|
|||
|
||||
<!-- new added 2025.10.29 -->
|
||||
<attr name="advBgColor" />
|
||||
<attr name="advBgDrawable" />
|
||||
<attr name="advRadius" />
|
||||
<attr name="advTopLeftRadius" />
|
||||
<attr name="advTopRightRadius" />
|
||||
|
|
|
|||
|
|
@ -486,7 +486,7 @@
|
|||
<string name="call_connecting">Connecting...</string>
|
||||
<string name="call_fail_hint">Network connection issue. Please check your connection and try again.</string>
|
||||
<string name="start_new_chat">Start New Chat</string>
|
||||
<string name="delete_chat">Delete Chat</string>
|
||||
<string name="delete_chat">DELETE CHAT</string>
|
||||
<string name="delete_chat_hint">This will permanently remove all data. This action is irreversible. Are you sure?</string>
|
||||
<string name="sure">SURE</string>
|
||||
<string name="no">NO</string>
|
||||
|
|
|
|||
Loading…
Reference in New Issue