improved user relationship display

This commit is contained in:
Mariotaku Lee 2017-04-22 15:27:05 +08:00
parent 2afa4375e9
commit 773e3162a4
No known key found for this signature in database
GPG Key ID: 15C10F89D7C33535
3 changed files with 28 additions and 18 deletions

View File

@ -218,7 +218,7 @@ abstract class ParcelableUsersFragment : AbsContentListRecyclerViewFragment<Parc
if (user.is_following) {
DestroyFriendshipDialogFragment.show(fragmentManager, user)
} else {
twitterWrapper.createFriendshipAsync(user.account_key, user.key)
twitterWrapper.createFriendshipAsync(user.account_key, user.key, user.screen_name)
}
}

View File

@ -796,20 +796,29 @@ class UserFragment : BaseFragment(), OnClickListener, OnLinkClickListener,
menu.setItemAvailability(R.id.blocked_users, isMyself)
menu.setItemAvailability(R.id.block, !isMyself)
val isTwitter: Boolean
if (account != null) {
isTwitter = AccountType.TWITTER == account.type
} else {
isTwitter = false
var canAddToList = false
var canMute = false
var canReportSpam = false
var canEnableRetweet = false
var canEnableNotifications = false
when (account?.type) {
AccountType.TWITTER -> {
canAddToList = true
canMute = true
canReportSpam = true
canEnableRetweet = true
canEnableNotifications = true
}
AccountType.MASTODON -> {
canMute = true
}
}
menu.setItemAvailability(R.id.add_to_list, isTwitter)
menu.setItemAvailability(R.id.mute_user, !isMyself && isTwitter)
menu.setItemAvailability(R.id.muted_users, isMyself && isTwitter)
menu.setItemAvailability(R.id.report_spam, !isMyself && isTwitter)
menu.setItemAvailability(R.id.enable_retweets, !isMyself && isTwitter)
menu.setItemAvailability(R.id.add_to_list, canAddToList)
menu.setItemAvailability(R.id.mute_user, !isMyself && canMute)
menu.setItemAvailability(R.id.muted_users, isMyself && canMute)
menu.setItemAvailability(R.id.report_spam, !isMyself && canReportSpam)
menu.setItemAvailability(R.id.enable_retweets, !isMyself && canEnableRetweet)
if (relationship != null) {
menu.findItem(R.id.add_to_filter)?.apply {
@ -822,7 +831,8 @@ class UserFragment : BaseFragment(), OnClickListener, OnLinkClickListener,
} else {
menu.setItemAvailability(R.id.send_direct_message, relationship.can_dm)
menu.setItemAvailability(R.id.block, true)
menu.setItemAvailability(R.id.enable_notifications, isTwitter && relationship.following)
menu.setItemAvailability(R.id.enable_notifications, canEnableNotifications &&
relationship.following)
menu.findItem(R.id.block)?.apply {
ActionIconDrawable.setMenuHighlight(this, TwidereMenuInfo(relationship.blocking))
@ -948,7 +958,7 @@ class UserFragment : BaseFragment(), OnClickListener, OnLinkClickListener,
if (userRelationship.following) {
DestroyFriendshipDialogFragment.show(fragmentManager, user)
} else {
twitter.createFriendshipAsync(user.account_key, user.key)
twitter.createFriendshipAsync(user.account_key, user.key, user.screen_name)
}
}
return true
@ -1174,7 +1184,7 @@ class UserFragment : BaseFragment(), OnClickListener, OnLinkClickListener,
} else if (userRelationship.following) {
DestroyFriendshipDialogFragment.show(fragmentManager, user)
} else {
twitter.createFriendshipAsync(user.account_key, user.key)
twitter.createFriendshipAsync(user.account_key, user.key, user.screen_name)
}
}
}

View File

@ -143,9 +143,9 @@ class AsyncTwitterWrapper(
TaskStarter.execute(task)
}
fun createFriendshipAsync(accountKey: UserKey, userKey: UserKey) {
fun createFriendshipAsync(accountKey: UserKey, userKey: UserKey, screenName: String) {
val task = CreateFriendshipTask(context)
task.setup(accountKey, userKey)
task.setup(accountKey, userKey, screenName)
TaskStarter.execute(task)
}