Browse Source

Fixed add first location loop; added add location button

develop
Robin Thoni 6 years ago
parent
commit
e7d84b03f1

BIN
app/src/main/ic_plus-web.png View File


+ 1
- 0
app/src/main/java/com/rthoni/camotion/ui/AddAccountActivity.java View File

145
             if (_response != null) {
145
             if (_response != null) {
146
                 _response.onResult(result);
146
                 _response.onResult(result);
147
             }
147
             }
148
+            setResult(RESULT_OK);
148
             finish();
149
             finish();
149
         }
150
         }
150
     }
151
     }

+ 13
- 4
app/src/main/java/com/rthoni/camotion/ui/MainActivity.java View File

82
 
82
 
83
         if (locations.isEmpty())
83
         if (locations.isEmpty())
84
         {
84
         {
85
-            Intent intent = new Intent(Settings.ACTION_ADD_ACCOUNT);
86
-            intent.putExtra(Settings.EXTRA_AUTHORITIES, new String[]{getResources().getString(R.string.account_type)});
87
-            startActivityForResult(intent, REQUEST_CODE_ADD_ACCOUNT);
85
+            startActivityForResult(new Intent(this, AddAccountActivity.class), REQUEST_CODE_ADD_ACCOUNT);
88
             return;
86
             return;
89
         }
87
         }
90
 
88
 
135
         super.onActivityResult(requestCode, resultCode, data);
133
         super.onActivityResult(requestCode, resultCode, data);
136
         if (requestCode == REQUEST_CODE_ADD_ACCOUNT)
134
         if (requestCode == REQUEST_CODE_ADD_ACCOUNT)
137
         {
135
         {
138
-            init();
136
+            if (resultCode == RESULT_OK) {
137
+                init();
138
+            }
139
+            else {
140
+                List<LocationDbo> locations = CamotionBusiness.getLocations(MainActivity.this);
141
+                if (locations.size() == 0) {
142
+                    finish();
143
+                }
144
+            }
139
         }
145
         }
140
     }
146
     }
141
 
147
 
227
         if (id == R.id.nav_cameras || id == R.id.nav_sensors || id == R.id.nav_commands) {
233
         if (id == R.id.nav_cameras || id == R.id.nav_sensors || id == R.id.nav_commands) {
228
             showView(id);
234
             showView(id);
229
         }
235
         }
236
+        else if (id == R.id.nav_add_account) {
237
+            startActivityForResult(new Intent(this, AddAccountActivity.class), REQUEST_CODE_ADD_ACCOUNT);
238
+        }
230
 
239
 
231
         DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
240
         DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
232
         drawer.closeDrawer(GravityCompat.START);
241
         drawer.closeDrawer(GravityCompat.START);

+ 5
- 1
app/src/main/res/menu/activity_main_drawer.xml View File

20
         android:id="@+id/location_menu">
20
         android:id="@+id/location_menu">
21
         <menu>
21
         <menu>
22
             <item
22
             <item
23
-                android:id="@+id/nav_share"
24
                 android:icon="@mipmap/ic_location"
23
                 android:icon="@mipmap/ic_location"
25
                 android:title="@string/location_select" />
24
                 android:title="@string/location_select" />
26
         </menu>
25
         </menu>
27
     </item>
26
     </item>
28
 
27
 
28
+    <item
29
+        android:id="@+id/nav_add_account"
30
+        android:icon="@mipmap/ic_plus"
31
+        android:title="@string/location_add" />
32
+
29
 </menu>
33
 </menu>

BIN
app/src/main/res/mipmap-hdpi/ic_plus.png View File


BIN
app/src/main/res/mipmap-mdpi/ic_plus.png View File


BIN
app/src/main/res/mipmap-xhdpi/ic_plus.png View File


BIN
app/src/main/res/mipmap-xxhdpi/ic_plus.png View File


BIN
app/src/main/res/mipmap-xxxhdpi/ic_plus.png View File


+ 1
- 0
app/src/main/res/values/strings.xml View File

13
     <string name="action_settings">Settings</string>
13
     <string name="action_settings">Settings</string>
14
     <string name="locations">Locations</string>
14
     <string name="locations">Locations</string>
15
     <string name="location_select">Select Location</string>
15
     <string name="location_select">Select Location</string>
16
+    <string name="location_add">Add Location</string>
16
 
17
 
17
     <string name="add_location">Add a location</string>
18
     <string name="add_location">Add a location</string>
18
     <string name="add_location_text">Fill in the following fields to add a location:</string>
19
     <string name="add_location_text">Fill in the following fields to add a location:</string>

Loading…
Cancel
Save