Search in sources :

Example 1 with AutoCompleteTextViewEx

use of net.osmand.plus.widgets.AutoCompleteTextViewEx in project Osmand by osmandapp.

the class PointEditorFragment method getCategoryTextValue.

public String getCategoryTextValue() {
    AutoCompleteTextViewEx categoryEdit = (AutoCompleteTextViewEx) view.findViewById(R.id.category_edit);
    String name = categoryEdit.getText().toString().trim();
    return name.equals(getDefaultCategoryName()) ? "" : name;
}
Also used : AutoCompleteTextViewEx(net.osmand.plus.widgets.AutoCompleteTextViewEx)

Example 2 with AutoCompleteTextViewEx

use of net.osmand.plus.widgets.AutoCompleteTextViewEx in project Osmand by osmandapp.

the class PointEditorFragment method setCategory.

public void setCategory(String name) {
    AutoCompleteTextViewEx categoryEdit = (AutoCompleteTextViewEx) view.findViewById(R.id.category_edit);
    String n = name.length() == 0 ? getDefaultCategoryName() : name;
    categoryEdit.setText(n);
    ImageView categoryImage = (ImageView) view.findViewById(R.id.category_image);
    categoryImage.setImageDrawable(getCategoryIcon());
    ImageView nameImage = (ImageView) view.findViewById(R.id.name_image);
    nameImage.setImageDrawable(getNameIcon());
}
Also used : AutoCompleteTextViewEx(net.osmand.plus.widgets.AutoCompleteTextViewEx) ImageView(android.widget.ImageView)

Example 3 with AutoCompleteTextViewEx

use of net.osmand.plus.widgets.AutoCompleteTextViewEx in project Osmand by osmandapp.

the class FavoriteAction method drawUI.

@Override
public void drawUI(final ViewGroup parent, final MapActivity activity) {
    FavouritesDbHelper helper = activity.getMyApplication().getFavorites();
    final View root = LayoutInflater.from(parent.getContext()).inflate(R.layout.quick_action_add_favorite, parent, false);
    parent.addView(root);
    AutoCompleteTextViewEx categoryEdit = (AutoCompleteTextViewEx) root.findViewById(R.id.category_edit);
    SwitchCompat showDialog = (SwitchCompat) root.findViewById(R.id.saveButton);
    ImageView categoryImage = (ImageView) root.findViewById(R.id.category_image);
    EditText name = (EditText) root.findViewById(R.id.name_edit);
    if (!getParams().isEmpty()) {
        showDialog.setChecked(Boolean.valueOf(getParams().get(KEY_DIALOG)));
        categoryImage.setColorFilter(Integer.valueOf(getParams().get(KEY_CATEGORY_COLOR)));
        name.setText(getParams().get(KEY_NAME));
        categoryEdit.setText(getParams().get(KEY_CATEGORY_NAME));
        if (getParams().get(KEY_NAME).isEmpty() && Integer.valueOf(getParams().get(KEY_CATEGORY_COLOR)) == 0) {
            categoryEdit.setText(activity.getString(R.string.shared_string_favorites));
            categoryImage.setColorFilter(activity.getResources().getColor(R.color.color_favorite));
        }
    } else if (helper.getFavoriteGroups().size() > 0) {
        FavouritesDbHelper.FavoriteGroup group = helper.getFavoriteGroups().get(0);
        if (group.name.isEmpty() && group.color == 0) {
            group.name = activity.getString(R.string.shared_string_favorites);
            categoryEdit.setText(activity.getString(R.string.shared_string_favorites));
            categoryImage.setColorFilter(activity.getResources().getColor(R.color.color_favorite));
        } else {
            categoryEdit.setText(group.name);
            categoryImage.setColorFilter(group.color);
        }
        getParams().put(KEY_CATEGORY_NAME, group.name);
        getParams().put(KEY_CATEGORY_COLOR, String.valueOf(group.color));
    } else {
        categoryEdit.setText(activity.getString(R.string.shared_string_favorites));
        categoryImage.setColorFilter(activity.getResources().getColor(R.color.color_favorite));
        getParams().put(KEY_CATEGORY_NAME, "");
        getParams().put(KEY_CATEGORY_COLOR, "0");
    }
    categoryEdit.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(final View view) {
            SelectCategoryDialogFragment dialogFragment = SelectCategoryDialogFragment.createInstance("");
            dialogFragment.show(activity.getSupportFragmentManager(), SelectCategoryDialogFragment.TAG);
            dialogFragment.setSelectionListener(new SelectCategoryDialogFragment.CategorySelectionListener() {

                @Override
                public void onCategorySelected(String category, int color) {
                    fillGroupParams(root, category, color);
                }
            });
        }
    });
    SelectCategoryDialogFragment dialogFragment = (SelectCategoryDialogFragment) activity.getSupportFragmentManager().findFragmentByTag(SelectCategoryDialogFragment.TAG);
    if (dialogFragment != null) {
        dialogFragment.setSelectionListener(new SelectCategoryDialogFragment.CategorySelectionListener() {

            @Override
            public void onCategorySelected(String category, int color) {
                fillGroupParams(root, category, color);
            }
        });
    } else {
        EditCategoryDialogFragment dialog = (EditCategoryDialogFragment) activity.getSupportFragmentManager().findFragmentByTag(EditCategoryDialogFragment.TAG);
        if (dialog != null) {
            dialogFragment.setSelectionListener(new SelectCategoryDialogFragment.CategorySelectionListener() {

                @Override
                public void onCategorySelected(String category, int color) {
                    fillGroupParams(root, category, color);
                }
            });
        }
    }
}
Also used : EditText(android.widget.EditText) AutoCompleteTextViewEx(net.osmand.plus.widgets.AutoCompleteTextViewEx) EditCategoryDialogFragment(net.osmand.plus.mapcontextmenu.editors.EditCategoryDialogFragment) FavouritesDbHelper(net.osmand.plus.FavouritesDbHelper) ImageView(android.widget.ImageView) View(android.view.View) SelectCategoryDialogFragment(net.osmand.plus.mapcontextmenu.editors.SelectCategoryDialogFragment) ImageView(android.widget.ImageView) SwitchCompat(android.support.v7.widget.SwitchCompat)

