use of net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerSpaceItem in project Osmand by osmandapp.
the class VoiceLanguageBottomSheetFragment method createMenuItems.
@Override
public void createMenuItems(Bundle savedInstanceState) {
Context context = requireContext();
int padding = getDimen(R.dimen.content_padding_small);
LayoutInflater inflater = UiUtilities.getInflater(app, nightMode);
BaseBottomSheetItem titleItem = new BaseBottomSheetItem.Builder().setCustomView(createTitleAndDescription(inflater)).create();
items.add(titleItem);
items.add(new DividerSpaceItem(context, padding));
LinearLayout voiceTypeButtons = (LinearLayout) inflater.inflate(R.layout.custom_radio_buttons, null);
LinearLayout.MarginLayoutParams itemTimeOfDayParams = new LinearLayout.MarginLayoutParams(LinearLayout.MarginLayoutParams.MATCH_PARENT, LinearLayout.MarginLayoutParams.WRAP_CONTENT);
AndroidUtils.setMargins(itemTimeOfDayParams, padding, 0, padding, 0);
voiceTypeButtons.setLayoutParams(itemTimeOfDayParams);
setupTypeRadioGroup(voiceTypeButtons);
items.add(new BaseBottomSheetItem.Builder().setCustomView(voiceTypeButtons).create());
items.add(new DividerSpaceItem(context, padding));
BaseBottomSheetItem selectedVoiceProviderDescription = new BottomSheetItemWithDescription.Builder().setCustomView(createVoiceProviderDescription(inflater, selectedVoiceType.descriptionRes)).create();
items.add(selectedVoiceProviderDescription);
items.add(createDividerItem());
createVoiceView();
}
use of net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerSpaceItem in project Osmand by osmandapp.
the class LocationSourceBottomSheet method createMenuItems.
@Override
public void createMenuItems(Bundle savedInstanceState) {
createHeaderItem();
items.add(new DividerSpaceItem(app, AndroidUtils.dpToPx(app, 12)));
createSourceItems();
}
use of net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerSpaceItem in project Osmand by osmandapp.
the class LiveUpdatesSettingsBottomSheet method createMenuItems.
@Override
public void createMenuItems(Bundle savedInstanceState) {
app = requiredMyApplication();
settings = app.getSettings();
LayoutInflater inflater = UiUtilities.getInflater(app, nightMode);
if (getTargetFragment() instanceof OnLiveUpdatesForLocalChange) {
onLiveUpdatesForLocalChange = (OnLiveUpdatesForLocalChange) getTargetFragment();
}
if (savedInstanceState != null && savedInstanceState.containsKey(LOCAL_INDEX_FILE_NAME)) {
fileName = savedInstanceState.getString(LOCAL_INDEX_FILE_NAME);
}
CommonPreference<Boolean> localUpdatePreference = preferenceForLocalIndex(fileName, settings);
CommonPreference<Boolean> downloadViaWiFiPreference = preferenceDownloadViaWiFi(fileName, settings);
CommonPreference<Integer> frequencyPreference = preferenceUpdateFrequency(fileName, settings);
CommonPreference<Integer> timeOfDayPreference = preferenceTimeOfDayToUpdate(fileName, settings);
int dp6 = getDimen(R.dimen.content_padding_small_half);
int dp8 = getDimen(R.dimen.content_padding_half);
int dp12 = getDimen(R.dimen.content_padding_small);
int dp16 = getDimen(R.dimen.content_padding);
int dp24 = getDimen(R.dimen.dialog_content_margin);
int dp36 = getDimen(R.dimen.dialog_button_height);
itemTitle = new SimpleBottomSheetItem.Builder().setTitle(getNameToDisplay(fileName, app)).setTitleColorId(ColorUtilities.getPrimaryTextColorId(nightMode)).setLayoutId(R.layout.bottom_sheet_item_title_big).create();
items.add(itemTitle);
itemLastCheck = new ShortDescriptionItem.Builder().setDescription(getLastCheckString()).setDescriptionColorId(ColorUtilities.getSecondaryTextColorId(nightMode)).setDescriptionMaxLines(2).setLayoutId(R.layout.bottom_sheet_item_description).create();
items.add(itemLastCheck);
View itemLiveUpdate = getCustomButtonView(app, null, localUpdatePreference.get(), nightMode);
View itemLiveUpdateButton = itemLiveUpdate.findViewById(R.id.button_container);
CompoundButton button = (CompoundButton) itemLiveUpdateButton.findViewById(R.id.compound_button);
UiUtilities.setupCompoundButton(button, nightMode, TOOLBAR);
itemLiveUpdateButton.setMinimumHeight(getDimen(R.dimen.bottom_sheet_selected_item_title_height));
itemSwitchLiveUpdate = new BottomSheetItemWithCompoundButton.Builder().setChecked(localUpdatePreference.get()).setTitle(getStateText(localUpdatePreference.get())).setTitleColorId(ColorUtilities.getActiveTabTextColorId(nightMode)).setCustomView(itemLiveUpdate).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
BottomSheetItemWithCompoundButton item = (BottomSheetItemWithCompoundButton) itemSwitchLiveUpdate;
boolean checked = item.isChecked();
item.setChecked(!checked);
if (onLiveUpdatesForLocalChange != null && onLiveUpdatesForLocalChange.onUpdateLocalIndex(fileName, !checked, new Runnable() {
@Override
public void run() {
updateLastCheck();
updateFrequencyHelpMessage();
updateFileSize();
Fragment target = getTargetFragment();
if (target instanceof LiveUpdatesFragment) {
((LiveUpdatesFragment) target).runSort();
}
}
})) {
item.setTitle(getStateText(!checked));
updateCustomButtonView(app, null, item.getView(), !checked, nightMode);
CommonPreference<Boolean> localUpdatePreference = preferenceForLocalIndex(fileName, settings);
frequencyToggleButton.setItemsEnabled(localUpdatePreference.get());
timeOfDayToggleButton.setItemsEnabled(localUpdatePreference.get());
setStateViaWiFiButton(localUpdatePreference);
}
}
}).create();
items.add(itemSwitchLiveUpdate);
Typeface typefaceRegular = FontCache.getRobotoRegular(app);
TextViewEx frequencyTitle = (TextViewEx) inflater.inflate(R.layout.bottom_sheet_item_title, null);
frequencyTitle.setMinHeight(dp24);
frequencyTitle.setMinimumHeight(dp24);
frequencyTitle.setText(R.string.update_frequency);
frequencyTitle.setTypeface(typefaceRegular);
AndroidUtils.setPadding(frequencyTitle, dp16, dp12, dp16, dp12);
AndroidUtils.setTextPrimaryColor(app, frequencyTitle, nightMode);
items.add(new BaseBottomSheetItem.Builder().setCustomView(frequencyTitle).create());
LinearLayout itemFrequencyButtons = (LinearLayout) inflater.inflate(R.layout.custom_radio_buttons, null);
LinearLayout.MarginLayoutParams itemFrequencyParams = new LinearLayout.MarginLayoutParams(LinearLayout.MarginLayoutParams.MATCH_PARENT, LinearLayout.MarginLayoutParams.WRAP_CONTENT);
AndroidUtils.setMargins(itemFrequencyParams, dp16, 0, dp16, 0);
itemFrequencyButtons.setLayoutParams(itemFrequencyParams);
String hourly = getString(R.string.hourly);
String daily = getString(R.string.daily);
String weekly = getString(R.string.weekly);
TextRadioItem hourlyButton = new TextRadioItem(hourly);
TextRadioItem dailyButton = new TextRadioItem(daily);
TextRadioItem weeklyButton = new TextRadioItem(weekly);
frequencyToggleButton = new TextToggleButton(app, itemFrequencyButtons, nightMode);
frequencyToggleButton.setItems(hourlyButton, dailyButton, weeklyButton);
setSelectedRadioItem(frequencyToggleButton, frequencyPreference.get(), hourlyButton, dailyButton, weeklyButton);
frequencyToggleButton.setItemsEnabled(localUpdatePreference.get());
items.add(new BaseBottomSheetItem.Builder().setCustomView(itemFrequencyButtons).create());
TextViewEx timeOfDayTitle = (TextViewEx) inflater.inflate(R.layout.bottom_sheet_item_title, null);
timeOfDayTitle.setMinHeight(dp24);
timeOfDayTitle.setMinimumHeight(dp24);
timeOfDayTitle.setText(R.string.update_time);
timeOfDayTitle.setTypeface(typefaceRegular);
AndroidUtils.setPadding(timeOfDayTitle, dp16, dp16, dp16, dp6);
AndroidUtils.setTextPrimaryColor(app, timeOfDayTitle, nightMode);
items.add(new BaseBottomSheetItem.Builder().setCustomView(timeOfDayTitle).create());
LinearLayout itemTimeOfDayButtons = (LinearLayout) inflater.inflate(R.layout.custom_radio_buttons, null);
LinearLayout.MarginLayoutParams itemTimeOfDayParams = new LinearLayout.MarginLayoutParams(LinearLayout.MarginLayoutParams.MATCH_PARENT, LinearLayout.MarginLayoutParams.WRAP_CONTENT);
AndroidUtils.setMargins(itemTimeOfDayParams, dp16, 0, dp16, 0);
itemTimeOfDayButtons.setLayoutParams(itemTimeOfDayParams);
String morning = getString(R.string.morning);
String night = getString(R.string.night);
TextRadioItem morningButton = new TextRadioItem(morning);
TextRadioItem nightButton = new TextRadioItem(night);
timeOfDayToggleButton = new TextToggleButton(app, itemTimeOfDayButtons, nightMode);
timeOfDayToggleButton.setItems(morningButton, nightButton);
setSelectedRadioItem(timeOfDayToggleButton, timeOfDayPreference.get(), morningButton, nightButton);
timeOfDayToggleButton.setItemsEnabled(localUpdatePreference.get());
refreshTimeOfDayLayout(frequencyPreference.get(), itemTimeOfDayButtons, timeOfDayTitle);
morningButton.setOnClickListener(getTimeOfDayButtonListener(TimeOfDay.MORNING));
nightButton.setOnClickListener(getTimeOfDayButtonListener(TimeOfDay.NIGHT));
items.add(new BaseBottomSheetItem.Builder().setCustomView(itemTimeOfDayButtons).create());
hourlyButton.setOnClickListener(getFrequencyButtonListener(UpdateFrequency.HOURLY, itemTimeOfDayButtons, timeOfDayTitle));
dailyButton.setOnClickListener(getFrequencyButtonListener(UpdateFrequency.DAILY, itemTimeOfDayButtons, timeOfDayTitle));
weeklyButton.setOnClickListener(getFrequencyButtonListener(UpdateFrequency.WEEKLY, itemTimeOfDayButtons, timeOfDayTitle));
itemFrequencyHelpMessage = new ShortDescriptionItem.Builder().setDescription(getFrequencyHelpMessage()).setDescriptionColorId(ColorUtilities.getSecondaryTextColorId(nightMode)).setLayoutId(R.layout.bottom_sheet_item_description).create();
items.add(itemFrequencyHelpMessage);
LinearLayout itemUpdateNowButton = (LinearLayout) inflater.inflate(R.layout.bottom_sheet_button_with_icon_center, null);
LinearLayout.MarginLayoutParams itemUpdateNowParams = new LinearLayout.MarginLayoutParams(LinearLayout.MarginLayoutParams.MATCH_PARENT, dp36);
AndroidUtils.setMargins(itemUpdateNowParams, dp12, dp16, dp16, dp12);
itemUpdateNowButton.setLayoutParams(itemUpdateNowParams);
((AppCompatImageView) itemUpdateNowButton.findViewById(R.id.button_icon)).setImageDrawable(AppCompatResources.getDrawable(app, R.drawable.ic_action_update));
UiUtilities.setupDialogButton(nightMode, itemUpdateNowButton, UiUtilities.DialogButtonType.SECONDARY, getString(R.string.update_now));
itemUpdateNowButton.setMinimumHeight(AndroidUtils.dpToPx(app, dp36));
items.add(new BaseBottomSheetItem.Builder().setCustomView(itemUpdateNowButton).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!settings.isInternetConnectionAvailable()) {
app.showShortToastMessage(R.string.no_internet_connection);
} else {
if (onLiveUpdatesForLocalChange != null) {
Runnable runnable = () -> {
if (isAdded()) {
updateLastCheck();
updateFrequencyHelpMessage();
updateFileSize();
Fragment target = getTargetFragment();
if (target instanceof LiveUpdatesFragment) {
((LiveUpdatesFragment) target).updateList();
}
}
};
onLiveUpdatesForLocalChange.forceUpdateLocal(fileName, true, runnable);
}
}
}
}).create());
items.add(createDividerItem());
int iconDeleteColor = ContextCompat.getColor(app, R.color.color_osm_edit_delete);
Drawable iconDelete = AppCompatResources.getDrawable(app, R.drawable.ic_action_delete_dark);
itemClear = new BottomSheetItemWithDescription.Builder().setDescription(getUpdatesSizeStr()).setIcon(UiUtilities.tintDrawable(iconDelete, iconDeleteColor)).setTitle(getString(R.string.updates_size)).setLayoutId(R.layout.bottom_sheet_item_with_descr_icon_right).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (getUpdatesSize() > 0) {
if (getFragmentManager() != null) {
LiveUpdatesClearBottomSheet.showInstance(getFragmentManager(), LiveUpdatesSettingsBottomSheet.this, fileName);
}
}
}
}).create();
items.add(itemClear);
items.add(createDividerItem());
itemViaWiFi = new BottomSheetItemWithCompoundButton.Builder().setChecked(downloadViaWiFiPreference.get()).setDescription(getStateText(downloadViaWiFiPreference.get())).setIconHidden(true).setTitle(getString(R.string.only_download_over_wifi)).setLayoutId(R.layout.bottom_sheet_item_with_descr_and_switch_56dp).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (preferenceForLocalIndex(fileName, settings).get()) {
BottomSheetItemWithCompoundButton item = (BottomSheetItemWithCompoundButton) itemViaWiFi;
boolean checked = item.isChecked();
item.setChecked(!checked);
item.setDescription(getStateText(!checked));
preferenceDownloadViaWiFi(fileName, settings).set(!checked);
}
}
}).create();
items.add(itemViaWiFi);
items.add(new DividerSpaceItem(app, getDimen(R.dimen.context_menu_padding_margin_large)));
}
use of net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerSpaceItem in project Osmand by osmandapp.
the class AddNewTrackFolderBottomSheet method createMenuItems.
@Override
public void createMenuItems(Bundle savedInstanceState) {
app = requiredMyApplication();
if (savedInstanceState != null) {
folderName = savedInstanceState.getString(FOLDER_NAME_KEY);
}
items.add(new TitleItem(getString(R.string.add_new_folder)));
View view = UiUtilities.getInflater(app, nightMode).inflate(R.layout.track_name_edit_text, null);
nameTextBox = view.findViewById(R.id.name_text_box);
int textBoxBgColorId = nightMode ? R.color.color_white : R.color.activity_background_color_light;
int textBoxBgColor = ContextCompat.getColor(app, textBoxBgColorId);
if (nightMode) {
textBoxBgColor = ColorUtilities.getColorWithAlpha(textBoxBgColor, 0.1f);
}
nameTextBox.setBoxBackgroundColor(textBoxBgColor);
nameTextBox.setHint(AndroidUtils.addColon(app, R.string.shared_string_name));
ColorStateList colorStateList = ColorStateList.valueOf(ColorUtilities.getSecondaryTextColor(app, nightMode));
nameTextBox.setDefaultHintTextColor(colorStateList);
editText = view.findViewById(R.id.name_edit_text);
editText.setText(folderName);
editText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
updateFileNameFromEditText(s.toString());
}
});
BaseBottomSheetItem editFolderName = new BaseBottomSheetItem.Builder().setCustomView(view).create();
items.add(editFolderName);
items.add(new DividerSpaceItem(app, AndroidUtils.dpToPx(app, 12)));
}
use of net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerSpaceItem in project Osmand by osmandapp.
the class LiveUpdatesClearBottomSheet method createMenuItems.
@Override
public void createMenuItems(Bundle savedInstanceState) {
app = getMyApplication();
settings = app.getSettings();
if (savedInstanceState != null && savedInstanceState.containsKey(LOCAL_INDEX_FILE_NAME)) {
fileName = savedInstanceState.getString(LOCAL_INDEX_FILE_NAME);
}
items.add(new SimpleBottomSheetItem.Builder().setTitle(getString(R.string.delete_updates)).setTitleColorId(ColorUtilities.getPrimaryTextColorId(nightMode)).setLayoutId(R.layout.bottom_sheet_item_title).create());
String nameToDisplay = getNameToDisplay(fileName, app);
String text = getString(R.string.live_update_delete_updates_msg, nameToDisplay);
SpannableString message = UiUtilities.createSpannableString(text, Typeface.BOLD, nameToDisplay);
items.add(new LongDescriptionItem.Builder().setDescription(message).setDescriptionColorId(ColorUtilities.getSecondaryTextColorId(nightMode)).setDescriptionMaxLines(5).setLayoutId(R.layout.bottom_sheet_item_description_long).create());
items.add(new DividerSpaceItem(app, getResources().getDimensionPixelSize(R.dimen.content_padding_small)));
}
Aggregations