improved GNU social profile support
This commit is contained in:
parent
96a2fd46ff
commit
6f562b5582
|
@ -114,6 +114,11 @@ public class User extends TwitterResponseObject implements Comparable<User> {
|
|||
|
||||
@JsonField(name = "profile_background_color")
|
||||
String profileBackgroundColor;
|
||||
/**
|
||||
* For GNU social compatibility
|
||||
*/
|
||||
@JsonField(name = "backgroundcolor")
|
||||
String backgroundcolor;
|
||||
|
||||
@JsonField(name = "profile_background_image_url")
|
||||
String profileBackgroundImageUrl;
|
||||
|
@ -133,9 +138,21 @@ public class User extends TwitterResponseObject implements Comparable<User> {
|
|||
@JsonField(name = "profile_banner_url")
|
||||
String profileBannerUrl;
|
||||
|
||||
/**
|
||||
* For GNU social compatibility
|
||||
*/
|
||||
@JsonField(name = "cover_photo")
|
||||
String coverPhoto;
|
||||
|
||||
@JsonField(name = "profile_link_color")
|
||||
String profileLinkColor;
|
||||
|
||||
/**
|
||||
* For GNU social compatibility
|
||||
*/
|
||||
@JsonField(name = "linkcolor")
|
||||
String linkcolor;
|
||||
|
||||
@JsonField(name = "profile_sidebar_border_color")
|
||||
String profileSidebarBorderColor;
|
||||
|
||||
|
@ -301,7 +318,8 @@ public class User extends TwitterResponseObject implements Comparable<User> {
|
|||
|
||||
|
||||
public String getProfileBackgroundColor() {
|
||||
return profileBackgroundColor;
|
||||
if (profileBackgroundColor != null) return profileBackgroundColor;
|
||||
return backgroundcolor;
|
||||
}
|
||||
|
||||
|
||||
|
@ -316,7 +334,8 @@ public class User extends TwitterResponseObject implements Comparable<User> {
|
|||
|
||||
|
||||
public String getProfileBannerImageUrl() {
|
||||
return profileBannerUrl;
|
||||
if (profileBannerUrl != null) return profileBannerUrl;
|
||||
return coverPhoto;
|
||||
}
|
||||
|
||||
|
||||
|
@ -331,7 +350,8 @@ public class User extends TwitterResponseObject implements Comparable<User> {
|
|||
|
||||
|
||||
public String getProfileLinkColor() {
|
||||
return profileLinkColor;
|
||||
if (profileLinkColor != null) return profileLinkColor;
|
||||
return linkcolor;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -44,6 +44,7 @@ import org.mariotaku.twidere.model.ConsumerKeyType;
|
|||
import org.mariotaku.twidere.model.ParcelableStatus;
|
||||
import org.mariotaku.twidere.provider.TwidereDataStore.Filters;
|
||||
import org.mariotaku.twidere.util.collection.LongSparseMap;
|
||||
import org.mariotaku.twidere.util.media.preview.PreviewMediaExtractor;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
|
@ -328,4 +329,27 @@ public class TwitterContentUtils {
|
|||
return isFiltered(database, status.user_id, status.text_plain, status.text_html, status.source,
|
||||
status.retweeted_by_user_id, status.quoted_user_id, filter_rts);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String getBestBannerUrl(@Nullable final String baseUrl, final int width) {
|
||||
if (baseUrl == null) return null;
|
||||
final String type = getBestBannerType(width);
|
||||
final String authority = PreviewMediaExtractor.getAuthority(baseUrl);
|
||||
return authority != null && authority.endsWith(".twimg.com") ? baseUrl + "/" + type : baseUrl;
|
||||
}
|
||||
|
||||
public static String getBestBannerType(final int width) {
|
||||
if (width <= 320)
|
||||
return "mobile";
|
||||
else if (width <= 520)
|
||||
return "web";
|
||||
else if (width <= 626)
|
||||
return "ipad";
|
||||
else if (width <= 640)
|
||||
return "mobile_retina";
|
||||
else if (width <= 1040)
|
||||
return "web_retina";
|
||||
else
|
||||
return "ipad_retina";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -99,6 +99,7 @@ import org.mariotaku.twidere.util.MediaLoaderWrapper;
|
|||
import org.mariotaku.twidere.util.SharedPreferencesWrapper;
|
||||
import org.mariotaku.twidere.util.ThemeUtils;
|
||||
import org.mariotaku.twidere.util.TransitionUtils;
|
||||
import org.mariotaku.twidere.util.TwitterContentUtils;
|
||||
import org.mariotaku.twidere.util.UserColorNameManager;
|
||||
import org.mariotaku.twidere.util.Utils;
|
||||
import org.mariotaku.twidere.util.content.SupportFragmentReloadCursorObserver;
|
||||
|
@ -652,7 +653,7 @@ public class AccountsDashboardFragment extends BaseSupportFragment implements Lo
|
|||
final Resources res = getResources();
|
||||
final int defWidth = res.getDisplayMetrics().widthPixels;
|
||||
final int width = bannerWidth > 0 ? bannerWidth : defWidth;
|
||||
final String bannerUrl = Utils.getBestBannerUrl(account.profile_banner_url, width);
|
||||
final String bannerUrl = TwitterContentUtils.getBestBannerUrl(account.profile_banner_url, width);
|
||||
final ImageView bannerView = mAccountProfileBannerView;
|
||||
if (bannerView.getDrawable() == null || !CompareUtils.objectEquals(bannerUrl, bannerView.getTag())) {
|
||||
mMediaLoader.displayProfileBanner(mAccountProfileBannerView, bannerUrl, this);
|
||||
|
|
|
@ -35,7 +35,7 @@ import org.mariotaku.twidere.util.imageloader.OvalBitmapDisplayer;
|
|||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import static org.mariotaku.twidere.util.Utils.getBestBannerUrl;
|
||||
import static org.mariotaku.twidere.util.TwitterContentUtils.getBestBannerUrl;
|
||||
|
||||
@Singleton
|
||||
public class MediaLoaderWrapper implements Constants {
|
||||
|
|
|
@ -37,7 +37,6 @@ import android.content.pm.PackageManager;
|
|||
import android.content.pm.ResolveInfo;
|
||||
import android.content.res.Resources;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Color;
|
||||
|
@ -201,14 +200,13 @@ import org.mariotaku.twidere.provider.TwidereDataStore.CachedStatuses;
|
|||
import org.mariotaku.twidere.provider.TwidereDataStore.CachedUsers;
|
||||
import org.mariotaku.twidere.provider.TwidereDataStore.DirectMessages;
|
||||
import org.mariotaku.twidere.provider.TwidereDataStore.DirectMessages.ConversationEntries;
|
||||
import org.mariotaku.twidere.provider.TwidereDataStore.Filters;
|
||||
import org.mariotaku.twidere.provider.TwidereDataStore.Filters.Users;
|
||||
import org.mariotaku.twidere.provider.TwidereDataStore.Statuses;
|
||||
import org.mariotaku.twidere.service.RefreshService;
|
||||
import org.mariotaku.twidere.util.TwidereLinkify.HighlightStyle;
|
||||
import org.mariotaku.twidere.util.content.ContentResolverUtils;
|
||||
import org.mariotaku.twidere.util.media.preview.PreviewMediaExtractor;
|
||||
import org.mariotaku.twidere.util.menu.TwidereMenuInfo;
|
||||
import org.mariotaku.twidere.view.CardMediaContainer.OnMediaClickListener;
|
||||
import org.mariotaku.twidere.view.CardMediaContainer.PreviewStyle;
|
||||
import org.mariotaku.twidere.view.ShapedImageView;
|
||||
import org.mariotaku.twidere.view.ShapedImageView.ShapeStyle;
|
||||
|
@ -1150,27 +1148,6 @@ public final class Utils implements Constants {
|
|||
return cr.update(CachedUsers.CONTENT_URI, values, where.getSQL(), null) != 0;
|
||||
}
|
||||
|
||||
|
||||
public static String getBestBannerUrl(final String baseUrl, final int width) {
|
||||
final String type = getBestBannerType(width);
|
||||
return TextUtils.isEmpty(baseUrl) ? null : baseUrl + "/" + type;
|
||||
}
|
||||
|
||||
public static String getBestBannerType(final int width) {
|
||||
if (width <= 320)
|
||||
return "mobile";
|
||||
else if (width <= 520)
|
||||
return "web";
|
||||
else if (width <= 626)
|
||||
return "ipad";
|
||||
else if (width <= 640)
|
||||
return "mobile_retina";
|
||||
else if (width <= 1040)
|
||||
return "web_retina";
|
||||
else
|
||||
return "ipad_retina";
|
||||
}
|
||||
|
||||
public static File getBestCacheDir(final Context context, final String cacheDirName) {
|
||||
if (context == null) throw new NullPointerException();
|
||||
final File extCacheDir;
|
||||
|
|
Loading…
Reference in New Issue