forked from tuskyapp/Tusky
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add notifications for follow requests
Issue tuskyapp#1719
- Loading branch information
Showing
15 changed files
with
995 additions
and
163 deletions.
There are no files selected for viewing
735 changes: 735 additions & 0 deletions
735
app/schemas/com.keylesspalace.tusky.db.AppDatabase/22.json
Large diffs are not rendered by default.
Oops, something went wrong.
51 changes: 51 additions & 0 deletions
51
app/src/main/java/com/keylesspalace/tusky/adapter/FollowRequestViewHolder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.keylesspalace.tusky.adapter | ||
|
||
import android.view.View | ||
import androidx.core.text.BidiFormatter | ||
import androidx.preference.PreferenceManager | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.keylesspalace.tusky.R | ||
import com.keylesspalace.tusky.entity.Account | ||
import com.keylesspalace.tusky.interfaces.AccountActionListener | ||
import com.keylesspalace.tusky.util.CustomEmojiHelper | ||
import com.keylesspalace.tusky.util.loadAvatar | ||
import com.keylesspalace.tusky.util.visible | ||
import kotlinx.android.synthetic.main.item_follow_request.view.* | ||
|
||
internal class FollowRequestViewHolder(itemView: View, private val showHeader: Boolean) : RecyclerView.ViewHolder(itemView) { | ||
private var id: String? = null | ||
private val animateAvatar: Boolean = PreferenceManager.getDefaultSharedPreferences(itemView.context) | ||
.getBoolean("animateGifAvatars", false) | ||
|
||
fun setupWithAccount(account: Account, formatter: BidiFormatter?) { | ||
id = account.id | ||
val wrappedName = formatter?.unicodeWrap(account.name) ?: account.name | ||
val emojifiedName: CharSequence = CustomEmojiHelper.emojifyString(wrappedName, account.emojis, itemView) | ||
itemView.displayNameTextView.text = emojifiedName | ||
if (showHeader) { | ||
itemView.notificationTextView.text = itemView.context.getString(R.string.notification_follow_request_format, emojifiedName) | ||
} | ||
itemView.notificationTextView.visible(showHeader) | ||
val format = itemView.context.getString(R.string.status_username_format) | ||
val formattedUsername = String.format(format, account.username) | ||
itemView.usernameTextView.text = formattedUsername | ||
val avatarRadius = itemView.avatar.context.resources.getDimensionPixelSize(R.dimen.avatar_radius_48dp) | ||
loadAvatar(account.avatar, itemView.avatar, avatarRadius, animateAvatar) | ||
} | ||
|
||
fun setupActionListener(listener: AccountActionListener) { | ||
itemView.acceptButton.setOnClickListener { | ||
val position = adapterPosition | ||
if (position != RecyclerView.NO_POSITION) { | ||
listener.onRespondToFollowRequest(true, id, position) | ||
} | ||
} | ||
itemView.rejectButton.setOnClickListener { | ||
val position = adapterPosition | ||
if (position != RecyclerView.NO_POSITION) { | ||
listener.onRespondToFollowRequest(false, id, position) | ||
} | ||
} | ||
itemView.avatar.setOnClickListener { listener.onViewAccount(id) } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.