summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenise Cheng <dcheng@codeaurora.org>2012-01-06 17:16:30 -0500
committerSteve Kondik <shade@chemlab.org>2012-09-11 13:29:34 -0700
commit9aa4a1b524d567c70967565bce2636f01c298d84 (patch)
treec64db1ec1cb0249c35fcfd2f0c13409986ae1f1e
parentfdebf369b0f328538170db5c8e7704590c64c009 (diff)
downloadpackages_apps_browser-9aa4a1b524d567c70967565bce2636f01c298d84.zip
packages_apps_browser-9aa4a1b524d567c70967565bce2636f01c298d84.tar.gz
packages_apps_browser-9aa4a1b524d567c70967565bce2636f01c298d84.tar.bz2
Multimedia feature port from ICS
Support for runtime media preload configuration with 3 options: - Never - Only on WiFi (default) - Always Support video transition animation Change-Id: Idd03f5bb57d6f78ec8b8e407eba01904f392f554
-rw-r--r--res/values/strings.xml25
-rw-r--r--res/xml/bandwidth_preferences.xml9
-rw-r--r--src/com/android/browser/BaseUi.java26
-rw-r--r--src/com/android/browser/BrowserSettings.java17
-rw-r--r--src/com/android/browser/Controller.java10
-rw-r--r--src/com/android/browser/NetworkStateHandler.java18
-rw-r--r--src/com/android/browser/PreferenceKeys.java2
-rw-r--r--src/com/android/browser/preferences/BandwidthPreferencesFragment.java10
8 files changed, 110 insertions, 7 deletions
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 69ce130..9d2fec6 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2007 The Android Open Source Project
+ Copyright (c) 2011, 2012, Code Aurora Forum. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -699,6 +700,28 @@
<string name="pref_link_prefetch_summary">Allow browser to preload linked web pages in the background</string>
<!-- Title of dialog for link prefetching [CHAR LIMIT=40] -->
<string name="pref_link_prefetch_dialogtitle">Web page preloading</string>
+ <!-- Title for video preloading [CHAR LIMIT=40] -->
+ <string name="pref_video_preload_title">Video preloading</string>
+ <!-- Video preloading options [CHAR LIMIT=20] -->
+ <string-array name="pref_video_preload_choices">
+ <item>Never</item>
+ <item>Only on WiFi</item>
+ <item>Always</item>
+ </string-array>
+ <!-- Do not translate -->
+ <string name="pref_video_preload_value_never" translatable="false">NEVER</string>
+ <string name="pref_video_preload_value_wifi_only" translatable="false">WIFI_ONLY</string>
+ <string name="pref_video_preload_value_always" translatable="false">ALWAYS</string>
+ <string name="pref_video_preload_default_value" translatable="false">@string/pref_video_preload_value_wifi_only</string>
+ <string-array name="pref_video_preload_values" translatable="false">
+ <item><xliff:g>@string/pref_video_preload_value_never</xliff:g></item>
+ <item><xliff:g>@string/pref_video_preload_value_wifi_only</xliff:g></item>
+ <item><xliff:g>@string/pref_video_preload_value_always</xliff:g></item>
+ </string-array>
+ <!-- Summary for video preloading [CHAR LIMIT=80] -->
+ <string name="pref_video_preload_summary">Allow browser to preload video when server allows</string>
+ <!-- Title of dialog for video preloading [CHAR LIMIT=40] -->
+ <string name="pref_video_preload_dialogtitle">Video preloading</string>
<!-- Title for a dialog displayed when the browser has a data connectivity
problem -->
<string name="browserFrameNetworkErrorLabel">Connection problem</string>
@@ -1018,4 +1041,4 @@
<!-- Content description for tab switcher transition [CHAR LIMIT=NONE] -->
<string name="accessibility_transition_navscreen">Tab management</string>
-</resources> \ No newline at end of file
+</resources>
diff --git a/res/xml/bandwidth_preferences.xml b/res/xml/bandwidth_preferences.xml
index 9946b48..709d9da 100644
--- a/res/xml/bandwidth_preferences.xml
+++ b/res/xml/bandwidth_preferences.xml
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2011 The Android Open Source Project
+ Copyright (c) 2012, Code Aurora Forum. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -32,6 +33,14 @@
android:entryValues="@array/pref_link_prefetch_values"
android:dialogTitle="@string/pref_link_prefetch_dialogtitle" />
+ <ListPreference
+ android:key="preload_video"
+ android:title="@string/pref_video_preload_title"
+ android:summary="@string/pref_video_preload_summary"
+ android:entries="@array/pref_video_preload_choices"
+ android:entryValues="@array/pref_video_preload_values"
+ android:dialogTitle="@string/pref_video_preload_dialogtitle" />
+
<CheckBoxPreference
android:key="load_images"
android:defaultValue="true"
diff --git a/src/com/android/browser/BaseUi.java b/src/com/android/browser/BaseUi.java
index c749465..bfee02f 100644
--- a/src/com/android/browser/BaseUi.java
+++ b/src/com/android/browser/BaseUi.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2010 The Android Open Source Project
+ * Copyright (c) 2012, Code Aurora Forum. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -76,7 +77,9 @@ public abstract class BaseUi implements UI {
Gravity.CENTER);
private static final int MSG_HIDE_TITLEBAR = 1;
+ private static final int MSG_HIDE_CUSTOM_VIEW = 2;
public static final int HIDE_TITLEBAR_DELAY = 1500; // in ms
+ public static final int HIDE_CUSTOM_VIEW_DELAY = 750; // in ms
Activity mActivity;
UiController mUiController;
@@ -539,22 +542,31 @@ public abstract class BaseUi implements UI {
mActivity.setRequestedOrientation(requestedOrientation);
}
- @Override
- public void onHideCustomView() {
- ((BrowserWebView) getWebView()).setVisibility(View.VISIBLE);
- if (mCustomView == null)
- return;
+ private void hideCustomViewAfterDuration() {
+ Message msg = Message.obtain(mHandler, MSG_HIDE_CUSTOM_VIEW);
+ mHandler.sendMessageDelayed(msg, HIDE_CUSTOM_VIEW_DELAY);
+ }
+
+ private void hideCustomView() {
setFullscreen(false);
FrameLayout decor = (FrameLayout) mActivity.getWindow().getDecorView();
decor.removeView(mFullscreenContainer);
mFullscreenContainer = null;
mCustomView = null;
- mCustomViewCallback.onCustomViewHidden();
// Show the content view.
mActivity.setRequestedOrientation(mOriginalOrientation);
}
@Override
+ public void onHideCustomView() {
+ ((BrowserWebView) getWebView()).setVisibility(View.VISIBLE);
+ if (mCustomView == null)
+ return;
+ mCustomViewCallback.onCustomViewHidden();
+ hideCustomViewAfterDuration();
+ }
+
+ @Override
public boolean isCustomViewShowing() {
return mCustomView != null;
}
@@ -826,6 +838,8 @@ public abstract class BaseUi implements UI {
public void handleMessage(Message msg) {
if (msg.what == MSG_HIDE_TITLEBAR) {
suggestHideTitleBar();
+ } else if (msg.what == MSG_HIDE_CUSTOM_VIEW) {
+ hideCustomView();
}
BaseUi.this.handleMessage(msg);
}
diff --git a/src/com/android/browser/BrowserSettings.java b/src/com/android/browser/BrowserSettings.java
index 03205a7..172abec 100644
--- a/src/com/android/browser/BrowserSettings.java
+++ b/src/com/android/browser/BrowserSettings.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2011 The Android Open Source Project
+ * Copyright (c) 2011, 2012, Code Aurora Forum. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -912,6 +913,22 @@ public class BrowserSettings implements OnSharedPreferenceChangeListener,
return mPrefs.getString(PREF_LINK_PREFETCH, getDefaultLinkPrefetchSetting());
}
+ public String getVideoPreloadOnWifiOnlyPreferenceString() {
+ return mContext.getResources().getString(R.string.pref_video_preload_value_wifi_only);
+ }
+
+ public String getVideoPreloadAlwaysPreferenceString() {
+ return mContext.getResources().getString(R.string.pref_video_preload_value_always);
+ }
+
+ public String getDefaultVideoPreloadSetting() {
+ return mContext.getResources().getString(R.string.pref_video_preload_default_value);
+ }
+
+ public String getVideoPreloadEnabled() {
+ return mPrefs.getString(PREF_VIDEO_PRELOAD, getDefaultVideoPreloadSetting());
+ }
+
// -----------------------------
// getter/setters for browser recovery
// -----------------------------
diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java
index 85d8061..4d50de1 100644
--- a/src/com/android/browser/Controller.java
+++ b/src/com/android/browser/Controller.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2010 The Android Open Source Project
+ * Copyright (c) 2011, 2012, Code Aurora Forum. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -832,6 +833,15 @@ public class Controller
view.setNetworkAvailable(false);
}
+ WebSettings settings = view.getSettings();
+ String preload = mSettings.getVideoPreloadEnabled();
+ if (mSettings.getVideoPreloadAlwaysPreferenceString().equals(preload))
+ settings.setMediaPreloadEnabled(true);
+ else if (mSettings.getVideoPreloadOnWifiOnlyPreferenceString().equals(preload))
+ settings.setMediaPreloadEnabled(mNetworkHandler.isWifiUp());
+ else
+ settings.setMediaPreloadEnabled(false);
+
// when BrowserActivity just starts, onPageStarted may be called before
// onResume as it is triggered from onCreate. Call resumeWebViewTimers
// to start the timer. As we won't switch tabs while an activity is in
diff --git a/src/com/android/browser/NetworkStateHandler.java b/src/com/android/browser/NetworkStateHandler.java
index 4480664..f3c46aa 100644
--- a/src/com/android/browser/NetworkStateHandler.java
+++ b/src/com/android/browser/NetworkStateHandler.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2010 The Android Open Source Project
+ * Copyright (c) 2012, Code Aurora Forum. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -112,6 +113,23 @@ public class NetworkStateHandler {
return mIsNetworkUp;
}
+ boolean isWifiUp() {
+ ConnectivityManager cm = (ConnectivityManager) mActivity
+ .getSystemService(Context.CONNECTIVITY_SERVICE);
+ NetworkInfo info = cm.getActiveNetworkInfo();
+ if (info != null) {
+ switch (info.getType()) {
+ case ConnectivityManager.TYPE_WIFI:
+ case ConnectivityManager.TYPE_ETHERNET:
+ case ConnectivityManager.TYPE_BLUETOOTH:
+ return true;
+ default:
+ return false;
+ }
+ } else
+ return false;
+ }
+
private void sendNetworkType(String type, String subtype) {
WebView w = mController.getCurrentWebView();
if (w != null) {
diff --git a/src/com/android/browser/PreferenceKeys.java b/src/com/android/browser/PreferenceKeys.java
index 1828032..405d893 100644
--- a/src/com/android/browser/PreferenceKeys.java
+++ b/src/com/android/browser/PreferenceKeys.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2011 The Android Open Source Project
+ * Copyright (c) 2011, 2012, Code Aurora Forum. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -104,6 +105,7 @@ public interface PreferenceKeys {
// ----------------------
static final String PREF_DATA_PRELOAD = "preload_when";
static final String PREF_LINK_PREFETCH = "link_prefetch_when";
+ static final String PREF_VIDEO_PRELOAD = "preload_video";
static final String PREF_LOAD_IMAGES = "load_images";
// ----------------------
diff --git a/src/com/android/browser/preferences/BandwidthPreferencesFragment.java b/src/com/android/browser/preferences/BandwidthPreferencesFragment.java
index 0cb064a..36d1689 100644
--- a/src/com/android/browser/preferences/BandwidthPreferencesFragment.java
+++ b/src/com/android/browser/preferences/BandwidthPreferencesFragment.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2011 The Android Open Source Project
+ * Copyright (c) 2012, Code Aurora Forum. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -58,6 +59,15 @@ public class BandwidthPreferencesFragment extends PreferenceFragment {
prefetch.setValue(BrowserSettings.getInstance().getDefaultLinkPrefetchSetting());
}
}
+ if (!getPreferenceScreen().getSharedPreferences()
+ .contains(PreferenceKeys.PREF_VIDEO_PRELOAD)) {
+ // set default value for preload setting
+ ListPreference preload = (ListPreference) getPreferenceScreen().findPreference(
+ PreferenceKeys.PREF_VIDEO_PRELOAD);
+ if (preload != null) {
+ preload.setValue(BrowserSettings.getInstance().getDefaultVideoPreloadSetting());
+ }
+ }
}
}