Make yes/no buttons larger and farther apart
This commit is contained in:
parent
88e40d0ecf
commit
ad281d4445
4 changed files with 133 additions and 22 deletions
|
@ -2652,7 +2652,7 @@
|
||||||
<string name="files_limit">%1$d files left</string>
|
<string name="files_limit">%1$d files left</string>
|
||||||
<string name="available_downloads_left">%1$d files left to download</string>
|
<string name="available_downloads_left">%1$d files left to download</string>
|
||||||
<string name="install_paid">Full version</string>
|
<string name="install_paid">Full version</string>
|
||||||
<string name="cancel_route">Dismiss route</string>
|
<string name="cancel_route">Dismiss route?</string>
|
||||||
<string name="cancel_navigation">Stop navigation</string>
|
<string name="cancel_navigation">Stop navigation</string>
|
||||||
<string name="clear_destination">Clear destination</string>
|
<string name="clear_destination">Clear destination</string>
|
||||||
<string name="download_using_mobile_internet">Not connected to Wi-Fi. Use current connection to the Internet to download?</string>
|
<string name="download_using_mobile_internet">Not connected to Wi-Fi. Use current connection to the Internet to download?</string>
|
||||||
|
|
|
@ -61,6 +61,7 @@ import net.osmand.plus.mapmarkers.MarkersPlanRouteContext;
|
||||||
import net.osmand.plus.measurementtool.MeasurementToolFragment;
|
import net.osmand.plus.measurementtool.MeasurementToolFragment;
|
||||||
import net.osmand.plus.measurementtool.StartPlanRouteBottomSheet;
|
import net.osmand.plus.measurementtool.StartPlanRouteBottomSheet;
|
||||||
import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
|
import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
|
||||||
|
import net.osmand.plus.osmedit.dialogs.DismissRouteBottomSheetFragment;
|
||||||
import net.osmand.plus.profiles.RoutingProfileDataObject;
|
import net.osmand.plus.profiles.RoutingProfileDataObject;
|
||||||
import net.osmand.plus.routepreparationmenu.MapRouteInfoMenu;
|
import net.osmand.plus.routepreparationmenu.MapRouteInfoMenu;
|
||||||
import net.osmand.plus.routepreparationmenu.WaypointsFragment;
|
import net.osmand.plus.routepreparationmenu.WaypointsFragment;
|
||||||
|
@ -157,6 +158,7 @@ public class MapActivityActions implements DialogProvider {
|
||||||
|
|
||||||
private final MapActivity mapActivity;
|
private final MapActivity mapActivity;
|
||||||
private OsmandSettings settings;
|
private OsmandSettings settings;
|
||||||
|
private DialogInterface.OnDismissListener dismissListener;
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
private ImageView drawerLogoHeader;
|
private ImageView drawerLogoHeader;
|
||||||
|
@ -1122,26 +1124,8 @@ public class MapActivityActions implements DialogProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public AlertDialog stopNavigationActionConfirm() {
|
public void stopNavigationActionConfirm() {
|
||||||
return stopNavigationActionConfirm(null);
|
DismissRouteBottomSheetFragment.showInstance(mapActivity.getSupportFragmentManager(), null, dismissListener);
|
||||||
}
|
|
||||||
|
|
||||||
public AlertDialog stopNavigationActionConfirm(final Runnable onStopAction) {
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(mapActivity);
|
|
||||||
// Stop the navigation
|
|
||||||
builder.setTitle(getString(R.string.cancel_route));
|
|
||||||
builder.setMessage(getString(R.string.stop_routing_confirm));
|
|
||||||
builder.setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
stopNavigationWithoutConfirm();
|
|
||||||
if (onStopAction != null) {
|
|
||||||
onStopAction.run();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
builder.setNegativeButton(R.string.shared_string_no, null);
|
|
||||||
return builder.show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void whereAmIDialog() {
|
public void whereAmIDialog() {
|
||||||
|
|
|
@ -306,7 +306,7 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean useVerticalButtons() {
|
protected boolean useVerticalButtons() {
|
||||||
Activity activity = requireActivity();
|
Activity activity = requireActivity();
|
||||||
int rightBottomButtonTextId = getRightBottomButtonTextId();
|
int rightBottomButtonTextId = getRightBottomButtonTextId();
|
||||||
if (getDismissButtonTextId() != DEFAULT_VALUE && rightBottomButtonTextId != DEFAULT_VALUE) {
|
if (getDismissButtonTextId() != DEFAULT_VALUE && rightBottomButtonTextId != DEFAULT_VALUE) {
|
||||||
|
|
|
@ -0,0 +1,127 @@
|
||||||
|
package net.osmand.plus.osmedit.dialogs;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.fragment.app.FragmentManager;
|
||||||
|
|
||||||
|
import net.osmand.plus.OsmandApplication;
|
||||||
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.UiUtilities;
|
||||||
|
import net.osmand.plus.activities.MapActivity;
|
||||||
|
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
||||||
|
import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerSpaceItem;
|
||||||
|
import net.osmand.plus.base.bottomsheetmenu.simpleitems.ShortDescriptionItem;
|
||||||
|
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||||
|
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||||
|
import net.osmand.router.GeneralRouter;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class DismissRouteBottomSheetFragment extends MenuBottomSheetDialogFragment {
|
||||||
|
|
||||||
|
private OsmandApplication app;
|
||||||
|
private OsmandSettings settings;
|
||||||
|
|
||||||
|
public static final int REQUEST_CODE = 1001;
|
||||||
|
|
||||||
|
public static final String TAG = DismissRouteBottomSheetFragment.class.getSimpleName();
|
||||||
|
private DialogInterface.OnDismissListener dismissListener;
|
||||||
|
|
||||||
|
public DismissRouteBottomSheetFragment() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void createMenuItems(Bundle savedInstanceState) {
|
||||||
|
app = getMyApplication();
|
||||||
|
if (app != null) {
|
||||||
|
settings = app.getSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
items.add(new ShortDescriptionItem.Builder()
|
||||||
|
.setDescription(getString(R.string.stop_routing_confirm))
|
||||||
|
.setTitle(getString(R.string.cancel_route))
|
||||||
|
.setLayoutId(R.layout.bottom_sheet_item_list_title_with_descr)
|
||||||
|
.create());
|
||||||
|
|
||||||
|
items.add(new DividerSpaceItem(getContext(),
|
||||||
|
getResources().getDimensionPixelSize(R.dimen.content_padding_small)));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean useVerticalButtons() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getDismissButtonTextId() {
|
||||||
|
return R.string.shared_string_cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getRightBottomButtonTextId() {
|
||||||
|
return R.string.shared_string_dismiss;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected UiUtilities.DialogButtonType getRightBottomButtonType() {
|
||||||
|
return (UiUtilities.DialogButtonType.PRIMARY);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getSecondDividerHeight() {
|
||||||
|
return getResources().getDimensionPixelSize(R.dimen.bottom_sheet_icon_margin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onRightBottomButtonClick() {
|
||||||
|
stopNavigationWithoutConfirm();
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void stopNavigationWithoutConfirm() {
|
||||||
|
app.stopNavigation();
|
||||||
|
getMapActivity().updateApplicationModeSettings();
|
||||||
|
getMapActivity().getDashboard().clearDeletedPoints();
|
||||||
|
List<ApplicationMode> modes = ApplicationMode.values(app);
|
||||||
|
for (ApplicationMode mode : modes) {
|
||||||
|
if (settings.FORCE_PRIVATE_ACCESS_ROUTING_ASKED.getModeValue(mode)) {
|
||||||
|
settings.FORCE_PRIVATE_ACCESS_ROUTING_ASKED.setModeValue(mode, false);
|
||||||
|
settings.getCustomRoutingBooleanProperty(GeneralRouter.ALLOW_PRIVATE, false).setModeValue(mode, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDismiss(@NonNull DialogInterface dialog) {
|
||||||
|
super.onDismiss(dialog);
|
||||||
|
if (dismissListener != null) {
|
||||||
|
dismissListener.onDismiss(dialog);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public MapActivity getMapActivity() {
|
||||||
|
Activity activity = getActivity();
|
||||||
|
if (activity instanceof MapActivity) {
|
||||||
|
return (MapActivity) activity;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void showInstance(@NonNull FragmentManager fragmentManager, @Nullable Fragment targetFragment, DialogInterface.OnDismissListener dismissListener) {
|
||||||
|
if (!fragmentManager.isStateSaved()) {
|
||||||
|
DismissRouteBottomSheetFragment fragment = new DismissRouteBottomSheetFragment();
|
||||||
|
fragment.dismissListener = dismissListener;
|
||||||
|
fragment.setTargetFragment(targetFragment, REQUEST_CODE);
|
||||||
|
fragment.show(fragmentManager, TAG);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue