Search in sources :

Example 6 with LongDescriptionItem

use of net.osmand.plus.base.bottomsheetmenu.simpleitems.LongDescriptionItem in project Osmand by osmandapp.

the class SendAnalyticsBottomSheetDialogFragment method createMenuItems.

@Override
public void createMenuItems(Bundle savedInstanceState) {
    OsmandApplication app = getMyApplication();
    Context context = getContext();
    if (context == null || app == null) {
        return;
    }
    final View titleView = View.inflate(new ContextThemeWrapper(context, themeRes), R.layout.make_better_title, null);
    final SimpleBottomSheetItem titleItem = (SimpleBottomSheetItem) new SimpleBottomSheetItem.Builder().setCustomView(titleView).create();
    items.add(titleItem);
    items.add(new SubtitleDividerItem(context));
    if (app.getSettings().SEND_ANONYMOUS_MAP_DOWNLOADS_DATA.isSet()) {
        sendAnonymousMapDownloadsData = app.getSettings().SEND_ANONYMOUS_MAP_DOWNLOADS_DATA.get();
    } else {
        sendAnonymousMapDownloadsData = true;
    }
    if (app.getSettings().SEND_ANONYMOUS_APP_USAGE_DATA.isSet()) {
        sendAnonymousAppUsageData = app.getSettings().SEND_ANONYMOUS_APP_USAGE_DATA.get();
    } else {
        sendAnonymousAppUsageData = true;
    }
    final BottomSheetItemWithCompoundButton[] downloadedMapsItem = new BottomSheetItemWithCompoundButton[1];
    downloadedMapsItem[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder().setChecked(sendAnonymousMapDownloadsData).setTitle(getString(R.string.downloaded_maps)).setLayoutId(R.layout.bottom_sheet_item_with_switch_no_icon).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean checked = !downloadedMapsItem[0].isChecked();
            downloadedMapsItem[0].setChecked(checked);
            sendAnonymousMapDownloadsData = checked;
            updateBottomButtons();
        }
    }).setTag("downloaded_maps").create();
    items.add(downloadedMapsItem[0]);
    items.add(new LongDescriptionItem(getString(R.string.downloaded_maps_collect_descr)));
    items.add(new SubtitmeListDividerItem(context));
    final BottomSheetItemWithCompoundButton[] visitedScreensItem = new BottomSheetItemWithCompoundButton[1];
    visitedScreensItem[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder().setChecked(sendAnonymousAppUsageData).setTitle(getString(R.string.visited_screens)).setLayoutId(R.layout.bottom_sheet_item_with_switch_no_icon).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean checked = !visitedScreensItem[0].isChecked();
            visitedScreensItem[0].setChecked(checked);
            sendAnonymousAppUsageData = checked;
            updateBottomButtons();
        }
    }).setTag("visited_screens").create();
    items.add(visitedScreensItem[0]);
    items.add(new LongDescriptionItem(getString(R.string.visited_screens_collect_descr)));
    items.add(new DividerItem(context));
    String privacyPolicyText = getString(R.string.shared_string_privacy_policy);
    String text = getString(R.string.privacy_and_security_change_descr, privacyPolicyText);
    SpannableString spannable = new SpannableString(text);
    int start = text.indexOf(privacyPolicyText);
    int end = start + privacyPolicyText.length();
    spannable.setSpan(new URLSpan(OsmandApplication.OSMAND_PRIVACY_POLICY_URL) {

        @Override
        public void updateDrawState(@NonNull TextPaint ds) {
            super.updateDrawState(ds);
            ds.setUnderlineText(false);
        }
    }, start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    int linkTextColor = ContextCompat.getColor(context, !nightMode ? R.color.ctx_menu_bottom_view_url_color_light : R.color.ctx_menu_bottom_view_url_color_dark);
    spannable.setSpan(new ForegroundColorSpan(linkTextColor), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    LongDescriptionItem descriptionItem = new LongDescriptionItem(spannable);
    descriptionItem.setDescriptionLinksClickable(true);
    items.add(descriptionItem);
}
Also used : Context(android.content.Context) SimpleBottomSheetItem(net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem) OsmandApplication(net.osmand.plus.OsmandApplication) ForegroundColorSpan(android.text.style.ForegroundColorSpan) LongDescriptionItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.LongDescriptionItem) SpannableString(android.text.SpannableString) URLSpan(android.text.style.URLSpan) View(android.view.View) TextPaint(android.text.TextPaint) SubtitleDividerItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.SubtitleDividerItem) TextPaint(android.text.TextPaint) SpannableString(android.text.SpannableString) ContextThemeWrapper(android.view.ContextThemeWrapper) SubtitmeListDividerItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.SubtitmeListDividerItem) SubtitmeListDividerItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.SubtitmeListDividerItem) SubtitleDividerItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.SubtitleDividerItem) DividerItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerItem) BottomSheetItemWithCompoundButton(net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithCompoundButton)

