added poll label

This commit is contained in:
Mariotaku Lee 2015-12-27 14:48:14 +08:00
parent c7edd7f647
commit e1f1e5299b
8 changed files with 63 additions and 39 deletions

View File

@ -243,6 +243,7 @@ public class ParcelableStatus implements Parcelable, Comparable<ParcelableStatus
@JsonField(name = "text_unescaped") @JsonField(name = "text_unescaped")
@CursorField(Statuses.TEXT_UNESCAPED) @CursorField(Statuses.TEXT_UNESCAPED)
public String text_unescaped; public String text_unescaped;
@Nullable
@ParcelableThisPlease @ParcelableThisPlease
@JsonField(name = "card_name") @JsonField(name = "card_name")
@CursorField(Statuses.CARD_NAME) @CursorField(Statuses.CARD_NAME)
@ -295,6 +296,7 @@ public class ParcelableStatus implements Parcelable, Comparable<ParcelableStatus
@JsonField(name = "quoted_media") @JsonField(name = "quoted_media")
@CursorField(value = Statuses.QUOTED_MEDIA_JSON, converter = LoganSquareCursorFieldConverter.class) @CursorField(value = Statuses.QUOTED_MEDIA_JSON, converter = LoganSquareCursorFieldConverter.class)
public ParcelableMedia[] quoted_media; public ParcelableMedia[] quoted_media;
@Nullable
@ParcelableThisPlease @ParcelableThisPlease
@JsonField(name = "card") @JsonField(name = "card")
@CursorField(value = Statuses.CARD, converter = LoganSquareCursorFieldConverter.class) @CursorField(value = Statuses.CARD, converter = LoganSquareCursorFieldConverter.class)

View File

@ -71,8 +71,8 @@ public class TwitterCardUtils {
} }
public static boolean isCardSupported(ParcelableStatus status) { public static boolean isCardSupported(ParcelableStatus status) {
if (status.card == null || status.card.name == null) return false; if (status.card == null || status.card_name == null) return false;
switch (status.card.name) { switch (status.card_name) {
case CARD_NAME_PLAYER: { case CARD_NAME_PLAYER: {
return ParcelableCardEntity.getValue(status.card, "player_stream_url") == null; return ParcelableCardEntity.getValue(status.card, "player_stream_url") == null;
} }
@ -80,10 +80,14 @@ public class TwitterCardUtils {
return true; return true;
} }
} }
if (CardPollFragment.isPoll(status.card.name)) { if (CardPollFragment.isPoll(status.card_name)) {
return true; return true;
} }
return false; return false;
} }
public static boolean isPoll(ParcelableStatus status) {
if (status.card_name == null) return false;
return CardPollFragment.isPoll(status.card_name);
}
} }

View File