Example 4 with AutoCompleteTextViewEx

use of net.osmand.plus.widgets.AutoCompleteTextViewEx in project Osmand by osmandapp.

the class PointEditorFragment method onCreateView.

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    view = inflater.inflate(R.layout.point_editor_fragment, container, false);
    AndroidUtils.addStatusBarPadding21v(getActivity(), view);
    getEditor().updateLandscapePortrait();
    getEditor().updateNightMode();
    Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar);
    toolbar.setTitle(getToolbarTitle());
    toolbar.setNavigationIcon(getMyApplication().getIconsCache().getIcon(R.drawable.ic_arrow_back));
    toolbar.setNavigationContentDescription(R.string.access_shared_string_navigate_up);
    toolbar.setTitleTextColor(getResources().getColor(getResIdFromAttribute(getMapActivity(), R.attr.pstsTextColor)));
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            dismiss();
        }
    });
    Button saveButton = (Button) view.findViewById(R.id.save_button);
    saveButton.setTextColor(getResources().getColor(!getEditor().isLight() ? R.color.osmand_orange : R.color.map_widget_blue));
    saveButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            savePressed();
        }
    });
    Button cancelButton = (Button) view.findViewById(R.id.cancel_button);
    cancelButton.setTextColor(getResources().getColor(!getEditor().isLight() ? R.color.osmand_orange : R.color.map_widget_blue));
    cancelButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            cancelled = true;
            dismiss();
        }
    });
    Button deleteButton = (Button) view.findViewById(R.id.delete_button);
    deleteButton.setTextColor(getResources().getColor(!getEditor().isLight() ? R.color.osmand_orange : R.color.map_widget_blue));
    deleteButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            deletePressed();
        }
    });
    if (getEditor().isNew()) {
        deleteButton.setVisibility(View.GONE);
    } else {
        deleteButton.setVisibility(View.VISIBLE);
    }
    view.findViewById(R.id.background_layout).setBackgroundResource(!getEditor().isLight() ? R.color.ctx_menu_info_view_bg_dark : R.color.ctx_menu_info_view_bg_light);
    view.findViewById(R.id.buttons_layout).setBackgroundResource(!getEditor().isLight() ? R.color.ctx_menu_info_view_bg_dark : R.color.ctx_menu_info_view_bg_light);
    view.findViewById(R.id.title_view).setBackgroundResource(!getEditor().isLight() ? R.color.bg_color_dark : R.color.bg_color_light);
    view.findViewById(R.id.description_info_view).setBackgroundResource(!getEditor().isLight() ? R.color.ctx_menu_info_view_bg_dark : R.color.ctx_menu_info_view_bg_light);
    TextView nameCaption = (TextView) view.findViewById(R.id.name_caption);
    AndroidUtils.setTextSecondaryColor(view.getContext(), nameCaption, !getEditor().isLight());
    nameCaption.setText(getNameCaption());
    TextView categoryCaption = (TextView) view.findViewById(R.id.category_caption);
    AndroidUtils.setTextSecondaryColor(view.getContext(), categoryCaption, !getEditor().isLight());
    categoryCaption.setText(getCategoryCaption());
    nameEdit = (EditText) view.findViewById(R.id.name_edit);
    AndroidUtils.setTextPrimaryColor(view.getContext(), nameEdit, !getEditor().isLight());
    AndroidUtils.setHintTextSecondaryColor(view.getContext(), nameEdit, !getEditor().isLight());
    nameEdit.setText(getNameInitValue());
    AutoCompleteTextViewEx categoryEdit = (AutoCompleteTextViewEx) view.findViewById(R.id.category_edit);
    AndroidUtils.setTextPrimaryColor(view.getContext(), categoryEdit, !getEditor().isLight());
    categoryEdit.setText(getCategoryInitValue());
    categoryEdit.setFocusable(false);
    categoryEdit.setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(final View v, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_UP) {
                DialogFragment dialogFragment = createSelectCategoryDialog();
                dialogFragment.show(getChildFragmentManager(), SelectCategoryDialogFragment.TAG);
                return true;
            }
            return false;
        }
    });
    final EditText descriptionEdit = (EditText) view.findViewById(R.id.description_edit);
    AndroidUtils.setTextPrimaryColor(view.getContext(), descriptionEdit, !getEditor().isLight());
    AndroidUtils.setHintTextSecondaryColor(view.getContext(), descriptionEdit, !getEditor().isLight());
    if (getDescriptionInitValue() != null) {
        descriptionEdit.setText(getDescriptionInitValue());
    }
    if (Build.VERSION.SDK_INT >= 11) {
        view.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {

            @Override
            public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
                if (descriptionEdit.isFocused()) {
                    ScrollView scrollView = (ScrollView) view.findViewById(R.id.editor_scroll_view);
                    scrollView.scrollTo(0, bottom);
                }
                if (Build.VERSION.SDK_INT >= 21 && AndroidUiHelper.isOrientationPortrait(getActivity())) {
                    Rect rect = new Rect();
                    getActivity().getWindow().getDecorView().getWindowVisibleDisplayFrame(rect);
                    int heightDiff = getResources().getDisplayMetrics().heightPixels - rect.bottom;
                    view.findViewById(R.id.buttons_container).setPadding(0, 0, 0, heightDiff);
                }
            }
        });
    } else {
        ViewTreeObserver vto = view.getViewTreeObserver();
        vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {

            @Override
            public void onGlobalLayout() {
                if (descriptionEdit.isFocused()) {
                    ScrollView scrollView = (ScrollView) view.findViewById(R.id.editor_scroll_view);
                    scrollView.scrollTo(0, view.getBottom());
                }
            }
        });
    }
    ImageView nameImage = (ImageView) view.findViewById(R.id.name_image);
    nameImage.setImageDrawable(getNameIcon());
    ImageView categoryImage = (ImageView) view.findViewById(R.id.category_image);
    categoryImage.setImageDrawable(getCategoryIcon());
    ImageView descriptionImage = (ImageView) view.findViewById(R.id.description_image);
    descriptionImage.setImageDrawable(getRowIcon(R.drawable.ic_action_note_dark));
    if (getMyApplication().accessibilityEnabled()) {
        nameCaption.setFocusable(true);
        categoryCaption.setFocusable(true);
        nameEdit.setHint(R.string.access_hint_enter_name);
        categoryEdit.setHint(R.string.access_hint_enter_category);
        descriptionEdit.setHint(R.string.access_hint_enter_description);
    }
    return view;
}
Also used : EditText(android.widget.EditText) Rect(android.graphics.Rect) AutoCompleteTextViewEx(net.osmand.plus.widgets.AutoCompleteTextViewEx) DialogFragment(android.support.v4.app.DialogFragment) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) ScrollView(android.widget.ScrollView) MotionEvent(android.view.MotionEvent) ScrollView(android.widget.ScrollView) Button(android.widget.Button) TextView(android.widget.TextView) ImageView(android.widget.ImageView) ViewTreeObserver(android.view.ViewTreeObserver) Toolbar(android.support.v7.widget.Toolbar) TargetApi(android.annotation.TargetApi)

Example 5 with AutoCompleteTextViewEx

use of net.osmand.plus.widgets.AutoCompleteTextViewEx in project Osmand by osmandapp.

the class GPXAction method drawUI.

@Override
public void drawUI(final ViewGroup parent, final MapActivity activity) {
    final View root = LayoutInflater.from(parent.getContext()).inflate(R.layout.quick_action_add_gpx, parent, false);
    parent.addView(root);
    AutoCompleteTextViewEx categoryEdit = (AutoCompleteTextViewEx) root.findViewById(R.id.category_edit);
    SwitchCompat showDialog = (SwitchCompat) root.findViewById(R.id.saveButton);
    ImageView categoryImage = (ImageView) root.findViewById(R.id.category_image);
    EditText name = (EditText) root.findViewById(R.id.name_edit);
    if (!getParams().isEmpty()) {
        showDialog.setChecked(Boolean.valueOf(getParams().get(KEY_DIALOG)));
        categoryImage.setColorFilter(Integer.valueOf(getParams().get(KEY_CATEGORY_COLOR)));
        name.setText(getParams().get(KEY_NAME));
        categoryEdit.setText(getParams().get(KEY_CATEGORY_NAME));
        if (getParams().get(KEY_NAME).isEmpty() && Integer.valueOf(getParams().get(KEY_CATEGORY_COLOR)) == 0) {
            categoryEdit.setText("");
            categoryImage.setColorFilter(activity.getResources().getColor(R.color.icon_color));
        }
    } else {
        categoryEdit.setText("");
        categoryImage.setColorFilter(activity.getResources().getColor(R.color.icon_color));
        getParams().put(KEY_CATEGORY_NAME, "");
        getParams().put(KEY_CATEGORY_COLOR, "0");
    }
    categoryEdit.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(final View view) {
            SelectCategoryDialogFragment dialogFragment = SelectCategoryDialogFragment.createInstance("");
            dialogFragment.show(activity.getSupportFragmentManager(), SelectCategoryDialogFragment.TAG);
            dialogFragment.setSelectionListener(new SelectCategoryDialogFragment.CategorySelectionListener() {

                @Override
                public void onCategorySelected(String category, int color) {
                    fillGroupParams(root, category, color);
                }
            });
        }
    });
    SelectCategoryDialogFragment dialogFragment = (SelectCategoryDialogFragment) activity.getSupportFragmentManager().findFragmentByTag(SelectCategoryDialogFragment.TAG);
    if (dialogFragment != null) {
        dialogFragment.setSelectionListener(new SelectCategoryDialogFragment.CategorySelectionListener() {

            @Override
            public void onCategorySelected(String category, int color) {
                fillGroupParams(root, category, color);
            }
        });
    } else {
        EditCategoryDialogFragment dialog = (EditCategoryDialogFragment) activity.getSupportFragmentManager().findFragmentByTag(EditCategoryDialogFragment.TAG);
        if (dialog != null) {
            dialogFragment.setSelectionListener(new SelectCategoryDialogFragment.CategorySelectionListener() {

                @Override
                public void onCategorySelected(String category, int color) {
                    fillGroupParams(root, category, color);
                }
            });
        }
    }
}
Also used : EditText(android.widget.EditText) AutoCompleteTextViewEx(net.osmand.plus.widgets.AutoCompleteTextViewEx) EditCategoryDialogFragment(net.osmand.plus.mapcontextmenu.editors.EditCategoryDialogFragment) ImageView(android.widget.ImageView) View(android.view.View) SelectCategoryDialogFragment(net.osmand.plus.mapcontextmenu.editors.SelectCategoryDialogFragment) ImageView(android.widget.ImageView) SwitchCompat(android.support.v7.widget.SwitchCompat)

Aggregations

AutoCompleteTextViewEx (net.osmand.plus.widgets.AutoCompleteTextViewEx)5 ImageView (android.widget.ImageView)4 View (android.view.View)3 EditText (android.widget.EditText)3 SwitchCompat (android.support.v7.widget.SwitchCompat)2 EditCategoryDialogFragment (net.osmand.plus.mapcontextmenu.editors.EditCategoryDialogFragment)2 SelectCategoryDialogFragment (net.osmand.plus.mapcontextmenu.editors.SelectCategoryDialogFragment)2 TargetApi (android.annotation.TargetApi)1 Rect (android.graphics.Rect)1 DialogFragment (android.support.v4.app.DialogFragment)1 Toolbar (android.support.v7.widget.Toolbar)1 MotionEvent (android.view.MotionEvent)1 ViewTreeObserver (android.view.ViewTreeObserver)1 Button (android.widget.Button)1 ScrollView (android.widget.ScrollView)1 TextView (android.widget.TextView)1 FavouritesDbHelper (net.osmand.plus.FavouritesDbHelper)1