Example 7 with LongDescriptionItem

use of net.osmand.plus.base.bottomsheetmenu.simpleitems.LongDescriptionItem in project Osmand by osmandapp.

the class SpeedCamerasUninstallRestartBottomSheet method createMenuItems.

@Override
public void createMenuItems(Bundle savedInstanceState) {
    items.add(new TitleItem(getString(R.string.uninstall_speed_cameras)));
    items.add(new LongDescriptionItem(getString(R.string.speed_cameras_restart_descr)));
}
Also used : LongDescriptionItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.LongDescriptionItem) TitleItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem)

Example 8 with LongDescriptionItem

use of net.osmand.plus.base.bottomsheetmenu.simpleitems.LongDescriptionItem in project Osmand by osmandapp.

the class AllocatedRoutingMemoryBottomSheet method createMenuItems.

@Override
public void createMenuItems(Bundle savedInstanceState) {
    LayoutInflater inflater = UiUtilities.getInflater(getContext(), nightMode);
    String title = getString(R.string.memory_allocated_for_routing);
    items.add(new TitleItem(title));
    String description = getString(R.string.memory_allocated_for_routing_ds);
    items.add(new LongDescriptionItem(description));
    View view = inflater.inflate(R.layout.bottom_sheet_allocated_routing_memory, null);
    items.add(new BaseBottomSheetItem.Builder().setCustomView(view).create());
    sliderContainer = view.findViewById(R.id.slider_container);
    setupSliderView(sliderContainer);
    View buttonView = view.findViewById(R.id.button_container);
    setupResetButton(buttonView);
}
Also used : BaseBottomSheetItem(net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem) LayoutInflater(android.view.LayoutInflater) LongDescriptionItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.LongDescriptionItem) TitleItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView)

Example 9 with LongDescriptionItem

use of net.osmand.plus.base.bottomsheetmenu.simpleitems.LongDescriptionItem in project Osmand by osmandapp.

the class SelectBaseProfileBottomSheet method createMenuItems.

@Override
public void createMenuItems(Bundle savedInstanceState) {
    items.add(new TitleItem(getString(R.string.select_base_profile_dialog_title)));
    items.add(new LongDescriptionItem(getString(R.string.select_base_profile_dialog_message)));
    for (int i = 0; i < profiles.size(); i++) {
        addProfileItem(profiles.get(i));
    }
}
Also used : LongDescriptionItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.LongDescriptionItem) TitleItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem)

Example 10 with LongDescriptionItem

use of net.osmand.plus.base.bottomsheetmenu.simpleitems.LongDescriptionItem in project Osmand by osmandapp.

the class SelectDefaultProfileBottomSheet method createMenuItems.

@Override
public void createMenuItems(@Nullable Bundle savedInstanceState) {
    items.add(new TitleItem(getString(R.string.settings_preset)));
    items.add(new LongDescriptionItem(getString(R.string.profile_by_default_description)));
    boolean useLastAppModeByDefault = app.getSettings().USE_LAST_APPLICATION_MODE_BY_DEFAULT.get();
    addCheckableItem(R.string.shared_string_last_used, useLastAppModeByDefault, new OnClickListener() {

        @Override
        public void onClick(View v) {
            Bundle args = new Bundle();
            args.putBoolean(USE_LAST_PROFILE_ARG, true);
            Fragment target = getTargetFragment();
            if (target instanceof OnSelectProfileCallback) {
                ((OnSelectProfileCallback) target).onProfileSelected(args);
            }
            dismiss();
        }
    });
    items.add(new SimpleDividerItem(app));
    for (int i = 0; i < profiles.size(); i++) {
        addProfileItem(profiles.get(i));
    }
}
Also used : SimpleDividerItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.SimpleDividerItem) Bundle(android.os.Bundle) LongDescriptionItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.LongDescriptionItem) OnClickListener(android.view.View.OnClickListener) TitleItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem) View(android.view.View) Fragment(androidx.fragment.app.Fragment)

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