Skip to content

Commit

Permalink
Issue 7443: Add support for Android's sensorPortrait orientation. (#7454
Browse files Browse the repository at this point in the history
)

Co-authored-by: Guy Carmeli <[email protected]>
  • Loading branch information
zabojad and guyca authored Mar 3, 2022
1 parent cc8387f commit 7e9ea6c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ public enum Orientation {
Landscape("landscape", ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE),
Portrait("portrait", ActivityInfo.SCREEN_ORIENTATION_PORTRAIT),
PortraitLandscape("sensor", ActivityInfo.SCREEN_ORIENTATION_USER),
SensorLandscape("sensorLandscape", ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
SensorLandscape("sensorLandscape", ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE),
SensorPortrait("sensorPortrait", ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);

public String name;
public int orientationCode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public int getValue() {
return orientations.contains(Orientation.Landscape) ? Orientation.PortraitLandscape.orientationCode : Orientation.Portrait.orientationCode;
case SensorLandscape:
return Orientation.SensorLandscape.orientationCode;
case SensorPortrait:
return Orientation.SensorPortrait.orientationCode;
default:
case Default:
return Orientation.Default.orientationCode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,13 @@ public void parse() {

@Test
public void parseOrientations() {
OrientationOptions options = OrientationOptions.parse(create("default", "landscape", "portrait"));
OrientationOptions options = OrientationOptions.parse(create("default", "landscape", "portrait", "sensor", "sensorLandscape", "sensorPortrait"));
assertThat(options.orientations.get(0)).isEqualTo(Orientation.Default);
assertThat(options.orientations.get(1)).isEqualTo(Orientation.Landscape);
assertThat(options.orientations.get(2)).isEqualTo(Orientation.Portrait);
assertThat(options.orientations.get(3)).isEqualTo(Orientation.PortraitLandscape);
assertThat(options.orientations.get(4)).isEqualTo(Orientation.SensorLandscape);
assertThat(options.orientations.get(5)).isEqualTo(Orientation.SensorPortrait);
}

@Test
Expand Down
7 changes: 6 additions & 1 deletion lib/src/interfaces/Options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ type FontWeight =
| '800'
| '900'
| FontWeightIOS;
export type LayoutOrientation = 'portrait' | 'landscape';
export type LayoutOrientation =
| 'portrait'
| 'landscape'
| 'sensor'
| 'sensorLandscape'
| 'sensorPortrait';
type AndroidDensityNumber = number;
export type SystemItemIcon =
| 'done'
Expand Down

0 comments on commit 7e9ea6c

Please sign in to comment.