@ -34,7 +34,6 @@ import org.thoughtcrime.securesms.database.documents.IdentityKeyMismatch;
import org.thoughtcrime.securesms.database.documents.NetworkFailure ;
import org.thoughtcrime.securesms.database.documents.NetworkFailure ;
import org.thoughtcrime.securesms.database.model.MessageRecord ;
import org.thoughtcrime.securesms.database.model.MessageRecord ;
import org.thoughtcrime.securesms.recipients.Recipient ;
import org.thoughtcrime.securesms.recipients.Recipient ;
import org.thoughtcrime.securesms.recipients.Recipients ;
import org.thoughtcrime.securesms.sms.MessageSender ;
import org.thoughtcrime.securesms.sms.MessageSender ;
import org.thoughtcrime.securesms.util.RecipientViewUtil ;
import org.thoughtcrime.securesms.util.RecipientViewUtil ;
@ -74,42 +73,58 @@ public class MessageRecipientListItem extends RelativeLayout
this . resendButton = ( Button ) findViewById ( R . id . resend_button ) ;
this . resendButton = ( Button ) findViewById ( R . id . resend_button ) ;
}
}
public void set ( final MasterSecret masterSecret , final MessageRecord record , final Recipients recipients , final int position ) {
public void set ( final MasterSecret masterSecret ,
recipient = recipients . getRecipientsList ( ) . get ( position ) ;
final MessageRecord record ,
final Recipient recipient ,
final boolean isPushGroup )
{
this . recipient = recipient ;
recipient . addListener ( this ) ;
recipient . addListener ( this ) ;
fromView . setText ( RecipientViewUtil . formatFrom ( getContext ( ) , recipient ) ) ;
fromView . setText ( RecipientViewUtil . formatFrom ( getContext ( ) , recipient ) ) ;
RecipientViewUtil . setContactPhoto ( getContext ( ) , contactPhotoImage , recipient , false ) ;
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 NetworkFailure networkFailure = getNetworkFailure ( record ) ;
final IdentityKeyMismatch keyMismatch = networkFailure = = null ? getKeyMismatch ( record ) : null ;
final IdentityKeyMismatch keyMismatch = networkFailure = = null ? getKeyMismatch ( record ) : null ;
String errorText = "" ;
String errorText = "" ;
if ( networkFailure ! = null ) {
errorText = getContext ( ) . getString ( R . string . MessageDetailsRecipient_failed_to_send ) ;
if ( keyMismatch ! = null ) {
resendButton . setOnClickListener ( new OnClickListener ( ) {
resendButton . setVisibility ( View . GONE ) ;
conflictButton . setVisibility ( View . VISIBLE ) ;
errorText = getContext ( ) . getString ( R . string . MessageDetailsRecipient_new_identity ) ;
conflictButton . setOnClickListener ( new OnClickListener ( ) {
@Override
@Override
public void onClick ( View v ) {
public void onClick ( View v ) {
new ResendAsyncTask ( masterSecret , record , networkFailure ) . execute ( ) ;
new ConfirmIdentityDialog( getContext ( ) , masterSecret , record , keyMismatch ) . show ( ) ;
}
}
} ) ;
} ) ;
} else if ( keyMismatch ! = null ) {
} else if ( networkFailure ! = null | | ( ! isPushGroup & & record . isFailed ( ) ) ) {
errorText = getContext ( ) . getString ( R . string . MessageDetailsRecipient_new_identity ) ;
resendButton . setVisibility ( View . VISIBLE ) ;
conflictButton . setOnClickListener ( new OnClickListener ( ) {
conflictButton . setVisibility ( View . GONE ) ;
errorText = getContext ( ) . getString ( R . string . MessageDetailsRecipient_failed_to_send ) ;
resendButton . setOnClickListener ( new OnClickListener ( ) {
@Override
@Override
public void onClick ( View v ) {
public void onClick ( View v ) {
new ConfirmIdentityDialog ( getContext ( ) , masterSecret , record , keyMismatch ) . show ( ) ;
new ResendAsyncTask( masterSecret , record , networkFailure ) . execute ( ) ;
}
}
} ) ;
} ) ;
} else {
resendButton . setVisibility ( View . GONE ) ;
conflictButton . setVisibility ( View . GONE ) ;
}
}
errorDescription . setText ( errorText ) ;
errorDescription . setText ( errorText ) ;
errorDescription . setVisibility ( TextUtils . isEmpty ( errorText ) ? View . GONE : View . VISIBLE ) ;
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 ) {
private NetworkFailure getNetworkFailure ( final MessageRecord record ) {