use of net.osmand.aidlapi.OsmAndCustomizationConstants.MAP_MAGNIFIER_ID in project Osmand by osmandapp.
the class ConfigureMapMenu method createRenderingAttributeItems.
private void createRenderingAttributeItems(List<RenderingRuleProperty> customRules, final ContextMenuAdapter adapter, final MapActivity activity, final boolean nightMode) {
final OsmandApplication app = activity.getMyApplication();
final OsmandSettings settings = app.getSettings();
final int selectedProfileColor = settings.APPLICATION_MODE.get().getProfileColor(nightMode);
final int themeRes = getThemeRes(nightMode);
adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.map_widget_map_rendering, activity).setId(MAP_RENDERING_CATEGORY_ID).setCategory(true).setLayout(R.layout.list_group_title_with_switch).createItem());
adapter.addItem(new ContextMenuItem.ItemBuilder().setId(MAP_STYLE_ID).setTitleId(R.string.map_widget_renderer, activity).setLayout(R.layout.list_item_single_line_descrition_narrow).setIcon(R.drawable.ic_map).setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
public boolean onContextMenuClick(final ArrayAdapter<ContextMenuItem> ad, int itemId, final int pos, boolean isChecked, int[] viewCoordinates) {
SelectMapStyleBottomSheetDialogFragment.showInstance(activity.getSupportFragmentManager());
return false;
}
}).setItemDeleteAction(makeDeleteAction(settings.RENDERER)).setOnUpdateCallback(new ContextMenuItem.OnUpdateCallback() {
@Override
public void onUpdateMenuItem(ContextMenuItem item) {
String renderDescr = ConfigureMapUtils.getRenderDescr(app);
item.setDescription(renderDescr);
}
}).createItem());
String description = "";
SunriseSunset sunriseSunset = activity.getMyApplication().getDaynightHelper().getSunriseSunset();
if (sunriseSunset != null && sunriseSunset.getSunrise() != null && sunriseSunset.getSunset() != null) {
DateFormat dateFormat = DateFormat.getTimeInstance(DateFormat.SHORT);
String sunriseTime = dateFormat.format(sunriseSunset.getSunrise());
String sunsetTime = dateFormat.format(sunriseSunset.getSunset());
DayNightMode dayNightMode = activity.getMyApplication().getSettings().DAYNIGHT_MODE.get();
if (dayNightMode.isDay() || dayNightMode.isNight()) {
if (sunriseSunset.isDaytime()) {
description = String.format(app.getString(R.string.sunset_at), sunsetTime);
} else {
description = String.format(app.getString(R.string.sunrise_at), sunriseTime);
}
} else if (dayNightMode.isAuto() || dayNightMode.isSensor()) {
description = String.format(app.getString(R.string.ltr_or_rtl_combine_via_slash), sunriseTime, sunsetTime);
}
description = String.format(app.getString(R.string.ltr_or_rtl_combine_via_bold_point), ConfigureMapUtils.getDayNightDescr(activity), description);
} else {
description = ConfigureMapUtils.getDayNightDescr(activity);
}
adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.map_mode, activity).setId(MAP_MODE_ID).setDescription(description).setIcon(ConfigureMapUtils.getDayNightIcon(activity)).setListener((ad, itemId, pos, isChecked, viewCoordinates) -> {
if (AndroidUtils.isActivityNotDestroyed(activity)) {
ConfigureMapDialogs.showMapModeDialog(activity, themeRes, nightMode);
}
return false;
}).setItemDeleteAction(makeDeleteAction(settings.DAYNIGHT_MODE)).createItem());
adapter.addItem(new ContextMenuItem.ItemBuilder().setId(MAP_MAGNIFIER_ID).setTitleId(R.string.map_magnifier, activity).setDescription(String.format(Locale.UK, "%.0f", 100f * activity.getMyApplication().getSettings().MAP_DENSITY.get()) + " %").setLayout(R.layout.list_item_single_line_descrition_narrow).setIcon(R.drawable.ic_action_map_magnifier).setListener((ad, itemId, pos, isChecked, viewCoordinates) -> {
if (AndroidUtils.isActivityNotDestroyed(activity)) {
ConfigureMapDialogs.showMapMagnifierDialog(activity, adapter, themeRes, nightMode, pos, ad);
}
return false;
}).setItemDeleteAction(makeDeleteAction(settings.MAP_DENSITY)).createItem());
ContextMenuItem props = createRenderingProperty(customRules, adapter, activity, R.drawable.ic_action_intersection, ROAD_STYLE_ATTR, ROAD_STYLE_ID, nightMode);
if (props != null) {
adapter.addItem(props);
}
adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.text_size, activity).setId(TEXT_SIZE_ID).setDescription(ConfigureMapUtils.getScale(activity)).setLayout(R.layout.list_item_single_line_descrition_narrow).setIcon(R.drawable.ic_action_map_text_size).setListener((ad, itemId, pos, isChecked, viewCoordinates) -> {
if (AndroidUtils.isActivityNotDestroyed(activity)) {
ConfigureMapDialogs.showTextSizeDialog(activity, adapter, themeRes, nightMode, pos, ad);
}
return false;
}).setItemDeleteAction(makeDeleteAction(settings.TEXT_SCALE)).createItem());
String localeDescr = activity.getMyApplication().getSettings().MAP_PREFERRED_LOCALE.get();
localeDescr = localeDescr == null || localeDescr.isEmpty() ? activity.getString(R.string.local_map_names) : localeDescr;
adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.map_locale, activity).setId(MAP_LANGUAGE_ID).setDescription(localeDescr).setLayout(R.layout.list_item_single_line_descrition_narrow).setIcon(R.drawable.ic_action_map_language).setListener((ad, itemId, pos, isChecked, viewCoordinates) -> {
if (AndroidUtils.isActivityNotDestroyed(activity)) {
ConfigureMapDialogs.showMapLanguageDialog(activity, adapter, themeRes, nightMode, pos, ad);
}
return false;
}).setItemDeleteAction(makeDeleteAction(settings.MAP_PREFERRED_LOCALE)).createItem());
props = createProperties(customRules, R.string.rendering_category_details, R.drawable.ic_action_layers, UI_CATEGORY_DETAILS, adapter, activity, true, DETAILS_ID, nightMode, selectedProfileColor);
if (props != null) {
adapter.addItem(props);
}
props = createProperties(customRules, R.string.rendering_category_hide, R.drawable.ic_action_hide, UI_CATEGORY_HIDE, adapter, activity, true, HIDE_ID, nightMode, selectedProfileColor);
if (props != null) {
adapter.addItem(props);
}
props = createProperties(customRules, R.string.rendering_category_routes, R.drawable.ic_action_map_routes, UI_CATEGORY_ROUTES, adapter, activity, true, CUSTOM_RENDERING_ITEMS_ID_SCHEME + UI_CATEGORY_ROUTES, nightMode, selectedProfileColor);
if (props != null) {
adapter.addItem(props);
}
if (getCustomRenderingPropertiesSize(customRules) > 0) {
adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.rendering_category_others, activity).setCategory(true).setLayout(R.layout.list_group_title_with_switch).createItem());
createCustomRenderingProperties(adapter, activity, customRules, nightMode);
}
}
Aggregations