sqlite map sources with urls / screen rotating / quick action apply
This commit is contained in:
parent
148e6a2b1e
commit
11e51ef318
3 changed files with 54 additions and 11 deletions
|
@ -1,6 +1,6 @@
|
|||
package net.osmand.plus;
|
||||
|
||||
import android.content.ContentValues;
|
||||
import android.database.SQLException;
|
||||
import android.database.sqlite.SQLiteDiskIOException;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
|
@ -23,7 +23,6 @@ import java.nio.ByteBuffer;
|
|||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static net.osmand.IndexConstants.APP_DIR;
|
||||
import static net.osmand.IndexConstants.SQLITE_EXT;
|
||||
import static net.osmand.IndexConstants.TILES_INDEX_DIR;
|
||||
|
||||
|
@ -312,7 +311,11 @@ public class SQLiteTileSource implements ITileSource {
|
|||
|
||||
private void addInfoColumn(String columnName, String value) {
|
||||
if(!onlyReadonlyAvailable) {
|
||||
try {
|
||||
db.execSQL("alter table info add column " + columnName + " TEXT");
|
||||
} catch (SQLException e) {
|
||||
LOG.info("Error adding column " + e);
|
||||
}
|
||||
db.execSQL("update info set "+columnName+" = '"+value+"'");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ import net.osmand.osm.PoiCategory;
|
|||
import net.osmand.plus.ApplicationMode.ApplicationModeBean;
|
||||
import net.osmand.plus.ApplicationMode.ApplicationModeBuilder;
|
||||
import net.osmand.plus.OsmandSettings.OsmandPreference;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.poi.PoiUIFilter;
|
||||
import net.osmand.plus.quickaction.QuickAction;
|
||||
import net.osmand.plus.quickaction.QuickActionFactory;
|
||||
|
@ -93,6 +94,7 @@ public class SettingsHelper {
|
|||
|
||||
private boolean importing;
|
||||
private boolean importSuspended;
|
||||
private boolean collectOnly;
|
||||
private ImportAsyncTask importTask;
|
||||
|
||||
public interface SettingsImportListener {
|
||||
|
@ -113,7 +115,7 @@ public class SettingsHelper {
|
|||
|
||||
public void setActivity(Activity activity) {
|
||||
this.activity = activity;
|
||||
if (importing) {
|
||||
if (importing && !collectOnly) {
|
||||
importTask.processNextItem();
|
||||
}
|
||||
}
|
||||
|
@ -762,7 +764,7 @@ public class SettingsHelper {
|
|||
}
|
||||
}
|
||||
newActions.addAll(quickActions);
|
||||
getSettings().QUICK_ACTION_LIST.set(factory.quickActionListToString(newActions));
|
||||
((MapActivity) app.getSettingsHelper().getActivity()).getMapLayers().getQuickActionRegistry().updateQuickActions(newActions);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1373,7 +1375,6 @@ public class SettingsHelper {
|
|||
private File file;
|
||||
private String latestChanges;
|
||||
private int version;
|
||||
private boolean collectOnly;
|
||||
|
||||
private SettingsImportListener listener;
|
||||
private SettingsImporter importer;
|
||||
|
@ -1429,10 +1430,10 @@ public class SettingsHelper {
|
|||
|
||||
@Override
|
||||
protected void onPostExecute(List<SettingsItem> items) {
|
||||
this.items = items;
|
||||
if (collectOnly) {
|
||||
listener.onSettingsImportFinished(true, false, items);
|
||||
} else {
|
||||
this.items = items;
|
||||
if (items != null && items.size() > 0) {
|
||||
processNextItem();
|
||||
}
|
||||
|
@ -1528,6 +1529,24 @@ public class SettingsHelper {
|
|||
processedItems.add(item);
|
||||
processNextItem();
|
||||
}
|
||||
|
||||
public List<SettingsItem> getItems() {
|
||||
return this.items;
|
||||
}
|
||||
|
||||
public File getFile() {
|
||||
return this.file;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public List<SettingsItem> getSettingsItems() {
|
||||
return this.importTask.getItems();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public File getSettingsFile() {
|
||||
return this.importTask.getFile();
|
||||
}
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
|
|
|
@ -63,6 +63,8 @@ public class ExportImportProfileBottomSheet extends BasePreferenceBottomSheet {
|
|||
|
||||
private static final String STATE_KEY = "EXPORT_IMPORT_DIALOG_STATE_KEY";
|
||||
|
||||
private static final String INCLUDE_ADDITIONAL_DATA_KEY = "INCLUDE_ADDITIONAL_DATA_KEY";
|
||||
|
||||
private boolean includeAdditionalData = false;
|
||||
|
||||
private boolean containsAdditionalData = false;
|
||||
|
@ -89,6 +91,9 @@ public class ExportImportProfileBottomSheet extends BasePreferenceBottomSheet {
|
|||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
if (savedInstanceState != null) {
|
||||
includeAdditionalData = savedInstanceState.getBoolean(INCLUDE_ADDITIONAL_DATA_KEY);
|
||||
}
|
||||
super.onCreate(savedInstanceState);
|
||||
app = requiredMyApplication();
|
||||
Bundle bundle = getArguments();
|
||||
|
@ -96,6 +101,12 @@ public class ExportImportProfileBottomSheet extends BasePreferenceBottomSheet {
|
|||
this.state = (State) getArguments().getSerializable(STATE_KEY);
|
||||
}
|
||||
if (state == State.IMPORT) {
|
||||
if (settingsItems == null) {
|
||||
settingsItems = app.getSettingsHelper().getSettingsItems();
|
||||
}
|
||||
if (file == null) {
|
||||
file = app.getSettingsHelper().getSettingsFile();
|
||||
}
|
||||
containsAdditionalData = checkAdditionalDataContains();
|
||||
} else {
|
||||
dataList = getAdditionalData();
|
||||
|
@ -105,6 +116,12 @@ public class ExportImportProfileBottomSheet extends BasePreferenceBottomSheet {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putBoolean(INCLUDE_ADDITIONAL_DATA_KEY, includeAdditionalData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMenuItems(Bundle savedInstanceState) {
|
||||
final Context context = getContext();
|
||||
|
@ -150,7 +167,7 @@ public class ExportImportProfileBottomSheet extends BasePreferenceBottomSheet {
|
|||
listView = additionalDataView.findViewById(R.id.list);
|
||||
SwitchCompat switchItem = additionalDataView.findViewById(R.id.switchItem);
|
||||
switchItem.setTextColor(getResources().getColor(nightMode ? R.color.active_color_primary_dark : R.color.active_color_primary_light));
|
||||
|
||||
switchItem.setChecked(includeAdditionalData);
|
||||
switchItem.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
@ -163,8 +180,8 @@ public class ExportImportProfileBottomSheet extends BasePreferenceBottomSheet {
|
|||
setupHeightAndBackground(getView());
|
||||
}
|
||||
});
|
||||
|
||||
adapter = new ProfileAdditionalDataAdapter(requiredMyApplication(), dataList, profileColor);
|
||||
listView.setVisibility(includeAdditionalData ? View.VISIBLE : View.GONE);
|
||||
adapter = new ProfileAdditionalDataAdapter(app, dataList, profileColor);
|
||||
listView.setOnGroupExpandListener(new ExpandableListView.OnGroupExpandListener() {
|
||||
@Override
|
||||
public void onGroupExpand(int i) {
|
||||
|
@ -398,7 +415,11 @@ public class ExportImportProfileBottomSheet extends BasePreferenceBottomSheet {
|
|||
app.getSettingsHelper().importSettings(file, list, "", 1, new SettingsHelper.SettingsImportListener() {
|
||||
@Override
|
||||
public void onSettingsImportFinished(boolean succeed, boolean empty, @NonNull List<SettingsHelper.SettingsItem> items) {
|
||||
|
||||
if (succeed) {
|
||||
app.showShortToastMessage(app.getString(R.string.file_imported_successfully, file.getName()));
|
||||
} else if (empty){
|
||||
app.showShortToastMessage(app.getString(R.string.file_import_error, file.getName(), app.getString(R.string.shared_string_unexpected_error)));
|
||||
}
|
||||
}
|
||||
});
|
||||
dismiss();
|
||||
|
|
Loading…
Reference in a new issue