diff --git a/twidere.component.common/src/main/java/org/mariotaku/twidere/model/ParcelableMedia.java b/twidere.component.common/src/main/java/org/mariotaku/twidere/model/ParcelableMedia.java index 23def7e30..0c66df265 100644 --- a/twidere.component.common/src/main/java/org/mariotaku/twidere/model/ParcelableMedia.java +++ b/twidere.component.common/src/main/java/org/mariotaku/twidere/model/ParcelableMedia.java @@ -76,6 +76,9 @@ public class ParcelableMedia implements Parcelable { public ParcelableCardEntity card; @JsonField(name = "page_url") String page_url; + @ParcelableThisPlease + @JsonField(name = "open_browser") + public boolean open_browser; public static final Creator CREATOR = new Creator() { public ParcelableMedia createFromParcel(Parcel source) { ParcelableMedia target = new ParcelableMedia(); diff --git a/twidere.component.common/src/main/java/org/mariotaku/twidere/util/media/preview/provider/InstagramProvider.java b/twidere.component.common/src/main/java/org/mariotaku/twidere/util/media/preview/provider/InstagramProvider.java index 603123490..5c0b667fc 100644 --- a/twidere.component.common/src/main/java/org/mariotaku/twidere/util/media/preview/provider/InstagramProvider.java +++ b/twidere.component.common/src/main/java/org/mariotaku/twidere/util/media/preview/provider/InstagramProvider.java @@ -35,6 +35,7 @@ public class InstagramProvider implements Provider { media.url = link; media.preview_url = String.format(Locale.ROOT, "https://instagram.com/p/%s/media/?size=m", id); media.media_url = String.format(Locale.ROOT, "https://instagram.com/p/%s/media/?size=l", id); + media.open_browser = true; return media; } diff --git a/twidere/build.gradle b/twidere/build.gradle index aa817c8ad..60e6ba1b8 100644 --- a/twidere/build.gradle +++ b/twidere/build.gradle @@ -90,7 +90,6 @@ dependencies { compile 'com.commonsware.cwac:layouts:0.4.2' compile 'com.rengwuxian.materialedittext:library:2.1.4' compile 'com.pnikosis:materialish-progress:1.7' - compile 'com.squareup.okhttp3:okhttp:3.1.0' compile 'pl.droidsonroids.gif:android-gif-drawable:1.1.7' compile 'com.github.johnpersano:supertoasts:1.3.4.1@aar' compile 'com.github.mariotaku:MessageBubbleView:1.2' diff --git a/twidere/src/main/java/org/mariotaku/twidere/activity/support/SignInActivity.java b/twidere/src/main/java/org/mariotaku/twidere/activity/support/SignInActivity.java index afc3f095c..75113be36 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/activity/support/SignInActivity.java +++ b/twidere/src/main/java/org/mariotaku/twidere/activity/support/SignInActivity.java @@ -750,15 +750,15 @@ public class SignInActivity extends BaseAppCompatActivity implements OnClickList final Endpoint endpoint = new Endpoint(TwitterAPIFactory.getApiUrl(apiUrlFormat, "api", versionSuffix)); final Authorization auth = new BasicAuthorization(username, password); final Twitter twitter = TwitterAPIFactory.getInstance(activity, endpoint, auth, Twitter.class); - User user = null; + User user; try { user = twitter.verifyCredentials(); } catch (TwitterException e) { if (e.getStatusCode() == 401) { throw new WrongBasicCredentialException(); } + throw e; } - if (user == null) throw new NullPointerException(); final long userId = user.getId(); if (userId <= 0) return new SignInResponse(false, false, null); if (isUserLoggedIn(activity, userId)) return new SignInResponse(true, false, null); diff --git a/twidere/src/main/java/org/mariotaku/twidere/util/StatusAdapterLinkClickHandler.java b/twidere/src/main/java/org/mariotaku/twidere/util/StatusAdapterLinkClickHandler.java index e0a3a1bbc..458e24523 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/util/StatusAdapterLinkClickHandler.java +++ b/twidere/src/main/java/org/mariotaku/twidere/util/StatusAdapterLinkClickHandler.java @@ -19,7 +19,6 @@ package org.mariotaku.twidere.util; -import android.os.Bundle; import android.support.v7.widget.RecyclerView; import org.mariotaku.twidere.adapter.iface.IStatusesAdapter; @@ -43,9 +42,11 @@ public class StatusAdapterLinkClickHandler extends OnLinkClickHandler { if (extraId == RecyclerView.NO_POSITION) return; final ParcelableStatus status = adapter.getStatus((int) extraId); final ParcelableMedia current = StatusLinkClickHandler.findByLink(status.media, link); - //TODO open media animation - Bundle options = null; - Utils.openMedia(context, status, current, options); + if (current != null && current.open_browser) { + openLink(link); + } else { + Utils.openMedia(context, status, current, null); + } } } diff --git a/twidere/src/main/java/org/mariotaku/twidere/util/StatusLinkClickHandler.java b/twidere/src/main/java/org/mariotaku/twidere/util/StatusLinkClickHandler.java index d35e4329e..6563be223 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/util/StatusLinkClickHandler.java +++ b/twidere/src/main/java/org/mariotaku/twidere/util/StatusLinkClickHandler.java @@ -20,7 +20,6 @@ package org.mariotaku.twidere.util; import android.content.Context; -import android.os.Bundle; import org.mariotaku.twidere.model.ParcelableMedia; import org.mariotaku.twidere.model.ParcelableStatus; @@ -36,9 +35,11 @@ public class StatusLinkClickHandler extends OnLinkClickHandler { protected void openMedia(long accountId, long extraId, boolean sensitive, String link, int start, int end) { final ParcelableStatus status = mStatus; final ParcelableMedia current = findByLink(status.media, link); - //TODO open media animation - Bundle options = null; - Utils.openMedia(context, status, current, options); + if (current.open_browser) { + openLink(link); + } else { + Utils.openMedia(context, status, current, null); + } } public static ParcelableMedia findByLink(ParcelableMedia[] media, String link) {