Correctly display call actions in thread list

Fixes #4170
// FREEBIE
This commit is contained in:
Moxie Marlinspike 2015-10-01 16:48:57 -07:00
parent a7348f6ae0
commit 77d73fa572
4 changed files with 25 additions and 11 deletions

View file

@ -290,6 +290,10 @@
<string name="MessageRecord_message_encrypted_with_a_legacy_protocol_version_that_is_no_longer_supported">Received a message encrypted using an old version of Signal that is no longer supported. Please ask the sender to upgrade to the most recent version and resend the message.</string>
<string name="MessageRecord_left_group">You have left the group.</string>
<string name="MessageRecord_updated_group">Updated the group.</string>
<string name="MessageRecord_s_called_you">%s called you</string>
<string name="MessageRecord_called_s">Called %s</string>
<string name="MessageRecord_missed_call_from">Missed call from %s</string>
<!-- PassphraseChangeActivity -->
<string name="PassphraseChangeActivity_passphrases_dont_match_exclamation">Passphrases don\'t match!</string>

View file

@ -116,11 +116,11 @@ public abstract class MessageRecord extends DisplayRecord {
} else if (isGroupQuit()) {
return emphasisAdded(context.getString(R.string.ConversationItem_group_action_left, getIndividualRecipient().toShortString()));
} else if (isIncomingCall()) {
return emphasisAdded(String.format("%s called you", getIndividualRecipient().toShortString()));
return emphasisAdded(context.getString(R.string.MessageRecord_s_called_you, getIndividualRecipient().toShortString()));
} else if (isOutgoingCall()) {
return emphasisAdded(String.format("Called %s", getIndividualRecipient().toShortString()));
return emphasisAdded(context.getString(R.string.MessageRecord_called_s, getIndividualRecipient().toShortString()));
} else if (isMissedCall()) {
return emphasisAdded(String.format("Missed call from %s", getIndividualRecipient().toShortString()));
return emphasisAdded(context.getString(R.string.MessageRecord_missed_call_from, getIndividualRecipient().toShortString()));
} else if (getBody().getBody().length() > MAX_DISPLAY_LENGTH) {
return new SpannableString(getBody().getBody().substring(0, MAX_DISPLAY_LENGTH));
}

View file

@ -75,6 +75,12 @@ public class ThreadRecord extends DisplayRecord {
} else if (MmsSmsColumns.Types.isDraftMessageType(type)) {
String draftText = context.getString(R.string.ThreadRecord_draft);
return emphasisAdded(draftText + " " + getBody().getBody(), 0, draftText.length());
} else if (SmsDatabase.Types.isOutgoingCall(type)) {
return emphasisAdded(context.getString(R.string.MessageRecord_called_s, getRecipients().getPrimaryRecipient().getName()));
} else if (SmsDatabase.Types.isIncomingCall(type)) {
return emphasisAdded(context.getString(R.string.MessageRecord_s_called_you, getRecipients().getPrimaryRecipient().getName()));
} else if (SmsDatabase.Types.isMissedCall(type)) {
return emphasisAdded(context.getString(R.string.MessageRecord_missed_call_from, getRecipients().getPrimaryRecipient().getName()));
} else {
if (TextUtils.isEmpty(getBody().getBody())) {
return new SpannableString(context.getString(R.string.MessageNotifier_no_subject));

View file

@ -33,8 +33,6 @@ import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.widget.Toast;
import junit.framework.Assert;
import org.thoughtcrime.securesms.R;
import org.thoughtcrime.securesms.components.ThumbnailView;
import org.thoughtcrime.securesms.crypto.MasterSecret;
@ -69,9 +67,12 @@ public class AttachmentManager {
AlphaAnimation animation = new AlphaAnimation(1.0f, 0.0f);
animation.setDuration(200);
animation.setAnimationListener(new Animation.AnimationListener() {
@Override public void onAnimationStart(Animation animation) {}
@Override public void onAnimationRepeat(Animation animation) {}
@Override public void onAnimationEnd(Animation animation) {
@Override
public void onAnimationStart(Animation animation) {}
@Override
public void onAnimationRepeat(Animation animation) {}
@Override
public void onAnimationEnd(Animation animation) {
slideDeck.clear();
thumbnail.clear();
attachmentView.setVisibility(View.GONE);
@ -94,7 +95,8 @@ public class AttachmentManager {
final boolean isCapture)
{
new AsyncTask<Void, Void, Slide>() {
@Override protected void onPreExecute() {
@Override
protected void onPreExecute() {
slideDeck.clear();
thumbnail.clear();
thumbnail.showProgressSpinner();
@ -104,7 +106,8 @@ public class AttachmentManager {
if (!uri.equals(captureUri)) cleanup();
}
@Override protected @Nullable Slide doInBackground(Void... params) {
@Override
protected @Nullable Slide doInBackground(Void... params) {
long start = System.currentTimeMillis();
try {
final long mediaSize = MediaUtil.getMediaSize(context, masterSecret, uri);
@ -117,7 +120,8 @@ public class AttachmentManager {
}
}
@Override protected void onPostExecute(@Nullable final Slide slide) {
@Override
protected void onPostExecute(@Nullable final Slide slide) {
if (slide == null) {
attachmentView.setVisibility(View.GONE);
Toast.makeText(context,