From 9aa27d13bd3d29f9118cb2f0df3d49ab36a0a2a5 Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Fri, 17 May 2024 08:25:13 +0700 Subject: [PATCH 1/3] docs: Add getOrientation, getWindowDensity, and getWindowSize APIs --- .../android/18.0/KMManager/getOrientation.md | 37 +++++++++++++++++++ .../18.0/KMManager/getWindowDensity.md | 34 +++++++++++++++++ .../android/18.0/KMManager/getWindowSize.md | 35 ++++++++++++++++++ .../engine/android/18.0/KMManager/index.md | 9 +++++ 4 files changed, 115 insertions(+) create mode 100644 developer/engine/android/18.0/KMManager/getOrientation.md create mode 100644 developer/engine/android/18.0/KMManager/getWindowDensity.md create mode 100644 developer/engine/android/18.0/KMManager/getWindowSize.md diff --git a/developer/engine/android/18.0/KMManager/getOrientation.md b/developer/engine/android/18.0/KMManager/getOrientation.md new file mode 100644 index 000000000..4bdc48699 --- /dev/null +++ b/developer/engine/android/18.0/KMManager/getOrientation.md @@ -0,0 +1,37 @@ +--- +title: KMManager.getOrientation() +--- + +## Summary + +The `getOrientation()` method returns the current orientation of the device. + +## Syntax + +```java +KMManager.getOrientation(Context context) +``` + +`context` +: The context. + +### ReturnsPoint = +Returns the device orientation as an int, one of: + +`Configuration.ORIENTATION_PORTRAIT` (`1`), + +`Configuration.ORIENTATION_LANDSCAPE` (`2`) + +`Configuration.ORIENTATION_UNDEFINED` (`0`) + +## Description +Use this method to get the current orientation of the device + +## Examples + +### Example: Using `getOrientation()` + +The following script illustrates the use of `getOrientation()`: +```java + int orientation = KMManager.getOrientation(context); +``` diff --git a/developer/engine/android/18.0/KMManager/getWindowDensity.md b/developer/engine/android/18.0/KMManager/getWindowDensity.md new file mode 100644 index 000000000..a5f54a123 --- /dev/null +++ b/developer/engine/android/18.0/KMManager/getWindowDensity.md @@ -0,0 +1,34 @@ +--- +title: KMManager.getWindowDensity() +--- + +## Summary + +The `getWindowDensity()` method returns the density of the window. + +## Syntax + +```java +KMManager.getWindowDensity(Context context) +``` + +`context` +: The context. + +### Returns +Returns the density + +## Description +Use this method to get the [density](https://developer.android.com/reference/android/util/DisplayMetrics#density) of the window. This is a scaling factor for the Density Independent Pixel (DIP) unit. + +## Examples + +### Example: Using `getWindowDensity()` + +The following script illustrates the use of `getWindowDensity()`: +```java + float density = KMManager.getWindowDensity(context); +``` + +## See Also +* [getWindowSize](getWindowSize) diff --git a/developer/engine/android/18.0/KMManager/getWindowSize.md b/developer/engine/android/18.0/KMManager/getWindowSize.md new file mode 100644 index 000000000..e1276de32 --- /dev/null +++ b/developer/engine/android/18.0/KMManager/getWindowSize.md @@ -0,0 +1,35 @@ +--- +title: KMManager.getWindowSize() +--- + +## Summary + +The `getWindowSize()` method returns the size of the area the window would occupy. + +## Syntax + +```java +KMManager.getWindowSize(Context context) +``` + +`context` +: The context. + +### Returns +Returns the window size (native resolution) of the display as (int x, int y). + +## Description +Use this method to get the size of the entire display. It may or may not include [system decoration areas](https://developer.android.com/reference/android/view/Display) + +## Examples + +### Example: Using `getWindowSize()` + +The following script illustrates the use of `getWindowSize()`: +```java + Point size = KMManager.getWindowSize(context); + int screenHeight = size.y; +``` + +## See also +* [getWindowDensity](getWindowDensity) \ No newline at end of file diff --git a/developer/engine/android/18.0/KMManager/index.md b/developer/engine/android/18.0/KMManager/index.md index e80ba9290..d29a6eb66 100644 --- a/developer/engine/android/18.0/KMManager/index.md +++ b/developer/engine/android/18.0/KMManager/index.md @@ -140,12 +140,21 @@ The KMManager is the core class which provides most of the methods and constants [`getMaySendCrashReport()`](getMaySendCrashReport) : returns whether Keyman Engine is allowed to send crash reports over the network to sentry.keyman.com +[`getOrientation()`](getOrientation) +: returns the device's current orientation (Portrait vs Landscape) + [`getSpacebarText()`](getSpacebarText) : returns the current text display pattern for the spacebar [`getVersion()`](getVersion) : returns the version number of Keyman Engine +[`getWindowDensity()`](getWindowDensity) +: returns the density of the window + +[`getWindowSize()`](getWindowSize) +: returns the size of an area the window would occupy + [`hasConnection()`](hasConnection) : returns whether the device has active network connection From 4dec4cc85171affbfff557fa3ea0b361f0d02f8a Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Fri, 17 May 2024 14:20:06 +0700 Subject: [PATCH 2/3] Apply suggestions from code review Co-authored-by: Marc Durdin --- .../engine/android/18.0/KMManager/getOrientation.md | 12 +++++------- .../android/18.0/KMManager/getWindowDensity.md | 2 +- .../engine/android/18.0/KMManager/getWindowSize.md | 2 +- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/developer/engine/android/18.0/KMManager/getOrientation.md b/developer/engine/android/18.0/KMManager/getOrientation.md index 4bdc48699..433ec1ee8 100644 --- a/developer/engine/android/18.0/KMManager/getOrientation.md +++ b/developer/engine/android/18.0/KMManager/getOrientation.md @@ -15,14 +15,12 @@ KMManager.getOrientation(Context context) `context` : The context. -### ReturnsPoint = +### Returns Returns the device orientation as an int, one of: -`Configuration.ORIENTATION_PORTRAIT` (`1`), - -`Configuration.ORIENTATION_LANDSCAPE` (`2`) - -`Configuration.ORIENTATION_UNDEFINED` (`0`) +* `Configuration.ORIENTATION_PORTRAIT` (`1`) +* `Configuration.ORIENTATION_LANDSCAPE` (`2`) +* `Configuration.ORIENTATION_UNDEFINED` (`0`) ## Description Use this method to get the current orientation of the device @@ -31,7 +29,7 @@ Use this method to get the current orientation of the device ### Example: Using `getOrientation()` -The following script illustrates the use of `getOrientation()`: +The following code illustrates the use of `getOrientation()`: ```java int orientation = KMManager.getOrientation(context); ``` diff --git a/developer/engine/android/18.0/KMManager/getWindowDensity.md b/developer/engine/android/18.0/KMManager/getWindowDensity.md index a5f54a123..49ce59e2b 100644 --- a/developer/engine/android/18.0/KMManager/getWindowDensity.md +++ b/developer/engine/android/18.0/KMManager/getWindowDensity.md @@ -25,7 +25,7 @@ Use this method to get the [density](https://developer.android.com/reference/and ### Example: Using `getWindowDensity()` -The following script illustrates the use of `getWindowDensity()`: +The following code illustrates the use of `getWindowDensity()`: ```java float density = KMManager.getWindowDensity(context); ``` diff --git a/developer/engine/android/18.0/KMManager/getWindowSize.md b/developer/engine/android/18.0/KMManager/getWindowSize.md index e1276de32..e8776bbb8 100644 --- a/developer/engine/android/18.0/KMManager/getWindowSize.md +++ b/developer/engine/android/18.0/KMManager/getWindowSize.md @@ -25,7 +25,7 @@ Use this method to get the size of the entire display. It may or may not include ### Example: Using `getWindowSize()` -The following script illustrates the use of `getWindowSize()`: +The following code illustrates the use of `getWindowSize()`: ```java Point size = KMManager.getWindowSize(context); int screenHeight = size.y; From 81fecbc97ea137d7dc39c3b3dd628e61fd17336a Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Wed, 22 May 2024 07:54:07 +0700 Subject: [PATCH 3/3] clarify size at different API levels --- developer/engine/android/18.0/KMManager/getWindowSize.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/developer/engine/android/18.0/KMManager/getWindowSize.md b/developer/engine/android/18.0/KMManager/getWindowSize.md index e8776bbb8..f3bd0a87d 100644 --- a/developer/engine/android/18.0/KMManager/getWindowSize.md +++ b/developer/engine/android/18.0/KMManager/getWindowSize.md @@ -19,7 +19,11 @@ KMManager.getWindowSize(Context context) Returns the window size (native resolution) of the display as (int x, int y). ## Description -Use this method to get the size of the entire display. It may or may not include [system decoration areas](https://developer.android.com/reference/android/view/Display) +Use this method to get the size of the entire display. + +For API level 29 and below, the size of the [entire display minus system decoration areas](https://developer.android.com/reference/android/view/Display#getSize(android.graphics.Point) is returned. + +For API level 30 and above, it may or may not include [system decoration areas](https://developer.android.com/reference/android/view/Display) ## Examples