diff --git a/OsmAnd/res/layout/fragment_import.xml b/OsmAnd/res/layout/fragment_import.xml index ef83bba63d..30f518cbfc 100644 --- a/OsmAnd/res/layout/fragment_import.xml +++ b/OsmAnd/res/layout/fragment_import.xml @@ -81,37 +81,20 @@ android:layout_width="@dimen/content_padding" android:layout_height="match_parent" /> - + android:layout_marginBottom="@dimen/content_padding_half"> - + layout="@layout/bottom_sheet_dialog_button" + android:visibility="visible" /> - + diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 6b382d13af..7a5a9b759e 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -12,7 +12,7 @@ --> There is not enough space - OsmAnd is needed %1$s to export a file. Your device only has %2$s free. You can free up space on the device, or skip some items from export. + Your device only has %1$s free. Please free up some space or unselect some items to export. Needed for import Select the data to be exported to the file. Approximate file size diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/ExportSettingsAdapter.java b/OsmAnd/src/net/osmand/plus/settings/fragments/ExportSettingsAdapter.java index 82ae93ebc0..65cd471216 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/ExportSettingsAdapter.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/ExportSettingsAdapter.java @@ -250,6 +250,10 @@ public class ExportSettingsAdapter extends OsmandBaseExpandableListAdapter { notifyDataSetChanged(); } + public boolean hasSelectedData() { + return !selectedItemsMap.isEmpty(); + } + public List getData() { List selectedItems = new ArrayList<>(); for (List items : selectedItemsMap.values()) { diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/ExportSettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/ExportSettingsFragment.java index f80c225ff2..9405714a34 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/ExportSettingsFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/ExportSettingsFragment.java @@ -34,6 +34,7 @@ import net.osmand.PlatformUtil; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; +import net.osmand.plus.UiUtilities.DialogButtonType; import net.osmand.plus.base.BaseOsmAndFragment; import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.settings.backend.ApplicationMode; @@ -79,6 +80,7 @@ public class ExportSettingsFragment extends BaseOsmAndFragment implements OnItem private ApplicationMode appMode; private SettingsExportListener exportListener; + private View continueBtn; private View headerShadow; private View headerDivider; private View itemsSizeContainer; @@ -150,13 +152,15 @@ public class ExportSettingsFragment extends BaseOsmAndFragment implements OnItem availableSpaceContainer = inflater.inflate(R.layout.enough_space_warning_card, null); availableSpaceDescr = availableSpaceContainer.findViewById(R.id.warning_descr); - TextViewEx continueBtn = root.findViewById(R.id.continue_button); + continueBtn = root.findViewById(R.id.continue_button); + UiUtilities.setupDialogButton(nightMode, continueBtn, DialogButtonType.PRIMARY, getString(R.string.shared_string_continue)); continueBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { prepareFile(); } }); + ViewTreeObserver treeObserver = buttonsContainer.getViewTreeObserver(); treeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override @@ -252,22 +256,24 @@ public class ExportSettingsFragment extends BaseOsmAndFragment implements OnItem private void updateAvailableSpace() { long calculatedSize = ExportSettingsAdapter.calculateItemsSize(adapter.getData()); if (calculatedSize != 0) { - String itemsSize = AndroidUtils.formatSize(app, calculatedSize); - selectedItemsSize.setText(itemsSize); + selectedItemsSize.setText(AndroidUtils.formatSize(app, calculatedSize)); File dir = app.getAppPath("").getParentFile(); long availableSizeBytes = AndroidUtils.getAvailableSpace(dir); if (calculatedSize > availableSizeBytes) { String availableSize = AndroidUtils.formatSize(app, availableSizeBytes); - availableSpaceDescr.setText(getString(R.string.export_not_enough_space_descr, itemsSize, availableSize)); + availableSpaceDescr.setText(getString(R.string.export_not_enough_space_descr, availableSize)); updateWarningHeaderVisibility(true); + continueBtn.setEnabled(false); } else { updateWarningHeaderVisibility(false); + continueBtn.setEnabled(adapter.hasSelectedData()); } itemsSizeContainer.setVisibility(View.VISIBLE); } else { updateWarningHeaderVisibility(false); itemsSizeContainer.setVisibility(View.INVISIBLE); + continueBtn.setEnabled(adapter.hasSelectedData()); } }