@ -58,7 +58,7 @@ public class StatusViewHolder extends ViewHolder implements Constants, OnClickLi
@NonNull @NonNull
private final IStatusesAdapter<?> adapter; private final IStatusesAdapter<?> adapter;
private final ImageView replyRetweetIcon; private final ImageView statusInfoIcon;
private final ImageView profileImageView; private final ImageView profileImageView;
private final ImageView profileTypeView; private final ImageView profileTypeView;
private final ImageView extraTypeView; private final ImageView extraTypeView;
@ -66,7 +66,7 @@ public class StatusViewHolder extends ViewHolder implements Constants, OnClickLi
private final TextView quotedTextView; private final TextView quotedTextView;
private final NameView nameView; private final NameView nameView;
private final NameView quotedNameView; private final NameView quotedNameView;
private final TextView replyRetweetView; private final TextView statusInfoLabel;
private final ShortTimeView timeView; private final ShortTimeView timeView;
private final CardMediaContainer mediaPreview; private final CardMediaContainer mediaPreview;
private final ActionIconThemedTextView replyCountView, retweetCountView, favoriteCountView; private final ActionIconThemedTextView replyCountView, retweetCountView, favoriteCountView;
@ -88,8 +88,8 @@ public class StatusViewHolder extends ViewHolder implements Constants, OnClickLi
quotedTextView = (TextView) itemView.findViewById(R.id.quoted_text); quotedTextView = (TextView) itemView.findViewById(R.id.quoted_text);
nameView = (NameView) itemView.findViewById(R.id.name); nameView = (NameView) itemView.findViewById(R.id.name);
quotedNameView = (NameView) itemView.findViewById(R.id.quoted_name); quotedNameView = (NameView) itemView.findViewById(R.id.quoted_name);
replyRetweetIcon = (ImageView) itemView.findViewById(R.id.reply_retweet_icon); statusInfoIcon = (ImageView) itemView.findViewById(R.id.status_info_icon);
replyRetweetView = (TextView) itemView.findViewById(R.id.reply_retweet_status); statusInfoLabel = (TextView) itemView.findViewById(R.id.status_info_label);
timeView = (ShortTimeView) itemView.findViewById(R.id.time); timeView = (ShortTimeView) itemView.findViewById(R.id.time);
mediaPreview = (CardMediaContainer) itemView.findViewById(R.id.media_preview); mediaPreview = (CardMediaContainer) itemView.findViewById(R.id.media_preview);
@ -148,23 +148,28 @@ public class StatusViewHolder extends ViewHolder implements Constants, OnClickLi
final long retweetCount; final long retweetCount;
final long favorite_count; final long favorite_count;
if (status.retweet_id > 0) { if (TwitterCardUtils.isPoll(status)) {
statusInfoLabel.setText(R.string.label_poll);
statusInfoIcon.setImageResource(R.drawable.ic_activity_action_poll);
statusInfoLabel.setVisibility(View.VISIBLE);
statusInfoIcon.setVisibility(View.VISIBLE);
} else if (status.retweet_id > 0) {
final String retweetedBy = manager.getDisplayName(status.retweeted_by_user_id, final String retweetedBy = manager.getDisplayName(status.retweeted_by_user_id,
status.retweeted_by_user_name, status.retweeted_by_user_screen_name, nameFirst, false); status.retweeted_by_user_name, status.retweeted_by_user_screen_name, nameFirst, false);
replyRetweetView.setText(context.getString(R.string.name_retweeted, retweetedBy)); statusInfoLabel.setText(context.getString(R.string.name_retweeted, retweetedBy));
replyRetweetIcon.setImageResource(R.drawable.ic_activity_action_retweet); statusInfoIcon.setImageResource(R.drawable.ic_activity_action_retweet);
replyRetweetView.setVisibility(View.VISIBLE); statusInfoLabel.setVisibility(View.VISIBLE);
replyRetweetIcon.setVisibility(View.VISIBLE); statusInfoIcon.setVisibility(View.VISIBLE);
} else if (status.in_reply_to_status_id > 0 && status.in_reply_to_user_id > 0 && displayInReplyTo) { } else if (status.in_reply_to_status_id > 0 && status.in_reply_to_user_id > 0 && displayInReplyTo) {
final String inReplyTo = manager.getDisplayName(status.in_reply_to_user_id, final String inReplyTo = manager.getDisplayName(status.in_reply_to_user_id,
status.in_reply_to_name, status.in_reply_to_screen_name, nameFirst, false); status.in_reply_to_name, status.in_reply_to_screen_name, nameFirst, false);
replyRetweetView.setText(context.getString(R.string.in_reply_to_name, inReplyTo)); statusInfoLabel.setText(context.getString(R.string.in_reply_to_name, inReplyTo));
replyRetweetIcon.setImageResource(R.drawable.ic_activity_action_reply); statusInfoIcon.setImageResource(R.drawable.ic_activity_action_reply);
replyRetweetView.setVisibility(View.VISIBLE); statusInfoLabel.setVisibility(View.VISIBLE);
replyRetweetIcon.setVisibility(View.VISIBLE); statusInfoIcon.setVisibility(View.VISIBLE);
} else { } else {
replyRetweetView.setVisibility(View.GONE); statusInfoLabel.setVisibility(View.GONE);
replyRetweetIcon.setVisibility(View.GONE); statusInfoIcon.setVisibility(View.GONE);
} }
@ -386,7 +391,7 @@ public class StatusViewHolder extends ViewHolder implements Constants, OnClickLi
nameView.setSecondaryTextSize(textSize * 0.85f); nameView.setSecondaryTextSize(textSize * 0.85f);
quotedNameView.setSecondaryTextSize(textSize * 0.85f); quotedNameView.setSecondaryTextSize(textSize * 0.85f);
timeView.setTextSize(textSize * 0.85f); timeView.setTextSize(textSize * 0.85f);
replyRetweetView.setTextSize(textSize * 0.75f); statusInfoLabel.setTextSize(textSize * 0.75f);
replyCountView.setTextSize(textSize); replyCountView.setTextSize(textSize);
retweetCountView.setTextSize(textSize); retweetCountView.setTextSize(textSize);
favoriteCountView.setTextSize(textSize); favoriteCountView.setTextSize(textSize);

View File

