Backed out changeset f36de129726f (bug 1403653)

This commit is contained in:
Sebastian Hengst 2017-10-22 11:54:09 +02:00
Родитель 75dc1431ee
Коммит 20ac5878dd
3 изменённых файлов: 12 добавлений и 54 удалений

Просмотреть файл

@ -113,7 +113,6 @@ import org.mozilla.gecko.icons.IconsHelper;
import org.mozilla.gecko.icons.decoders.FaviconDecoder;
import org.mozilla.gecko.icons.decoders.IconDirectoryEntry;
import org.mozilla.gecko.icons.decoders.LoadFaviconResult;
import org.mozilla.gecko.lwt.LightweightTheme;
import org.mozilla.gecko.media.VideoPlayer;
import org.mozilla.gecko.menu.GeckoMenu;
import org.mozilla.gecko.menu.GeckoMenuItem;
@ -185,6 +184,7 @@ import java.util.EnumSet;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import java.util.regex.Pattern;
import static org.mozilla.gecko.mma.MmaDelegate.NEW_TAB;
@ -198,7 +198,6 @@ public class BrowserApp extends GeckoApp
DynamicToolbarAnimator.MetricsListener,
DynamicToolbarAnimator.ToolbarChromeProxy,
LayoutInflater.Factory,
LightweightTheme.OnChangeListener,
OnUrlOpenListener,
OnUrlOpenInBackgroundListener,
PropertyAnimator.PropertyAnimationListener,
@ -642,8 +641,7 @@ public class BrowserApp extends GeckoApp
// This has to be prepared prior to calling GeckoApp.onCreate, because
// widget code and BrowserToolbar need it, and they're created by the
// layout, which GeckoApp takes care of.
final GeckoApplication app = (GeckoApplication) getApplication();
app.prepareLightweightTheme();
((GeckoApplication) getApplication()).prepareLightweightTheme();
super.onCreate(savedInstanceState);
@ -678,8 +676,6 @@ public class BrowserApp extends GeckoApp
}
});
app.getLightweightTheme().addListener(this);
mProgressView = (AnimatedProgressBar) findViewById(R.id.page_progress);
mDynamicToolbar.setLayerView(mLayerView);
mProgressView.setDynamicToolbar(mDynamicToolbar);
@ -1555,9 +1551,6 @@ public class BrowserApp extends GeckoApp
mDynamicToolbar.destroy();
final GeckoApplication app = (GeckoApplication) getApplication();
app.getLightweightTheme().removeListener(this);
if (mBrowserToolbar != null)
mBrowserToolbar.onDestroy();
@ -2337,7 +2330,8 @@ public class BrowserApp extends GeckoApp
delegate.onTabsTrayHidden(this, mTabsPanel);
}
refreshStatusBarColor();
final boolean isPrivate = mBrowserToolbar.isPrivateMode();
WindowUtil.setStatusBarColor(this, isPrivate);
}
@Override
@ -4454,19 +4448,4 @@ public class BrowserApp extends GeckoApp
public void onEditBookmark(@NonNull Bundle bundle) {
new EditBookmarkTask(this, bundle).execute();
}
@Override
public void onLightweightThemeChanged() {
refreshStatusBarColor();
}
@Override
public void onLightweightThemeReset() {
refreshStatusBarColor();
}
private void refreshStatusBarColor() {
final boolean isPrivate = mBrowserToolbar.isPrivateMode();
WindowUtil.setStatusBarColor(BrowserApp.this, isPrivate);
}
}

Просмотреть файл

@ -33,7 +33,6 @@ import android.graphics.Rect;
import android.graphics.Shader;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.support.annotation.ColorInt;
import android.text.TextUtils;
import android.util.Log;
import android.view.Gravity;
@ -51,7 +50,7 @@ public class LightweightTheme implements BundleEventListener {
private final Application mApplication;
private Bitmap mBitmap;
private @ColorInt int mColor;
private int mColor;
private boolean mIsLight;
public static interface OnChangeListener {
@ -236,8 +235,8 @@ public class LightweightTheme implements BundleEventListener {
mColor = Color.parseColor(color);
} catch (Exception e) {
// Malformed or missing color.
// We attempt calculating an accent colour ourselves, falling back to TRANSPARENT.
mColor = BitmapUtils.getDominantColor(bitmap, Color.TRANSPARENT);
// Default to TRANSPARENT.
mColor = Color.TRANSPARENT;
}
// Calculate the luminance to determine if it's a light or a dark theme.
@ -317,13 +316,6 @@ public class LightweightTheme implements BundleEventListener {
return mIsLight;
}
/**
* @return The accent color of the theme.
*/
public @ColorInt int getColor() {
return mColor;
}
/**
* Crop the image based on the position of the view on the window.
* Either the View or one of its ancestors might have scrolled or translated.

Просмотреть файл

@ -6,7 +6,6 @@
package org.mozilla.gecko.util;
import android.app.Activity;
import android.graphics.Color;
import android.os.Build;
import android.support.annotation.ColorInt;
import android.support.annotation.ColorRes;
@ -14,9 +13,7 @@ import android.support.v4.content.ContextCompat;
import android.view.View;
import android.view.Window;
import org.mozilla.gecko.GeckoApplication;
import org.mozilla.gecko.R;
import org.mozilla.gecko.lwt.LightweightTheme;
public class WindowUtil {
@ -32,27 +29,17 @@ public class WindowUtil {
return;
}
final @ColorInt int color;
final @ColorRes int colorResId;
final boolean isDarkTheme;
if (HardwareUtils.isTablet()) {
color = ContextCompat.getColor(activity, R.color.status_bar_bg_color_tablet);
colorResId = R.color.status_bar_bg_color_tablet;
isDarkTheme = true;
} else {
LightweightTheme theme = ((GeckoApplication) activity.getApplication()).getLightweightTheme();
@ColorInt int themeColor = theme.getColor();
if (isPrivate) {
color = ContextCompat.getColor(activity, R.color.status_bar_bg_color_private);
isDarkTheme = true;
} else if (theme.isEnabled() && themeColor != Color.TRANSPARENT) {
color = themeColor;
isDarkTheme = !theme.isLightTheme();
} else {
color = ContextCompat.getColor(activity, R.color.status_bar_bg_color);
isDarkTheme = false;
}
colorResId = isPrivate ? R.color.status_bar_bg_color_private : R.color.status_bar_bg_color;
isDarkTheme = isPrivate;
}
setStatusBarColor(activity, color, isDarkTheme);
setStatusBarColorRes(activity, colorResId, isDarkTheme);
}
public static void setStatusBarColorRes(final Activity activity, final @ColorRes int colorResId,