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.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
@ -10,6 +11,7 @@ import androidx.annotation.NonNull;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;
import net.osmand.AndroidUtils;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
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.SimpleBottomSheetItem;
import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerItem;
import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerSpaceItem;
import net.osmand.util.Algorithms;
import java.io.File;
public class SavedTrackBottomSheetDialogFragment extends MenuBottomSheetDialogFragment {
public static final String TAG = SavedTrackBottomSheetDialogFragment.class.getSimpleName();
@ -68,16 +71,47 @@ public class SavedTrackBottomSheetDialogFragment extends MenuBottomSheetDialogFr
}
})
.create());
}
items.add(new DividerSpaceItem(getContext(), contextPaddingSmall));
items.add(new BottomSheetItemButton.Builder()
.setButtonType(UiUtilities.DialogButtonType.SECONDARY)
.setTitle(getString(R.string.plan_route_create_new_route))
.setLayoutId(R.layout.bottom_sheet_button)
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
protected int getThirdBottomButtonTextId() {
return R.string.shared_string_share;
}
@Override
protected void onThirdBottomButtonClick() {
final Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
final Uri fileUri = AndroidUtils.getUriForFile(getMyApplication(), new File(fileName));
sendIntent.putExtra(Intent.EXTRA_STREAM, fileUri);
sendIntent.setType("application/gpx+xml");
sendIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(sendIntent);
dismiss();
}
@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(),
@ -85,10 +119,10 @@ public class SavedTrackBottomSheetDialogFragment extends MenuBottomSheetDialogFr
}
dismiss();
}
})
.create());
items.add(new DividerSpaceItem(getContext(), contextPaddingSmall));
@Override
protected int getFirstDividerHeight() {
return getResources().getDimensionPixelSize(R.dimen.context_menu_sub_info_height);
}
@Override