diff --git a/OsmAnd/res/layout/fragment_edit_map_source.xml b/OsmAnd/res/layout/fragment_edit_map_source.xml
index b179cc5eb6..57370b06a5 100644
--- a/OsmAnd/res/layout/fragment_edit_map_source.xml
+++ b/OsmAnd/res/layout/fragment_edit_map_source.xml
@@ -16,16 +16,18 @@
app:title="@string/edit_online_source"
osmand:titleTextColor="?android:textColorPrimary">
-
+ android:layout_marginStart="@dimen/list_item_button_padding"
+ android:layout_marginLeft="@dimen/list_item_button_padding"
+ android:layout_marginEnd="@dimen/list_item_button_padding"
+ android:layout_marginRight="@dimen/list_item_button_padding"
+ android:contentDescription="@string/back_to_map"
+ app:srcCompat="@drawable/ic_action_help" />
@@ -94,7 +96,7 @@
]");
public static final Pattern ILLEGAL_PATH_NAME_CHARACTERS = Pattern.compile("[?:\"*|<>]");
diff --git a/OsmAnd/src/net/osmand/plus/mapsource/EditMapSourceDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapsource/EditMapSourceDialogFragment.java
index cf8381a309..13a4313d62 100644
--- a/OsmAnd/src/net/osmand/plus/mapsource/EditMapSourceDialogFragment.java
+++ b/OsmAnd/src/net/osmand/plus/mapsource/EditMapSourceDialogFragment.java
@@ -14,6 +14,7 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
+import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
@@ -24,6 +25,7 @@ import androidx.annotation.Nullable;
import androidx.annotation.StringRes;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.widget.Toolbar;
+import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
@@ -52,12 +54,11 @@ import org.apache.commons.logging.Log;
import java.io.File;
import java.util.List;
-import static net.osmand.plus.download.ui.LocalIndexesFragment.ILLEGAL_FILE_NAME_CHARACTERS;
import static net.osmand.plus.download.ui.LocalIndexesFragment.renameSQLiteFile;
public class EditMapSourceDialogFragment extends BaseOsmAndDialogFragment
implements OnZoomSetListener, OnExpireValueSetListener, OnMercatorSelectedListener,
- OnTileStorageFormatSelectedListener, View.OnClickListener {
+ OnTileStorageFormatSelectedListener {
public static final String TAG = EditMapSourceDialogFragment.class.getName();
static final int EXPIRE_TIME_NEVER = -1;
@@ -118,10 +119,10 @@ public class EditMapSourceDialogFragment extends BaseOsmAndDialogFragment
elliptic = savedInstanceState.getBoolean(ELLIPTIC_KEY);
sqliteDB = savedInstanceState.getBoolean(SQLITE_DB_KEY);
}
- View root = UiUtilities.getMaterialInflater(getContext(), nightMode).inflate(R.layout.fragment_edit_map_source, container, false);
+ View root = UiUtilities.getMaterialInflater(app, nightMode).inflate(R.layout.fragment_edit_map_source, container, false);
Toolbar toolbar = root.findViewById(R.id.toolbar);
- ImageView iconHelp = root.findViewById(R.id.toolbar_action);
- Drawable closeDrawable = app.getUIUtilities().getIcon(R.drawable.ic_arrow_back,
+ ImageButton iconHelp = root.findViewById(R.id.toolbar_action);
+ Drawable closeDrawable = app.getUIUtilities().getIcon(AndroidUtils.getNavigationIconResId(app),
nightMode ? R.color.active_buttons_and_links_text_dark : R.color.active_buttons_and_links_text_light);
Drawable helpDrawable = app.getUIUtilities().getIcon(R.drawable.ic_action_help,
nightMode ? R.color.active_buttons_and_links_text_dark : R.color.active_buttons_and_links_text_light);
@@ -141,8 +142,8 @@ public class EditMapSourceDialogFragment extends BaseOsmAndDialogFragment
}
});
int boxStrokeColor = nightMode
- ? getResources().getColor(R.color.app_bar_color_light)
- : getResources().getColor(R.color.active_buttons_and_links_bg_pressed_dark);
+ ? ContextCompat.getColor(app, R.color.app_bar_color_light)
+ : ContextCompat.getColor(app, R.color.active_buttons_and_links_bg_pressed_dark);
TextInputLayout nameInputLayout = root.findViewById(R.id.name_input_layout);
nameInputLayout.setBoxStrokeColor(boxStrokeColor);
nameEditText = root.findViewById(R.id.name_edit_text);
@@ -154,7 +155,13 @@ public class EditMapSourceDialogFragment extends BaseOsmAndDialogFragment
contentContainer = root.findViewById(R.id.content_container);
saveBtn = root.findViewById(R.id.save_button);
saveBtnTitle = root.findViewById(R.id.save_button_title);
- saveBtn.setOnClickListener(this);
+ saveBtn.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ saveTemplate();
+ dismiss();
+ }
+ });
template = new TileSourceManager.TileSourceTemplate("", "", PNG_EXT, MAX_ZOOM, MIN_ZOOM, TILE_SIZE, BIT_DENSITY, AVG_SIZE);
if (editedLayerName != null) {
if (!editedLayerName.endsWith(IndexConstants.SQLITE_EXT)) {
@@ -222,19 +229,15 @@ public class EditMapSourceDialogFragment extends BaseOsmAndDialogFragment
@Override
public void onZoomSet(int min, int max) {
- if (isAdded()) {
minZoom = min;
maxZoom = max;
updateDescription(ConfigurationItem.ZOOM_LEVELS);
- }
}
@Override
public void onExpireValueSet(int expireValue) {
- if (isAdded()) {
expireTimeMinutes = expireValue;
updateDescription(ConfigurationItem.EXPIRE_TIME);
- }
}
@Override
@@ -253,14 +256,6 @@ public class EditMapSourceDialogFragment extends BaseOsmAndDialogFragment
}
}
- @Override
- public void onClick(View view) {
- if (view.getId() == R.id.save_button) {
- saveTemplate();
- dismiss();
- }
- }
-
private TextWatcher getTextWatcher() {
return new TextWatcher() {
@Override
@@ -390,7 +385,7 @@ public class EditMapSourceDialogFragment extends BaseOsmAndDialogFragment
@Override
public void onClick(View view) {
FragmentManager fm = getFragmentManager();
- if (fm != null) {
+ if (fm != null && !fm.isStateSaved()) {
switch (item) {
case ZOOM_LEVELS:
InputZoomLevelsBottomSheet.showInstance(
@@ -415,7 +410,7 @@ public class EditMapSourceDialogFragment extends BaseOsmAndDialogFragment
}
private void addConfigurationItems(ConfigurationItem... items) {
- LayoutInflater inflater = UiUtilities.getMaterialInflater(getContext(), nightMode);
+ LayoutInflater inflater = UiUtilities.getMaterialInflater(app, nightMode);
for (ConfigurationItem item : items) {
View view = inflater.inflate(R.layout.list_item_ui_customization, null);
((ImageView) view.findViewById(R.id.icon)).setImageDrawable(app.getUIUtilities().getIcon(item.iconRes, nightMode));
diff --git a/OsmAnd/src/net/osmand/plus/mapsource/ExpireTimeBottomSheet.java b/OsmAnd/src/net/osmand/plus/mapsource/ExpireTimeBottomSheet.java
index 1f645a3848..e9016980ba 100644
--- a/OsmAnd/src/net/osmand/plus/mapsource/ExpireTimeBottomSheet.java
+++ b/OsmAnd/src/net/osmand/plus/mapsource/ExpireTimeBottomSheet.java
@@ -7,7 +7,7 @@ import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
-import androidx.annotation.StringRes;
+import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
@@ -15,6 +15,7 @@ import com.google.android.material.textfield.TextInputEditText;
import com.google.android.material.textfield.TextInputLayout;
import net.osmand.PlatformUtil;
+import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
@@ -45,6 +46,7 @@ public class ExpireTimeBottomSheet extends MenuBottomSheetDialogFragment {
@Override
public void createMenuItems(Bundle savedInstanceState) {
+ OsmandApplication app = requiredMyApplication();
if (savedInstanceState != null) {
expireValue = savedInstanceState.getInt(EXPIRE_VALUE_KEY, EXPIRE_TIME_NEVER);
}
@@ -58,8 +60,8 @@ public class ExpireTimeBottomSheet extends MenuBottomSheetDialogFragment {
editText.setText(String.valueOf(expireValue));
}
int boxStrokeColor = nightMode
- ? getResources().getColor(R.color.app_bar_color_light)
- : getResources().getColor(R.color.active_buttons_and_links_bg_pressed_dark);
+ ? ContextCompat.getColor(app, R.color.app_bar_color_light)
+ : ContextCompat.getColor(app, R.color.active_buttons_and_links_bg_pressed_dark);
TextInputLayout textInputLayout = inputValueLayout.findViewById(R.id.value_input_layout);
textInputLayout.setBoxStrokeColor(boxStrokeColor);
final SimpleBottomSheetItem editTextItem = (SimpleBottomSheetItem) new SimpleBottomSheetItem.Builder()
@@ -70,13 +72,12 @@ public class ExpireTimeBottomSheet extends MenuBottomSheetDialogFragment {
@Override
public void onSaveInstanceState(Bundle outState) {
- outState.putLong(EXPIRE_VALUE_KEY, getExpireValue());
+ outState.putInt(EXPIRE_VALUE_KEY, getExpireValue());
super.onSaveInstanceState(outState);
}
@Override
protected void onRightBottomButtonClick() {
- super.onRightBottomButtonClick();
Fragment fragment = getTargetFragment();
if (fragment instanceof OnExpireValueSetListener) {
((OnExpireValueSetListener) fragment).onExpireValueSet(getExpireValue());
diff --git a/OsmAnd/src/net/osmand/plus/mapsource/InputZoomLevelsBottomSheet.java b/OsmAnd/src/net/osmand/plus/mapsource/InputZoomLevelsBottomSheet.java
index 8c11a97d70..3f44454f22 100644
--- a/OsmAnd/src/net/osmand/plus/mapsource/InputZoomLevelsBottomSheet.java
+++ b/OsmAnd/src/net/osmand/plus/mapsource/InputZoomLevelsBottomSheet.java
@@ -17,6 +17,7 @@ import androidx.fragment.app.FragmentManager;
import com.google.android.material.slider.Slider;
import net.osmand.PlatformUtil;
+import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
@@ -38,7 +39,7 @@ public class InputZoomLevelsBottomSheet extends MenuBottomSheetDialogFragment {
private static final String SLIDER_DESCR_RES_KEY = "slider_descr_key";
private static final String DIALOG_DESCR_RES_KEY = "dialog_descr_key";
private static final int SLIDER_FROM = 1;
- private static final int SLIDER_TO = 20;
+ private static final int SLIDER_TO = 22;
@StringRes
private int sliderDescrRes;
@StringRes
@@ -63,13 +64,14 @@ public class InputZoomLevelsBottomSheet extends MenuBottomSheetDialogFragment {
@Override
public void createMenuItems(Bundle savedInstanceState) {
+ OsmandApplication app = requiredMyApplication();
if (savedInstanceState != null) {
minZoom = savedInstanceState.getInt(MIN_ZOOM_KEY);
maxZoom = savedInstanceState.getInt(MAX_ZOOM_KEY);
dialogDescrRes = savedInstanceState.getInt(DIALOG_DESCR_RES_KEY);
sliderDescrRes = savedInstanceState.getInt(SLIDER_DESCR_RES_KEY);
}
- LayoutInflater inflater = UiUtilities.getInflater(requiredMyApplication(), nightMode);
+ LayoutInflater inflater = UiUtilities.getInflater(app, nightMode);
TitleItem titleItem = new TitleItem(getString(R.string.shared_string_zoom_levels));
items.add(titleItem);
final View sliderView = inflater.inflate(R.layout.zoom_levels_with_descr, null);
@@ -88,8 +90,8 @@ public class InputZoomLevelsBottomSheet extends MenuBottomSheetDialogFragment {
final TextView maxZoomValue = sliderView.findViewById(R.id.zoom_value_max);
maxZoomValue.setText(String.valueOf(maxZoom));
Slider slider = sliderView.findViewById(R.id.zoom_slider);
- int colorProfileRes = requiredMyApplication().getSettings().getApplicationMode().getIconColorInfo().getColor(nightMode);
- int colorProfile = ContextCompat.getColor(requiredMyApplication(), colorProfileRes);
+ int colorProfileRes = app.getSettings().getApplicationMode().getIconColorInfo().getColor(nightMode);
+ int colorProfile = ContextCompat.getColor(app, colorProfileRes);
UiUtilities.setupSlider(slider, nightMode, colorProfile, true);
slider.setValueFrom(SLIDER_FROM);
slider.setValueTo(SLIDER_TO);
@@ -136,7 +138,6 @@ public class InputZoomLevelsBottomSheet extends MenuBottomSheetDialogFragment {
@Override
protected void onRightBottomButtonClick() {
- super.onRightBottomButtonClick();
Fragment fragment = getTargetFragment();
if (fragment instanceof OnZoomSetListener) {
((OnZoomSetListener) fragment).onZoomSet(minZoom, maxZoom);