1
0
mirror of https://github.com/TwidereProject/Twidere-Android synced 2025-02-17 04:00:48 +01:00

supports joined_twitter event

This commit is contained in:
Mariotaku Lee 2016-03-23 12:06:48 +08:00
parent 332a59231e
commit ad4420abad
3 changed files with 60 additions and 50 deletions

View File

@ -40,7 +40,7 @@ public class Activity extends TwitterResponseObject implements TwitterResponse,
Status[] targetObjectStatuses, targetStatuses; Status[] targetObjectStatuses, targetStatuses;
UserList[] targetUserLists, targetObjectUserLists; UserList[] targetUserLists, targetObjectUserLists;
String maxPosition = null, minPosition = null; String maxPosition = null, minPosition = null;
long maxSortPosition =-1, minSortPosition = -1; long maxSortPosition = -1, minSortPosition = -1;
int targetObjectsSize, targetsSize, sourcesSize; int targetObjectsSize, targetsSize, sourcesSize;
Activity() { Activity() {
@ -175,38 +175,38 @@ public class Activity extends TwitterResponseObject implements TwitterResponse,
Action.FAVORITED_MENTION, Action.JOINED_TWITTER, Action.MEDIA_TAGGED, Action.FAVORITED_MENTION, Action.JOINED_TWITTER, Action.MEDIA_TAGGED,
Action.FAVORITED_MEDIA_TAGGED, Action.RETWEETED_MEDIA_TAGGED}) Action.FAVORITED_MEDIA_TAGGED, Action.RETWEETED_MEDIA_TAGGED})
public @interface Action { public @interface Action {
String FAVORITE = ("favorite"); String FAVORITE = "favorite";
/** /**
* Sources: followers to targets (User) * Sources: followers to targets (User)
* Targets: following user (User) * Targets: following user (User)
*/ */
String FOLLOW = ("follow"); String FOLLOW = "follow";
/** /**
* Targets: mentioned users (User) * Targets: mentioned users (User)
* Target objects: mention status (Status) * Target objects: mention status (Status)
*/ */
String MENTION = ("mention"); String MENTION = "mention";
/** /**
* Targets: reply status (Status) * Targets: reply status (Status)
* Target objects: in reply to status (Status) * Target objects: in reply to status (Status)
*/ */
String REPLY = ("reply"); String REPLY = "reply";
String RETWEET = ("retweet"); String RETWEET = "retweet";
String LIST_MEMBER_ADDED = ("list_member_added"); String LIST_MEMBER_ADDED = "list_member_added";
String LIST_CREATED = ("list_created"); String LIST_CREATED = "list_created";
String FAVORITED_RETWEET = ("favorited_retweet"); String FAVORITED_RETWEET = "favorited_retweet";
String RETWEETED_RETWEET = ("retweeted_retweet"); String RETWEETED_RETWEET = "retweeted_retweet";
/** /**
* Targets: Quote result (Status) * Targets: Quote result (Status)
* Target objects: Original status (Status) * Target objects: Original status (Status)
*/ */
String QUOTE = ("quote"); String QUOTE = "quote";
String RETWEETED_MENTION = ("retweeted_mention"); String RETWEETED_MENTION = "retweeted_mention";
String FAVORITED_MENTION = ("favorited_mention"); String FAVORITED_MENTION = "favorited_mention";
String JOINED_TWITTER = ("joined_twitter"); String JOINED_TWITTER = "joined_twitter";
String MEDIA_TAGGED = ("media_tagged"); String MEDIA_TAGGED = "media_tagged";
String FAVORITED_MEDIA_TAGGED = ("favorited_media_tagged"); String FAVORITED_MEDIA_TAGGED = "favorited_media_tagged";
String RETWEETED_MEDIA_TAGGED = ("retweeted_media_tagged"); String RETWEETED_MEDIA_TAGGED = "retweeted_media_tagged";
String[] MENTION_ACTIONS = {MENTION, REPLY, QUOTE}; String[] MENTION_ACTIONS = {MENTION, REPLY, QUOTE};
} }

View File

