Show TS group titles properly, hide MMS options

This commit is contained in:
Jake McGinty 2014-02-17 20:25:40 -08:00
parent 54b087c458
commit 877ed8f59c
5 changed files with 72 additions and 54 deletions

View File

@ -6,17 +6,4 @@
android:icon="?menu_group_icon" android:icon="?menu_group_icon"
android:showAsAction="ifRoom" /> android:showAsAction="ifRoom" />
<item android:title="@string/conversation_group_options__delivery"
android:id="@+id/menu_group_delivery"
android:icon="?menu_split_icon"
android:showAsAction="ifRoom" >
<menu>
<group android:id="@+id/distribution_group"
android:checkableBehavior="single">
<item android:id="@+id/menu_distribution_conversation" android:title="@string/conversation_group_options__conversation" android:checked="true" />
<item android:id="@+id/menu_distribution_broadcast" android:title="@string/conversation_group_options__broadcast" />
</group>
</menu>
</item>
</menu> </menu>

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:title="@string/conversation_group_options__delivery"
android:id="@+id/menu_group_delivery"
android:icon="?menu_split_icon"
android:showAsAction="ifRoom" >
<menu>
<group android:id="@+id/distribution_group"
android:checkableBehavior="single">
<item android:id="@+id/menu_distribution_conversation" android:title="@string/conversation_group_options__conversation" android:checked="true" />
<item android:id="@+id/menu_distribution_broadcast" android:title="@string/conversation_group_options__broadcast" />
</group>
</menu>
</item>
</menu>

View File

@ -67,7 +67,8 @@
<string name="ConversationActivity_forward_message_prefix">FWD</string> <string name="ConversationActivity_forward_message_prefix">FWD</string>
<string name="ConversationActivity_group_conversation_recipients">Group Conversation Recipients</string> <string name="ConversationActivity_group_conversation_recipients">Group Conversation Recipients</string>
<string name="ConversationActivity_group_conversation">Group Conversation</string> <string name="ConversationActivity_group_conversation">Group Conversation</string>
<string name="ConversationActivity_d_recipients_in_group">%d recipients in group</string> <string name="ConversationActivity_d_recipients_in_group">%d members</string>
<string name="ConversationActivity_d_recipients_in_group_singular">1 member</string>
<string name="ConversationActivity_saving_draft">Saving draft...</string> <string name="ConversationActivity_saving_draft">Saving draft...</string>
<string name="ConversationActivity_invalid_recipient">Invalid recipient!</string> <string name="ConversationActivity_invalid_recipient">Invalid recipient!</string>
<string name="ConversationActivity_calls_not_supported">Calls Not Supported</string> <string name="ConversationActivity_calls_not_supported">Calls Not Supported</string>

View File

