Plan route share button
This commit is contained in:
parent
e9b3a881b5
commit
839e11faac
1 changed files with 53 additions and 19 deletions
|
@ -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,16 +71,47 @@ public class SavedTrackBottomSheetDialogFragment extends MenuBottomSheetDialogFr
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.create());
|
.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
|
@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();
|
Activity activity = getActivity();
|
||||||
if (activity instanceof MapActivity) {
|
if (activity instanceof MapActivity) {
|
||||||
MeasurementToolFragment.showInstance(((MapActivity) activity).getSupportFragmentManager(),
|
MeasurementToolFragment.showInstance(((MapActivity) activity).getSupportFragmentManager(),
|
||||||
|
@ -85,10 +119,10 @@ public class SavedTrackBottomSheetDialogFragment extends MenuBottomSheetDialogFr
|
||||||
}
|
}
|
||||||
dismiss();
|
dismiss();
|
||||||
}
|
}
|
||||||
})
|
|
||||||
.create());
|
|
||||||
|
|
||||||
items.add(new DividerSpaceItem(getContext(), contextPaddingSmall));
|
@Override
|
||||||
|
protected int getFirstDividerHeight() {
|
||||||
|
return getResources().getDimensionPixelSize(R.dimen.context_menu_sub_info_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue