From cc8bac8fab001b10740cf09dbad50dce2ae96830 Mon Sep 17 00:00:00 2001 From: ligi Date: Sun, 24 Aug 2014 13:18:57 +0200 Subject: [PATCH] url rewrite for swiss --- src/main/AndroidManifest.xml | 23 +++++++++++++++++++ .../ui/quirk_fix/URLRewriteActivity.java | 20 ++++++++++++++-- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml index ffaedaa7..93cabaf7 100644 --- a/src/main/AndroidManifest.xml +++ b/src/main/AndroidManifest.xml @@ -570,6 +570,29 @@ android:pathPattern="/icheckin2/mbp.do.*" android:scheme="https" /> + + + + + + + + + + + + + + + + + diff --git a/src/main/java/org/ligi/passandroid/ui/quirk_fix/URLRewriteActivity.java b/src/main/java/org/ligi/passandroid/ui/quirk_fix/URLRewriteActivity.java index 3459f909..612d035f 100644 --- a/src/main/java/org/ligi/passandroid/ui/quirk_fix/URLRewriteActivity.java +++ b/src/main/java/org/ligi/passandroid/ui/quirk_fix/URLRewriteActivity.java @@ -25,6 +25,8 @@ public class URLRewriteActivity extends Activity { url = getVirginAustraliaURL(); } else if (getIntent().getData().getHost().equals("www.cathaypacific.com")) { url = getCathay(); + } else if (getIntent().getData().getHost().equals("mbp.swiss.com")) { + url = getSwiss(); } if (url == null) { @@ -46,7 +48,7 @@ public class URLRewriteActivity extends Activity { 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, "foo"+getIntent().getData()); + intent.putExtra(Intent.EXTRA_TEXT, "foo" + getIntent().getData()); intent.setType("text/plain"); startActivity(Intent.createChooser(intent, "How to send Link?")); @@ -68,7 +70,6 @@ public class URLRewriteActivity extends Activity { final Intent intent = new Intent(this, PassImportActivity.class); intent.setData(Uri.parse(url)); startActivity(intent); - finish(); } @@ -100,4 +101,19 @@ public class URLRewriteActivity extends Activity { return "https://www.cathaypacific.com/icheckin2/PassbookServlet?v=" + URLEncoder.encode(passId); } + public String getSwiss() { + String url = getIntent().getData().toString(); + if (url.endsWith("/")) { + url = url.substring(0, url.length() - 1); + + } + + final String[] split = url.split("/"); + + if (split.length < 6) { + return null; + } + + return "http://prod.wap.ncrwebhost.mobi/mobiqa/wap/" + split[split.length - 2] + "/" + split[split.length - 1] + "/passbook"; + } }