@ -108,6 +108,7 @@ import ws.com.google.android.mms.MmsException;
public class ConversationActivity extends PassphraseRequiredSherlockFragmentActivity public class ConversationActivity extends PassphraseRequiredSherlockFragmentActivity
implements ConversationFragment.ConversationFragmentListener implements ConversationFragment.ConversationFragmentListener
{ {
private static final String TAG = "ConversationActivity";
public static final String RECIPIENTS_EXTRA = "recipients"; public static final String RECIPIENTS_EXTRA = "recipients";
public static final String THREAD_ID_EXTRA = "thread_id"; public static final String THREAD_ID_EXTRA = "thread_id";
@ -117,31 +118,31 @@ public class ConversationActivity extends PassphraseRequiredSherlockFragmentActi
public static final String DRAFT_AUDIO_EXTRA = "draft_audio"; public static final String DRAFT_AUDIO_EXTRA = "draft_audio";
public static final String DISTRIBUTION_TYPE_EXTRA = "distribution_type"; public static final String DISTRIBUTION_TYPE_EXTRA = "distribution_type";
private static final int PICK_CONTACT = 1; private static final int PICK_CONTACT = 1;
private static final int PICK_IMAGE = 2; private static final int PICK_IMAGE = 2;
private static final int PICK_VIDEO = 3; private static final int PICK_VIDEO = 3;
private static final int PICK_AUDIO = 4; private static final int PICK_AUDIO = 4;
private static final int PICK_CONTACT_INFO = 5; private static final int PICK_CONTACT_INFO = 5;
private MasterSecret masterSecret; private MasterSecret masterSecret;
private RecipientsPanel recipientsPanel; private RecipientsPanel recipientsPanel;
private EditText composeText; private EditText composeText;
private ImageButton addContactButton; private ImageButton addContactButton;
private ImageButton sendButton; private ImageButton sendButton;
private TextView charactersLeft; private TextView charactersLeft;
private AttachmentTypeSelectorAdapter attachmentAdapter; private AttachmentTypeSelectorAdapter attachmentAdapter;
private AttachmentManager attachmentManager; private AttachmentManager attachmentManager;
private BroadcastReceiver securityUpdateReceiver; private BroadcastReceiver securityUpdateReceiver;
private EmojiDrawer emojiDrawer; private EmojiDrawer emojiDrawer;
private EmojiToggle emojiToggle; private EmojiToggle emojiToggle;
private Recipients recipients; private Recipients recipients;
private long threadId; private long threadId;
private int distributionType; private int distributionType;
private boolean isEncryptedConversation; private boolean isEncryptedConversation;
private boolean isAuthenticatedConversation; private boolean isAuthenticatedConversation;
private boolean isMmsEnabled = true; private boolean isMmsEnabled = true;
private CharacterCalculator characterCalculator = new CharacterCalculator(); private CharacterCalculator characterCalculator = new CharacterCalculator();
private DynamicTheme dynamicTheme = new DynamicTheme(); private DynamicTheme dynamicTheme = new DynamicTheme();
@ -210,7 +211,7 @@ public class ConversationActivity extends PassphraseRequiredSherlockFragmentActi
case PICK_CONTACT: case PICK_CONTACT:
Recipients recipients = data.getParcelableExtra("recipients"); Recipients recipients = data.getParcelableExtra("recipients");
if (recipients != null) if (recipients != null)
recipientsPanel.addRecipients(recipients); recipientsPanel.addRecipients(recipients);
break; break;
case PICK_IMAGE: case PICK_IMAGE:
addAttachmentImage(data.getData()); addAttachmentImage(data.getData());
@ -232,8 +233,7 @@ public class ConversationActivity extends PassphraseRequiredSherlockFragmentActi
MenuInflater inflater = this.getSupportMenuInflater(); MenuInflater inflater = this.getSupportMenuInflater();
menu.clear(); menu.clear();
if (isSingleConversation() && isEncryptedConversation) if (isSingleConversation() && isEncryptedConversation) {
{
if (isAuthenticatedConversation) { if (isAuthenticatedConversation) {
inflater.inflate(R.menu.conversation_secure_identity, menu); inflater.inflate(R.menu.conversation_secure_identity, menu);
} else { } else {
@ -248,11 +248,13 @@ public class ConversationActivity extends PassphraseRequiredSherlockFragmentActi
} else if (isGroupConversation()) { } else if (isGroupConversation()) {
inflater.inflate(R.menu.conversation_group_options, menu); inflater.inflate(R.menu.conversation_group_options, menu);
if (distributionType == ThreadDatabase.DistributionTypes.BROADCAST) if (!isPushGroupConversation()) {
{ inflater.inflate(R.menu.conversation_mms_group_options, menu);
menu.findItem(R.id.menu_distribution_broadcast).setChecked(true); if (distributionType == ThreadDatabase.DistributionTypes.BROADCAST) {
} else { menu.findItem(R.id.menu_distribution_broadcast).setChecked(true);
menu.findItem(R.id.menu_distribution_conversation).setChecked(true); } else {
menu.findItem(R.id.menu_distribution_conversation).setChecked(true);
}
} }
} }
@ -282,7 +284,7 @@ public class ConversationActivity extends PassphraseRequiredSherlockFragmentActi
} }
@Override @Override
public void onCreateContextMenu (ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
if (isEncryptedConversation) { if (isEncryptedConversation) {
android.view.MenuInflater inflater = getMenuInflater(); android.view.MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.conversation_button_context, menu); inflater.inflate(R.menu.conversation_button_context, menu);
@ -412,7 +414,7 @@ public class ConversationActivity extends PassphraseRequiredSherlockFragmentActi
Uri.parse("tel:" + recipient.getNumber())); Uri.parse("tel:" + recipient.getNumber()));
startActivity(dialIntent); startActivity(dialIntent);
} catch (ActivityNotFoundException anfe) { } catch (ActivityNotFoundException anfe) {
Log.w("ConversationActivity", anfe); Log.w(TAG, anfe);
Util.showAlertDialog(this, Util.showAlertDialog(this,
getString(R.string.ConversationActivity_calls_not_supported), getString(R.string.ConversationActivity_calls_not_supported),
getString(R.string.ConversationActivity_this_device_does_not_appear_to_support_dial_actions)); getString(R.string.ConversationActivity_this_device_does_not_appear_to_support_dial_actions));
@ -483,9 +485,17 @@ public class ConversationActivity extends PassphraseRequiredSherlockFragmentActi
subtitle = getRecipients().getPrimaryRecipient().getNumber(); subtitle = getRecipients().getPrimaryRecipient().getNumber();
} }
} else if (isGroupConversation()) { } else if (isGroupConversation()) {
title = getString(R.string.ConversationActivity_group_conversation); if (isPushGroupConversation()) {
subtitle = String.format(getString(R.string.ConversationActivity_d_recipients_in_group), Log.i(TAG, "name: " + getRecipients().getPrimaryRecipient().getName() + ", number: " + getRecipients().getPrimaryRecipient().getNumber() + ", avatar?: " + (getRecipients().getPrimaryRecipient().getContactPhoto() != null));
getRecipients().getRecipientsList().size()); title = getRecipients().getPrimaryRecipient().getName();
}
else {
title = getString(R.string.ConversationActivity_group_conversation);
}
int size = getRecipients().getRecipientsList().size();
subtitle = (size == 1) ? getString(R.string.ConversationActivity_d_recipients_in_group_singular)
: String.format(getString(R.string.ConversationActivity_d_recipients_in_group),
getRecipients().getRecipientsList().size());
} else { } else {
title = getString(R.string.ConversationActivity_compose_message); title = getString(R.string.ConversationActivity_compose_message);
subtitle = ""; subtitle = "";
@ -680,12 +690,12 @@ public class ConversationActivity extends PassphraseRequiredSherlockFragmentActi
try { try {
attachmentManager.setImage(imageUri); attachmentManager.setImage(imageUri);
} catch (IOException e) { } catch (IOException e) {
Log.w("ConversationActivity", e); Log.w(TAG, e);
attachmentManager.clear(); attachmentManager.clear();
Toast.makeText(this, R.string.ConversationActivity_sorry_there_was_an_error_setting_your_attachment, Toast.makeText(this, R.string.ConversationActivity_sorry_there_was_an_error_setting_your_attachment,
Toast.LENGTH_LONG).show(); Toast.LENGTH_LONG).show();
} catch (BitmapDecodingException e) { } catch (BitmapDecodingException e) {
Log.w("ConversationActivity", e); Log.w(TAG, e);
attachmentManager.clear(); attachmentManager.clear();
Toast.makeText(this, R.string.ConversationActivity_sorry_there_was_an_error_setting_your_attachment, Toast.makeText(this, R.string.ConversationActivity_sorry_there_was_an_error_setting_your_attachment,
Toast.LENGTH_LONG).show(); Toast.LENGTH_LONG).show();
@ -823,12 +833,16 @@ public class ConversationActivity extends PassphraseRequiredSherlockFragmentActi
(!getRecipients().isSingleRecipient() || getRecipients().isGroupRecipient()); (!getRecipients().isSingleRecipient() || getRecipients().isGroupRecipient());
} }
private boolean isPushGroupConversation() {
return getRecipients().isGroupRecipient();
}
private Recipients getRecipients() { private Recipients getRecipients() {
try { try {
if (isExistingConversation()) return this.recipients; if (isExistingConversation()) return this.recipients;
else return recipientsPanel.getRecipients(); else return recipientsPanel.getRecipients();
} catch (RecipientFormattingException rfe) { } catch (RecipientFormattingException rfe) {
Log.d("ConversationActivity", "Empty list of recipients retrieved from RecipientsPanel."); Log.d(TAG, "Empty list of recipients retrieved from RecipientsPanel.");
return null; return null;
} }
} }
@ -907,7 +921,7 @@ public class ConversationActivity extends PassphraseRequiredSherlockFragmentActi
message = new OutgoingTextMessage(recipients, body); message = new OutgoingTextMessage(recipients, body);
} }
Log.w("ConversationActivity", "Sending message..."); Log.w(TAG, "Sending message...");
allocatedThreadId = MessageSender.send(ConversationActivity.this, masterSecret, allocatedThreadId = MessageSender.send(ConversationActivity.this, masterSecret,
message, threadId); message, threadId);
} }
@ -916,13 +930,13 @@ public class ConversationActivity extends PassphraseRequiredSherlockFragmentActi
Toast.makeText(ConversationActivity.this, Toast.makeText(ConversationActivity.this,
R.string.ConversationActivity_recipient_is_not_a_valid_sms_or_email_address_exclamation, R.string.ConversationActivity_recipient_is_not_a_valid_sms_or_email_address_exclamation,
Toast.LENGTH_LONG).show(); Toast.LENGTH_LONG).show();
Log.w("ConversationActivity", ex); Log.w(TAG, ex);
} catch (InvalidMessageException ex) { } catch (InvalidMessageException ex) {
Toast.makeText(ConversationActivity.this, R.string.ConversationActivity_message_is_empty_exclamation, Toast.makeText(ConversationActivity.this, R.string.ConversationActivity_message_is_empty_exclamation,
Toast.LENGTH_SHORT).show(); Toast.LENGTH_SHORT).show();
Log.w("ConversationActivity", ex); Log.w(TAG, ex);
} catch (MmsException e) { } catch (MmsException e) {
Log.w("ComposeMessageActivity", e); Log.w(TAG, e);
} }
} }

View File

@ -1,7 +1,6 @@
package org.thoughtcrime.securesms.util; package org.thoughtcrime.securesms.util;
import android.util.Log; import android.util.Log;
import android.util.Pair;
import com.google.protobuf.ByteString; import com.google.protobuf.ByteString;