mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-22 02:36:55 +00:00
Update blur UI.
This commit is contained in:
@@ -7,7 +7,6 @@ import org.whispersystems.signalservice.api.storage.StorageKey;
|
||||
public class TooltipValues {
|
||||
|
||||
private static final String BLUR_HUD_ICON = "tooltip.blur_hud_icon";
|
||||
private static final String AUTO_BLUR_FACES = "tooltip.auto_blur_faces";
|
||||
|
||||
private final KeyValueStore store;
|
||||
|
||||
@@ -25,12 +24,4 @@ public class TooltipValues {
|
||||
public void markBlurHudIconTooltipSeen() {
|
||||
store.beginWrite().putBoolean(BLUR_HUD_ICON, true).apply();
|
||||
}
|
||||
|
||||
public boolean hasSeenAutoBlurFacesTooltip() {
|
||||
return store.getBoolean(AUTO_BLUR_FACES, false);
|
||||
}
|
||||
|
||||
public void markAutoBlurFacesTooltipSeen() {
|
||||
store.beginWrite().putBoolean(AUTO_BLUR_FACES, true).apply();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -306,12 +306,8 @@ public final class ImageEditorFragment extends Fragment implements ImageEditorHu
|
||||
}
|
||||
|
||||
case BLUR: {
|
||||
imageEditorView.startDrawing(0.055f, Paint.Cap.ROUND, true);
|
||||
imageEditorView.startDrawing(0.052f, Paint.Cap.ROUND, true);
|
||||
imageEditorHud.setBlurFacesToggleEnabled(imageEditorView.getModel().hasFaceRenderer());
|
||||
if (!SignalStore.tooltips().hasSeenAutoBlurFacesTooltip()) {
|
||||
imageEditorHud.showAutoBlurFacesTooltip();
|
||||
SignalStore.tooltips().markAutoBlurFacesTooltipSeen();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -348,11 +344,13 @@ public final class ImageEditorFragment extends Fragment implements ImageEditorHu
|
||||
EditorModel model = imageEditorView.getModel();
|
||||
EditorElement mainImage = model.getMainImage();
|
||||
if (mainImage == null) {
|
||||
imageEditorHud.hideBlurToast();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!enabled) {
|
||||
model.clearFaceRenderers();
|
||||
imageEditorHud.hideBlurToast();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -361,6 +359,7 @@ public final class ImageEditorFragment extends Fragment implements ImageEditorHu
|
||||
if (cachedFaceDetection != null) {
|
||||
if (cachedFaceDetection.first().equals(getUri()) && cachedFaceDetection.second().position.equals(inverseCropPosition)) {
|
||||
renderFaceBlurs(cachedFaceDetection.second());
|
||||
imageEditorHud.showBlurToast();
|
||||
return;
|
||||
} else {
|
||||
cachedFaceDetection = null;
|
||||
@@ -392,6 +391,7 @@ public final class ImageEditorFragment extends Fragment implements ImageEditorHu
|
||||
mainImage.getFlags().reset();
|
||||
renderFaceBlurs(result);
|
||||
progress.dismiss();
|
||||
imageEditorHud.showBlurToast();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -4,10 +4,10 @@ import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.Switch;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
@@ -19,6 +19,8 @@ import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.components.TooltipPopup;
|
||||
import org.thoughtcrime.securesms.scribbles.widget.ColorPaletteAdapter;
|
||||
import org.thoughtcrime.securesms.scribbles.widget.VerticalSlideColorPicker;
|
||||
import org.thoughtcrime.securesms.util.Debouncer;
|
||||
import org.thoughtcrime.securesms.util.ViewUtil;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
@@ -46,11 +48,13 @@ public final class ImageEditorHud extends LinearLayout {
|
||||
private View deleteButton;
|
||||
private View confirmButton;
|
||||
private View doneButton;
|
||||
private View blurToggleContainer;
|
||||
private View blurToggleHud;
|
||||
private Switch blurToggle;
|
||||
private View blurToast;
|
||||
private VerticalSlideColorPicker colorPicker;
|
||||
private RecyclerView colorPalette;
|
||||
|
||||
|
||||
@NonNull
|
||||
private EventListener eventListener = NULL_EVENT_LISTENER;
|
||||
@Nullable
|
||||
@@ -58,6 +62,7 @@ public final class ImageEditorHud extends LinearLayout {
|
||||
|
||||
private final Map<Mode, Set<View>> visibilityModeMap = new HashMap<>();
|
||||
private final Set<View> allViews = new HashSet<>();
|
||||
private final Debouncer toastDebouncer = new Debouncer(3000);
|
||||
|
||||
private Mode currentMode;
|
||||
private boolean undoAvailable;
|
||||
@@ -81,24 +86,25 @@ public final class ImageEditorHud extends LinearLayout {
|
||||
inflate(getContext(), R.layout.image_editor_hud, this);
|
||||
setOrientation(VERTICAL);
|
||||
|
||||
cropButton = findViewById(R.id.scribble_crop_button);
|
||||
cropFlipButton = findViewById(R.id.scribble_crop_flip);
|
||||
cropRotateButton = findViewById(R.id.scribble_crop_rotate);
|
||||
cropAspectLock = findViewById(R.id.scribble_crop_aspect_lock);
|
||||
colorPalette = findViewById(R.id.scribble_color_palette);
|
||||
drawButton = findViewById(R.id.scribble_draw_button);
|
||||
highlightButton = findViewById(R.id.scribble_highlight_button);
|
||||
blurButton = findViewById(R.id.scribble_blur_button);
|
||||
textButton = findViewById(R.id.scribble_text_button);
|
||||
stickerButton = findViewById(R.id.scribble_sticker_button);
|
||||
undoButton = findViewById(R.id.scribble_undo_button);
|
||||
saveButton = findViewById(R.id.scribble_save_button);
|
||||
deleteButton = findViewById(R.id.scribble_delete_button);
|
||||
confirmButton = findViewById(R.id.scribble_confirm_button);
|
||||
colorPicker = findViewById(R.id.scribble_color_picker);
|
||||
doneButton = findViewById(R.id.scribble_done_button);
|
||||
blurToggleContainer = findViewById(R.id.scribble_blur_toggle_container);
|
||||
blurToggle = findViewById(R.id.scribble_blur_toggle);
|
||||
cropButton = findViewById(R.id.scribble_crop_button);
|
||||
cropFlipButton = findViewById(R.id.scribble_crop_flip);
|
||||
cropRotateButton = findViewById(R.id.scribble_crop_rotate);
|
||||
cropAspectLock = findViewById(R.id.scribble_crop_aspect_lock);
|
||||
colorPalette = findViewById(R.id.scribble_color_palette);
|
||||
drawButton = findViewById(R.id.scribble_draw_button);
|
||||
highlightButton = findViewById(R.id.scribble_highlight_button);
|
||||
blurButton = findViewById(R.id.scribble_blur_button);
|
||||
textButton = findViewById(R.id.scribble_text_button);
|
||||
stickerButton = findViewById(R.id.scribble_sticker_button);
|
||||
undoButton = findViewById(R.id.scribble_undo_button);
|
||||
saveButton = findViewById(R.id.scribble_save_button);
|
||||
deleteButton = findViewById(R.id.scribble_delete_button);
|
||||
confirmButton = findViewById(R.id.scribble_confirm_button);
|
||||
colorPicker = findViewById(R.id.scribble_color_picker);
|
||||
doneButton = findViewById(R.id.scribble_done_button);
|
||||
blurToggleHud = findViewById(R.id.scribble_blur_toggle_hud);
|
||||
blurToggle = findViewById(R.id.scribble_blur_toggle);
|
||||
blurToast = findViewById(R.id.scribble_blur_toast);
|
||||
|
||||
cropAspectLock.setOnClickListener(v -> {
|
||||
eventListener.onCropAspectLock(!eventListener.isCropAspectLocked());
|
||||
@@ -121,7 +127,7 @@ public final class ImageEditorHud extends LinearLayout {
|
||||
|
||||
setVisibleViewsWhenInMode(Mode.HIGHLIGHT, confirmButton, undoButton, colorPicker, colorPalette);
|
||||
|
||||
setVisibleViewsWhenInMode(Mode.BLUR, confirmButton, undoButton, blurToggleContainer);
|
||||
setVisibleViewsWhenInMode(Mode.BLUR, confirmButton, undoButton, blurToggleHud);
|
||||
|
||||
setVisibleViewsWhenInMode(Mode.TEXT, confirmButton, deleteButton, colorPicker, colorPalette);
|
||||
|
||||
@@ -208,18 +214,22 @@ public final class ImageEditorHud extends LinearLayout {
|
||||
|
||||
public void showBlurHudTooltip() {
|
||||
TooltipPopup.forTarget(blurButton)
|
||||
.setText(R.string.ImageEditorHud_new_auto_blur_faces_and_blur_brush)
|
||||
.setText(R.string.ImageEditorHud_new_blur_faces_or_draw_anywhere_to_blur)
|
||||
.setBackgroundTint(ContextCompat.getColor(getContext(), R.color.core_ultramarine))
|
||||
.setTextColor(ContextCompat.getColor(getContext(), R.color.core_white))
|
||||
.show(TooltipPopup.POSITION_BELOW);
|
||||
}
|
||||
|
||||
public void showAutoBlurFacesTooltip() {
|
||||
TooltipPopup.forTarget(blurToggleContainer)
|
||||
.setText(R.string.ImageEditorHud_draw_to_blur_or_try_auto_blur)
|
||||
.setBackgroundTint(ContextCompat.getColor(getContext(), R.color.core_ultramarine))
|
||||
.setTextColor(ContextCompat.getColor(getContext(), R.color.core_white))
|
||||
.show(TooltipPopup.POSITION_ABOVE);
|
||||
public void showBlurToast() {
|
||||
blurToast.clearAnimation();
|
||||
blurToast.setVisibility(View.VISIBLE);
|
||||
toastDebouncer.publish(() -> blurToast.setVisibility(GONE));
|
||||
}
|
||||
|
||||
public void hideBlurToast() {
|
||||
blurToast.clearAnimation();
|
||||
blurToast.setVisibility(View.GONE);
|
||||
toastDebouncer.clear();
|
||||
}
|
||||
|
||||
public void setEventListener(@Nullable EventListener eventListener) {
|
||||
@@ -239,6 +249,7 @@ public final class ImageEditorHud extends LinearLayout {
|
||||
updateButtonVisibility(mode);
|
||||
|
||||
switch (mode) {
|
||||
case NONE: presentModeNone(); break;
|
||||
case CROP: presentModeCrop(); break;
|
||||
case DRAW: presentModeDraw(); break;
|
||||
case HIGHLIGHT: presentModeHighlight(); break;
|
||||
@@ -264,6 +275,10 @@ public final class ImageEditorHud extends LinearLayout {
|
||||
(button != undoButton || undoAvailable);
|
||||
}
|
||||
|
||||
private void presentModeNone() {
|
||||
blurToast.setVisibility(GONE);
|
||||
}
|
||||
|
||||
private void presentModeCrop() {
|
||||
updateCropAspectLockImage(eventListener.isCropAspectLocked());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user