Преглед изворни кода

Landscape only (#533)

* Landscape only option

* Fixed typo

* Removed old startApp

* Spacing
b_d пре 8 година
родитељ
комит
9e058dcf23

+ 3
- 0
android/app/src/main/AndroidManifest.xml Прегледај датотеку

@@ -6,6 +6,9 @@
6 6
         <activity
7 7
             android:name=".controllers.PortraitNavigationActivity"
8 8
             android:screenOrientation="portrait" />
9
+        <activity
10
+            android:name=".controllers.LandscapeNavigationActivity"
11
+            android:screenOrientation="landscape" />
9 12
         <activity
10 13
             android:name="com.facebook.react.devsupport.DevSettingsActivity"
11 14
             android:exported="false" />

+ 8
- 1
android/app/src/main/java/com/reactnativenavigation/bridge/NavigationReactModule.java Прегледај датотеку

@@ -45,10 +45,17 @@ public class NavigationReactModule extends ReactContextBaseJavaModule {
45 45
     @ReactMethod
46 46
     public void startApp(final ReadableMap params) {
47 47
         boolean portraitOnlyMode = false;
48
+        boolean landscapeOnlyMode = false;
49
+
48 50
         if (params.hasKey("portraitOnlyMode")) {
49 51
             portraitOnlyMode = params.getBoolean("portraitOnlyMode");
50 52
         }
51
-        NavigationCommandsHandler.startApp(BundleConverter.toBundle(params), portraitOnlyMode);
53
+
54
+        if (params.hasKey(("landscapeOnlyMode"))) {
55
+            landscapeOnlyMode = params.getBoolean("landscapeOnlyMode");
56
+        }
57
+
58
+        NavigationCommandsHandler.startApp(BundleConverter.toBundle(params), portraitOnlyMode, landscapeOnlyMode);
52 59
     }
53 60
 
54 61
     @ReactMethod

+ 4
- 0
android/app/src/main/java/com/reactnativenavigation/controllers/LandscapeNavigationActivity.java Прегледај датотеку

@@ -0,0 +1,4 @@
1
+package com.reactnativenavigation.controllers;
2
+
3
+public class LandscapeNavigationActivity extends NavigationActivity {
4
+}

+ 4
- 1
android/app/src/main/java/com/reactnativenavigation/controllers/NavigationCommandsHandler.java Прегледај датотеку

@@ -29,10 +29,13 @@ public class NavigationCommandsHandler {
29 29
      *
30 30
      * @param params ActivityParams as bundle
31 31
      */
32
-    public static void startApp(Bundle params, boolean portraitOnlyMode) {
32
+
33
+    public static void startApp(Bundle params, boolean portraitOnlyMode, boolean landscapeOnlyMode) {
33 34
         Intent intent;
34 35
         if (portraitOnlyMode) {
35 36
             intent = new Intent(NavigationApplication.instance, PortraitNavigationActivity.class);
37
+        } else if (landscapeOnlyMode) {
38
+            intent = new Intent(NavigationApplication.instance, LandscapeNavigationActivity.class);
36 39
         } else {
37 40
             intent = new Intent(NavigationApplication.instance, NavigationActivity.class);
38 41
         }