加入点赞按钮。

This commit is contained in:
Cold-Mint 2023-04-12 23:42:53 +08:00
parent cfc3a6eb90
commit 528efe3f83
19 changed files with 229 additions and 93 deletions

View File

@ -116,7 +116,7 @@ dependencies {
implementation 'cat.ereza:customactivityoncrash:2.3.0' implementation 'cat.ereza:customactivityoncrash:2.3.0'
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0" implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
implementation 'androidx.appcompat:appcompat:1.5.0' implementation 'androidx.appcompat:appcompat:1.5.0'
implementation 'com.google.android.material:material:1.7.0-rc01' implementation 'com.google.android.material:material:1.9.0-beta01'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation "androidx.navigation:navigation-fragment-ktx:$nav_version" implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
implementation "androidx.navigation:navigation-ui-ktx:$nav_version" implementation "androidx.navigation:navigation-ui-ktx:$nav_version"

View File

@ -194,7 +194,6 @@ class UserHomePageActivity : BaseActivity<ActivityUserHomePageBinding>() {
viewBinding.loginTimeView.text = String.format( viewBinding.loginTimeView.text = String.format(
getString(R.string.user_info), getString(R.string.user_info),
spaceInfoData.data.loginTime, spaceInfoData.data.loginTime,
spaceInfoData.data.account,
spaceInfoData.data.location spaceInfoData.data.location
) )

View File

@ -59,10 +59,10 @@ class DynamicAdapter(context: Context, dataList: MutableList<DynamicItemDataBean
data.time + " " + data.location data.time + " " + data.location
} }
viewBinding.nameView.text = data.userName viewBinding.nameView.text = data.userName
TextStyleMaker.instance.load(viewBinding.textview, data.content) { type, data -> TextStyleMaker.instance.load(viewBinding.contentView, data.content) { type, data ->
TextStyleMaker.instance.clickEvent(context, type, data) TextStyleMaker.instance.clickEvent(context, type, data)
} }
viewBinding.textview.setOnLongClickListener { view -> viewBinding.contentView.setOnLongClickListener { view ->
val menu = GlobalMethod.createPopMenu(view) val menu = GlobalMethod.createPopMenu(view)
menu.menu.add(R.string.copy) menu.menu.add(R.string.copy)
menu.menu.add(R.string.delete_title) menu.menu.add(R.string.delete_title)

View File

@ -49,6 +49,7 @@ abstract class BaseActivity<ViewBingType : ViewBinding> :
} }
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
try {
WindowCompat.setDecorFitsSystemWindows(window, false) WindowCompat.setDecorFitsSystemWindows(window, false)
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
whenCreateActivity(savedInstanceState, false) whenCreateActivity(savedInstanceState, false)
@ -58,6 +59,17 @@ abstract class BaseActivity<ViewBingType : ViewBinding> :
setSupportActionBar(toolBar) setSupportActionBar(toolBar)
} }
whenCreateActivity(savedInstanceState, true) whenCreateActivity(savedInstanceState, true)
} catch (e: Exception) {
e.printStackTrace()
val dialog = CoreDialog(this)
dialog.setTitle(R.string.error)
dialog.setMessage(e.toString())
dialog.setPositiveButton(R.string.dialog_close) {
finish()
}
dialog.show()
}
} }
@ -163,8 +175,8 @@ abstract class BaseActivity<ViewBingType : ViewBinding> :
Snackbar.LENGTH_SHORT Snackbar.LENGTH_SHORT
) )
.setAction(R.string.show_details) { .setAction(R.string.show_details) {
CoreDialog(this).setTitle(R.string.details).setMessage( thisMsg) CoreDialog(this).setTitle(R.string.details).setMessage(thisMsg)
.setPositiveButton(R.string.dialog_ok){ .setPositiveButton(R.string.dialog_ok) {
}.show() }.show()
}.show() }.show()

View File

