This source file includes following definitions.
- JNINamespace
- registerListener
- updateNativeViewConfigurationIfNecessary
- getDoubleTapTimeout
- getLongPressTimeout
- getTapTimeout
- getScrollFriction
- getScaledMaximumFlingVelocity
- getScaledMinimumFlingVelocity
- getScaledTouchSlop
- getScaledDoubleTapSlop
- getScaledMinScalingSpan
- getScaledMinScalingTouchMajor
- createWithListener
- nativeUpdateSharedViewConfiguration
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.view.ViewConfiguration;
import org.chromium.base.CalledByNative;
import org.chromium.base.JNINamespace;
import org.chromium.ui.R;
@JNINamespace("gfx")
public class ViewConfigurationHelper {
private final Context mAppContext;
private ViewConfiguration mViewConfiguration;
private ViewConfigurationHelper(Context context) {
mAppContext = context.getApplicationContext();
mViewConfiguration = ViewConfiguration.get(mAppContext);
}
private void registerListener() {
mAppContext.registerComponentCallbacks(
new ComponentCallbacks() {
@Override
public void onConfigurationChanged(Configuration configuration) {
updateNativeViewConfigurationIfNecessary();
}
@Override
public void onLowMemory() {
}
});
}
private void updateNativeViewConfigurationIfNecessary() {
ViewConfiguration configuration = ViewConfiguration.get(mAppContext);
if (mViewConfiguration == configuration) return;
mViewConfiguration = configuration;
nativeUpdateSharedViewConfiguration(
getScaledMaximumFlingVelocity(),
getScaledMinimumFlingVelocity(),
getScaledTouchSlop(),
getScaledDoubleTapSlop(),
getScaledMinScalingSpan(),
getScaledMinScalingTouchMajor());
}
@CalledByNative
private static int getDoubleTapTimeout() {
return ViewConfiguration.getDoubleTapTimeout();
}
@CalledByNative
private static int getLongPressTimeout() {
return ViewConfiguration.getLongPressTimeout();
}
@CalledByNative
private static int getTapTimeout() {
return ViewConfiguration.getTapTimeout();
}
@CalledByNative
private static float getScrollFriction() {
return ViewConfiguration.getScrollFriction();
}
@CalledByNative
private int getScaledMaximumFlingVelocity() {
return mViewConfiguration.getScaledMaximumFlingVelocity();
}
@CalledByNative
private int getScaledMinimumFlingVelocity() {
return mViewConfiguration.getScaledMinimumFlingVelocity();
}
@CalledByNative
private int getScaledTouchSlop() {
return mViewConfiguration.getScaledTouchSlop();
}
@CalledByNative
private int getScaledDoubleTapSlop() {
return mViewConfiguration.getScaledDoubleTapSlop();
}
@CalledByNative
private int getScaledMinScalingSpan() {
final Resources res = mAppContext.getResources();
int id = res.getIdentifier("config_minScalingSpan", "dimen", "android");
if (id == 0) id = R.dimen.config_min_scaling_span;
return res.getDimensionPixelSize(id);
}
@CalledByNative
private int getScaledMinScalingTouchMajor() {
final Resources res = mAppContext.getResources();
int id = res.getIdentifier("config_minScalingTouchMajor", "dimen", "android");
if (id == 0) id = R.dimen.config_min_scaling_touch_major;
return res.getDimensionPixelSize(id);
}
@CalledByNative
private static ViewConfigurationHelper createWithListener(Context context) {
ViewConfigurationHelper viewConfigurationHelper = new ViewConfigurationHelper(context);
viewConfigurationHelper.registerListener();
return viewConfigurationHelper;
}
private native void nativeUpdateSharedViewConfiguration(
int scaledMaximumFlingVelocity, int scaledMinimumFlingVelocity,
int scaledTouchSlop, int scaledDoubleTapSlop,
int scaledMinScalingSpan, int scaledMinScalingTouchMajor);
}