Merge "Browser: add to support exit prompt feature"
diff --git a/src/com/android/browser/NavigationBarBase.java b/src/com/android/browser/NavigationBarBase.java
index 1963564..daeb1de 100644
--- a/src/com/android/browser/NavigationBarBase.java
+++ b/src/com/android/browser/NavigationBarBase.java
@@ -40,6 +40,7 @@
import com.android.browser.UrlInputView.UrlInputListener;
import java.io.UnsupportedEncodingException;
+import java.net.URISyntaxException;
public class NavigationBarBase extends LinearLayout implements
OnClickListener, UrlInputListener, OnFocusChangeListener,
@@ -170,7 +171,8 @@
String url = null;
boolean wap2estore = SystemProperties.getBoolean(
"persist.env.browser.wap2estore", false);
- if (wap2estore && isEstoreTypeUrl(text)) {
+ if ((wap2estore && isEstoreTypeUrl(text))
+ || isRtspTypeUrl(text)) {
url = text;
} else {
url = UrlUtils.smartUrlFilter(text, false);
@@ -191,6 +193,12 @@
setDisplayTitle(text);
return;
}
+ // add for rtsp scheme feature
+ if (url != null && t != null && isRtspTypeUrl(url)) {
+ if (handleRtspTypeUrl(url)) {
+ return;
+ }
+ }
}
Intent i = new Intent();
String action = Intent.ACTION_SEARCH;
@@ -248,6 +256,38 @@
}
}
+ private boolean isRtspTypeUrl(String url) {
+ String utf8Url = null;
+ try {
+ utf8Url = new String(url.getBytes("UTF-8"), "UTF-8");
+ } catch (UnsupportedEncodingException e) {
+ Log.e(TAG, "err " + e);
+ }
+ if (utf8Url != null && utf8Url.startsWith("rtsp://")) {
+ return true;
+ }
+ return false;
+ }
+
+ private boolean handleRtspTypeUrl(String url) {
+ Intent intent;
+ // perform generic parsing of the URI to turn it into an Intent.
+ try {
+ intent = Intent.parseUri(url, Intent.URI_INTENT_SCHEME);
+ } catch (URISyntaxException ex) {
+ Log.w("Browser", "Bad URI " + url + ": " + ex.getMessage());
+ return false;
+ }
+
+ try {
+ mContext.startActivity(intent);
+ } catch (ActivityNotFoundException ex) {
+ Log.w("Browser", "No resolveActivity " + url);
+ return false;
+ }
+ return true;
+ }
+
@Override
public void onDismiss() {
final Tab currentTab = mBaseUi.getActiveTab();