mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-27 12:05:22 +00:00
Adapt Conflicts UI to work with single-recipient failures.
This commit is contained in:
parent
00d7b5c284
commit
3f93731300
@ -1,5 +1,6 @@
|
||||
-keepattributes **
|
||||
-keep class !android.support.v7.internal.view.menu.**,!org.spongycastle.asn1.**,!org.spongycastle.crypto.ec.**,!org.spongycastle.x509.**,** {*;}
|
||||
|
||||
-keep class !org.spongycastle.crypto.tls.**,!com.doomonafireball.betterpickers.**,!org.w3c.**,!android.support.v7.internal.view.menu.**,!org.spongycastle.asn1.**,!org.spongycastle.crypto.ec.**,!org.spongycastle.x509.**,!org.spongycastle.crypto.agreement.**,!org.spongycastle.crypto.ec.**,!org.spongycastle.math.**,!org.spongycastle.pqc.**,!org.spongycastle.jcajce.provider.asymmetric.**,!org.apache.http.**,** {*;}
|
||||
-dontpreverify
|
||||
-dontoptimize
|
||||
-dontwarn **
|
||||
|
@ -67,7 +67,8 @@
|
||||
android:paddingBottom="5dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:drawableLeft="@drawable/ic_error_white_18dp"
|
||||
android:text="FIX" />
|
||||
android:text="FIX"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<Button android:id="@+id/resend_button"
|
||||
android:layout_width="85sp"
|
||||
@ -79,7 +80,8 @@
|
||||
android:paddingBottom="5dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:drawableLeft="@drawable/ic_refresh_white_18dp"
|
||||
android:text="RESEND" />
|
||||
android:text="RESEND"
|
||||
android:visibility="gone"/>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
@ -332,9 +332,8 @@ public class ConversationItem extends LinearLayout {
|
||||
}
|
||||
|
||||
private void setEvents(MessageRecord messageRecord) {
|
||||
setClickable(messageRecord.isPendingSmsFallback() ||
|
||||
messageRecord.hasNetworkFailures() ||
|
||||
messageRecord.isIdentityMismatchFailure() ||
|
||||
setClickable(messageRecord.isFailed()||
|
||||
messageRecord.isPendingSmsFallback() ||
|
||||
(messageRecord.isKeyExchange() &&
|
||||
!messageRecord.isCorruptedKeyExchange() &&
|
||||
!messageRecord.isOutgoing()));
|
||||
@ -573,12 +572,12 @@ public class ConversationItem extends LinearLayout {
|
||||
|
||||
private class ClickListener implements View.OnClickListener {
|
||||
public void onClick(View v) {
|
||||
if (messageRecord.isIdentityMismatchFailure() || messageRecord.hasNetworkFailures()) {
|
||||
if (messageRecord.isFailed()) {
|
||||
Intent intent = new Intent(context, MessageDetailsActivity.class);
|
||||
intent.putExtra(MessageDetailsActivity.MASTER_SECRET_EXTRA, masterSecret);
|
||||
intent.putExtra(MessageDetailsActivity.MESSAGE_ID_EXTRA, messageRecord.getId());
|
||||
intent.putExtra(MessageDetailsActivity.TYPE_EXTRA, messageRecord.isMms() ? MmsSmsDatabase.MMS_TRANSPORT : MmsSmsDatabase.SMS_TRANSPORT);
|
||||
intent.putExtra(MessageDetailsActivity.PUSH_EXTRA, pushDestination);
|
||||
intent.putExtra(MessageDetailsActivity.IS_PUSH_GROUP_EXTRA, groupThread && pushDestination);
|
||||
context.startActivity(intent);
|
||||
} else if (messageRecord.isKeyExchange() &&
|
||||
!messageRecord.isOutgoing() &&
|
||||
|
@ -55,10 +55,11 @@ public class MessageDetailsActivity extends PassphraseRequiredActionBarActivity
|
||||
|
||||
public final static String MASTER_SECRET_EXTRA = "master_secret";
|
||||
public final static String MESSAGE_ID_EXTRA = "message_id";
|
||||
public final static String IS_PUSH_GROUP_EXTRA = "is_push_group";
|
||||
public final static String TYPE_EXTRA = "type";
|
||||
public final static String PUSH_EXTRA = "push";
|
||||
|
||||
private MasterSecret masterSecret;
|
||||
private boolean isPushGroup;
|
||||
private ConversationItem conversationItem;
|
||||
private ViewGroup itemParent;
|
||||
private TextView sentDate;
|
||||
@ -84,6 +85,7 @@ public class MessageDetailsActivity extends PassphraseRequiredActionBarActivity
|
||||
View header = inflater.inflate(R.layout.message_details_header, recipientsList, false);
|
||||
|
||||
masterSecret = getIntent().getParcelableExtra(MASTER_SECRET_EXTRA);
|
||||
isPushGroup = getIntent().getBooleanExtra(IS_PUSH_GROUP_EXTRA, false);
|
||||
itemParent = (ViewGroup) findViewById(R.id.item_container );
|
||||
recipientsList = (ListView ) findViewById(R.id.recipients_list);
|
||||
sentDate = (TextView ) header.findViewById(R.id.sent_time);
|
||||
@ -142,7 +144,8 @@ public class MessageDetailsActivity extends PassphraseRequiredActionBarActivity
|
||||
conversationItem.set(masterSecret, messageRecord, new HashSet<MessageRecord>(), null,
|
||||
recipients != messageRecord.getRecipients(),
|
||||
DirectoryHelper.isPushDestination(this, recipients));
|
||||
recipientsList.setAdapter(new MessageDetailsRecipientAdapter(this, masterSecret, messageRecord, recipients));
|
||||
recipientsList.setAdapter(new MessageDetailsRecipientAdapter(this, masterSecret, messageRecord,
|
||||
recipients, isPushGroup));
|
||||
}
|
||||
|
||||
private void inflateMessageViewIfAbsent(MessageRecord messageRecord) {
|
||||
|
@ -9,20 +9,26 @@ import android.widget.BaseAdapter;
|
||||
|
||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||
import org.thoughtcrime.securesms.database.model.MessageRecord;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.recipients.Recipients;
|
||||
|
||||
public class MessageDetailsRecipientAdapter extends BaseAdapter implements AbsListView.RecyclerListener {
|
||||
|
||||
private Context context;
|
||||
private MasterSecret masterSecret;
|
||||
private MessageRecord record;
|
||||
private Recipients recipients;
|
||||
private final Context context;
|
||||
private final MasterSecret masterSecret;
|
||||
private final MessageRecord record;
|
||||
private final Recipients recipients;
|
||||
private final boolean isPushGroup;
|
||||
|
||||
public MessageDetailsRecipientAdapter(Context context, MasterSecret masterSecret, MessageRecord record, Recipients recipients) {
|
||||
public MessageDetailsRecipientAdapter(Context context, MasterSecret masterSecret,
|
||||
MessageRecord record, Recipients recipients,
|
||||
boolean isPushGroup)
|
||||
{
|
||||
this.context = context;
|
||||
this.masterSecret = masterSecret;
|
||||
this.record = record;
|
||||
this.recipients = recipients;
|
||||
this.isPushGroup = isPushGroup;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -46,7 +52,8 @@ public class MessageDetailsRecipientAdapter extends BaseAdapter implements AbsLi
|
||||
convertView = LayoutInflater.from(context).inflate(R.layout.message_details_recipient, parent, false);
|
||||
}
|
||||
|
||||
((MessageRecipientListItem)convertView).set(masterSecret, record, recipients, position);
|
||||
Recipient recipient = recipients.getRecipientsList().get(position);
|
||||
((MessageRecipientListItem)convertView).set(masterSecret, record, recipient, isPushGroup);
|
||||
return convertView;
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,6 @@ import org.thoughtcrime.securesms.database.documents.IdentityKeyMismatch;
|
||||
import org.thoughtcrime.securesms.database.documents.NetworkFailure;
|
||||
import org.thoughtcrime.securesms.database.model.MessageRecord;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.recipients.Recipients;
|
||||
import org.thoughtcrime.securesms.sms.MessageSender;
|
||||
import org.thoughtcrime.securesms.util.RecipientViewUtil;
|
||||
|
||||
@ -74,29 +73,33 @@ public class MessageRecipientListItem extends RelativeLayout
|
||||
this.resendButton = (Button) findViewById(R.id.resend_button);
|
||||
}
|
||||
|
||||
public void set(final MasterSecret masterSecret, final MessageRecord record, final Recipients recipients, final int position) {
|
||||
recipient = recipients.getRecipientsList().get(position);
|
||||
public void set(final MasterSecret masterSecret,
|
||||
final MessageRecord record,
|
||||
final Recipient recipient,
|
||||
final boolean isPushGroup)
|
||||
{
|
||||
this.recipient = recipient;
|
||||
|
||||
recipient.addListener(this);
|
||||
fromView.setText(RecipientViewUtil.formatFrom(getContext(), recipient));
|
||||
|
||||
RecipientViewUtil.setContactPhoto(getContext(), contactPhotoImage, recipient, false);
|
||||
setIssueIndicators(masterSecret, record);
|
||||
setIssueIndicators(masterSecret, record, isPushGroup);
|
||||
}
|
||||
|
||||
private void setIssueIndicators(final MasterSecret masterSecret, final MessageRecord record) {
|
||||
private void setIssueIndicators(final MasterSecret masterSecret,
|
||||
final MessageRecord record,
|
||||
final boolean isPushGroup)
|
||||
{
|
||||
final NetworkFailure networkFailure = getNetworkFailure(record);
|
||||
final IdentityKeyMismatch keyMismatch = networkFailure == null ? getKeyMismatch(record) : null;
|
||||
|
||||
String errorText = "";
|
||||
if (networkFailure != null) {
|
||||
errorText = getContext().getString(R.string.MessageDetailsRecipient_failed_to_send);
|
||||
resendButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
new ResendAsyncTask(masterSecret, record, networkFailure).execute();
|
||||
}
|
||||
});
|
||||
} else if (keyMismatch != null) {
|
||||
|
||||
if (keyMismatch != null) {
|
||||
resendButton.setVisibility(View.GONE);
|
||||
conflictButton.setVisibility(View.VISIBLE);
|
||||
|
||||
errorText = getContext().getString(R.string.MessageDetailsRecipient_new_identity);
|
||||
conflictButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
@ -104,12 +107,24 @@ public class MessageRecipientListItem extends RelativeLayout
|
||||
new ConfirmIdentityDialog(getContext(), masterSecret, record, keyMismatch).show();
|
||||
}
|
||||
});
|
||||
} else if (networkFailure != null || (!isPushGroup && record.isFailed())) {
|
||||
resendButton.setVisibility(View.VISIBLE);
|
||||
conflictButton.setVisibility(View.GONE);
|
||||
|
||||
errorText = getContext().getString(R.string.MessageDetailsRecipient_failed_to_send);
|
||||
resendButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
new ResendAsyncTask(masterSecret, record, networkFailure).execute();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
resendButton.setVisibility(View.GONE);
|
||||
conflictButton.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
errorDescription.setText(errorText);
|
||||
errorDescription.setVisibility(TextUtils.isEmpty(errorText) ? View.GONE : View.VISIBLE);
|
||||
resendButton.setVisibility(networkFailure != null ? View.VISIBLE : View.GONE);
|
||||
conflictButton.setVisibility(keyMismatch != null ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
||||
private NetworkFailure getNetworkFailure(final MessageRecord record) {
|
||||
|
Loading…
Reference in New Issue
Block a user