From 1371bb901c9995fb30077e5feddf5938d55e01af Mon Sep 17 00:00:00 2001 From: Mariotaku Lee Date: Wed, 8 Apr 2015 14:33:07 +0800 Subject: [PATCH] restarts activity when tabs changed. improved quote feature fixed media preview in status screen --- .../model/ParcelableDirectMessage.java | 11 +- .../twidere/model/ParcelableMedia.java | 10 +- .../twidere/model/ParcelableStatus.java | 120 +-- .../twidere/model/ParcelableUser.java | 7 +- .../twidere/model/ParcelableUserList.java | 295 +++--- .../twidere/provider/TwidereDataStore.java | 98 +- .../twidere/util/ContentValuesCreator.java | 34 +- .../twidere/util/MediaPreviewUtils.java | 6 +- .../mariotaku/twidere/util/ParseUtils.java | 5 + .../twidere/util/TwitterContentUtils.java | 18 +- .../src/main/java/twitter4j/MediaEntity.java | 4 +- .../src/main/java/twitter4j/URLEntity.java | 4 +- .../src/main/java/twitter4j/User.java | 6 +- .../internal/json/MediaEntityJSONImpl.java | 38 +- .../internal/json/URLEntityJSONImpl.java | 233 ++--- .../twitter4j/internal/json/UserJSONImpl.java | 929 +++++++++--------- twidere/src/main/AndroidManifest.xml | 31 +- .../java/org/mariotaku/twidere/Constants.java | 2 +- .../twidere/activity/SettingsActivity.java | 35 + .../support/QuickSearchBarActivity.java | 3 +- .../twidere/fragment/CustomTabsFragment.java | 8 +- .../support/MessagesConversationFragment.java | 2 +- .../fragment/support/StatusFragment.java | 70 +- .../fragment/support/UserFragment.java | 5 + .../loader/support/TileImageLoader.java | 3 +- .../twidere/view/holder/StatusViewHolder.java | 23 +- .../main/res/layout/header_status_common.xml | 42 +- .../main/res/layout/layout_media_preview.xml | 59 -- 28 files changed, 1046 insertions(+), 1055 deletions(-) delete mode 100644 twidere/src/main/res/layout/layout_media_preview.xml diff --git a/twidere.component.common/src/main/java/org/mariotaku/twidere/model/ParcelableDirectMessage.java b/twidere.component.common/src/main/java/org/mariotaku/twidere/model/ParcelableDirectMessage.java index 0a53d93b6..8223d794f 100644 --- a/twidere.component.common/src/main/java/org/mariotaku/twidere/model/ParcelableDirectMessage.java +++ b/twidere.component.common/src/main/java/org/mariotaku/twidere/model/ParcelableDirectMessage.java @@ -26,7 +26,6 @@ import android.os.Parcelable; import android.support.annotation.NonNull; import org.mariotaku.twidere.provider.TwidereDataStore.DirectMessages; -import org.mariotaku.twidere.util.ParseUtils; import org.mariotaku.twidere.util.SimpleValueSerializer; import org.mariotaku.twidere.util.TwitterContentUtils; @@ -122,10 +121,8 @@ public class ParcelableDirectMessage implements Parcelable, Comparable REVERSE_ID_COMPARATOR = new Comparator() { @Override @@ -103,13 +97,19 @@ public class ParcelableStatus implements TwidereParcelable, Comparable 0 ? ParseUtils - .parseString(urls_url_entities[0].getExpandedURL()) : null; + url = user.getURL(); + url_expanded = url != null && urls_url_entities != null && urls_url_entities.length > 0 ? urls_url_entities[0].getExpandedURL() : null; is_follow_request_sent = user.isFollowRequestSent(); followers_count = user.getFollowersCount(); friends_count = user.getFriendsCount(); diff --git a/twidere.component.common/src/main/java/org/mariotaku/twidere/model/ParcelableUserList.java b/twidere.component.common/src/main/java/org/mariotaku/twidere/model/ParcelableUserList.java index e5c4c3524..cee537029 100644 --- a/twidere.component.common/src/main/java/org/mariotaku/twidere/model/ParcelableUserList.java +++ b/twidere.component.common/src/main/java/org/mariotaku/twidere/model/ParcelableUserList.java @@ -21,181 +21,180 @@ package org.mariotaku.twidere.model; import android.os.Parcel; import android.os.Parcelable; +import android.support.annotation.NonNull; import org.mariotaku.jsonserializer.JSONParcel; import org.mariotaku.jsonserializer.JSONParcelable; -import org.mariotaku.twidere.util.ParseUtils; import twitter4j.User; import twitter4j.UserList; public class ParcelableUserList implements Parcelable, JSONParcelable, Comparable { - public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { - @Override - public ParcelableUserList createFromParcel(final Parcel in) { - return new ParcelableUserList(in); - } + public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { + @Override + public ParcelableUserList createFromParcel(final Parcel in) { + return new ParcelableUserList(in); + } - @Override - public ParcelableUserList[] newArray(final int size) { - return new ParcelableUserList[size]; - } - }; + @Override + public ParcelableUserList[] newArray(final int size) { + return new ParcelableUserList[size]; + } + }; - public static final JSONParcelable.Creator JSON_CREATOR = new JSONParcelable.Creator() { - @Override - public ParcelableUserList createFromParcel(final JSONParcel in) { - return new ParcelableUserList(in); - } + public static final JSONParcelable.Creator JSON_CREATOR = new JSONParcelable.Creator() { + @Override + public ParcelableUserList createFromParcel(final JSONParcel in) { + return new ParcelableUserList(in); + } - @Override - public ParcelableUserList[] newArray(final int size) { - return new ParcelableUserList[size]; - } - }; + @Override + public ParcelableUserList[] newArray(final int size) { + return new ParcelableUserList[size]; + } + }; - public final int members_count, subscribers_count; + public final int members_count, subscribers_count; - public final long account_id, id, user_id, position; + public final long account_id, id, user_id, position; - public final boolean is_public, is_following; + public final boolean is_public, is_following; - public final String description, name, user_screen_name, user_name, user_profile_image_url; + public final String description, name, user_screen_name, user_name, user_profile_image_url; - public ParcelableUserList(final JSONParcel in) { - position = in.readLong("position"); - account_id = in.readLong("account_id"); - id = in.readLong("list_id"); - is_public = in.readBoolean("is_public"); - is_following = in.readBoolean("is_following"); - name = in.readString("name"); - description = in.readString("description"); - user_id = in.readLong("user_id"); - user_name = in.readString("user_name"); - user_screen_name = in.readString("user_screen_name"); - user_profile_image_url = in.readString("user_profile_image_url"); - members_count = in.readInt("members_count"); - subscribers_count = in.readInt("subscribers_count"); - } + public ParcelableUserList(final JSONParcel in) { + position = in.readLong("position"); + account_id = in.readLong("account_id"); + id = in.readLong("list_id"); + is_public = in.readBoolean("is_public"); + is_following = in.readBoolean("is_following"); + name = in.readString("name"); + description = in.readString("description"); + user_id = in.readLong("user_id"); + user_name = in.readString("user_name"); + user_screen_name = in.readString("user_screen_name"); + user_profile_image_url = in.readString("user_profile_image_url"); + members_count = in.readInt("members_count"); + subscribers_count = in.readInt("subscribers_count"); + } - public ParcelableUserList(final Parcel in) { - position = in.readLong(); - account_id = in.readLong(); - id = in.readLong(); - is_public = in.readInt() == 1; - is_following = in.readInt() == 1; - name = in.readString(); - description = in.readString(); - user_id = in.readLong(); - user_name = in.readString(); - user_screen_name = in.readString(); - user_profile_image_url = in.readString(); - members_count = in.readInt(); - subscribers_count = in.readInt(); - } + public ParcelableUserList(final Parcel in) { + position = in.readLong(); + account_id = in.readLong(); + id = in.readLong(); + is_public = in.readInt() == 1; + is_following = in.readInt() == 1; + name = in.readString(); + description = in.readString(); + user_id = in.readLong(); + user_name = in.readString(); + user_screen_name = in.readString(); + user_profile_image_url = in.readString(); + members_count = in.readInt(); + subscribers_count = in.readInt(); + } - public ParcelableUserList(final UserList list, final long account_id) { - this(list, account_id, 0); - } + public ParcelableUserList(final UserList list, final long account_id) { + this(list, account_id, 0); + } - public ParcelableUserList(final UserList list, final long account_id, final long position) { - this(list, account_id, position, list.isFollowing()); - } + public ParcelableUserList(final UserList list, final long account_id, final long position) { + this(list, account_id, position, list.isFollowing()); + } - public ParcelableUserList(final UserList list, final long account_id, final long position, - final boolean is_following) { - final User user = list.getUser(); - this.position = position; - this.account_id = account_id; - id = list.getId(); - is_public = list.isPublic(); - this.is_following = is_following; - name = list.getName(); - description = list.getDescription(); - user_id = user.getId(); - user_name = user.getName(); - user_screen_name = user.getScreenName(); - user_profile_image_url = ParseUtils.parseString(user.getProfileImageUrlHttps()); - members_count = list.getMemberCount(); - subscribers_count = list.getSubscriberCount(); - } + public ParcelableUserList(final UserList list, final long account_id, final long position, + final boolean is_following) { + final User user = list.getUser(); + this.position = position; + this.account_id = account_id; + id = list.getId(); + is_public = list.isPublic(); + this.is_following = is_following; + name = list.getName(); + description = list.getDescription(); + user_id = user.getId(); + user_name = user.getName(); + user_screen_name = user.getScreenName(); + user_profile_image_url = user.getProfileImageUrlHttps(); + members_count = list.getMemberCount(); + subscribers_count = list.getSubscriberCount(); + } - @Override - public int compareTo(final ParcelableUserList another) { - if (another == null) return 0; - final long diff = position - another.position; - if (diff > Integer.MAX_VALUE) return Integer.MAX_VALUE; - if (diff < Integer.MIN_VALUE) return Integer.MIN_VALUE; - return (int) diff; - } + @Override + public int compareTo(@NonNull final ParcelableUserList another) { + final long diff = position - another.position; + if (diff > Integer.MAX_VALUE) return Integer.MAX_VALUE; + if (diff < Integer.MIN_VALUE) return Integer.MIN_VALUE; + return (int) diff; + } - @Override - public int describeContents() { - return 0; - } + @Override + public int describeContents() { + return 0; + } - @Override - public boolean equals(final Object obj) { - if (this == obj) return true; - if (obj == null) return false; - if (!(obj instanceof ParcelableUserList)) return false; - final ParcelableUserList other = (ParcelableUserList) obj; - if (account_id != other.account_id) return false; - if (id != other.id) return false; - return true; - } + @Override + public boolean equals(final Object obj) { + if (this == obj) return true; + if (obj == null) return false; + if (!(obj instanceof ParcelableUserList)) return false; + final ParcelableUserList other = (ParcelableUserList) obj; + if (account_id != other.account_id) return false; + if (id != other.id) return false; + return true; + } - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + (int) (account_id ^ account_id >>> 32); - result = prime * result + (int) (id ^ id >>> 32); - return result; - } + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + (int) (account_id ^ account_id >>> 32); + result = prime * result + (int) (id ^ id >>> 32); + return result; + } - @Override - public String toString() { - return "ParcelableUserList{members_count=" + members_count + ", subscribers_count=" + subscribers_count - + ", account_id=" + account_id + ", id=" + id + ", user_id=" + user_id + ", position=" + position - + ", is_public=" + is_public + ", is_following=" + is_following + ", description=" + description - + ", name=" + name + ", user_screen_name=" + user_screen_name + ", user_name=" + user_name - + ", user_profile_image_url=" + user_profile_image_url + "}"; - } + @Override + public String toString() { + return "ParcelableUserList{members_count=" + members_count + ", subscribers_count=" + subscribers_count + + ", account_id=" + account_id + ", id=" + id + ", user_id=" + user_id + ", position=" + position + + ", is_public=" + is_public + ", is_following=" + is_following + ", description=" + description + + ", name=" + name + ", user_screen_name=" + user_screen_name + ", user_name=" + user_name + + ", user_profile_image_url=" + user_profile_image_url + "}"; + } - @Override - public void writeToParcel(final JSONParcel out) { - out.writeLong("position", position); - out.writeLong("account_id", account_id); - out.writeLong("list_id", id); - out.writeBoolean("is_public", is_public); - out.writeBoolean("is_following", is_following); - out.writeString("name", name); - out.writeString("description", description); - out.writeLong("user_id", user_id); - out.writeString("user_name", user_name); - out.writeString("user_screen_name", user_screen_name); - out.writeString("user_profile_image_url", user_profile_image_url); - out.writeInt("members_count", members_count); - out.writeInt("subscribers_count", subscribers_count); - } + @Override + public void writeToParcel(final JSONParcel out) { + out.writeLong("position", position); + out.writeLong("account_id", account_id); + out.writeLong("list_id", id); + out.writeBoolean("is_public", is_public); + out.writeBoolean("is_following", is_following); + out.writeString("name", name); + out.writeString("description", description); + out.writeLong("user_id", user_id); + out.writeString("user_name", user_name); + out.writeString("user_screen_name", user_screen_name); + out.writeString("user_profile_image_url", user_profile_image_url); + out.writeInt("members_count", members_count); + out.writeInt("subscribers_count", subscribers_count); + } - @Override - public void writeToParcel(final Parcel out, final int flags) { - out.writeLong(position); - out.writeLong(account_id); - out.writeLong(id); - out.writeInt(is_public ? 1 : 0); - out.writeInt(is_following ? 1 : 0); - out.writeString(name); - out.writeString(description); - out.writeLong(user_id); - out.writeString(user_name); - out.writeString(user_screen_name); - out.writeString(user_profile_image_url); - out.writeInt(members_count); - out.writeInt(subscribers_count); - } + @Override + public void writeToParcel(final Parcel out, final int flags) { + out.writeLong(position); + out.writeLong(account_id); + out.writeLong(id); + out.writeInt(is_public ? 1 : 0); + out.writeInt(is_following ? 1 : 0); + out.writeString(name); + out.writeString(description); + out.writeLong(user_id); + out.writeString(user_name); + out.writeString(user_screen_name); + out.writeString(user_profile_image_url); + out.writeInt(members_count); + out.writeInt(subscribers_count); + } } diff --git a/twidere.component.common/src/main/java/org/mariotaku/twidere/provider/TwidereDataStore.java b/twidere.component.common/src/main/java/org/mariotaku/twidere/provider/TwidereDataStore.java index 9fee435be..5393fa9e4 100644 --- a/twidere.component.common/src/main/java/org/mariotaku/twidere/provider/TwidereDataStore.java +++ b/twidere.component.common/src/main/java/org/mariotaku/twidere/provider/TwidereDataStore.java @@ -138,15 +138,15 @@ public interface TwidereDataStore { String SAME_OAUTH_SIGNING_URL = "same_oauth_signing_url"; String NO_VERSION_SUFFIX = "no_version_suffix"; - String[] COLUMNS_NO_CREDENTIALS = new String[]{_ID, NAME, SCREEN_NAME, ACCOUNT_ID, + String[] COLUMNS_NO_CREDENTIALS = {_ID, NAME, SCREEN_NAME, ACCOUNT_ID, PROFILE_IMAGE_URL, PROFILE_BANNER_URL, COLOR, IS_ACTIVATED}; - String[] COLUMNS = new String[]{_ID, NAME, SCREEN_NAME, ACCOUNT_ID, AUTH_TYPE, + String[] COLUMNS = {_ID, NAME, SCREEN_NAME, ACCOUNT_ID, AUTH_TYPE, BASIC_AUTH_USERNAME, BASIC_AUTH_PASSWORD, OAUTH_TOKEN, OAUTH_TOKEN_SECRET, CONSUMER_KEY, CONSUMER_SECRET, API_URL_FORMAT, SAME_OAUTH_SIGNING_URL, NO_VERSION_SUFFIX, PROFILE_IMAGE_URL, PROFILE_BANNER_URL, COLOR, IS_ACTIVATED, SORT_POSITION}; - String[] TYPES = new String[]{TYPE_PRIMARY_KEY, TYPE_TEXT_NOT_NULL, TYPE_TEXT_NOT_NULL, + String[] TYPES = {TYPE_PRIMARY_KEY, TYPE_TEXT_NOT_NULL, TYPE_TEXT_NOT_NULL, TYPE_INT_UNIQUE, TYPE_INT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_BOOLEAN, TYPE_BOOLEAN, TYPE_TEXT, TYPE_TEXT, TYPE_INT, TYPE_BOOLEAN, TYPE_INT}; @@ -154,8 +154,8 @@ public interface TwidereDataStore { public static interface CachedHashtags extends CachedValues { - String[] COLUMNS = new String[]{_ID, NAME}; - String[] TYPES = new String[]{TYPE_PRIMARY_KEY, TYPE_TEXT}; + String[] COLUMNS = {_ID, NAME}; + String[] TYPES = {TYPE_PRIMARY_KEY, TYPE_TEXT}; String TABLE_NAME = "cached_hashtags"; String CONTENT_PATH = TABLE_NAME; @@ -173,9 +173,9 @@ public interface TwidereDataStore { String PATH = "path"; - String[] MATRIX_COLUMNS = new String[]{URL, PATH}; + String[] MATRIX_COLUMNS = {URL, PATH}; - String[] COLUMNS = new String[]{_ID, URL, PATH}; + String[] COLUMNS = {_ID, URL, PATH}; } public static interface CachedStatuses extends Statuses { @@ -189,8 +189,8 @@ public interface TwidereDataStore { String TIMESTAMP = "timestamp"; - String[] COLUMNS = new String[]{_ID, NAME, TIMESTAMP}; - String[] TYPES = new String[]{TYPE_PRIMARY_KEY, TYPE_TEXT, TYPE_INT}; + String[] COLUMNS = {_ID, NAME, TIMESTAMP}; + String[] TYPES = {TYPE_PRIMARY_KEY, TYPE_TEXT, TYPE_INT}; public static interface Local extends CachedTrends { String TABLE_NAME = "local_trends"; @@ -273,16 +273,16 @@ public interface TwidereDataStore { String LAST_SEEN = "last_seen"; - String[] COLUMNS = new String[]{_ID, USER_ID, CREATED_AT, NAME, SCREEN_NAME, + String[] COLUMNS = {_ID, USER_ID, CREATED_AT, NAME, SCREEN_NAME, DESCRIPTION_PLAIN, LOCATION, URL, PROFILE_IMAGE_URL, PROFILE_BANNER_URL, IS_PROTECTED, IS_VERIFIED, IS_FOLLOWING, FOLLOWERS_COUNT, FRIENDS_COUNT, STATUSES_COUNT, FAVORITES_COUNT, LISTED_COUNT, DESCRIPTION_HTML, DESCRIPTION_EXPANDED, URL_EXPANDED, BACKGROUND_COLOR, LINK_COLOR, TEXT_COLOR, LAST_SEEN}; - String[] BASIC_COLUMNS = new String[]{_ID, USER_ID, + String[] BASIC_COLUMNS = {_ID, USER_ID, NAME, SCREEN_NAME, PROFILE_IMAGE_URL}; - String[] TYPES = new String[]{TYPE_PRIMARY_KEY, TYPE_INT_UNIQUE, TYPE_INT, + String[] TYPES = {TYPE_PRIMARY_KEY, TYPE_INT_UNIQUE, TYPE_INT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_BOOLEAN, TYPE_BOOLEAN, TYPE_BOOLEAN, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT}; @@ -304,9 +304,9 @@ public interface TwidereDataStore { String PATH = "path"; - String[] MATRIX_COLUMNS = new String[]{NAME, PATH}; + String[] MATRIX_COLUMNS = {NAME, PATH}; - String[] COLUMNS = new String[]{_ID, NAME, PATH}; + String[] COLUMNS = {_ID, NAME, PATH}; } public static interface DirectMessages extends BaseColumns { @@ -337,11 +337,11 @@ public interface TwidereDataStore { String MEDIA_LIST = "media_list"; - String[] COLUMNS = new String[]{_ID, ACCOUNT_ID, MESSAGE_ID, MESSAGE_TIMESTAMP, + String[] COLUMNS = {_ID, ACCOUNT_ID, MESSAGE_ID, MESSAGE_TIMESTAMP, SENDER_ID, RECIPIENT_ID, CONVERSATION_ID, IS_OUTGOING, TEXT_HTML, TEXT_PLAIN, TEXT_UNESCAPED, SENDER_NAME, RECIPIENT_NAME, SENDER_SCREEN_NAME, RECIPIENT_SCREEN_NAME, SENDER_PROFILE_IMAGE_URL, RECIPIENT_PROFILE_IMAGE_URL, MEDIA_LIST}; - String[] TYPES = new String[]{TYPE_PRIMARY_KEY, TYPE_INT, TYPE_INT, TYPE_INT, + String[] TYPES = {TYPE_PRIMARY_KEY, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_BOOLEAN, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT}; @@ -434,8 +434,8 @@ public interface TwidereDataStore { String RECENT_QUERY = "recent_query"; - String[] COLUMNS = new String[]{_ID, RECENT_QUERY, QUERY}; - String[] TYPES = new String[]{TYPE_PRIMARY_KEY, TYPE_INT, TYPE_TEXT_NOT_NULL_UNIQUE}; + String[] COLUMNS = {_ID, RECENT_QUERY, QUERY}; + String[] TYPES = {TYPE_PRIMARY_KEY, TYPE_INT, TYPE_TEXT_NOT_NULL_UNIQUE}; String DEFAULT_SORT_ORDER = RECENT_QUERY + " DESC"; } @@ -449,9 +449,9 @@ public interface TwidereDataStore { String ADDRESS = "address"; - String[] MATRIX_COLUMNS = new String[]{HOST, ADDRESS}; + String[] MATRIX_COLUMNS = {HOST, ADDRESS}; - String[] COLUMNS = new String[]{_ID, HOST, ADDRESS}; + String[] COLUMNS = {_ID, HOST, ADDRESS}; } public static interface SavedSearches extends BaseColumns { @@ -468,9 +468,9 @@ public interface TwidereDataStore { String NAME = "name"; String CREATED_AT = "created_at"; - String[] COLUMNS = new String[]{_ID, ACCOUNT_ID, SEARCH_ID, CREATED_AT, + String[] COLUMNS = {_ID, ACCOUNT_ID, SEARCH_ID, CREATED_AT, QUERY, NAME}; - String[] TYPES = new String[]{TYPE_PRIMARY_KEY, TYPE_INT, TYPE_INT, + String[] TYPES = {TYPE_PRIMARY_KEY, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_TEXT, TYPE_TEXT}; String DEFAULT_SORT_ORDER = CREATED_AT + " DESC"; } @@ -514,10 +514,10 @@ public interface TwidereDataStore { String ACTION_EXTRAS = "action_extras"; - String[] COLUMNS = new String[]{_ID, TEXT, ACCOUNT_IDS, LOCATION, MEDIA, + String[] COLUMNS = {_ID, TEXT, ACCOUNT_IDS, LOCATION, MEDIA, IN_REPLY_TO_STATUS_ID, IS_POSSIBLY_SENSITIVE, TIMESTAMP, ACTION_TYPE, ACTION_EXTRAS}; - String[] TYPES = new String[]{TYPE_PRIMARY_KEY, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, + String[] TYPES = {TYPE_PRIMARY_KEY, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_INT, TYPE_INT, TYPE_BOOLEAN, TYPE_INT, TYPE_INT, TYPE_TEXT}; } @@ -536,9 +536,9 @@ public interface TwidereDataStore { String ENABLE_FOR_RETWEETS = "enable_for_retweets"; - String[] COLUMNS = new String[]{_ID, VALUE}; + String[] COLUMNS = {_ID, VALUE}; - String[] TYPES = new String[]{TYPE_PRIMARY_KEY, TYPE_TEXT_NOT_NULL_UNIQUE}; + String[] TYPES = {TYPE_PRIMARY_KEY, TYPE_TEXT_NOT_NULL_UNIQUE}; public static interface Keywords extends Filters { @@ -575,9 +575,9 @@ public interface TwidereDataStore { String NAME = "name"; String SCREEN_NAME = "screen_name"; - String[] COLUMNS = new String[]{_ID, USER_ID, NAME, SCREEN_NAME}; + String[] COLUMNS = {_ID, USER_ID, NAME, SCREEN_NAME}; - String[] TYPES = new String[]{TYPE_PRIMARY_KEY, TYPE_INT_UNIQUE, TYPE_TEXT_NOT_NULL, + String[] TYPES = {TYPE_PRIMARY_KEY, TYPE_INT_UNIQUE, TYPE_TEXT_NOT_NULL, TYPE_TEXT_NOT_NULL}; } } @@ -603,9 +603,9 @@ public interface TwidereDataStore { String COUNT = "count"; - String[] MATRIX_COLUMNS = new String[]{ID, COUNT}; + String[] MATRIX_COLUMNS = {ID, COUNT}; - String[] COLUMNS = new String[]{_ID, ID, COUNT}; + String[] COLUMNS = {_ID, ID, COUNT}; } public static interface Permissions extends BaseColumns { @@ -618,9 +618,9 @@ public interface TwidereDataStore { String PACKAGE_NAME = "package_name"; - String[] MATRIX_COLUMNS = new String[]{PACKAGE_NAME, PERMISSION}; + String[] MATRIX_COLUMNS = {PACKAGE_NAME, PERMISSION}; - String[] COLUMNS = new String[]{_ID, PACKAGE_NAME, PERMISSION}; + String[] COLUMNS = {_ID, PACKAGE_NAME, PERMISSION}; } public static interface Preferences extends BaseColumns { @@ -649,9 +649,9 @@ public interface TwidereDataStore { String TYPE = "type"; - String[] MATRIX_COLUMNS = new String[]{KEY, VALUE, TYPE}; + String[] MATRIX_COLUMNS = {KEY, VALUE, TYPE}; - String[] COLUMNS = new String[]{_ID, KEY, VALUE, TYPE}; + String[] COLUMNS = {_ID, KEY, VALUE, TYPE}; } public static interface Statuses extends BaseColumns { @@ -803,30 +803,34 @@ public interface TwidereDataStore { String QUOTE_TEXT_PLAIN = "quote_text_plain"; String QUOTE_TEXT_UNESCAPED = "quote_text_unescaped"; String QUOTE_TIMESTAMP = "quote_timestamp"; + String QUOTE_SOURCE = "quote_source"; String QUOTED_BY_USER_ID = "quoted_by_user_id"; String QUOTED_BY_USER_NAME = "quoted_by_user_name"; String QUOTED_BY_USER_SCREEN_NAME = "quoted_by_user_screen_name"; String QUOTED_BY_USER_PROFILE_IMAGE = "quoted_by_user_profile_image"; + String QUOTED_BY_USER_IS_VERIFIED = "quoted_by_user_is_verified"; + String QUOTED_BY_USER_IS_PROTECTED = "quoted_by_user_is_protected"; - String[] COLUMNS = new String[]{_ID, ACCOUNT_ID, STATUS_ID, USER_ID, + String[] COLUMNS = {_ID, ACCOUNT_ID, STATUS_ID, USER_ID, STATUS_TIMESTAMP, TEXT_HTML, TEXT_PLAIN, TEXT_UNESCAPED, USER_NAME, USER_SCREEN_NAME, USER_PROFILE_IMAGE_URL, IN_REPLY_TO_STATUS_ID, IN_REPLY_TO_USER_ID, IN_REPLY_TO_USER_NAME, IN_REPLY_TO_USER_SCREEN_NAME, SOURCE, LOCATION, RETWEET_COUNT, FAVORITE_COUNT, REPLY_COUNT, DESCENDENT_REPLY_COUNT, RETWEET_ID, RETWEET_TIMESTAMP, RETWEETED_BY_USER_ID, RETWEETED_BY_USER_NAME, RETWEETED_BY_USER_SCREEN_NAME, RETWEETED_BY_USER_PROFILE_IMAGE, QUOTE_ID, QUOTE_TEXT_HTML, QUOTE_TEXT_PLAIN, QUOTE_TEXT_UNESCAPED, QUOTE_TIMESTAMP, - QUOTED_BY_USER_ID, QUOTED_BY_USER_NAME, QUOTED_BY_USER_SCREEN_NAME, QUOTED_BY_USER_PROFILE_IMAGE, - MY_RETWEET_ID, IS_RETWEET, IS_QUOTE, IS_FAVORITE, IS_PROTECTED, IS_VERIFIED, IS_FOLLOWING, IS_GAP, - IS_POSSIBLY_SENSITIVE, MEDIA_LIST, MENTIONS_LIST, CARD_NAME, CARD, PLACE_FULL_NAME}; + QUOTE_SOURCE, QUOTED_BY_USER_ID, QUOTED_BY_USER_NAME, QUOTED_BY_USER_SCREEN_NAME, + QUOTED_BY_USER_PROFILE_IMAGE, QUOTED_BY_USER_IS_VERIFIED, QUOTED_BY_USER_IS_PROTECTED, + MY_RETWEET_ID, IS_RETWEET, IS_QUOTE, IS_FAVORITE, IS_PROTECTED, IS_VERIFIED, IS_FOLLOWING, + IS_GAP, IS_POSSIBLY_SENSITIVE, MEDIA_LIST, MENTIONS_LIST, CARD_NAME, CARD, PLACE_FULL_NAME}; - String[] TYPES = new String[]{TYPE_PRIMARY_KEY, TYPE_INT, TYPE_INT, + String[] TYPES = {TYPE_PRIMARY_KEY, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_INT, TYPE_INT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_TEXT, TYPE_TEXT, - TYPE_TEXT, TYPE_INT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_INT, TYPE_INT, TYPE_TEXT, - TYPE_TEXT, TYPE_TEXT, TYPE_INT, TYPE_BOOLEAN, TYPE_BOOLEAN, TYPE_BOOLEAN, TYPE_BOOLEAN, - TYPE_BOOLEAN, TYPE_BOOLEAN, TYPE_BOOLEAN, TYPE_BOOLEAN, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, - TYPE_TEXT, TYPE_TEXT}; + TYPE_TEXT, TYPE_INT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_INT, TYPE_TEXT, TYPE_INT, + TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_BOOLEAN, TYPE_BOOLEAN, TYPE_INT, TYPE_BOOLEAN, + TYPE_BOOLEAN, TYPE_BOOLEAN, TYPE_BOOLEAN, TYPE_BOOLEAN, TYPE_BOOLEAN, TYPE_BOOLEAN, + TYPE_BOOLEAN, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT}; } @@ -848,10 +852,10 @@ public interface TwidereDataStore { String POSITION = "position"; - String[] COLUMNS = new String[]{_ID, NAME, ICON, TYPE, ARGUMENTS, EXTRAS, + String[] COLUMNS = {_ID, NAME, ICON, TYPE, ARGUMENTS, EXTRAS, POSITION}; - String[] TYPES = new String[]{TYPE_PRIMARY_KEY, TYPE_TEXT, TYPE_TEXT, + String[] TYPES = {TYPE_PRIMARY_KEY, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT_NOT_NULL, TYPE_TEXT, TYPE_TEXT, TYPE_INT}; String DEFAULT_SORT_ORDER = POSITION + " ASC"; @@ -898,9 +902,9 @@ public interface TwidereDataStore { String COUNT = "count"; - String[] MATRIX_COLUMNS = new String[]{TAB_POSITION, TAB_TYPE, COUNT}; + String[] MATRIX_COLUMNS = {TAB_POSITION, TAB_TYPE, COUNT}; - String[] COLUMNS = new String[]{_ID, TAB_POSITION, TAB_TYPE, COUNT}; + String[] COLUMNS = {_ID, TAB_POSITION, TAB_TYPE, COUNT}; public static interface ByType extends UnreadCounts { diff --git a/twidere.component.common/src/main/java/org/mariotaku/twidere/util/ContentValuesCreator.java b/twidere.component.common/src/main/java/org/mariotaku/twidere/util/ContentValuesCreator.java index 531a3b851..c739e8e38 100644 --- a/twidere.component.common/src/main/java/org/mariotaku/twidere/util/ContentValuesCreator.java +++ b/twidere.component.common/src/main/java/org/mariotaku/twidere/util/ContentValuesCreator.java @@ -78,8 +78,8 @@ public final class ContentValuesCreator implements TwidereConstants { values.put(Accounts.ACCOUNT_ID, user.getId()); values.put(Accounts.SCREEN_NAME, user.getScreenName()); values.put(Accounts.NAME, user.getName()); - values.put(Accounts.PROFILE_IMAGE_URL, ParseUtils.parseString(user.getProfileImageUrlHttps())); - values.put(Accounts.PROFILE_BANNER_URL, ParseUtils.parseString(user.getProfileBannerImageUrl())); + values.put(Accounts.PROFILE_IMAGE_URL, user.getProfileImageUrlHttps()); + values.put(Accounts.PROFILE_BANNER_URL, user.getProfileBannerImageUrl()); values.put(Accounts.COLOR, color); values.put(Accounts.IS_ACTIVATED, 1); values.put(Accounts.API_URL_FORMAT, apiUrlFormat); @@ -102,8 +102,8 @@ public final class ContentValuesCreator implements TwidereConstants { values.put(Accounts.ACCOUNT_ID, user.getId()); values.put(Accounts.SCREEN_NAME, user.getScreenName()); values.put(Accounts.NAME, user.getName()); - values.put(Accounts.PROFILE_IMAGE_URL, ParseUtils.parseString(user.getProfileImageUrlHttps())); - values.put(Accounts.PROFILE_BANNER_URL, ParseUtils.parseString(user.getProfileBannerImageUrl())); + values.put(Accounts.PROFILE_IMAGE_URL, user.getProfileImageUrlHttps()); + values.put(Accounts.PROFILE_BANNER_URL, user.getProfileBannerImageUrl()); values.put(Accounts.COLOR, color); values.put(Accounts.IS_ACTIVATED, 1); values.put(Accounts.API_URL_FORMAT, apiUrlFormat); @@ -120,8 +120,8 @@ public final class ContentValuesCreator implements TwidereConstants { values.put(Accounts.ACCOUNT_ID, user.getId()); values.put(Accounts.SCREEN_NAME, user.getScreenName()); values.put(Accounts.NAME, user.getName()); - values.put(Accounts.PROFILE_IMAGE_URL, ParseUtils.parseString(user.getProfileImageUrlHttps())); - values.put(Accounts.PROFILE_BANNER_URL, ParseUtils.parseString(user.getProfileBannerImageUrl())); + values.put(Accounts.PROFILE_IMAGE_URL, (user.getProfileImageUrlHttps())); + values.put(Accounts.PROFILE_BANNER_URL, (user.getProfileBannerImageUrl())); values.put(Accounts.COLOR, color); values.put(Accounts.IS_ACTIVATED, 1); values.put(Accounts.API_URL_FORMAT, apiUrlFormat); @@ -144,8 +144,8 @@ public final class ContentValuesCreator implements TwidereConstants { public static ContentValues createCachedUser(final User user) { if (user == null || user.getId() <= 0) return null; - final String profile_image_url = ParseUtils.parseString(user.getProfileImageUrlHttps()); - final String url = ParseUtils.parseString(user.getURL()); + final String profile_image_url = user.getProfileImageUrlHttps(); + final String url = user.getURL(); final URLEntity[] urls = user.getURLEntities(); final ContentValues values = new ContentValues(); values.put(CachedUsers.USER_ID, user.getId()); @@ -168,7 +168,7 @@ public final class ContentValuesCreator implements TwidereConstants { values.put(CachedUsers.DESCRIPTION_EXPANDED, TwitterContentUtils.formatExpandedUserDescription(user)); values.put(CachedUsers.URL, url); if (url != null && urls != null && urls.length > 0) { - values.put(CachedUsers.URL_EXPANDED, ParseUtils.parseString(urls[0].getExpandedURL())); + values.put(CachedUsers.URL_EXPANDED, urls[0].getExpandedURL()); } values.put(CachedUsers.BACKGROUND_COLOR, ParseUtils.parseColor("#" + user.getProfileBackgroundColor(), 0)); values.put(CachedUsers.LINK_COLOR, ParseUtils.parseColor("#" + user.getProfileLinkColor(), 0)); @@ -182,8 +182,8 @@ public final class ContentValuesCreator implements TwidereConstants { final ContentValues values = new ContentValues(); final User sender = message.getSender(), recipient = message.getRecipient(); if (sender == null || recipient == null) return null; - final String sender_profile_image_url = ParseUtils.parseString(sender.getProfileImageUrlHttps()); - final String recipient_profile_image_url = ParseUtils.parseString(recipient.getProfileImageUrlHttps()); + final String sender_profile_image_url = sender.getProfileImageUrlHttps(); + final String recipient_profile_image_url = recipient.getProfileImageUrlHttps(); values.put(DirectMessages.ACCOUNT_ID, accountId); values.put(DirectMessages.MESSAGE_ID, message.getId()); values.put(DirectMessages.MESSAGE_TIMESTAMP, message.getCreatedAt().getTime()); @@ -317,7 +317,7 @@ public final class ContentValuesCreator implements TwidereConstants { values.put(Statuses.RETWEETED_BY_USER_ID, retweetedById); values.put(Statuses.RETWEETED_BY_USER_NAME, retweetUser.getName()); values.put(Statuses.RETWEETED_BY_USER_SCREEN_NAME, retweetUser.getScreenName()); - values.put(Statuses.RETWEETED_BY_USER_PROFILE_IMAGE, ParseUtils.parseString(retweetUser.getProfileImageUrlHttps())); + values.put(Statuses.RETWEETED_BY_USER_PROFILE_IMAGE, (retweetUser.getProfileImageUrlHttps())); values.put(Statuses.IS_RETWEET, true); if (retweetedById == accountId) { values.put(Statuses.MY_RETWEET_ID, orig.getId()); @@ -334,11 +334,15 @@ public final class ContentValuesCreator implements TwidereConstants { values.put(Statuses.QUOTE_TEXT_HTML, textHtml); values.put(Statuses.QUOTE_TEXT_PLAIN, orig.getText()); values.put(Statuses.QUOTE_TEXT_UNESCAPED, toPlainText(textHtml)); - values.put(Statuses.QUOTE_TIMESTAMP, quotedStatus.getCreatedAt().getTime()); + values.put(Statuses.QUOTE_TIMESTAMP, orig.getCreatedAt().getTime()); + values.put(Statuses.QUOTE_SOURCE, orig.getSource()); + values.put(Statuses.QUOTED_BY_USER_ID, quotedById); values.put(Statuses.QUOTED_BY_USER_NAME, quoteUser.getName()); values.put(Statuses.QUOTED_BY_USER_SCREEN_NAME, quoteUser.getScreenName()); - values.put(Statuses.QUOTED_BY_USER_PROFILE_IMAGE, ParseUtils.parseString(quoteUser.getProfileImageUrlHttps())); + values.put(Statuses.QUOTED_BY_USER_PROFILE_IMAGE, quoteUser.getProfileImageUrlHttps()); + values.put(Statuses.QUOTED_BY_USER_IS_VERIFIED, quoteUser.isVerified()); + values.put(Statuses.QUOTED_BY_USER_IS_PROTECTED, quoteUser.isProtected()); values.put(Statuses.IS_QUOTE, true); if (quotedById == accountId) { values.put(Statuses.MY_QUOTE_ID, orig.getId()); @@ -352,7 +356,7 @@ public final class ContentValuesCreator implements TwidereConstants { } final User user = status.getUser(); final long userId = user.getId(); - final String profileImageUrl = ParseUtils.parseString(user.getProfileImageUrlHttps()); + final String profileImageUrl = (user.getProfileImageUrlHttps()); final String name = user.getName(), screenName = user.getScreenName(); values.put(Statuses.USER_ID, userId); values.put(Statuses.USER_NAME, name); diff --git a/twidere.component.common/src/main/java/org/mariotaku/twidere/util/MediaPreviewUtils.java b/twidere.component.common/src/main/java/org/mariotaku/twidere/util/MediaPreviewUtils.java index 02900977d..35b16c08c 100644 --- a/twidere.component.common/src/main/java/org/mariotaku/twidere/util/MediaPreviewUtils.java +++ b/twidere.component.common/src/main/java/org/mariotaku/twidere/util/MediaPreviewUtils.java @@ -164,7 +164,7 @@ public class MediaPreviewUtils { private static final Pattern[] SUPPORTED_PATTERNS = {PATTERN_TWITTER_IMAGES, PATTERN_INSTAGRAM, PATTERN_GOOGLE_IMAGES, PATTERN_GOOGLE_PROXY_IMAGES, PATTERN_SINA_WEIBO_IMAGES, PATTERN_TWITPIC, PATTERN_IMGUR, PATTERN_IMGLY, PATTERN_YFROG, PATTERN_LOCKERZ, PATTERN_PLIXI, PATTERN_TWITGOO, - PATTERN_MOBYPICTURE, PATTERN_PHOTOZOU,PATTERN_TWITTER_DM_IMAGES}; + PATTERN_MOBYPICTURE, PATTERN_PHOTOZOU, PATTERN_TWITTER_DM_IMAGES}; private static final String URL_PHOTOZOU_PHOTO_INFO = "https://api.photozou.jp/rest/photo_info.json"; @@ -241,14 +241,14 @@ public class MediaPreviewUtils { final MediaEntity[] mediaEntities = status.getMediaEntities(); if (mediaEntities != null) { for (final MediaEntity mediaEntity : mediaEntities) { - final String expanded = ParseUtils.parseString(mediaEntity.getMediaURLHttps()); + final String expanded = mediaEntity.getMediaURLHttps(); if (getSupportedLink(expanded) != null) return expanded; } } final URLEntity[] urlEntities = status.getURLEntities(); if (urlEntities != null) { for (final URLEntity urlEntity : urlEntities) { - final String expanded = ParseUtils.parseString(urlEntity.getExpandedURL()); + final String expanded = urlEntity.getExpandedURL(); if (getSupportedLink(expanded) != null) return expanded; } } diff --git a/twidere.component.common/src/main/java/org/mariotaku/twidere/util/ParseUtils.java b/twidere.component.common/src/main/java/org/mariotaku/twidere/util/ParseUtils.java index 28b257198..ec6373f06 100644 --- a/twidere.component.common/src/main/java/org/mariotaku/twidere/util/ParseUtils.java +++ b/twidere.component.common/src/main/java/org/mariotaku/twidere/util/ParseUtils.java @@ -161,6 +161,11 @@ public final class ParseUtils { return def; } + @Deprecated + public static String parseString(final String object) { + return object; + } + public static String parseString(final Object object) { return parseString(object, null); } diff --git a/twidere.component.common/src/main/java/org/mariotaku/twidere/util/TwitterContentUtils.java b/twidere.component.common/src/main/java/org/mariotaku/twidere/util/TwitterContentUtils.java index 807ee095a..0633a9122 100644 --- a/twidere.component.common/src/main/java/org/mariotaku/twidere/util/TwitterContentUtils.java +++ b/twidere.component.common/src/main/java/org/mariotaku/twidere/util/TwitterContentUtils.java @@ -24,7 +24,6 @@ import android.support.annotation.NonNull; import org.mariotaku.twidere.common.R; -import java.net.URL; import java.nio.charset.Charset; import java.util.zip.CRC32; @@ -59,7 +58,7 @@ public class TwitterContentUtils { final URLEntity[] urls = user.getDescriptionEntities(); if (urls != null) { for (final URLEntity url : urls) { - final String expanded_url = ParseUtils.parseString(url.getExpandedURL()); + final String expanded_url = url.getExpandedURL(); if (expanded_url != null) { builder.addLink(expanded_url, expanded_url, url.getStart(), url.getEnd()); } @@ -85,10 +84,9 @@ public class TwitterContentUtils { final URLEntity[] urls = user.getDescriptionEntities(); if (urls != null) { for (final URLEntity url : urls) { - final URL expanded_url = url.getExpandedURL(); + final String expanded_url = url.getExpandedURL(); if (expanded_url != null) { - builder.addLink(ParseUtils.parseString(expanded_url), url.getDisplayURL(), url.getStart(), - url.getEnd()); + builder.addLink(expanded_url, url.getDisplayURL(), url.getStart(), url.getEnd()); } } } @@ -128,10 +126,9 @@ public class TwitterContentUtils { if (mediaEntities != null) { for (final MediaEntity mediaEntity : mediaEntities) { final int start = mediaEntity.getStart(), end = mediaEntity.getEnd(); - final URL mediaUrl = mediaEntity.getMediaURL(); + final String mediaUrl = mediaEntity.getMediaURL(); if (mediaUrl != null && start >= 0 && end >= 0) { - builder.addLink(ParseUtils.parseString(mediaUrl), mediaEntity.getDisplayURL(), - start, end); + builder.addLink(mediaUrl, mediaEntity.getDisplayURL(), start, end); } } } @@ -139,10 +136,9 @@ public class TwitterContentUtils { if (urlEntities != null) { for (final URLEntity urlEntity : urlEntities) { final int start = urlEntity.getStart(), end = urlEntity.getEnd(); - final URL expandedUrl = urlEntity.getExpandedURL(); + final String expandedUrl = urlEntity.getExpandedURL(); if (expandedUrl != null && start >= 0 && end >= 0) { - builder.addLink(ParseUtils.parseString(expandedUrl), urlEntity.getDisplayURL(), - start, end); + builder.addLink(expandedUrl, urlEntity.getDisplayURL(), start, end); } } } diff --git a/twidere.component.twitter4j/src/main/java/twitter4j/MediaEntity.java b/twidere.component.twitter4j/src/main/java/twitter4j/MediaEntity.java index dd6fa2b78..0cb583cfe 100644 --- a/twidere.component.twitter4j/src/main/java/twitter4j/MediaEntity.java +++ b/twidere.component.twitter4j/src/main/java/twitter4j/MediaEntity.java @@ -37,14 +37,14 @@ public interface MediaEntity extends URLEntity, Serializable { * * @return the media URL */ - URL getMediaURL(); + String getMediaURL(); /** * Returns the media secure URL. * * @return the media secure URL */ - URL getMediaURLHttps(); + String getMediaURLHttps(); /** * Returns size variations of the media. diff --git a/twidere.component.twitter4j/src/main/java/twitter4j/URLEntity.java b/twidere.component.twitter4j/src/main/java/twitter4j/URLEntity.java index baa83e8e2..69da6413d 100644 --- a/twidere.component.twitter4j/src/main/java/twitter4j/URLEntity.java +++ b/twidere.component.twitter4j/src/main/java/twitter4j/URLEntity.java @@ -48,7 +48,7 @@ public interface URLEntity extends Serializable { * @return the expanded URL if mentioned URL is shorten, or null if no * shorten URL was mentioned. */ - URL getExpandedURL(); + String getExpandedURL(); /** * Returns the index of the start character of the URL mentioned in the @@ -64,5 +64,5 @@ public interface URLEntity extends Serializable { * * @return the mentioned URL */ - URL getURL(); + String getURL(); } diff --git a/twidere.component.twitter4j/src/main/java/twitter4j/User.java b/twidere.component.twitter4j/src/main/java/twitter4j/User.java index ed49fb1a6..e4cbbf98f 100644 --- a/twidere.component.twitter4j/src/main/java/twitter4j/User.java +++ b/twidere.component.twitter4j/src/main/java/twitter4j/User.java @@ -100,14 +100,14 @@ public interface User extends Comparable, TwitterResponse, Serializable { * * @return the profile image url of the user */ - URL getProfileImageURL(); + String getProfileImageURL(); /** * Returns the profile image url of the user, served over SSL * * @return the profile image url of the user, served over SSL */ - URL getProfileImageUrlHttps(); + String getProfileImageUrlHttps(); String getProfileLinkColor(); @@ -142,7 +142,7 @@ public interface User extends Comparable, TwitterResponse, Serializable { * * @return the url of the user */ - URL getURL(); + String getURL(); URLEntity[] getURLEntities(); diff --git a/twidere.component.twitter4j/src/main/java/twitter4j/internal/json/MediaEntityJSONImpl.java b/twidere.component.twitter4j/src/main/java/twitter4j/internal/json/MediaEntityJSONImpl.java index 26799621b..22151e12a 100644 --- a/twidere.component.twitter4j/src/main/java/twitter4j/internal/json/MediaEntityJSONImpl.java +++ b/twidere.component.twitter4j/src/main/java/twitter4j/internal/json/MediaEntityJSONImpl.java @@ -23,8 +23,6 @@ import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; -import java.net.MalformedURLException; -import java.net.URL; import java.util.Arrays; import java.util.HashMap; import java.util.Map; @@ -47,10 +45,10 @@ public class MediaEntityJSONImpl implements MediaEntity { private long id; private int start = -1; private int end = -1; - private URL url; - private URL mediaURL; - private URL mediaURLHttps; - private URL expandedURL; + private String url; + private String mediaURL; + private String mediaURLHttps; + private String expandedURL; private String displayURL; private Map sizes; private Type type; @@ -67,28 +65,16 @@ public class MediaEntityJSONImpl implements MediaEntity { end = indicesArray.getInt(1); id = getLong("id", json); - try { - url = new URL(json.getString("url")); - } catch (final MalformedURLException ignore) { - } + url = (json.getString("url")); if (!json.isNull("expanded_url")) { - try { - expandedURL = new URL(json.getString("expanded_url")); - } catch (final MalformedURLException ignore) { - } + expandedURL = json.getString("expanded_url"); } if (!json.isNull("media_url")) { - try { - mediaURL = new URL(json.getString("media_url")); - } catch (final MalformedURLException ignore) { - } + mediaURL = (json.getString("media_url")); } if (!json.isNull("media_url_https")) { - try { - mediaURLHttps = new URL(json.getString("media_url_https")); - } catch (final MalformedURLException ignore) { - } + mediaURLHttps = (json.getString("media_url_https")); } if (!json.isNull("display_url")) { displayURL = json.getString("display_url"); @@ -148,7 +134,7 @@ public class MediaEntityJSONImpl implements MediaEntity { * {@inheritDoc} */ @Override - public URL getExpandedURL() { + public String getExpandedURL() { return expandedURL; } @@ -164,7 +150,7 @@ public class MediaEntityJSONImpl implements MediaEntity { * {@inheritDoc} */ @Override - public URL getMediaURL() { + public String getMediaURL() { return mediaURL; } @@ -172,7 +158,7 @@ public class MediaEntityJSONImpl implements MediaEntity { * {@inheritDoc} */ @Override - public URL getMediaURLHttps() { + public String getMediaURLHttps() { return mediaURLHttps; } @@ -201,7 +187,7 @@ public class MediaEntityJSONImpl implements MediaEntity { * {@inheritDoc} */ @Override - public URL getURL() { + public String getURL() { return url; } diff --git a/twidere.component.twitter4j/src/main/java/twitter4j/internal/json/URLEntityJSONImpl.java b/twidere.component.twitter4j/src/main/java/twitter4j/internal/json/URLEntityJSONImpl.java index 08f3ba187..7c0afd6db 100644 --- a/twidere.component.twitter4j/src/main/java/twitter4j/internal/json/URLEntityJSONImpl.java +++ b/twidere.component.twitter4j/src/main/java/twitter4j/internal/json/URLEntityJSONImpl.java @@ -23,159 +23,138 @@ import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; -import java.net.MalformedURLException; -import java.net.URL; - import twitter4j.TwitterException; import twitter4j.URLEntity; /** * A data class representing one single URL entity. - * + * * @author Mocel - mocel at guma.jp * @since Twitter4J 2.1.9 */ /* package */final class URLEntityJSONImpl implements URLEntity { - /** - * - */ - private static final long serialVersionUID = 1326410198426703277L; - private int start = -1; - private int end = -1; - private URL url; - private URL expandedURL; - private String displayURL; + /** + * + */ + private static final long serialVersionUID = 1326410198426703277L; + private int start = -1; + private int end = -1; + private String url; + private String expandedURL; + private String displayURL; - /* For serialization purposes only. */ - /* package */URLEntityJSONImpl() { + /* For serialization purposes only. */ + /* package */URLEntityJSONImpl() { - } + } - /* package */URLEntityJSONImpl(final int start, final int end, final String url, final String expandedURL, - final String displayURL) { - super(); - this.start = start; - this.end = end; - try { - this.url = new URL(url); - } catch (final MalformedURLException e) { - try { - this.url = new URL("http://example.com/"); - } catch (final MalformedURLException ignore) { - } - } - try { - this.expandedURL = new URL(expandedURL); - } catch (final MalformedURLException e) { - try { - this.expandedURL = new URL("http://example.com/"); - } catch (final MalformedURLException ignore) { - } - } - this.displayURL = displayURL; - } + /* package */URLEntityJSONImpl(final int start, final int end, final String url, final String expandedURL, + final String displayURL) { + super(); + this.start = start; + this.end = end; + this.url = url; + this.expandedURL = expandedURL; + this.displayURL = displayURL; + } - /* package */URLEntityJSONImpl(final JSONObject json) throws TwitterException { - super(); - init(json); - } + /* package */URLEntityJSONImpl(final JSONObject json) throws TwitterException { + super(); + init(json); + } - @Override - public boolean equals(final Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; - final URLEntityJSONImpl that = (URLEntityJSONImpl) o; + final URLEntityJSONImpl that = (URLEntityJSONImpl) o; - if (end != that.end) return false; - if (start != that.start) return false; - if (displayURL != null ? !displayURL.equals(that.displayURL) : that.displayURL != null) return false; - if (expandedURL != null ? !expandedURL.toString().equalsIgnoreCase(that.expandedURL.toString()) - : that.expandedURL != null) return false; - if (url != null ? !url.toString().equalsIgnoreCase(that.url.toString()) : that.url != null) return false; + if (end != that.end) return false; + if (start != that.start) return false; + if (displayURL != null ? !displayURL.equals(that.displayURL) : that.displayURL != null) + return false; + if (expandedURL != null ? !expandedURL.equalsIgnoreCase(that.expandedURL) + : that.expandedURL != null) return false; + if (url != null ? !url.equalsIgnoreCase(that.url) : that.url != null) + return false; - return true; - } + return true; + } - /** - * {@inheritDoc} - */ - @Override - public String getDisplayURL() { - return displayURL; - } + /** + * {@inheritDoc} + */ + @Override + public String getDisplayURL() { + return displayURL; + } - /** - * {@inheritDoc} - */ - @Override - public int getEnd() { - return end; - } + /** + * {@inheritDoc} + */ + @Override + public int getEnd() { + return end; + } - /** - * {@inheritDoc} - */ - @Override - public URL getExpandedURL() { - return expandedURL; - } + /** + * {@inheritDoc} + */ + @Override + public String getExpandedURL() { + return expandedURL; + } - /** - * {@inheritDoc} - */ - @Override - public int getStart() { - return start; - } + /** + * {@inheritDoc} + */ + @Override + public int getStart() { + return start; + } - /** - * {@inheritDoc} - */ - @Override - public URL getURL() { - return url; - } + /** + * {@inheritDoc} + */ + @Override + public String getURL() { + return url; + } - @Override - public int hashCode() { - int result = start; - result = 31 * result + end; - result = 31 * result + (url != null ? url.toString().hashCode() : 0); - result = 31 * result + (expandedURL != null ? expandedURL.toString().hashCode() : 0); - result = 31 * result + (displayURL != null ? displayURL.hashCode() : 0); - return result; - } + @Override + public int hashCode() { + int result = start; + result = 31 * result + end; + result = 31 * result + (url != null ? url.hashCode() : 0); + result = 31 * result + (expandedURL != null ? expandedURL.hashCode() : 0); + result = 31 * result + (displayURL != null ? displayURL.hashCode() : 0); + return result; + } - @Override - public String toString() { - return "URLEntityJSONImpl{" + "start=" + start + ", end=" + end + ", url=" + url + ", expandedURL=" - + expandedURL + ", displayURL=" + displayURL + '}'; - } + @Override + public String toString() { + return "URLEntityJSONImpl{" + "start=" + start + ", end=" + end + ", url=" + url + ", expandedURL=" + + expandedURL + ", displayURL=" + displayURL + '}'; + } - private void init(final JSONObject json) throws TwitterException { - try { - final JSONArray indicesArray = json.getJSONArray("indices"); - start = indicesArray.getInt(0); - end = indicesArray.getInt(1); + private void init(final JSONObject json) throws TwitterException { + try { + final JSONArray indicesArray = json.getJSONArray("indices"); + start = indicesArray.getInt(0); + end = indicesArray.getInt(1); - try { - url = new URL(json.getString("url")); - } catch (final MalformedURLException ignore) { - } + url = json.getString("url"); - if (!json.isNull("expanded_url")) { - try { - expandedURL = new URL(json.getString("expanded_url")); - } catch (final MalformedURLException ignore) { - } - } - if (!json.isNull("display_url")) { - displayURL = json.getString("display_url"); - } - } catch (final JSONException jsone) { - throw new TwitterException(jsone); - } - } + if (!json.isNull("expanded_url")) { + expandedURL = json.getString("expanded_url"); + } + if (!json.isNull("display_url")) { + displayURL = json.getString("display_url"); + } + } catch (final JSONException jsone) { + throw new TwitterException(jsone); + } + } } diff --git a/twidere.component.twitter4j/src/main/java/twitter4j/internal/json/UserJSONImpl.java b/twidere.component.twitter4j/src/main/java/twitter4j/internal/json/UserJSONImpl.java index 1018c6fad..5fb24f2ed 100644 --- a/twidere.component.twitter4j/src/main/java/twitter4j/internal/json/UserJSONImpl.java +++ b/twidere.component.twitter4j/src/main/java/twitter4j/internal/json/UserJSONImpl.java @@ -23,8 +23,6 @@ import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; -import java.net.MalformedURLException; -import java.net.URL; import java.util.Date; import twitter4j.PageableResponseList; @@ -44,529 +42,516 @@ import static twitter4j.internal.util.InternalParseUtil.getRawString; /** * A data class representing Basic user information element - * + * * @author Yusuke Yamamoto - yusuke at mac.com */ /* package */final class UserJSONImpl extends TwitterResponseImpl implements User { - private static final long serialVersionUID = 1401119968489672262L; - private long id; - private String name; + private static final long serialVersionUID = 1401119968489672262L; + private long id; + private String name; - private String screenName; - private String location; - private String description; - private boolean isContributorsEnabled; - private String profileImageUrl; - private String profileImageUrlHttps; - private String url; - private boolean isProtected; - private int followersCount; - private Status status; - private String profileBackgroundColor; - private String profileTextColor; + private String screenName; + private String location; + private String description; + private boolean isContributorsEnabled; + private String profileImageUrl; + private String profileImageUrlHttps; + private String url; + private boolean isProtected; + private int followersCount; + private Status status; + private String profileBackgroundColor; + private String profileTextColor; - private String profileLinkColor; + private String profileLinkColor; - private String profileSidebarFillColor; - private String profileSidebarBorderColor; - private boolean profileUseBackgroundImage; - private boolean showAllInlineMedia; - private int friendsCount; - private Date createdAt; - private int favouritesCount; - private int utcOffset; - private String timeZone; - private String profileBackgroundImageUrl; - private String profileBackgroundImageUrlHttps; - private boolean profileBackgroundTiled; - private String lang; - private int statusesCount; - private boolean isGeoEnabled; - private boolean isVerified; - private boolean isTranslator; - private boolean isFollowing; - private int listedCount; - private boolean isFollowRequestSent; - private String profileBannerImageUrl; - private boolean isDefaultProfileImage; - private URLEntity[] urlEntities; - private URLEntity[] descriptionEntities; + private String profileSidebarFillColor; + private String profileSidebarBorderColor; + private boolean profileUseBackgroundImage; + private boolean showAllInlineMedia; + private int friendsCount; + private Date createdAt; + private int favouritesCount; + private int utcOffset; + private String timeZone; + private String profileBackgroundImageUrl; + private String profileBackgroundImageUrlHttps; + private boolean profileBackgroundTiled; + private String lang; + private int statusesCount; + private boolean isGeoEnabled; + private boolean isVerified; + private boolean isTranslator; + private boolean isFollowing; + private int listedCount; + private boolean isFollowRequestSent; + private String profileBannerImageUrl; + private boolean isDefaultProfileImage; + private URLEntity[] urlEntities; + private URLEntity[] descriptionEntities; - /* package */UserJSONImpl(final HttpResponse res, final Configuration conf) throws TwitterException { - super(res); - final JSONObject json = res.asJSONObject(); - init(json); - } + /* package */UserJSONImpl(final HttpResponse res, final Configuration conf) throws TwitterException { + super(res); + final JSONObject json = res.asJSONObject(); + init(json); + } - /* package */UserJSONImpl(final JSONObject json) throws TwitterException { - super(); - init(json); - } + /* package */UserJSONImpl(final JSONObject json) throws TwitterException { + super(); + init(json); + } - @Override - public int compareTo(final User that) { - return (int) (id - that.getId()); - } + @Override + public int compareTo(final User that) { + return (int) (id - that.getId()); + } - @Override - public boolean equals(final Object obj) { - if (null == obj) return false; - if (this == obj) return true; - return obj instanceof User && ((User) obj).getId() == id; - } + @Override + public boolean equals(final Object obj) { + if (null == obj) return false; + if (this == obj) return true; + return obj instanceof User && ((User) obj).getId() == id; + } - /** - * {@inheritDoc} - */ - @Override - public Date getCreatedAt() { - return createdAt; - } + /** + * {@inheritDoc} + */ + @Override + public Date getCreatedAt() { + return createdAt; + } - /** - * {@inheritDoc} - */ - @Override - public String getDescription() { - return description; - } + /** + * {@inheritDoc} + */ + @Override + public String getDescription() { + return description; + } - @Override - public URLEntity[] getDescriptionEntities() { - return descriptionEntities; - } + @Override + public URLEntity[] getDescriptionEntities() { + return descriptionEntities; + } - /** - * {@inheritDoc} - */ - @Override - public int getFavouritesCount() { - return favouritesCount; - } + /** + * {@inheritDoc} + */ + @Override + public int getFavouritesCount() { + return favouritesCount; + } - /** - * {@inheritDoc} - */ - @Override - public int getFollowersCount() { - return followersCount; - } + /** + * {@inheritDoc} + */ + @Override + public int getFollowersCount() { + return followersCount; + } - /** - * {@inheritDoc} - */ - @Override - public int getFriendsCount() { - return friendsCount; - } + /** + * {@inheritDoc} + */ + @Override + public int getFriendsCount() { + return friendsCount; + } - /** - * {@inheritDoc} - */ - @Override - public long getId() { - return id; - } + /** + * {@inheritDoc} + */ + @Override + public long getId() { + return id; + } - /** - * {@inheritDoc} - */ - @Override - public String getLang() { - return lang; - } + /** + * {@inheritDoc} + */ + @Override + public String getLang() { + return lang; + } - /** - * {@inheritDoc} - */ - @Override - public int getListedCount() { - return listedCount; - } + /** + * {@inheritDoc} + */ + @Override + public int getListedCount() { + return listedCount; + } - /** - * {@inheritDoc} - */ - @Override - public String getLocation() { - return location; - } + /** + * {@inheritDoc} + */ + @Override + public String getLocation() { + return location; + } - /** - * {@inheritDoc} - */ - @Override - public String getName() { - return name; - } + /** + * {@inheritDoc} + */ + @Override + public String getName() { + return name; + } - /** - * {@inheritDoc} - */ - @Override - public String getProfileBackgroundColor() { - return profileBackgroundColor; - } + /** + * {@inheritDoc} + */ + @Override + public String getProfileBackgroundColor() { + return profileBackgroundColor; + } - /** - * {@inheritDoc} - */ - @Override - public String getProfileBackgroundImageUrl() { - return profileBackgroundImageUrl; - } + /** + * {@inheritDoc} + */ + @Override + public String getProfileBackgroundImageUrl() { + return profileBackgroundImageUrl; + } - /** - * {@inheritDoc} - */ - @Override - public String getProfileBackgroundImageUrlHttps() { - return profileBackgroundImageUrlHttps; - } + /** + * {@inheritDoc} + */ + @Override + public String getProfileBackgroundImageUrlHttps() { + return profileBackgroundImageUrlHttps; + } - @Override - public String getProfileBannerImageUrl() { - return profileBannerImageUrl; - } + @Override + public String getProfileBannerImageUrl() { + return profileBannerImageUrl; + } - /** - * {@inheritDoc} - */ - @Override - public URL getProfileImageURL() { - try { - return new URL(profileImageUrl); - } catch (final MalformedURLException ex) { - return null; - } - } + /** + * {@inheritDoc} + */ + @Override + public String getProfileImageURL() { + return profileImageUrl; + } - /** - * {@inheritDoc} - */ - @Override - public URL getProfileImageUrlHttps() { - if (null == profileImageUrlHttps) return null; - try { - return new URL(profileImageUrlHttps); - } catch (final MalformedURLException ex) { - return null; - } - } + /** + * {@inheritDoc} + */ + @Override + public String getProfileImageUrlHttps() { + return profileImageUrlHttps; + } - /** - * {@inheritDoc} - */ - @Override - public String getProfileLinkColor() { - return profileLinkColor; - } + /** + * {@inheritDoc} + */ + @Override + public String getProfileLinkColor() { + return profileLinkColor; + } - /** - * {@inheritDoc} - */ - @Override - public String getProfileSidebarBorderColor() { - return profileSidebarBorderColor; - } + /** + * {@inheritDoc} + */ + @Override + public String getProfileSidebarBorderColor() { + return profileSidebarBorderColor; + } - /** - * {@inheritDoc} - */ - @Override - public String getProfileSidebarFillColor() { - return profileSidebarFillColor; - } + /** + * {@inheritDoc} + */ + @Override + public String getProfileSidebarFillColor() { + return profileSidebarFillColor; + } - @Override - public String getProfileTextColor() { - return profileTextColor; - } + @Override + public String getProfileTextColor() { + return profileTextColor; + } - /** - * {@inheritDoc} - */ - @Override - public String getScreenName() { - return screenName; - } + /** + * {@inheritDoc} + */ + @Override + public String getScreenName() { + return screenName; + } - /** - * {@inheritDoc} - */ - @Override - public Status getStatus() { - return status; - } + /** + * {@inheritDoc} + */ + @Override + public Status getStatus() { + return status; + } - /** - * {@inheritDoc} - */ - @Override - public int getStatusesCount() { - return statusesCount; - } + /** + * {@inheritDoc} + */ + @Override + public int getStatusesCount() { + return statusesCount; + } - /** - * {@inheritDoc} - */ - @Override - public String getTimeZone() { - return timeZone; - } + /** + * {@inheritDoc} + */ + @Override + public String getTimeZone() { + return timeZone; + } - /** - * {@inheritDoc} - */ - @Override - public URL getURL() { - try { - return new URL(url); - } catch (final MalformedURLException ex) { - return null; - } - } + /** + * {@inheritDoc} + */ + @Override + public String getURL() { + return url; + } - @Override - public URLEntity[] getURLEntities() { - return urlEntities; - } + @Override + public URLEntity[] getURLEntities() { + return urlEntities; + } - /** - * {@inheritDoc} - */ - @Override - public int getUtcOffset() { - return utcOffset; - } + /** + * {@inheritDoc} + */ + @Override + public int getUtcOffset() { + return utcOffset; + } - @Override - public int hashCode() { - return (int) id; - } + @Override + public int hashCode() { + return (int) id; + } - /** - * {@inheritDoc} - */ - @Override - public boolean isContributorsEnabled() { - return isContributorsEnabled; - } + /** + * {@inheritDoc} + */ + @Override + public boolean isContributorsEnabled() { + return isContributorsEnabled; + } - @Override - public boolean isDefaultProfileImage() { - return isDefaultProfileImage; - } + @Override + public boolean isDefaultProfileImage() { + return isDefaultProfileImage; + } - @Override - public boolean isFollowing() { - return isFollowing; - } + @Override + public boolean isFollowing() { + return isFollowing; + } - /** - * {@inheritDoc} - */ - @Override - public boolean isFollowRequestSent() { - return isFollowRequestSent; - } + /** + * {@inheritDoc} + */ + @Override + public boolean isFollowRequestSent() { + return isFollowRequestSent; + } - /** - * {@inheritDoc} - */ - @Override - public boolean isGeoEnabled() { - return isGeoEnabled; - } + /** + * {@inheritDoc} + */ + @Override + public boolean isGeoEnabled() { + return isGeoEnabled; + } - /** - * {@inheritDoc} - */ - @Override - public boolean isProfileBackgroundTiled() { - return profileBackgroundTiled; - } + /** + * {@inheritDoc} + */ + @Override + public boolean isProfileBackgroundTiled() { + return profileBackgroundTiled; + } - /** - * {@inheritDoc} - */ - @Override - public boolean isProfileUseBackgroundImage() { - return profileUseBackgroundImage; - } + /** + * {@inheritDoc} + */ + @Override + public boolean isProfileUseBackgroundImage() { + return profileUseBackgroundImage; + } - /** - * {@inheritDoc} - */ - @Override - public boolean isProtected() { - return isProtected; - } + /** + * {@inheritDoc} + */ + @Override + public boolean isProtected() { + return isProtected; + } - /** - * {@inheritDoc} - */ - @Override - public boolean isShowAllInlineMedia() { - return showAllInlineMedia; - } + /** + * {@inheritDoc} + */ + @Override + public boolean isShowAllInlineMedia() { + return showAllInlineMedia; + } - /** - * {@inheritDoc} - */ - @Override - public boolean isTranslator() { - return isTranslator; - } + /** + * {@inheritDoc} + */ + @Override + public boolean isTranslator() { + return isTranslator; + } - /** - * {@inheritDoc} - */ - @Override - public boolean isVerified() { - return isVerified; - } + /** + * {@inheritDoc} + */ + @Override + public boolean isVerified() { + return isVerified; + } - @Override - public String toString() { - return "UserJSONImpl{" + "id=" + id + ", name='" + name + '\'' + ", screenName='" + screenName + '\'' - + ", location='" + location + '\'' + ", description='" + description + '\'' - + ", isContributorsEnabled=" + isContributorsEnabled + ", profileImageUrl='" + profileImageUrl + '\'' - + ", profileImageUrlHttps='" + profileImageUrlHttps + '\'' + ", url='" + url + '\'' + ", isProtected=" - + isProtected + ", followersCount=" + followersCount + ", status=" + status - + ", profileBackgroundColor='" + profileBackgroundColor + '\'' + ", profileTextColor='" - + profileTextColor + '\'' + ", profileLinkColor='" + profileLinkColor + '\'' - + ", profileSidebarFillColor='" + profileSidebarFillColor + '\'' + ", profileSidebarBorderColor='" - + profileSidebarBorderColor + '\'' + ", profileUseBackgroundImage=" + profileUseBackgroundImage - + ", showAllInlineMedia=" + showAllInlineMedia + ", friendsCount=" + friendsCount + ", createdAt=" - + createdAt + ", favouritesCount=" + favouritesCount + ", utcOffset=" + utcOffset + ", timeZone='" - + timeZone + '\'' + ", profileBackgroundImageUrl='" + profileBackgroundImageUrl + '\'' - + ", profileBackgroundImageUrlHttps='" + profileBackgroundImageUrlHttps + '\'' - + ", profileBackgroundTiled=" + profileBackgroundTiled + ", lang='" + lang + '\'' + ", statusesCount=" - + statusesCount + ", isGeoEnabled=" + isGeoEnabled + ", isVerified=" + isVerified + ", isTranslator=" - + isTranslator + ", listedCount=" + listedCount + ", isFollowRequestSent=" + isFollowRequestSent + '}'; - } + @Override + public String toString() { + return "UserJSONImpl{" + "id=" + id + ", name='" + name + '\'' + ", screenName='" + screenName + '\'' + + ", location='" + location + '\'' + ", description='" + description + '\'' + + ", isContributorsEnabled=" + isContributorsEnabled + ", profileImageUrl='" + profileImageUrl + '\'' + + ", profileImageUrlHttps='" + profileImageUrlHttps + '\'' + ", url='" + url + '\'' + ", isProtected=" + + isProtected + ", followersCount=" + followersCount + ", status=" + status + + ", profileBackgroundColor='" + profileBackgroundColor + '\'' + ", profileTextColor='" + + profileTextColor + '\'' + ", profileLinkColor='" + profileLinkColor + '\'' + + ", profileSidebarFillColor='" + profileSidebarFillColor + '\'' + ", profileSidebarBorderColor='" + + profileSidebarBorderColor + '\'' + ", profileUseBackgroundImage=" + profileUseBackgroundImage + + ", showAllInlineMedia=" + showAllInlineMedia + ", friendsCount=" + friendsCount + ", createdAt=" + + createdAt + ", favouritesCount=" + favouritesCount + ", utcOffset=" + utcOffset + ", timeZone='" + + timeZone + '\'' + ", profileBackgroundImageUrl='" + profileBackgroundImageUrl + '\'' + + ", profileBackgroundImageUrlHttps='" + profileBackgroundImageUrlHttps + '\'' + + ", profileBackgroundTiled=" + profileBackgroundTiled + ", lang='" + lang + '\'' + ", statusesCount=" + + statusesCount + ", isGeoEnabled=" + isGeoEnabled + ", isVerified=" + isVerified + ", isTranslator=" + + isTranslator + ", listedCount=" + listedCount + ", isFollowRequestSent=" + isFollowRequestSent + '}'; + } - private void init(final JSONObject json) throws TwitterException { - try { - id = getLong("id", json); - name = getRawString("name", json); - screenName = getRawString("screen_name", json); - location = getRawString("location", json); - description = getRawString("description", json); - isContributorsEnabled = getBoolean("contributors_enabled", json); - profileImageUrl = getRawString("profile_image_url", json); - profileImageUrlHttps = getRawString("profile_image_url_https", json); - url = getRawString("url", json); - isProtected = getBoolean("protected", json); - isGeoEnabled = getBoolean("geo_enabled", json); - isVerified = getBoolean("verified", json); - isTranslator = getBoolean("is_translator", json); - isFollowing = getBoolean("following", json); - followersCount = getInt("followers_count", json); - profileBannerImageUrl = getRawString("profile_banner_url", json); - profileBackgroundColor = getRawString("profile_background_color", json); - profileTextColor = getRawString("profile_text_color", json); - profileLinkColor = getRawString("profile_link_color", json); - profileSidebarFillColor = getRawString("profile_sidebar_fill_color", json); - profileSidebarBorderColor = getRawString("profile_sidebar_border_color", json); - profileUseBackgroundImage = getBoolean("profile_use_background_image", json); - showAllInlineMedia = getBoolean("show_all_inline_media", json); - friendsCount = getInt("friends_count", json); - createdAt = getDate("created_at", json, "EEE MMM dd HH:mm:ss z yyyy"); - favouritesCount = getInt("favourites_count", json); - utcOffset = getInt("utc_offset", json); - timeZone = getRawString("time_zone", json); - profileBackgroundImageUrl = getRawString("profile_background_image_url", json); - profileBackgroundImageUrlHttps = getRawString("profile_background_image_url_https", json); - profileBackgroundTiled = getBoolean("profile_background_tile", json); - lang = getRawString("lang", json); - statusesCount = getInt("statuses_count", json); - listedCount = getInt("listed_count", json); - isFollowRequestSent = getBoolean("follow_request_sent", json); - isDefaultProfileImage = getBoolean("default_profile_image", json); - if (!json.isNull("status")) { - final JSONObject statusJSON = json.getJSONObject("status"); - status = new StatusJSONImpl(statusJSON); - } - if (!json.isNull("entities")) { - try { - final JSONObject entities = json.getJSONObject("entities"); - int len; - if (!entities.isNull("description")) { - final JSONObject description = entities.getJSONObject("description"); - if (!description.isNull("urls")) { - final JSONArray urlsArray = description.getJSONArray("urls"); - len = urlsArray.length(); - descriptionEntities = new URLEntity[len]; - for (int i = 0; i < len; i++) { - descriptionEntities[i] = new URLEntityJSONImpl(urlsArray.getJSONObject(i)); - } - } - } - if (!entities.isNull("url")) { - final JSONObject url = entities.getJSONObject("url"); - if (!url.isNull("urls")) { - final JSONArray urlsArray = url.getJSONArray("urls"); - len = urlsArray.length(); - urlEntities = new URLEntity[len]; - for (int i = 0; i < len; i++) { - urlEntities[i] = new URLEntityJSONImpl(urlsArray.getJSONObject(i)); - } - } - } - } catch (final JSONException jsone) { - throw new TwitterException(jsone); - } - } - } catch (final JSONException jsone) { - throw new TwitterException(jsone.getMessage() + ":" + json.toString(), jsone); - } - } + private void init(final JSONObject json) throws TwitterException { + try { + id = getLong("id", json); + name = getRawString("name", json); + screenName = getRawString("screen_name", json); + location = getRawString("location", json); + description = getRawString("description", json); + isContributorsEnabled = getBoolean("contributors_enabled", json); + profileImageUrl = getRawString("profile_image_url", json); + profileImageUrlHttps = getRawString("profile_image_url_https", json); + url = getRawString("url", json); + isProtected = getBoolean("protected", json); + isGeoEnabled = getBoolean("geo_enabled", json); + isVerified = getBoolean("verified", json); + isTranslator = getBoolean("is_translator", json); + isFollowing = getBoolean("following", json); + followersCount = getInt("followers_count", json); + profileBannerImageUrl = getRawString("profile_banner_url", json); + profileBackgroundColor = getRawString("profile_background_color", json); + profileTextColor = getRawString("profile_text_color", json); + profileLinkColor = getRawString("profile_link_color", json); + profileSidebarFillColor = getRawString("profile_sidebar_fill_color", json); + profileSidebarBorderColor = getRawString("profile_sidebar_border_color", json); + profileUseBackgroundImage = getBoolean("profile_use_background_image", json); + showAllInlineMedia = getBoolean("show_all_inline_media", json); + friendsCount = getInt("friends_count", json); + createdAt = getDate("created_at", json, "EEE MMM dd HH:mm:ss z yyyy"); + favouritesCount = getInt("favourites_count", json); + utcOffset = getInt("utc_offset", json); + timeZone = getRawString("time_zone", json); + profileBackgroundImageUrl = getRawString("profile_background_image_url", json); + profileBackgroundImageUrlHttps = getRawString("profile_background_image_url_https", json); + profileBackgroundTiled = getBoolean("profile_background_tile", json); + lang = getRawString("lang", json); + statusesCount = getInt("statuses_count", json); + listedCount = getInt("listed_count", json); + isFollowRequestSent = getBoolean("follow_request_sent", json); + isDefaultProfileImage = getBoolean("default_profile_image", json); + if (!json.isNull("status")) { + final JSONObject statusJSON = json.getJSONObject("status"); + status = new StatusJSONImpl(statusJSON); + } + if (!json.isNull("entities")) { + try { + final JSONObject entities = json.getJSONObject("entities"); + int len; + if (!entities.isNull("description")) { + final JSONObject description = entities.getJSONObject("description"); + if (!description.isNull("urls")) { + final JSONArray urlsArray = description.getJSONArray("urls"); + len = urlsArray.length(); + descriptionEntities = new URLEntity[len]; + for (int i = 0; i < len; i++) { + descriptionEntities[i] = new URLEntityJSONImpl(urlsArray.getJSONObject(i)); + } + } + } + if (!entities.isNull("url")) { + final JSONObject url = entities.getJSONObject("url"); + if (!url.isNull("urls")) { + final JSONArray urlsArray = url.getJSONArray("urls"); + len = urlsArray.length(); + urlEntities = new URLEntity[len]; + for (int i = 0; i < len; i++) { + urlEntities[i] = new URLEntityJSONImpl(urlsArray.getJSONObject(i)); + } + } + } + } catch (final JSONException jsone) { + throw new TwitterException(jsone); + } + } + } catch (final JSONException jsone) { + throw new TwitterException(jsone.getMessage() + ":" + json.toString(), jsone); + } + } - /* package */ - static PageableResponseList createPagableUserList(final HttpResponse res, final Configuration conf) - throws TwitterException { - try { - final JSONObject json = res.asJSONObject(); - final JSONArray list = json.getJSONArray("users"); - final int size = list.length(); - @SuppressWarnings("unchecked") - final PageableResponseList users = new PageableResponseListImpl(size, json, res); - for (int i = 0; i < size; i++) { - final JSONObject userJson = list.getJSONObject(i); - final User user = new UserJSONImpl(userJson); - users.add(user); - } - return users; - } catch (final JSONException jsone) { - throw new TwitterException(jsone); - } catch (final TwitterException te) { - throw te; - } - } + /* package */ + static PageableResponseList createPagableUserList(final HttpResponse res, final Configuration conf) + throws TwitterException { + try { + final JSONObject json = res.asJSONObject(); + final JSONArray list = json.getJSONArray("users"); + final int size = list.length(); + @SuppressWarnings("unchecked") + final PageableResponseList users = new PageableResponseListImpl(size, json, res); + for (int i = 0; i < size; i++) { + final JSONObject userJson = list.getJSONObject(i); + final User user = new UserJSONImpl(userJson); + users.add(user); + } + return users; + } catch (final JSONException jsone) { + throw new TwitterException(jsone); + } catch (final TwitterException te) { + throw te; + } + } - /* package */ - static ResponseList createUserList(final HttpResponse res, final Configuration conf) throws TwitterException { - return createUserList(res.asJSONArray(), res, conf); - } + /* package */ + static ResponseList createUserList(final HttpResponse res, final Configuration conf) throws TwitterException { + return createUserList(res.asJSONArray(), res, conf); + } - /* package */ - static ResponseList createUserList(final JSONArray list, final HttpResponse res, final Configuration conf) - throws TwitterException { - try { - final int size = list.length(); - final ResponseList users = new ResponseListImpl(size, res); - for (int i = 0; i < size; i++) { - final JSONObject json = list.getJSONObject(i); - final User user = new UserJSONImpl(json); - users.add(user); - } - return users; - } catch (final JSONException jsone) { - throw new TwitterException(jsone); - } catch (final TwitterException te) { - throw te; - } - } + /* package */ + static ResponseList createUserList(final JSONArray list, final HttpResponse res, final Configuration conf) + throws TwitterException { + try { + final int size = list.length(); + final ResponseList users = new ResponseListImpl(size, res); + for (int i = 0; i < size; i++) { + final JSONObject json = list.getJSONObject(i); + final User user = new UserJSONImpl(json); + users.add(user); + } + return users; + } catch (final JSONException jsone) { + throw new TwitterException(jsone); + } catch (final TwitterException te) { + throw te; + } + } } diff --git a/twidere/src/main/AndroidManifest.xml b/twidere/src/main/AndroidManifest.xml index 3d44fba1e..ddce1a4d8 100644 --- a/twidere/src/main/AndroidManifest.xml +++ b/twidere/src/main/AndroidManifest.xml @@ -1,6 +1,7 @@ - @@ -45,18 +46,18 @@ + android:label="@string/usage_statistics" + android:theme="@android:style/Theme.NoDisplay"/> + android:label="@string/label_tweetstore_provider" + tools:ignore="ExportedContentProvider"/> + android:exported="true" + tools:ignore="ExportedContentProvider"/> + android:authorities="org.mariotaku.twidere.provider.SearchRecentSuggestions" + tools:ignore="ExportedContentProvider"/> + + + + + diff --git a/twidere/src/main/java/org/mariotaku/twidere/Constants.java b/twidere/src/main/java/org/mariotaku/twidere/Constants.java index 1dfea7834..9916328a6 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/Constants.java +++ b/twidere/src/main/java/org/mariotaku/twidere/Constants.java @@ -33,7 +33,7 @@ import static org.mariotaku.twidere.annotation.Preference.Type.STRING; public interface Constants extends TwidereConstants { String DATABASES_NAME = "twidere.sqlite"; - int DATABASES_VERSION = 94; + int DATABASES_VERSION = 95; int MENU_GROUP_STATUS_EXTENSION = 10; int MENU_GROUP_COMPOSE_EXTENSION = 11; diff --git a/twidere/src/main/java/org/mariotaku/twidere/activity/SettingsActivity.java b/twidere/src/main/java/org/mariotaku/twidere/activity/SettingsActivity.java index 15d4b9eae..9154dfa4b 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/activity/SettingsActivity.java +++ b/twidere/src/main/java/org/mariotaku/twidere/activity/SettingsActivity.java @@ -20,6 +20,7 @@ package org.mariotaku.twidere.activity; import android.app.ActionBar; +import android.app.Activity; import android.app.Fragment; import android.content.ComponentName; import android.content.Context; @@ -74,6 +75,17 @@ public class SettingsActivity extends BasePreferenceActivity { private String mThemeFontFamily; private String mThemeBackground; + private boolean mShouldNotifyChange; + + public static void setShouldNotifyChange(Activity activity) { + if (!(activity instanceof SettingsActivity)) return; + ((SettingsActivity) activity).setShouldNotifyChange(true); + } + + private void setShouldNotifyChange(boolean notify) { + mShouldNotifyChange = notify; + } + @Override public void finish() { if (shouldNotifyThemeChange()) { @@ -84,11 +96,33 @@ public class SettingsActivity extends BasePreferenceActivity { super.finish(); } + /** + * {@inheritDoc} + */ + @Override + public void startWithFragment(String fragmentName, Bundle args, + Fragment resultTo, int resultRequestCode, int titleRes, int shortTitleRes) { + Intent intent = onBuildStartFragmentIntent(fragmentName, args, titleRes, shortTitleRes); + if (resultTo == null) { + startActivityForResult(intent, resultRequestCode); + } else { + resultTo.startActivityForResult(intent, resultRequestCode); + } + } + public HeaderAdapter getHeaderAdapter() { if (mAdapter != null) return mAdapter; return mAdapter = new HeaderAdapter(this); } + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + if (resultCode == RESULT_OK && data != null && data.getBooleanExtra(EXTRA_RESTART_ACTIVITY, false)) { + setShouldNotifyChange(true); + } + super.onActivityResult(requestCode, resultCode, data); + } + @Override public void onBuildHeaders(final List
target) { loadHeadersFromResource(R.xml.settings_headers, target); @@ -222,6 +256,7 @@ public class SettingsActivity extends BasePreferenceActivity { } private boolean shouldNotifyThemeChange() { + if (mShouldNotifyChange) return true; return !CompareUtils.objectEquals(mTheme, mPreferences.getString(KEY_THEME, DEFAULT_THEME)) || !CompareUtils.objectEquals(mThemeFontFamily, mPreferences.getString(KEY_THEME_FONT_FAMILY, DEFAULT_THEME_FONT_FAMILY)) || !CompareUtils.objectEquals(mThemeBackground, mPreferences.getString(KEY_THEME_BACKGROUND, DEFAULT_THEME_BACKGROUND)) diff --git a/twidere/src/main/java/org/mariotaku/twidere/activity/support/QuickSearchBarActivity.java b/twidere/src/main/java/org/mariotaku/twidere/activity/support/QuickSearchBarActivity.java index 807115a17..18f9659c3 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/activity/support/QuickSearchBarActivity.java +++ b/twidere/src/main/java/org/mariotaku/twidere/activity/support/QuickSearchBarActivity.java @@ -574,8 +574,7 @@ public class QuickSearchBarActivity extends ThemedFragmentActivity implements On final String queryEscaped = mQuery.replace("_", "^_"); final SharedPreferences nicknamePrefs = context.getSharedPreferences( USER_NICKNAME_PREFERENCES_NAME, Context.MODE_PRIVATE); - final long[] nicknameIds = Utils.getMatchedNicknameIds(ParseUtils.parseString(mQuery), - nicknamePrefs); + final long[] nicknameIds = Utils.getMatchedNicknameIds(mQuery, nicknamePrefs); final Expression selection = Expression.or( Expression.likeRaw(new Column(CachedUsers.SCREEN_NAME), "?||'%'", "^"), Expression.likeRaw(new Column(CachedUsers.NAME), "?||'%'", "^"), diff --git a/twidere/src/main/java/org/mariotaku/twidere/fragment/CustomTabsFragment.java b/twidere/src/main/java/org/mariotaku/twidere/fragment/CustomTabsFragment.java index 63246515d..a1aeb2919 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/fragment/CustomTabsFragment.java +++ b/twidere/src/main/java/org/mariotaku/twidere/fragment/CustomTabsFragment.java @@ -59,6 +59,7 @@ import org.mariotaku.querybuilder.Columns.Column; import org.mariotaku.querybuilder.Expression; import org.mariotaku.querybuilder.RawItemArray; import org.mariotaku.twidere.R; +import org.mariotaku.twidere.activity.SettingsActivity; import org.mariotaku.twidere.activity.support.CustomTabEditorActivity; import org.mariotaku.twidere.model.CustomTabConfiguration; import org.mariotaku.twidere.model.CustomTabConfiguration.CustomTabConfigurationComparator; @@ -101,7 +102,8 @@ public class CustomTabsFragment extends BaseFragment implements LoaderCallbacks< public boolean onActionItemClicked(final ActionMode mode, final MenuItem item) { switch (item.getItemId()) { case MENU_DELETE: { - final Expression where = Expression.in(new Column(Tabs._ID), new RawItemArray(mListView.getCheckedItemIds())); + final long[] itemIds = mListView.getCheckedItemIds(); + final Expression where = Expression.in(new Column(Tabs._ID), new RawItemArray(itemIds)); mResolver.delete(Tabs.CONTENT_URI, where.getSQL(), null); break; } @@ -160,7 +162,6 @@ public class CustomTabsFragment extends BaseFragment implements LoaderCallbacks< mProgressContainer.setVisibility(shown ? View.GONE : View.VISIBLE); } - @Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); @@ -185,6 +186,7 @@ public class CustomTabsFragment extends BaseFragment implements LoaderCallbacks< values.put(Tabs.EXTRAS, data.getStringExtra(EXTRA_EXTRAS)); values.put(Tabs.POSITION, mAdapter.getCount()); mResolver.insert(Tabs.CONTENT_URI, values); + SettingsActivity.setShouldNotifyChange(getActivity()); } break; } @@ -196,6 +198,7 @@ public class CustomTabsFragment extends BaseFragment implements LoaderCallbacks< values.put(Tabs.EXTRAS, data.getStringExtra(EXTRA_EXTRAS)); final String where = Expression.equals(Tabs._ID, data.getLongExtra(EXTRA_ID, -1)).getSQL(); mResolver.update(Tabs.CONTENT_URI, values, where, null); + SettingsActivity.setShouldNotifyChange(getActivity()); } break; } @@ -326,6 +329,7 @@ public class CustomTabsFragment extends BaseFragment implements LoaderCallbacks< mResolver.update(Tabs.CONTENT_URI, values, where, null); } } + SettingsActivity.setShouldNotifyChange(getActivity()); } private void updateTitle(final ActionMode mode) { diff --git a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/MessagesConversationFragment.java b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/MessagesConversationFragment.java index 2dac2b076..25a6f9148 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/MessagesConversationFragment.java +++ b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/MessagesConversationFragment.java @@ -758,7 +758,7 @@ public class MessagesConversationFragment extends BaseSupportFragment implements final String[] selectionArgs; if (queryEscaped != null) { final SharedPreferences nicknamePrefs = context.getSharedPreferences(USER_NICKNAME_PREFERENCES_NAME, Context.MODE_PRIVATE); - final long[] nicknameIds = Utils.getMatchedNicknameIds(ParseUtils.parseString(query), nicknamePrefs); + final long[] nicknameIds = Utils.getMatchedNicknameIds(query, nicknamePrefs); selection = Expression.or(Expression.likeRaw(new Column(CachedUsers.SCREEN_NAME), "?||'%'", "^"), Expression.likeRaw(new Column(CachedUsers.NAME), "?||'%'", "^"), Expression.in(new Column(CachedUsers.USER_ID), new RawItemArray(nicknameIds))); 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 05ad6d08e..eadb45757 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 @@ -596,6 +596,10 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac retweetedByContainer.setVisibility(View.GONE); } + + final int typeIconRes, typeDescriptionRes; + final long timestamp; + final String source; if (status.is_quote) { quotedNameView.setText(getUserNickname(context, status.user_id, status.user_name, true)); quotedScreenNameView.setText("@" + status.user_screen_name); @@ -614,6 +618,11 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac quoteTextView.setVisibility(View.VISIBLE); quoteIndicator.setVisibility(View.VISIBLE); + 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); + + timestamp = status.quote_timestamp; + source = status.quote_source; } else { nameView.setText(getUserNickname(context, status.user_id, status.user_name, true)); screenNameView.setText("@" + status.user_screen_name); @@ -623,25 +632,39 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac quotedNameContainer.setVisibility(View.GONE); quoteTextView.setVisibility(View.GONE); quoteIndicator.setVisibility(View.GONE); + + typeIconRes = getUserTypeIconRes(status.user_is_verified, status.user_is_protected); + typeDescriptionRes = Utils.getUserTypeDescriptionRes(status.user_is_verified, status.user_is_protected); + + timestamp = status.timestamp; + source = status.source; } + if (typeIconRes != 0 && typeDescriptionRes != 0) { + profileTypeView.setImageResource(typeIconRes); + profileTypeView.setContentDescription(context.getString(typeDescriptionRes)); + profileTypeView.setVisibility(View.VISIBLE); + } else { + profileTypeView.setImageDrawable(null); + profileTypeView.setContentDescription(null); + profileTypeView.setVisibility(View.GONE); + } + + final String timeString = formatToLongTimeString(context, timestamp); + if (!isEmpty(timeString) && !isEmpty(source)) { + timeSourceView.setText(Html.fromHtml(context.getString(R.string.time_source, timeString, source))); + } else if (isEmpty(timeString) && !isEmpty(source)) { + timeSourceView.setText(Html.fromHtml(context.getString(R.string.source, source))); + } else if (!isEmpty(timeString) && isEmpty(source)) { + timeSourceView.setText(timeString); + } + timeSourceView.setMovementMethod(LinkMovementMethod.getInstance()); + + textView.setText(Html.fromHtml(status.text_html)); linkify.applyAllLinks(textView, status.account_id, getAdapterPosition(), status.is_possibly_sensitive); ThemeUtils.applyParagraphSpacing(textView, 1.1f); - final String timeString = formatToLongTimeString(context, status.timestamp); - final String sourceHtml = status.source; - if (!isEmpty(timeString) && !isEmpty(sourceHtml)) { - timeSourceView.setText(Html.fromHtml(context.getString(R.string.time_source, - timeString, sourceHtml))); - } else if (isEmpty(timeString) && !isEmpty(sourceHtml)) { - timeSourceView.setText(Html.fromHtml(context.getString(R.string.source, - sourceHtml))); - } else if (!isEmpty(timeString) && isEmpty(sourceHtml)) { - timeSourceView.setText(timeString); - } - timeSourceView.setMovementMethod(LinkMovementMethod.getInstance()); - if (!TextUtils.isEmpty(status.place_full_name)) { locationView.setVisibility(View.VISIBLE); locationView.setText(status.place_full_name); @@ -662,30 +685,23 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac retweetsCountView.setText(getLocalizedNumber(locale, status.retweet_count)); favoritesCountView.setText(getLocalizedNumber(locale, status.favorite_count)); - final int typeIconRes = getUserTypeIconRes(status.user_is_verified, status.user_is_protected); - final int typeDescriptionRes = Utils.getUserTypeDescriptionRes(status.user_is_verified, status.user_is_protected); - if (typeIconRes != 0 && typeDescriptionRes != 0) { - profileTypeView.setImageResource(typeIconRes); - profileTypeView.setContentDescription(context.getString(typeDescriptionRes)); - profileTypeView.setVisibility(View.VISIBLE); - } else { - profileTypeView.setImageDrawable(null); - profileTypeView.setContentDescription(null); - profileTypeView.setVisibility(View.GONE); - } if (status.media == null) { mediaPreviewContainer.setVisibility(View.GONE); + mediaPreview.setVisibility(View.GONE); + mediaPreviewLoad.setVisibility(View.GONE); + mediaPreview.displayMedia(); } else if (adapter.isDetailMediaExpanded()) { mediaPreviewContainer.setVisibility(View.VISIBLE); - mediaPreviewLoad.setVisibility(View.GONE); mediaPreview.setVisibility(View.VISIBLE); + mediaPreviewLoad.setVisibility(View.GONE); mediaPreview.displayMedia(status.media, loader, status.account_id, adapter.getFragment(), adapter.getImageLoadingHandler()); } else { mediaPreviewContainer.setVisibility(View.VISIBLE); - mediaPreviewLoad.setVisibility(View.VISIBLE); mediaPreview.setVisibility(View.GONE); + mediaPreviewLoad.setVisibility(View.VISIBLE); + mediaPreview.displayMedia(); } if (TwitterCardUtils.isCardSupported(status.card)) { @@ -786,6 +802,8 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac locationView.setTextSize(defaultTextSize * 0.85f); timeSourceView.setTextSize(defaultTextSize * 0.85f); + mediaPreview.setStyle(adapter.getMediaPreviewStyle()); + textView.setMovementMethod(StatusContentMovementMethod.getInstance()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { quoteTextView.setCustomSelectionActionModeCallback(new StatusActionModeCallback(quoteTextView, fragment, activity)); diff --git a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/UserFragment.java b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/UserFragment.java index 6a16f7d86..196bc66a1 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/UserFragment.java +++ b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/UserFragment.java @@ -114,6 +114,8 @@ import org.mariotaku.twidere.util.TwidereLinkify; import org.mariotaku.twidere.util.TwidereLinkify.OnLinkClickListener; import org.mariotaku.twidere.util.UserColorNameUtils; import org.mariotaku.twidere.util.Utils; +import org.mariotaku.twidere.util.accessor.ActivityAccessor; +import org.mariotaku.twidere.util.accessor.ActivityAccessor.TaskDescriptionCompat; import org.mariotaku.twidere.util.accessor.ViewAccessor; import org.mariotaku.twidere.util.menu.TwidereMenuInfo; import org.mariotaku.twidere.util.message.FriendshipUpdatedEvent; @@ -723,6 +725,7 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener mProfileNameBackground.setBackgroundColor(mCardBackgroundColor); mProfileDetailsContainer.setBackgroundColor(mCardBackgroundColor); + mPagerIndicator.setBackgroundColor(mCardBackgroundColor); mUuckyFooter.setBackgroundColor(mCardBackgroundColor); getUserInfo(accountId, userId, screenName, false); @@ -1257,9 +1260,11 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener final int actionBarColor = getResources().getColor(R.color.background_color_action_bar_dark); mTintedStatusContent.setColor(actionBarColor, themed.getCurrentThemeBackgroundAlpha()); mActionBarBackground.setColor(actionBarColor); + ActivityAccessor.setTaskDescription(activity, new TaskDescriptionCompat(null, null, actionBarColor)); } else { mTintedStatusContent.setColor(color, themed.getCurrentThemeBackgroundAlpha()); mActionBarBackground.setColor(color); + ActivityAccessor.setTaskDescription(activity, new TaskDescriptionCompat(null, null, color)); } mDescriptionView.setLinkTextColor(color); mProfileBannerView.setBackgroundColor(color); diff --git a/twidere/src/main/java/org/mariotaku/twidere/loader/support/TileImageLoader.java b/twidere/src/main/java/org/mariotaku/twidere/loader/support/TileImageLoader.java index a1a4c0b35..c8230460f 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/loader/support/TileImageLoader.java +++ b/twidere/src/main/java/org/mariotaku/twidere/loader/support/TileImageLoader.java @@ -38,7 +38,6 @@ import org.mariotaku.twidere.app.TwidereApplication; import org.mariotaku.twidere.util.BitmapUtils; import org.mariotaku.twidere.util.Exif; import org.mariotaku.twidere.util.ImageValidator; -import org.mariotaku.twidere.util.ParseUtils; import org.mariotaku.twidere.util.imageloader.AccountExtra; import java.io.File; @@ -79,7 +78,7 @@ public class TileImageLoader extends AsyncTaskLoader { } final String scheme = mUri.getScheme(); if ("http".equals(scheme) || "https".equals(scheme)) { - final String url = ParseUtils.parseString(mUri.toString()); + final String url = mUri.toString(); if (url == null) return Result.nullInstance(); final File cacheFile = mDiskCache.get(url); if (cacheFile != null) { 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 dd509c8b5..b1ccf0fed 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 @@ -335,15 +335,7 @@ public class StatusViewHolder extends RecyclerView.ViewHolder implements Constan replyRetweetIcon.setVisibility(View.GONE); } - final int typeIconRes = getUserTypeIconRes(cursor.getShort(indices.is_verified) == 1, - cursor.getShort(indices.is_protected) == 1); - if (typeIconRes != 0) { - profileTypeView.setImageResource(typeIconRes); - profileTypeView.setVisibility(View.VISIBLE); - } else { - profileTypeView.setImageDrawable(null); - profileTypeView.setVisibility(View.GONE); - } + final int typeIconRes; if (cursor.getShort(indices.is_quote) == 1) { quotedNameView.setText(user_name); @@ -380,6 +372,9 @@ public class StatusViewHolder extends RecyclerView.ViewHolder implements Constan final int userColor = UserColorNameUtils.getUserColor(context, cursor.getLong(indices.quoted_by_user_id)); itemContent.drawStart(userColor); + + typeIconRes = getUserTypeIconRes(cursor.getShort(indices.quoted_by_user_is_verified) == 1, + cursor.getShort(indices.quoted_by_user_is_protected) == 1); } else { nameView.setText(user_name); screenNameView.setText("@" + user_screen_name); @@ -401,8 +396,18 @@ public class StatusViewHolder extends RecyclerView.ViewHolder implements Constan } final int userColor = UserColorNameUtils.getUserColor(context, user_id); itemContent.drawStart(userColor); + + typeIconRes = getUserTypeIconRes(cursor.getShort(indices.is_verified) == 1, + cursor.getShort(indices.is_protected) == 1); } + if (typeIconRes != 0) { + profileTypeView.setImageResource(typeIconRes); + profileTypeView.setVisibility(View.VISIBLE); + } else { + profileTypeView.setImageDrawable(null); + profileTypeView.setVisibility(View.GONE); + } if (adapter.shouldShowAccountsColor()) { itemContent.drawEnd(Utils.getAccountColor(context, account_id)); diff --git a/twidere/src/main/res/layout/header_status_common.xml b/twidere/src/main/res/layout/header_status_common.xml index 71b27c0ad..9f3b6f193 100644 --- a/twidere/src/main/res/layout/header_status_common.xml +++ b/twidere/src/main/res/layout/header_status_common.xml @@ -226,14 +226,50 @@ tools:text="\@username"/> - + tools:visibility="visible"> + + + + + + + + + + + + + - - - - - - - - - - - - - - - - \ No newline at end of file