@ -42,15 +42,15 @@ public class ActivityTitleSummaryMessage {
final Resources resources = context.getResources(); final Resources resources = context.getResources();
switch (activity.action) { switch (activity.action) {
case Activity.Action.FOLLOW: { case Activity.Action.FOLLOW: {
int typeIcon = (R.drawable.ic_activity_action_follow); int typeIcon = R.drawable.ic_activity_action_follow;
int color = ContextCompat.getColor(context, R.color.highlight_follow); int color = ContextCompat.getColor(context, R.color.highlight_follow);
CharSequence title; CharSequence title;
if (byFriends) { if (byFriends) {
title = getTitleStringByFriends(resources, manager, R.string.activity_by_friends_follow, title = getTitleStringByFriends(resources, manager, R.string.activity_by_friends_follow,
R.string.activity_by_friends_follow_multi, sources, activity.target_users, nameFirst); R.string.activity_by_friends_follow_multi, sources, activity.target_users, nameFirst);
} else { } else {
title = (getTitleStringAboutMe(resources, manager, R.string.activity_about_me_follow, title = getTitleStringAboutMe(resources, manager, R.string.activity_about_me_follow,
R.string.activity_about_me_follow_multi, sources, nameFirst)); R.string.activity_about_me_follow_multi, sources, nameFirst);
} }
return new ActivityTitleSummaryMessage(typeIcon, color, title, null); return new ActivityTitleSummaryMessage(typeIcon, color, title, null);
} }
@ -59,25 +59,25 @@ public class ActivityTitleSummaryMessage {
int color; int color;
CharSequence title; CharSequence title;
if (shouldUseStarsForLikes) { if (shouldUseStarsForLikes) {
typeIcon = (R.drawable.ic_activity_action_favorite); typeIcon = R.drawable.ic_activity_action_favorite;
color = ContextCompat.getColor(context, R.color.highlight_favorite); color = ContextCompat.getColor(context, R.color.highlight_favorite);
if (byFriends) { if (byFriends) {
title = getTitleStringByFriends(resources, manager, R.string.activity_by_friends_favorite, title = getTitleStringByFriends(resources, manager, R.string.activity_by_friends_favorite,
R.string.activity_by_friends_favorite_multi, sources, activity.target_statuses, nameFirst); R.string.activity_by_friends_favorite_multi, sources, activity.target_statuses, nameFirst);
} else { } else {
title = (getTitleStringAboutMe(resources, manager, R.string.activity_about_me_favorite, title = getTitleStringAboutMe(resources, manager, R.string.activity_about_me_favorite,
R.string.activity_about_me_favorite_multi, sources, nameFirst)); R.string.activity_about_me_favorite_multi, sources, nameFirst);
} }
} else { } else {
typeIcon = (R.drawable.ic_activity_action_like); typeIcon = R.drawable.ic_activity_action_like;
color = ContextCompat.getColor(context, R.color.highlight_like); color = ContextCompat.getColor(context, R.color.highlight_like);
if (byFriends) { if (byFriends) {
title = (getTitleStringByFriends(resources, manager, R.string.activity_by_friends_like, title = getTitleStringByFriends(resources, manager, R.string.activity_by_friends_like,
R.string.activity_by_friends_like_multi, sources, activity.target_statuses, nameFirst)); R.string.activity_by_friends_like_multi, sources, activity.target_statuses, nameFirst);
} else { } else {
title = (getTitleStringAboutMe(resources, manager, R.string.activity_about_me_like, title = getTitleStringAboutMe(resources, manager, R.string.activity_about_me_like,
R.string.activity_about_me_like_multi, sources, nameFirst)); R.string.activity_about_me_like_multi, sources, nameFirst);
} }
} }
final StringBuilder summaryBuilder = new StringBuilder(); final StringBuilder summaryBuilder = new StringBuilder();
@ -92,7 +92,7 @@ public class ActivityTitleSummaryMessage {
return new ActivityTitleSummaryMessage(typeIcon, color, title, summaryBuilder.toString()); return new ActivityTitleSummaryMessage(typeIcon, color, title, summaryBuilder.toString());
} }
case Activity.Action.RETWEET: { case Activity.Action.RETWEET: {
int typeIcon = (R.drawable.ic_activity_action_retweet); int typeIcon = R.drawable.ic_activity_action_retweet;
int color = ContextCompat.getColor(context, R.color.highlight_retweet); int color = ContextCompat.getColor(context, R.color.highlight_retweet);
CharSequence title; CharSequence title;
if (byFriends) { if (byFriends) {
@ -111,12 +111,12 @@ public class ActivityTitleSummaryMessage {
int color; int color;
CharSequence title; CharSequence title;
if (shouldUseStarsForLikes) { if (shouldUseStarsForLikes) {
typeIcon = (R.drawable.ic_activity_action_favorite); typeIcon = R.drawable.ic_activity_action_favorite;
color = ContextCompat.getColor(context, R.color.highlight_favorite); color = ContextCompat.getColor(context, R.color.highlight_favorite);
title = getTitleStringAboutMe(resources, manager, R.string.activity_about_me_favorited_retweet, title = getTitleStringAboutMe(resources, manager, R.string.activity_about_me_favorited_retweet,
R.string.activity_about_me_favorited_retweet_multi, sources, nameFirst); R.string.activity_about_me_favorited_retweet_multi, sources, nameFirst);
} else { } else {
typeIcon = (R.drawable.ic_activity_action_like); typeIcon = R.drawable.ic_activity_action_like;
color = ContextCompat.getColor(context, R.color.highlight_like); color = ContextCompat.getColor(context, R.color.highlight_like);
title = getTitleStringAboutMe(resources, manager, R.string.activity_about_me_liked_retweet, title = getTitleStringAboutMe(resources, manager, R.string.activity_about_me_liked_retweet,
R.string.activity_about_me_liked_retweet_multi, sources, nameFirst); R.string.activity_about_me_liked_retweet_multi, sources, nameFirst);
@ -126,19 +126,19 @@ public class ActivityTitleSummaryMessage {
} }
case Activity.Action.RETWEETED_RETWEET: { case Activity.Action.RETWEETED_RETWEET: {
if (byFriends) return null; if (byFriends) return null;
int typeIcon = (R.drawable.ic_activity_action_retweet); int typeIcon = R.drawable.ic_activity_action_retweet;
int color = ContextCompat.getColor(context, R.color.highlight_retweet); int color = ContextCompat.getColor(context, R.color.highlight_retweet);
CharSequence title = (getTitleStringAboutMe(resources, manager, R.string.activity_about_me_retweeted_retweet, CharSequence title = getTitleStringAboutMe(resources, manager, R.string.activity_about_me_retweeted_retweet,
R.string.activity_about_me_retweeted_retweet_multi, sources, nameFirst)); R.string.activity_about_me_retweeted_retweet_multi, sources, nameFirst);
final String summary = activity.target_statuses[0].text_unescaped; final String summary = activity.target_statuses[0].text_unescaped;
return new ActivityTitleSummaryMessage(typeIcon, color, title, summary); return new ActivityTitleSummaryMessage(typeIcon, color, title, summary);
} }
case Activity.Action.RETWEETED_MENTION: { case Activity.Action.RETWEETED_MENTION: {
if (byFriends) return null; if (byFriends) return null;
int typeIcon = (R.drawable.ic_activity_action_retweet); int typeIcon = R.drawable.ic_activity_action_retweet;
int color = ContextCompat.getColor(context, R.color.highlight_retweet); int color = ContextCompat.getColor(context, R.color.highlight_retweet);
CharSequence title = (getTitleStringAboutMe(resources, manager, R.string.activity_about_me_retweeted_mention, CharSequence title = getTitleStringAboutMe(resources, manager, R.string.activity_about_me_retweeted_mention,
R.string.activity_about_me_retweeted_mention_multi, sources, nameFirst)); R.string.activity_about_me_retweeted_mention_multi, sources, nameFirst);
final String summary = activity.target_statuses[0].text_unescaped; final String summary = activity.target_statuses[0].text_unescaped;
return new ActivityTitleSummaryMessage(typeIcon, color, title, summary); return new ActivityTitleSummaryMessage(typeIcon, color, title, summary);
} }
@ -148,25 +148,25 @@ public class ActivityTitleSummaryMessage {
int color; int color;
CharSequence title; CharSequence title;
if (shouldUseStarsForLikes) { if (shouldUseStarsForLikes) {
typeIcon = (R.drawable.ic_activity_action_favorite); typeIcon = R.drawable.ic_activity_action_favorite;
color = ContextCompat.getColor(context, R.color.highlight_favorite); color = ContextCompat.getColor(context, R.color.highlight_favorite);
title = (getTitleStringAboutMe(resources, manager, R.string.activity_about_me_favorited_mention, title = getTitleStringAboutMe(resources, manager, R.string.activity_about_me_favorited_mention,
R.string.activity_about_me_favorited_mention_multi, sources, nameFirst)); R.string.activity_about_me_favorited_mention_multi, sources, nameFirst);
} else { } else {
typeIcon = (R.drawable.ic_activity_action_like); typeIcon = R.drawable.ic_activity_action_like;
color = ContextCompat.getColor(context, R.color.highlight_like); color = ContextCompat.getColor(context, R.color.highlight_like);
title = (getTitleStringAboutMe(resources, manager, R.string.activity_about_me_liked_mention, title = getTitleStringAboutMe(resources, manager, R.string.activity_about_me_liked_mention,
R.string.activity_about_me_liked_mention_multi, sources, nameFirst)); R.string.activity_about_me_liked_mention_multi, sources, nameFirst);
} }
final String summary = activity.target_statuses[0].text_unescaped; final String summary = activity.target_statuses[0].text_unescaped;
return new ActivityTitleSummaryMessage(typeIcon, color, title, summary); return new ActivityTitleSummaryMessage(typeIcon, color, title, summary);
} }
case Activity.Action.LIST_CREATED: { case Activity.Action.LIST_CREATED: {
if (!byFriends) return null; if (!byFriends) return null;
int typeIcon = (R.drawable.ic_activity_action_list_added); int typeIcon = R.drawable.ic_activity_action_list_added;
CharSequence title = (getTitleStringByFriends(resources, manager, R.string.activity_by_friends_list_created, CharSequence title = getTitleStringByFriends(resources, manager, R.string.activity_by_friends_list_created,
R.string.activity_by_friends_list_created_multi, sources, R.string.activity_by_friends_list_created_multi, sources,
activity.target_object_user_lists, nameFirst)); activity.target_object_user_lists, nameFirst);
boolean firstLine = true; boolean firstLine = true;
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
for (ParcelableUserList item : activity.target_object_user_lists) { for (ParcelableUserList item : activity.target_object_user_lists) {
@ -182,8 +182,8 @@ public class ActivityTitleSummaryMessage {
if (byFriends) return null; if (byFriends) return null;
CharSequence title; CharSequence title;
int icon = R.drawable.ic_activity_action_list_added; int icon = R.drawable.ic_activity_action_list_added;
if (sources.length == 1 && activity.target_object_user_lists != null if ((sources.length == 1) && (activity.target_object_user_lists != null)
&& activity.target_object_user_lists.length == 1) { && (activity.target_object_user_lists.length == 1)) {
final SpannableString firstDisplayName = new SpannableString(manager.getDisplayName( final SpannableString firstDisplayName = new SpannableString(manager.getDisplayName(
sources[0], nameFirst)); sources[0], nameFirst));
final SpannableString listName = new SpannableString(activity.target_object_user_lists[0].name); final SpannableString listName = new SpannableString(activity.target_object_user_lists[0].name);
@ -210,6 +210,14 @@ public class ActivityTitleSummaryMessage {
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
return new ActivityTitleSummaryMessage(0, 0, title, status.text_unescaped); return new ActivityTitleSummaryMessage(0, 0, title, status.text_unescaped);
} }
case Activity.Action.JOINED_TWITTER: {
int typeIcon = R.drawable.ic_activity_action_follow;
int color = ContextCompat.getColor(context, R.color.highlight_follow);
CharSequence title = getTitleStringAboutMe(resources, manager,
R.string.activity_joined_twitter, R.string.activity_joined_twitter_multi,
sources, nameFirst);
return new ActivityTitleSummaryMessage(typeIcon, color, title, null);
}
} }
return null; return null;
} }
@ -217,7 +225,7 @@ public class ActivityTitleSummaryMessage {
private static Spanned getTitleStringAboutMe(Resources resources, UserColorNameManager manager, private static Spanned getTitleStringAboutMe(Resources resources, UserColorNameManager manager,
int stringRes, int stringResMulti, int stringRes, int stringResMulti,
ParcelableUser[] sources, boolean nameFirst) { ParcelableUser[] sources, boolean nameFirst) {
if (sources == null || sources.length == 0) return null; if ((sources == null) || (sources.length == 0)) return null;
final Configuration configuration = resources.getConfiguration(); final Configuration configuration = resources.getConfiguration();
final SpannableString firstDisplayName = new SpannableString(manager.getDisplayName(sources[0], final SpannableString firstDisplayName = new SpannableString(manager.getDisplayName(sources[0],
nameFirst)); nameFirst));
@ -243,7 +251,7 @@ public class ActivityTitleSummaryMessage {
private static Spanned getTitleStringByFriends(Resources resources, UserColorNameManager manager, private static Spanned getTitleStringByFriends(Resources resources, UserColorNameManager manager,
int stringRes, int stringResMulti, int stringRes, int stringResMulti,
ParcelableUser[] sources, Object[] targets, boolean nameFirst) { ParcelableUser[] sources, Object[] targets, boolean nameFirst) {
if (sources == null || sources.length == 0) return null; if ((sources == null) || (sources.length == 0)) return null;
final Configuration configuration = resources.getConfiguration(); final Configuration configuration = resources.getConfiguration();
final SpannableString firstSourceName = new SpannableString(manager.getDisplayName( final SpannableString firstSourceName = new SpannableString(manager.getDisplayName(
sources[0], nameFirst)); sources[0], nameFirst));

View File

@ -261,6 +261,8 @@
<string name="activity_by_friends_list_member_added_multi"><xliff:g id="user">%1$s</xliff:g> added <xliff:g id="target">%2$s</xliff:g> and <xliff:g id="other">%1$s</xliff:g> to list.</string> <string name="activity_by_friends_list_member_added_multi"><xliff:g id="user">%1$s</xliff:g> added <xliff:g id="target">%2$s</xliff:g> and <xliff:g id="other">%1$s</xliff:g> to list.</string>
<string name="activity_by_friends_list_created"><xliff:g id="user">%1$s</xliff:g> created list <xliff:g id="target">%2$s</xliff:g>.</string> <string name="activity_by_friends_list_created"><xliff:g id="user">%1$s</xliff:g> created list <xliff:g id="target">%2$s</xliff:g>.</string>
<string name="activity_by_friends_list_created_multi"><xliff:g id="user">%1$s</xliff:g> created list <xliff:g id="target">%2$s</xliff:g> and <xliff:g id="other">%1$s</xliff:g>.</string> <string name="activity_by_friends_list_created_multi"><xliff:g id="user">%1$s</xliff:g> created list <xliff:g id="target">%2$s</xliff:g> and <xliff:g id="other">%1$s</xliff:g>.</string>
<string name="activity_joined_twitter"><xliff:g id="user">%s</xliff:g> joined Twitter.</string>
<string name="activity_joined_twitter_multi"><xliff:g id="user">%1$s</xliff:g> and <xliff:g id="other">%2$s</xliff:g> joined Twitter.</string>
<string name="status_not_updated">Tweet not sent.</string> <string name="status_not_updated">Tweet not sent.</string>
<string name="status_not_updated_summary">Tweet not sent, and saved to drafts.</string> <string name="status_not_updated_summary">Tweet not sent, and saved to drafts.</string>
<string name="incoming_friendships">Pending follow requests</string> <string name="incoming_friendships">Pending follow requests</string>