added option to use favorite instead of like

This commit is contained in:
Mariotaku Lee 2015-11-05 18:55:03 +08:00
parent 3417fc68d4
commit 83ee6d855b
21 changed files with 168 additions and 46 deletions

View File

@ -1,9 +1,11 @@
apply plugin: 'com.github.ben-manes.versions'
apply plugin: 'com.github.hierynomus.license'
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
maven { url 'https://plugins.gradle.org/m2/' }
}
dependencies {
classpath 'com.github.ben-manes:gradle-versions-plugin:0.11.3'
@ -13,6 +15,7 @@ buildscript {
// should be excluded to avoid conflict
exclude group: 'xerces'
}
classpath 'gradle.plugin.nl.javadude.gradle.plugins:license-gradle-plugin:0.12.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
@ -21,7 +24,7 @@ buildscript {
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
maven { url 'https://jitpack.io' }
}
}

View File

@ -312,5 +312,7 @@ public interface SharedPreferenceConstants {
@Preference(type = BOOLEAN, hasDefault = true, defaultBoolean = false)
String KEY_COMBINED_NOTIFICATIONS = "combined_notifications";
@Preference(type = BOOLEAN, hasDefault = true, defaultBoolean = true)
String TWITTER_OPTIMIZED_SEARCHES = "twitter_optimized_searches";
String KEY_TWITTER_OPTIMIZED_SEARCHES = "twitter_optimized_searches";
@Preference(type = BOOLEAN, hasDefault = true, defaultBoolean = false)
String KEY_I_WANT_MY_STARS_BACK = "i_want_my_stars_back";
}

View File

@ -38,6 +38,7 @@ import org.mariotaku.twidere.util.AsyncTwitterWrapper;
import org.mariotaku.twidere.util.KeyboardShortcutsHandler;
import org.mariotaku.twidere.util.KeyboardShortcutsHandler.KeyboardShortcutCallback;
import org.mariotaku.twidere.util.ReadStateManager;
import org.mariotaku.twidere.util.SharedPreferencesWrapper;
import org.mariotaku.twidere.util.ThemeUtils;
import org.mariotaku.twidere.util.dagger.ApplicationModule;
import org.mariotaku.twidere.util.dagger.DaggerGeneralComponent;
@ -63,6 +64,8 @@ public class BaseAppCompatActivity extends ThemedAppCompatActivity implements Co
protected ReadStateManager mReadStateManager;
@Inject
protected Bus mBus;
@Inject
protected SharedPreferencesWrapper mPreferences;
// Registered listeners
private ArrayList<ControlBarOffsetListener> mControlBarOffsetListeners = new ArrayList<>();

View File

@ -430,7 +430,11 @@ public class LinkHandlerActivity extends BaseAppCompatActivity implements System
break;
}
case LINK_ID_USER_FAVORITES: {
setTitle(R.string.likes);
if (mPreferences.getBoolean(KEY_I_WANT_MY_STARS_BACK)) {
setTitle(R.string.favorites);
} else {
setTitle(R.string.likes);
}
break;
}
case LINK_ID_USER_FOLLOWERS: {

View File

@ -52,6 +52,7 @@ public abstract class AbsStatusesAdapter<D> extends LoadMoreSupportAdapter<ViewH
private final boolean mDisplayProfileImage;
private final boolean mSensitiveContentEnabled;
private final boolean mHideCardActions;
private final boolean mUseStarsForLikes;
private StatusAdapterListener mStatusAdapterListener;
private boolean mShowInReplyTo;
private boolean mShowAccountsColor;
@ -71,6 +72,7 @@ public abstract class AbsStatusesAdapter<D> extends LoadMoreSupportAdapter<ViewH
mDisplayMediaPreview = mPreferences.getBoolean(KEY_MEDIA_PREVIEW, false);
mSensitiveContentEnabled = mPreferences.getBoolean(KEY_DISPLAY_SENSITIVE_CONTENTS, false);
mHideCardActions = mPreferences.getBoolean(KEY_HIDE_CARD_ACTIONS, false);
mUseStarsForLikes = mPreferences.getBoolean(KEY_I_WANT_MY_STARS_BACK);
mLinkify = new TwidereLinkify(new StatusAdapterLinkClickHandler<>(this));
setShowInReplyTo(true);
}
@ -165,6 +167,11 @@ public abstract class AbsStatusesAdapter<D> extends LoadMoreSupportAdapter<ViewH
return mStatusAdapterListener != null && mStatusAdapterListener.onStatusLongClick(holder, position);
}
@Override
public boolean shouldUseStarsForLikes() {
return mUseStarsForLikes;
}
@Override
public final void onStatusClick(IStatusViewHolder holder, int position) {
if (mStatusAdapterListener == null) return;

View File

@ -20,6 +20,7 @@
package org.mariotaku.twidere.adapter;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import org.mariotaku.twidere.util.AsyncTwitterWrapper;
@ -60,6 +61,7 @@ public abstract class BaseRecyclerViewAdapter<VH extends RecyclerView.ViewHolder
.inject((BaseRecyclerViewAdapter<RecyclerView.ViewHolder>) this);
}
@NonNull
public final Context getContext() {
return mContext;
}

