Pārlūkot izejas kodu

Fixed add first location loop; added add location button

develop
Robin Thoni 6 gadus atpakaļ
vecāks
revīzija
e7d84b03f1

Binārs
app/src/main/ic_plus-web.png Parādīt failu


+ 1
- 0
app/src/main/java/com/rthoni/camotion/ui/AddAccountActivity.java Parādīt failu

@@ -145,6 +145,7 @@ public class AddAccountActivity extends AppCompatActivity {
145 145
             if (_response != null) {
146 146
                 _response.onResult(result);
147 147
             }
148
+            setResult(RESULT_OK);
148 149
             finish();
149 150
         }
150 151
     }

+ 13
- 4
app/src/main/java/com/rthoni/camotion/ui/MainActivity.java Parādīt failu

@@ -82,9 +82,7 @@ public class MainActivity extends AppCompatActivity
82 82
 
83 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 86
             return;
89 87
         }
90 88
 
@@ -135,7 +133,15 @@ public class MainActivity extends AppCompatActivity
135 133
         super.onActivityResult(requestCode, resultCode, data);
136 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,6 +233,9 @@ public class MainActivity extends AppCompatActivity
227 233
         if (id == R.id.nav_cameras || id == R.id.nav_sensors || id == R.id.nav_commands) {
228 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 240
         DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
232 241
         drawer.closeDrawer(GravityCompat.START);

+ 5
- 1
app/src/main/res/menu/activity_main_drawer.xml Parādīt failu

@@ -20,10 +20,14 @@
20 20
         android:id="@+id/location_menu">
21 21
         <menu>
22 22
             <item
23
-                android:id="@+id/nav_share"
24 23
                 android:icon="@mipmap/ic_location"
25 24
                 android:title="@string/location_select" />
26 25
         </menu>
27 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 33
 </menu>

Binārs
app/src/main/res/mipmap-hdpi/ic_plus.png Parādīt failu


Binārs
app/src/main/res/mipmap-mdpi/ic_plus.png Parādīt failu


Binārs
app/src/main/res/mipmap-xhdpi/ic_plus.png Parādīt failu


Binārs
app/src/main/res/mipmap-xxhdpi/ic_plus.png Parādīt failu


Binārs
app/src/main/res/mipmap-xxxhdpi/ic_plus.png Parādīt failu


+ 1
- 0
app/src/main/res/values/strings.xml Parādīt failu

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

Notiek ielāde…
Atcelt
Saglabāt