@ -104,71 +104,71 @@ class TextStyleMaker private constructor() {
val num3 = start3Index val num3 = start3Index
val type = spannable.subSequence(num1 + start.length, num2).toString() val type = spannable.subSequence(num1 + start.length, num2).toString()
val data: String = spannable.subSequence(num2 + start2.length, num3).toString() val data: String = spannable.subSequence(num2 + start2.length, num3).toString()
val chipDrawable = ChipDrawable.createFromResource(context, R.xml.chip) // val chipDrawable = ChipDrawable.createFromResource(context, R.xml.chip)
chipDrawable.text = data // chipDrawable.text = data
when (type) { // when (type) {
"mod" -> { // "mod" -> {
chipDrawable.chipIcon = context.getDrawable(R.drawable.mod) // chipDrawable.chipIcon = context.getDrawable(R.drawable.mod)
}
"user" -> {
chipDrawable.chipIcon = context.getDrawable(R.drawable.head_icon)
// User.getIcon(data, object : ApiCallBack<IconData> {
// override fun onResponse(t: IconData) {
// val data2 = t.data
// if (data2 != null) {
// chipDrawable.text = data2.userName
//
// Glide.with(context)
// .load(ServerConfiguration.getRealLink(data2.headIcon!!))
// .apply(GlobalMethod.getRequestOptions(true))
// .into(
// object : CustomTarget<Drawable>() {
// override fun onResourceReady(
// resource: Drawable,
// transition: Transition<in Drawable>?
// ) {
// chipDrawable.chipIcon = resource
// } // }
// // "user" -> {
// override fun onLoadCleared(placeholder: Drawable?) { // chipDrawable.chipIcon = context.getDrawable(R.drawable.head_icon)
// //// User.getIcon(data, object : ApiCallBack<IconData> {
//// override fun onResponse(t: IconData) {
//// val data2 = t.data
//// if (data2 != null) {
//// chipDrawable.text = data2.userName
////
//// Glide.with(context)
//// .load(ServerConfiguration.getRealLink(data2.headIcon!!))
//// .apply(GlobalMethod.getRequestOptions(true))
//// .into(
//// object : CustomTarget<Drawable>() {
//// override fun onResourceReady(
//// resource: Drawable,
//// transition: Transition<in Drawable>?
//// ) {
//// chipDrawable.chipIcon = resource
//// }
////
//// override fun onLoadCleared(placeholder: Drawable?) {
////
//// }
////
//// }
//// )
//// }
//// }
////
//// override fun onFailure(e: Exception) {
//// }
////
//// })
// } // }
// // "activate"->{
// chipDrawable.chipIcon =
// context.getDrawable(R.drawable.store)
// chipDrawable.text = context.getString(R.string.activate)
// } // }
// "link" -> {
// chipDrawable.chipIcon =
// context.getDrawable(R.drawable.ic_baseline_link_24)
// }
// else -> {
// chipDrawable.chipIcon = context.getDrawable(R.drawable.image)
// }
// }
// chipDrawable.closeIcon = null
// chipDrawable.setBounds(
// 0,
// 0,
// chipDrawable.intrinsicWidth,
// chipDrawable.intrinsicHeight
// )
// val span = ImageSpan(chipDrawable)
// spannable.setSpan(
// span, startIndex,
// start3Index + start3.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
// ) // )
// }
// }
//
// override fun onFailure(e: Exception) {
// }
//
// })
}
"activate"->{
chipDrawable.chipIcon =
context.getDrawable(R.drawable.store)
chipDrawable.text = context.getString(R.string.activate)
}
"link" -> {
chipDrawable.chipIcon =
context.getDrawable(R.drawable.ic_baseline_link_24)
}
else -> {
chipDrawable.chipIcon = context.getDrawable(R.drawable.image)
}
}
chipDrawable.closeIcon = null
chipDrawable.setBounds(
0,
0,
chipDrawable.intrinsicWidth,
chipDrawable.intrinsicHeight
)
val span = ImageSpan(chipDrawable)
spannable.setSpan(
span, startIndex,
start3Index + start3.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
)
spannable.setSpan( spannable.setSpan(
object : ClickableSpan() { object : ClickableSpan() {
override fun onClick(p0: View) { override fun onClick(p0: View) {

View File

@ -1,6 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" <vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp" android:width="24dp"
android:height="24dp" android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportWidth="24" android:viewportWidth="24"
android:viewportHeight="24"> android:viewportHeight="24">

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@android:color/white"
android:pathData="M9,21h9c0.83,0 1.54,-0.5 1.84,-1.22l3.02,-7.05c0.09,-0.23 0.14,-0.47 0.14,-0.73v-2c0,-1.1 -0.9,-2 -2,-2h-6.31l0.95,-4.57 0.03,-0.32c0,-0.41 -0.17,-0.79 -0.44,-1.06L14.17,1 7.58,7.59C7.22,7.95 7,8.45 7,9v10c0,1.1 0.9,2 2,2zM9,9l4.34,-4.34L12,10h9v2l-3,7H9V9zM1,9h4v12H1z" />
</vector>

View File

@ -110,6 +110,8 @@
android:layout_alignParentEnd="true" android:layout_alignParentEnd="true"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:layout_margin="8dp" android:layout_margin="8dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:clickable="false"
android:src="@drawable/next" /> android:src="@drawable/next" />

View File

@ -7,12 +7,15 @@
android:orientation="vertical"> android:orientation="vertical">
<ImageView <ImageView
android:background="?attr/selectableItemBackgroundBorderless"
android:clickable="true"
android:layout_marginTop="32dp" android:layout_marginTop="32dp"
android:id="@+id/imageView" android:id="@+id/imageView"
android:layout_width="72dp" android:layout_width="72dp"
android:layout_height="72dp" android:layout_height="72dp"
android:layout_marginHorizontal="16dp" android:layout_marginHorizontal="16dp"
android:src="@drawable/head_icon" /> android:src="@drawable/head_icon"
android:focusable="true" />
<TextView <TextView
android:id="@+id/nameView" android:id="@+id/nameView"

View File

@ -1,14 +1,18 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <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_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="8dp"> android:padding="8dp">
<ImageView <ImageView
android:background="?attr/selectableItemBackgroundBorderless"
android:clickable="true"
android:id="@+id/iconView" android:id="@+id/iconView"
android:layout_width="40dp" android:layout_width="40dp"
android:layout_height="40dp" android:layout_height="40dp"
android:src="@drawable/head_icon" /> android:src="@drawable/head_icon"
android:focusable="true" />
<LinearLayout <LinearLayout
android:id="@+id/headLayout" android:id="@+id/headLayout"
@ -43,8 +47,58 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@id/headLayout" android:layout_below="@id/headLayout"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
android:text="@string/no_content" /> android:text="@string/no_content" />
<ImageView
android:id="@+id/thumb_up_image_view"
android:layout_width="24dp"
android:layout_height="24dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:layout_below="@id/contentView"
android:layout_marginTop="8dp"
android:padding="2dp"
android:clickable="true"
android:src="@drawable/outline_thumb_up_24"
android:focusable="true" />
<TextView
android:id="@+id/thumb_up_text_view"
style="@style/MaterialAlertDialog.Material3.Body.Text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@id/thumb_up_image_view"
android:layout_marginStart="4dp"
android:layout_toEndOf="@id/thumb_up_image_view"
android:text="0" />
<ImageView
android:background="?attr/selectableItemBackgroundBorderless"
android:clickable="true"
android:id="@+id/share_image_view"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_below="@id/contentView"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_toEndOf="@+id/thumb_up_text_view"
android:padding="2dp"
android:src="@drawable/ic_outline_share_24"
android:focusable="true" />
<ImageView
android:background="?attr/selectableItemBackgroundBorderless"
android:clickable="true"
android:id="@+id/more_image_view"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_below="@id/contentView"
android:layout_alignParentEnd="true"
android:layout_marginTop="8dp"
android:padding="2dp"
android:src="@drawable/more"
android:focusable="true" />
</RelativeLayout> </RelativeLayout>

View File

@ -11,6 +11,7 @@
android:layout_margin="16dp"> android:layout_margin="16dp">
<ImageView <ImageView
android:background="?attr/selectableItemBackgroundBorderless"
android:id="@+id/headIconView" android:id="@+id/headIconView"
android:layout_width="48dp" android:layout_width="48dp"
android:layout_height="48dp" android:layout_height="48dp"
@ -44,7 +45,7 @@
</LinearLayout> </LinearLayout>
<TextView <TextView
android:id="@+id/textview" android:id="@+id/contentView"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@id/contentLayout" android:layout_below="@id/contentLayout"
@ -52,6 +53,54 @@
style="@style/TextAppearance.Material3.BodyMedium" style="@style/TextAppearance.Material3.BodyMedium"
android:text="@string/expiration_time_null" /> android:text="@string/expiration_time_null" />
<ImageView
android:clickable="true"
android:background="?attr/selectableItemBackgroundBorderless"
android:id="@+id/thumb_up_image_view"
android:layout_width="24dp"
android:padding="2dp"
android:layout_height="24dp"
android:layout_below="@id/contentView"
android:layout_marginTop="8dp"
android:src="@drawable/outline_thumb_up_24"
android:focusable="true" />
<TextView
android:layout_marginStart="4dp"
android:id="@+id/thumb_up_text_view"
style="@style/MaterialAlertDialog.Material3.Body.Text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@id/thumb_up_image_view"
android:layout_toEndOf="@id/thumb_up_image_view"
android:text="0" />
<ImageView
android:clickable="true"
android:background="?attr/selectableItemBackgroundBorderless"
android:layout_marginStart="8dp"
android:id="@+id/share_image_view"
android:layout_width="24dp"
android:layout_toEndOf="@+id/thumb_up_text_view"
android:padding="2dp"
android:layout_height="24dp"
android:layout_below="@id/contentView"
android:layout_marginTop="8dp"
android:src="@drawable/ic_outline_share_24"
android:focusable="true" />
<ImageView
android:clickable="true"
android:background="?attr/selectableItemBackgroundBorderless"
android:layout_alignParentEnd="true"
android:id="@+id/more_image_view"
android:layout_width="24dp"
android:padding="2dp"
android:layout_height="24dp"
android:layout_below="@id/contentView"
android:layout_marginTop="8dp"
android:src="@drawable/more"
android:focusable="true" />
</RelativeLayout> </RelativeLayout>
</com.google.android.material.card.MaterialCardView> </com.google.android.material.card.MaterialCardView>

View File

@ -4,6 +4,9 @@
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<ImageView <ImageView
android:background="?attr/selectableItemBackgroundBorderless"
android:clickable="true"
android:focusable="true"
android:id="@+id/imageView" android:id="@+id/imageView"
android:layout_width="60dp" android:layout_width="60dp"
android:layout_height="60dp" android:layout_height="60dp"

View File

@ -35,10 +35,14 @@
<ImageView <ImageView
android:id="@+id/linkView" android:id="@+id/linkView"
android:layout_width="20dp" android:layout_width="24dp"
android:layout_height="20dp" android:layout_height="24dp"
android:layout_alignBottom="@id/titleView" android:layout_alignBottom="@id/titleView"
android:layout_alignParentEnd="true" android:layout_alignParentEnd="true"
android:background="?attr/selectableItemBackgroundBorderless"
android:clickable="true"
android:focusable="true"
android:padding="2dp"
android:src="@drawable/link" /> android:src="@drawable/link" />
<ImageView <ImageView

View File

@ -24,19 +24,19 @@
<TextView <TextView
android:id="@+id/nameView" android:id="@+id/nameView"
style="@style/TextAppearance.Material3.TitleMedium"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/name" android:text="@string/name" />
style="@style/TextAppearance.Material3.TitleMedium" />
<TextView <TextView
android:singleLine="true"
android:ellipsize="end"
style="@style/TextAppearance.Material3.BodySmall"
android:id="@+id/describeView" android:id="@+id/describeView"
style="@style/TextAppearance.Material3.BodySmall"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
android:ellipsize="end"
android:singleLine="true"
android:text="@string/describe" /> android:text="@string/describe" />
</LinearLayout> </LinearLayout>

View File

@ -6,6 +6,7 @@
android:orientation="vertical"> android:orientation="vertical">
<ImageView <ImageView
android:background="?attr/selectableItemBackgroundBorderless"
android:id="@+id/headIconView" android:id="@+id/headIconView"
android:layout_width="56dp" android:layout_width="56dp"
android:layout_height="56dp" android:layout_height="56dp"

View File

@ -788,7 +788,6 @@
<string name="change_server_complete">The server has changed.</string> <string name="change_server_complete">The server has changed.</string>
<string name="order_manager">The order management</string> <string name="order_manager">The order management</string>
<string name="log_out">logout</string> <string name="log_out">logout</string>
<string name="user_info">%1$s uid:%2$s location:%3$s</string>
<string name="use_coupon">Will use coupons to create orders, still continue\? (After creating the order, use the coupon)</string> <string name="use_coupon">Will use coupons to create orders, still continue\? (After creating the order, use the coupon)</string>
<string name="use">use</string> <string name="use">use</string>
<string name="account_or_email">Account/email</string> <string name="account_or_email">Account/email</string>

View File

@ -788,7 +788,6 @@
<string name="change_server_complete">サーバーを変更しました。</string> <string name="change_server_complete">サーバーを変更しました。</string>
<string name="order_manager">注文管理</string> <string name="order_manager">注文管理</string>
<string name="log_out">掲載</string> <string name="log_out">掲載</string>
<string name="user_info">最近ログイン:%1$s uid:%2$s 住所:%3$s</string>
<string name="use_coupon">クーポンを使った注文を作成しますが、継続しますか\?(注文作成完了後、クーポンを消費)</string> <string name="use_coupon">クーポンを使った注文を作成しますが、継続しますか\?(注文作成完了後、クーポンを消費)</string>
<string name="use">使用</string> <string name="use">使用</string>
<string name="account_or_email">アカウント/ eメール</string> <string name="account_or_email">アカウント/ eメール</string>

View File

@ -787,7 +787,6 @@
<string name="change_server_complete">Сервер был изменен.</string> <string name="change_server_complete">Сервер был изменен.</string>
<string name="order_manager">Управление заказом</string> <string name="order_manager">Управление заказом</string>
<string name="log_out">напечата</string> <string name="log_out">напечата</string>
<string name="user_info">Зарегистрировано недавно :%1$s uid:%2$s местожительство:%3$s</string>
<string name="use_coupon">Мы используем купоны, чтобы создать порядок. (после создания заказа, купоны будут расходуться)</string> <string name="use_coupon">Мы используем купоны, чтобы создать порядок. (после создания заказа, купоны будут расходуться)</string>
<string name="use">использова</string> <string name="use">использова</string>
<string name="account_or_email">Номер счета/письмо</string> <string name="account_or_email">Номер счета/письмо</string>

View File

@ -826,7 +826,7 @@
<string name="change_server_complete">已更改服务器。</string> <string name="change_server_complete">已更改服务器。</string>
<string name="order_manager">订单管理</string> <string name="order_manager">订单管理</string>
<string name="log_out">登出</string> <string name="log_out">登出</string>
<string name="user_info">最近登录:%1$s uid:%2$s ip归属地:%3$s</string> <string name="user_info">最近登录:%1$s ip归属地:%2$s</string>
<string name="use_coupon">将使用优惠券创建订单,仍继续嘛?(创建订单完成后,将优惠券消耗)</string> <string name="use_coupon">将使用优惠券创建订单,仍继续嘛?(创建订单完成后,将优惠券消耗)</string>
<string name="use">使用</string> <string name="use">使用</string>
<string name="account_or_email">账号/电子邮件</string> <string name="account_or_email">账号/电子邮件</string>
@ -956,4 +956,5 @@
<string name="public_mod">公开</string> <string name="public_mod">公开</string>
<string name="private_mod">私有</string> <string name="private_mod">私有</string>
<string name="minVersion">最低游戏版本</string> <string name="minVersion">最低游戏版本</string>
<string name="thumbs_up">点赞</string>
</resources> </resources>