Skip to content

Commit

Permalink
Merge pull request #1270 from keymanapp/docs/android/size-18
Browse files Browse the repository at this point in the history
docs: Add getOrientation, getWindowDensity, and getWindowSize APIs
  • Loading branch information
mcdurdin authored May 30, 2024
2 parents 7a2c545 + 81fecbc commit a374026
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 0 deletions.
35 changes: 35 additions & 0 deletions developer/engine/android/18.0/KMManager/getOrientation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
title: KMManager.getOrientation()
---

## Summary

The `getOrientation()` method returns the current orientation of the device.

## Syntax

```java
KMManager.getOrientation(Context context)
```

`context`
: The context.

### Returns
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 code illustrates the use of `getOrientation()`:
```java
int orientation = KMManager.getOrientation(context);
```
34 changes: 34 additions & 0 deletions developer/engine/android/18.0/KMManager/getWindowDensity.md
Original file line number Diff line number Diff line change
@@ -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 code illustrates the use of `getWindowDensity()`:
```java
float density = KMManager.getWindowDensity(context);
```

## See Also
* [getWindowSize](getWindowSize)
39 changes: 39 additions & 0 deletions developer/engine/android/18.0/KMManager/getWindowSize.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
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.

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

### Example: Using `getWindowSize()`

The following code illustrates the use of `getWindowSize()`:
```java
Point size = KMManager.getWindowSize(context);
int screenHeight = size.y;
```

## See also
* [getWindowDensity](getWindowDensity)
9 changes: 9 additions & 0 deletions developer/engine/android/18.0/KMManager/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit a374026

Please sign in to comment.