Browse Source

POC snackbar and FAB works. some minor formatting

Daniel Zlotin 8 years ago
parent
commit
785170ce27

+ 17
- 18
android/app/src/main/java/com/reactnativenavigation/activities/BaseReactActivity.java View File

@@ -46,9 +46,6 @@ import java.util.List;
46 46
 
47 47
 import javax.annotation.Nullable;
48 48
 
49
-/**
50
- * Base Activity for React Native applications.
51
- */
52 49
 public abstract class BaseReactActivity extends AppCompatActivity implements DefaultHardwareBackBtnHandler {
53 50
 
54 51
     protected static final String KEY_ANIMATED = "animated";
@@ -157,6 +154,7 @@ public abstract class BaseReactActivity extends AppCompatActivity implements Def
157 154
         ContextProvider.setActivityContext(this);
158 155
         mReactInstanceManager = createReactInstanceManager();
159 156
         handleOnCreate();
157
+
160 158
     }
161 159
 
162 160
     /**
@@ -176,14 +174,15 @@ public abstract class BaseReactActivity extends AppCompatActivity implements Def
176 174
 
177 175
     @CallSuper
178 176
     protected void handleOnCreate() {
179
-        if (getUseDeveloperSupport() && Build.VERSION.SDK_INT >= 23) {
180
-            // Get permission to show redbox in dev builds.
181
-            if (!Settings.canDrawOverlays(this)) {
182
-                Intent serviceIntent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION);
183
-                startActivity(serviceIntent);
184
-                FLog.w(ReactConstants.TAG, REDBOX_PERMISSION_MESSAGE);
185
-                Toast.makeText(this, REDBOX_PERMISSION_MESSAGE, Toast.LENGTH_LONG).show();
186
-            }
177
+        permissionToShowRedboxIfNeeded();
178
+    }
179
+
180
+    private void permissionToShowRedboxIfNeeded() {
181
+        if (getUseDeveloperSupport() && Build.VERSION.SDK_INT >= 23 && !Settings.canDrawOverlays(this)) {
182
+            Intent serviceIntent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION);
183
+            startActivity(serviceIntent);
184
+            FLog.w(ReactConstants.TAG, REDBOX_PERMISSION_MESSAGE);
185
+            Toast.makeText(this, REDBOX_PERMISSION_MESSAGE, Toast.LENGTH_LONG).show();
187 186
         }
188 187
     }
189 188
 
@@ -230,7 +229,7 @@ public abstract class BaseReactActivity extends AppCompatActivity implements Def
230 229
             mToolbar.update(screen);
231 230
 
232 231
             if (getCurrentNavigatorId().equals(screen.navigatorId) &&
233
-                getScreenStackSize() >= 1) {
232
+                    getScreenStackSize() >= 1) {
234 233
                 mToolbar.setNavUpButton(screen);
235 234
             }
236 235
         }
@@ -239,8 +238,8 @@ public abstract class BaseReactActivity extends AppCompatActivity implements Def
239 238
     @CallSuper
240 239
     public Screen pop(String navigatorId) {
241 240
         if (mToolbar != null &&
242
-            getCurrentNavigatorId().equals(navigatorId) &&
243
-            getScreenStackSize() <= 2) {
241
+                getCurrentNavigatorId().equals(navigatorId) &&
242
+                getScreenStackSize() <= 2) {
244 243
             mToolbar.setNavUpButton();
245 244
         }
246 245
 
@@ -303,8 +302,8 @@ public abstract class BaseReactActivity extends AppCompatActivity implements Def
303 302
     @Override
304 303
     public boolean onOptionsItemSelected(MenuItem item) {
305 304
         if (mDrawerToggle != null &&
306
-            getScreenStackSize() == 1 &&
307
-            mDrawerToggle.onOptionsItemSelected(item)) {
305
+                getScreenStackSize() == 1 &&
306
+                mDrawerToggle.onOptionsItemSelected(item)) {
308 307
             return true;
309 308
         }
310 309
 
@@ -342,7 +341,7 @@ public abstract class BaseReactActivity extends AppCompatActivity implements Def
342 341
     @Override
343 342
     public boolean onKeyUp(int keyCode, KeyEvent event) {
344 343
         if (mReactInstanceManager != null &&
345
-            mReactInstanceManager.getDevSupportManager().getDevSupportEnabled()) {
344
+                mReactInstanceManager.getDevSupportManager().getDevSupportEnabled()) {
346 345
             if (keyCode == KeyEvent.KEYCODE_MENU) {
347 346
                 mReactInstanceManager.showDevOptionsDialog();
348 347
                 return true;
@@ -400,7 +399,7 @@ public abstract class BaseReactActivity extends AppCompatActivity implements Def
400 399
         mDrawerToggle = mToolbar.setupDrawer(mDrawerLayout, drawer.left, screen);
401 400
     }
402 401
 
403
-    public void setNavigationButtons(ReadableMap buttons){
402
+    public void setNavigationButtons(ReadableMap buttons) {
404 403
         if (mToolbar == null) {
405 404
             return;
406 405
         }

+ 5
- 9
android/app/src/main/java/com/reactnativenavigation/activities/BottomTabActivity.java View File

@@ -22,9 +22,6 @@ import java.util.ArrayList;
22 22
 import java.util.HashMap;
23 23
 import java.util.Map;
24 24
 
25
-/**
26
- * Created by guyc on 02/04/16.
27
- */
28 25
 public class BottomTabActivity extends BaseReactActivity implements AHBottomNavigation.OnTabSelectedListener {
29 26
     public static final String DRAWER_PARAMS = "drawerParams";
30 27
     public static final String EXTRA_SCREENS = "extraScreens";
@@ -84,7 +81,7 @@ public class BottomTabActivity extends BaseReactActivity implements AHBottomNavi
84 81
     @Override
85 82
     protected void onResume() {
86 83
         super.onResume();
87
-        if(mScreenStacks != null) {
84
+        if (mScreenStacks != null) {
88 85
             StyleHelper.updateStyles(mToolbar, getCurrentScreen());
89 86
         }
90 87
     }
@@ -100,8 +97,7 @@ public class BottomTabActivity extends BaseReactActivity implements AHBottomNavi
100 97
     private static int getColor(Bundle bundle, String key, int defaultColor) {
101 98
         if (bundle.containsKey(key)) {
102 99
             return Color.parseColor(bundle.getString(key));
103
-        }
104
-        else {
100
+        } else {
105 101
             return defaultColor;
106 102
         }
107 103
     }
@@ -127,7 +123,7 @@ public class BottomTabActivity extends BaseReactActivity implements AHBottomNavi
127 123
     @Override
128 124
     public Screen pop(String navigatorId) {
129 125
         super.pop(navigatorId);
130
-        for (ScreenStack stack: mScreenStacks) {
126
+        for (ScreenStack stack : mScreenStacks) {
131 127
             if (stack.peek().navigatorId.equals(navigatorId)) {
132 128
                 Screen popped = stack.pop();
133 129
                 StyleHelper.updateStyles(mToolbar, getCurrentScreen());
@@ -140,7 +136,7 @@ public class BottomTabActivity extends BaseReactActivity implements AHBottomNavi
140 136
     @Override
141 137
     public Screen popToRoot(String navigatorId) {
142 138
         super.popToRoot(navigatorId);
143
-        for (ScreenStack stack: mScreenStacks) {
139
+        for (ScreenStack stack : mScreenStacks) {
144 140
             if (stack.peek().navigatorId.equals(navigatorId)) {
145 141
                 Screen popped = stack.popToRoot();
146 142
                 StyleHelper.updateStyles(mToolbar, getCurrentScreen());
@@ -261,7 +257,7 @@ public class BottomTabActivity extends BaseReactActivity implements AHBottomNavi
261 257
 
262 258
     private void setTabsWithIcons(ArrayList<Screen> screens, Map<Screen, Drawable> icons) {
263 259
         mScreenStacks = new ArrayList<>();
264
-        for(Screen screen: screens) {
260
+        for (Screen screen : screens) {
265 261
             ScreenStack stack = new ScreenStack(this);
266 262
             stack.push(screen);
267 263
             mScreenStacks.add(stack);

+ 4
- 1
android/app/src/main/java/com/reactnativenavigation/activities/RootActivity.java View File

@@ -1,5 +1,7 @@
1 1
 package com.reactnativenavigation.activities;
2 2
 
3
+import android.view.ViewGroup;
4
+
3 5
 import com.facebook.react.ReactRootView;
4 6
 import com.reactnativenavigation.core.objects.Screen;
5 7
 
@@ -26,7 +28,7 @@ public class RootActivity extends BaseReactActivity {
26 28
         finish();
27 29
     }
28 30
 
29
-     // No need to implement stack interface since this activity is only used to start other
31
+    // No need to implement stack interface since this activity is only used to start other
30 32
     // activities such as TabActivity or SingleScreenActivity.
31 33
     @Override
32 34
     public Screen getCurrentScreen() {
@@ -42,4 +44,5 @@ public class RootActivity extends BaseReactActivity {
42 44
     public int getScreenStackSize() {
43 45
         return 0;
44 46
     }
47
+
45 48
 }

+ 0
- 3
android/app/src/main/java/com/reactnativenavigation/activities/SingleScreenActivity.java View File

@@ -10,9 +10,6 @@ import com.reactnativenavigation.utils.StyleHelper;
10 10
 import com.reactnativenavigation.views.RnnToolBar;
11 11
 import com.reactnativenavigation.views.ScreenStack;
12 12
 
13
-/**
14
- * Created by guyc on 05/04/16.
15
- */
16 13
 public class SingleScreenActivity extends BaseReactActivity {
17 14
 
18 15
     public static final String DRAWER_PARAMS = "drawerParams";

+ 2
- 0
android/app/src/main/java/com/reactnativenavigation/activities/TabActivity.java View File

@@ -1,7 +1,9 @@
1 1
 package com.reactnativenavigation.activities;
2 2
 
3
+import android.support.design.widget.CoordinatorLayout;
3 4
 import android.support.v4.view.ViewPager;
4 5
 import android.view.Menu;
6
+import android.view.ViewGroup;
5 7
 
6 8
 import com.reactnativenavigation.R;
7 9
 import com.reactnativenavigation.adapters.ViewPagerAdapter;

+ 0
- 4
android/app/src/main/java/com/reactnativenavigation/modules/RctActivityModule.java View File

@@ -23,9 +23,6 @@ import com.reactnativenavigation.utils.ContextProvider;
23 23
 
24 24
 import java.util.ArrayList;
25 25
 
26
-/**
27
- * Created by guyc on 10/03/16.
28
- */
29 26
 public class RctActivityModule extends ReactContextBaseJavaModule {
30 27
     public static final String REACT_CLASS = "RctActivity";
31 28
     private static final String KEY_NAVIGATOR_ID = "navigatorID";
@@ -321,7 +318,6 @@ public class RctActivityModule extends ReactContextBaseJavaModule {
321 318
         }
322 319
     }
323 320
 
324
-
325 321
     /**
326 322
      * Dismisses the top modal (the last modal pushed).
327 323
      */

+ 0
- 4
android/app/src/main/java/com/reactnativenavigation/packages/RnnPackage.java View File

@@ -11,10 +11,6 @@ import java.util.Arrays;
11 11
 import java.util.Collections;
12 12
 import java.util.List;
13 13
 
14
-/**
15
- *
16
- * Created by guyc on 07/03/16.
17
- */
18 14
 public class RnnPackage implements ReactPackage {
19 15
 
20 16
     @Override

+ 13
- 10
android/app/src/main/res/layout/bottom_tab_activity.xml View File

@@ -1,45 +1,48 @@
1 1
 <?xml version="1.0" encoding="utf-8"?>
2 2
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
-    xmlns:tools="http://schemas.android.com/tools"
4 3
     xmlns:app="http://schemas.android.com/apk/res-auto"
5
-    android:orientation="vertical"
4
+    xmlns:tools="http://schemas.android.com/tools"
6 5
     android:layout_width="match_parent"
7 6
     android:layout_height="match_parent"
8
-    tools:context=".activities.TabActivity"
9
-    android:animateLayoutChanges="true">
7
+    android:animateLayoutChanges="true"
8
+    android:orientation="vertical"
9
+    tools:context=".activities.BottomTabActivity">
10 10
 
11 11
     <android.support.design.widget.AppBarLayout
12 12
         android:id="@+id/appbar"
13 13
         android:layout_width="match_parent"
14 14
         android:layout_height="wrap_content"
15 15
         android:fitsSystemWindows="true">
16
+
16 17
         <com.reactnativenavigation.views.RnnToolBar
17 18
             android:id="@+id/toolbar"
18 19
             android:layout_width="match_parent"
19 20
             android:layout_height="?attr/actionBarSize"
20
-            app:layout_scrollFlags="scroll|enterAlways"/>
21
+            app:layout_scrollFlags="scroll|enterAlways" />
21 22
     </android.support.design.widget.AppBarLayout>
22 23
 
23 24
     <android.support.v4.widget.DrawerLayout
24
-        xmlns:android="http://schemas.android.com/apk/res/android"
25 25
         android:id="@+id/drawerLayout"
26 26
         android:layout_width="match_parent"
27 27
         android:layout_height="0dp"
28 28
         android:layout_weight="1">
29
+
29 30
         <FrameLayout
30 31
             android:id="@+id/contentFrame"
31 32
             android:layout_width="match_parent"
32 33
             android:layout_height="0dp"
33
-            android:layout_weight="1"/>
34
-        <FrameLayout android:id="@+id/drawerFrame"
34
+            android:layout_weight="1" />
35
+
36
+        <FrameLayout
37
+            android:id="@+id/drawerFrame"
35 38
             android:layout_width="240dp"
36 39
             android:layout_height="match_parent"
37
-            android:layout_gravity="start"/>
40
+            android:layout_gravity="start" />
38 41
     </android.support.v4.widget.DrawerLayout>
39 42
 
40 43
     <com.aurelhubert.ahbottomnavigation.AHBottomNavigation
41 44
         android:id="@+id/bottom_tab_bar"
42 45
         android:layout_width="match_parent"
43
-        android:layout_height="wrap_content"/>
46
+        android:layout_height="wrap_content" />
44 47
 
45 48
 </LinearLayout>

+ 6
- 5
android/app/src/main/res/layout/modal_layout.xml View File

@@ -1,25 +1,26 @@
1 1
 <?xml version="1.0" encoding="utf-8"?>
2 2
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 3
     xmlns:app="http://schemas.android.com/apk/res-auto"
4
-    android:background="@android:color/transparent"
5
-    android:orientation="vertical"
6 4
     android:layout_width="match_parent"
7
-    android:layout_height="match_parent">
5
+    android:layout_height="match_parent"
6
+    android:background="@android:color/transparent"
7
+    android:orientation="vertical">
8 8
 
9 9
     <android.support.design.widget.AppBarLayout
10 10
         android:id="@+id/appbar"
11 11
         android:layout_width="match_parent"
12 12
         android:layout_height="wrap_content"
13 13
         android:fitsSystemWindows="true">
14
+
14 15
         <com.reactnativenavigation.views.RnnToolBar
15 16
             android:id="@+id/toolbar"
16 17
             android:layout_width="match_parent"
17 18
             android:layout_height="?attr/actionBarSize"
18
-            app:layout_scrollFlags="scroll|enterAlways"/>
19
+            app:layout_scrollFlags="scroll|enterAlways" />
19 20
     </android.support.design.widget.AppBarLayout>
20 21
 
21 22
     <com.reactnativenavigation.views.ScreenStack
22 23
         android:id="@+id/screenStack"
23 24
         android:layout_width="match_parent"
24
-        android:layout_height="match_parent"/>
25
+        android:layout_height="match_parent" />
25 26
 </LinearLayout>

+ 10
- 7
android/app/src/main/res/layout/single_screen_activity.xml View File

@@ -1,34 +1,37 @@
1 1
 <?xml version="1.0" encoding="utf-8"?>
2 2
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 3
     xmlns:app="http://schemas.android.com/apk/res-auto"
4
-    android:orientation="vertical"
5 4
     android:layout_width="match_parent"
6
-    android:layout_height="match_parent">
5
+    android:layout_height="match_parent"
6
+    android:orientation="vertical">
7 7
 
8 8
     <android.support.design.widget.AppBarLayout
9 9
         android:id="@+id/appbar"
10 10
         android:layout_width="match_parent"
11 11
         android:layout_height="wrap_content"
12 12
         android:fitsSystemWindows="true">
13
+
13 14
         <com.reactnativenavigation.views.RnnToolBar
14 15
             android:id="@+id/toolbar"
15 16
             android:layout_width="match_parent"
16 17
             android:layout_height="?attr/actionBarSize"
17
-            app:layout_scrollFlags="scroll|enterAlways"/>
18
+            app:layout_scrollFlags="scroll|enterAlways" />
18 19
     </android.support.design.widget.AppBarLayout>
19 20
 
20 21
     <android.support.v4.widget.DrawerLayout
21
-        xmlns:android="http://schemas.android.com/apk/res/android"
22 22
         android:id="@+id/drawerLayout"
23 23
         android:layout_width="match_parent"
24 24
         android:layout_height="match_parent">
25
+
25 26
         <FrameLayout
26 27
             android:id="@+id/contentFrame"
27 28
             android:layout_width="match_parent"
28
-            android:layout_height="match_parent"/>
29
-        <FrameLayout android:id="@+id/drawerFrame"
29
+            android:layout_height="match_parent" />
30
+
31
+        <FrameLayout
32
+            android:id="@+id/drawerFrame"
30 33
             android:layout_width="240dp"
31 34
             android:layout_height="match_parent"
32
-            android:layout_gravity="start"/>
35
+            android:layout_gravity="start" />
33 36
     </android.support.v4.widget.DrawerLayout>
34 37
 </LinearLayout>

+ 8
- 6
android/app/src/main/res/layout/tab_activity.xml View File

@@ -1,10 +1,10 @@
1 1
 <?xml version="1.0" encoding="utf-8"?>
2 2
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
-    xmlns:tools="http://schemas.android.com/tools"
4 3
     xmlns:app="http://schemas.android.com/apk/res-auto"
5
-    android:orientation="vertical"
4
+    xmlns:tools="http://schemas.android.com/tools"
6 5
     android:layout_width="match_parent"
7 6
     android:layout_height="match_parent"
7
+    android:orientation="vertical"
8 8
     tools:context=".activities.TabActivity">
9 9
 
10 10
     <android.support.design.widget.AppBarLayout
@@ -12,21 +12,23 @@
12 12
         android:layout_width="match_parent"
13 13
         android:layout_height="wrap_content"
14 14
         android:fitsSystemWindows="true">
15
+
15 16
         <com.reactnativenavigation.views.RnnToolBar
16 17
             android:id="@+id/toolbar"
17 18
             android:layout_width="match_parent"
18 19
             android:layout_height="?attr/actionBarSize"
19
-            app:layout_scrollFlags="scroll|enterAlways"/>
20
+            app:layout_scrollFlags="scroll|enterAlways" />
21
+
20 22
         <com.reactnativenavigation.views.RnnTabLayout
21 23
             android:id="@+id/tabLayout"
22 24
             android:layout_width="match_parent"
23 25
             android:layout_height="?attr/actionBarSize"
24
-            app:layout_scrollFlags="scroll|enterAlways"/>
26
+            app:layout_scrollFlags="scroll|enterAlways" />
25 27
     </android.support.design.widget.AppBarLayout>
26 28
 
27 29
     <android.support.v4.view.ViewPager
28 30
         android:id="@+id/viewPager"
29
-        app:layout_behavior="@string/appbar_scrolling_view_behavior"
30 31
         android:layout_width="match_parent"
31
-        android:layout_height="match_parent"/>
32
+        android:layout_height="match_parent"
33
+        app:layout_behavior="@string/appbar_scrolling_view_behavior" />
32 34
 </LinearLayout>