feat: activity ui tweaks
This commit is contained in:
parent
b187cf06be
commit
abcf9fcbef
10 changed files with 120 additions and 77 deletions
|
@ -15,17 +15,6 @@ data class FeedResponse(
|
|||
) : java.io.Serializable
|
||||
}
|
||||
@Serializable
|
||||
data class Social(
|
||||
@SerialName("data")
|
||||
val data: Data
|
||||
) : java.io.Serializable {
|
||||
@Serializable
|
||||
data class Data(
|
||||
@SerialName("Page1") val page1: ActivityPage,
|
||||
@SerialName("Page2") val page2: ActivityPage
|
||||
) : java.io.Serializable
|
||||
}
|
||||
@Serializable
|
||||
data class ActivityPage(
|
||||
@SerialName("activities")
|
||||
val activities: List<Activity>
|
||||
|
@ -94,9 +83,9 @@ data class ActivityReply(
|
|||
@SerialName("text")
|
||||
val text: String,
|
||||
@SerialName("likeCount")
|
||||
val likeCount: Int,
|
||||
var likeCount: Int,
|
||||
@SerialName("isLiked")
|
||||
val isLiked: Boolean,
|
||||
var isLiked: Boolean,
|
||||
@SerialName("createdAt")
|
||||
val createdAt: Int,
|
||||
@SerialName("user")
|
||||
|
|
|
@ -445,17 +445,14 @@ class Stories @JvmOverloads constructor(
|
|||
story.likes?.forEach { i ->
|
||||
userList.add(User(i.id, i.name.toString(), i.avatar?.medium, i.bannerImage))
|
||||
}
|
||||
|
||||
|
||||
val likeColor = ContextCompat.getColor(context, R.color.yt_red)
|
||||
val notLikeColor = ContextCompat.getColor(context, R.color.bg_opp)
|
||||
binding.activityLikeCount.text = story.likeCount.toString()
|
||||
binding.activityLike.setColorFilter(if (story.isLiked == true) likeColor else notLikeColor)
|
||||
binding.statusUserActions.setOnClickListener {
|
||||
binding.activityLikeContainer.setOnClickListener {
|
||||
like()
|
||||
}
|
||||
|
||||
binding.statusUserActions.setOnLongClickListener {
|
||||
binding.activityLikeContainer.setOnLongClickListener {
|
||||
val context = activity
|
||||
UsersDialogFragment().apply {
|
||||
userList(userList)
|
||||
|
|
|
@ -88,9 +88,10 @@ class FollowActivity : AppCompatActivity() {
|
|||
|
||||
private fun fillList() {
|
||||
adapter.clear()
|
||||
val screenWidth = resources.displayMetrics.run { widthPixels / density }
|
||||
binding.listRecyclerView.layoutManager = when (getLayoutType(selected)) {
|
||||
0 -> LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false)
|
||||
1 -> GridLayoutManager(this, 3, GridLayoutManager.VERTICAL, false)
|
||||
1 -> GridLayoutManager(this, (screenWidth / 120f).toInt(), GridLayoutManager.VERTICAL, false)
|
||||
else -> LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false)
|
||||
}
|
||||
users?.forEach { user ->
|
||||
|
|
|
@ -57,7 +57,7 @@ class ActivityItem(
|
|||
when (binding.activityReplies.visibility) {
|
||||
View.GONE -> {
|
||||
val replyItems = activity.replies?.map {
|
||||
ActivityReplyItem(it) { id, type ->
|
||||
ActivityReplyItem(it,fragActivity) { id, type ->
|
||||
clickCallback(
|
||||
id,
|
||||
type
|
||||
|
@ -77,8 +77,19 @@ class ActivityItem(
|
|||
}
|
||||
}
|
||||
}
|
||||
val userList = arrayListOf<User>()
|
||||
activity.likes?.forEach { i ->
|
||||
userList.add(User(i.id, i.name.toString(), i.avatar?.medium, i.bannerImage))
|
||||
}
|
||||
binding.activityLikeContainer.setOnLongClickListener {
|
||||
UsersDialogFragment().apply {
|
||||
userList(userList)
|
||||
show(fragActivity.supportFragmentManager, "dialog")
|
||||
}
|
||||
true
|
||||
}
|
||||
binding.activityLikeCount.text = (activity.likeCount ?: 0).toString()
|
||||
binding.activityLike.setOnClickListener {
|
||||
binding.activityLikeContainer.setOnClickListener {
|
||||
val scope = CoroutineScope(Dispatchers.IO + SupervisorJob())
|
||||
scope.launch {
|
||||
val res = Anilist.query.toggleLike(activity.id, "ACTIVITY")
|
||||
|
@ -101,19 +112,6 @@ class ActivityItem(
|
|||
}
|
||||
}
|
||||
val context = binding.root.context
|
||||
val userList = arrayListOf<User>()
|
||||
activity.likes?.forEach { i ->
|
||||
userList.add(User(i.id, i.name.toString(), i.avatar?.medium, i.bannerImage))
|
||||
}
|
||||
binding.activityLike.setOnLongClickListener {
|
||||
UsersDialogFragment().apply {
|
||||
userList(userList)
|
||||
show(fragActivity.supportFragmentManager, "dialog")
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
|
||||
when (activity.typename) {
|
||||
"ListActivity" -> {
|
||||
val cover = activity.media?.coverImage?.large
|
||||
|
|
|
@ -2,17 +2,28 @@ package ani.dantotsu.profile.activity
|
|||
|
||||
import android.view.View
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import ani.dantotsu.R
|
||||
import ani.dantotsu.buildMarkwon
|
||||
import ani.dantotsu.connections.anilist.Anilist
|
||||
import ani.dantotsu.connections.anilist.api.ActivityReply
|
||||
import ani.dantotsu.databinding.ItemActivityReplyBinding
|
||||
import ani.dantotsu.loadImage
|
||||
import ani.dantotsu.profile.User
|
||||
import ani.dantotsu.profile.UsersDialogFragment
|
||||
import ani.dantotsu.snackString
|
||||
import ani.dantotsu.util.AniMarkdown.Companion.getBasicAniHTML
|
||||
import com.xwray.groupie.viewbinding.BindableItem
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.SupervisorJob
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
class ActivityReplyItem(
|
||||
private val reply: ActivityReply,
|
||||
private val clickCallback: (Int, type: String) -> Unit
|
||||
private val fragActivity: FragmentActivity,
|
||||
private val clickCallback: (Int, type: String) -> Unit,
|
||||
) : BindableItem<ItemActivityReplyBinding>() {
|
||||
private lateinit var binding: ItemActivityReplyBinding
|
||||
|
||||
|
@ -28,6 +39,39 @@ class ActivityReplyItem(
|
|||
binding.activityLike.setColorFilter(if (reply.isLiked) likeColor else notLikeColor)
|
||||
val markwon = buildMarkwon(binding.root.context)
|
||||
markwon.setMarkdown(binding.activityContent, getBasicAniHTML(reply.text))
|
||||
val userList = arrayListOf<User>()
|
||||
reply.likes?.forEach { i ->
|
||||
userList.add(User(i.id, i.name.toString(), i.avatar?.medium, i.bannerImage))
|
||||
}
|
||||
binding.activityLikeContainer.setOnLongClickListener {
|
||||
UsersDialogFragment().apply {
|
||||
userList(userList)
|
||||
show(fragActivity.supportFragmentManager, "dialog")
|
||||
}
|
||||
true
|
||||
}
|
||||
binding.activityLikeContainer.setOnClickListener {
|
||||
val scope = CoroutineScope(Dispatchers.IO + SupervisorJob())
|
||||
scope.launch {
|
||||
val res = Anilist.query.toggleLike(reply.id, "ACTIVITY_REPLY")
|
||||
withContext(Dispatchers.Main) {
|
||||
if (res != null) {
|
||||
if (reply.isLiked) {
|
||||
reply.likeCount = reply.likeCount.minus(1)
|
||||
} else {
|
||||
reply.likeCount = reply.likeCount.plus(1)
|
||||
}
|
||||
binding.activityLikeCount.text = (reply.likeCount).toString()
|
||||
reply.isLiked = !reply.isLiked
|
||||
binding.activityLike.setColorFilter(if (reply.isLiked) likeColor else notLikeColor)
|
||||
|
||||
} else {
|
||||
snackString("Failed to like activity")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
binding.activityAvatarContainer.setOnClickListener {
|
||||
clickCallback(reply.userId, "USER")
|
||||
}
|
||||
|
|
|
@ -206,7 +206,7 @@
|
|||
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/statusUserActions"
|
||||
android:id="@+id/activityLikeContainer"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center|end"
|
||||
|
|
|
@ -4,20 +4,20 @@
|
|||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="24dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:background="?attr/colorSurface"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:id="@+id/activityAvatarContainer"
|
||||
android:layout_width="64dp"
|
||||
android:layout_height="64dp"
|
||||
android:layout_gravity="start|center_vertical"
|
||||
android:layout_width="42dp"
|
||||
android:layout_height="42dp"
|
||||
android:layout_marginStart="12dp"
|
||||
android:backgroundTint="@color/transparent"
|
||||
app:cardCornerRadius="64dp"
|
||||
|
@ -25,8 +25,8 @@
|
|||
|
||||
<com.google.android.material.imageview.ShapeableImageView
|
||||
android:id="@+id/activityUserAvatar"
|
||||
android:layout_width="64dp"
|
||||
android:layout_height="64dp"
|
||||
android:layout_width="42dp"
|
||||
android:layout_height="42dp"
|
||||
android:layout_gravity="center"
|
||||
app:srcCompat="@drawable/ic_round_add_circle_24"
|
||||
tools:ignore="ContentDescription,ImageContrastCheck"
|
||||
|
@ -37,35 +37,45 @@
|
|||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
android:orientation="horizontal">
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/activityUserName"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:fontFamily="@font/poppins_semi_bold"
|
||||
android:text="Username"
|
||||
android:textSize="15sp"
|
||||
tools:ignore="HardcodedText,RtlSymmetry" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:alpha="0.6"
|
||||
android:fontFamily="@font/poppins_semi_bold"
|
||||
android:text="•"
|
||||
android:textSize="16sp"
|
||||
tools:ignore="HardcodedText,RtlSymmetry" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/activityTime"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/poppins_semi_bold"
|
||||
android:text="Wed,06 March 2024, 7:00PM"
|
||||
android:text="@string/time"
|
||||
android:textSize="14sp"
|
||||
tools:ignore="HardcodedText" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/activityLikeContainer"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end|center"
|
||||
android:layout_marginEnd="12dp"
|
||||
android:orientation="vertical"
|
||||
tools:ignore="UseCompoundDrawables">
|
||||
|
@ -93,21 +103,18 @@
|
|||
android:id="@+id/activityContent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="18dp"
|
||||
android:layout_marginTop="3dp"
|
||||
android:layout_marginEnd="18dp"
|
||||
android:layout_marginStart="64dp"
|
||||
android:background="?android:colorBackground"
|
||||
android:fontFamily="@font/poppins_semi_bold"
|
||||
android:text="@string/lorem_ipsum"
|
||||
android:textAlignment="center"
|
||||
android:textSize="12sp"
|
||||
tools:visibility="gone" />
|
||||
android:textSize="12sp" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/activityBannerContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp">
|
||||
android:layout_marginTop="8dp"
|
||||
android:visibility="gone">
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="match_parent"
|
||||
|
@ -200,9 +207,8 @@
|
|||
android:id="@+id/commentRepliesContainer"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="start|center_vertical"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:layout_marginTop="6dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<View
|
||||
|
|
|
@ -12,22 +12,22 @@
|
|||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:id="@+id/activityAvatarContainer"
|
||||
android:layout_width="64dp"
|
||||
android:layout_height="64dp"
|
||||
android:layout_gravity="start|center_vertical"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_width="42dp"
|
||||
android:layout_height="42dp"
|
||||
android:layout_marginStart="12dp"
|
||||
android:backgroundTint="@color/transparent"
|
||||
app:cardCornerRadius="64dp"
|
||||
app:strokeColor="@color/transparent">
|
||||
|
||||
<com.google.android.material.imageview.ShapeableImageView
|
||||
android:id="@+id/activityUserAvatar"
|
||||
android:layout_width="64dp"
|
||||
android:layout_height="64dp"
|
||||
android:layout_width="42dp"
|
||||
android:layout_height="42dp"
|
||||
android:layout_gravity="center"
|
||||
app:srcCompat="@drawable/ic_round_add_circle_24"
|
||||
tools:ignore="ContentDescription,ImageContrastCheck"
|
||||
|
@ -38,37 +38,48 @@
|
|||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
android:orientation="horizontal">
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/activityUserName"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:fontFamily="@font/poppins_semi_bold"
|
||||
android:text="Username"
|
||||
android:textSize="15sp"
|
||||
tools:ignore="HardcodedText,RtlSymmetry" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:alpha="0.6"
|
||||
android:fontFamily="@font/poppins_semi_bold"
|
||||
android:text="•"
|
||||
android:textSize="16sp"
|
||||
tools:ignore="HardcodedText,RtlSymmetry" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/activityTime"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/poppins_semi_bold"
|
||||
android:text="Wed,06 March 2024, 7:00PM"
|
||||
android:text="@string/time"
|
||||
android:textSize="14sp"
|
||||
tools:ignore="HardcodedText" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:id="@+id/activityLikeContainer"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end|center"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:orientation="vertical">
|
||||
android:layout_marginEnd="12dp"
|
||||
android:orientation="vertical"
|
||||
tools:ignore="UseCompoundDrawables">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/activityLike"
|
||||
|
@ -93,12 +104,9 @@
|
|||
android:id="@+id/activityContent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginStart="64dp"
|
||||
android:background="?android:colorBackground"
|
||||
android:fontFamily="@font/poppins_semi_bold"
|
||||
android:text="@string/lorem_ipsum"
|
||||
android:textAlignment="center"
|
||||
android:textSize="14sp" />
|
||||
|
||||
android:textSize="12sp" />
|
||||
</LinearLayout>
|
|
@ -86,7 +86,7 @@
|
|||
<TextView
|
||||
android:id="@+id/commentUserName"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:ellipsize="end"
|
||||
android:fontFamily="@font/poppins_bold"
|
||||
|
|
|
@ -139,7 +139,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:ellipsize="marquee"
|
||||
android:fontFamily="@font/poppins_bold"
|
||||
android:layout_marginStart="2dp"
|
||||
android:layout_marginStart="4dp"
|
||||
android:maxLines="5"
|
||||
android:text="@string/empty"
|
||||
app:lineHeight="15sp" />
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue