removed timeline user color/nickname caching

This commit is contained in:
Mariotaku Lee 2017-01-16 01:55:53 +08:00
parent 2aca2be609
commit 70830e404d
14 changed files with 66 additions and 174 deletions

View File

@ -321,34 +321,6 @@ public class ParcelableStatus implements Parcelable, Comparable<ParcelableStatus
@JsonField(name = "account_color")
@CursorField(Statuses.ACCOUNT_COLOR)
public int account_color;
@ParcelableThisPlease
@JsonField(name = "user_color")
@CursorField(Statuses.USER_COLOR)
public int user_color;
@ParcelableThisPlease
@JsonField(name = "quoted_user_color")
@CursorField(Statuses.QUOTED_USER_COLOR)
public int quoted_user_color;
@ParcelableThisPlease
@JsonField(name = "retweet_user_color")
@CursorField(Statuses.RETWEET_USER_COLOR)
public int retweet_user_color;
@ParcelableThisPlease
@JsonField(name = "user_nickname")
@CursorField(Statuses.USER_NICKNAME)
public String user_nickname;
@ParcelableThisPlease
@JsonField(name = "quoted_user_nickname")
@CursorField(Statuses.QUOTED_USER_NICKNAME)
public String quoted_user_nickname;
@ParcelableThisPlease
@JsonField(name = "retweet_user_nickname")
@CursorField(Statuses.RETWEET_USER_NICKNAME)
public String retweet_user_nickname;
@ParcelableThisPlease
@JsonField(name = "in_reply_to_user_nickname")
@CursorField(Statuses.IN_REPLY_TO_USER_NICKNAME)
public String in_reply_to_user_nickname;
@CursorField(Statuses.INSERTED_DATE)
public long inserted_date;
@ -461,13 +433,6 @@ public class ParcelableStatus implements Parcelable, Comparable<ParcelableStatus
", quoted_spans=" + Arrays.toString(quoted_spans) +
", is_filtered=" + is_filtered +
", account_color=" + account_color +
", user_color=" + user_color +
", quoted_user_color=" + quoted_user_color +
", retweet_user_color=" + retweet_user_color +
", user_nickname='" + user_nickname + '\'' +
", quoted_user_nickname='" + quoted_user_nickname + '\'' +
", retweet_user_nickname='" + retweet_user_nickname + '\'' +
", in_reply_to_user_nickname='" + in_reply_to_user_nickname + '\'' +
", inserted_date=" + inserted_date +
", is_pinned_status=" + is_pinned_status +
'}';

View File

