use of net.osmand.plus.base.bottomsheetmenu.simpleitems.LongDescriptionItem in project Osmand by osmandapp.
the class SelectWikiLanguagesBottomSheet method createMenuItems.
@Override
public void createMenuItems(Bundle savedInstanceState) {
final int activeColorResId = ColorUtilities.getActiveColorId(nightMode);
final int profileColor = appMode.getProfileColor(nightMode);
final int contentPadding = app.getResources().getDimensionPixelSize(R.dimen.content_padding);
final int contentPaddingSmall = app.getResources().getDimensionPixelSize(R.dimen.content_padding_small);
final int contentPaddingHalf = app.getResources().getDimensionPixelSize(R.dimen.content_padding_half);
items.add(new TitleItem(getString(R.string.shared_string_languages)));
items.add(new LongDescriptionItem(getString(R.string.some_articles_may_not_available_in_lang)));
items.add(new DividerSpaceItem(app, contentPadding));
items.add(new LongDescriptionItem(getString(R.string.select_wikipedia_article_langs)));
items.add(new DividerSpaceItem(app, contentPaddingSmall));
final BottomSheetItemWithCompoundButton[] btnSelectAll = new BottomSheetItemWithCompoundButton[1];
btnSelectAll[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder().setChecked(this.isGlobalWikiPoiEnabled).setCompoundButtonColor(profileColor).setTitle(getString(R.string.shared_string_all_languages)).setTitleColorId(activeColorResId).setCustomView(getCustomButtonView()).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
isGlobalWikiPoiEnabled = !isGlobalWikiPoiEnabled;
btnSelectAll[0].setChecked(isGlobalWikiPoiEnabled);
setLanguageListEnable(!isGlobalWikiPoiEnabled);
}
}).create();
items.add(btnSelectAll[0]);
items.add(new DividerSpaceItem(app, contentPaddingHalf));
languageItems = new ArrayList<>();
boolean categoryChanged = false;
for (final WikiLanguageItem language : languages) {
if (!categoryChanged && !language.isTopDefined()) {
categoryChanged = true;
DividerItem divider = new DividerItem(app);
divider.setMargins(contentPadding, 0, 0, 0);
items.add(divider);
}
final BottomSheetItemWithCompoundButton[] languageItem = new BottomSheetItemWithCompoundButton[1];
languageItem[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder().setChecked(language.isChecked()).setTitle(language.getTitle()).setLayoutId(R.layout.bottom_sheet_item_title_with_checkbox).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
boolean newValue = !languageItem[0].isChecked();
languageItem[0].setChecked(newValue);
language.setChecked(newValue);
}
}).create();
languageItems.add(languageItem[0]);
items.add(languageItem[0]);
}
}
use of net.osmand.plus.base.bottomsheetmenu.simpleitems.LongDescriptionItem in project Osmand by osmandapp.
the class SelectNavProfileBottomSheet method createOnlineFooter.
private void createOnlineFooter() {
items.add(new LongDescriptionItem(app.getString(R.string.osmand_online_routing_promo)));
addButtonItem(R.string.add_online_routing_engine, R.drawable.ic_action_plus, v -> {
if (getActivity() != null) {
OnlineRoutingEngineFragment.showInstance(getActivity(), getAppMode(), null);
}
dismiss();
});
}
use of net.osmand.plus.base.bottomsheetmenu.simpleitems.LongDescriptionItem in project Osmand by osmandapp.
the class SelectNavProfileBottomSheet method createHeader.
private void createHeader() {
items.add(new TitleItem(getString(R.string.select_nav_profile_dialog_title)));
items.add(new LongDescriptionItem(getString(R.string.select_nav_profile_dialog_message)));
TextRadioItem offline = createRadioButton(DialogMode.OFFLINE);
TextRadioItem online = createRadioButton(DialogMode.ONLINE);
TextRadioItem selectedItem = dialogMode == DialogMode.ONLINE ? online : offline;
addToggleButton(selectedItem, offline, online);
}
use of net.osmand.plus.base.bottomsheetmenu.simpleitems.LongDescriptionItem in project Osmand by osmandapp.
the class SelectNavProfileBottomSheet method createOfflineFooter.
private void createOfflineFooter() {
items.add(new LongDescriptionItem(app.getString(R.string.osmand_routing_promo)));
addButtonItem(R.string.import_routing_file, R.drawable.ic_action_folder, v -> {
MapActivity mapActivity = getMapActivity();
if (mapActivity == null) {
return;
}
mapActivity.getImportHelper().chooseFileToImport(ROUTING, (CallbackWithObject<Builder>) builder -> {
updateMenuItems();
return false;
});
});
}
use of net.osmand.plus.base.bottomsheetmenu.simpleitems.LongDescriptionItem in project Osmand by osmandapp.
the class ChangeGeneralProfilesPrefBottomSheet method createMenuItems.
@Override
public void createMenuItems(Bundle savedInstanceState) {
final OsmandApplication app = getMyApplication();
Bundle args = getArguments();
if (app == null || args == null) {
return;
}
int cancelTitleRes = args.getInt(CANCEL_TITLE_RES_KEY);
final String prefId = args.getString(PREFERENCE_ID);
newValue = args.getSerializable(NEW_VALUE_KEY);
if (newValue == null || prefId == null) {
return;
}
items.add(new TitleItem(getString(R.string.change_default_settings)));
items.add(new LongDescriptionItem(getString(R.string.apply_preference_to_all_profiles)));
BaseBottomSheetItem applyToAllProfiles = new SimpleBottomSheetItem.Builder().setTitle(getString(R.string.apply_to_all_profiles)).setIcon(getActiveIcon(R.drawable.ic_action_copy)).setLayoutId(R.layout.bottom_sheet_item_simple).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
app.getSettings().setPreferenceForAllModes(prefId, newValue);
updateTargetSettings(false, true);
if (listener != null) {
listener.onApplied(false);
}
dismiss();
}
}).create();
items.add(applyToAllProfiles);
ApplicationMode selectedAppMode = getAppMode();
BaseBottomSheetItem applyToCurrentProfile = new SimpleBottomSheetItem.Builder().setTitle(getString(R.string.apply_to_current_profile, selectedAppMode.toHumanString())).setIcon(getActiveIcon(selectedAppMode.getIconRes())).setLayoutId(R.layout.bottom_sheet_item_simple).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
app.getSettings().setPreference(prefId, newValue, getAppMode());
updateTargetSettings(false, false);
if (listener != null) {
listener.onApplied(true);
}
dismiss();
}
}).create();
items.add(applyToCurrentProfile);
BaseBottomSheetItem discardChanges = new SimpleBottomSheetItem.Builder().setTitle(cancelTitleRes == 0 ? getString(R.string.discard_changes) : getString(cancelTitleRes)).setIcon(getActiveIcon(R.drawable.ic_action_undo_dark)).setLayoutId(R.layout.bottom_sheet_item_simple).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
updateTargetSettings(true, false);
if (listener != null) {
listener.onDiscard();
}
dismiss();
}
}).create();
items.add(discardChanges);
}
Aggregations