Skip to content

Commit 4688f70

Browse files
committed
Fixed settings not saving
1 parent bf3bf10 commit 4688f70

File tree

3 files changed

+26
-213
lines changed

3 files changed

+26
-213
lines changed

app/src/main/java/kevin/carrismobile/fragments/SettingsFragment.java

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,26 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
5656
mapTilerSwitch = v.findViewById(R.id.mapTilerSwitch);
5757
resetButton = v.findViewById(R.id.resetPreferences);
5858
mPrefs = getActivity().getSharedPreferences("SettingsFragment", MODE_PRIVATE);
59-
if (loadObject("key_topo", String.class) == null){
60-
storeObject(new Gson().toJson("1"), "key_topo");
61-
openTopoSwitch.setChecked(true);
59+
String selectedSwitch = (String)loadObject("key_settings", String.class);
60+
if (loadObject("key_settings", String.class) == null){
61+
storeObject(new Gson().toJson("topo"), "key_settings");
62+
openTopoSwitch.performClick();
6263
}else{
63-
String topo_switched = (String)loadObject("key_topo", String.class);
64-
String thunderForest_switched = (String)loadObject("key_tunderForest", String.class);
65-
String bingMaps_switched = (String)loadObject("key_bingMaps", String.class);
66-
if (topo_switched != null && topo_switched.equals("1")){
67-
openTopoSwitch.performClick();
68-
}else if(thunderForest_switched != null && thunderForest_switched.equals("1")){
69-
thunderForestSwitch.performClick();
70-
}else if(bingMaps_switched != null && bingMaps_switched.equals("1")){
71-
bingMapsSwitch.performClick();
64+
switch (selectedSwitch) {
65+
case "topo":
66+
openTopoSwitch.performClick();
67+
break;
68+
case "thunderForest":
69+
thunderForestSwitch.performClick();
70+
break;
71+
case "bingMaps":
72+
bingMapsSwitch.performClick();
73+
break;
74+
case "mapTiler":
75+
mapTilerSwitch.performClick();
76+
break;
77+
default:
78+
openTopoSwitch.performClick();
7279
}
7380
}
7481
setOpenTopoSwitchOnClickListener();
@@ -114,7 +121,7 @@ public void onClick(View view) {
114121
map1.invalidate();
115122
map2.invalidate();
116123
map3.invalidate();
117-
storeObject(new Gson().toJson("1"), "key_topo");
124+
storeObject(new Gson().toJson("topo"), "key_settings");
118125
}
119126
});
120127
}
@@ -151,7 +158,7 @@ public void onClick(View view) {
151158
map1.invalidate();
152159
map2.invalidate();
153160
map3.invalidate();
154-
storeObject(new Gson().toJson("1"), "key_bingMaps");
161+
storeObject(new Gson().toJson("bingMaps"), "key_settings");
155162
}
156163
});
157164
}
@@ -187,7 +194,7 @@ public void onClick(View view) {
187194
map1.invalidate();
188195
map2.invalidate();
189196
map3.invalidate();
190-
storeObject(new Gson().toJson("1"), "key_thunderForest");
197+
storeObject(new Gson().toJson("thunderForest"), "key_settings");
191198
}
192199
});
193200
}
@@ -235,7 +242,7 @@ public void onClick(View view) {
235242
map1.invalidate();
236243
map2.invalidate();
237244
map3.invalidate();
238-
storeObject(new Gson().toJson("1"), "key_mapTiler");
245+
storeObject(new Gson().toJson("mapTiler"), "key_settings");
239246
}
240247
});
241248
}

app/src/main/res/layout/realtime_fragment.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
android:layout_width="wrap_content"
7272
android:layout_height="40dp"
7373
android:layout_marginStart="10dp"
74-
android:layout_marginTop="12dp"
74+
android:layout_marginTop="5dp"
7575
android:backgroundTint="@color/lightYellow"
7676
android:text="Anterior"
7777
android:textColor="@color/black"
@@ -82,13 +82,13 @@
8282
android:id="@+id/nextButton"
8383
android:layout_width="wrap_content"
8484
android:layout_height="40dp"
85-
android:layout_marginTop="12dp"
85+
android:layout_marginTop="5dp"
8686
android:layout_marginEnd="10dp"
8787
android:backgroundTint="@color/lightYellow"
8888
android:text="Seguinte"
8989
android:textColor="@color/black"
9090
app:layout_constraintEnd_toEndOf="parent"
91-
app:layout_constraintTop_toBottomOf="@+id/button2" />
91+
app:layout_constraintTop_toBottomOf="@+id/editText2" />
9292

9393
<TextView
9494
android:id="@+id/textViewRealTimeFragment"

app/src/main/res/xml/splash_screen_scene.xml

Lines changed: 0 additions & 194 deletions
This file was deleted.

0 commit comments

Comments
 (0)