summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
Diffstat (limited to 'src/com')
-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
6 files changed, 77 insertions, 6 deletions
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());
+ }
+ }
}
}