mirror of
https://github.com/TwidereProject/Twidere-Android
synced 2025-02-01 09:16:47 +01:00
supports mastodon user lin
This commit is contained in:
parent
121950dc92
commit
dcfc73b8bd
@ -20,6 +20,7 @@
|
||||
package org.mariotaku.twidere.extension.model.api.mastodon
|
||||
|
||||
import org.mariotaku.microblog.library.mastodon.model.Account
|
||||
import org.mariotaku.twidere.annotation.AccountType
|
||||
import org.mariotaku.twidere.model.ParcelableUser
|
||||
import org.mariotaku.twidere.model.UserKey
|
||||
|
||||
@ -47,6 +48,7 @@ fun Account.toParcelable(accountKey: UserKey, position: Long = 0): ParcelableUse
|
||||
obj.favorites_count = -1
|
||||
obj.listed_count = -1
|
||||
obj.media_count = -1
|
||||
obj.user_type = AccountType.MASTODON
|
||||
return obj
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@ package org.mariotaku.twidere.model.util
|
||||
import android.text.TextUtils
|
||||
import org.mariotaku.ktextension.isNotNullOrEmpty
|
||||
import org.mariotaku.microblog.library.twitter.model.User
|
||||
import org.mariotaku.twidere.annotation.AccountType
|
||||
import org.mariotaku.twidere.extension.model.api.getProfileImageOfSize
|
||||
import org.mariotaku.twidere.model.AccountDetails
|
||||
import org.mariotaku.twidere.model.ParcelableUser
|
||||
@ -29,8 +30,8 @@ object ParcelableUserUtils {
|
||||
}
|
||||
|
||||
|
||||
private fun fromUserInternal(user: User, accountKey: UserKey?, accountType: String?, position: Long = 0,
|
||||
profileImageSize: String = "normal"): ParcelableUser {
|
||||
private fun fromUserInternal(user: User, accountKey: UserKey?, @AccountType accountType: String?,
|
||||
position: Long = 0, profileImageSize: String = "normal"): ParcelableUser {
|
||||
val urlEntities = user.urlEntities
|
||||
val obj = ParcelableUser()
|
||||
obj.position = position
|
||||
|
@ -21,6 +21,7 @@ package org.mariotaku.twidere.util
|
||||
|
||||
import android.net.Uri
|
||||
import org.mariotaku.twidere.TwidereConstants.*
|
||||
import org.mariotaku.twidere.annotation.AccountType
|
||||
import org.mariotaku.twidere.model.ParcelableStatus
|
||||
import org.mariotaku.twidere.model.ParcelableUser
|
||||
import org.mariotaku.twidere.model.UserKey
|
||||
@ -133,8 +134,12 @@ object LinkCreator {
|
||||
if (user.extras != null && user.extras.statusnet_profile_url != null) {
|
||||
return Uri.parse(user.extras.statusnet_profile_url)
|
||||
}
|
||||
if (USER_TYPE_FANFOU_COM == user.key.host) {
|
||||
return getFanfouUserLink(user.key.id)
|
||||
when (user.user_type) {
|
||||
AccountType.FANFOU -> return getFanfouUserLink(user.key.id)
|
||||
AccountType.MASTODON -> {
|
||||
val host = user.key.host ?: user.account_key.host
|
||||
return getMastodonUserLink(host!!, user.screen_name)
|
||||
}
|
||||
}
|
||||
return getTwitterUserLink(user.screen_name)
|
||||
}
|
||||
@ -173,4 +178,12 @@ object LinkCreator {
|
||||
builder.appendPath(id)
|
||||
return builder.build()
|
||||
}
|
||||
|
||||
internal fun getMastodonUserLink(host: String, username: String): Uri {
|
||||
val builder = Uri.Builder()
|
||||
builder.scheme(SCHEME_HTTPS)
|
||||
builder.authority(host)
|
||||
builder.appendEncodedPath(Uri.encode("@$username", "@"))
|
||||
return builder.build()
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user