fixed #776
This commit is contained in:
parent
9c48ce3fe6
commit
ebc3385c48
|
@ -237,6 +237,7 @@ public class ParcelableStatus implements Parcelable, Comparable<ParcelableStatus
|
|||
@ParcelableThisPlease
|
||||
@JsonField(name = "source")
|
||||
@CursorField(Statuses.SOURCE)
|
||||
@Nullable
|
||||
public String source;
|
||||
@ParcelableThisPlease
|
||||
@JsonField(name = "user_profile_image_url")
|
||||
|
|
|
@ -78,9 +78,7 @@ import org.mariotaku.twidere.constant.IntentConstants.EXTRA_SCREEN_NAME
|
|||
import org.mariotaku.twidere.extension.applyTheme
|
||||
import org.mariotaku.twidere.extension.getCachedLocation
|
||||
import org.mariotaku.twidere.extension.loadProfileImage
|
||||
import org.mariotaku.twidere.extension.model.applyUpdateStatus
|
||||
import org.mariotaku.twidere.extension.model.textLimit
|
||||
import org.mariotaku.twidere.extension.model.unique_id_non_null
|
||||
import org.mariotaku.twidere.extension.model.*
|
||||
import org.mariotaku.twidere.extension.text.twitter.ReplyTextAndMentions
|
||||
import org.mariotaku.twidere.extension.text.twitter.extractReplyTextAndMentions
|
||||
import org.mariotaku.twidere.extension.withAppendedPath
|
||||
|
@ -964,20 +962,21 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
|||
val details = AccountUtils.getAccountDetails(am, status.account_key, false) ?: return false
|
||||
val accountUser = details.user
|
||||
val mentions = ArrayList<String>()
|
||||
val userAcct = status.user_acct
|
||||
if (accountUser.key != status.user_key) {
|
||||
editText.append("@${status.user_screen_name} ")
|
||||
editText.append("@$userAcct ")
|
||||
}
|
||||
var selectionStart = editText.length()
|
||||
if (status.is_retweet && !TextUtils.isEmpty(status.retweeted_by_user_screen_name)) {
|
||||
mentions.add(status.retweeted_by_user_screen_name)
|
||||
status.retweeted_by_user_acct?.addTo(mentions)
|
||||
}
|
||||
if (status.is_quote && !TextUtils.isEmpty(status.quoted_user_screen_name)) {
|
||||
mentions.add(status.quoted_user_screen_name)
|
||||
status.quoted_user_acct?.addTo(mentions)
|
||||
}
|
||||
if (status.mentions.isNotNullOrEmpty()) {
|
||||
status.mentions.filterNot {
|
||||
it.key == status.account_key || it.screen_name.isNullOrEmpty()
|
||||
}.mapTo(mentions) { it.screen_name }
|
||||
}.mapTo(mentions) { it.getAcct(details.key) }
|
||||
mentions.addAll(extractor.extractMentionedScreennames(status.quoted_text_plain))
|
||||
} else if (USER_TYPE_FANFOU_COM == status.account_key.host) {
|
||||
addFanfouHtmlToMentions(status.text_unescaped, status.spans, mentions)
|
||||
|
@ -992,13 +991,13 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
|||
}
|
||||
|
||||
mentions.distinctBy { it.toLowerCase(Locale.US) }.filterNot {
|
||||
return@filterNot it.equals(status.user_screen_name, ignoreCase = true)
|
||||
return@filterNot it.equals(userAcct, ignoreCase = true)
|
||||
}.forEach { editText.append("@$it ") }
|
||||
|
||||
// For non-Twitter instances, put current user mention at last
|
||||
if (details.type != AccountType.TWITTER && accountUser.key == status.user_key) {
|
||||
selectionStart = editText.length()
|
||||
editText.append("@${status.user_screen_name} ")
|
||||
editText.append("@$userAcct ")
|
||||
}
|
||||
|
||||
val text = intent.getStringExtra(EXTRA_TEXT)
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2017 Mariotaku Lee <mariotaku.lee@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.mariotaku.twidere.extension.model
|
||||
|
||||
import org.mariotaku.twidere.model.ParcelableUserMention
|
||||
import org.mariotaku.twidere.model.UserKey
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 2017/4/23.
|
||||
*/
|
||||
fun ParcelableUserMention.getAcct(accountKey: UserKey): String {
|
||||
if (accountKey.host == key.host) {
|
||||
return screen_name
|
||||
} else {
|
||||
return "$screen_name@${key.host}"
|
||||
}
|
||||
}
|
|
@ -157,7 +157,7 @@ class AddStatusFilterDialogFragment : BaseDialogFragment() {
|
|||
for (hashtag in hashtags) {
|
||||
list.add(FilterItemInfo(FilterItemInfo.FILTER_TYPE_KEYWORD, hashtag))
|
||||
}
|
||||
val source = HtmlEscapeHelper.toPlainText(status.source)
|
||||
val source = status.source?.let(HtmlEscapeHelper::toPlainText)
|
||||
if (source != null) {
|
||||
list.add(FilterItemInfo(FilterItemInfo.FILTER_TYPE_SOURCE, source))
|
||||
}
|
||||
|
|
|
@ -433,7 +433,7 @@ class StatusFragment : BaseFragment(), LoaderCallbacks<SingleResponse<Parcelable
|
|||
|
||||
Analyzer.log(StatusView(details?.type, status.media_type).apply {
|
||||
this.type = StatusView.getStatusType(status)
|
||||
this.source = HtmlEscapeHelper.toPlainText(status.source)
|
||||
this.source = status.source?.let(HtmlEscapeHelper::toPlainText)
|
||||
})
|
||||
} else if (readPosition != null) {
|
||||
restoreReadPosition(readPosition)
|
||||
|
@ -776,7 +776,7 @@ class StatusFragment : BaseFragment(), LoaderCallbacks<SingleResponse<Parcelable
|
|||
|
||||
if (status.retweet_id != null) {
|
||||
val retweetedBy = colorNameManager.getDisplayName(status.retweeted_by_user_key!!,
|
||||
status.retweeted_by_user_name, status.retweeted_by_user_screen_name, nameFirst)
|
||||
status.retweeted_by_user_name!!, status.retweeted_by_user_acct!!, nameFirst)
|
||||
retweetedByView.text = context.getString(R.string.name_retweeted, retweetedBy)
|
||||
retweetedByView.visibility = View.VISIBLE
|
||||
} else {
|
||||
|
@ -801,7 +801,7 @@ class StatusFragment : BaseFragment(), LoaderCallbacks<SingleResponse<Parcelable
|
|||
|
||||
itemView.quotedName.name = colorNameManager.getUserNickname(status.quoted_user_key!!,
|
||||
status.quoted_user_name)
|
||||
itemView.quotedName.screenName = "@${status.quoted_user_screen_name}"
|
||||
itemView.quotedName.screenName = "@${status.quoted_user_acct}"
|
||||
itemView.quotedName.updateText(formatter)
|
||||
|
||||
|
||||
|
@ -876,7 +876,7 @@ class StatusFragment : BaseFragment(), LoaderCallbacks<SingleResponse<Parcelable
|
|||
}
|
||||
|
||||
nameView.name = colorNameManager.getUserNickname(status.user_key, status.user_name)
|
||||
nameView.screenName = String.format("@%s", status.user_screen_name)
|
||||
nameView.screenName = "@${status.user_acct}"
|
||||
nameView.updateText(formatter)
|
||||
|
||||
adapter.requestManager.loadProfileImage(context, status, adapter.profileImageStyle,
|
||||
|
@ -897,13 +897,16 @@ class StatusFragment : BaseFragment(), LoaderCallbacks<SingleResponse<Parcelable
|
|||
profileTypeView.visibility = View.GONE
|
||||
}
|
||||
|
||||
val timeString = Utils.formatToLongTimeString(context, timestamp)
|
||||
if (!TextUtils.isEmpty(timeString) && !TextUtils.isEmpty(status.source)) {
|
||||
itemView.timeSource.text = HtmlSpanBuilder.fromHtml(context.getString(R.string.status_format_time_source, timeString, status.source))
|
||||
} else if (TextUtils.isEmpty(timeString) && !TextUtils.isEmpty(status.source)) {
|
||||
itemView.timeSource.text = HtmlSpanBuilder.fromHtml(status.source)
|
||||
} else if (!TextUtils.isEmpty(timeString) && TextUtils.isEmpty(status.source)) {
|
||||
itemView.timeSource.text = timeString
|
||||
val timeString = Utils.formatToLongTimeString(context, timestamp)?.takeIf(String::isNotEmpty)
|
||||
val source = status.source?.takeIf(String::isNotEmpty)
|
||||
itemView.timeSource.text = when {
|
||||
timeString != null && source != null -> {
|
||||
HtmlSpanBuilder.fromHtml(context.getString(R.string.status_format_time_source,
|
||||
timeString, source))
|
||||
}
|
||||
source != null -> HtmlSpanBuilder.fromHtml(source)
|
||||
timeString != null -> timeString
|
||||
else -> null
|
||||
}
|
||||
itemView.timeSource.movementMethod = LinkMovementMethod.getInstance()
|
||||
|
||||
|
|
|
@ -450,7 +450,7 @@ class UserFragment : BaseFragment(), OnClickListener, OnLinkClickListener,
|
|||
profileType.visibility = View.GONE
|
||||
}
|
||||
@SuppressLint("SetTextI18n")
|
||||
profileNameContainer.screenName.text = "@${user.screen_name}"
|
||||
profileNameContainer.screenName.text = "@${user.acct}"
|
||||
val linkHighlightOption = preferences[linkHighlightOptionKey]
|
||||
val linkify = TwidereLinkify(this, linkHighlightOption)
|
||||
if (user.description_unescaped != null) {
|
||||
|
|
|
@ -113,32 +113,39 @@
|
|||
android:textColor="?android:textColorPrimary"
|
||||
tools:text="Name"/>
|
||||
|
||||
<org.mariotaku.twidere.view.FixedTextView
|
||||
android:id="@+id/screenName"
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/name"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:textAppearance="?android:textAppearanceSmall"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
tools:text="\@screenname"/>
|
||||
android:baselineAligned="true"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<org.mariotaku.twidere.view.FixedTextView
|
||||
android:id="@+id/followingYouIndicator"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignBaseline="@+id/screenName"
|
||||
android:layout_marginLeft="@dimen/element_spacing_small"
|
||||
android:layout_marginStart="@dimen/element_spacing_small"
|
||||
android:layout_toEndOf="@+id/screenName"
|
||||
android:layout_toRightOf="@+id/screenName"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:text="@string/following_you"
|
||||
android:textAppearance="?android:textAppearanceSmall"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:visibility="gone"/>
|
||||
<org.mariotaku.twidere.view.FixedTextView
|
||||
android:id="@+id/screenName"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:textAppearance="?android:textAppearanceSmall"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
tools:text="\@screenname"/>
|
||||
|
||||
<org.mariotaku.twidere.view.FixedTextView
|
||||
android:id="@+id/followingYouIndicator"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/element_spacing_small"
|
||||
android:layout_marginStart="@dimen/element_spacing_small"
|
||||
android:layout_weight="0"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:text="@string/following_you"
|
||||
android:textAppearance="?android:textAppearanceSmall"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible"/>
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
||||
|
||||
</org.mariotaku.twidere.view.ColorLabelRelativeLayout>
|
||||
|
|
Loading…
Reference in New Issue