From aebf1cf2a683fc71125f01e257064b557f375f88 Mon Sep 17 00:00:00 2001 From: Mariotaku Lee Date: Tue, 9 Feb 2016 12:18:36 +0800 Subject: [PATCH] improved translation text color --- .../fragment/support/StatusFragment.java | 76 ++++++++++++------- .../org/mariotaku/twidere/util/Utils.java | 18 ++--- .../main/res/layout/header_status_common.xml | 1 + 3 files changed, 58 insertions(+), 37 deletions(-) diff --git a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/StatusFragment.java b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/StatusFragment.java index 96687b1f2..7bb97588e 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/StatusFragment.java +++ b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/StatusFragment.java @@ -873,7 +873,6 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac if (result.hasData()) { fragment.displayTranslation(result.getData()); } else if (result.hasException()) { - //TODO show translation error Utils.showErrorMessage(context, R.string.translate, result.getException(), false); } } @@ -1068,7 +1067,7 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac final CountsUsersAdapter interactUsersAdapter = (CountsUsersAdapter) countsUsersView.getAdapter(); if (statusActivity != null) { - interactUsersAdapter.setUsers(statusActivity.retweeters); + interactUsersAdapter.setUsers(statusActivity.getRetweeters()); interactUsersAdapter.setCounts(statusActivity); } else { interactUsersAdapter.setUsers(null); @@ -1124,7 +1123,6 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac twitterCard.setVisibility(View.GONE); } - Utils.setMenuForStatus(context, fragment.mPreferences, menuBar.getMenu(), status, adapter.getStatusAccount(), twitter); @@ -1176,25 +1174,6 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac activityOption); break; } -// case R.id.retweets_container: { -// final FragmentActivity activity = fragment.getActivity(); -// if (status.is_retweet) { -// Utils.openStatusRetweeters(activity, status.account_id, status.retweet_id); -// } else { -// Utils.openStatusRetweeters(activity, status.account_id, status.id); -// } -// break; -// } -// case R.id.favorites_container: { -// final FragmentActivity activity = fragment.getActivity(); -// if (!Utils.isOfficialCredentials(activity, adapter.getStatusAccount())) return; -// if (status.is_retweet) { -// Utils.openStatusFavoriters(activity, status.account_id, status.retweet_id); -// } else { -// Utils.openStatusFavoriters(activity, status.account_id, status.id); -// } -// break; -// } case R.id.retweeted_by: { if (status.retweet_id > 0) { Utils.openUserProfile(adapter.getContext(), status.account_id, status.retweeted_by_user_id, @@ -1431,7 +1410,38 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac } private void notifyItemClick(int position) { - mFragment.onUserClick(getUser(position)); + switch (getItemViewType(position)) { + case ITEM_VIEW_TYPE_COUNT: { + final LabeledCount count = getCount(position); + final ParcelableStatus status = mStatusAdapter.getStatus(); + if (count == null || status == null) return; + switch (count.type) { + case KEY_RETWEET_COUNT: { + if (status.is_retweet) { + Utils.openStatusRetweeters(getContext(), status.account_id, status.retweet_id); + } else { + Utils.openStatusRetweeters(getContext(), status.account_id, status.id); + } + break; + } + case KEY_FAVORITE_COUNT: { + final ParcelableCredentials account = mStatusAdapter.getStatusAccount(); + if (!Utils.isOfficialCredentials(getContext(), account)) return; + if (status.is_retweet) { + Utils.openStatusFavoriters(getContext(), status.account_id, status.retweet_id); + } else { + Utils.openStatusFavoriters(getContext(), status.account_id, status.id); + } + break; + } + } + break; + } + case ITEM_VIEW_TYPE_USER: { + mFragment.onUserClick(getUser(position)); + break; + } + } } private ParcelableUser getUser(int position) { @@ -1448,9 +1458,9 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac public ProfileImageViewHolder(CountsUsersAdapter adapter, View itemView) { super(itemView); - profileImageView = (ImageView) itemView.findViewById(R.id.profile_image); itemView.setOnClickListener(this); this.adapter = adapter; + profileImageView = (ImageView) itemView.findViewById(R.id.profile_image); } public void displayUser(ParcelableUser item) { @@ -1470,10 +1480,11 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac public CountViewHolder(CountsUsersAdapter adapter, View itemView) { super(itemView); - countView = (TextView) itemView.findViewById(R.id.count); - labelView = (TextView) itemView.findViewById(R.id.label); + itemView.setOnClickListener(this); this.adapter = adapter; final float textSize = adapter.getTextSize(); + countView = (TextView) itemView.findViewById(R.id.count); + labelView = (TextView) itemView.findViewById(R.id.label); countView.setTextSize(textSize * 1.25f); labelView.setTextSize(textSize * 0.85f); } @@ -1547,7 +1558,6 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac private void expandOrOpenMedia(ParcelableMedia current) { if (adapter.isDetailMediaExpanded()) { - //TODO open first media Utils.openMedia(adapter.getContext(), adapter.getStatus(), current, null); return; } @@ -1951,7 +1961,7 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac } case VIEW_TYPE_CONVERSATION_ERROR: { final StatusErrorItemViewHolder errorHolder = (StatusErrorItemViewHolder) holder; - errorHolder.showError(mReplyError); + errorHolder.showError(mConversationError); break; } case VIEW_TYPE_CONVERSATION_LOAD_INDICATOR: { @@ -2459,6 +2469,16 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac this.retweetCount = retweetCount; } + @Override + public String toString() { + return "StatusActivity{" + + "retweeters=" + retweeters + + ", statusId=" + statusId + + ", favoriteCount=" + favoriteCount + + ", replyCount=" + replyCount + + ", retweetCount=" + retweetCount + + '}'; + } } static class ReadPosition { diff --git a/twidere/src/main/java/org/mariotaku/twidere/util/Utils.java b/twidere/src/main/java/org/mariotaku/twidere/util/Utils.java index b3c4602b5..b45c02b8c 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/util/Utils.java +++ b/twidere/src/main/java/org/mariotaku/twidere/util/Utils.java @@ -1976,8 +1976,8 @@ public final class Utils implements Constants { } } - public static void openStatuses(final Activity activity, final List statuses) { - if (activity == null || statuses == null) return; + public static void openStatuses(final Context context, final List statuses) { + if (context == null || statuses == null) return; final Bundle extras = new Bundle(); extras.putParcelableArrayList(EXTRA_STATUSES, new ArrayList<>(statuses)); final Uri.Builder builder = new Uri.Builder(); @@ -1985,23 +1985,23 @@ public final class Utils implements Constants { builder.authority(AUTHORITY_STATUSES); final Intent intent = new Intent(Intent.ACTION_VIEW, builder.build()); intent.putExtras(extras); - activity.startActivity(intent); + context.startActivity(intent); } - public static void openStatusFavoriters(final Activity activity, final long accountId, final long statusId) { - if (activity == null) return; + public static void openStatusFavoriters(final Context context, final long accountId, final long statusId) { + if (context == null) return; final Uri.Builder builder = new Uri.Builder(); builder.scheme(SCHEME_TWIDERE); builder.authority(AUTHORITY_STATUS_FAVORITERS); builder.appendQueryParameter(QUERY_PARAM_ACCOUNT_ID, String.valueOf(accountId)); builder.appendQueryParameter(QUERY_PARAM_STATUS_ID, String.valueOf(statusId)); final Intent intent = new Intent(Intent.ACTION_VIEW, builder.build()); - activity.startActivity(intent); + context.startActivity(intent); } - public static void openStatusReplies(final Activity activity, final long accountId, final long statusId, + public static void openStatusReplies(final Context context, final long accountId, final long statusId, final String screenName) { - if (activity == null) return; + if (context == null) return; final Uri.Builder builder = new Uri.Builder(); builder.scheme(SCHEME_TWIDERE); builder.authority(AUTHORITY_STATUS_REPLIES); @@ -2009,7 +2009,7 @@ public final class Utils implements Constants { builder.appendQueryParameter(QUERY_PARAM_STATUS_ID, String.valueOf(statusId)); builder.appendQueryParameter(QUERY_PARAM_SCREEN_NAME, screenName); final Intent intent = new Intent(Intent.ACTION_VIEW, builder.build()); - activity.startActivity(intent); + context.startActivity(intent); } public static void openStatusRetweeters(final Context context, final long accountId, final long statusId) { diff --git a/twidere/src/main/res/layout/header_status_common.xml b/twidere/src/main/res/layout/header_status_common.xml index df4755aab..c412e2ffa 100644 --- a/twidere/src/main/res/layout/header_status_common.xml +++ b/twidere/src/main/res/layout/header_status_common.xml @@ -207,6 +207,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="@dimen/element_spacing_normal" + android:textColor="?android:textColorPrimary" android:visibility="gone" tools:text="@string/sample_status_text"/>