Search in sources :

Example 1 with LongDescriptionItem

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]);
    }
}
Also used : LongDescriptionItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.LongDescriptionItem) TitleItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem) View(android.view.View) DividerSpaceItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerSpaceItem) DividerItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerItem) BottomSheetItemWithCompoundButton(net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithCompoundButton)

Example 2 with LongDescriptionItem

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();
    });
}
Also used : LongDescriptionItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.LongDescriptionItem)

Example 3 with LongDescriptionItem

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);
}
Also used : LongDescriptionItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.LongDescriptionItem) TextRadioItem(net.osmand.plus.widgets.multistatetoggle.TextToggleButton.TextRadioItem) TitleItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem)

Example 4 with LongDescriptionItem

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;
        });
    });
}
Also used : Bundle(android.os.Bundle) NonNull(androidx.annotation.NonNull) ImageView(android.widget.ImageView) OnlineRoutingHelper(net.osmand.plus.onlinerouting.OnlineRoutingHelper) ProfileDataObject(net.osmand.plus.profiles.data.ProfileDataObject) R(net.osmand.plus.R) NONE_VEHICLE(net.osmand.plus.onlinerouting.engine.OnlineRoutingEngine.NONE_VEHICLE) Drawable(android.graphics.drawable.Drawable) FragmentActivity(androidx.fragment.app.FragmentActivity) EngineParameter(net.osmand.plus.onlinerouting.EngineParameter) ApplicationMode(net.osmand.plus.settings.backend.ApplicationMode) ArrayList(java.util.ArrayList) UiUtilities(net.osmand.plus.utils.UiUtilities) CallbackWithObject(net.osmand.CallbackWithObject) RoutingDataUtils(net.osmand.plus.profiles.data.RoutingDataUtils) Fragment(androidx.fragment.app.Fragment) LongDescriptionItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.LongDescriptionItem) View(android.view.View) OnlineRoutingEngine(net.osmand.plus.onlinerouting.engine.OnlineRoutingEngine) OnlineRoutingEngineFragment(net.osmand.plus.onlinerouting.ui.OnlineRoutingEngineFragment) TextRadioItem(net.osmand.plus.widgets.multistatetoggle.TextToggleButton.TextRadioItem) Build(android.os.Build) Algorithms(net.osmand.util.Algorithms) ContextCompat(androidx.core.content.ContextCompat) ROUTING(net.osmand.plus.importfiles.ImportHelper.ImportType.ROUTING) AndroidUtils(net.osmand.plus.utils.AndroidUtils) FragmentManager(androidx.fragment.app.FragmentManager) ProfilesGroup(net.osmand.plus.profiles.data.ProfilesGroup) CompoundButton(android.widget.CompoundButton) BaseBottomSheetItem(net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem) LayoutInflater(android.view.LayoutInflater) PredefinedProfilesGroup(net.osmand.plus.profiles.data.PredefinedProfilesGroup) EngineType(net.osmand.plus.onlinerouting.engine.EngineType) List(java.util.List) TextView(android.widget.TextView) Nullable(androidx.annotation.Nullable) TitleItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem) Builder(net.osmand.router.RoutingConfiguration.Builder) MapActivity(net.osmand.plus.activities.MapActivity) RoutingDataObject(net.osmand.plus.profiles.data.RoutingDataObject) LongDescriptionItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.LongDescriptionItem) Builder(net.osmand.router.RoutingConfiguration.Builder) MapActivity(net.osmand.plus.activities.MapActivity)

Example 5 with LongDescriptionItem

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);
}
Also used : BaseBottomSheetItem(net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem) SimpleBottomSheetItem(net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem) OsmandApplication(net.osmand.plus.OsmandApplication) Bundle(android.os.Bundle) LongDescriptionItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.LongDescriptionItem) TitleItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem) ApplicationMode(net.osmand.plus.settings.backend.ApplicationMode) View(android.view.View)

Aggregations

LongDescriptionItem (net.osmand.plus.base.bottomsheetmenu.simpleitems.LongDescriptionItem)12 TitleItem (net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem)10 View (android.view.View)8 BaseBottomSheetItem (net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem)4 BottomSheetItemWithCompoundButton (net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithCompoundButton)4 Bundle (android.os.Bundle)3 TextView (android.widget.TextView)3 Fragment (androidx.fragment.app.Fragment)3 OsmandApplication (net.osmand.plus.OsmandApplication)3 Context (android.content.Context)2 LayoutInflater (android.view.LayoutInflater)2 ImageView (android.widget.ImageView)2 SimpleBottomSheetItem (net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem)2 DividerItem (net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerItem)2 DividerSpaceItem (net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerSpaceItem)2 SubtitmeListDividerItem (net.osmand.plus.base.bottomsheetmenu.simpleitems.SubtitmeListDividerItem)2 ApplicationMode (net.osmand.plus.settings.backend.ApplicationMode)2 TextRadioItem (net.osmand.plus.widgets.multistatetoggle.TextToggleButton.TextRadioItem)2 Drawable (android.graphics.drawable.Drawable)1 Build (android.os.Build)1