url rewrite for swiss

This commit is contained in:
ligi 2014-08-24 13:18:57 +02:00
parent 1b220edf16
commit cc8bac8fab
2 changed files with 41 additions and 2 deletions

View file

@ -570,6 +570,29 @@
android:pathPattern="/icheckin2/mbp.do.*" android:pathPattern="/icheckin2/mbp.do.*"
android:scheme="https" /> android:scheme="https" />
</intent-filter> </intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="mbp.swiss.com"
android:pathPattern="/mobiqa/wap/.*"
android:scheme="http" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="mbp.swiss.com"
android:pathPattern="/mobiqa/wap/.*"
android:scheme="https" />
</intent-filter>
</activity> </activity>

View file

@ -25,6 +25,8 @@ public class URLRewriteActivity extends Activity {
url = getVirginAustraliaURL(); url = getVirginAustraliaURL();
} else if (getIntent().getData().getHost().equals("www.cathaypacific.com")) { } else if (getIntent().getData().getHost().equals("www.cathaypacific.com")) {
url = getCathay(); url = getCathay();
} else if (getIntent().getData().getHost().equals("mbp.swiss.com")) {
url = getSwiss();
} }
if (url == null) { if (url == null) {
@ -46,7 +48,7 @@ public class URLRewriteActivity extends Activity {
Intent intent = new Intent(Intent.ACTION_SEND); Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_SUBJECT, "PassAndroid: URLRewrite Problem"); intent.putExtra(Intent.EXTRA_SUBJECT, "PassAndroid: URLRewrite Problem");
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{"ligi@ligi.de"}); 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"); intent.setType("text/plain");
startActivity(Intent.createChooser(intent, "How to send Link?")); 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); final Intent intent = new Intent(this, PassImportActivity.class);
intent.setData(Uri.parse(url)); intent.setData(Uri.parse(url));
startActivity(intent); startActivity(intent);
finish(); finish();
} }
@ -100,4 +101,19 @@ public class URLRewriteActivity extends Activity {
return "https://www.cathaypacific.com/icheckin2/PassbookServlet?v=" + URLEncoder.encode(passId); 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";
}
} }