| Index: ui/android/java/src/org/chromium/ui/gfx/ViewConfigurationHelper.java
|
| diff --git a/ui/android/java/src/org/chromium/ui/gfx/ViewConfigurationHelper.java b/ui/android/java/src/org/chromium/ui/gfx/ViewConfigurationHelper.java
|
| index 91bfd69c1f5d77e2407bb449ae0f8ce03c570deb..2c57c9207bc88ebdcab8618954c9747819e55959 100644
|
| --- a/ui/android/java/src/org/chromium/ui/gfx/ViewConfigurationHelper.java
|
| +++ b/ui/android/java/src/org/chromium/ui/gfx/ViewConfigurationHelper.java
|
| @@ -5,12 +5,12 @@
|
| package org.chromium.ui.gfx;
|
|
|
| import android.content.ComponentCallbacks;
|
| -import android.content.Context;
|
| import android.content.res.Configuration;
|
| import android.content.res.Resources;
|
| import android.util.TypedValue;
|
| import android.view.ViewConfiguration;
|
|
|
| +import org.chromium.base.ContextUtils;
|
| import org.chromium.base.annotations.CalledByNative;
|
| import org.chromium.base.annotations.JNINamespace;
|
| import org.chromium.ui.R;
|
| @@ -27,19 +27,17 @@ public class ViewConfigurationHelper {
|
| // ui/android/java/res/values/dimens.xml.
|
| private static final float MIN_SCALING_SPAN_MM = 12.0f;
|
|
|
| - private final Context mAppContext;
|
| private ViewConfiguration mViewConfiguration;
|
| private float mDensity;
|
|
|
| - private ViewConfigurationHelper(Context context) {
|
| - mAppContext = context.getApplicationContext();
|
| - mViewConfiguration = ViewConfiguration.get(mAppContext);
|
| - mDensity = mAppContext.getResources().getDisplayMetrics().density;
|
| + private ViewConfigurationHelper() {
|
| + mViewConfiguration = ViewConfiguration.get(ContextUtils.getApplicationContext());
|
| + mDensity = ContextUtils.getApplicationContext().getResources().getDisplayMetrics().density;
|
| assert mDensity > 0;
|
| }
|
|
|
| private void registerListener() {
|
| - mAppContext.registerComponentCallbacks(
|
| + ContextUtils.getApplicationContext().registerComponentCallbacks(
|
| new ComponentCallbacks() {
|
| @Override
|
| public void onConfigurationChanged(Configuration configuration) {
|
| @@ -53,15 +51,20 @@ public class ViewConfigurationHelper {
|
| }
|
|
|
| private void updateNativeViewConfigurationIfNecessary() {
|
| - ViewConfiguration configuration = ViewConfiguration.get(mAppContext);
|
| + ViewConfiguration configuration =
|
| + ViewConfiguration.get(ContextUtils.getApplicationContext());
|
| if (mViewConfiguration == configuration) {
|
| // The density should remain the same as long as the ViewConfiguration remains the same.
|
| - assert mDensity == mAppContext.getResources().getDisplayMetrics().density;
|
| + assert mDensity
|
| + == ContextUtils.getApplicationContext()
|
| + .getResources()
|
| + .getDisplayMetrics()
|
| + .density;
|
| return;
|
| }
|
|
|
| mViewConfiguration = configuration;
|
| - mDensity = mAppContext.getResources().getDisplayMetrics().density;
|
| + mDensity = ContextUtils.getApplicationContext().getResources().getDisplayMetrics().density;
|
| assert mDensity > 0;
|
| nativeUpdateSharedViewConfiguration(getMaximumFlingVelocity(), getMinimumFlingVelocity(),
|
| getTouchSlop(), getDoubleTapSlop(), getMinScalingSpan());
|
| @@ -108,7 +111,7 @@ public class ViewConfigurationHelper {
|
| }
|
|
|
| private int getScaledMinScalingSpan() {
|
| - final Resources res = mAppContext.getResources();
|
| + final Resources res = ContextUtils.getApplicationContext().getResources();
|
| // The correct minimum scaling span depends on how we recognize scale
|
| // gestures. Since we've deviated from Android, don't use the Android
|
| // system value here.
|
| @@ -130,8 +133,8 @@ public class ViewConfigurationHelper {
|
| }
|
|
|
| @CalledByNative
|
| - private static ViewConfigurationHelper createWithListener(Context context) {
|
| - ViewConfigurationHelper viewConfigurationHelper = new ViewConfigurationHelper(context);
|
| + private static ViewConfigurationHelper createWithListener() {
|
| + ViewConfigurationHelper viewConfigurationHelper = new ViewConfigurationHelper();
|
| viewConfigurationHelper.registerListener();
|
| return viewConfigurationHelper;
|
| }
|
|
|