mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-25 01:07:47 +00:00
Image Editor - Remove initial text.
- Flashing cursor.
This commit is contained in:
parent
2de64fca02
commit
95304fe001
@ -623,8 +623,6 @@
|
|||||||
<!-- ScribbleActivity -->
|
<!-- ScribbleActivity -->
|
||||||
<string name="ScribbleActivity_save_failure">Failed to save image changes</string>
|
<string name="ScribbleActivity_save_failure">Failed to save image changes</string>
|
||||||
|
|
||||||
<string name="ImageEditorFragment_initial_text">Signal</string>
|
|
||||||
|
|
||||||
<!-- Search -->
|
<!-- Search -->
|
||||||
<string name="SearchFragment_no_results">No results found for \'%s\'</string>
|
<string name="SearchFragment_no_results">No results found for \'%s\'</string>
|
||||||
<string name="SearchFragment_header_conversations">Conversations</string>
|
<string name="SearchFragment_header_conversations">Conversations</string>
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package org.thoughtcrime.securesms.imageeditor.renderers;
|
package org.thoughtcrime.securesms.imageeditor.renderers;
|
||||||
|
|
||||||
|
import android.animation.ValueAnimator;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Matrix;
|
import android.graphics.Matrix;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
@ -10,6 +11,7 @@ import android.os.Parcel;
|
|||||||
import android.support.annotation.ColorInt;
|
import android.support.annotation.ColorInt;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
import android.view.animation.Interpolator;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.imageeditor.Bounds;
|
import org.thoughtcrime.securesms.imageeditor.Bounds;
|
||||||
import org.thoughtcrime.securesms.imageeditor.ColorableRenderer;
|
import org.thoughtcrime.securesms.imageeditor.ColorableRenderer;
|
||||||
@ -43,6 +45,9 @@ public final class TextRenderer extends InvalidateableRenderer implements Colora
|
|||||||
private int selEnd;
|
private int selEnd;
|
||||||
private boolean hasFocus;
|
private boolean hasFocus;
|
||||||
|
|
||||||
|
private ValueAnimator cursorAnimator;
|
||||||
|
private float cursorAnimatedValue;
|
||||||
|
|
||||||
public TextRenderer(@Nullable String text, @ColorInt int color) {
|
public TextRenderer(@Nullable String text, @ColorInt int color) {
|
||||||
setColor(color);
|
setColor(color);
|
||||||
float regularTextSize = paint.getTextSize();
|
float regularTextSize = paint.getTextSize();
|
||||||
@ -78,9 +83,12 @@ public final class TextRenderer extends InvalidateableRenderer implements Colora
|
|||||||
|
|
||||||
rendererContext.canvasMatrix.concat(projectionMatrix);
|
rendererContext.canvasMatrix.concat(projectionMatrix);
|
||||||
|
|
||||||
canvas.clipRect(textBounds);
|
|
||||||
|
|
||||||
if (hasFocus) {
|
if (hasFocus) {
|
||||||
|
if (selStart == selEnd) {
|
||||||
|
selectionPaint.setAlpha((int) (cursorAnimatedValue * 128));
|
||||||
|
} else {
|
||||||
|
selectionPaint.setAlpha(128);
|
||||||
|
}
|
||||||
canvas.drawRect(selectionBounds, selectionPaint);
|
canvas.drawRect(selectionBounds, selectionPaint);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,7 +174,7 @@ public final class TextRenderer extends InvalidateableRenderer implements Colora
|
|||||||
if (this.color != color) {
|
if (this.color != color) {
|
||||||
this.color = color;
|
this.color = color;
|
||||||
paint.setColor(color);
|
paint.setColor(color);
|
||||||
selectionPaint.setColor(color & ~0xff000000 | 0x7f000000);
|
selectionPaint.setColor(color);
|
||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -198,7 +206,33 @@ public final class TextRenderer extends InvalidateableRenderer implements Colora
|
|||||||
public void setFocused(boolean hasFocus) {
|
public void setFocused(boolean hasFocus) {
|
||||||
if (this.hasFocus != hasFocus) {
|
if (this.hasFocus != hasFocus) {
|
||||||
this.hasFocus = hasFocus;
|
this.hasFocus = hasFocus;
|
||||||
invalidate();
|
if (cursorAnimator != null) {
|
||||||
|
cursorAnimator.cancel();
|
||||||
|
cursorAnimator = null;
|
||||||
|
}
|
||||||
|
if (hasFocus) {
|
||||||
|
cursorAnimator = ValueAnimator.ofFloat(0, 1);
|
||||||
|
cursorAnimator.setInterpolator(pulseInterpolator());
|
||||||
|
cursorAnimator.setRepeatCount(ValueAnimator.INFINITE);
|
||||||
|
cursorAnimator.setDuration(1000);
|
||||||
|
cursorAnimator.addUpdateListener(animation -> {
|
||||||
|
cursorAnimatedValue = (float) animation.getAnimatedValue();
|
||||||
|
invalidate();
|
||||||
|
});
|
||||||
|
cursorAnimator.start();
|
||||||
|
} else {
|
||||||
|
invalidate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Interpolator pulseInterpolator() {
|
||||||
|
return input -> {
|
||||||
|
input *= 5;
|
||||||
|
if (input > 1) {
|
||||||
|
input = 4 - input;
|
||||||
|
}
|
||||||
|
return Math.max(0, Math.min(1, input));
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -212,7 +212,7 @@ public final class ImageEditorFragment extends Fragment implements ImageEditorHu
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void addText() {
|
protected void addText() {
|
||||||
String initialText = requireContext().getString(R.string.ImageEditorFragment_initial_text);
|
String initialText = "";
|
||||||
int color = imageEditorHud.getActiveColor();
|
int color = imageEditorHud.getActiveColor();
|
||||||
TextRenderer renderer = new TextRenderer(initialText, color);
|
TextRenderer renderer = new TextRenderer(initialText, color);
|
||||||
EditorElement element = new EditorElement(renderer);
|
EditorElement element = new EditorElement(renderer);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user