diff --git a/core/java/android/view/ViewConfiguration.java b/core/java/android/view/ViewConfiguration.java index 35e75699d72d..8470c2c71edc 100644 --- a/core/java/android/view/ViewConfiguration.java +++ b/core/java/android/view/ViewConfiguration.java @@ -31,6 +31,7 @@ import android.os.Bundle; import android.os.RemoteException; import android.os.StrictMode; +import android.os.SystemProperties; import android.provider.Settings; import android.util.DisplayMetrics; import android.util.Log; @@ -467,10 +468,49 @@ private ViewConfiguration(Context context) { mDoubleTapTouchSlop = mTouchSlop; - mMinimumFlingVelocity = res.getDimensionPixelSize( - com.android.internal.R.dimen.config_viewMinFlingVelocity); - mMaximumFlingVelocity = res.getDimensionPixelSize( - com.android.internal.R.dimen.config_viewMaxFlingVelocity); + // Modification by xdevs23 for better responsiveness using + // system.prop + String minFlingVeloProp = "ro.min.fling_velocity", // Min fling prop + maxFlingVeloProp = "ro.max.fling_velocity"; // Max fling prop + // Get the properties + String minFlingVeloSysProp = SystemProperties.get(minFlingVeloProp), + maxFlingVeloSysProp = SystemProperties.get(maxFlingVeloProp); + boolean isMaxFlingVeloPredefined = false, + isMinFlingVeloPredefined = false; + int minFlingVeloTmp = 0, + maxFlingVeloTmp = 0; + + // Check whether the property values are valid + if(minFlingVeloSysProp != null && (!minFlingVeloSysProp.isEmpty()) && + isNumeric(minFlingVeloSysProp)) { + minFlingVeloTmp = Integer.parseInt(minFlingVeloSysProp); + isMinFlingVeloPredefined = true; + } + + if(maxFlingVeloSysProp != null && (!maxFlingVeloSysProp.isEmpty()) && + isNumeric(maxFlingVeloSysProp)) { + maxFlingVeloTmp = Integer.parseInt(maxFlingVeloSysProp); + isMaxFlingVeloPredefined = true; + } + + // Use config values if no prop available or invalid + if(!isMinFlingVeloPredefined && minFlingVeloTmp == 0) + minFlingVeloTmp = res.getDimensionPixelSize( + com.android.internal.R.dimen.config_viewMinFlingVelocity); + if(!isMaxFlingVeloPredefined && maxFlingVeloTmp == 0) + maxFlingVeloTmp = res.getDimensionPixelSize( + com.android.internal.R.dimen.config_viewMaxFlingVelocity); + + // Check again for availability, otherwise use default values + if(minFlingVeloTmp * maxFlingVeloTmp == 0) { + minFlingVeloTmp = MINIMUM_FLING_VELOCITY; + maxFlingVeloTmp = MAXIMUM_FLING_VELOCITY; + } + + // Assign the final variables + mMinimumFlingVelocity = minFlingVeloTmp; + mMaximumFlingVelocity = maxFlingVeloTmp; + mGlobalActionsKeyTimeout = res.getInteger( com.android.internal.R.integer.config_globalActionsKeyTimeout); @@ -489,6 +529,18 @@ private ViewConfiguration(Context context) { com.android.internal.R.integer.config_screenshotChordKeyTimeout); } + /** + * @hide + */ + public static boolean isNumeric(String string) { + try { + Integer.parseInt(string); + } catch(NumberFormatException e) { + return false; + } + return true; + } + /** * Returns a configuration for the specified visual {@link Context}. The configuration depends * on various parameters of the {@link Context}, like the dimension of the display or the