showClearTilesWarningDialog for storage change
This commit is contained in:
parent
1e2f5e6581
commit
73d7c93f67
3 changed files with 42 additions and 24 deletions
|
@ -485,7 +485,7 @@ public class EditMapSourceDialogFragment extends BaseOsmAndDialogFragment
|
|||
MercatorProjectionBottomSheet.showInstance(fm, EditMapSourceDialogFragment.this, elliptic);
|
||||
break;
|
||||
case STORAGE_FORMAT:
|
||||
TileStorageFormatBottomSheet.showInstance(fm, EditMapSourceDialogFragment.this, sqliteDB);
|
||||
TileStorageFormatBottomSheet.showInstance(fm, EditMapSourceDialogFragment.this, sqliteDB, editedLayerName == null && !fromTemplate);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package net.osmand.plus.mapsource;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
|
@ -147,7 +148,12 @@ public class InputZoomLevelsBottomSheet extends MenuBottomSheetDialogFragment {
|
|||
@Override
|
||||
protected void onRightBottomButtonClick() {
|
||||
if (!newMapSource) {
|
||||
showClearTilesWarningDialog();
|
||||
showClearTilesWarningDialog(requireActivity(), nightMode, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
applySelectedZooms();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
applySelectedZooms();
|
||||
}
|
||||
|
@ -163,18 +169,13 @@ public class InputZoomLevelsBottomSheet extends MenuBottomSheetDialogFragment {
|
|||
return R.string.shared_string_apply;
|
||||
}
|
||||
|
||||
private void showClearTilesWarningDialog() {
|
||||
Context themedContext = UiUtilities.getThemedContext(getActivity(), nightMode);
|
||||
public static void showClearTilesWarningDialog(Activity activity, boolean nightMode, DialogInterface.OnClickListener onPositiveListener) {
|
||||
Context themedContext = UiUtilities.getThemedContext(activity, nightMode);
|
||||
AlertDialog.Builder dismissDialog = new AlertDialog.Builder(themedContext);
|
||||
dismissDialog.setTitle(getString(R.string.osmand_parking_warning));
|
||||
dismissDialog.setMessage(getString(R.string.clear_tiles_warning));
|
||||
dismissDialog.setTitle(activity.getString(R.string.osmand_parking_warning));
|
||||
dismissDialog.setMessage(activity.getString(R.string.clear_tiles_warning));
|
||||
dismissDialog.setNegativeButton(R.string.shared_string_cancel, null);
|
||||
dismissDialog.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
applySelectedZooms();
|
||||
}
|
||||
});
|
||||
dismissDialog.setPositiveButton(R.string.shared_string_ok, onPositiveListener);
|
||||
dismissDialog.show();
|
||||
}
|
||||
|
||||
|
|
|
@ -26,15 +26,19 @@ public class TileStorageFormatBottomSheet extends MenuBottomSheetDialogFragment
|
|||
|
||||
public static final String TAG = TileStorageFormatBottomSheet.class.getName();
|
||||
private static final String SQLITE_DB_KEY = "sqlite_db_key";
|
||||
private static final String NEW_MAP_SOURCE_KEY = "new_map_source_key";
|
||||
private LinearLayout valuesContainer;
|
||||
private TileStorageFormat tileStorageFormat;
|
||||
private boolean newMapSource;
|
||||
|
||||
public static void showInstance(@NonNull FragmentManager fm,
|
||||
@Nullable Fragment targetFragment,
|
||||
boolean sqliteDb) {
|
||||
boolean sqliteDb,
|
||||
boolean newMapSource) {
|
||||
TileStorageFormatBottomSheet bottomSheet = new TileStorageFormatBottomSheet();
|
||||
bottomSheet.setTargetFragment(targetFragment, 0);
|
||||
bottomSheet.setTileStorageFormat(sqliteDb);
|
||||
bottomSheet.setNewMapSource(newMapSource);
|
||||
bottomSheet.show(fm, TAG);
|
||||
}
|
||||
|
||||
|
@ -42,6 +46,7 @@ public class TileStorageFormatBottomSheet extends MenuBottomSheetDialogFragment
|
|||
public void createMenuItems(Bundle savedInstanceState) {
|
||||
if (savedInstanceState != null) {
|
||||
setTileStorageFormat(savedInstanceState.getBoolean(SQLITE_DB_KEY));
|
||||
newMapSource = savedInstanceState.getBoolean(NEW_MAP_SOURCE_KEY);
|
||||
}
|
||||
Context context = requireContext();
|
||||
TitleItem titleItem = new TitleItem(getString(R.string.mercator_projection));
|
||||
|
@ -63,18 +68,10 @@ public class TileStorageFormatBottomSheet extends MenuBottomSheetDialogFragment
|
|||
@Override
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
outState.putBoolean(SQLITE_DB_KEY, tileStorageFormat == TileStorageFormat.SQLITE_DB);
|
||||
outState.putBoolean(NEW_MAP_SOURCE_KEY, newMapSource);
|
||||
super.onSaveInstanceState(outState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDismiss(@NonNull DialogInterface dialog) {
|
||||
Fragment fragment = getTargetFragment();
|
||||
if (fragment instanceof OnTileStorageFormatSelectedListener) {
|
||||
((OnTileStorageFormatSelectedListener) fragment).onStorageFormatSelected(tileStorageFormat == TileStorageFormat.SQLITE_DB);
|
||||
}
|
||||
super.onDismiss(dialog);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getDismissButtonTextId() {
|
||||
return R.string.shared_string_close;
|
||||
|
@ -91,18 +88,38 @@ public class TileStorageFormatBottomSheet extends MenuBottomSheetDialogFragment
|
|||
@Override
|
||||
public void onClick(View view) {
|
||||
if (tileStorageFormat != m) {
|
||||
tileStorageFormat = m;
|
||||
dismiss();
|
||||
if (newMapSource) {
|
||||
applyTileStorageFormat(m);
|
||||
} else {
|
||||
InputZoomLevelsBottomSheet.showClearTilesWarningDialog(requireActivity(), nightMode, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
applyTileStorageFormat(m);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void applyTileStorageFormat(TileStorageFormat tileStorageFormat) {
|
||||
Fragment fragment = getTargetFragment();
|
||||
if (fragment instanceof OnTileStorageFormatSelectedListener) {
|
||||
((OnTileStorageFormatSelectedListener) fragment).onStorageFormatSelected(tileStorageFormat == TileStorageFormat.SQLITE_DB);
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
|
||||
private void setTileStorageFormat(boolean sqliteDb) {
|
||||
tileStorageFormat = sqliteDb ? TileStorageFormat.SQLITE_DB : TileStorageFormat.ONE_IMAGE_PER_TILE;
|
||||
}
|
||||
|
||||
public void setNewMapSource(boolean newMapSource) {
|
||||
this.newMapSource = newMapSource;
|
||||
}
|
||||
|
||||
public enum TileStorageFormat {
|
||||
ONE_IMAGE_PER_TILE(R.string.one_image_per_tile),
|
||||
SQLITE_DB(R.string.sqlite_db_file);
|
||||
|
|
Loading…
Reference in a new issue