Skip to content

added handling for cancelation #120

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@

import im.delight.android.webview.AdvancedWebView;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class OAuthManagerDialogFragment extends DialogFragment implements AdvancedWebView.Listener {

private static final int WEBVIEW_TAG = 100001;
Expand Down Expand Up @@ -195,6 +198,15 @@ public void onReceivedError(WebView view, int code, String desc, String failingU

private boolean interceptUrl(WebView view, String url, boolean loadUrl) {
Log.i(TAG, "interceptUrl called with url: " + url);

// url would be http://localhost/twitter?denied=xxx when it's canceled
Pattern p = Pattern.compile("\\S*denied\\S*");
Matcher m = p.matcher(url);
if(m.matches()){
Log.i(TAG, "authentication is canceled");
return false;
}

if (isCallbackUri(url, mController.getCallbackUrl())) {
mController.getAccessToken(mWebView, url);
return true;
Expand Down Expand Up @@ -326,4 +338,4 @@ public static int convertDpToPixel(float dp, Context context){
float px = dp * ((float)metrics.densityDpi / DisplayMetrics.DENSITY_DEFAULT);
return (int)px;
}
}
}