|
10 | 10 |
|
11 | 11 | import com.cylonid.nativealpha.R; |
12 | 12 | import com.cylonid.nativealpha.util.App; |
| 13 | +import com.cylonid.nativealpha.util.Const; |
13 | 14 | import com.cylonid.nativealpha.util.InvalidChecksumException; |
14 | 15 | import com.cylonid.nativealpha.util.Utility; |
15 | 16 | import com.google.gson.Gson; |
@@ -101,14 +102,6 @@ public void saveWebAppData() { |
101 | 102 | editor.apply(); |
102 | 103 | } |
103 | 104 |
|
104 | | - public void setDataFormat(int dataFormat) { |
105 | | - getGeneralInfo().edit().putInt(DATA_FORMAT, dataFormat).apply(); |
106 | | - } |
107 | | - |
108 | | - public int getDataFormat() { |
109 | | - return getGeneralInfo().getInt(DATA_FORMAT, LEGACY_DATA_FORMAT); |
110 | | - } |
111 | | - |
112 | 105 | public boolean getEulaData() { |
113 | 106 | return getGeneralInfo().getBoolean(EULA_ACCEPTED, false); |
114 | 107 | } |
@@ -181,6 +174,7 @@ public void loadAppData() { |
181 | 174 | int oldDataFormat = DataVersionConverter.getDataFormat(json); |
182 | 175 | String currentDataFormattedJson = this.checkDataFormat(oldDataFormat, json); |
183 | 176 | settings = gson.fromJson(currentDataFormattedJson, new TypeToken<GlobalSettings>() {}.getType()); |
| 177 | + assertGlobalWebappData(); |
184 | 178 | if(oldDataFormat != DataVersionConverter.getDataFormat(currentDataFormattedJson)) this.saveGlobalSettings(); |
185 | 179 | } |
186 | 180 | } |
@@ -336,7 +330,6 @@ private String checkDataFormat(int dataFormat, String jsonInput) { |
336 | 330 | switch(dataFormat) { |
337 | 331 | case LEGACY_DATA_FORMAT: |
338 | 332 | String convertedInput = DataVersionConverter.convertToDataFormat(jsonInput, DataVersionConverter.getLegacyTo1300Map()); |
339 | | - this.setDataFormat(1300); |
340 | 333 | return convertedInput; |
341 | 334 | default: |
342 | 335 | case 1300: // Current data format => corresponding to app release version |
@@ -366,19 +359,16 @@ public WebApp getPredecessor(int i) { |
366 | 359 | } |
367 | 360 | while (!websites.get(neighbor).isActiveEntry()); |
368 | 361 | return websites.get(neighbor); |
| 362 | + } |
369 | 363 |
|
370 | | -// if (i != (websites.size() - 1)) { |
371 | | -// return websites.get(i + 1); |
372 | | -// } |
373 | | -// else |
374 | | -// return websites.get(0); |
375 | | - |
376 | | -// |
377 | | -// if (i != 0) { |
378 | | -// return websites.get(i - 1); |
379 | | -// } |
380 | | -// else |
381 | | -// return websites.get(websites.size() - 1); |
| 364 | + private void assertGlobalWebappData() { |
| 365 | + boolean override = settings.getGlobalWebApp().isOverrideGlobalSettings(); |
| 366 | + int container = settings.getGlobalWebApp().getContainerId(); |
| 367 | + if(!override || container != Const.NO_CONTAINER) { |
| 368 | + settings.getGlobalWebApp().setOverrideGlobalSettings(true); |
| 369 | + settings.getGlobalWebApp().setContainerId(Const.NO_CONTAINER); |
| 370 | + this.saveGlobalSettings(); |
| 371 | + } |
382 | 372 | } |
383 | 373 |
|
384 | 374 |
|
|
0 commit comments