Use config_screen_metrics resource in BogusMoveEventDetector
Change-Id: I6b957b43c6dd7ce4f639e46d248179662c1ee669main
parent
db6d9b0ab4
commit
9c4de1e5f7
|
@ -19,11 +19,6 @@
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<resources>
|
<resources>
|
||||||
<!-- Screen metrics for logging.
|
<!-- Must be aligned with {@link Constants#SCREEN_METRICS_LARGE_PHONE}. -->
|
||||||
0 = "small phone screen"
|
<integer name="config_screen_metrics">1</integer>
|
||||||
1 = "large phone screen"
|
|
||||||
2 = "large tablet screen"
|
|
||||||
3 = "small tablet screen"
|
|
||||||
-->
|
|
||||||
<integer name="log_screen_metrics">1</integer>
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -19,11 +19,6 @@
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<resources>
|
<resources>
|
||||||
<!-- Screen metrics for logging.
|
<!-- Must be aligned with {@link Constants#SCREEN_METRICS_SMALL_TABLET}. -->
|
||||||
0 = "small phone screen"
|
<integer name="config_screen_metrics">3</integer>
|
||||||
1 = "large phone screen"
|
|
||||||
2 = "large tablet screen"
|
|
||||||
3 = "small tablet screen"
|
|
||||||
-->
|
|
||||||
<integer name="log_screen_metrics">3</integer>
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -19,11 +19,6 @@
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<resources>
|
<resources>
|
||||||
<!-- Screen metrics for logging.
|
<!-- Must be aligned with {@link Constants#SCREEN_METRICS_LARGE_TABLET}. -->
|
||||||
0 = "small phone screen"
|
<integer name="config_screen_metrics">2</integer>
|
||||||
1 = "large phone screen"
|
|
||||||
2 = "large tablet screen"
|
|
||||||
3 = "small tablet screen"
|
|
||||||
-->
|
|
||||||
<integer name="log_screen_metrics">2</integer>
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -19,11 +19,6 @@
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<resources>
|
<resources>
|
||||||
<!-- Screen metrics for logging.
|
<!-- Must be aligned with {@link Constants#SCREEN_METRICS_SMALL_PHONE}. -->
|
||||||
0 = "small phone screen"
|
<integer name="config_screen_metrics">0</integer>
|
||||||
1 = "large phone screen"
|
|
||||||
2 = "large tablet screen"
|
|
||||||
3 = "small tablet screen"
|
|
||||||
-->
|
|
||||||
<integer name="log_screen_metrics">0</integer>
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -20,7 +20,9 @@ import android.content.res.Resources;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import com.android.inputmethod.latin.Constants;
|
||||||
import com.android.inputmethod.latin.LatinImeLogger;
|
import com.android.inputmethod.latin.LatinImeLogger;
|
||||||
|
import com.android.inputmethod.latin.R;
|
||||||
|
|
||||||
// This hack is applied to certain classes of tablets.
|
// This hack is applied to certain classes of tablets.
|
||||||
public final class BogusMoveEventDetector {
|
public final class BogusMoveEventDetector {
|
||||||
|
@ -32,9 +34,6 @@ public final class BogusMoveEventDetector {
|
||||||
private static final float BOGUS_MOVE_ACCUMULATED_DISTANCE_THRESHOLD = 0.53f;
|
private static final float BOGUS_MOVE_ACCUMULATED_DISTANCE_THRESHOLD = 0.53f;
|
||||||
private static final float BOGUS_MOVE_RADIUS_THRESHOLD = 1.14f;
|
private static final float BOGUS_MOVE_RADIUS_THRESHOLD = 1.14f;
|
||||||
|
|
||||||
private static final int SMALL_TABLET_SMALLEST_WIDTH = 600; // dp
|
|
||||||
private static final int LARGE_TABLET_SMALLEST_WIDTH = 768; // dp
|
|
||||||
|
|
||||||
private static boolean sNeedsProximateBogusDownMoveUpEventHack;
|
private static boolean sNeedsProximateBogusDownMoveUpEventHack;
|
||||||
|
|
||||||
public static void init(final Resources res) {
|
public static void init(final Resources res) {
|
||||||
|
@ -43,16 +42,17 @@ public final class BogusMoveEventDetector {
|
||||||
// Though it seems odd to use screen density as criteria of the quality of the touch
|
// Though it seems odd to use screen density as criteria of the quality of the touch
|
||||||
// screen, the small table that has a less density screen than hdpi most likely has been
|
// screen, the small table that has a less density screen than hdpi most likely has been
|
||||||
// made with the touch screen that needs the hack.
|
// made with the touch screen that needs the hack.
|
||||||
final int sw = res.getConfiguration().smallestScreenWidthDp;
|
final int screenMetrics = res.getInteger(R.integer.config_screen_metrics);
|
||||||
final boolean isLargeTablet = (sw >= LARGE_TABLET_SMALLEST_WIDTH);
|
final boolean isLargeTablet = (screenMetrics == Constants.SCREEN_METRICS_LARGE_TABLET);
|
||||||
final boolean isSmallTablet =
|
final boolean isSmallTablet = (screenMetrics == Constants.SCREEN_METRICS_SMALL_TABLET);
|
||||||
(sw >= SMALL_TABLET_SMALLEST_WIDTH && sw < LARGE_TABLET_SMALLEST_WIDTH);
|
|
||||||
final int densityDpi = res.getDisplayMetrics().densityDpi;
|
final int densityDpi = res.getDisplayMetrics().densityDpi;
|
||||||
final boolean hasLowDensityScreen = (densityDpi < DisplayMetrics.DENSITY_HIGH);
|
final boolean hasLowDensityScreen = (densityDpi < DisplayMetrics.DENSITY_HIGH);
|
||||||
final boolean needsTheHack = isLargeTablet || (isSmallTablet && hasLowDensityScreen);
|
final boolean needsTheHack = isLargeTablet || (isSmallTablet && hasLowDensityScreen);
|
||||||
if (DEBUG_MODE) {
|
if (DEBUG_MODE) {
|
||||||
|
final int sw = res.getConfiguration().smallestScreenWidthDp;
|
||||||
Log.d(TAG, "needsProximateBogusDownMoveUpEventHack=" + needsTheHack
|
Log.d(TAG, "needsProximateBogusDownMoveUpEventHack=" + needsTheHack
|
||||||
+ " smallestScreenWidthDp=" + sw + " densityDpi=" + densityDpi);
|
+ " smallestScreenWidthDp=" + sw + " densityDpi=" + densityDpi
|
||||||
|
+ " screenMetrics=" + screenMetrics);
|
||||||
}
|
}
|
||||||
sNeedsProximateBogusDownMoveUpEventHack = needsTheHack;
|
sNeedsProximateBogusDownMoveUpEventHack = needsTheHack;
|
||||||
}
|
}
|
||||||
|
|
|
@ -248,6 +248,15 @@ public final class Constants {
|
||||||
|
|
||||||
public static final int MAX_INT_BIT_COUNT = 32;
|
public static final int MAX_INT_BIT_COUNT = 32;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Screen metrics (a.k.a. Device form factor) constants of
|
||||||
|
* {@link R.integer#config_screen_metrics}.
|
||||||
|
*/
|
||||||
|
public static final int SCREEN_METRICS_SMALL_PHONE = 0;
|
||||||
|
public static final int SCREEN_METRICS_LARGE_PHONE = 1;
|
||||||
|
public static final int SCREEN_METRICS_LARGE_TABLET = 2;
|
||||||
|
public static final int SCREEN_METRICS_SMALL_TABLET = 3;
|
||||||
|
|
||||||
private Constants() {
|
private Constants() {
|
||||||
// This utility class is not publicly instantiable.
|
// This utility class is not publicly instantiable.
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue