feat(social): mark alr watched
This commit is contained in:
parent
da456d3067
commit
f4c95b6cc0
5 changed files with 135 additions and 16 deletions
|
@ -1,5 +1,6 @@
|
|||
package ani.dantotsu.home
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.view.ViewGroup
|
||||
import android.view.animation.Animation
|
||||
|
@ -14,6 +15,7 @@ import ani.dantotsu.themes.ThemeManager
|
|||
import ani.dantotsu.home.status.listener.StoriesCallback
|
||||
import ani.dantotsu.navBarHeight
|
||||
import ani.dantotsu.profile.User
|
||||
import ani.dantotsu.settings.saving.PrefManager
|
||||
import ani.dantotsu.statusBarHeight
|
||||
|
||||
class StatusActivity : AppCompatActivity(), StoriesCallback {
|
||||
|
@ -42,6 +44,7 @@ class StatusActivity : AppCompatActivity(), StoriesCallback {
|
|||
slideInRight = AnimationUtils.loadAnimation(this, R.anim.slide_in_right)
|
||||
|
||||
binding.stories.setStoriesList(activity[position].activity, this)
|
||||
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
|
|
|
@ -7,8 +7,10 @@ import androidx.core.content.ContextCompat
|
|||
import androidx.recyclerview.widget.RecyclerView
|
||||
import ani.dantotsu.databinding.ItemUserStatusBinding
|
||||
import ani.dantotsu.loadImage
|
||||
import ani.dantotsu.profile.ProfileActivity
|
||||
import ani.dantotsu.profile.User
|
||||
import ani.dantotsu.setAnimation
|
||||
import ani.dantotsu.settings.saving.PrefManager
|
||||
import java.io.Serializable
|
||||
|
||||
class UserStatus(private val user: ArrayList<User>) :
|
||||
|
@ -28,6 +30,17 @@ class UserStatus(private val user: ArrayList<User>) :
|
|||
null
|
||||
)
|
||||
}
|
||||
itemView.setOnLongClickListener {
|
||||
ContextCompat.startActivity(
|
||||
itemView.context,
|
||||
Intent(
|
||||
itemView.context,
|
||||
ProfileActivity::class.java
|
||||
).putExtra("userId", user[bindingAdapterPosition].id),
|
||||
null
|
||||
)
|
||||
true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,6 +61,10 @@ class UserStatus(private val user: ArrayList<User>) :
|
|||
b.profileUserAvatar.loadImage(user.pfp)
|
||||
b.profileUserName.text = user.name
|
||||
|
||||
val watchedActivityIds = PrefManager.getCustomVal<Set<Int>>("${user.id}_activities", setOf())
|
||||
val activityIdToStatusList = user.activity.map { watchedActivityIds.contains(it.id) }
|
||||
b.profileUserStatusIndicator.setParts(user.activity.size, activityIdToStatusList)
|
||||
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int = user.size
|
||||
|
|
82
app/src/main/java/ani/dantotsu/home/status/CircleView.kt
Normal file
82
app/src/main/java/ani/dantotsu/home/status/CircleView.kt
Normal file
|
@ -0,0 +1,82 @@
|
|||
package ani.dantotsu.home.status
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.graphics.Canvas
|
||||
import android.graphics.Color
|
||||
import android.graphics.Paint
|
||||
import android.graphics.Path
|
||||
import android.util.AttributeSet
|
||||
import android.util.TypedValue
|
||||
import android.view.View
|
||||
|
||||
class CircleView(context: Context, attrs: AttributeSet?) : View(context, attrs) {
|
||||
private var parts: Int = 3
|
||||
private var gapAngle: Float = 9f
|
||||
private val path = Path()
|
||||
private var booleanList = listOf<Boolean>()
|
||||
private val paint: Paint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
|
||||
style = Paint.Style.STROKE
|
||||
strokeWidth = 4f
|
||||
}
|
||||
|
||||
@SuppressLint("DrawAllocation")
|
||||
override fun onDraw(canvas: Canvas) {
|
||||
super.onDraw(canvas)
|
||||
val centerX = width / 2f
|
||||
val centerY = height / 2f
|
||||
val radius = centerX.coerceAtMost(centerY) - paint.strokeWidth / 2
|
||||
|
||||
val totalGapAngle = gapAngle * (parts)
|
||||
val totalAngle = 360f - totalGapAngle
|
||||
val typedValue = TypedValue()
|
||||
context.theme.resolveAttribute(com.google.android.material.R.attr.colorPrimary, typedValue, true)
|
||||
val primaryColor = typedValue.data
|
||||
fun setColor(int: Int) {
|
||||
if (int < booleanList.size && booleanList[int]) {
|
||||
|
||||
paint.color = Color.GRAY
|
||||
} else {
|
||||
|
||||
paint.color = primaryColor
|
||||
}
|
||||
canvas.drawPath(path, paint)
|
||||
}
|
||||
|
||||
if (parts == 1) {
|
||||
// Draw a single arc covering the entire circle
|
||||
path.addArc(
|
||||
centerX - radius,
|
||||
centerY - radius,
|
||||
centerX + radius,
|
||||
centerY + radius,
|
||||
0f,
|
||||
360f
|
||||
)
|
||||
setColor(0)
|
||||
} else {
|
||||
val effectiveAngle = totalAngle / parts
|
||||
|
||||
for (i in 0 until parts) {
|
||||
val startAngle = i * (effectiveAngle + gapAngle)
|
||||
path.reset()
|
||||
path.addArc(
|
||||
centerX - radius,
|
||||
centerY - radius,
|
||||
centerX + radius,
|
||||
centerY + radius,
|
||||
startAngle,
|
||||
effectiveAngle
|
||||
)
|
||||
setColor(i)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun setParts(parts: Int, list : List<Boolean> = mutableListOf()) {
|
||||
this.parts = parts
|
||||
this.booleanList = list
|
||||
invalidate()
|
||||
}
|
||||
}
|
|
@ -30,6 +30,7 @@ import ani.dantotsu.profile.ProfileActivity
|
|||
import ani.dantotsu.profile.User
|
||||
import ani.dantotsu.profile.UsersDialogFragment
|
||||
import ani.dantotsu.profile.activity.ActivityItemBuilder
|
||||
import ani.dantotsu.settings.saving.PrefManager
|
||||
import ani.dantotsu.snackString
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
|
@ -432,5 +433,8 @@ constructor(
|
|||
}
|
||||
true
|
||||
}
|
||||
val key = "${story.user?.id}_activities"
|
||||
val set = PrefManager.getCustomVal<Set<Int>>(key, setOf()).plus((story.id))
|
||||
PrefManager.setCustomVal(key, set)
|
||||
}
|
||||
}
|
|
@ -7,31 +7,44 @@
|
|||
android:orientation="vertical"
|
||||
android:padding="8dp">
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:id="@+id/profileUserAvatarContainer"
|
||||
<FrameLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:backgroundTint="@color/transparent"
|
||||
app:strokeColor="@color/transparent"
|
||||
app:cardCornerRadius="124dp">
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/profileUserAvatar"
|
||||
android:layout_width="64dp"
|
||||
android:layout_height="64dp"
|
||||
tools:ignore="ContentDescription,ImageContrastCheck"
|
||||
tools:tint="@color/transparent" />
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:id="@+id/profileUserAvatarContainer"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:backgroundTint="@color/transparent"
|
||||
app:cardCornerRadius="124dp"
|
||||
app:strokeColor="@color/transparent">
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
<ImageView
|
||||
android:id="@+id/profileUserAvatar"
|
||||
android:layout_width="64dp"
|
||||
android:layout_height="64dp"
|
||||
tools:ignore="ContentDescription,ImageContrastCheck"
|
||||
tools:tint="@color/transparent" />
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
<ani.dantotsu.home.status.CircleView
|
||||
android:id="@+id/profileUserStatusIndicator"
|
||||
android:layout_width="78dp"
|
||||
android:layout_height="78dp">
|
||||
|
||||
</ani.dantotsu.home.status.CircleView>
|
||||
</FrameLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/profileUserName"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="64dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/poppins_semi_bold"
|
||||
android:layout_gravity="center_horizontal|center_vertical"
|
||||
android:ellipsize="end"
|
||||
android:fontFamily="@font/poppins_semi_bold"
|
||||
android:gravity="center"
|
||||
android:singleLine="true"
|
||||
android:text="@string/username"
|
||||
android:textColor="?attr/colorOnBackground"
|
||||
android:textSize="12sp" />
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue