diff --git a/briar-android/src/main/java/org/briarproject/briar/android/view/CompositeSendButton.java b/briar-android/src/main/java/org/briarproject/briar/android/view/CompositeSendButton.java index 273a250c5..11ed0adfc 100644 --- a/briar-android/src/main/java/org/briarproject/briar/android/view/CompositeSendButton.java +++ b/briar-android/src/main/java/org/briarproject/briar/android/view/CompositeSendButton.java @@ -5,6 +5,7 @@ import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.View; import android.widget.FrameLayout; +import android.widget.ImageView; import android.widget.ProgressBar; import org.briarproject.briar.R; @@ -19,9 +20,10 @@ import static java.util.Objects.requireNonNull; public class CompositeSendButton extends FrameLayout { private final AppCompatImageButton sendButton, imageButton; + private final ImageView bombBadge; private final ProgressBar progressBar; - private boolean hasImageSupport = false; + private boolean hasImageSupport = false, bombVisible = false; public CompositeSendButton(@NonNull Context context, @Nullable AttributeSet attrs) { @@ -32,6 +34,7 @@ public class CompositeSendButton extends FrameLayout { sendButton = findViewById(R.id.sendButton); imageButton = findViewById(R.id.imageButton); + bombBadge = findViewById(R.id.bombBadge); progressBar = findViewById(R.id.progressBar); } @@ -71,6 +74,11 @@ public class CompositeSendButton extends FrameLayout { return hasImageSupport; } + public void setBombVisible(boolean visible) { + bombVisible = visible; + bombBadge.setVisibility(visible ? VISIBLE : INVISIBLE); + } + public void showImageButton(boolean showImageButton, boolean sendEnabled) { if (showImageButton) { imageButton.setVisibility(VISIBLE); @@ -78,6 +86,7 @@ public class CompositeSendButton extends FrameLayout { sendButton.clearAnimation(); sendButton.animate().alpha(0f).withEndAction(() -> { sendButton.setVisibility(INVISIBLE); + bombBadge.setVisibility(INVISIBLE); imageButton.setEnabled(true); }).start(); imageButton.clearAnimation(); @@ -88,7 +97,9 @@ public class CompositeSendButton extends FrameLayout { sendButton.setEnabled(sendEnabled); imageButton.setEnabled(false); sendButton.clearAnimation(); - sendButton.animate().alpha(1f).start(); + sendButton.animate().alpha(1f).withEndAction(() -> { + if (bombVisible) bombBadge.setVisibility(VISIBLE); + }).start(); imageButton.clearAnimation(); imageButton.animate().alpha(0f).withEndAction(() -> imageButton.setVisibility(INVISIBLE) diff --git a/briar-android/src/main/java/org/briarproject/briar/android/view/TextSendController.java b/briar-android/src/main/java/org/briarproject/briar/android/view/TextSendController.java index 2e510132b..886a0a44b 100644 --- a/briar-android/src/main/java/org/briarproject/briar/android/view/TextSendController.java +++ b/briar-android/src/main/java/org/briarproject/briar/android/view/TextSendController.java @@ -7,6 +7,7 @@ import com.google.android.material.snackbar.Snackbar; import org.briarproject.bramble.api.nullsafety.NotNullByDefault; import org.briarproject.briar.R; +import org.briarproject.briar.android.conversation.ConversationActivity; import org.briarproject.briar.android.view.EmojiTextInputView.TextInputListener; import org.briarproject.briar.api.attachment.AttachmentHeader; @@ -60,15 +61,26 @@ public class TextSendController implements TextInputListener { updateViewState(); } + /** + * Sets the current auto delete timer and updates the UI accordingly. + *
+ * Attention: Works only in {@link ConversationActivity}.
+ */
public void setAutoDeleteTimer(long timer) {
+ // this will need to be adapted when other screens
+ // besides the private conversation use auto delete timers
+ CompositeSendButton sendButton =
+ (CompositeSendButton) compositeSendButton;
// update hint
if (timer == NO_AUTO_DELETE_TIMER) {
textInput.setHint(defaultHint);
+ sendButton.setBombVisible(false);
} else {
// this might need to be adapted when other screens
// besides the private conversation use auto delete timers
defaultHint = textInput.getHint();
textInput.setHint(R.string.message_hint_auto_delete);
+ sendButton.setBombVisible(true);
}
}
diff --git a/briar-android/src/main/res/drawable/bomb_badge.xml b/briar-android/src/main/res/drawable/bomb_badge.xml
new file mode 100644
index 000000000..c3bf3da45
--- /dev/null
+++ b/briar-android/src/main/res/drawable/bomb_badge.xml
@@ -0,0 +1,13 @@
+
+