mirror of
https://github.com/zxing/zxing.git
synced 2025-01-12 19:57:27 -08:00
Matching Issue 414 / commit 2088 change to iPhone: support zxing://scan/... URLs too
git-svn-id: https://zxing.googlecode.com/svn/trunk@2091 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
35eecdeb45
commit
a9754fb978
|
@ -69,6 +69,13 @@
|
|||
<category android:name="android.intent.category.BROWSABLE"/>
|
||||
<data android:scheme="http" android:host="www.google.co.uk" android:path="/m/products/scan"/>
|
||||
</intent-filter>
|
||||
<!-- Support zxing://scan/?... like iPhone app -->
|
||||
<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:scheme="zxing" android:host="scan" android:path="/"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name=".PreferencesActivity"
|
||||
android:label="@string/preferences_name"
|
||||
|
|
|
@ -95,7 +95,7 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
|
|||
private static final String PACKAGE_NAME = "com.google.zxing.client.android";
|
||||
private static final String PRODUCT_SEARCH_URL_PREFIX = "http://www.google";
|
||||
private static final String PRODUCT_SEARCH_URL_SUFFIX = "/m/products/scan";
|
||||
private static final String ZXING_URL = "http://zxing.appspot.com/scan";
|
||||
private static final String[] ZXING_URLS = { "http://zxing.appspot.com/scan", "zxing://scan/" };
|
||||
private static final String RETURN_CODE_PLACEHOLDER = "{CODE}";
|
||||
private static final String RETURN_URL_PARAM = "ret";
|
||||
|
||||
|
@ -242,7 +242,7 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
|
|||
sourceUrl = dataString;
|
||||
decodeFormats = DecodeFormatManager.PRODUCT_FORMATS;
|
||||
|
||||
} else if (dataString != null && dataString.startsWith(ZXING_URL)) {
|
||||
} else if (isZXingURL(dataString)) {
|
||||
|
||||
// Scan formats requested in query string (all formats if none specified).
|
||||
// If a return URL is specified, send the results there. Otherwise, handle it ourselves.
|
||||
|
@ -259,6 +259,18 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
|
|||
}
|
||||
}
|
||||
|
||||
private static boolean isZXingURL(String dataString) {
|
||||
if (dataString == null) {
|
||||
return false;
|
||||
}
|
||||
for (String url : ZXING_URLS) {
|
||||
if (dataString.startsWith(url)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
if (handler != null) {
|
||||
|
|
Loading…
Reference in a new issue