mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-22 14:13:45 +00:00
@@ -425,15 +425,6 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||||||
|
|
||||||
private void shareMyLocation()
|
private void shareMyLocation()
|
||||||
{
|
{
|
||||||
// Check if location sharing is already active
|
|
||||||
if (app.organicmaps.location.LocationSharingManager.getInstance().isSharing())
|
|
||||||
{
|
|
||||||
// Stop sharing
|
|
||||||
app.organicmaps.location.LocationSharingManager.getInstance().stopSharing();
|
|
||||||
mMapButtonsViewModel.setLocationSharingState(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final Location loc = MwmApplication.from(this).getLocationHelper().getSavedLocation();
|
final Location loc = MwmApplication.from(this).getLocationHelper().getSavedLocation();
|
||||||
if (loc == null)
|
if (loc == null)
|
||||||
{
|
{
|
||||||
@@ -447,27 +438,8 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show dialog with two options: share current coordinates or start live sharing
|
|
||||||
new MaterialAlertDialogBuilder(this, R.style.MwmTheme_AlertDialog)
|
|
||||||
.setTitle(R.string.share_my_location)
|
|
||||||
.setItems(new CharSequence[] {
|
|
||||||
getString(R.string.share_location_coordinates),
|
|
||||||
getString(R.string.share_location_live)
|
|
||||||
}, (dialog, which) -> {
|
|
||||||
if (which == 0)
|
|
||||||
{
|
|
||||||
// Share current coordinates
|
|
||||||
SharingUtils.shareLocation(this, loc);
|
SharingUtils.shareLocation(this, loc);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
// Start live location sharing
|
|
||||||
app.organicmaps.location.LocationSharingDialog.show(getSupportFragmentManager());
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.setNegativeButton(R.string.cancel, null)
|
|
||||||
.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onLocationSharingStateChanged(boolean isSharing)
|
public void onLocationSharingStateChanged(boolean isSharing)
|
||||||
{
|
{
|
||||||
@@ -1724,6 +1696,13 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||||||
mMapButtonsViewModel.setLayoutMode(MapButtonsController.LayoutMode.regular);
|
mMapButtonsViewModel.setLayoutMode(MapButtonsController.LayoutMode.regular);
|
||||||
refreshLightStatusBar();
|
refreshLightStatusBar();
|
||||||
Utils.keepScreenOn(Config.isKeepScreenOnEnabled(), getWindow());
|
Utils.keepScreenOn(Config.isKeepScreenOnEnabled(), getWindow());
|
||||||
|
|
||||||
|
// Stop location sharing when navigation ends
|
||||||
|
if (app.organicmaps.location.LocationSharingManager.getInstance().isSharing())
|
||||||
|
{
|
||||||
|
app.organicmaps.location.LocationSharingManager.getInstance().stopSharing();
|
||||||
|
onLocationSharingStateChanged(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -2537,10 +2516,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||||||
items.add(new MenuBottomSheetItem(R.string.start_track_recording, R.drawable.ic_track_recording_off, -1,
|
items.add(new MenuBottomSheetItem(R.string.start_track_recording, R.drawable.ic_track_recording_off, -1,
|
||||||
this::onTrackRecordingOptionSelected));
|
this::onTrackRecordingOptionSelected));
|
||||||
|
|
||||||
final boolean isLocationSharingActive = app.organicmaps.location.LocationSharingManager.getInstance().isSharing();
|
items.add(new MenuBottomSheetItem(R.string.share_my_location, R.drawable.ic_share,
|
||||||
final int locationSharingTitleRes = isLocationSharingActive ? R.string.stop_sharing_my_location : R.string.share_my_location;
|
|
||||||
final int locationSharingBadge = isLocationSharingActive ? -1 : 0;
|
|
||||||
items.add(new MenuBottomSheetItem(locationSharingTitleRes, R.drawable.ic_share, locationSharingBadge,
|
|
||||||
this::onShareLocationOptionSelected));
|
this::onShareLocationOptionSelected));
|
||||||
|
|
||||||
if (!BUTTON_HELP_CODE.equals(activeLeftButton))
|
if (!BUTTON_HELP_CODE.equals(activeLeftButton))
|
||||||
|
|||||||
@@ -323,8 +323,7 @@ public class MapButtonsController extends Fragment
|
|||||||
BadgeUtils.attachBadgeDrawable(mBadgeDrawable, menuButton);
|
BadgeUtils.attachBadgeDrawable(mBadgeDrawable, menuButton);
|
||||||
|
|
||||||
final boolean isTrackRecording = TrackRecorder.nativeIsTrackRecordingEnabled();
|
final boolean isTrackRecording = TrackRecorder.nativeIsTrackRecordingEnabled();
|
||||||
final boolean isLocationSharing = app.organicmaps.location.LocationSharingManager.getInstance().isSharing();
|
updateMenuBadge(isTrackRecording);
|
||||||
updateMenuBadge(isTrackRecording || isLocationSharing);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateLayerButton()
|
public void updateLayerButton()
|
||||||
|
|||||||
@@ -68,16 +68,6 @@ public class MenuAdapter extends RecyclerView.Adapter<MenuAdapter.ViewHolder>
|
|||||||
badge.setBackgroundResource(R.drawable.track_recorder_badge);
|
badge.setBackgroundResource(R.drawable.track_recorder_badge);
|
||||||
badge.setVisibility(View.VISIBLE);
|
badge.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.iconRes == R.drawable.ic_share && app.organicmaps.location.LocationSharingManager.getInstance().isSharing())
|
|
||||||
{
|
|
||||||
// Set icon tint to orange
|
|
||||||
iv.setImageTintList(android.content.res.ColorStateList.valueOf(
|
|
||||||
androidx.core.content.ContextCompat.getColor(viewHolder.itemView.getContext(), R.color.active_location_sharing)));
|
|
||||||
// Show badge
|
|
||||||
badge.setBackgroundResource(R.drawable.location_sharing_badge);
|
|
||||||
badge.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user