@@ -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 }
0 commit comments