use of net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerSpaceItem in project Osmand by osmandapp.
the class ExitBottomSheetDialogFragment method createMenuItems.
@Override
public void createMenuItems(Bundle savedInstanceState) {
Bundle args = getArguments();
String description = "";
if (args != null) {
description = args.getString(DESCRIPTION);
}
items.add(new ShortDescriptionItem.Builder().setDescription(description).setTitle(getString(R.string.exit_without_saving)).setLayoutId(R.layout.bottom_sheet_item_list_title_with_descr).create());
items.add(new DividerSpaceItem(getContext(), getResources().getDimensionPixelSize(R.dimen.bottom_sheet_exit_button_margin)));
}
use of net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerSpaceItem in project Osmand by osmandapp.
the class TripRecordingOptionsBottomSheet method createMenuItems.
@Override
public void createMenuItems(Bundle savedInstanceState) {
app = requiredMyApplication();
settings = app.getSettings();
helper = app.getSavingTrackHelper();
selectedGpxFile = helper.getCurrentTrack();
LayoutInflater inflater = UiUtilities.getInflater(app, nightMode);
final FragmentManager fragmentManager = getFragmentManager();
int dp16 = getResources().getDimensionPixelSize(R.dimen.content_padding);
int dp36 = getResources().getDimensionPixelSize(R.dimen.context_menu_controller_height);
buttonClear = createItem(inflater, ItemType.CLEAR_DATA, hasDataToSave());
final View buttonDiscard = createItem(inflater, ItemType.STOP_AND_DISCARD);
final View buttonOnline = createItem(inflater, settings.LIVE_MONITORING.get() ? ItemType.STOP_ONLINE : ItemType.START_ONLINE);
buttonSave = createItem(inflater, ItemType.SAVE, hasDataToSave());
final View buttonSegment = createItem(inflater, ItemType.START_NEW_SEGMENT, wasTrackMonitored());
items.add(new SimpleBottomSheetItem.Builder().setTitle(getString(R.string.shared_string_options)).setTitleColorId(ColorUtilities.getPrimaryTextColorId(nightMode)).setLayoutId(R.layout.bottom_sheet_item_title).create());
items.add(new DividerSpaceItem(app, getResources().getDimensionPixelSize(R.dimen.content_padding_small)));
items.add(new BaseBottomSheetItem.Builder().setCustomView(buttonClear).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (fragmentManager != null && hasDataToSave()) {
TripRecordingClearDataBottomSheet.showInstance(fragmentManager, TripRecordingOptionsBottomSheet.this);
}
}
}).create());
items.add(new DividerSpaceItem(app, dp16));
items.add(new BaseBottomSheetItem.Builder().setCustomView(buttonDiscard).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (fragmentManager != null) {
TripRecordingDiscardBottomSheet.showInstance(fragmentManager, TripRecordingOptionsBottomSheet.this);
}
}
}).create());
items.add(new DividerSpaceItem(app, dp36));
items.add(new BaseBottomSheetItem.Builder().setCustomView(buttonOnline).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
boolean wasOnlineMonitored = !settings.LIVE_MONITORING.get();
settings.LIVE_MONITORING.set(wasOnlineMonitored);
createItem(buttonOnline, wasOnlineMonitored ? ItemType.STOP_ONLINE : ItemType.START_ONLINE);
}
}).create());
items.add(new DividerSpaceItem(app, dp36));
items.add(new BaseBottomSheetItem.Builder().setCustomView(buttonSave).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (hasDataToSave()) {
final GPXFile gpxFile = getGPXFile();
new SaveCurrentTrackTask(app, gpxFile, createSaveListener()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
}
}).create());
items.add(new DividerSpaceItem(app, dp16));
items.add(new BaseBottomSheetItem.Builder().setCustomView(buttonSegment).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (wasTrackMonitored()) {
helper.startNewSegment();
}
}
}).create());
items.add(new DividerSpaceItem(app, getResources().getDimensionPixelSize(R.dimen.content_padding_small)));
}
use of net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerSpaceItem in project Osmand by osmandapp.
the class WakeTimeBottomSheet method createMenuItems.
@Override
public void createMenuItems(Bundle savedInstanceState) {
Context ctx = getContext();
listPreference = getListPreference();
if (ctx == null || listPreference == null) {
return;
}
if (savedInstanceState != null) {
selectedEntryIndex = savedInstanceState.getInt(SELECTED_ENTRY_INDEX_KEY);
keepScreenOnEnabled = savedInstanceState.getBoolean(KEEP_SCREEN_ON_ENABLED);
} else {
int savedValIndex = listPreference.getValueIndex();
keepScreenOnEnabled = savedValIndex <= 0;
selectedEntryIndex = savedValIndex > 0 ? savedValIndex : 1;
}
items.add(new TitleItem(listPreference.getDialogTitle()));
BaseBottomSheetItem preferenceDescription = new BottomSheetItemWithDescription.Builder().setDescription(listPreference.getDescription()).setLayoutId(R.layout.bottom_sheet_item_descr).create();
items.add(preferenceDescription);
final String on = getString(R.string.keep_screen_on);
// also needs to say 'on' the way the dialog is designed.
final String off = getString(R.string.keep_screen_on);
final BottomSheetItemWithCompoundButton[] preferenceBtn = new BottomSheetItemWithCompoundButton[1];
preferenceBtn[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder().setChecked(keepScreenOnEnabled).setTitle(keepScreenOnEnabled ? on : off).setLayoutId(R.layout.bottom_sheet_item_with_switch_no_icon).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
keepScreenOnEnabled = !keepScreenOnEnabled;
preferenceBtn[0].setTitle(keepScreenOnEnabled ? on : off);
preferenceBtn[0].setChecked(keepScreenOnEnabled);
AndroidUiHelper.updateVisibility(sliderView, !keepScreenOnEnabled);
setupHeightAndBackground(getView());
}
}).create();
items.add(preferenceBtn[0]);
DividerItem dividerItem = new DividerItem(ctx);
int topMargin = ctx.getResources().getDimensionPixelSize(R.dimen.context_menu_subtitle_margin);
int startMargin = ctx.getResources().getDimensionPixelSize(R.dimen.content_padding);
dividerItem.setMargins(startMargin, topMargin, 0, 0);
items.add(dividerItem);
items.add(new DividerSpaceItem(ctx, ctx.getResources().getDimensionPixelSize(R.dimen.content_padding_small)));
sliderView = UiUtilities.getInflater(ctx, nightMode).inflate(R.layout.bottom_sheet_item_slider_with_two_text, null);
AndroidUiHelper.updateVisibility(sliderView, !keepScreenOnEnabled);
Context themedCtx = UiUtilities.getThemedContext(ctx, nightMode);
TextView tvSliderTitle = sliderView.findViewById(android.R.id.title);
tvSliderTitle.setText(getString(R.string.wake_time));
final TextView tvSliderSummary = sliderView.findViewById(android.R.id.summary);
tvSliderSummary.setText(listPreference.getEntries()[selectedEntryIndex]);
Slider slider = sliderView.findViewById(R.id.slider);
slider.setValue(selectedEntryIndex);
slider.setStepSize(1);
slider.setValueFrom(1);
slider.setValueTo(listPreference.getEntryValues().length - 1);
slider.addOnChangeListener(new Slider.OnChangeListener() {
@Override
public void onValueChange(@NonNull Slider slider, float value, boolean fromUser) {
if (fromUser) {
selectedEntryIndex = (int) value;
tvSliderSummary.setText(listPreference.getEntries()[selectedEntryIndex]);
}
}
});
int appModeColor = getAppMode().getProfileColor(nightMode);
UiUtilities.setupSlider(slider, nightMode, appModeColor, true);
items.add(new BaseBottomSheetItem.Builder().setCustomView(sliderView).create());
BaseBottomSheetItem timeoutDescription = new BottomSheetItemWithDescription.Builder().setDescription(getString(R.string.screen_timeout_descr, getString(R.string.system_screen_timeout))).setLayoutId(R.layout.bottom_sheet_item_descr).create();
items.add(timeoutDescription);
}
use of net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerSpaceItem in project Osmand by osmandapp.
the class RecalculateRouteInDeviationBottomSheet method createMenuItems.
@Override
public void createMenuItems(Bundle savedInstanceState) {
app = requiredMyApplication();
settings = app.getSettings();
appMode = getAppMode();
preference = settings.ROUTE_RECALCULATION_DISTANCE;
Context themedCtx = UiUtilities.getThemedContext(app, nightMode);
getPreferenceStateAndValue();
final SwitchPreferenceEx switchPref = (SwitchPreferenceEx) getPreference();
if (switchPref == null) {
return;
}
if (savedInstanceState != null && savedInstanceState.containsKey(CURRENT_VALUE)) {
currentValue = savedInstanceState.getFloat(CURRENT_VALUE);
}
int contentPaddingSmall = app.getResources().getDimensionPixelSize(R.dimen.content_padding_small);
int contentPadding = app.getResources().getDimensionPixelSize(R.dimen.content_padding);
MetricsConstants mc = settings.METRIC_SYSTEM.get();
if (mc == MetricsConstants.KILOMETERS_AND_METERS) {
entryValues = new Float[] { 10.f, 20.0f, 30.0f, 50.0f, 100.0f, 200.0f, 500.0f, 1000.0f, 1500.0f };
} else {
entryValues = new Float[] { 9.1f, 18.3f, 30.5f, 45.7f, 91.5f, 183.0f, 482.0f, 965.0f, 1609.0f };
}
final int appModeColor = appMode.getProfileColor(nightMode);
final int activeColor = AndroidUtils.resolveAttribute(themedCtx, R.attr.active_color_basic);
final int disabledColor = AndroidUtils.resolveAttribute(themedCtx, android.R.attr.textColorSecondary);
String title = getString(R.string.recalculate_route_in_deviation);
items.add(new TitleItem(title));
final View sliderView = UiUtilities.getInflater(getContext(), nightMode).inflate(R.layout.bottom_sheet_item_slider_with_two_text, null);
slider = sliderView.findViewById(R.id.slider);
tvSliderTitle = sliderView.findViewById(android.R.id.title);
tvSliderTitle.setText(getString(R.string.distance));
tvSliderSummary = sliderView.findViewById(android.R.id.summary);
slider.setValueFrom(0);
slider.setValueTo(entryValues.length - 1);
slider.setStepSize(1);
updateSliderView();
final String on = getString(R.string.shared_string_enabled);
final String off = getString(R.string.shared_string_disabled);
final BottomSheetItemWithCompoundButton[] preferenceBtn = new BottomSheetItemWithCompoundButton[1];
preferenceBtn[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder().setChecked(enabled).setCompoundButtonColor(appModeColor).setTitle(enabled ? on : off).setTitleColorId(enabled ? activeColor : disabledColor).setCustomView(getCustomButtonView(app, getAppMode(), enabled, nightMode)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
enabled = !enabled;
sliderPositionChanged = false;
switchPref.setChecked(enabled);
preferenceBtn[0].setTitle(enabled ? on : off);
preferenceBtn[0].setTitleColorId(enabled ? activeColor : disabledColor);
preferenceBtn[0].setChecked(enabled);
getDefaultValue();
updateSliderView();
updateCustomButtonView(app, getAppMode(), v, enabled, nightMode);
Fragment target = getTargetFragment();
float newValue = enabled ? DEFAULT_MODE : DISABLE_MODE;
if (target instanceof OnConfirmPreferenceChange) {
((OnConfirmPreferenceChange) target).onConfirmPreferenceChange(switchPref.getKey(), newValue, ApplyQueryType.NONE);
}
}
}).create();
items.add(preferenceBtn[0]);
items.add(new DividerSpaceItem(app, contentPaddingSmall));
items.add(new LongDescriptionItem(getString(R.string.select_distance_route_will_recalc)));
items.add(new DividerSpaceItem(app, contentPadding));
slider.addOnChangeListener(new Slider.OnChangeListener() {
@Override
public void onValueChange(@NonNull Slider slider, float value, boolean fromUser) {
sliderPositionChanged = true;
if (fromUser) {
currentValue = entryValues[(int) slider.getValue()];
tvSliderSummary.setText(getFormattedDistance(app, currentValue));
}
}
});
UiUtilities.setupSlider(slider, nightMode, appModeColor, true);
items.add(new BaseBottomSheetItem.Builder().setCustomView(sliderView).create());
items.add(new SubtitmeListDividerItem(getContext()));
items.add(new DividerSpaceItem(app, contentPaddingSmall));
items.add(new LongDescriptionItem(getString(R.string.recalculate_route_distance_promo)));
}
use of net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerSpaceItem in project Osmand by osmandapp.
the class ElevationDateBottomSheet method createMenuItems.
@Override
public void createMenuItems(Bundle savedInstanceState) {
Context themedCtx = UiUtilities.getThemedContext(requireContext(), nightMode);
on = getString(R.string.shared_string_enabled);
off = getString(R.string.shared_string_disabled);
appModeColor = appMode.getProfileColor(nightMode);
activeColor = AndroidUtils.resolveAttribute(themedCtx, R.attr.active_color_basic);
disabledColor = AndroidUtils.resolveAttribute(themedCtx, android.R.attr.textColorSecondary);
checkedColor = ColorUtilities.getPrimaryTextColor(app, nightMode);
uncheckedColor = ColorUtilities.getSecondaryTextColor(app, nightMode);
items.add(new TitleItem(getString(R.string.routing_attr_height_obstacles_name)));
createUseHeightButton(themedCtx);
int contentPaddingSmall = getResources().getDimensionPixelSize(R.dimen.content_padding_small);
items.add(new DividerSpaceItem(app, contentPaddingSmall));
items.add(new ShortDescriptionItem((getString(R.string.routing_attr_height_obstacles_description))));
createReliefFactorButtons(themedCtx);
}
Aggregations