mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
Merge branch 'adb/pgp-contacts2' of https://github.com/deltachat/deltachat-android into adb/pgp-contacts2
This commit is contained in:
@@ -2,6 +2,7 @@ package org.thoughtcrime.securesms.reactions;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
@@ -23,6 +24,7 @@ public class ReactionRecipientItem extends LinearLayout {
|
||||
private TextView reactionView;
|
||||
|
||||
private int contactId;
|
||||
private String reaction;
|
||||
|
||||
public ReactionRecipientItem(Context context) {
|
||||
super(context);
|
||||
@@ -44,6 +46,7 @@ public class ReactionRecipientItem extends LinearLayout {
|
||||
|
||||
public void bind(@NonNull GlideRequests glideRequests, int contactId, String reaction) {
|
||||
this.contactId = contactId;
|
||||
this.reaction = reaction;
|
||||
DcContact dcContact = DcHelper.getContext(getContext()).getContact(contactId);
|
||||
Recipient recipient = new Recipient(getContext(), dcContact);
|
||||
this.contactPhotoImage.setAvatar(glideRequests, recipient, false);
|
||||
@@ -58,4 +61,12 @@ public class ReactionRecipientItem extends LinearLayout {
|
||||
public int getContactId() {
|
||||
return contactId;
|
||||
}
|
||||
|
||||
public String getReaction() {
|
||||
return reaction;
|
||||
}
|
||||
|
||||
public View getReactionView() {
|
||||
return reactionView;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,6 +47,11 @@ public class ReactionRecipientsAdapter extends RecyclerView.Adapter
|
||||
clickListener.onItemClick(getView());
|
||||
}
|
||||
});
|
||||
((ReactionRecipientItem) itemView).getReactionView().setOnClickListener(view -> {
|
||||
if (clickListener != null) {
|
||||
clickListener.onReactionClick(getView());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public ReactionRecipientItem getView() {
|
||||
@@ -93,6 +98,7 @@ public class ReactionRecipientsAdapter extends RecyclerView.Adapter
|
||||
|
||||
public interface ItemClickListener {
|
||||
void onItemClick(ReactionRecipientItem item);
|
||||
void onReactionClick(ReactionRecipientItem item);
|
||||
}
|
||||
|
||||
public void changeData(ArrayList<Pair<Integer, String>> contactsReactions) {
|
||||
|
||||
@@ -17,6 +17,7 @@ import com.b44t.messenger.DcContact;
|
||||
import com.b44t.messenger.DcContext;
|
||||
import com.b44t.messenger.DcEvent;
|
||||
import com.b44t.messenger.rpc.Reactions;
|
||||
import com.b44t.messenger.rpc.Rpc;
|
||||
import com.b44t.messenger.rpc.RpcException;
|
||||
|
||||
import org.thoughtcrime.securesms.ProfileActivity;
|
||||
@@ -114,6 +115,39 @@ public class ReactionsDetailsFragment extends DialogFragment implements DcEventC
|
||||
requireContext().startActivity(intent);
|
||||
}
|
||||
|
||||
private String getSelfReaction(Rpc rpc, int accId) {
|
||||
String result = null;
|
||||
try {
|
||||
final Reactions reactions = rpc.getMsgReactions(accId, msgId);
|
||||
if (reactions != null) {
|
||||
final Map<Integer, String[]> reactionsByContact = reactions.getReactionsByContact();
|
||||
final String [] selfReactions = reactionsByContact.get(DcContact.DC_CONTACT_ID_SELF);
|
||||
if (selfReactions != null && selfReactions.length > 0) {
|
||||
result = selfReactions[0];
|
||||
}
|
||||
}
|
||||
} catch(RpcException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private void sendReaction(final String reaction) {
|
||||
Rpc rpc = DcHelper.getRpc(requireActivity());
|
||||
DcContext dcContext = DcHelper.getContext(requireActivity());
|
||||
int accId = dcContext.getAccountId();
|
||||
|
||||
try {
|
||||
if (reaction == null || reaction.equals(getSelfReaction(rpc, accId))) {
|
||||
rpc.sendReaction(accId, msgId, "");
|
||||
} else {
|
||||
rpc.sendReaction(accId, msgId, reaction);
|
||||
}
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private class ListClickListener implements ReactionRecipientsAdapter.ItemClickListener {
|
||||
|
||||
@Override
|
||||
@@ -124,6 +158,12 @@ public class ReactionsDetailsFragment extends DialogFragment implements DcEventC
|
||||
openConversation(contactId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReactionClick(ReactionRecipientItem item) {
|
||||
sendReaction(item.getReaction());
|
||||
ReactionsDetailsFragment.this.dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -50,8 +50,9 @@
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/reaction"
|
||||
style="@style/ButtonSecondary"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="40dp"
|
||||
android:gravity="center"
|
||||
android:textSize="22dp"
|
||||
android:fontFamily="sans-serif"
|
||||
|
||||
@@ -34,6 +34,8 @@
|
||||
<string name="update">Update</string>
|
||||
<string name="emoji">Emoji</string>
|
||||
<string name="attachment">Attachment</string>
|
||||
<!-- the placeholder will be replaced by the name of the image or file to attach -->
|
||||
<string name="ask_attach">Attach \"%1$s\"?</string>
|
||||
<string name="back">Back</string>
|
||||
<string name="close">Close</string>
|
||||
<string name="close_window">Close Window</string>
|
||||
@@ -58,6 +60,8 @@
|
||||
<string name="media">Media</string>
|
||||
<string name="apps_and_media">Apps & Media</string>
|
||||
<string name="profile">Profile</string>
|
||||
<string name="all_profiles">All Profiles</string>
|
||||
<string name="current_profile">Current Profile</string>
|
||||
<string name="main_menu">Main Menu</string>
|
||||
<string name="start_chat">Start Chat</string>
|
||||
<string name="show_full_message">Show Full Message…</string>
|
||||
@@ -92,6 +96,8 @@
|
||||
<string name="no_app_to_handle_data">Can\'t find an app to handle this type of data.</string>
|
||||
<string name="no_browser_installed">No browser installed.</string>
|
||||
<string name="file_not_found">Could not find %1$s.</string>
|
||||
<!-- the placeholder will be replaced by the name of a file -->
|
||||
<string name="cannot_save_file">Cannot save %1$s.</string>
|
||||
<string name="copied_to_clipboard">Copied to clipboard.</string>
|
||||
<string name="contacts_headline">Contacts</string>
|
||||
<string name="email_address">E-Mail Address</string>
|
||||
@@ -151,7 +157,7 @@
|
||||
<item quantity="one">%d Selected</item>
|
||||
<item quantity="other">%d Selected</item>
|
||||
</plurals>
|
||||
|
||||
<string name="selected_colon">Selected:</string>
|
||||
<string name="self">Me</string>
|
||||
<string name="draft">Draft</string>
|
||||
<string name="image">Image</string>
|
||||
@@ -438,6 +444,7 @@
|
||||
<string name="chat_input_placeholder">Message</string>
|
||||
<string name="chat_archived_label">Archived</string>
|
||||
<string name="chat_request_label">Request</string>
|
||||
<string name="chat_request_label_explain">Include requests in counters and notifications</string>
|
||||
<string name="chat_no_messages">No messages.</string>
|
||||
<string name="chat_self_talk_subtitle">Messages to Self</string>
|
||||
<string name="archive_empty_hint">Archived chats will appear here.</string>
|
||||
@@ -511,7 +518,7 @@
|
||||
<string name="group_add_members">Add Members</string>
|
||||
<string name="group_self_not_in_group">You must be a member of the group to perform this action.</string>
|
||||
<string name="profile_encryption">Encryption</string>
|
||||
<string name="profile_shared_chats">Shared Chats</string>
|
||||
<string name="profile_shared_chats">Chats in Common</string>
|
||||
<string name="related_chats">Related Chats</string>
|
||||
<!-- Separator between the list of actual members and past members -->
|
||||
<string name="past_members">Past Members</string>
|
||||
@@ -807,6 +814,7 @@
|
||||
<string name="n_bytes_message">%1$s message</string>
|
||||
<!-- %1$s will be replaced by human-readable date and time -->
|
||||
<string name="download_max_available_until">Download maximum available until %1$s</string>
|
||||
<string name="select_profile">Select Profile</string>
|
||||
<string name="profile_image_select">Select Profile Image</string>
|
||||
<string name="select_your_new_profile_image">Select your new profile image</string>
|
||||
<string name="profile_image_delete">Delete Profile Image</string>
|
||||
|
||||
Reference in New Issue
Block a user