[android] Hide currently active left button action from hamburger menu

fixes #549
And add "About CoMaps" option in burger menu when using custom buttons
Signed-off-by: Harry Bond <me@hbond.xyz>
This commit is contained in:
Harry Bond
2025-06-23 02:03:24 +01:00
committed by Konstantin Pastbin
parent 464b3cf59a
commit 58bab61890
3 changed files with 28 additions and 13 deletions

View File

@@ -8,6 +8,7 @@ CoMaps contributors:
--------------------------------------------------------------------------------
clover sage
Harry Bond <me@hbond.xyz>
--------------------------------------------------------------------------------
Organic Maps (formerly OMaps) contributors:

View File

@@ -2584,20 +2584,28 @@ public class MwmActivity extends BaseMwmFragmentActivity
{
if (id.equals(MAIN_MENU_ID))
{
final String activeLeftButton = buttonsHolder.getActiveButtonCode();
ArrayList<MenuBottomSheetItem> items = new ArrayList<>();
items.add(new MenuBottomSheetItem(R.string.placepage_add_place_button, R.drawable.ic_plus, this::onAddPlaceOptionSelected));
items.add(new MenuBottomSheetItem(
R.string.download_maps,
R.drawable.ic_download,
getDownloadMapsCounter(),
this::onDownloadMapsOptionSelected
));
mDonatesUrl = Config.getDonateUrl(getApplicationContext());
if (!TextUtils.isEmpty(mDonatesUrl))
if (!BUTTON_ADD_PLACE_CODE.equals(activeLeftButton))
items.add(new MenuBottomSheetItem(R.string.placepage_add_place_button, R.drawable.ic_plus, this::onAddPlaceOptionSelected));
items.add(new MenuBottomSheetItem(R.string.download_maps, R.drawable.ic_download, getDownloadMapsCounter(), this::onDownloadMapsOptionSelected));
if (!Config.getDonateUrl(getApplicationContext()).isEmpty())
items.add(new MenuBottomSheetItem(R.string.donate, R.drawable.ic_donate, this::onDonateOptionSelected));
items.add(new MenuBottomSheetItem(R.string.settings, R.drawable.ic_settings, this::onSettingsOptionSelected));
items.add(new MenuBottomSheetItem(R.string.start_track_recording, R.drawable.ic_track_recording_off, -1, this::onTrackRecordingOptionSelected));
if (!BUTTON_SETTINGS_CODE.equals(activeLeftButton))
items.add(new MenuBottomSheetItem(R.string.settings, R.drawable.ic_settings, this::onSettingsOptionSelected));
if (!BUTTON_RECORD_TRACK_CODE.equals(activeLeftButton))
items.add(new MenuBottomSheetItem(R.string.start_track_recording, R.drawable.ic_track_recording_off, -1, this::onTrackRecordingOptionSelected));
items.add(new MenuBottomSheetItem(R.string.share_my_location, R.drawable.ic_share, this::onShareLocationOptionSelected));
if (!BUTTON_HELP_CODE.equals(activeLeftButton))
items.add(new MenuBottomSheetItem(R.string.about_menu_title, R.drawable.ic_question_mark, this::showHelp));
return items;
}
return null;

View File

@@ -43,15 +43,21 @@ public class LeftButtonsHolder
}
@Nullable
public LeftButton getActiveButton()
public String getActiveButtonCode()
{
String activeButtonCode = prefs.getString(leftButtonPreferenceKey, DEFAULT_BUTTON_CODE);
if (!TextUtils.isEmpty(activeButtonCode))
return availableButtons.get(activeButtonCode);
return activeButtonCode;
else
return null;
}
@Nullable
public LeftButton getActiveButton()
{
return availableButtons.get(getActiveButtonCode());
}
public Collection<LeftButton> getAllButtons()
{
return availableButtons.values();