@ -33,27 +33,27 @@
app:ignorePadding="true"> app:ignorePadding="true">
<Space <Space
android:id="@+id/reply_retweet_space" android:id="@+id/status_info_space"
android:layout_width="@dimen/icon_size_status_profile_image" android:layout_width="@dimen/icon_size_status_profile_image"
android:layout_height="@dimen/element_size_small" android:layout_height="@dimen/element_size_small"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" android:layout_alignParentStart="true"
android:layout_alignTop="@+id/reply_retweet_status" android:layout_alignTop="@+id/status_info_label"
android:layout_marginEnd="@dimen/element_spacing_small" android:layout_marginEnd="@dimen/element_spacing_small"
android:layout_marginLeft="@dimen/element_spacing_normal" android:layout_marginLeft="@dimen/element_spacing_normal"
android:layout_marginRight="@dimen/element_spacing_small" android:layout_marginRight="@dimen/element_spacing_small"
android:layout_marginStart="@dimen/element_spacing_normal" /> android:layout_marginStart="@dimen/element_spacing_normal" />
<org.mariotaku.twidere.view.ActionIconView <org.mariotaku.twidere.view.ActionIconView
android:id="@+id/reply_retweet_icon" android:id="@+id/status_info_icon"
style="?profileImageStyle" style="?profileImageStyle"
android:layout_width="@dimen/element_size_small" android:layout_width="@dimen/element_size_small"
android:layout_height="@dimen/element_size_small" android:layout_height="@dimen/element_size_small"
android:layout_alignTop="@id/reply_retweet_status" android:layout_alignTop="@id/status_info_label"
android:layout_marginLeft="@dimen/element_spacing_small" android:layout_marginLeft="@dimen/element_spacing_small"
android:layout_marginStart="@dimen/element_spacing_small" android:layout_marginStart="@dimen/element_spacing_small"
android:layout_toLeftOf="@+id/reply_retweet_status" android:layout_toLeftOf="@+id/status_info_label"
android:layout_toStartOf="@+id/reply_retweet_status" android:layout_toStartOf="@+id/status_info_label"
android:color="?android:textColorSecondary" android:color="?android:textColorSecondary"
android:padding="@dimen/element_spacing_small" android:padding="@dimen/element_spacing_small"
android:scaleType="centerInside" android:scaleType="centerInside"
@ -62,13 +62,13 @@
tools:visibility="visible" /> tools:visibility="visible" />
<org.mariotaku.twidere.view.themed.ThemedTextView <org.mariotaku.twidere.view.themed.ThemedTextView
android:id="@+id/reply_retweet_status" android:id="@+id/status_info_label"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/element_spacing_normal" android:layout_marginLeft="@dimen/element_spacing_normal"
android:layout_marginRight="@dimen/element_spacing_normal" android:layout_marginRight="@dimen/element_spacing_normal"
android:layout_toEndOf="@+id/reply_retweet_space" android:layout_toEndOf="@+id/status_info_space"
android:layout_toRightOf="@+id/reply_retweet_space" android:layout_toRightOf="@+id/status_info_space"
android:ellipsize="end" android:ellipsize="end"
android:gravity="center_vertical|start" android:gravity="center_vertical|start"
android:minHeight="@dimen/element_size_small" android:minHeight="@dimen/element_size_small"
@ -84,7 +84,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" android:layout_alignParentStart="true"
android:layout_below="@+id/reply_retweet_status" android:layout_below="@+id/status_info_label"
android:paddingEnd="0dp" android:paddingEnd="0dp"
android:paddingLeft="@dimen/element_spacing_normal" android:paddingLeft="@dimen/element_spacing_normal"
android:paddingRight="0dp" android:paddingRight="0dp"

View File

