Plan route share button

This commit is contained in:
Dima-1 2020-11-24 18:43:40 +02:00
parent e9b3a881b5
commit 839e11faac

View file

@ -2,6 +2,7 @@ package net.osmand.plus.measurementtool;
import android.app.Activity; import android.app.Activity;
import android.content.Intent; import android.content.Intent;
import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.view.View; import android.view.View;
import android.widget.TextView; import android.widget.TextView;
@ -10,6 +11,7 @@ import androidx.annotation.NonNull;
import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentManager;
import net.osmand.AndroidUtils;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.UiUtilities; import net.osmand.plus.UiUtilities;
@ -19,9 +21,10 @@ import net.osmand.plus.base.MenuBottomSheetDialogFragment;
import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemButton; import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemButton;
import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem; import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem;
import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerItem; import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerItem;
import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerSpaceItem;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
import java.io.File;
public class SavedTrackBottomSheetDialogFragment extends MenuBottomSheetDialogFragment { public class SavedTrackBottomSheetDialogFragment extends MenuBottomSheetDialogFragment {
public static final String TAG = SavedTrackBottomSheetDialogFragment.class.getSimpleName(); public static final String TAG = SavedTrackBottomSheetDialogFragment.class.getSimpleName();
@ -68,27 +71,58 @@ public class SavedTrackBottomSheetDialogFragment extends MenuBottomSheetDialogFr
} }
}) })
.create()); .create());
}
items.add(new DividerSpaceItem(getContext(), contextPaddingSmall)); @Override
protected int getThirdBottomButtonTextId() {
return R.string.shared_string_share;
}
items.add(new BottomSheetItemButton.Builder() @Override
.setButtonType(UiUtilities.DialogButtonType.SECONDARY) protected void onThirdBottomButtonClick() {
.setTitle(getString(R.string.plan_route_create_new_route)) final Intent sendIntent = new Intent();
.setLayoutId(R.layout.bottom_sheet_button) sendIntent.setAction(Intent.ACTION_SEND);
.setOnClickListener(new View.OnClickListener() { final Uri fileUri = AndroidUtils.getUriForFile(getMyApplication(), new File(fileName));
@Override sendIntent.putExtra(Intent.EXTRA_STREAM, fileUri);
public void onClick(View v) { sendIntent.setType("application/gpx+xml");
Activity activity = getActivity(); sendIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
if (activity instanceof MapActivity) { startActivity(sendIntent);
MeasurementToolFragment.showInstance(((MapActivity) activity).getSupportFragmentManager(), dismiss();
((MapActivity) activity).getMapLocation()); }
}
dismiss();
}
})
.create());
items.add(new DividerSpaceItem(getContext(), contextPaddingSmall)); @Override
protected UiUtilities.DialogButtonType getThirdBottomButtonType() {
return UiUtilities.DialogButtonType.SECONDARY;
}
@Override
protected int getSecondDividerHeight() {
return getResources().getDimensionPixelSize(R.dimen.content_padding_small);
}
@Override
protected int getRightBottomButtonTextId() {
return R.string.plan_route_create_new_route;
}
@Override
protected UiUtilities.DialogButtonType getRightBottomButtonType() {
return UiUtilities.DialogButtonType.SECONDARY;
}
@Override
protected void onRightBottomButtonClick() {
Activity activity = getActivity();
if (activity instanceof MapActivity) {
MeasurementToolFragment.showInstance(((MapActivity) activity).getSupportFragmentManager(),
((MapActivity) activity).getMapLocation());
}
dismiss();
}
@Override
protected int getFirstDividerHeight() {
return getResources().getDimensionPixelSize(R.dimen.context_menu_sub_info_height);
} }
@Override @Override