@ -866,9 +866,6 @@ public interface TwidereDataStore {
String ACCOUNT_COLOR = "account_color";
String USER_COLOR = "user_color";
String QUOTED_USER_COLOR = "quoted_user_color";
String RETWEET_USER_COLOR = "retweet_user_color";
String USER_NICKNAME = "user_nickname";
String QUOTED_USER_NICKNAME = "quoted_user_nickname";

View File

@ -34,7 +34,7 @@ import static org.mariotaku.twidere.annotation.PreferenceType.STRING;
public interface Constants extends TwidereConstants {
String DATABASES_NAME = "twidere.sqlite";
int DATABASES_VERSION = 160;
int DATABASES_VERSION = 161;
int MENU_GROUP_STATUS_EXTENSION = 10;
int MENU_GROUP_COMPOSE_EXTENSION = 11;

View File

@ -95,7 +95,7 @@ public class ActivityTitleSummaryMessage {
title = getTitleStringAboutMe(resources, manager, R.string.activity_about_me_liked_retweet,
R.string.activity_about_me_liked_retweet_multi, sources, nameFirst);
}
final Spanned summary = generateStatusTextSummary(context, activity.target_statuses,
final Spanned summary = generateStatusTextSummary(context, manager, activity.target_statuses,
nameFirst);
return new ActivityTitleSummaryMessage(typeIcon, color, title, summary);
}
@ -104,7 +104,7 @@ public class ActivityTitleSummaryMessage {
int color = ContextCompat.getColor(context, R.color.highlight_retweet);
CharSequence title = getTitleStringAboutMe(resources, manager, R.string.activity_about_me_retweeted_retweet,
R.string.activity_about_me_retweeted_retweet_multi, sources, nameFirst);
final Spanned summary = generateStatusTextSummary(context, activity.target_statuses,
final Spanned summary = generateStatusTextSummary(context, manager, activity.target_statuses,
nameFirst);
return new ActivityTitleSummaryMessage(typeIcon, color, title, summary);
}
@ -113,7 +113,7 @@ public class ActivityTitleSummaryMessage {
int color = ContextCompat.getColor(context, R.color.highlight_retweet);
CharSequence title = getTitleStringAboutMe(resources, manager, R.string.activity_about_me_retweeted_mention,
R.string.activity_about_me_retweeted_mention_multi, sources, nameFirst);
final Spanned summary = generateStatusTextSummary(context, activity.target_statuses,
final Spanned summary = generateStatusTextSummary(context, manager, activity.target_statuses,
nameFirst);
return new ActivityTitleSummaryMessage(typeIcon, color, title, summary);
}
@ -132,7 +132,7 @@ public class ActivityTitleSummaryMessage {
title = getTitleStringAboutMe(resources, manager, R.string.activity_about_me_liked_mention,
R.string.activity_about_me_liked_mention_multi, sources, nameFirst);
}
final Spanned summary = generateStatusTextSummary(context, activity.target_statuses,
final Spanned summary = generateStatusTextSummary(context, manager, activity.target_statuses,
nameFirst);
return new ActivityTitleSummaryMessage(typeIcon, color, title, summary);
}
@ -197,7 +197,7 @@ public class ActivityTitleSummaryMessage {
CharSequence title;
title = getTitleStringAboutMe(resources, manager, R.string.activity_about_me_media_tagged,
R.string.activity_about_me_media_tagged_multi, sources, nameFirst);
final Spanned summary = generateStatusTextSummary(context, activity.target_statuses,
final Spanned summary = generateStatusTextSummary(context, manager, activity.target_statuses,
nameFirst);
return new ActivityTitleSummaryMessage(typeIcon, color, title, summary);
}
@ -216,7 +216,7 @@ public class ActivityTitleSummaryMessage {
title = getTitleStringAboutMe(resources, manager, R.string.activity_about_me_liked_media_tagged,
R.string.activity_about_me_liked_media_tagged_multi, sources, nameFirst);
}
final Spanned summary = generateStatusTextSummary(context, activity.target_statuses,
final Spanned summary = generateStatusTextSummary(context, manager, activity.target_statuses,
nameFirst);
return new ActivityTitleSummaryMessage(typeIcon, color, title, summary);
}
@ -225,7 +225,7 @@ public class ActivityTitleSummaryMessage {
int color = ContextCompat.getColor(context, R.color.highlight_retweet);
CharSequence title = getTitleStringAboutMe(resources, manager, R.string.activity_about_me_retweeted_media_tagged,
R.string.activity_about_me_retweeted_media_tagged_multi, sources, nameFirst);
final Spanned summary = generateStatusTextSummary(context, activity.target_statuses,
final Spanned summary = generateStatusTextSummary(context, manager, activity.target_statuses,
nameFirst);
return new ActivityTitleSummaryMessage(typeIcon, color, title, summary);
}
@ -233,7 +233,8 @@ public class ActivityTitleSummaryMessage {
return null;
}
public static Spanned generateStatusTextSummary(Context context, ParcelableStatus[] statuses, boolean nameFirst) {
public static Spanned generateStatusTextSummary(Context context, UserColorNameManager manager,
ParcelableStatus[] statuses, boolean nameFirst) {
if (statuses == null) return null;
final SpannableStringBuilder summaryBuilder = new SpannableStringBuilder();
boolean first = true;
@ -241,7 +242,7 @@ public class ActivityTitleSummaryMessage {
if (!first) {
summaryBuilder.append('\n');
}
final SpannableString displayName = new SpannableString(UserColorNameManager.decideDisplayName(status.user_nickname,
final SpannableString displayName = new SpannableString(manager.getDisplayName(status.user_key,
status.user_name, status.user_screen_name, nameFirst));
displayName.setSpan(new StyleSpan(Typeface.BOLD), 0, displayName.length(),
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

View File

@ -182,15 +182,6 @@ public final class ContentValuesCreator implements TwidereConstants {
activity.status_spans = status.spans;
activity.status_text_plain = status.text_plain;
activity.status_source = status.source;
activity.status_user_color = status.user_color;
activity.status_retweet_user_color = status.retweet_user_color;
activity.status_quoted_user_color = status.quoted_user_color;
activity.status_user_nickname = status.user_nickname;
activity.status_in_reply_to_user_nickname = status.in_reply_to_user_nickname;
activity.status_retweet_user_nickname = status.retweet_user_nickname;
activity.status_quoted_user_nickname = status.quoted_user_nickname;
}
ParcelableActivityValuesCreator.writeTo(activity, values);
return values;

View File

@ -19,26 +19,21 @@
package org.mariotaku.twidere.util;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.graphics.Color;
import android.net.Uri;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.util.LruCache;
import org.mariotaku.microblog.library.twitter.model.User;
import org.mariotaku.sqliteqb.library.Expression;
import org.mariotaku.twidere.TwidereConstants;
import org.mariotaku.twidere.model.ParcelableStatus;
import org.mariotaku.twidere.model.ParcelableUser;
import org.mariotaku.twidere.model.ParcelableUserList;
import org.mariotaku.twidere.model.UserKey;
import org.mariotaku.twidere.model.util.UserKeyUtils;
import org.mariotaku.twidere.provider.TwidereDataStore.Activities;
import org.mariotaku.twidere.provider.TwidereDataStore.Statuses;
import java.util.Map;
import java.util.Set;
@ -47,13 +42,19 @@ import static android.text.TextUtils.isEmpty;
public class UserColorNameManager implements TwidereConstants {
private final static String NICKNAME_NULL = ".#NULL#";
private final SharedPreferences colorPreferences, nicknamePreferences;
private final LruCache<String, Integer> colorCache;
private final LruCache<String, String> nicknameCache;
private final Context context;
public UserColorNameManager(Context context) {
this.context = context;
colorPreferences = context.getSharedPreferences(USER_COLOR_PREFERENCES_NAME, Context.MODE_PRIVATE);
nicknamePreferences = context.getSharedPreferences(USER_NICKNAME_PREFERENCES_NAME, Context.MODE_PRIVATE);
colorCache = new LruCache<>(512);
nicknameCache = new LruCache<>(256);
}
public SharedPreferences getColorPreferences() {
@ -87,7 +88,7 @@ public class UserColorNameManager implements TwidereConstants {
public void clearUserColor(@NonNull final UserKey userKey) {
final SharedPreferences.Editor editor = colorPreferences.edit();
final String userKeyString = userKey.toString();
updateColor(userKeyString, 0);
colorCache.remove(userKeyString);
editor.remove(userKeyString);
editor.apply();
}
@ -95,7 +96,7 @@ public class UserColorNameManager implements TwidereConstants {
public void setUserColor(@NonNull final UserKey userKey, final int color) {
final SharedPreferences.Editor editor = colorPreferences.edit();
final String userKeyString = userKey.toString();
updateColor(userKeyString, color);
colorCache.put(userKeyString, color);
editor.putInt(userKeyString, color);
editor.apply();
}
@ -103,7 +104,7 @@ public class UserColorNameManager implements TwidereConstants {
public void setUserNickname(@NonNull final UserKey userKey, final String nickname) {
final SharedPreferences.Editor editor = nicknamePreferences.edit();
final String userKeyString = userKey.toString();
updateNickname(userKeyString, null);
nicknameCache.put(userKeyString, nickname);
editor.putString(userKeyString, nickname);
editor.apply();
}
@ -111,63 +112,11 @@ public class UserColorNameManager implements TwidereConstants {
public void clearUserNickname(@NonNull final UserKey userKey) {
final SharedPreferences.Editor editor = nicknamePreferences.edit();
final String userKeyString = userKey.toString();
updateNickname(userKeyString, null);
nicknameCache.remove(userKeyString);
editor.remove(userKeyString);
editor.apply();
}
private void updateColor(String userKey, int color) {
final ContentResolver cr = context.getContentResolver();
ContentValues cv = new ContentValues();
updateColumn(cr, Statuses.CONTENT_URI, userKey, Statuses.USER_COLOR, Statuses.USER_KEY,
color, cv);
updateColumn(cr, Statuses.CONTENT_URI, userKey, Statuses.QUOTED_USER_COLOR,
Statuses.QUOTED_USER_KEY, color, cv);
updateColumn(cr, Statuses.CONTENT_URI, userKey, Statuses.RETWEET_USER_COLOR,
Statuses.RETWEETED_BY_USER_KEY, color, cv);
updateColumn(cr, Activities.AboutMe.CONTENT_URI, userKey, Activities.STATUS_USER_COLOR,
Activities.STATUS_USER_KEY, color, cv);
updateColumn(cr, Activities.AboutMe.CONTENT_URI, userKey, Activities.STATUS_RETWEET_USER_COLOR,
Activities.STATUS_RETWEETED_BY_USER_KEY, color, cv);
updateColumn(cr, Activities.AboutMe.CONTENT_URI, userKey, Activities.STATUS_QUOTED_USER_COLOR,
Activities.STATUS_QUOTED_USER_KEY, color, cv);
}
private void updateNickname(String userKey, String nickname) {
final ContentResolver cr = context.getContentResolver();
ContentValues cv = new ContentValues();
updateColumn(cr, Statuses.CONTENT_URI, userKey, Statuses.USER_NICKNAME, Statuses.USER_KEY,
nickname, cv);
updateColumn(cr, Statuses.CONTENT_URI, userKey, Statuses.QUOTED_USER_NICKNAME,
Statuses.QUOTED_USER_KEY, nickname, cv);
updateColumn(cr, Statuses.CONTENT_URI, userKey, Statuses.RETWEET_USER_NICKNAME,
Statuses.RETWEETED_BY_USER_KEY, nickname, cv);
updateColumn(cr, Activities.AboutMe.CONTENT_URI, userKey, Activities.STATUS_USER_NICKNAME,
Activities.STATUS_USER_KEY, nickname, cv);
updateColumn(cr, Activities.AboutMe.CONTENT_URI, userKey, Activities.STATUS_RETWEET_USER_NICKNAME,
Activities.STATUS_RETWEETED_BY_USER_KEY, nickname, cv);
updateColumn(cr, Activities.AboutMe.CONTENT_URI, userKey, Activities.STATUS_QUOTED_USER_NICKNAME,
Activities.STATUS_QUOTED_USER_KEY, nickname, cv);
}
private static void updateColumn(ContentResolver cr, Uri uri, String userKey, String valueColumn,
String whereColumn, int value, ContentValues temp) {
temp.clear();
temp.put(valueColumn, value);
cr.update(uri, temp, Expression.equalsArgs(whereColumn).getSQL(),
new String[]{userKey});
}
private static void updateColumn(ContentResolver cr, Uri uri, String userKey, String valueColumn,
String whereColumn, String value, ContentValues temp) {
temp.clear();
temp.put(valueColumn, value);
cr.update(uri, temp, Expression.equalsArgs(whereColumn).getSQL(),
new String[]{userKey});
}
public String getDisplayName(final ParcelableUser user, final boolean nameFirst) {
return getDisplayName(user.key, user.name, user.screen_name, nameFirst);
@ -201,21 +150,17 @@ public class UserColorNameManager implements TwidereConstants {
}
public int getUserColor(@NonNull final String userId) {
return colorPreferences.getInt(userId, Color.TRANSPARENT);
final Integer cached = colorCache.get(userId);
if (cached != null) return cached;
final int color = colorPreferences.getInt(userId, Color.TRANSPARENT);
colorCache.put(userId, color);
return color;
}
@Nullable
public String getUserNickname(@NonNull final UserKey userKey) {
final String userKeyString = userKey.toString();
if (nicknamePreferences.contains(userKey.getId())) {
String nick = nicknamePreferences.getString(userKey.getId(), null);
SharedPreferences.Editor editor = nicknamePreferences.edit();
editor.remove(userKey.getId());
editor.putString(userKeyString, nick);
editor.apply();
return nick;
}
return nicknamePreferences.getString(userKeyString, null);
return getUserNicknameInternal(userKeyString);
}
@Nullable
@ -235,7 +180,16 @@ public class UserColorNameManager implements TwidereConstants {
}
private String getUserNicknameInternal(@NonNull final String userId) {
return nicknamePreferences.getString(userId, null);
final String cached = nicknameCache.get(userId);
if (NICKNAME_NULL.equals(cached)) return null;
if (cached != null) return cached;
final String nickname = nicknamePreferences.getString(userId, null);
if (nickname != null) {
nicknameCache.put(userId, nickname);
} else {
nicknameCache.put(userId, NICKNAME_NULL);
}
return nickname;
}
public interface UserColorChangedListener {

View File

@ -464,7 +464,8 @@ abstract class AbsActivitiesFragment protected constructor() :
ITEM_VIEW_TYPE_STATUS -> {
val status = getActivityStatus(position) ?: return
inflater.inflate(R.menu.action_status, menu)
MenuUtils.setupForStatus(context, preferences, menu, status, twitterWrapper)
MenuUtils.setupForStatus(context, preferences, menu, status, twitterWrapper,
userColorNameManager)
}
}
}

View File

@ -472,7 +472,8 @@ abstract class AbsStatusesFragment protected constructor() :
val contextMenuInfo = menuInfo as ExtendedRecyclerView.ContextMenuInfo?
val status = adapter.getStatus(contextMenuInfo!!.position)
inflater.inflate(R.menu.action_status, menu)
MenuUtils.setupForStatus(context, preferences, menu, status!!, twitterWrapper)
MenuUtils.setupForStatus(context, preferences, menu, status!!, twitterWrapper,
userColorNameManager)
}
override fun onContextItemSelected(item: MenuItem): Boolean {

View File

@ -122,7 +122,7 @@ class ItemsListFragment : AbsContentListRecyclerViewFragment<VariousItemsAdapter
val status = dummyAdapter.getStatus(contextMenuInfo.position) ?: return
inflater.inflate(R.menu.action_status, menu)
MenuUtils.setupForStatus(context, preferences, menu, status,
twitterWrapper)
twitterWrapper, userColorNameManager)
}
}
}

View File

@ -236,10 +236,8 @@ class StatusFragment : BaseFragment(), LoaderCallbacks<SingleResponse<Parcelable
if (data == null) return
val color = data.getIntExtra(EXTRA_COLOR, Color.TRANSPARENT)
userColorNameManager.setUserColor(status.user_key, color)
status.user_color = color
} else if (resultCode == ColorPickerDialogActivity.RESULT_CLEARED) {
userColorNameManager.clearUserColor(status.user_key)
status.user_color = 0
}
val args = arguments
if (args.containsKey(EXTRA_STATUS)) {
@ -629,7 +627,8 @@ class StatusFragment : BaseFragment(), LoaderCallbacks<SingleResponse<Parcelable
val status = adapter.getStatus(contextMenuInfo.position) ?: return
val inflater = MenuInflater(context)
inflater.inflate(R.menu.action_status, menu)
MenuUtils.setupForStatus(context, preferences, menu, status, twitterWrapper)
MenuUtils.setupForStatus(context, preferences, menu, status, twitterWrapper,
userColorNameManager)
}
override fun onContextItemSelected(item: MenuItem): Boolean {
@ -780,11 +779,12 @@ class StatusFragment : BaseFragment(), LoaderCallbacks<SingleResponse<Parcelable
val formatter = adapter.bidiFormatter
val twitter = adapter.twitterWrapper
val nameFirst = adapter.nameFirst
val colorNameManager = adapter.userColorNameManager
linkClickHandler.status = status
if (status.retweet_id != null) {
val retweetedBy = UserColorNameManager.decideDisplayName(status.retweet_user_nickname,
val retweetedBy = colorNameManager.getDisplayName(status.retweeted_by_user_key!!,
status.retweeted_by_user_name, status.retweeted_by_user_screen_name, nameFirst)
retweetedByView.text = context.getString(R.string.name_retweeted, retweetedBy)
retweetedByView.visibility = View.VISIBLE
@ -808,7 +808,7 @@ class StatusFragment : BaseFragment(), LoaderCallbacks<SingleResponse<Parcelable
itemView.quotedName.visibility = View.VISIBLE
itemView.quotedText.visibility = View.VISIBLE
itemView.quotedName.setName(UserColorNameManager.decideNickname(status.quoted_user_nickname,
itemView.quotedName.setName(colorNameManager.getUserNickname(status.quoted_user_key!!,
status.quoted_user_name))
itemView.quotedName.setScreenName(String.format("@%s", status.quoted_user_screen_name))
itemView.quotedName.updateText(formatter)
@ -835,7 +835,7 @@ class StatusFragment : BaseFragment(), LoaderCallbacks<SingleResponse<Parcelable
itemView.quotedText.visibility = View.VISIBLE
}
itemView.quoteIndicator.color = status.quoted_user_color
itemView.quoteIndicator.color = colorNameManager.getUserColor(status.quoted_user_key!!)
val quotedMedia = status.quoted_media
@ -872,7 +872,7 @@ class StatusFragment : BaseFragment(), LoaderCallbacks<SingleResponse<Parcelable
itemView.quotedView.visibility = View.GONE
}
itemView.profileContainer.drawStart(status.user_color)
itemView.profileContainer.drawStart(colorNameManager.getUserColor(status.user_key))
val timestamp: Long
@ -882,7 +882,7 @@ class StatusFragment : BaseFragment(), LoaderCallbacks<SingleResponse<Parcelable
timestamp = status.timestamp
}
itemView.name.setName(UserColorNameManager.decideNickname(status.user_nickname, status.user_name))
itemView.name.setName(colorNameManager.getUserNickname(status.user_key, status.user_name))
itemView.name.setScreenName(String.format("@%s", status.user_screen_name))
itemView.name.updateText(formatter)
@ -1008,7 +1008,7 @@ class StatusFragment : BaseFragment(), LoaderCallbacks<SingleResponse<Parcelable
}
MenuUtils.setupForStatus(context, fragment.preferences, itemView.menuBar.menu, status,
adapter.statusAccount!!, twitter)
adapter.statusAccount!!, twitter, colorNameManager)
val lang = status.lang

View File

@ -25,13 +25,5 @@ fun ParcelableActivity.getActivityStatus(): ParcelableStatus? {
else -> return null
}
status.account_color = account_color
status.user_color = status_user_color
status.retweet_user_color = status_retweet_user_color
status.quoted_user_color = status_quoted_user_color
status.user_nickname = status_user_nickname
status.in_reply_to_user_nickname = status_in_reply_to_user_nickname
status.retweet_user_nickname = status_retweet_user_nickname
status.quoted_user_nickname = status_quoted_user_nickname
return status
}

View File

@ -268,21 +268,6 @@ object ParcelableStatusUtils {
fun updateExtraInformation(status: ParcelableStatus, details: AccountDetails, manager: UserColorNameManager) {
status.account_color = details.color
status.user_color = manager.getUserColor(status.user_key)
status.user_nickname = manager.getUserNickname(status.user_key)
if (status.quoted_user_key != null) {
status.quoted_user_color = manager.getUserColor(status.quoted_user_key!!)
status.quoted_user_nickname = manager.getUserNickname(status.quoted_user_key!!)
}
if (status.retweeted_by_user_key != null) {
status.retweet_user_color = manager.getUserColor(status.retweeted_by_user_key!!)
status.retweet_user_nickname = manager.getUserNickname(status.retweeted_by_user_key!!)
}
if (status.in_reply_to_user_key != null) {
status.in_reply_to_user_nickname = manager.getUserNickname(status.in_reply_to_user_key!!)
}
}
fun Status.inferExternalUrl(): String? {

View File

@ -36,6 +36,7 @@ import android.util.Log
import android.view.ContextMenu
import android.view.Menu
import android.view.MenuItem
import org.mariotaku.kpreferences.get
import org.mariotaku.ktextension.setItemChecked
import org.mariotaku.ktextension.setMenuItemIcon
import org.mariotaku.twidere.Constants
@ -44,6 +45,7 @@ import org.mariotaku.twidere.TwidereConstants.*
import org.mariotaku.twidere.activity.AccountSelectorActivity
import org.mariotaku.twidere.activity.ColorPickerDialogActivity
import org.mariotaku.twidere.constant.SharedPreferenceConstants
import org.mariotaku.twidere.constant.nameFirstKey
import org.mariotaku.twidere.fragment.AbsStatusesFragment
import org.mariotaku.twidere.fragment.AddStatusFilterDialogFragment
import org.mariotaku.twidere.fragment.DestroyStatusDialogFragment
@ -113,10 +115,11 @@ object MenuUtils {
preferences: SharedPreferencesWrapper,
menu: Menu,
status: ParcelableStatus,
twitter: AsyncTwitterWrapper) {
twitter: AsyncTwitterWrapper,
manager: UserColorNameManager) {
val account = AccountUtils.getAccountDetails(AccountManager.get(context),
status.account_key, true) ?: return
setupForStatus(context, preferences, menu, status, account, twitter)
setupForStatus(context, preferences, menu, status, account, twitter, manager)
}
@UiThread
@ -125,11 +128,12 @@ object MenuUtils {
menu: Menu,
status: ParcelableStatus,
details: AccountDetails,
twitter: AsyncTwitterWrapper) {
twitter: AsyncTwitterWrapper,
manager: UserColorNameManager) {
if (menu is ContextMenu) {
menu.setHeaderTitle(context.getString(R.string.status_menu_title_format,
UserColorNameManager.decideDisplayName(status.user_nickname, status.user_name,
status.user_screen_name, preferences.getBoolean(SharedPreferenceConstants.KEY_NAME_FIRST)),
manager.getDisplayName(status.user_key, status.user_name, status.user_screen_name,
preferences[nameFirstKey]),
status.text_unescaped))
}
val retweetHighlight = ContextCompat.getColor(context, R.color.highlight_retweet)

View File

@ -268,13 +268,14 @@ class StatusViewHolder(private val adapter: IStatusesAdapter<*>, itemView: View)
quotedView.drawStart(ThemeUtils.getColorFromAttribute(context, R.attr.quoteIndicatorBackgroundColor, 0))
}
itemContent.drawStart(status.user_color)
itemContent.drawStart(colorNameManager.getUserColor(status.user_key))
} else {
quotedView.visibility = View.GONE
val userColor = colorNameManager.getUserColor(status.user_key)
if (status.is_retweet) {
val retweetUserColor = status.retweet_user_color
val userColor = status.user_color
val retweetUserColor = colorNameManager.getUserColor(status.retweeted_by_user_key!!)
if (retweetUserColor == 0) {
itemContent.drawStart(userColor)
} else if (userColor == 0) {
@ -283,7 +284,7 @@ class StatusViewHolder(private val adapter: IStatusesAdapter<*>, itemView: View)
itemContent.drawStart(retweetUserColor, userColor)
}
} else {
itemContent.drawStart(status.user_color)
itemContent.drawStart(userColor)
}
}