@ -34,14 +34,14 @@
android:paddingRight="@dimen/element_spacing_normal"> android:paddingRight="@dimen/element_spacing_normal">
<org.mariotaku.twidere.view.ActionIconView <org.mariotaku.twidere.view.ActionIconView
android:id="@+id/reply_retweet_icon" android:id="@+id/status_info_icon"
style="?profileImageStyle" style="?profileImageStyle"
android:layout_width="@dimen/element_size_small" android:layout_width="@dimen/element_size_small"
android:layout_height="@dimen/element_size_small" android:layout_height="@dimen/element_size_small"
android:layout_alignBottom="@id/reply_retweet_status" android:layout_alignBottom="@id/status_info_label"
android:layout_alignEnd="@id/profile_image" android:layout_alignEnd="@id/profile_image"
android:layout_alignRight="@id/profile_image" android:layout_alignRight="@id/profile_image"
android:layout_alignTop="@id/reply_retweet_status" android:layout_alignTop="@id/status_info_label"
android:color="?android:textColorSecondary" android:color="?android:textColorSecondary"
android:padding="@dimen/element_spacing_small" android:padding="@dimen/element_spacing_small"
android:scaleType="centerInside" android:scaleType="centerInside"
@ -50,14 +50,14 @@
tools:visibility="visible"/> tools:visibility="visible"/>
<org.mariotaku.twidere.view.ActionIconThemedTextView <org.mariotaku.twidere.view.ActionIconThemedTextView
android:id="@+id/reply_retweet_status" android:id="@+id/status_info_label"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/element_spacing_minus_small" android:layout_marginBottom="@dimen/element_spacing_minus_small"
android:layout_marginLeft="@dimen/element_spacing_small" android:layout_marginLeft="@dimen/element_spacing_small"
android:layout_marginStart="@dimen/element_spacing_small" android:layout_marginStart="@dimen/element_spacing_small"
android:layout_toEndOf="@id/reply_retweet_icon" android:layout_toEndOf="@id/status_info_icon"
android:layout_toRightOf="@id/reply_retweet_icon" android:layout_toRightOf="@id/status_info_icon"
android:ellipsize="end" android:ellipsize="end"
android:gravity="center_vertical|start" android:gravity="center_vertical|start"
android:minHeight="@dimen/element_size_small" android:minHeight="@dimen/element_size_small"
@ -77,7 +77,7 @@
android:layout_alignParentStart="true" android:layout_alignParentStart="true"
android:layout_alignTop="@+id/status_content" android:layout_alignTop="@+id/status_content"
android:layout_alignWithParentIfMissing="true" android:layout_alignWithParentIfMissing="true"
android:layout_below="@+id/reply_retweet_status" android:layout_below="@+id/status_info_label"
android:layout_marginBottom="@dimen/element_spacing_small" android:layout_marginBottom="@dimen/element_spacing_small"
android:layout_marginEnd="@dimen/element_spacing_small" android:layout_marginEnd="@dimen/element_spacing_small"
android:layout_marginRight="@dimen/element_spacing_small" android:layout_marginRight="@dimen/element_spacing_small"
@ -102,7 +102,7 @@
android:id="@+id/status_content" android:id="@+id/status_content"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@id/reply_retweet_status" android:layout_below="@id/status_info_label"
android:layout_marginTop="@dimen/element_spacing_small" android:layout_marginTop="@dimen/element_spacing_small"
android:layout_toEndOf="@id/profile_image" android:layout_toEndOf="@id/profile_image"
android:layout_toRightOf="@id/profile_image" android:layout_toRightOf="@id/profile_image"

View File

@ -41,7 +41,7 @@
android:id="@+id/vote" android:id="@+id/vote"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/vote"/> android:text="@string/action_vote"/>
<TextView <TextView
android:id="@+id/poll_summary" android:id="@+id/poll_summary"

View File

@ -830,6 +830,7 @@
<string name="system_default">System default</string> <string name="system_default">System default</string>
<string name="emoji_support">Emoji support</string> <string name="emoji_support">Emoji support</string>
<string name="open_poll_in_official_app">Open poll in official app</string> <string name="open_poll_in_official_app">Open poll in official app</string>
<string name="vote">Vote</string> <string name="action_vote">Vote</string>
<string name="label_poll">Poll</string>
<string name="poll_summary_format"><xliff:g id="poll_count">%s</xliff:g> · <xliff:g id="poll_time_left">%s</xliff:g></string> <string name="poll_summary_format"><xliff:g id="poll_count">%s</xliff:g> · <xliff:g id="poll_time_left">%s</xliff:g></string>
</resources> </resources>

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg width="18px" height="18px" viewBox="0 0 18 18" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns">
<!-- Generator: Sketch 3.4.3 (16618) - http://www.bohemiancoding.com/sketch -->
<title>Artboard</title>
<desc>Created with Sketch.</desc>
<defs></defs>
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" sketch:type="MSPage">
<g id="Artboard" sketch:type="MSArtboardGroup" fill="#FFFFFF">
<path d="M1,4.00947762 C1,2.34738902 2.33663106,1 4.00947762,1 L13.9905224,1 C15.652611,1 17,2.33663106 17,4.00947762 L17,13.9905224 C17,15.652611 15.6633689,17 13.9905224,17 L4.00947762,17 C2.34738902,17 1,15.6633689 1,13.9905224 L1,4.00947762 Z M3,12.8181818 L7,12.8181818 L7,15 L3,15 L3,12.8181818 Z M3,9.54545455 L11,9.54545455 L11,11.7272727 L3,11.7272727 L3,9.54545455 Z M3,6.27272727 L15,6.27272727 L15,8.45454545 L3,8.45454545 L3,6.27272727 Z M3,3 L12,3 L12,5.18181818 L3,5.18181818 L3,3 Z" id="Rectangle-1" sketch:type="MSShapeGroup"></path>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.2 KiB