diff options
author | Sagar Dhawan <sdhawan@codeaurora.org> | 2015-09-25 12:02:34 -0700 |
---|---|---|
committer | jrizzoli <joey@cyanogenmoditalia.it> | 2015-11-05 14:22:57 +0100 |
commit | eecefa3787892c97721c1acff0040c94ee1bf411 (patch) | |
tree | 96edd2aedd89e133ee13b9f9d81634f761d2f30d /src | |
parent | 800171308ed901de39f3861114f1a24da3bbbb7b (diff) | |
download | android_packages_apps_Gello-eecefa3787892c97721c1acff0040c94ee1bf411.tar.gz android_packages_apps_Gello-eecefa3787892c97721c1acff0040c94ee1bf411.tar.bz2 android_packages_apps_Gello-eecefa3787892c97721c1acff0040c94ee1bf411.zip |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/browser/BaseUi.java | 12 | ||||
-rw-r--r-- | src/com/android/browser/BrowserActivity.java | 9 | ||||
-rw-r--r-- | src/com/android/browser/NavigationBarBase.java | 3 | ||||
-rw-r--r-- | src/com/android/browser/preferences/GeneralPreferencesFragment.java | 4 |
4 files changed, 20 insertions, 8 deletions
diff --git a/src/com/android/browser/BaseUi.java b/src/com/android/browser/BaseUi.java index 4de34b64..1083576e 100644 --- a/src/com/android/browser/BaseUi.java +++ b/src/com/android/browser/BaseUi.java @@ -879,7 +879,6 @@ public abstract class BaseUi implements UI { //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 @@ public abstract class BaseUi implements UI { 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 @@ public abstract class BaseUi implements UI { } 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 af2fbfa0..70320293 100644 --- a/src/com/android/browser/BrowserActivity.java +++ b/src/com/android/browser/BrowserActivity.java @@ -23,6 +23,7 @@ import android.app.KeyguardManager; 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.MotionEvent; 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 @@ public class BrowserActivity extends Activity { @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 90b551b7..5a39678c 100644 --- a/src/com/android/browser/NavigationBarBase.java +++ b/src/com/android/browser/NavigationBarBase.java @@ -200,6 +200,9 @@ public class NavigationBarBase extends LinearLayout implements } 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 9f610617..dbffafb9 100644 --- a/src/com/android/browser/preferences/GeneralPreferencesFragment.java +++ b/src/com/android/browser/preferences/GeneralPreferencesFragment.java @@ -171,9 +171,9 @@ public class GeneralPreferencesFragment extends SWEPreferenceFragment 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)) { |