Search in sources :

Example 1 with TextEntity

use of org.thoughtcrime.securesms.scribbles.widget.entity.TextEntity in project Signal-Android by WhisperSystems.

the class ScribbleActivity method addTextSticker.

protected void addTextSticker() {
    TextLayer textLayer = createTextLayer();
    TextEntity textEntity = new TextEntity(textLayer, scribbleView.getWidth(), scribbleView.getHeight());
    scribbleView.addEntityAndPosition(textEntity);
    // move text sticker up so that its not hidden under keyboard
    PointF center = textEntity.absoluteCenter();
    center.y = center.y * 0.5F;
    textEntity.moveCenterTo(center);
    // redraw
    scribbleView.invalidate();
    startTextEntityEditing();
    changeTextEntityColor(toolbar.getToolColor());
}
Also used : TextLayer(org.thoughtcrime.securesms.scribbles.viewmodel.TextLayer) PointF(android.graphics.PointF) TextEntity(org.thoughtcrime.securesms.scribbles.widget.entity.TextEntity)

Example 2 with TextEntity

use of org.thoughtcrime.securesms.scribbles.widget.entity.TextEntity in project Signal-Android by WhisperSystems.

the class MotionView method selectEntity.

private void selectEntity(@Nullable MotionEntity entity, boolean updateCallback) {
    if (selectedEntity != null) {
        selectedEntity.setIsSelected(false);
        if (selectedEntity instanceof TextEntity) {
            editText.clearComposingText();
            editText.clearFocus();
            InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(editText.getWindowToken(), 0);
        }
    }
    if (entity != null) {
        entity.setIsSelected(true);
    }
    selectedEntity = entity;
    invalidate();
    if (updateCallback && motionViewCallback != null) {
        motionViewCallback.onEntitySelected(entity);
    }
}
Also used : InputMethodManager(android.view.inputmethod.InputMethodManager) TextEntity(org.thoughtcrime.securesms.scribbles.widget.entity.TextEntity)

Example 3 with TextEntity

use of org.thoughtcrime.securesms.scribbles.widget.entity.TextEntity in project Signal-Android by signalapp.

the class MotionView method selectEntity.

private void selectEntity(@Nullable MotionEntity entity, boolean updateCallback) {
    if (selectedEntity != null) {
        selectedEntity.setIsSelected(false);
        if (selectedEntity instanceof TextEntity) {
            editText.clearComposingText();
            editText.clearFocus();
            InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(editText.getWindowToken(), 0);
        }
    }
    if (entity != null) {
        entity.setIsSelected(true);
    }
    selectedEntity = entity;
    invalidate();
    if (updateCallback && motionViewCallback != null) {
        motionViewCallback.onEntitySelected(entity);
    }
}
Also used : InputMethodManager(android.view.inputmethod.InputMethodManager) TextEntity(org.thoughtcrime.securesms.scribbles.widget.entity.TextEntity)

Example 4 with TextEntity

use of org.thoughtcrime.securesms.scribbles.widget.entity.TextEntity in project Signal-Android by signalapp.

the class ScribbleActivity method addTextSticker.

protected void addTextSticker() {
    TextLayer textLayer = createTextLayer();
    TextEntity textEntity = new TextEntity(textLayer, scribbleView.getWidth(), scribbleView.getHeight());
    scribbleView.addEntityAndPosition(textEntity);
    // move text sticker up so that its not hidden under keyboard
    PointF center = textEntity.absoluteCenter();
    center.y = center.y * 0.5F;
    textEntity.moveCenterTo(center);
    // redraw
    scribbleView.invalidate();
    startTextEntityEditing();
    changeTextEntityColor(toolbar.getToolColor());
}
Also used : TextLayer(org.thoughtcrime.securesms.scribbles.viewmodel.TextLayer) PointF(android.graphics.PointF) TextEntity(org.thoughtcrime.securesms.scribbles.widget.entity.TextEntity)

Example 5 with TextEntity

use of org.thoughtcrime.securesms.scribbles.widget.entity.TextEntity in project Signal-Android by WhisperSystems.

the class MotionView method afterTextChanged.

@Override
public void afterTextChanged(Editable s) {
    String text = s.toString();
    MotionEntity entity = getSelectedEntity();
    if (entity != null && entity instanceof TextEntity) {
        TextEntity textEntity = (TextEntity) entity;
        if (!textEntity.getLayer().getText().equals(text)) {
            textEntity.getLayer().setText(text);
            textEntity.updateEntity();
            MotionView.this.invalidate();
        }
    }
}
Also used : MotionEntity(org.thoughtcrime.securesms.scribbles.widget.entity.MotionEntity) TextEntity(org.thoughtcrime.securesms.scribbles.widget.entity.TextEntity)

Aggregations

TextEntity (org.thoughtcrime.securesms.scribbles.widget.entity.TextEntity)8 PointF (android.graphics.PointF)2 InputMethodManager (android.view.inputmethod.InputMethodManager)2 TextLayer (org.thoughtcrime.securesms.scribbles.viewmodel.TextLayer)2 MotionEntity (org.thoughtcrime.securesms.scribbles.widget.entity.MotionEntity)2