diff options
Diffstat (limited to 'src/com/android/settings/accessibility/AccessibilityUtil.java')
-rw-r--r-- | src/com/android/settings/accessibility/AccessibilityUtil.java | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/com/android/settings/accessibility/AccessibilityUtil.java b/src/com/android/settings/accessibility/AccessibilityUtil.java index 8da6fbb920..76fb3ff53b 100644 --- a/src/com/android/settings/accessibility/AccessibilityUtil.java +++ b/src/com/android/settings/accessibility/AccessibilityUtil.java @@ -21,9 +21,11 @@ import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL; import android.accessibilityservice.AccessibilityServiceInfo; import android.content.ComponentName; import android.content.Context; +import android.content.res.Resources; import android.os.Build; import android.provider.Settings; import android.text.TextUtils; +import android.util.TypedValue; import android.view.accessibility.AccessibilityManager; import androidx.annotation.IntDef; @@ -350,4 +352,32 @@ final class AccessibilityUtil { "Unsupported userShortcutType " + shortcutType); } } + + /** + * Gets the width of the screen. + * + * @param context the current context. + * @return the width of the screen in terms of pixels. + */ + public static int getScreenWidthPixels(Context context) { + final Resources resources = context.getResources(); + final int screenWidthDp = resources.getConfiguration().screenWidthDp; + + return Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, screenWidthDp, + resources.getDisplayMetrics())); + } + + /** + * Gets the height of the screen. + * + * @param context the current context. + * @return the height of the screen in terms of pixels. + */ + public static int getScreenHeightPixels(Context context) { + final Resources resources = context.getResources(); + final int screenHeightDp = resources.getConfiguration().screenHeightDp; + + return Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, screenHeightDp, + resources.getDisplayMetrics())); + } } |