mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-18 05:39:53 +01:00
Show a bomb badge on the send button when disappearing messages is active
This commit is contained in:
@@ -5,6 +5,7 @@ import android.util.AttributeSet;
|
|||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
|
import android.widget.ImageView;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
|
|
||||||
import org.briarproject.briar.R;
|
import org.briarproject.briar.R;
|
||||||
@@ -19,9 +20,10 @@ import static java.util.Objects.requireNonNull;
|
|||||||
public class CompositeSendButton extends FrameLayout {
|
public class CompositeSendButton extends FrameLayout {
|
||||||
|
|
||||||
private final AppCompatImageButton sendButton, imageButton;
|
private final AppCompatImageButton sendButton, imageButton;
|
||||||
|
private final ImageView bombBadge;
|
||||||
private final ProgressBar progressBar;
|
private final ProgressBar progressBar;
|
||||||
|
|
||||||
private boolean hasImageSupport = false;
|
private boolean hasImageSupport = false, bombVisible = false;
|
||||||
|
|
||||||
public CompositeSendButton(@NonNull Context context,
|
public CompositeSendButton(@NonNull Context context,
|
||||||
@Nullable AttributeSet attrs) {
|
@Nullable AttributeSet attrs) {
|
||||||
@@ -32,6 +34,7 @@ public class CompositeSendButton extends FrameLayout {
|
|||||||
|
|
||||||
sendButton = findViewById(R.id.sendButton);
|
sendButton = findViewById(R.id.sendButton);
|
||||||
imageButton = findViewById(R.id.imageButton);
|
imageButton = findViewById(R.id.imageButton);
|
||||||
|
bombBadge = findViewById(R.id.bombBadge);
|
||||||
progressBar = findViewById(R.id.progressBar);
|
progressBar = findViewById(R.id.progressBar);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,6 +74,11 @@ public class CompositeSendButton extends FrameLayout {
|
|||||||
return hasImageSupport;
|
return hasImageSupport;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setBombVisible(boolean visible) {
|
||||||
|
bombVisible = visible;
|
||||||
|
bombBadge.setVisibility(visible ? VISIBLE : INVISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
public void showImageButton(boolean showImageButton, boolean sendEnabled) {
|
public void showImageButton(boolean showImageButton, boolean sendEnabled) {
|
||||||
if (showImageButton) {
|
if (showImageButton) {
|
||||||
imageButton.setVisibility(VISIBLE);
|
imageButton.setVisibility(VISIBLE);
|
||||||
@@ -78,6 +86,7 @@ public class CompositeSendButton extends FrameLayout {
|
|||||||
sendButton.clearAnimation();
|
sendButton.clearAnimation();
|
||||||
sendButton.animate().alpha(0f).withEndAction(() -> {
|
sendButton.animate().alpha(0f).withEndAction(() -> {
|
||||||
sendButton.setVisibility(INVISIBLE);
|
sendButton.setVisibility(INVISIBLE);
|
||||||
|
bombBadge.setVisibility(INVISIBLE);
|
||||||
imageButton.setEnabled(true);
|
imageButton.setEnabled(true);
|
||||||
}).start();
|
}).start();
|
||||||
imageButton.clearAnimation();
|
imageButton.clearAnimation();
|
||||||
@@ -88,7 +97,9 @@ public class CompositeSendButton extends FrameLayout {
|
|||||||
sendButton.setEnabled(sendEnabled);
|
sendButton.setEnabled(sendEnabled);
|
||||||
imageButton.setEnabled(false);
|
imageButton.setEnabled(false);
|
||||||
sendButton.clearAnimation();
|
sendButton.clearAnimation();
|
||||||
sendButton.animate().alpha(1f).start();
|
sendButton.animate().alpha(1f).withEndAction(() -> {
|
||||||
|
if (bombVisible) bombBadge.setVisibility(VISIBLE);
|
||||||
|
}).start();
|
||||||
imageButton.clearAnimation();
|
imageButton.clearAnimation();
|
||||||
imageButton.animate().alpha(0f).withEndAction(() ->
|
imageButton.animate().alpha(0f).withEndAction(() ->
|
||||||
imageButton.setVisibility(INVISIBLE)
|
imageButton.setVisibility(INVISIBLE)
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import com.google.android.material.snackbar.Snackbar;
|
|||||||
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||||
import org.briarproject.briar.R;
|
import org.briarproject.briar.R;
|
||||||
|
import org.briarproject.briar.android.conversation.ConversationActivity;
|
||||||
import org.briarproject.briar.android.view.EmojiTextInputView.TextInputListener;
|
import org.briarproject.briar.android.view.EmojiTextInputView.TextInputListener;
|
||||||
import org.briarproject.briar.api.attachment.AttachmentHeader;
|
import org.briarproject.briar.api.attachment.AttachmentHeader;
|
||||||
|
|
||||||
@@ -60,15 +61,26 @@ public class TextSendController implements TextInputListener {
|
|||||||
updateViewState();
|
updateViewState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the current auto delete timer and updates the UI accordingly.
|
||||||
|
* <p>
|
||||||
|
* Attention: Works only in {@link ConversationActivity}.
|
||||||
|
*/
|
||||||
public void setAutoDeleteTimer(long timer) {
|
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
|
// update hint
|
||||||
if (timer == NO_AUTO_DELETE_TIMER) {
|
if (timer == NO_AUTO_DELETE_TIMER) {
|
||||||
textInput.setHint(defaultHint);
|
textInput.setHint(defaultHint);
|
||||||
|
sendButton.setBombVisible(false);
|
||||||
} else {
|
} else {
|
||||||
// this might need to be adapted when other screens
|
// this might need to be adapted when other screens
|
||||||
// besides the private conversation use auto delete timers
|
// besides the private conversation use auto delete timers
|
||||||
defaultHint = textInput.getHint();
|
defaultHint = textInput.getHint();
|
||||||
textInput.setHint(R.string.message_hint_auto_delete);
|
textInput.setHint(R.string.message_hint_auto_delete);
|
||||||
|
sendButton.setBombVisible(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
13
briar-android/src/main/res/drawable/bomb_badge.xml
Normal file
13
briar-android/src/main/res/drawable/bomb_badge.xml
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="oval">
|
||||||
|
|
||||||
|
<padding
|
||||||
|
android:bottom="1dp"
|
||||||
|
android:left="1dp"
|
||||||
|
android:right="1dp"
|
||||||
|
android:top="1dp" />
|
||||||
|
|
||||||
|
<solid android:color="@color/item_background_highlight" />
|
||||||
|
|
||||||
|
</shape>
|
||||||
@@ -37,6 +37,19 @@
|
|||||||
app:srcCompat="@drawable/social_send_now_white"
|
app:srcCompat="@drawable/social_send_now_white"
|
||||||
app:tint="@color/briar_accent" />
|
app:tint="@color/briar_accent" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/bombBadge"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="end|bottom"
|
||||||
|
android:layout_margin="1dp"
|
||||||
|
android:background="@drawable/bomb_badge"
|
||||||
|
android:contentDescription="@string/auto_delete_msg_contact_enabled"
|
||||||
|
android:visibility="invisible"
|
||||||
|
app:srcCompat="@drawable/ic_bomb"
|
||||||
|
app:tint="@color/color_primary"
|
||||||
|
tools:visibility="visible" />
|
||||||
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
android:id="@+id/progressBar"
|
android:id="@+id/progressBar"
|
||||||
android:layout_width="@dimen/text_input_height"
|
android:layout_width="@dimen/text_input_height"
|
||||||
|
|||||||
Reference in New Issue
Block a user