Improve how we deal with browser-rescuing
also do not use rethrowIntentExcludingSelf any more - thanks @cketti for the hint
This commit is contained in:
parent
4f24b42919
commit
5c55cd9622
4 changed files with 63 additions and 43 deletions
|
@ -129,6 +129,8 @@ dependencies {
|
|||
compile 'com.larswerkman:HoloColorPicker:1.4'
|
||||
compile 'com.google.code.findbugs:jsr305:3.0.0'
|
||||
|
||||
compile 'net.steamcrafted:load-toast:1.0.6'
|
||||
|
||||
provided "org.projectlombok:lombok:1.16.4"
|
||||
|
||||
androidTestCompile 'com.google.code.findbugs:jsr305:3.0.0'
|
||||
|
|
|
@ -6,19 +6,16 @@ import android.content.Intent;
|
|||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.squareup.okhttp.OkHttpClient;
|
||||
import com.squareup.okhttp.Request;
|
||||
import com.squareup.okhttp.ResponseBody;
|
||||
|
||||
import org.ligi.axt.AXT;
|
||||
import org.ligi.passandroid.Tracker;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import org.ligi.passandroid.Tracker;
|
||||
import org.ligi.passandroid.ui.quirk_fix.OpenIphoneWebView;
|
||||
|
||||
public class ExtractURLAsIphoneActivity extends Activity {
|
||||
|
||||
|
@ -71,7 +68,9 @@ public class ExtractURLAsIphoneActivity extends Activity {
|
|||
protected void onPostExecute(String s) {
|
||||
super.onPostExecute(s);
|
||||
if (s == null) {
|
||||
AXT.at(ExtractURLAsIphoneActivity.this).rethrowIntentExcludingSelf();
|
||||
final Intent intent = new Intent(ExtractURLAsIphoneActivity.this, OpenIphoneWebView.class);
|
||||
intent.setData(getIntent().getData());
|
||||
startActivity(intent);
|
||||
tearDown();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,9 @@ package org.ligi.passandroid.ui.quirk_fix;
|
|||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import net.steamcrafted.loadtoast.LoadToast;
|
||||
import org.ligi.passandroid.R;
|
||||
import org.ligi.passandroid.ui.InputStreamProvider;
|
||||
|
||||
public class OpenIphoneWebView extends Activity {
|
||||
|
@ -17,10 +20,27 @@ public class OpenIphoneWebView extends Activity {
|
|||
webView.getSettings().setJavaScriptEnabled(true);
|
||||
|
||||
webView.loadUrl(getIntent().getData().toString());
|
||||
|
||||
|
||||
setContentView(webView);
|
||||
|
||||
final LoadToast loadToast = new LoadToast(this)
|
||||
.setText("Loading")
|
||||
.setBackgroundColor(getResources().getColor(R.color.dividing_color)).show();
|
||||
|
||||
|
||||
|
||||
webView.setWebViewClient(new WebViewClient() {
|
||||
@Override
|
||||
public void onPageFinished(final WebView view, final String url) {
|
||||
super.onPageFinished(view, url);
|
||||
loadToast.success();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceivedError(final WebView view, final int errorCode, final String description, final String failingUrl) {
|
||||
super.onReceivedError(view, errorCode, description, failingUrl);
|
||||
loadToast.error();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,14 +5,11 @@ import android.content.DialogInterface;
|
|||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import org.ligi.axt.AXT;
|
||||
import java.net.URLEncoder;
|
||||
import org.ligi.passandroid.Tracker;
|
||||
import org.ligi.passandroid.ui.PassImportActivity;
|
||||
|
||||
import java.net.URLEncoder;
|
||||
|
||||
public class URLRewriteActivity extends Activity {
|
||||
|
||||
@Override
|
||||
|
@ -30,39 +27,41 @@ public class URLRewriteActivity extends Activity {
|
|||
}
|
||||
|
||||
if (url == null) {
|
||||
new AlertDialog.Builder(this)
|
||||
.setTitle("Workaround failed")
|
||||
.setMessage("The URL PassAndroid tried to work around failed :-( some companies just send PassBooks to Apple Devices - this was an attempt to workaround this." +
|
||||
"Unfortunately it failed - perhaps there where changes on the serverside - you can open the site with your browser now - to see it in PassAndroid in future again it would help if you can send me the pass")
|
||||
.setPositiveButton("Browser", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
Tracker.get().trackException("URLRewrite with invalid activity", false);
|
||||
AXT.at(URLRewriteActivity.this).rethrowIntentExcludingSelf();
|
||||
}
|
||||
})
|
||||
.setNeutralButton("send", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
new AlertDialog.Builder(this).setTitle("Workaround failed")
|
||||
.setMessage(
|
||||
"The URL PassAndroid tried to work around failed :-( some companies just send PassBooks to Apple Devices - this was an attempt to workaround this." +
|
||||
"Unfortunately it failed - perhaps there where changes on the serverside - you can open the site with your browser now - to see it in PassAndroid in future again it would help if you can send me the pass")
|
||||
.setPositiveButton("Browser", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
Tracker.get().trackException("URLRewrite with invalid activity", false);
|
||||
final Intent intent = new Intent(URLRewriteActivity.this, OpenIphoneWebView.class);
|
||||
intent.setData(getIntent().getData());
|
||||
startActivity(intent);
|
||||
|
||||
Intent intent = new Intent(Intent.ACTION_SEND);
|
||||
intent.putExtra(Intent.EXTRA_SUBJECT, "PassAndroid: URLRewrite Problem");
|
||||
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{"ligi@ligi.de"});
|
||||
intent.putExtra(Intent.EXTRA_TEXT, getIntent().getData().toString());
|
||||
intent.setType("text/plain");
|
||||
}
|
||||
})
|
||||
.setNeutralButton("send", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
|
||||
startActivity(Intent.createChooser(intent, "How to send Link?"));
|
||||
finish();
|
||||
}
|
||||
}
|
||||
)
|
||||
.setNegativeButton("cancel", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
URLRewriteActivity.this.finish();
|
||||
}
|
||||
})
|
||||
.show();
|
||||
Intent intent = new Intent(Intent.ACTION_SEND);
|
||||
intent.putExtra(Intent.EXTRA_SUBJECT, "PassAndroid: URLRewrite Problem");
|
||||
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{"ligi@ligi.de"});
|
||||
intent.putExtra(Intent.EXTRA_TEXT, getIntent().getData().toString());
|
||||
intent.setType("text/plain");
|
||||
|
||||
startActivity(Intent.createChooser(intent, "How to send Link?"));
|
||||
finish();
|
||||
}
|
||||
})
|
||||
.setNegativeButton("cancel", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
URLRewriteActivity.this.finish();
|
||||
}
|
||||
})
|
||||
.show();
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue