Search in sources :

Example 1 with UploadVisibility

use of net.osmand.plus.plugins.osmedit.OsmEditingPlugin.UploadVisibility in project Osmand by osmandapp.

the class SendGpxBottomSheetFragment method createMenuItems.

@Override
public void createMenuItems(Bundle savedInstanceState) {
    OsmandApplication app = requiredMyApplication();
    plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
    LayoutInflater themedInflater = UiUtilities.getInflater(app, nightMode);
    View sendGpxView = themedInflater.inflate(R.layout.send_gpx_fragment, null);
    sendGpxView.getViewTreeObserver().addOnGlobalLayoutListener(getShadowLayoutListener());
    if (selectedUploadVisibility == null) {
        selectedUploadVisibility = plugin.OSM_UPLOAD_VISIBILITY.get();
    }
    tagsField = sendGpxView.findViewById(R.id.tags_field);
    messageField = sendGpxView.findViewById(R.id.message_field);
    TextView accountName = sendGpxView.findViewById(R.id.user_name);
    if (!Algorithms.isEmpty(plugin.OSM_USER_DISPLAY_NAME.get())) {
        accountName.setText(plugin.OSM_USER_DISPLAY_NAME.get());
    } else {
        accountName.setText(plugin.OSM_USER_NAME_OR_EMAIL.get());
    }
    final TextView visibilityName = sendGpxView.findViewById(R.id.visibility_name);
    final TextView visibilityDescription = sendGpxView.findViewById(R.id.visibility_description);
    visibilityName.setText(selectedUploadVisibility.getTitleId());
    visibilityDescription.setText(selectedUploadVisibility.getDescriptionId());
    List<ChipItem> itemsVisibility = new ArrayList<>();
    for (UploadVisibility visibilityType : UploadVisibility.values()) {
        String title = getString(visibilityType.getTitleId());
        ChipItem item = new ChipItem(title);
        item.title = title;
        item.tag = visibilityType;
        itemsVisibility.add(item);
    }
    HorizontalChipsView chipsView = sendGpxView.findViewById(R.id.selector_view);
    chipsView.setItems(itemsVisibility);
    ChipItem selected = chipsView.getChipById(getString(selectedUploadVisibility.getTitleId()));
    chipsView.setSelected(selected);
    chipsView.setOnSelectChipListener(chip -> {
        selectedUploadVisibility = (UploadVisibility) chip.tag;
        plugin.OSM_UPLOAD_VISIBILITY.set(selectedUploadVisibility);
        visibilityName.setText(selectedUploadVisibility.getTitleId());
        visibilityDescription.setText(selectedUploadVisibility.getDescriptionId());
        chipsView.smoothScrollTo(chip);
        return true;
    });
    chipsView.notifyDataSetChanged();
    LinearLayout account = sendGpxView.findViewById(R.id.account_container);
    account.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            FragmentActivity activity = getActivity();
            if (activity != null) {
                showOpenStreetMapScreen(activity);
            }
            dismiss();
        }
    });
    SimpleBottomSheetItem titleItem = (SimpleBottomSheetItem) new SimpleBottomSheetItem.Builder().setCustomView(sendGpxView).create();
    items.add(titleItem);
}
Also used : SimpleBottomSheetItem(net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem) OsmandApplication(net.osmand.plus.OsmandApplication) ArrayList(java.util.ArrayList) UploadVisibility(net.osmand.plus.plugins.osmedit.OsmEditingPlugin.UploadVisibility) View(android.view.View) HorizontalChipsView(net.osmand.plus.widgets.chips.HorizontalChipsView) TextView(android.widget.TextView) OsmEditingPlugin(net.osmand.plus.plugins.osmedit.OsmEditingPlugin) ChipItem(net.osmand.plus.widgets.chips.ChipItem) FragmentActivity(androidx.fragment.app.FragmentActivity) HorizontalChipsView(net.osmand.plus.widgets.chips.HorizontalChipsView) LayoutInflater(android.view.LayoutInflater) TextView(android.widget.TextView) LinearLayout(android.widget.LinearLayout)

Aggregations

LayoutInflater (android.view.LayoutInflater)1 View (android.view.View)1 LinearLayout (android.widget.LinearLayout)1 TextView (android.widget.TextView)1 FragmentActivity (androidx.fragment.app.FragmentActivity)1 ArrayList (java.util.ArrayList)1 OsmandApplication (net.osmand.plus.OsmandApplication)1 SimpleBottomSheetItem (net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem)1 OsmEditingPlugin (net.osmand.plus.plugins.osmedit.OsmEditingPlugin)1 UploadVisibility (net.osmand.plus.plugins.osmedit.OsmEditingPlugin.UploadVisibility)1 ChipItem (net.osmand.plus.widgets.chips.ChipItem)1 HorizontalChipsView (net.osmand.plus.widgets.chips.HorizontalChipsView)1