页面优化
This commit is contained in:
parent
1ad30ca2b2
commit
8b490e61a8
@ -12,6 +12,7 @@ import com.tenlionsoft.aimz_k.model.MsgCategoryBean
|
||||
@Dao
|
||||
interface MsgCategoryDao {
|
||||
|
||||
|
||||
/**
|
||||
* 获取全部信息
|
||||
*
|
||||
|
@ -29,7 +29,6 @@ import com.tenlionsoft.baselib.utils.LogUtils
|
||||
import com.tenlionsoft.baselib.utils.ToastUtils
|
||||
import com.tenlionsoft.baselib.widget.CenterProgressUpdateView
|
||||
import com.tenlionsoft.baselib.widget.FadePageTransformer
|
||||
import pl.com.salsoft.sqlitestudioremote.SQLiteStudioService
|
||||
import java.io.File
|
||||
|
||||
/**
|
||||
|
@ -46,5 +46,7 @@ class SearchContactActivity : BaseActivity() {
|
||||
|
||||
}
|
||||
}
|
||||
showSoftKeyBoard(mBind.etSearchContact)
|
||||
mBind.etSearchContact.requestFocus()
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package com.tenlionsoft.aimz_k.page.activity
|
||||
|
||||
import android.content.Intent
|
||||
import android.util.Log
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import com.hjq.permissions.OnPermissionCallback
|
||||
@ -10,6 +11,7 @@ import com.tenlionsoft.aimz_k.R
|
||||
import com.tenlionsoft.aimz_k.dao.DbManager
|
||||
import com.tenlionsoft.aimz_k.databinding.ActivitySplashBinding
|
||||
import com.tenlionsoft.aimz_k.model.ReplyBean
|
||||
import com.tenlionsoft.aimz_k.widget.ApplyPermissionDialog
|
||||
import com.tenlionsoft.baselib.base.BaseActivity
|
||||
import com.tenlionsoft.baselib.utils.SpUtils
|
||||
import com.tenlionsoft.baselib.utils.ToastUtils
|
||||
@ -29,9 +31,39 @@ class SplashActivity : BaseActivity() {
|
||||
override fun bindView() {
|
||||
mBinding = DataBindingUtil.setContentView(this, R.layout.activity_splash)
|
||||
mBinding.lifecycleOwner = this
|
||||
XXPermissions.with(this).permission(Permission.MANAGE_EXTERNAL_STORAGE)
|
||||
val isGranted = XXPermissions.isGranted(this, Permission.MANAGE_EXTERNAL_STORAGE)
|
||||
Log.e("SplashActivity", "bindView:${isGranted}")
|
||||
if (!isGranted) {
|
||||
ApplyPermissionDialog.Builder(this)
|
||||
.setCancelOutside(false)
|
||||
.setCancelable(false)
|
||||
.setMessage("为了能正常使用,需要文件管理权限,请前往设置进行授权.")
|
||||
.addConfirmListener(object : ApplyPermissionDialog.OnConfirmListener {
|
||||
override fun onConfirm() {
|
||||
toLoginPage()
|
||||
}
|
||||
|
||||
override fun onCancel() {
|
||||
ToastUtils.error("未授权无法使用App,请自行前往设置页面进行授权.")
|
||||
exitApp()
|
||||
}
|
||||
})
|
||||
.create()
|
||||
.show()
|
||||
} else {
|
||||
toLoginPage()
|
||||
}
|
||||
}
|
||||
|
||||
//打开登录页面
|
||||
fun toLoginPage() {
|
||||
XXPermissions.with(this@SplashActivity)
|
||||
.permission(Permission.MANAGE_EXTERNAL_STORAGE)
|
||||
.request(object : OnPermissionCallback {
|
||||
override fun onGranted(permissions: MutableList<String>, allGranted: Boolean) {
|
||||
override fun onGranted(
|
||||
permissions: MutableList<String>,
|
||||
allGranted: Boolean
|
||||
) {
|
||||
if (allGranted) {
|
||||
lifecycleScope.launch {
|
||||
withContext(Dispatchers.IO) {
|
||||
@ -67,7 +99,8 @@ class SplashActivity : BaseActivity() {
|
||||
override fun run() {
|
||||
startActivity(
|
||||
Intent(
|
||||
this@SplashActivity, LoginActivity::class.java
|
||||
this@SplashActivity,
|
||||
LoginActivity::class.java
|
||||
)
|
||||
);
|
||||
finish();
|
||||
@ -80,11 +113,17 @@ class SplashActivity : BaseActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDenied(permissions: MutableList<String>, doNotAskAgain: Boolean) {
|
||||
override fun onDenied(
|
||||
permissions: MutableList<String>,
|
||||
doNotAskAgain: Boolean
|
||||
) {
|
||||
if (doNotAskAgain) {
|
||||
ToastUtils.error("被永久拒绝授权,请手动授予")
|
||||
// 如果是被永久拒绝就跳转到应用权限系统设置页面
|
||||
XXPermissions.startPermissionActivity(this@SplashActivity, permissions)
|
||||
XXPermissions.startPermissionActivity(
|
||||
this@SplashActivity,
|
||||
permissions
|
||||
)
|
||||
} else {
|
||||
ToastUtils.error("获取权限失败")
|
||||
finish()
|
||||
|
@ -0,0 +1,130 @@
|
||||
package com.tenlionsoft.aimz_k.widget
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.Dialog
|
||||
import android.content.Context
|
||||
import android.content.DialogInterface
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.os.Bundle
|
||||
import android.view.Gravity
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.widget.Button
|
||||
import android.widget.TextView
|
||||
import com.lxj.xpopup.interfaces.OnConfirmListener
|
||||
import com.tenlionsoft.aimz_k.R
|
||||
|
||||
|
||||
class ApplyPermissionDialog : Dialog {
|
||||
constructor(context: Context) : super(context)
|
||||
|
||||
constructor(context: Context, themeResId: Int) : super(context, themeResId)
|
||||
|
||||
constructor(
|
||||
context: Context, cancelable: Boolean, cancelListener: DialogInterface.OnCancelListener?
|
||||
) : super(context, cancelable, cancelListener)
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
val window = this.window
|
||||
val displayMetrics = context.resources.displayMetrics
|
||||
window!!.setGravity(Gravity.CENTER)
|
||||
window.setWindowAnimations(com.tenlionsoft.baselib.R.style.dialog_style)
|
||||
val params = window.attributes
|
||||
params.width = (displayMetrics.widthPixels * 0.8).toInt()
|
||||
params.height = (displayMetrics.heightPixels * 0.2).toInt()
|
||||
window.attributes = params
|
||||
window.setBackgroundDrawable(ColorDrawable())
|
||||
|
||||
}
|
||||
|
||||
class Builder(private val context: Activity) {
|
||||
//提示信息
|
||||
private var message: String? = null
|
||||
|
||||
//是否展示提示信息
|
||||
private var isShowMessage = true
|
||||
|
||||
//是否按返回键取消
|
||||
private var isCancelable = true
|
||||
|
||||
//是否取消
|
||||
private var isCancelOutside = false
|
||||
private var listener: OnConfirmListener? = null
|
||||
|
||||
/**
|
||||
* 设置提示信息
|
||||
* @param message
|
||||
* @return
|
||||
*/
|
||||
fun setMessage(message: String?): Builder {
|
||||
this.message = message
|
||||
return this
|
||||
}
|
||||
|
||||
fun addConfirmListener(listener: OnConfirmListener): Builder {
|
||||
this.listener = listener
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置是否显示提示信息
|
||||
* @param isShowMessage
|
||||
* @return
|
||||
*/
|
||||
fun setShowMessage(isShowMessage: Boolean): Builder {
|
||||
this.isShowMessage = isShowMessage
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置是否可以按返回键取消
|
||||
* @param isCancelable
|
||||
* @return
|
||||
*/
|
||||
fun setCancelable(isCancelable: Boolean): Builder {
|
||||
this.isCancelable = isCancelable
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置是否可以取消
|
||||
* @param isCancelOutside
|
||||
* @return
|
||||
*/
|
||||
fun setCancelOutside(isCancelOutside: Boolean): Builder {
|
||||
this.isCancelOutside = isCancelOutside
|
||||
return this
|
||||
}
|
||||
|
||||
//创建Dialog
|
||||
fun create(): ApplyPermissionDialog {
|
||||
val inflater = LayoutInflater.from(context)
|
||||
val view: View = inflater.inflate(R.layout.dialog_apply_permission, null)
|
||||
//设置带自定义主题的dialog
|
||||
val dialog =
|
||||
ApplyPermissionDialog(context, com.tenlionsoft.baselib.R.style.dialog_style)
|
||||
view.findViewById<TextView>(R.id.tv_hint).text = message
|
||||
?: "为了能正常使用,需要相关权限,请前往设置进行授权."
|
||||
view.findViewById<Button>(R.id.btn_cancel).setOnClickListener {
|
||||
dialog.dismiss()
|
||||
listener?.onCancel()
|
||||
}
|
||||
view.findViewById<Button>(R.id.btn_confirm).setOnClickListener {
|
||||
dialog.dismiss()
|
||||
listener?.onConfirm()
|
||||
}
|
||||
dialog.setContentView(view)
|
||||
dialog.setCancelable(isCancelable)
|
||||
dialog.setCanceledOnTouchOutside(isCancelOutside)
|
||||
return dialog
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
interface OnConfirmListener {
|
||||
fun onConfirm()
|
||||
fun onCancel()
|
||||
}
|
||||
}
|
@ -69,7 +69,7 @@ object BindingUtils {
|
||||
} else {
|
||||
val requestOptions = RequestOptions.bitmapTransform(RoundedCornersTransformation(10, 0))
|
||||
.error(R.drawable.ic_user_default).placeholder(R.drawable.ic_user_default)
|
||||
.skipMemoryCache(true).diskCacheStrategy(DiskCacheStrategy.NONE)
|
||||
.skipMemoryCache(false).diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
||||
Glide.with(imageView.context).load(url).apply(requestOptions).into(imageView)
|
||||
}
|
||||
}
|
||||
@ -84,7 +84,7 @@ object BindingUtils {
|
||||
} else {
|
||||
val requestOptions = RequestOptions.bitmapTransform(RoundedCornersTransformation(10, 0))
|
||||
.error(R.drawable.ic_user_default).placeholder(R.drawable.ic_user_default)
|
||||
.skipMemoryCache(false).diskCacheStrategy(DiskCacheStrategy.NONE)
|
||||
.skipMemoryCache(false).diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
||||
val split = url.split(":")
|
||||
Glide.with(imageView.context).load(NetConfig.FILE_DOWNLOAD_URL + split[0])
|
||||
.apply(requestOptions).into(imageView)
|
||||
@ -115,6 +115,27 @@ object BindingUtils {
|
||||
}
|
||||
}
|
||||
|
||||
@BindingAdapter("convertMsgBean")
|
||||
@JvmStatic
|
||||
fun convertMsgBean(tv: TextView, bean: MsgBean?) {
|
||||
if (bean == null) {
|
||||
tv.text = ""
|
||||
} else {
|
||||
when (bean.msgType) {
|
||||
MsgTypeStateEnum.MSG_TO_OTHER_TXT, MsgTypeStateEnum.MSG_TO_OTHER_MOVIE, MsgTypeStateEnum.MSG_TO_OTHER_IMG, MsgTypeStateEnum.MSG_TO_OTHER_FILE -> {
|
||||
}
|
||||
|
||||
MsgTypeStateEnum.MSG_FROM_OTHER_TXT, MsgTypeStateEnum.MSG_FROM_OTHER_MOVIE, MsgTypeStateEnum.MSG_FROM_OTHER_IMG, MsgTypeStateEnum.MSG_FROM_OTHER_FILE -> {
|
||||
val nickName =
|
||||
if (bean.receiverNickName.isNullOrEmpty()) "匿名用户" else bean.receiverNickName
|
||||
val time = TimeUtils.getFriendlyTimeSpanByNow(bean.timestamp!!)
|
||||
val txt = nickName?.plus(" $time")
|
||||
tv.text = txt
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@BindingAdapter("imgUserIconType")
|
||||
@JvmStatic
|
||||
fun bindCategoryUserIcon(iv: ImageView, bean: MsgCategoryBean?) {
|
||||
@ -123,7 +144,7 @@ object BindingUtils {
|
||||
} else {
|
||||
val requestOptions = RequestOptions.bitmapTransform(RoundedCornersTransformation(10, 0))
|
||||
.error(R.drawable.ic_user_default).placeholder(R.drawable.ic_user_default)
|
||||
.skipMemoryCache(true).diskCacheStrategy(DiskCacheStrategy.NONE)
|
||||
.skipMemoryCache(false).diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
||||
val split = bean.avatar?.split(":")
|
||||
if (split != null) {
|
||||
Glide.with(iv.context).load(NetConfig.FILE_DOWNLOAD_URL + (split[0]))
|
||||
@ -140,15 +161,13 @@ object BindingUtils {
|
||||
} else {
|
||||
val requestOptions = RequestOptions.bitmapTransform(RoundedCornersTransformation(10, 0))
|
||||
.error(R.drawable.ic_user_default).placeholder(R.drawable.ic_user_default)
|
||||
.skipMemoryCache(true).diskCacheStrategy(DiskCacheStrategy.NONE)
|
||||
.skipMemoryCache(false).diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
||||
when (bean.msgType) {
|
||||
MsgTypeStateEnum.MSG_TO_OTHER_TXT, MsgTypeStateEnum.MSG_TO_OTHER_MOVIE, MsgTypeStateEnum.MSG_TO_OTHER_IMG, MsgTypeStateEnum.MSG_TO_OTHER_FILE -> {
|
||||
val split = bean.senderAvatar?.split(":")
|
||||
if (split != null) {
|
||||
Glide.with(iv.context).load(NetConfig.FILE_DOWNLOAD_URL + (split[0]))
|
||||
.apply(requestOptions).into(iv)
|
||||
} else {
|
||||
iv.setImageResource(R.drawable.ic_user_default)
|
||||
}
|
||||
}
|
||||
|
||||
@ -157,8 +176,6 @@ object BindingUtils {
|
||||
if (split != null) {
|
||||
Glide.with(iv.context).load(NetConfig.FILE_DOWNLOAD_URL + split[0])
|
||||
.apply(requestOptions).into(iv)
|
||||
} else {
|
||||
iv.setImageResource(R.drawable.ic_user_default)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -227,8 +244,8 @@ object BindingUtils {
|
||||
|
||||
val options = RequestOptions.bitmapTransform(RoundedCornersTransformation(10, 0))
|
||||
.error(com.tenlionsoft.baselib.R.drawable.ic_img_load_err)
|
||||
.placeholder(com.tenlionsoft.baselib.R.drawable.ic_loading).skipMemoryCache(true)
|
||||
.diskCacheStrategy(DiskCacheStrategy.NONE)
|
||||
.placeholder(com.tenlionsoft.baselib.R.drawable.ic_loading).skipMemoryCache(false)
|
||||
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
||||
val gson = Gson()
|
||||
val bodyContent = gson.fromJson<BodyContent>(str, BodyContent::class.java)
|
||||
|
||||
@ -267,7 +284,7 @@ object BindingUtils {
|
||||
val fileData = gson.fromJson(body.content, FileDataBean::class.java)
|
||||
val requestOptions = RequestOptions()
|
||||
.error(R.drawable.app_logo_small).placeholder(R.drawable.app_logo_small)
|
||||
.skipMemoryCache(true).diskCacheStrategy(DiskCacheStrategy.NONE)
|
||||
.skipMemoryCache(false).diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
||||
|
||||
Glide.with(view.context).load(NetConfig.MAIN_URL + fileData.fileUrl)
|
||||
.apply(requestOptions).into(view)
|
||||
|
5
app/src/main/res/drawable/sel_login_btn_gray.xml
Normal file
5
app/src/main/res/drawable/sel_login_btn_gray.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_pressed="true" android:drawable="@drawable/shp_gray_btn_press"/>
|
||||
<item android:state_pressed="false" android:drawable="@drawable/shp_gray_deep_btn_press"/>
|
||||
</selector>
|
6
app/src/main/res/drawable/shp_gray_deep_btn_press.xml
Normal file
6
app/src/main/res/drawable/shp_gray_deep_btn_press.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<solid android:color="@color/gray_bg" />
|
||||
<corners android:radius="25dp" />
|
||||
</shape>
|
70
app/src/main/res/layout/dialog_apply_permission.xml
Normal file
70
app/src/main/res/layout/dialog_apply_permission.xml
Normal file
@ -0,0 +1,70 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/shp_tr_radius_5"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:text="权限申请"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_hint"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="15dp"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/gray_6f"
|
||||
android:textSize="14sp"
|
||||
tools:text="为了能正常使用,需要文件管理权限" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_margin="10dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_cancel"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/sel_login_btn_gray"
|
||||
android:minWidth="0dp"
|
||||
android:minHeight="0dp"
|
||||
android:padding="5dp"
|
||||
android:stateListAnimator="@null"
|
||||
android:text="取消"
|
||||
android:textColor="@color/black" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_confirm"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="15dp"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/sel_login_btn"
|
||||
android:minWidth="0dp"
|
||||
android:minHeight="0dp"
|
||||
android:padding="5dp"
|
||||
android:stateListAnimator="@null"
|
||||
android:text="去授权"
|
||||
android:textColor="@color/col_login_btn" />
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
@ -59,19 +59,38 @@
|
||||
tools:visibility="visible" />
|
||||
</RelativeLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_content"
|
||||
jsonConvertMsgBody="@{bean.body}"
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/ic_message_text_send"
|
||||
android:gravity="center|left"
|
||||
android:maxWidth="200dp"
|
||||
android:paddingLeft="5dp"
|
||||
android:paddingRight="10dp"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="14sp"
|
||||
tools:text="测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试" />
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
convertMsgBean="@{bean}"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:gravity="right"
|
||||
android:textColor="@color/gray_6f"
|
||||
android:textSize="11sp"
|
||||
tools:text="张三 20323423" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_content"
|
||||
jsonConvertMsgBody="@{bean.body}"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="2dp"
|
||||
android:gravity="center|left"
|
||||
android:maxWidth="200dp"
|
||||
android:paddingLeft="5dp"
|
||||
android:paddingRight="10dp"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="14sp"
|
||||
tools:text="测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
@ -27,11 +27,10 @@
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_user_icon"
|
||||
imgUserIconTypeMsg="@{bean}"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:scaleType="fitXY"
|
||||
imgUserIconTypeMsg="@{bean}" />
|
||||
|
||||
android:scaleType="fitXY" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_content"
|
||||
@ -45,7 +44,8 @@
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingRight="5dp"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="14sp" />
|
||||
android:textSize="14sp"
|
||||
tools:text="测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试" />
|
||||
|
||||
|
||||
<RelativeLayout
|
||||
|
Loading…
Reference in New Issue
Block a user