Add low power mode optimization
- In low power mode UI will no longer try
to color the status bar based on the favicon
- Fixed titlebar not translating fully. This
was resulting in the view not hiding completely
and causing a higher power draw.
- Removed previous change to hide dropshadow
when playing fullscreen content. Not needed now.
Change-Id: I7943737429f22e105aa2315a97c018bce75c839c
diff --git a/src/com/android/browser/BaseUi.java b/src/com/android/browser/BaseUi.java
index 4de34b6..1083576 100644
--- a/src/com/android/browser/BaseUi.java
+++ b/src/com/android/browser/BaseUi.java
@@ -879,7 +879,6 @@
//make full screen by showing/hiding topbar and system status bar
public void showFullscreen(boolean fullScreen) {
- ImageView shadow = (ImageView) mActivity.findViewById(R.id.titleBar_dropShadow);
//Hide/show system ui bar as needed
if (!BrowserSettings.getInstance().useFullscreen())
@@ -890,13 +889,9 @@
if (fullScreen) {
// hide titlebar
mTitleBar.hideTopControls(true);
- //Hide the Titlebar DropShadow
- shadow.setVisibility(View.GONE);
} else {
// show titlebar
mTitleBar.showTopControls(false);
- //Show the Titlebar DropShadow
- shadow.setVisibility(View.VISIBLE);
// enable auto hide titlebar
if (!mTitleBar.isFixed())
mTitleBar.enableTopControls(false);
@@ -915,15 +910,20 @@
}
float currentY = mTitleBar.getTranslationY();
float height = mNavigationBar.getHeight();
+
if ((height + currentY) <= 0 && (height + topControlsOffsetYPix) > 0) {
mTitleBar.requestLayout();
} else if ((height + topControlsOffsetYPix) <= 0) {
- topControlsOffsetYPix -= 1;
+ // Need to add the progress bar's margin to the offest since it's height is not
+ // accounted for and the dropshadow draws inside it.
+ topControlsOffsetYPix +=
+ mActivity.getResources().getDimension(R.dimen.progress_bar_margin);
mTitleBar.getParent().requestTransparentRegion(mTitleBar);
}
// This was done to get HTML5 fullscreen API to work with fixed mode since
// topcontrols are used to implement HTML5 fullscreen
mTitleBar.setTranslationY(topControlsOffsetYPix);
+
}
}
diff --git a/src/com/android/browser/BrowserActivity.java b/src/com/android/browser/BrowserActivity.java
index af2fbfa..7032029 100644
--- a/src/com/android/browser/BrowserActivity.java
+++ b/src/com/android/browser/BrowserActivity.java
@@ -23,6 +23,7 @@
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
+import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.PowerManager;
@@ -38,6 +39,7 @@
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
+import android.view.WindowManager;
import org.chromium.base.VisibleForTesting;
import com.android.browser.R;
@@ -219,6 +221,13 @@
@Override
protected void onResume() {
+ // Checking for Lollipop or above as only those builds will use the v21/styles(material)
+ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP &&
+ BrowserSettings.getInstance().isPowerSaveModeEnabled()) {
+ getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
+ } else if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
+ }
super.onResume();
if (LOGV_ENABLED) {
Log.v(LOGTAG, "BrowserActivity.onResume: this=" + this);
diff --git a/src/com/android/browser/NavigationBarBase.java b/src/com/android/browser/NavigationBarBase.java
index 90b551b..5a39678 100644
--- a/src/com/android/browser/NavigationBarBase.java
+++ b/src/com/android/browser/NavigationBarBase.java
@@ -200,6 +200,9 @@
}
public static void setStatusAndNavigationBarColor(final Activity activity, int color) {
+ // The flag that allows coloring is disabled in PowerSaveMode, no point in trying to color.
+ if (BrowserSettings.getInstance().isPowerSaveModeEnabled())
+ return;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
int currentColor = activity.getWindow().getStatusBarColor();
Integer from = currentColor;
diff --git a/src/com/android/browser/preferences/GeneralPreferencesFragment.java b/src/com/android/browser/preferences/GeneralPreferencesFragment.java
index 9f61061..dbffafb 100644
--- a/src/com/android/browser/preferences/GeneralPreferencesFragment.java
+++ b/src/com/android/browser/preferences/GeneralPreferencesFragment.java
@@ -171,9 +171,9 @@
BrowserSettings settings = BrowserSettings.getInstance();
settings.setPowerSaveModeEnabled((Boolean)objValue);
PermissionsServiceFactory.setDefaultPermissions(
- PermissionsServiceFactory.PermissionType.WEBREFINER, !(Boolean)objValue);
+ PermissionsServiceFactory.PermissionType.WEBREFINER, !(Boolean) objValue);
showPowerSaveInfo((Boolean) objValue);
- BrowserPreferencesPage.sResultExtra = PreferenceKeys.ACTION_RELOAD_PAGE;
+ BrowserPreferencesPage.sResultExtra = PreferenceKeys.ACTION_RELOAD_PAGE;
}
if (pref.getKey().equals(PreferenceKeys.PREF_NIGHTMODE_ENABLED)) {