Skip to content

Commit

Permalink
[Android] Provide fallback scaling constants in ViewConfiguration
Browse files Browse the repository at this point in the history
Certain devices may lack the internal Android dimension lookups for
MinScalingSpan and MinScalingTouchMajor.  Provide sensible default backups
for this case.

BUG=345602
NOTRY=true

Review URL: https://codereview.chromium.org/175493002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@252641 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
jdduke@chromium.org committed Feb 21, 2014
1 parent 9d8d766 commit aae9941
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
8 changes: 8 additions & 0 deletions ui/android/java/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,12 @@
<dimen name="autofill_text_height">44dp</dimen>
<dimen name="autofill_text_divider_height">1px</dimen>

<!--
Fallback values if the corresponding com.android.internal.R dimensions
cannot be retrieved by name.
Note: Constants taken directly from Android's core/res/values/config.xml.
-->
<dimen name="config_minScalingSpan">27.0mm</dimen>
<dimen name="config_minScalingTouchMajor">48.0dp</dimen>

</resources>
2 changes: 2 additions & 0 deletions ui/android/java/resource_map/org/chromium/ui/R.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,7 @@ public static final class dimen {
public static int autofill_text_height;
public static int autofill_text_divider_height;
public static int color_button_height;
public static int config_minScalingSpan;
public static int config_minScalingTouchMajor;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import org.chromium.base.CalledByNative;
import org.chromium.base.JNINamespace;
import org.chromium.ui.R;

/**
* This class facilitates access to ViewConfiguration-related properties, also
Expand Down Expand Up @@ -100,14 +101,19 @@ private int getScaledDoubleTapSlop() {
@CalledByNative
private int getScaledMinScalingSpan() {
final Resources res = mAppContext.getResources();
final int id = res.getIdentifier("config_minScalingSpan", "dimen", "android");
int id = res.getIdentifier("config_minScalingSpan", "dimen", "android");
// Fall back to a sensible default if the internal identifier does not exist.
if (id == 0) id = res.getDimensionPixelSize(R.dimen.config_minScalingSpan);
return res.getDimensionPixelSize(id);

}

@CalledByNative
private int getScaledMinScalingTouchMajor() {
final Resources res = mAppContext.getResources();
final int id = res.getIdentifier("config_minScalingTouchMajor", "dimen", "android");
int id = res.getIdentifier("config_minScalingTouchMajor", "dimen", "android");
// Fall back to a sensible default if the internal identifier does not exist.
if (id == 0) id = res.getDimensionPixelSize(R.dimen.config_minScalingTouchMajor);
return res.getDimensionPixelSize(id);
}

Expand Down

0 comments on commit aae9941

Please sign in to comment.