Also open public URLs with an external browser.

This commit is contained in:
danielegobbetti 2016-03-13 08:31:50 +01:00
parent d378b4eb7b
commit ea855a4cc2
1 changed files with 14 additions and 6 deletions

View File

@ -1,6 +1,7 @@
package nodomain.freeyourgadget.gadgetbridge.activities; package nodomain.freeyourgadget.gadgetbridge.activities;
import android.app.Activity; import android.app.Activity;
import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.NavUtils; import android.support.v4.app.NavUtils;
@ -92,8 +93,15 @@ public class ExternalPebbleJSActivity extends Activity {
private class GBWebClient extends WebViewClient { private class GBWebClient extends WebViewClient {
@Override @Override
public boolean shouldOverrideUrlLoading(WebView view, String url) { public boolean shouldOverrideUrlLoading(WebView view, String url) {
url = url.replaceFirst("^pebblejs://close#", "file:///android_asset/app_config/configure.html?config=true&json="); if (url.startsWith("http://") || url.startsWith("https://")) {
view.loadUrl(url); Intent i = new Intent(Intent.ACTION_VIEW,
Uri.parse(url));
startActivity(i);
} else {
url = url.replaceFirst("^pebblejs://close#", "file:///android_asset/app_config/configure.html?config=true&json=");
view.loadUrl(url);
}
return true; return true;
} }
@ -143,11 +151,11 @@ public class ExternalPebbleJSActivity extends Activity {
public String getActiveWatchInfo() { public String getActiveWatchInfo() {
JSONObject wi = new JSONObject(); JSONObject wi = new JSONObject();
try { try {
wi.put("firmware",mGBDevice.getFirmwareVersion()); wi.put("firmware", mGBDevice.getFirmwareVersion());
wi.put("platform", PebbleUtils.getPlatformName(mGBDevice.getHardwareVersion())); wi.put("platform", PebbleUtils.getPlatformName(mGBDevice.getHardwareVersion()));
wi.put("model", PebbleUtils.getModel(mGBDevice.getHardwareVersion())); wi.put("model", PebbleUtils.getModel(mGBDevice.getHardwareVersion()));
//TODO: use real info //TODO: use real info
wi.put("language","en"); wi.put("language", "en");
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -173,11 +181,11 @@ public class ExternalPebbleJSActivity extends Activity {
public String getAppUUID() { public String getAppUUID() {
return appUuid.toString(); return appUuid.toString();
} }
@JavascriptInterface @JavascriptInterface
public String getWatchToken() { public String getWatchToken() {
//specification says: A string that is is guaranteed to be identical for each Pebble device for the same app across different mobile devices. The token is unique to your app and cannot be used to track Pebble devices across applications. see https://developer.pebble.com/docs/js/Pebble/ //specification says: A string that is is guaranteed to be identical for each Pebble device for the same app across different mobile devices. The token is unique to your app and cannot be used to track Pebble devices across applications. see https://developer.pebble.com/docs/js/Pebble/
return "gb"+appUuid.toString(); return "gb" + appUuid.toString();
} }
} }