show sqlite extension

This commit is contained in:
veliymolfar 2020-06-12 12:13:37 +03:00
parent f05effa157
commit 404079888b

View file

@ -194,7 +194,6 @@ public class EditMapSourceDialogFragment extends BaseOsmAndDialogFragment
if (!editedLayerName.endsWith(IndexConstants.SQLITE_EXT)) { if (!editedLayerName.endsWith(IndexConstants.SQLITE_EXT)) {
File f = app.getAppPath(IndexConstants.TILES_INDEX_DIR + editedLayerName); File f = app.getAppPath(IndexConstants.TILES_INDEX_DIR + editedLayerName);
template = TileSourceManager.createTileSourceTemplate(f); template = TileSourceManager.createTileSourceTemplate(f);
sqliteDB = false;
} else { } else {
List<TileSourceTemplate> knownTemplates = TileSourceManager.getKnownSourceTemplates(); List<TileSourceTemplate> knownTemplates = TileSourceManager.getKnownSourceTemplates();
File tPath = app.getAppPath(IndexConstants.TILES_INDEX_DIR); File tPath = app.getAppPath(IndexConstants.TILES_INDEX_DIR);
@ -207,11 +206,9 @@ public class EditMapSourceDialogFragment extends BaseOsmAndDialogFragment
sqLiteTileSource.getBitDensity(), AVG_SIZE); sqLiteTileSource.getBitDensity(), AVG_SIZE);
template.setExpirationTimeMinutes(sqLiteTileSource.getExpirationTimeMinutes()); template.setExpirationTimeMinutes(sqLiteTileSource.getExpirationTimeMinutes());
template.setEllipticYTile(sqLiteTileSource.isEllipticYTile()); template.setEllipticYTile(sqLiteTileSource.isEllipticYTile());
sqliteDB = true;
} }
} }
if (savedInstanceState == null) { if (savedInstanceState == null) {
editedLayerName = template.getName();
urlToLoad = template.getUrlTemplate(); urlToLoad = template.getUrlTemplate();
expireTimeMinutes = template.getExpirationTimeMinutes(); expireTimeMinutes = template.getExpirationTimeMinutes();
minZoom = template.getMinimumZoomSupported(); minZoom = template.getMinimumZoomSupported();
@ -234,6 +231,13 @@ public class EditMapSourceDialogFragment extends BaseOsmAndDialogFragment
super.onSaveInstanceState(outState); super.onSaveInstanceState(outState);
} }
@Override
public void onViewStateRestored(@Nullable Bundle savedInstanceState) {
super.onViewStateRestored(savedInstanceState);
sqliteDB = nameEditText.getText().toString().contains(IndexConstants.SQLITE_EXT);
updateDescription(ConfigurationItem.STORAGE_FORMAT);
}
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
@ -290,6 +294,13 @@ public class EditMapSourceDialogFragment extends BaseOsmAndDialogFragment
public void onStorageFormatSelected(boolean sqliteDb) { public void onStorageFormatSelected(boolean sqliteDb) {
if (isAdded()) { if (isAdded()) {
this.sqliteDB = sqliteDb; this.sqliteDB = sqliteDb;
String name = nameEditText.getText().toString();
if (sqliteDb && !name.contains(IndexConstants.SQLITE_EXT)) {
name += IndexConstants.SQLITE_EXT;
nameEditText.setText(name);
} else if (!sqliteDb) {
nameEditText.setText(name.replace(IndexConstants.SQLITE_EXT, ""));
}
updateDescription(ConfigurationItem.STORAGE_FORMAT); updateDescription(ConfigurationItem.STORAGE_FORMAT);
wasChanged = true; wasChanged = true;
} }
@ -329,7 +340,7 @@ public class EditMapSourceDialogFragment extends BaseOsmAndDialogFragment
private void saveTemplate() { private void saveTemplate() {
try { try {
String newName = nameEditText.getText().toString(); String newName = nameEditText.getText().toString().replace(IndexConstants.SQLITE_EXT, "");
String urlToLoad = urlEditText.getText().toString(); String urlToLoad = urlEditText.getText().toString();
template.setName(newName); template.setName(newName);
template.setUrlToLoad(urlToLoad.isEmpty() ? null : urlToLoad.replace("{$x}", "{1}").replace("{$y}", "{2}").replace("{$z}", "{0}")); template.setUrlToLoad(urlToLoad.isEmpty() ? null : urlToLoad.replace("{$x}", "{1}").replace("{$y}", "{2}").replace("{$z}", "{0}"));
@ -378,7 +389,7 @@ public class EditMapSourceDialogFragment extends BaseOsmAndDialogFragment
} }
private void updateUi() { private void updateUi() {
nameEditText.setText(editedLayerName != null ? editedLayerName.replace(IndexConstants.SQLITE_EXT, "") : ""); nameEditText.setText(editedLayerName);
urlEditText.setText(urlToLoad); urlEditText.setText(urlToLoad);
nameEditText.addTextChangedListener(getTextWatcher()); nameEditText.addTextChangedListener(getTextWatcher());
urlEditText.addTextChangedListener(getTextWatcher()); urlEditText.addTextChangedListener(getTextWatcher());