fixed user url not clickable
This commit is contained in:
parent
ffe44849b6
commit
e4cee5ed3b
|
@ -25,3 +25,5 @@ import org.mariotaku.twidere.util.InternalTwitterContentUtils
|
|||
fun ParcelableUser.getBestProfileBanner(width: Int): String? {
|
||||
return InternalTwitterContentUtils.getBestBannerUrl(profile_banner_url, width)
|
||||
}
|
||||
|
||||
val ParcelableUser.urlPreferred: String? get() = url_expanded?.takeIf(String::isNotEmpty) ?: url
|
|
@ -106,6 +106,7 @@ import org.mariotaku.twidere.extension.applyTheme
|
|||
import org.mariotaku.twidere.extension.loadOriginalProfileImage
|
||||
import org.mariotaku.twidere.extension.loadProfileBanner
|
||||
import org.mariotaku.twidere.extension.model.applyTo
|
||||
import org.mariotaku.twidere.extension.model.urlPreferred
|
||||
import org.mariotaku.twidere.fragment.AbsStatusesFragment.StatusesFragmentDelegate
|
||||
import org.mariotaku.twidere.fragment.UserTimelineFragment.UserTimelineFragmentDelegate
|
||||
import org.mariotaku.twidere.fragment.iface.IBaseFragment.SystemWindowsInsetsCallback
|
||||
|
@ -493,7 +494,7 @@ class UserFragment : BaseFragment(), OnClickListener, OnLinkClickListener,
|
|||
|
||||
locationContainer.location.text = user.location
|
||||
locationContainer.visibility = if (locationContainer.location.empty) View.GONE else View.VISIBLE
|
||||
urlContainer.url.text = (user.url_expanded?.takeIf(String::isNotEmpty) ?: user.url)?.let {
|
||||
urlContainer.url.text = user.urlPreferred?.let {
|
||||
val ssb = SpannableStringBuilder(it)
|
||||
ssb.setSpan(TwidereURLSpan(it, highlightStyle = linkHighlightOption), 0, ssb.length,
|
||||
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
|
||||
|
@ -563,6 +564,9 @@ class UserFragment : BaseFragment(), OnClickListener, OnLinkClickListener,
|
|||
} else if (profileBirthdayStub == null) {
|
||||
profileBirthdayBanner.visibility = View.GONE
|
||||
}
|
||||
|
||||
urlContainer.url.movementMethod = null
|
||||
|
||||
updateTitleAlpha()
|
||||
activity.invalidateOptionsMenu()
|
||||
updateSubtitle()
|
||||
|
@ -729,6 +733,7 @@ class UserFragment : BaseFragment(), OnClickListener, OnLinkClickListener,
|
|||
followersContainer.setOnClickListener(this)
|
||||
friendsContainer.setOnClickListener(this)
|
||||
errorIcon.setOnClickListener(this)
|
||||
urlContainer.setOnClickListener(this)
|
||||
profileBanner.setOnSizeChangedListener(this)
|
||||
profileBannerSpace.setOnTouchListener(this)
|
||||
|
||||
|
@ -1247,6 +1252,10 @@ class UserFragment : BaseFragment(), OnClickListener, OnLinkClickListener,
|
|||
if (user.account_key == user.key) return
|
||||
IntentUtils.openProfileEditor(getActivity(), user.account_key)
|
||||
}
|
||||
R.id.urlContainer -> {
|
||||
val url = user.urlPreferred ?: return
|
||||
OnLinkClickHandler.openLink(context, preferences, url)
|
||||
}
|
||||
R.id.profileBirthdayBanner -> {
|
||||
hideBirthdayView = true
|
||||
profileBirthdayBanner.startAnimation(AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_out))
|
||||
|
|
|
@ -140,29 +140,7 @@ open class OnLinkClickHandler(
|
|||
|
||||
protected open fun openLink(link: String) {
|
||||
if (manager != null && manager.isActive) return
|
||||
val uri = Uri.parse(link)
|
||||
if (!preferences[chromeCustomTabKey]) {
|
||||
val viewIntent = Intent(Intent.ACTION_VIEW, uri)
|
||||
viewIntent.addCategory(Intent.CATEGORY_BROWSABLE)
|
||||
try {
|
||||
return context.startActivity(viewIntent)
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
// Ignore
|
||||
}
|
||||
return
|
||||
}
|
||||
val builder = CustomTabsIntent.Builder()
|
||||
builder.addDefaultShareMenuItem()
|
||||
(ChameleonUtils.getActivity(context) as? Chameleon.Themeable)?.overrideTheme?.let { theme ->
|
||||
builder.setToolbarColor(theme.colorToolbar)
|
||||
}
|
||||
val intent = builder.build()
|
||||
try {
|
||||
intent.launchUrl(context, uri)
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
// Ignore
|
||||
}
|
||||
|
||||
openLink(context, preferences, link)
|
||||
}
|
||||
|
||||
protected fun openTwitterLink(link: String, accountKey: UserKey) {
|
||||
|
@ -213,4 +191,33 @@ open class OnLinkClickHandler(
|
|||
context.startActivity(intent)
|
||||
return true
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
fun openLink(context: Context, preferences: SharedPreferences, link: String) {
|
||||
val uri = Uri.parse(link)
|
||||
if (!preferences[chromeCustomTabKey]) {
|
||||
val viewIntent = Intent(Intent.ACTION_VIEW, uri)
|
||||
viewIntent.addCategory(Intent.CATEGORY_BROWSABLE)
|
||||
try {
|
||||
return context.startActivity(viewIntent)
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
// Ignore
|
||||
}
|
||||
return
|
||||
}
|
||||
val builder = CustomTabsIntent.Builder()
|
||||
builder.addDefaultShareMenuItem()
|
||||
(ChameleonUtils.getActivity(context) as? Chameleon.Themeable)?.overrideTheme?.let { theme ->
|
||||
builder.setToolbarColor(theme.colorToolbar)
|
||||
}
|
||||
val intent = builder.build()
|
||||
try {
|
||||
intent.launchUrl(context, uri)
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
// Ignore
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue