Disable attachments on non-friends.

This commit is contained in:
Mikunj 2019-10-18 16:12:49 +11:00
parent 8d6094ecd6
commit b12e6b838c
2 changed files with 12 additions and 1 deletions

View File

@ -127,7 +127,8 @@
android:paddingStart="6dp" android:paddingStart="6dp"
android:paddingEnd="6dp" android:paddingEnd="6dp"
android:background="?selectableItemBackgroundBorderless" android:background="?selectableItemBackgroundBorderless"
android:contentDescription="@string/conversation_activity__quick_attachment_drawer_toggle_camera_description" /> android:contentDescription="@string/conversation_activity__quick_attachment_drawer_toggle_camera_description"
android:visibility="gone"/>
<org.thoughtcrime.securesms.components.MicrophoneRecorderView <org.thoughtcrime.securesms.components.MicrophoneRecorderView
android:id="@+id/recorder_view" android:id="@+id/recorder_view"

View File

@ -2189,6 +2189,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
private void updateInputPanel() { private void updateInputPanel() {
boolean hasPendingFriendRequest = !recipient.isGroupRecipient() && DatabaseFactory.getLokiThreadDatabase(this).hasPendingFriendRequest(threadId); boolean hasPendingFriendRequest = !recipient.isGroupRecipient() && DatabaseFactory.getLokiThreadDatabase(this).hasPendingFriendRequest(threadId);
updateToggleButtonState();
inputPanel.setEnabled(!hasPendingFriendRequest); inputPanel.setEnabled(!hasPendingFriendRequest);
int hintID = hasPendingFriendRequest ? R.string.activity_conversation_pending_friend_request_hint : R.string.activity_conversation_default_hint; int hintID = hasPendingFriendRequest ? R.string.activity_conversation_pending_friend_request_hint : R.string.activity_conversation_default_hint;
inputPanel.setHint(getResources().getString(hintID)); inputPanel.setHint(getResources().getString(hintID));
@ -2400,6 +2401,15 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
} }
private void updateToggleButtonState() { private void updateToggleButtonState() {
// Don't allow attachments if we're not friends
LokiThreadFriendRequestStatus friendRequestStatus = DatabaseFactory.getLokiThreadDatabase(this).getFriendRequestStatus(threadId);
if (!recipient.isGroupRecipient() && friendRequestStatus != LokiThreadFriendRequestStatus.FRIENDS) {
buttonToggle.display(sendButton);
quickAttachmentToggle.hide();
inlineAttachmentToggle.hide();
return;
}
if (inputPanel.isRecordingInLockedMode()) { if (inputPanel.isRecordingInLockedMode()) {
buttonToggle.display(sendButton); buttonToggle.display(sendButton);
quickAttachmentToggle.show(); quickAttachmentToggle.show();