Fix string and update continue button
This commit is contained in:
parent
e5152aa947
commit
bae457acb9
4 changed files with 21 additions and 28 deletions
|
@ -81,37 +81,20 @@
|
|||
android:layout_width="@dimen/content_padding"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
<FrameLayout
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/content_padding_half"
|
||||
android:layout_marginTop="@dimen/content_padding_half"
|
||||
android:layout_marginRight="@dimen/content_padding_half"
|
||||
android:layout_marginBottom="@dimen/content_padding_half"
|
||||
android:background="?attr/dlg_btn_primary">
|
||||
android:layout_marginBottom="@dimen/content_padding_half">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
<include
|
||||
android:id="@+id/continue_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center"
|
||||
android:letterSpacing="@dimen/description_letter_spacing"
|
||||
android:maxLines="1"
|
||||
android:paddingLeft="@dimen/content_padding"
|
||||
android:paddingTop="@dimen/content_padding_half"
|
||||
android:paddingRight="@dimen/content_padding"
|
||||
android:paddingBottom="@dimen/content_padding_half"
|
||||
android:text="@string/shared_string_continue"
|
||||
android:textColor="?attr/text_color_tab_active"
|
||||
android:textSize="@dimen/default_desc_text_size"
|
||||
osmand:lineHeight="@dimen/default_desc_line_height"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
tools:text="Continue" />
|
||||
layout="@layout/bottom_sheet_dialog_button"
|
||||
android:visibility="visible" />
|
||||
|
||||
</FrameLayout>
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
-->
|
||||
<string name="export_not_enough_space">There is not enough space</string>
|
||||
<string name="export_not_enough_space_descr">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.</string>
|
||||
<string name="export_not_enough_space_descr">Your device only has %1$s free. Please free up some space or unselect some items to export.</string>
|
||||
<string name="file_size_needed_for_import">Needed for import</string>
|
||||
<string name="select_data_to_export">Select the data to be exported to the file.</string>
|
||||
<string name="approximate_file_size">Approximate file size</string>
|
||||
|
|
|
@ -250,6 +250,10 @@ public class ExportSettingsAdapter extends OsmandBaseExpandableListAdapter {
|
|||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public boolean hasSelectedData() {
|
||||
return !selectedItemsMap.isEmpty();
|
||||
}
|
||||
|
||||
public List<? super Object> getData() {
|
||||
List<Object> selectedItems = new ArrayList<>();
|
||||
for (List<?> items : selectedItemsMap.values()) {
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue