Search in sources :

Example 1 with DrawingCanvasView

use of com.waz.zclient.ui.sketch.DrawingCanvasView in project wire-android by wireapp.

the class DrawingFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_drawing, container, false);
    drawingCanvasView = ViewUtils.getView(rootView, R.id.dcv__canvas);
    drawingCanvasView.setDrawingCanvasCallback(this);
    drawingCanvasView.setDrawingColor(getControllerFactory().getAccentColorController().getColor());
    drawingCanvasView.setOnTouchListener(drawingCanvasViewOnTouchListener);
    colorPickerScrollContainer = ViewUtils.getView(rootView, R.id.hsv_color_picker_scroll_view);
    colorLayout = ViewUtils.getView(rootView, R.id.cpdl__color_layout);
    colorLayout.setOnColorSelectedListener(this);
    int[] colors = getResources().getIntArray(R.array.draw_color);
    colorLayout.setAccentColors(colors, getControllerFactory().getAccentColorController().getColor());
    colorLayout.getViewTreeObserver().addOnScrollChangedListener(this);
    // TODO uncomment once AN-4649 is fixed
    //        colorPickerScrollBar = ViewUtils.getView(rootView, R.id.cpsb__color_picker_scrollbar);
    //        colorPickerScrollBar.setScrollBarColor(getControllerFactory().getAccentColorController().getColor());
    TypefaceTextView conversationTitle = ViewUtils.getView(rootView, R.id.tv__drawing_toolbar__title);
    conversationTitle.setText(getStoreFactory().getConversationStore().getCurrentConversation().getName().toUpperCase(Locale.getDefault()));
    toolbar = ViewUtils.getView(rootView, R.id.t_drawing_toolbar);
    toolbar.inflateMenu(R.menu.toolbar_sketch);
    toolbar.setOnMenuItemClickListener(toolbarOnMenuItemClickListener);
    toolbar.setNavigationOnClickListener(toolbarNavigationClickListener);
    toolbar.setNavigationIcon(R.drawable.toolbar_action_undo_disabled);
    actionButtonText = ViewUtils.getView(rootView, R.id.gtv__drawing_button__text);
    actionButtonText.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            onTextClick();
        }
    });
    actionButtonEmoji = ViewUtils.getView(rootView, R.id.gtv__drawing_button__emoji);
    actionButtonEmoji.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            onEmojiClick();
        }
    });
    actionButtonSketch = ViewUtils.getView(rootView, R.id.gtv__drawing_button__sketch);
    actionButtonSketch.setTextColor(getControllerFactory().getAccentColorController().getColor());
    actionButtonSketch.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            onSketchClick();
        }
    });
    galleryButton = ViewUtils.getView(rootView, R.id.gtv__drawing__gallery_button);
    galleryButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            if (PermissionUtils.hasSelfPermissions(getContext(), SKETCH_FROM_GALLERY_PERMISSION)) {
                sketchEditTextView.destroyDrawingCache();
                assetIntentsManager.openGalleryForSketch();
            } else {
                ActivityCompat.requestPermissions(getActivity(), SKETCH_FROM_GALLERY_PERMISSION, OPEN_SKETCH_FROM_GALLERY);
            }
        }
    });
    drawingTipBackground = ViewUtils.getView(rootView, R.id.v__tip_background);
    drawingViewTip = ViewUtils.getView(rootView, R.id.ttv__drawing__view__tip);
    drawingTipBackground.setVisibility(View.INVISIBLE);
    sendDrawingButton = ViewUtils.getView(rootView, R.id.tv__send_button);
    sendDrawingButton.setOnClickListener(sketchButtonsOnClickListener);
    sendDrawingButton.setClickable(false);
    sketchEditTextView = ViewUtils.getView(rootView, R.id.et__sketch_text);
    sketchEditTextView.setAlpha(TEXT_ALPHA_INVISIBLE);
    sketchEditTextView.setVisibility(View.INVISIBLE);
    sketchEditTextView.setCustomHint(getString(R.string.drawing__text_hint));
    currentBackgroundColor = getControllerFactory().getAccentColorController().getColor();
    sketchEditTextView.setBackground(ColorUtils.getTransparentDrawable());
    sketchEditTextView.setHintFontId(R.string.wire__typeface__medium);
    sketchEditTextView.setTextFontId(R.string.wire__typeface__regular);
    sketchEditTextView.setSketchScale(1.0f);
    sketchEditTextView.setOnTouchListener(sketchEditTextOnTouchListener);
    if (savedInstanceState != null) {
        Bitmap savedBitmap = savedInstanceState.getParcelable(SAVED_INSTANCE_BITMAP);
        if (savedBitmap != null) {
            // Use saved background image if exists
            drawingCanvasView.setBackgroundBitmap(savedBitmap);
        } else {
            setBackgroundBitmap(true);
        }
    } else {
        setBackgroundBitmap(true);
    }
    return rootView;
}
Also used : Bitmap(android.graphics.Bitmap) TypefaceTextView(com.waz.zclient.ui.text.TypefaceTextView) HorizontalScrollView(android.widget.HorizontalScrollView) TypefaceTextView(com.waz.zclient.ui.text.TypefaceTextView) View(android.view.View) DrawingCanvasView(com.waz.zclient.ui.sketch.DrawingCanvasView) TextView(android.widget.TextView)

Aggregations

Bitmap (android.graphics.Bitmap)1 View (android.view.View)1 HorizontalScrollView (android.widget.HorizontalScrollView)1 TextView (android.widget.TextView)1 DrawingCanvasView (com.waz.zclient.ui.sketch.DrawingCanvasView)1 TypefaceTextView (com.waz.zclient.ui.text.TypefaceTextView)1