diff --git a/twidere.component.common/src/main/java/org/mariotaku/twidere/model/ParcelableStatus.java b/twidere.component.common/src/main/java/org/mariotaku/twidere/model/ParcelableStatus.java index a56ba79ae..7d27e5f1f 100644 --- a/twidere.component.common/src/main/java/org/mariotaku/twidere/model/ParcelableStatus.java +++ b/twidere.component.common/src/main/java/org/mariotaku/twidere/model/ParcelableStatus.java @@ -98,8 +98,8 @@ public class ParcelableStatus implements Parcelable, Comparable mentions = new TreeSet<>(String.CASE_INSENSITIVE_ORDER); mentions.addAll(mExtractor.extractMentionedScreennames(status.text_plain)); for (final String mention : mentions) { if (mention.equalsIgnoreCase(status.user_screen_name) || mention.equalsIgnoreCase(myScreenName) - || mention.equalsIgnoreCase(status.retweeted_by_screen_name)) { + || mention.equalsIgnoreCase(status.retweeted_by_user_screen_name)) { continue; } mEditText.append("@" + mention + " "); 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 e444524ec..2bff5fd3c 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 @@ -131,16 +131,6 @@ import edu.tsinghua.spice.Utilies.SpiceProfilingUtil; import edu.tsinghua.spice.Utilies.TypeMappingUtil; import twitter4j.TwitterException; -import static android.text.TextUtils.isEmpty; -import static org.mariotaku.twidere.util.Utils.findStatus; -import static org.mariotaku.twidere.util.Utils.formatToLongTimeString; -import static org.mariotaku.twidere.util.Utils.getLocalizedNumber; -import static org.mariotaku.twidere.util.Utils.getUserTypeIconRes; -import static org.mariotaku.twidere.util.Utils.openStatus; -import static org.mariotaku.twidere.util.Utils.openUserProfile; -import static org.mariotaku.twidere.util.Utils.setMenuForStatus; -import static org.mariotaku.twidere.util.Utils.showErrorMessage; - /** * Created by mariotaku on 14/12/5. */ @@ -236,7 +226,7 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac if (resultCode == Activity.RESULT_OK) { if (data == null || !data.hasExtra(EXTRA_ID)) return; final long accountId = data.getLongExtra(EXTRA_ID, -1); - openStatus(activity, accountId, status.id); + Utils.openStatus(activity, accountId, status.id); } break; } @@ -357,7 +347,7 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac @Override public void onStatusClick(StatusViewHolder holder, int position) { - openStatus(getActivity(), mStatusAdapter.getStatus(position), null); + Utils.openStatus(getActivity(), mStatusAdapter.getStatus(position), null); } @Override @@ -376,7 +366,7 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac popupMenu.setOnMenuItemClickListener(mOnStatusMenuItemClickListener); popupMenu.inflate(R.menu.action_status); final ParcelableStatus status = mStatusAdapter.getStatus(position); - setMenuForStatus(mStatusAdapter.getContext(), popupMenu.getMenu(), status); + Utils.setMenuForStatus(mStatusAdapter.getContext(), popupMenu.getMenu(), status); popupMenu.show(); mPopupMenu = popupMenu; mSelectedStatus = status; @@ -496,7 +486,7 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac final Bundle args = new Bundle(); args.putLong(EXTRA_ACCOUNT_ID, status.account_id); args.putLong(EXTRA_STATUS_ID, status.retweet_id > 0 ? status.retweet_id : status.id); - args.putString(EXTRA_SCREEN_NAME, status.retweet_id > 0 ? status.retweeted_by_screen_name : status.user_screen_name); + args.putString(EXTRA_SCREEN_NAME, status.retweet_id > 0 ? status.retweeted_by_user_screen_name : status.user_screen_name); if (mRepliesLoaderInitialized) { getLoaderManager().restartLoader(LOADER_ID_STATUS_REPLIES, args, mRepliesLoaderCallback); return; @@ -697,8 +687,8 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac linkClickHandler.setStatus(status); if (status.retweet_id > 0) { - final String retweetedBy = manager.getDisplayName(status.retweeted_by_id, - status.retweeted_by_name, status.retweeted_by_screen_name, nameFirst, false); + final String retweetedBy = manager.getDisplayName(status.retweeted_by_user_id, + status.retweeted_by_user_name, status.retweeted_by_user_screen_name, nameFirst, false); retweetedByView.setText(context.getString(R.string.name_retweeted, retweetedBy)); retweetedByContainer.setVisibility(View.VISIBLE); } else { @@ -711,6 +701,8 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac final int typeIconRes, typeDescriptionRes; final long timestamp; final String source; + final int layoutPosition = getLayoutPosition(); + final int linkHighlightingStyle = adapter.getLinkHighlightingStyle(); if (status.is_quote) { quotedNameView.setText(manager.getUserNickname(status.user_id, status.user_name, false)); quotedScreenNameView.setText("@" + status.user_screen_name); @@ -721,8 +713,8 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac final int idx = status.quote_text_unescaped.lastIndexOf(" twitter.com"); final Spanned quote_text = Html.fromHtml(status.quote_text_html); quoteTextView.setText(idx > 0 ? quote_text.subSequence(0, idx) : quote_text); - linkify.applyAllLinks(quoteTextView, status.account_id, getLayoutPosition(), - status.is_possibly_sensitive, adapter.getLinkHighlightingStyle()); + linkify.applyAllLinks(quoteTextView, status.account_id, layoutPosition, status.is_possibly_sensitive); + ThemeUtils.applyParagraphSpacing(quoteTextView, 1.1f); loader.displayProfileImage(profileImageView, status.quoted_by_user_profile_image); @@ -733,8 +725,9 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac quoteIndicator.setColor(manager.getUserColor(status.user_id, false)); profileContainer.drawStart(manager.getUserColor(status.quoted_by_user_id, false)); - typeIconRes = getUserTypeIconRes(status.quoted_by_user_is_verified, status.quoted_by_user_is_protected); - typeDescriptionRes = Utils.getUserTypeDescriptionRes(status.quoted_by_user_is_verified, status.quoted_by_user_is_protected); + typeIconRes = Utils.getUserTypeIconRes(status.quoted_by_user_is_verified, status.quoted_by_user_is_protected); + typeDescriptionRes = Utils.getUserTypeDescriptionRes(status.quoted_by_user_is_verified, + status.quoted_by_user_is_protected); timestamp = status.quote_timestamp; source = status.quote_source; @@ -751,7 +744,7 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac profileContainer.drawStart(manager.getUserColor(status.user_id, false)); - typeIconRes = getUserTypeIconRes(status.user_is_verified, status.user_is_protected); + typeIconRes = Utils.getUserTypeIconRes(status.user_is_verified, status.user_is_protected); typeDescriptionRes = Utils.getUserTypeDescriptionRes(status.user_is_verified, status.user_is_protected); timestamp = status.timestamp; @@ -768,19 +761,19 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac profileTypeView.setVisibility(View.GONE); } - final String timeString = formatToLongTimeString(context, timestamp); - if (!isEmpty(timeString) && !isEmpty(source)) { + final String timeString = Utils.formatToLongTimeString(context, timestamp); + if (!TextUtils.isEmpty(timeString) && !TextUtils.isEmpty(source)) { timeSourceView.setText(Html.fromHtml(context.getString(R.string.time_source, timeString, source))); - } else if (isEmpty(timeString) && !isEmpty(source)) { + } else if (TextUtils.isEmpty(timeString) && !TextUtils.isEmpty(source)) { timeSourceView.setText(Html.fromHtml(context.getString(R.string.source, source))); - } else if (!isEmpty(timeString) && isEmpty(source)) { + } else if (!TextUtils.isEmpty(timeString) && TextUtils.isEmpty(source)) { timeSourceView.setText(timeString); } timeSourceView.setMovementMethod(null); textView.setText(Html.fromHtml(status.text_html)); - linkify.applyAllLinks(textView, status.account_id, getLayoutPosition(), status.is_possibly_sensitive); + linkify.applyAllLinks(textView, status.account_id, layoutPosition, status.is_possibly_sensitive); ThemeUtils.applyParagraphSpacing(textView, 1.1f); if (!TextUtils.isEmpty(status.place_full_name)) { @@ -800,9 +793,9 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac repliesContainer.setVisibility(status.reply_count < 0 ? View.GONE : View.VISIBLE); favoritesContainer.setVisibility(status.favorite_count < 0 ? View.GONE : View.VISIBLE); final Locale locale = context.getResources().getConfiguration().locale; - repliesCountView.setText(getLocalizedNumber(locale, status.reply_count)); - retweetsCountView.setText(getLocalizedNumber(locale, status.retweet_count)); - favoritesCountView.setText(getLocalizedNumber(locale, status.favorite_count)); + repliesCountView.setText(Utils.getLocalizedNumber(locale, status.reply_count)); + retweetsCountView.setText(Utils.getLocalizedNumber(locale, status.retweet_count)); + favoritesCountView.setText(Utils.getLocalizedNumber(locale, status.favorite_count)); if (status.media == null) { @@ -872,8 +865,13 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac final Bundle activityOption = Utils.makeSceneTransitionOption(activity, new Pair(profileImageView, UserFragment.TRANSITION_NAME_PROFILE_IMAGE), new Pair(profileTypeView, UserFragment.TRANSITION_NAME_PROFILE_TYPE)); - openUserProfile(activity, status.account_id, status.user_id, status.user_screen_name, - activityOption); + if (status.is_quote) { + Utils.openUserProfile(adapter.getContext(), status.account_id, status.quoted_by_user_id, + status.quoted_by_user_screen_name, activityOption); + } else { + Utils.openUserProfile(activity, status.account_id, status.user_id, status.user_screen_name, + activityOption); + } break; } case R.id.retweets_container: { @@ -883,8 +881,8 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac } case R.id.retweeted_by_container: { if (status.retweet_id > 0) { - Utils.openUserProfile(adapter.getContext(), status.account_id, status.retweeted_by_id, - status.retweeted_by_screen_name, null); + Utils.openUserProfile(adapter.getContext(), status.account_id, status.retweeted_by_user_id, + status.retweeted_by_user_screen_name, null); } break; } @@ -894,6 +892,11 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac Utils.openMap(adapter.getContext(), location.latitude, location.longitude); break; } + case R.id.quoted_name_container: { + Utils.openUserProfile(adapter.getContext(), status.account_id, status.user_id, + status.user_screen_name, null); + break; + } } } @@ -924,6 +927,7 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac ThemeUtils.wrapMenuIcon(menuBar, MENU_GROUP_STATUS_SHARE); mediaPreviewLoad.setOnClickListener(this); profileContainer.setOnClickListener(this); + quotedNameContainer.setOnClickListener(this); retweetsContainer.setOnClickListener(this); favoritesContainer.setOnClickListener(this); retweetedByContainer.setOnClickListener(this); @@ -1014,7 +1018,7 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac ParcelableStatus status = params[0]; final long account_id = status.account_id; while (status.in_reply_to_status_id > 0 && !isCancelled()) { - status = findStatus(context, account_id, status.in_reply_to_status_id); + status = Utils.findStatus(context, account_id, status.in_reply_to_status_id); publishProgress(status); list.add(0, status); } @@ -1029,7 +1033,7 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac if (data.hasData()) { fragment.setConversation(data.getData()); } else { - showErrorMessage(context, context.getString(R.string.action_getting_status), data.getException(), true); + Utils.showErrorMessage(context, context.getString(R.string.action_getting_status), data.getException(), true); } } 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 7aa5d2c20..52e81ecab 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/util/Utils.java +++ b/twidere/src/main/java/org/mariotaku/twidere/util/Utils.java @@ -1700,9 +1700,13 @@ public final class Utils implements Constants, TwitterConstants { public static long getDefaultAccountId(final Context context) { if (context == null) return -1; final SharedPreferences prefs = context.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE); - long account_id = prefs.getLong(KEY_DEFAULT_ACCOUNT_ID, -1); - if (account_id == -1) account_id = Utils.getAccountIds(context)[0]; /* TODO: this is just a quick fix */ - return account_id; + final long accountId = prefs.getLong(KEY_DEFAULT_ACCOUNT_ID, -1); + final long[] accountIds; + if (accountId == -1 && (accountIds = Utils.getAccountIds(context)).length > 0) { + /* TODO: this is just a quick fix */ + return accountIds[0]; + } + return accountId; } public static String getDefaultAccountScreenName(final Context context) { @@ -2763,7 +2767,7 @@ public final class Utils implements Constants, TwitterConstants { final boolean filter_rts) { if (database == null || status == null) return false; return isFiltered(database, status.user_id, status.text_plain, status.text_html, status.source, - status.retweeted_by_id, filter_rts); + status.retweeted_by_user_id, filter_rts); } public static boolean isMyAccount(final Context context, final long account_id) { @@ -2796,7 +2800,7 @@ public final class Utils implements Constants, TwitterConstants { } public static boolean isMyRetweet(final ParcelableStatus status) { - return status != null && isMyRetweet(status.account_id, status.retweeted_by_id, status.my_retweet_id); + return status != null && isMyRetweet(status.account_id, status.retweeted_by_user_id, status.my_retweet_id); } public static boolean isMyRetweet(final long account_id, final long retweeted_by_id, final long my_retweet_id) { diff --git a/twidere/src/main/java/org/mariotaku/twidere/view/holder/StatusViewHolder.java b/twidere/src/main/java/org/mariotaku/twidere/view/holder/StatusViewHolder.java index 2d2e74159..df05bbfcf 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/view/holder/StatusViewHolder.java +++ b/twidere/src/main/java/org/mariotaku/twidere/view/holder/StatusViewHolder.java @@ -149,8 +149,8 @@ public class StatusViewHolder extends ViewHolder implements Constants, OnClickLi final long favorite_count; if (status.retweet_id > 0) { - final String retweetedBy = manager.getDisplayName(status.retweeted_by_id, - status.retweeted_by_name, status.retweeted_by_screen_name, nameFirst, false); + final String retweetedBy = manager.getDisplayName(status.retweeted_by_user_id, + status.retweeted_by_user_name, status.retweeted_by_user_screen_name, nameFirst, false); replyRetweetView.setText(context.getString(R.string.name_retweeted, retweetedBy)); replyRetweetIcon.setImageResource(R.drawable.ic_activity_action_retweet); replyRetweetView.setVisibility(View.VISIBLE); @@ -292,7 +292,7 @@ public class StatusViewHolder extends ViewHolder implements Constants, OnClickLi } else { final boolean creatingRetweet = twitter.isCreatingRetweet(status.account_id, status.id); retweetCountView.setActivated(creatingRetweet || Utils.isMyRetweet(status.account_id, - status.retweeted_by_id, status.my_retweet_id)); + status.retweeted_by_user_id, status.my_retweet_id)); retweet_count = status.retweet_count + (creatingRetweet ? 1 : 0); } if (retweet_count > 0) { diff --git a/twidere/src/main/java/org/mariotaku/twidere/view/themed/TintThemedProgressWheel.java b/twidere/src/main/java/org/mariotaku/twidere/view/themed/TintThemedProgressWheel.java new file mode 100644 index 000000000..9189597bb --- /dev/null +++ b/twidere/src/main/java/org/mariotaku/twidere/view/themed/TintThemedProgressWheel.java @@ -0,0 +1,51 @@ +/* + * Twidere - Twitter client for Android + * + * Copyright (C) 2012-2015 Mariotaku Lee + * + * 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 . + */ + +package org.mariotaku.twidere.view.themed; + +import android.content.Context; +import android.content.res.ColorStateList; +import android.graphics.Color; +import android.util.AttributeSet; + +import com.pnikosis.materialishprogress.ProgressWheel; + +import org.mariotaku.twidere.view.iface.IThemedView; + +/** + * Created by mariotaku on 15/4/25. + */ +public class TintThemedProgressWheel extends ProgressWheel implements IThemedView { + public TintThemedProgressWheel(Context context, AttributeSet attrs) { + super(context, attrs); + } + + public TintThemedProgressWheel(Context context) { + super(context); + } + + @Override + public void setThemeTintColor(ColorStateList color) { + if (color != null) { + setBarColor(color.getDefaultColor()); + } else { + setBarColor(Color.TRANSPARENT); + } + } +} diff --git a/twidere/src/main/res/layout/fragment_media_page_image.xml b/twidere/src/main/res/layout/fragment_media_page_image.xml index 327ba9a23..604f0d3c9 100644 --- a/twidere/src/main/res/layout/fragment_media_page_image.xml +++ b/twidere/src/main/res/layout/fragment_media_page_image.xml @@ -35,7 +35,7 @@ android:layout_width="match_parent" android:layout_height="match_parent"/> - - - . -->