View File

@ -37,6 +37,8 @@ public interface IStatusesAdapter<Data> extends IContentCardAdapter, IStatusView
boolean shouldShowAccountsColor();
boolean shouldUseStarsForLikes();
MediaLoadingHandler getMediaLoadingHandler();
}

View File

@ -372,7 +372,7 @@ public abstract class AbsStatusesFragment<Data> extends AbsContentListRecyclerVi
popupMenu.setOnMenuItemClickListener(mOnStatusMenuItemClickListener);
popupMenu.inflate(R.menu.action_status);
final ParcelableStatus status = adapter.getStatus(position);
setMenuForStatus(adapter.getContext(), popupMenu.getMenu(), status);
setMenuForStatus(adapter.getContext(), mPreferences, popupMenu.getMenu(), status);
popupMenu.show();
mPopupMenu = popupMenu;
mSelectedStatus = status;

View File

@ -116,7 +116,6 @@ public class AccountsDashboardFragment extends BaseSupportFragment implements Lo
private final Rect mSystemWindowsInsets = new Rect();
private ContentResolver mResolver;
private SharedPreferences mPreferences;
private MergeAdapter mAdapter;
private AccountSelectorAdapter mAccountsAdapter;
@ -410,7 +409,6 @@ public class AccountsDashboardFragment extends BaseSupportFragment implements Lo
@Override
public void onActivityCreated(final Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
mPreferences = getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
mResolver = getContentResolver();
final View view = getView();
if (view == null) throw new AssertionError();
@ -512,11 +510,15 @@ public class AccountsDashboardFragment extends BaseSupportFragment implements Lo
void initAccountActionsAdapter(ParcelableAccount[] accounts) {
mAccountOptionsAdapter.clear();
mAccountOptionsAdapter.add(new OptionItem(android.R.string.search_go, R.drawable.ic_action_search, R.id.search));
// if (accounts.length > 1) {
// mAccountOptionsAdapter.add(new OptionItem(R.string.compose, R.drawable.ic_action_status_compose, R.id.compose));
// }
mAccountOptionsAdapter.add(new OptionItem(R.string.likes, R.drawable.ic_action_heart, R.id.favorites));
mAccountOptionsAdapter.add(new OptionItem(android.R.string.search_go, R.drawable.ic_action_search,
R.id.search));
if (mPreferences.getBoolean(KEY_I_WANT_MY_STARS_BACK)) {
mAccountOptionsAdapter.add(new OptionItem(R.string.favorites, R.drawable.ic_action_star,
R.id.favorites));
} else {
mAccountOptionsAdapter.add(new OptionItem(R.string.likes, R.drawable.ic_action_heart,
R.id.favorites));
}
mAccountOptionsAdapter.add(new OptionItem(R.string.lists, R.drawable.ic_action_list, R.id.lists));
}

View File

@ -179,7 +179,7 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
final long statusId = args.getLong(EXTRA_STATUS_ID, -1);
final long maxId = args.getLong(EXTRA_MAX_ID, -1);
final long sinceId = args.getLong(EXTRA_SINCE_ID, -1);
final boolean twitterOptimizedSearches = mPreferences.getBoolean(TWITTER_OPTIMIZED_SEARCHES);
final boolean twitterOptimizedSearches = mPreferences.getBoolean(KEY_TWITTER_OPTIMIZED_SEARCHES);
final StatusRepliesLoader loader = new StatusRepliesLoader(getActivity(), accountId,
screenName, statusId, maxId, sinceId, null, null, 0, true, twitterOptimizedSearches);
@ -389,7 +389,7 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
popupMenu.setOnMenuItemClickListener(mOnStatusMenuItemClickListener);
popupMenu.inflate(R.menu.action_status);
final ParcelableStatus status = mStatusAdapter.getStatus(position);
Utils.setMenuForStatus(mStatusAdapter.getContext(), popupMenu.getMenu(), status);
Utils.setMenuForStatus(mStatusAdapter.getContext(), mPreferences, popupMenu.getMenu(), status);
popupMenu.show();
mPopupMenu = popupMenu;
mSelectedStatus = status;
@ -758,6 +758,7 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
private static class DetailStatusViewHolder extends ViewHolder implements OnClickListener,
ActionMenuView.OnMenuItemClickListener {
private final StatusFragment fragment;
private final StatusAdapter adapter;
private final ActionMenuView menuBar;
@ -771,23 +772,25 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
private final TextView retweetedByView;
private final View repliesContainer, retweetsContainer, favoritesContainer;
private final TextView repliesCountView, retweetsCountView, favoritesCountView;
private final TextView quoteOriginalLink;
private final TextView quoteOriginalLink;
private final ColorLabelRelativeLayout profileContainer;
private final View mediaPreviewContainer;
private final View mediaPreviewLoad;
private final CardMediaContainer mediaPreview;
private final View quotedNameContainer;
private final ForegroundColorView quoteIndicator;
private final ForegroundColorView quoteIndicator;
private final TextView locationView;
private final TwitterCardContainer twitterCard;
private final StatusLinkClickHandler linkClickHandler;
private final TwidereLinkify linkify;
private final TextView favoritesLabel;
public DetailStatusViewHolder(StatusAdapter adapter, View itemView) {
public DetailStatusViewHolder(StatusFragment fragment, StatusAdapter adapter, View itemView) {
super(itemView);
this.fragment = fragment;
this.linkClickHandler = new StatusLinkClickHandler(adapter.getContext(), null);
this.linkify = new TwidereLinkify(linkClickHandler, false);
this.adapter = adapter;
@ -812,6 +815,7 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
quoteOriginalLink = (TextView) itemView.findViewById(R.id.quote_original_link);
profileContainer = (ColorLabelRelativeLayout) itemView.findViewById(R.id.profile_container);
twitterCard = (TwitterCardContainer) itemView.findViewById(R.id.twitter_card);
favoritesLabel = (TextView) itemView.findViewById(R.id.favorites_label);
quotedTextView = (TextView) itemView.findViewById(R.id.quoted_text);
quotedNameView = (TextView) itemView.findViewById(R.id.quoted_name);
@ -973,7 +977,8 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
twitterCard.setVisibility(View.GONE);
}
Utils.setMenuForStatus(context, menuBar.getMenu(), status, adapter.getStatusAccount());
Utils.setMenuForStatus(context, fragment.mPreferences, menuBar.getMenu(), status,
adapter.getStatusAccount());
textView.setTextIsSelectable(true);
quotedTextView.setTextIsSelectable(true);
@ -1093,6 +1098,10 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
quotedTextView.setCustomSelectionActionModeCallback(new StatusActionModeCallback(quotedTextView, activity));
textView.setCustomSelectionActionModeCallback(new StatusActionModeCallback(textView, activity));
if (adapter.shouldUseStarsForLikes()) {
favoritesLabel.setText(R.string.favorites);
}
}
@ -1140,6 +1149,7 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
private final boolean mDisplayProfileImage;
private final boolean mSensitiveContentEnabled;
private final boolean mHideCardActions;
private final boolean mUseStarsForLikes;
private boolean mLoadMoreSupported;
private boolean mLoadMoreIndicatorVisible;
private boolean mDetailMediaExpanded;
@ -1173,6 +1183,7 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
mDisplayMediaPreview = mPreferences.getBoolean(KEY_MEDIA_PREVIEW, false);
mSensitiveContentEnabled = mPreferences.getBoolean(KEY_DISPLAY_SENSITIVE_CONTENTS, false);
mHideCardActions = mPreferences.getBoolean(KEY_HIDE_CARD_ACTIONS, false);
mUseStarsForLikes = mPreferences.getBoolean(KEY_I_WANT_MY_STARS_BACK);
if (compact) {
mCardLayoutResource = R.layout.card_item_status_compact;
} else {
@ -1307,6 +1318,11 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
return false;
}
@Override
public boolean shouldUseStarsForLikes() {
return mUseStarsForLikes;
}
@Override
public MediaLoadingHandler getMediaLoadingHandler() {
return mMediaLoadingHandler;
@ -1414,7 +1430,7 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
final CardView cardView = (CardView) view.findViewById(R.id.card);
cardView.setCardBackgroundColor(mCardBackgroundColor);
}
return new DetailStatusViewHolder(this, view);
return new DetailStatusViewHolder(mFragment, this, view);
}
case VIEW_TYPE_LIST_STATUS: {
final View view = mInflater.inflate(mCardLayoutResource, parent, false);

View File

@ -40,7 +40,7 @@ public class StatusRepliesListFragment extends StatusesSearchFragment {
final long maxId = args.getLong(EXTRA_MAX_ID, -1);
final long sinceId = args.getLong(EXTRA_SINCE_ID, -1);
final int tabPosition = args.getInt(EXTRA_TAB_POSITION, -1);
final boolean twitterOptimizedSearches = mPreferences.getBoolean(TWITTER_OPTIMIZED_SEARCHES);
final boolean twitterOptimizedSearches = mPreferences.getBoolean(KEY_TWITTER_OPTIMIZED_SEARCHES);
return new StatusRepliesLoader(getActivity(), accountId, screenName, statusId, maxId,
sinceId, getAdapterData(), getSavedStatusesFileArgs(), tabPosition, fromUser,
twitterOptimizedSearches);

View File

@ -45,7 +45,7 @@ public class StatusesSearchFragment extends ParcelableStatusesFragment {
final String query = args.getString(EXTRA_QUERY);
final int tabPosition = args.getInt(EXTRA_TAB_POSITION, -1);
final boolean makeGap = args.getBoolean(EXTRA_MAKE_GAP, true);
final boolean twitterOptimizedSearches = mPreferences.getBoolean(TWITTER_OPTIMIZED_SEARCHES);
final boolean twitterOptimizedSearches = mPreferences.getBoolean(KEY_TWITTER_OPTIMIZED_SEARCHES);
return new TweetSearchLoader(getActivity(), accountId, query, sinceId, maxId, getAdapterData(),
getSavedStatusesFileArgs(), tabPosition, fromUser, makeGap, twitterOptimizedSearches);
}

View File

@ -426,8 +426,14 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
break;
}
case TAB_TYPE_FAVORITES: {
actionBar.setSubtitle(getResources().getQuantityString(R.plurals.N_favorites,
(int) user.favorites_count, user.favorites_count));
if (mPreferences.getBoolean(KEY_I_WANT_MY_STARS_BACK)) {
actionBar.setSubtitle(getResources().getQuantityString(R.plurals.N_favorites,
(int) user.favorites_count, user.favorites_count));
} else {
actionBar.setSubtitle(getResources().getQuantityString(R.plurals.N_likes,
(int) user.favorites_count, user.favorites_count));
}
break;
}
default: {
@ -1445,11 +1451,19 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
tabArgs.putLong(EXTRA_USER_ID, args.getLong(EXTRA_USER_ID, -1));
tabArgs.putString(EXTRA_SCREEN_NAME, args.getString(EXTRA_SCREEN_NAME));
}
mPagerAdapter.addTab(UserTimelineFragment.class, tabArgs, getString(R.string.statuses), R.drawable.ic_action_quote, TAB_TYPE_STATUSES, TAB_POSITION_STATUSES, null);
mPagerAdapter.addTab(UserTimelineFragment.class, tabArgs, getString(R.string.statuses),
R.drawable.ic_action_quote, TAB_TYPE_STATUSES, TAB_POSITION_STATUSES, null);
if (Utils.isOfficialKeyAccount(context, accountId)) {
mPagerAdapter.addTab(UserMediaTimelineFragment.class, tabArgs, getString(R.string.media), R.drawable.ic_action_gallery, TAB_TYPE_MEDIA, TAB_POSITION_MEDIA, null);
mPagerAdapter.addTab(UserMediaTimelineFragment.class, tabArgs, getString(R.string.media),
R.drawable.ic_action_gallery, TAB_TYPE_MEDIA, TAB_POSITION_MEDIA, null);
}
if (mPreferences.getBoolean(KEY_I_WANT_MY_STARS_BACK)) {
mPagerAdapter.addTab(UserFavoritesFragment.class, tabArgs, getString(R.string.favorites),
R.drawable.ic_action_star, TAB_TYPE_FAVORITES, TAB_POSITION_FAVORITES, null);
} else {
mPagerAdapter.addTab(UserFavoritesFragment.class, tabArgs, getString(R.string.likes),
R.drawable.ic_action_heart, TAB_TYPE_FAVORITES, TAB_POSITION_FAVORITES, null);
}
mPagerAdapter.addTab(UserFavoritesFragment.class, tabArgs, getString(R.string.likes), R.drawable.ic_action_heart, TAB_TYPE_FAVORITES, TAB_POSITION_FAVORITES, null);
}
private void updateFollowProgressState() {

View File

@ -41,7 +41,7 @@ public class UserMentionsFragment extends StatusesSearchFragment {
final long sinceId = args.getLong(EXTRA_SINCE_ID, -1);
final int tabPosition = args.getInt(EXTRA_TAB_POSITION, -1);
final boolean makeGap = args.getBoolean(EXTRA_MAKE_GAP, true);
final boolean twitterOptimizedSearches = mPreferences.getBoolean(TWITTER_OPTIMIZED_SEARCHES);
final boolean twitterOptimizedSearches = mPreferences.getBoolean(KEY_TWITTER_OPTIMIZED_SEARCHES);
return new UserMentionsLoader(getActivity(), accountId, screenName, maxId, sinceId,
getAdapterData(), getSavedStatusesFileArgs(), tabPosition, fromUser, makeGap,
twitterOptimizedSearches);

View File

@ -15,10 +15,12 @@ import java.util.Set;
public class SharedPreferencesWrapper implements Constants, SharedPreferences {
private final Context mContext;
private final SharedPreferences mPreferences;
private final HashMap<String, Preference> mMap;
private SharedPreferencesWrapper(final SharedPreferences preferences, final Class<?> keysClass) {
private SharedPreferencesWrapper(final Context context, SharedPreferences preferences, final Class<?> keysClass) {
mContext = context;
mPreferences = preferences;
mMap = new HashMap<>();
if (keysClass != null) {
@ -60,9 +62,15 @@ public class SharedPreferencesWrapper implements Constants, SharedPreferences {
}
public boolean getBoolean(final String key) {
final Preference preference = mMap.get(key);
if (preference == null || !preference.hasDefault()) return getBoolean(key, false);
return getBoolean(key, preference.defaultBoolean());
return getBoolean(key, getDefaultBoolean(key));
}
private boolean getDefaultBoolean(String key) {
final Preference annotation = mMap.get(key);
if (annotation == null || !annotation.hasDefault()) return false;
final int resId = annotation.defaultResource();
if (resId != 0) return mContext.getResources().getBoolean(resId);
return annotation.defaultBoolean();
}
@Override
@ -140,9 +148,10 @@ public class SharedPreferencesWrapper implements Constants, SharedPreferences {
public static SharedPreferencesWrapper getInstance(final Context context, final String name, final int mode,
final Class<?> keysClass) {
final SharedPreferences prefs = context.getSharedPreferences(name, mode);
final Context app = context.getApplicationContext();
final SharedPreferences prefs = app.getSharedPreferences(name, mode);
if (prefs == null) return null;
return new SharedPreferencesWrapper(prefs, keysClass);
return new SharedPreferencesWrapper(app, prefs, keysClass);
}
}

View File

@ -3323,17 +3323,19 @@ public final class Utils implements Constants {
scrollListToPosition(list, 0);
}
public static void setMenuForStatus(final Context context, final Menu menu, final ParcelableStatus status) {
public static void setMenuForStatus(final Context context, final SharedPreferencesWrapper preferences,
final Menu menu, final ParcelableStatus status) {
if (status == null) return;
final ParcelableCredentials account = ParcelableAccount.getCredentials(context, status.account_id);
setMenuForStatus(context, menu, status, account);
setMenuForStatus(context, preferences, menu, status, account);
}
public static void setMenuForStatus(final Context context, final Menu menu, final ParcelableStatus status,
final ParcelableCredentials account) {
public static void setMenuForStatus(final Context context, final SharedPreferencesWrapper preferences,
final Menu menu, final ParcelableStatus status, final ParcelableCredentials account) {
if (context == null || menu == null || status == null || account == null) return;
final Resources resources = context.getResources();
final int retweetHighlight = ContextCompat.getColor(context, R.color.highlight_retweet);
final int favoriteHighlight = ContextCompat.getColor(context, R.color.highlight_favorite);
final int likeHighlight = ContextCompat.getColor(context, R.color.highlight_like);
final boolean isMyRetweet = isMyRetweet(status);
final MenuItem delete = menu.findItem(R.id.delete);
@ -3347,8 +3349,13 @@ public final class Utils implements Constants {
}
final MenuItem favorite = menu.findItem(R.id.favorite);
if (favorite != null) {
ActionIconDrawable.setMenuHighlight(favorite, new TwidereMenuInfo(status.is_favorite, likeHighlight));
favorite.setTitle(status.is_favorite ? R.string.undo_like : R.string.like);
if (preferences.getBoolean(KEY_I_WANT_MY_STARS_BACK)) {
ActionIconDrawable.setMenuHighlight(favorite, new TwidereMenuInfo(status.is_favorite, favoriteHighlight));
favorite.setTitle(status.is_favorite ? R.string.unfavorite : R.string.favorite);
} else {
ActionIconDrawable.setMenuHighlight(favorite, new TwidereMenuInfo(status.is_favorite, likeHighlight));
favorite.setTitle(status.is_favorite ? R.string.undo_like : R.string.like);
}
}
final MenuItem translate = menu.findItem(R.id.translate);
if (translate != null) {

View File

@ -24,6 +24,7 @@ import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.graphics.PorterDuff.Mode;
import android.graphics.drawable.Drawable;
import android.support.annotation.ColorInt;
import android.support.v7.widget.AppCompatTextView;
import android.util.AttributeSet;
@ -36,7 +37,12 @@ import org.mariotaku.twidere.util.support.TextViewSupport;
public class ActionIconThemedTextView extends AppCompatTextView {
private final int mIconWidth, mIconHeight;
private int mColor, mDisabledColor, mActivatedColor;
@ColorInt
private int mColor;
@ColorInt
private int mDisabledColor;
@ColorInt
private int mActivatedColor;
public ActionIconThemedTextView(Context context) {
this(context, null);
@ -58,6 +64,7 @@ public class ActionIconThemedTextView extends AppCompatTextView {
updateCompoundDrawables();
}
@ColorInt
public int getActivatedColor() {
if (mActivatedColor != 0) return mActivatedColor;
final ColorStateList colors = getLinkTextColors();
@ -65,6 +72,10 @@ public class ActionIconThemedTextView extends AppCompatTextView {
return getCurrentTextColor();
}
public void setActivatedColor(@ColorInt int color) {
this.mActivatedColor = color;
}
@Override
public void setCompoundDrawablesWithIntrinsicBounds(Drawable left, Drawable top, Drawable right, Drawable bottom) {
super.setCompoundDrawablesWithIntrinsicBounds(left, top, right, bottom);
@ -89,6 +100,7 @@ public class ActionIconThemedTextView extends AppCompatTextView {
updateCompoundDrawables();
}
@ColorInt
public int getColor() {
if (mColor != 0) return mColor;
final ColorStateList colors = getTextColors();
@ -96,6 +108,11 @@ public class ActionIconThemedTextView extends AppCompatTextView {
return getCurrentTextColor();
}
public void setColor(@ColorInt int color) {
this.mColor = color;
}
@ColorInt
public int getDisabledColor() {
if (mDisabledColor != 0) return mDisabledColor;
final ColorStateList colors = getTextColors();
@ -103,6 +120,10 @@ public class ActionIconThemedTextView extends AppCompatTextView {
return getCurrentTextColor();
}
public void setDisabledColor(@ColorInt int color) {
this.mDisabledColor = color;
}
@Override
public void setActivated(boolean activated) {
super.setActivated(activated);

View File

@ -3,6 +3,8 @@ package org.mariotaku.twidere.view.holder;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.support.v4.widget.TextViewCompat;
import android.support.v7.widget.RecyclerView.ViewHolder;
import android.text.Html;
import android.text.Spanned;
@ -18,7 +20,6 @@ import org.mariotaku.twidere.Constants;
import org.mariotaku.twidere.R;
import org.mariotaku.twidere.adapter.iface.IStatusesAdapter;
import org.mariotaku.twidere.api.twitter.model.TranslationResult;
import org.mariotaku.twidere.app.TwidereApplication;
import org.mariotaku.twidere.model.ParcelableLocation;
import org.mariotaku.twidere.model.ParcelableMedia;
import org.mariotaku.twidere.model.ParcelableStatus;
@ -32,6 +33,7 @@ import org.mariotaku.twidere.util.UserColorNameManager;
import org.mariotaku.twidere.util.Utils;
import org.mariotaku.twidere.util.dagger.ApplicationModule;
import org.mariotaku.twidere.util.dagger.DaggerGeneralComponent;
import org.mariotaku.twidere.view.ActionIconThemedTextView;
import org.mariotaku.twidere.view.CardMediaContainer;
import org.mariotaku.twidere.view.ForegroundColorView;
import org.mariotaku.twidere.view.NameView;
@ -68,7 +70,7 @@ public class StatusViewHolder extends ViewHolder implements Constants, OnClickLi
private final TextView replyRetweetView;
private final ShortTimeView timeView;
private final CardMediaContainer mediaPreview;
private final TextView replyCountView, retweetCountView, favoriteCountView;
private final ActionIconThemedTextView replyCountView, retweetCountView, favoriteCountView;
private final IColorLabelView itemContent;
private final ForegroundColorView quoteIndicator;
private final View actionButtons;
@ -98,9 +100,9 @@ public class StatusViewHolder extends ViewHolder implements Constants, OnClickLi
itemMenu = itemView.findViewById(R.id.item_menu);
actionButtons = itemView.findViewById(R.id.action_buttons);
replyCountView = (TextView) itemView.findViewById(R.id.reply_count);
retweetCountView = (TextView) itemView.findViewById(R.id.retweet_count);
favoriteCountView = (TextView) itemView.findViewById(R.id.favorite_count);
replyCountView = (ActionIconThemedTextView) itemView.findViewById(R.id.reply_count);
retweetCountView = (ActionIconThemedTextView) itemView.findViewById(R.id.retweet_count);
favoriteCountView = (ActionIconThemedTextView) itemView.findViewById(R.id.favorite_count);
//TODO
// profileImageView.setSelectorColor(ThemeUtils.getUserHighlightColor(itemView.getContext()));
@ -407,6 +409,13 @@ public class StatusViewHolder extends ViewHolder implements Constants, OnClickLi
final boolean nameFirst = adapter.isNameFirst();
nameView.setNameFirst(nameFirst);
quotedNameView.setNameFirst(nameFirst);
if (adapter.shouldUseStarsForLikes()) {
favoriteCountView.setActivatedColor(ContextCompat.getColor(adapter.getContext(),
R.color.highlight_favorite));
TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(favoriteCountView,
R.drawable.ic_action_star, 0, 0, 0);
}
}
private void displayExtraTypeIcon(String cardName, ParcelableMedia[] media, ParcelableLocation location, String placeFullName, boolean sensitive) {
@ -466,12 +475,12 @@ public class StatusViewHolder extends ViewHolder implements Constants, OnClickLi
private boolean hideCardActions;
private boolean displayMediaPreview;
private boolean shouldShowAccountsColor;
private boolean useStarsForLikes;
public DummyStatusHolderAdapter(Context context) {
DaggerGeneralComponent.builder().applicationModule(ApplicationModule.get(context)).build().inject(this);
this.context = context;
preferences = SharedPreferencesWrapper.getInstance(context, SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
final TwidereApplication app = TwidereApplication.getInstance(context);
handler = new MediaLoadingHandler(R.id.media_preview_progress);
linkify = new TwidereLinkify(null);
updateOptions();
@ -604,6 +613,15 @@ public class StatusViewHolder extends ViewHolder implements Constants, OnClickLi
}
@Override
public boolean shouldUseStarsForLikes() {
return useStarsForLikes;
}
public void setUseStarsForLikes(boolean useStarsForLikes) {
this.useStarsForLikes = useStarsForLikes;
}
@Override
public boolean shouldShowAccountsColor() {
return shouldShowAccountsColor;

View File

@ -435,6 +435,7 @@
android:layout_height="wrap_content"
android:singleLine="true"
android:text="@string/likes"
android:id="@+id/favorites_label"
android:textAppearance="?android:textAppearanceSmall"
android:textColor="?android:textColorSecondary" />
</LinearLayout>

View File

@ -809,4 +809,6 @@
<string name="current_status">Current tweet</string>
<string name="twitter_optimized_searches">Twitter optimized searches</string>
<string name="twitter_optimized_searches_summary">Use special search terms to improve search results like exclude retweets</string>
<string name="i_want_my_stars_back">I want my stars back!</string>
<string name="i_want_my_stars_back_summary">Show use favorite (star) instead of like (heart)</string>
</resources>

View File

@ -21,5 +21,14 @@
android:name="resid"
android:value="@xml/preferences_scrapyard" />
</Preference>
<org.mariotaku.twidere.preference.AutoFixCheckBoxPreference
android:defaultValue="false"
android:key="i_want_my_stars_back"
android:summary="@string/i_want_my_stars_back_summary"
android:title="@string/i_want_my_stars_back">
<extra
android:name="notify_change"
android:value="true" />
</org.mariotaku.twidere.preference.AutoFixCheckBoxPreference>
</PreferenceScreen>