From 76645a6ecd36e8084a0c4738e68e8af593e57ec1 Mon Sep 17 00:00:00 2001 From: Mariotaku Lee Date: Sun, 14 Feb 2016 16:24:39 +0800 Subject: [PATCH] supports retype phone login challenge --- .../twidere/util/DebugModeUtils.java | 17 ++++++- .../activity/support/SignInActivity.java | 4 +- .../fragment/support/AbsUsersFragment.java | 4 +- .../CursorSupportUsersListFragment.java | 3 +- .../support/IncomingFriendshipsFragment.java | 4 +- .../support/MutesUsersListFragment.java | 3 +- .../fragment/support/SearchUsersFragment.java | 3 +- .../support/StatusFavoritersListFragment.java | 3 +- .../support/StatusRetweetersListFragment.java | 3 +- .../support/UserBlocksListFragment.java | 3 +- .../support/UserFollowersFragment.java | 3 +- .../fragment/support/UserFriendsFragment.java | 3 +- .../support/UserListMembersFragment.java | 2 +- .../support/UserListSubscribersFragment.java | 3 +- .../fragment/support/UsersListFragment.java | 3 +- .../twidere/util/DataImportExportUtils.java | 2 + .../util/OAuthPasswordAuthenticator.java | 46 +++++++++++-------- .../util/media/TwidereMediaDownloader.java | 6 ++- .../twidere/util/net/NoIntercept.java | 8 ++++ twidere/src/main/res/values/strings.xml | 1 + 20 files changed, 89 insertions(+), 35 deletions(-) create mode 100644 twidere/src/main/java/org/mariotaku/twidere/util/net/NoIntercept.java diff --git a/twidere/src/debug/java/org/mariotaku/twidere/util/DebugModeUtils.java b/twidere/src/debug/java/org/mariotaku/twidere/util/DebugModeUtils.java index 2e1c9b497..7f2efba54 100644 --- a/twidere/src/debug/java/org/mariotaku/twidere/util/DebugModeUtils.java +++ b/twidere/src/debug/java/org/mariotaku/twidere/util/DebugModeUtils.java @@ -34,8 +34,13 @@ import com.squareup.leakcanary.ServiceHeapDumpListener; import org.mariotaku.twidere.BuildConfig; import org.mariotaku.twidere.activity.support.ComposeActivity; +import org.mariotaku.twidere.util.net.NoIntercept; +import java.io.IOException; + +import okhttp3.Interceptor; import okhttp3.OkHttpClient; +import okhttp3.Response; /** * Created by mariotaku on 15/5/27. @@ -45,7 +50,17 @@ public class DebugModeUtils { private static RefWatcher sRefWatcher; public static void initForOkHttpClient(final OkHttpClient.Builder builder) { - builder.addNetworkInterceptor(new StethoInterceptor()); + final StethoInterceptor interceptor = new StethoInterceptor(); + + builder.addNetworkInterceptor(new Interceptor() { + @Override + public Response intercept(Chain chain) throws IOException { + if (chain.request().tag() == NoIntercept.INSTANCE) { + return chain.proceed(chain.request()); + } + return interceptor.intercept(chain); + } + }); } public static void initForApplication(final Application application) { 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 b4e4b325f..d5aa7d6bc 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 @@ -92,7 +92,6 @@ import org.mariotaku.twidere.util.ParseUtils; import org.mariotaku.twidere.util.SharedPreferencesWrapper; import org.mariotaku.twidere.util.ThemeUtils; import org.mariotaku.twidere.util.TwidereActionModeForChildListener; -import org.mariotaku.twidere.util.TwidereColorUtils; import org.mariotaku.twidere.util.TwitterAPIFactory; import org.mariotaku.twidere.util.UserAgentUtils; import org.mariotaku.twidere.util.Utils; @@ -942,6 +941,9 @@ public class SignInActivity extends BaseAppCompatActivity implements OnClickList if ("Push".equalsIgnoreCase(challengeType)) { verificationHint.setText(R.string.login_verification_push_hint); editVerification.setVisibility(View.GONE); + } else if ("RetypePhoneNumber".equalsIgnoreCase(challengeType)) { + verificationHint.setText(R.string.login_challenge_retype_phone_hint); + editVerification.setVisibility(View.VISIBLE); } else { verificationHint.setText(R.string.login_verification_pin_hint); editVerification.setVisibility(View.VISIBLE); diff --git a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/AbsUsersFragment.java b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/AbsUsersFragment.java index 9be268a5b..860ba8819 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/AbsUsersFragment.java +++ b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/AbsUsersFragment.java @@ -129,6 +129,8 @@ abstract class AbsUsersFragment extends AbsContentListRecyclerViewFragment protected abstract boolean hasMoreData(Data data); - protected abstract Loader onCreateUsersLoader(Context context, Bundle args, boolean fromUser); + protected abstract Loader onCreateUsersLoader(final Context context, + @NonNull final Bundle args, + final boolean fromUser); } diff --git a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/CursorSupportUsersListFragment.java b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/CursorSupportUsersListFragment.java index 7f5f23ed9..f81112e65 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/CursorSupportUsersListFragment.java +++ b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/CursorSupportUsersListFragment.java @@ -21,6 +21,7 @@ package org.mariotaku.twidere.fragment.support; import android.content.Context; import android.os.Bundle; +import android.support.annotation.NonNull; import android.support.v4.content.Loader; import org.mariotaku.twidere.adapter.iface.ILoadMoreSupportAdapter.IndicatorPosition; @@ -95,5 +96,5 @@ public abstract class CursorSupportUsersListFragment extends ParcelableUsersFrag } @Override - protected abstract BaseCursorSupportUsersLoader onCreateUsersLoader(final Context context, final Bundle args, boolean fromUser); + protected abstract BaseCursorSupportUsersLoader onCreateUsersLoader(final Context context, @NonNull final Bundle args, boolean fromUser); } diff --git a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/IncomingFriendshipsFragment.java b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/IncomingFriendshipsFragment.java index 107eb2aa9..2a62a7b88 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/IncomingFriendshipsFragment.java +++ b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/IncomingFriendshipsFragment.java @@ -21,6 +21,7 @@ package org.mariotaku.twidere.fragment.support; import android.content.Context; import android.os.Bundle; +import android.support.annotation.NonNull; import org.mariotaku.twidere.loader.support.IDsUsersLoader; import org.mariotaku.twidere.loader.support.IncomingFriendshipsLoader; @@ -28,8 +29,7 @@ import org.mariotaku.twidere.loader.support.IncomingFriendshipsLoader; public class IncomingFriendshipsFragment extends CursorSupportUsersListFragment { @Override - public IDsUsersLoader onCreateUsersLoader(final Context context, final Bundle args, boolean fromUser) { - if (args == null) return null; + public IDsUsersLoader onCreateUsersLoader(final Context context, @NonNull final Bundle args, boolean fromUser) { final long accountId = args.getLong(EXTRA_ACCOUNT_ID, -1); return new IncomingFriendshipsLoader(context, accountId, getNextCursor(), getData(), fromUser); } diff --git a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/MutesUsersListFragment.java b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/MutesUsersListFragment.java index 666bfd848..8f6e415ab 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/MutesUsersListFragment.java +++ b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/MutesUsersListFragment.java @@ -21,6 +21,7 @@ package org.mariotaku.twidere.fragment.support; import android.content.Context; import android.os.Bundle; +import android.support.annotation.NonNull; import org.mariotaku.twidere.loader.support.CursorSupportUsersLoader; import org.mariotaku.twidere.loader.support.MutesUsersLoader; @@ -28,7 +29,7 @@ import org.mariotaku.twidere.loader.support.MutesUsersLoader; public class MutesUsersListFragment extends CursorSupportUsersListFragment { @Override - public CursorSupportUsersLoader onCreateUsersLoader(final Context context, final Bundle args, boolean fromUser) { + public CursorSupportUsersLoader onCreateUsersLoader(final Context context, @NonNull final Bundle args, boolean fromUser) { if (args == null) return null; final long account_id = args.getLong(EXTRA_ACCOUNT_ID, -1); return new MutesUsersLoader(context, account_id, getNextCursor(), getData(), fromUser); diff --git a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/SearchUsersFragment.java b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/SearchUsersFragment.java index 3b085059c..e275f7b2e 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/SearchUsersFragment.java +++ b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/SearchUsersFragment.java @@ -21,6 +21,7 @@ package org.mariotaku.twidere.fragment.support; import android.content.Context; import android.os.Bundle; +import android.support.annotation.NonNull; import android.support.v4.content.Loader; import org.mariotaku.twidere.adapter.iface.ILoadMoreSupportAdapter.IndicatorPosition; @@ -42,7 +43,7 @@ public class SearchUsersFragment extends ParcelableUsersFragment { } @Override - public Loader> onCreateUsersLoader(final Context context, final Bundle args, boolean fromUser) { + public Loader> onCreateUsersLoader(final Context context, @NonNull final Bundle args, boolean fromUser) { if (args == null) return null; final long account_id = args.getLong(EXTRA_ACCOUNT_ID); final String query = args.getString(EXTRA_QUERY); diff --git a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/StatusFavoritersListFragment.java b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/StatusFavoritersListFragment.java index bb54b2507..79e595935 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/StatusFavoritersListFragment.java +++ b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/StatusFavoritersListFragment.java @@ -21,6 +21,7 @@ package org.mariotaku.twidere.fragment.support; import android.content.Context; import android.os.Bundle; +import android.support.annotation.NonNull; import org.mariotaku.twidere.loader.support.IDsUsersLoader; import org.mariotaku.twidere.loader.support.StatusFavoritersLoader; @@ -28,7 +29,7 @@ import org.mariotaku.twidere.loader.support.StatusFavoritersLoader; public class StatusFavoritersListFragment extends CursorSupportUsersListFragment { @Override - public IDsUsersLoader onCreateUsersLoader(final Context context, final Bundle args, boolean fromUser) { + public IDsUsersLoader onCreateUsersLoader(final Context context, @NonNull final Bundle args, boolean fromUser) { if (args == null) return null; final long accountId = args.getLong(EXTRA_ACCOUNT_ID, -1); final long statusId = args.getLong(EXTRA_STATUS_ID, -1); diff --git a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/StatusRetweetersListFragment.java b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/StatusRetweetersListFragment.java index 175070765..95b66359c 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/StatusRetweetersListFragment.java +++ b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/StatusRetweetersListFragment.java @@ -21,6 +21,7 @@ package org.mariotaku.twidere.fragment.support; import android.content.Context; import android.os.Bundle; +import android.support.annotation.NonNull; import org.mariotaku.twidere.loader.support.IDsUsersLoader; import org.mariotaku.twidere.loader.support.StatusRetweetersLoader; @@ -28,7 +29,7 @@ import org.mariotaku.twidere.loader.support.StatusRetweetersLoader; public class StatusRetweetersListFragment extends CursorSupportUsersListFragment { @Override - public IDsUsersLoader onCreateUsersLoader(final Context context, final Bundle args, boolean fromUser) { + public IDsUsersLoader onCreateUsersLoader(final Context context, @NonNull final Bundle args, boolean fromUser) { if (args == null) return null; final long account_id = args.getLong(EXTRA_ACCOUNT_ID, -1); final long status_id = args.getLong(EXTRA_STATUS_ID, -1); diff --git a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/UserBlocksListFragment.java b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/UserBlocksListFragment.java index cfd1837e7..cdd2518b9 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/UserBlocksListFragment.java +++ b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/UserBlocksListFragment.java @@ -21,6 +21,7 @@ package org.mariotaku.twidere.fragment.support; import android.content.Context; import android.os.Bundle; +import android.support.annotation.NonNull; import org.mariotaku.twidere.loader.support.CursorSupportUsersLoader; import org.mariotaku.twidere.loader.support.UserBlocksLoader; @@ -28,7 +29,7 @@ import org.mariotaku.twidere.loader.support.UserBlocksLoader; public class UserBlocksListFragment extends CursorSupportUsersListFragment { @Override - public CursorSupportUsersLoader onCreateUsersLoader(final Context context, final Bundle args, boolean fromUser) { + public CursorSupportUsersLoader onCreateUsersLoader(final Context context, @NonNull final Bundle args, boolean fromUser) { if (args == null) return null; final long account_id = args.getLong(EXTRA_ACCOUNT_ID, -1); return new UserBlocksLoader(context, account_id, getNextCursor(), getData(), fromUser); diff --git a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/UserFollowersFragment.java b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/UserFollowersFragment.java index 40638cc86..02f152f37 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/UserFollowersFragment.java +++ b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/UserFollowersFragment.java @@ -24,6 +24,7 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.os.Bundle; +import android.support.annotation.NonNull; import org.mariotaku.twidere.loader.support.CursorSupportUsersLoader; import org.mariotaku.twidere.loader.support.UserFollowersLoader; @@ -53,7 +54,7 @@ public class UserFollowersFragment extends CursorSupportUsersListFragment { }; @Override - public CursorSupportUsersLoader onCreateUsersLoader(final Context context, final Bundle args, boolean fromUser) { + public CursorSupportUsersLoader onCreateUsersLoader(final Context context, @NonNull final Bundle args, boolean fromUser) { if (args == null) return null; final long account_id = args.getLong(EXTRA_ACCOUNT_ID, -1); final long user_id = args.getLong(EXTRA_USER_ID, -1); diff --git a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/UserFriendsFragment.java b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/UserFriendsFragment.java index fe63efba0..d59db82ef 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/UserFriendsFragment.java +++ b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/UserFriendsFragment.java @@ -21,6 +21,7 @@ package org.mariotaku.twidere.fragment.support; import android.content.Context; import android.os.Bundle; +import android.support.annotation.NonNull; import org.mariotaku.twidere.loader.support.CursorSupportUsersLoader; import org.mariotaku.twidere.loader.support.UserFriendsLoader; @@ -28,7 +29,7 @@ import org.mariotaku.twidere.loader.support.UserFriendsLoader; public class UserFriendsFragment extends CursorSupportUsersListFragment { @Override - public CursorSupportUsersLoader onCreateUsersLoader(final Context context, final Bundle args, boolean fromUser) { + public CursorSupportUsersLoader onCreateUsersLoader(final Context context, @NonNull final Bundle args, boolean fromUser) { if (args == null) return null; final long account_id = args.getLong(EXTRA_ACCOUNT_ID, -1); final long user_id = args.getLong(EXTRA_USER_ID, -1); diff --git a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/UserListMembersFragment.java b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/UserListMembersFragment.java index ab8172ae6..34b95f58b 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/UserListMembersFragment.java +++ b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/UserListMembersFragment.java @@ -57,7 +57,7 @@ public class UserListMembersFragment extends CursorSupportUsersListFragment { }; @Override - public CursorSupportUsersLoader onCreateUsersLoader(final Context context, final Bundle args, boolean fromUser) { + public CursorSupportUsersLoader onCreateUsersLoader(final Context context, @NonNull final Bundle args, boolean fromUser) { if (args == null) return null; final long listId = args.getLong(EXTRA_LIST_ID, -1); final long accountId = args.getLong(EXTRA_ACCOUNT_ID, -1); diff --git a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/UserListSubscribersFragment.java b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/UserListSubscribersFragment.java index c937d40f4..787c85ca8 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/UserListSubscribersFragment.java +++ b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/UserListSubscribersFragment.java @@ -21,6 +21,7 @@ package org.mariotaku.twidere.fragment.support; import android.content.Context; import android.os.Bundle; +import android.support.annotation.NonNull; import org.mariotaku.twidere.loader.support.CursorSupportUsersLoader; import org.mariotaku.twidere.loader.support.UserListSubscribersLoader; @@ -28,7 +29,7 @@ import org.mariotaku.twidere.loader.support.UserListSubscribersLoader; public class UserListSubscribersFragment extends CursorSupportUsersListFragment { @Override - public CursorSupportUsersLoader onCreateUsersLoader(final Context context, final Bundle args, boolean fromUser) { + public CursorSupportUsersLoader onCreateUsersLoader(final Context context, @NonNull final Bundle args, boolean fromUser) { if (args == null) return null; final long listId = args.getLong(EXTRA_LIST_ID, -1); final long accountId = args.getLong(EXTRA_ACCOUNT_ID, -1); diff --git a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/UsersListFragment.java b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/UsersListFragment.java index 72e962b58..f36066a13 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/UsersListFragment.java +++ b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/UsersListFragment.java @@ -21,6 +21,7 @@ package org.mariotaku.twidere.fragment.support; import android.content.Context; import android.os.Bundle; +import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v4.content.Loader; @@ -54,7 +55,7 @@ public class UsersListFragment extends ParcelableUsersFragment { } @Override - public Loader> onCreateUsersLoader(final Context context, final Bundle args, boolean fromUser) { + public Loader> onCreateUsersLoader(final Context context, @NonNull final Bundle args, boolean fromUser) { if (args == null) return null; if (args.containsKey(EXTRA_USERS)) return new IntentExtrasUsersLoader(context, args, getData(), fromUser); diff --git a/twidere/src/main/java/org/mariotaku/twidere/util/DataImportExportUtils.java b/twidere/src/main/java/org/mariotaku/twidere/util/DataImportExportUtils.java index d91bf03ce..62f631738 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/util/DataImportExportUtils.java +++ b/twidere/src/main/java/org/mariotaku/twidere/util/DataImportExportUtils.java @@ -302,6 +302,8 @@ public class DataImportExportUtils implements Constants { } } catch (JSONException e) { return false; + } catch (ClassCastException e) { + return false; } return true; } diff --git a/twidere/src/main/java/org/mariotaku/twidere/util/OAuthPasswordAuthenticator.java b/twidere/src/main/java/org/mariotaku/twidere/util/OAuthPasswordAuthenticator.java index ab2a76838..4ce17e076 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/util/OAuthPasswordAuthenticator.java +++ b/twidere/src/main/java/org/mariotaku/twidere/util/OAuthPasswordAuthenticator.java @@ -98,12 +98,12 @@ public class OAuthPasswordAuthenticator implements Constants { if (!TextUtils.isEmpty(authorizeResponseData.oauthPin)) { // Here we got OAuth PIN, just get access token directly return oauth.getAccessToken(requestToken, authorizeResponseData.oauthPin); - } else if (authorizeResponseData.verification == null) { + } else if (authorizeResponseData.challenge == null) { // No OAuth pin, or verification challenge, so treat as wrong password throw new WrongUserPassException(); } // Go to password verification flow - final String challengeType = authorizeResponseData.verification.challengeType; + final String challengeType = authorizeResponseData.challenge.challengeType; final String loginVerification = loginVerificationCallback.getLoginVerification(challengeType); final AuthorizeRequestData verificationData = getVerificationData(authorizeResponseData, loginVerification); @@ -124,7 +124,7 @@ public class OAuthPasswordAuthenticator implements Constants { try { final AuthorizeRequestData data = new AuthorizeRequestData(); final MultiValueMap params = new MultiValueMap<>(); - final AuthorizeResponseData.Verification verification = authorizeResponseData.verification; + final AuthorizeResponseData.Verification verification = authorizeResponseData.challenge; params.add("authenticity_token", verification.authenticityToken); params.add("user_id", verification.userId); params.add("challenge_id", verification.challengeId); @@ -234,7 +234,7 @@ public class OAuthPasswordAuthenticator implements Constants { final HtmlParsingConfiguration conf = new HtmlParsingConfiguration(); final IAttoHandler handler = new AbstractStandardNonValidatingHtmlAttoHandler(conf) { boolean isOAuthPinDivOpened; - boolean isLoginVerificationFormOpened; + boolean isChallengeFormOpened; @Override public void handleHtmlStandaloneElement(IHtmlElement element, boolean minimized, @@ -252,7 +252,7 @@ public class OAuthPasswordAuthenticator implements Constants { break; } case "form": { - isLoginVerificationFormOpened = false; + isChallengeFormOpened = false; break; } } @@ -263,51 +263,61 @@ public class OAuthPasswordAuthenticator implements Constants { Map attributes, int line, int col) { switch (elementName) { case "div": { - if (attributes != null && "oauth_pin".equals(attributes.get("id"))) { + if (attributes == null) break; + if ("oauth_pin".equals(attributes.get("id"))) { isOAuthPinDivOpened = true; } + break; } case "form": { - if (attributes != null && "login-verification-form".equals(attributes.get("id"))) { - isLoginVerificationFormOpened = true; + if (attributes == null) break; + final String id = attributes.get("id"); + if (id == null) break; + switch (id) { + case "login-verification-form": + case "login-challenge-form": { + isChallengeFormOpened = true; + break; + } } break; } case "input": - if (isLoginVerificationFormOpened && attributes != null) { + if (attributes == null) break; + if (isChallengeFormOpened) { final String name = attributes.get("name"); if (TextUtils.isEmpty(name)) break; final String value = attributes.get("value"); switch (name) { case "authenticity_token": { ensureVerification(); - data.verification.authenticityToken = value; + data.challenge.authenticityToken = value; break; } case "challenge_id": { ensureVerification(); - data.verification.challengeId = value; + data.challenge.challengeId = value; break; } case "challenge_type": { ensureVerification(); - data.verification.challengeType = value; + data.challenge.challengeType = value; break; } case "platform": { ensureVerification(); - data.verification.platform = value; + data.challenge.platform = value; break; } case "user_id": { ensureVerification(); - data.verification.userId = value; + data.challenge.userId = value; break; } case "redirect_after_login": { ensureVerification(); - data.verification.redirectAfterLogin = value; + data.challenge.redirectAfterLogin = value; break; } } @@ -317,8 +327,8 @@ public class OAuthPasswordAuthenticator implements Constants { } private void ensureVerification() { - if (data.verification == null) { - data.verification = new AuthorizeResponseData.Verification(); + if (data.challenge == null) { + data.challenge = new AuthorizeResponseData.Verification(); } } @@ -484,7 +494,7 @@ public class OAuthPasswordAuthenticator implements Constants { String referer; public String oauthPin; - public Verification verification; + public Verification challenge; static class Verification { diff --git a/twidere/src/main/java/org/mariotaku/twidere/util/media/TwidereMediaDownloader.java b/twidere/src/main/java/org/mariotaku/twidere/util/media/TwidereMediaDownloader.java index 9349a3e11..422d843ba 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/util/media/TwidereMediaDownloader.java +++ b/twidere/src/main/java/org/mariotaku/twidere/util/media/TwidereMediaDownloader.java @@ -32,6 +32,7 @@ import org.mariotaku.twidere.util.SharedPreferencesWrapper; import org.mariotaku.twidere.util.TwitterAPIFactory; import org.mariotaku.twidere.util.UserAgentUtils; import org.mariotaku.twidere.util.media.preview.PreviewMediaExtractor; +import org.mariotaku.twidere.util.net.NoIntercept; import java.io.IOException; @@ -130,8 +131,11 @@ public class TwidereMediaDownloader implements MediaDownloader, Constants { builder.method(method); builder.url(requestUri); builder.headers(additionalHeaders); + builder.tag(NoIntercept.INSTANCE); final HttpResponse resp = mClient.newCall(builder.build()).execute(); - if (!resp.isSuccessful()) throw new IOException("Unable to get media, response code: " + resp.getStatus()); + if (!resp.isSuccessful()) { + throw new IOException("Unable to get media, response code: " + resp.getStatus()); + } final Body body = resp.getBody(); return new CacheDownloadLoader.DownloadResult(body.length(), body.stream()); } diff --git a/twidere/src/main/java/org/mariotaku/twidere/util/net/NoIntercept.java b/twidere/src/main/java/org/mariotaku/twidere/util/net/NoIntercept.java new file mode 100644 index 000000000..211f7e6de --- /dev/null +++ b/twidere/src/main/java/org/mariotaku/twidere/util/net/NoIntercept.java @@ -0,0 +1,8 @@ +package org.mariotaku.twidere.util.net; + +/** + * Created by mariotaku on 16/2/14. + */ +public class NoIntercept { + public static final NoIntercept INSTANCE = new NoIntercept(); +} diff --git a/twidere/src/main/res/values/strings.xml b/twidere/src/main/res/values/strings.xml index 16fa4b5d0..09b1dbb20 100644 --- a/twidere/src/main/res/values/strings.xml +++ b/twidere/src/main/res/values/strings.xml @@ -827,6 +827,7 @@ Link copied to clipboard Login verification Check your phone for a PIN code and enter it to log in. + Retype the phone number associated with your Twitter account. Accept login verification request from Twitter app, once you approved the request, click OK. Login verification failed. Perhaps you already saved this search