|
|
|
@ -34,8 +34,11 @@ import android.provider.ContactsContract;
|
|
|
|
|
import android.telephony.PhoneNumberUtils;
|
|
|
|
|
import android.text.Editable;
|
|
|
|
|
import android.text.InputType;
|
|
|
|
|
import android.text.Spannable;
|
|
|
|
|
import android.text.SpannableString;
|
|
|
|
|
import android.text.TextUtils;
|
|
|
|
|
import android.text.TextWatcher;
|
|
|
|
|
import android.text.style.RelativeSizeSpan;
|
|
|
|
|
import android.util.Log;
|
|
|
|
|
import android.view.ContextMenu;
|
|
|
|
|
import android.view.ContextThemeWrapper;
|
|
|
|
@ -125,7 +128,8 @@ import static org.whispersystems.textsecure.push.PushMessageProtos.PushMessageCo
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
public class ConversationActivity extends PassphraseRequiredSherlockFragmentActivity
|
|
|
|
|
implements ConversationFragment.ConversationFragmentListener
|
|
|
|
|
implements ConversationFragment.ConversationFragmentListener,
|
|
|
|
|
AttachmentManager.AttachmentListener
|
|
|
|
|
{
|
|
|
|
|
private static final String TAG = ConversationActivity.class.getSimpleName();
|
|
|
|
|
|
|
|
|
@ -199,6 +203,7 @@ public class ConversationActivity extends PassphraseRequiredSherlockFragmentActi
|
|
|
|
|
dynamicLanguage.onResume(this);
|
|
|
|
|
|
|
|
|
|
initializeSecurity();
|
|
|
|
|
initializeScreenshotSecurity();
|
|
|
|
|
initializeTitleBar();
|
|
|
|
|
initializeEnabledCheck();
|
|
|
|
|
initializeMmsEnabledCheck();
|
|
|
|
@ -681,28 +686,40 @@ public class ConversationActivity extends PassphraseRequiredSherlockFragmentActi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void initializeSecurity() {
|
|
|
|
|
TypedArray drawables = obtainStyledAttributes(SEND_ATTRIBUTES);
|
|
|
|
|
boolean isPushDestination = DirectoryHelper.isPushDestination(this, getRecipients());
|
|
|
|
|
Recipient primaryRecipient = getRecipients() == null ? null : getRecipients().getPrimaryRecipient();
|
|
|
|
|
TypedArray drawables = obtainStyledAttributes(SEND_ATTRIBUTES);
|
|
|
|
|
Recipient primaryRecipient = getRecipients() == null ? null : getRecipients().getPrimaryRecipient();
|
|
|
|
|
boolean isPushDestination = DirectoryHelper.isPushDestination(this, getRecipients());
|
|
|
|
|
boolean isSecureDestination = isSingleConversation() && Session.hasSession(this, masterSecret, primaryRecipient);
|
|
|
|
|
|
|
|
|
|
if (isPushDestination ||
|
|
|
|
|
(isSingleConversation() && Session.hasSession(this, masterSecret, primaryRecipient)))
|
|
|
|
|
{
|
|
|
|
|
if (isPushDestination || isSecureDestination) {
|
|
|
|
|
this.isEncryptedConversation = true;
|
|
|
|
|
this.characterCalculator = new EncryptedCharacterCalculator();
|
|
|
|
|
|
|
|
|
|
if (isPushDestination) sendButton.setImageDrawable(drawables.getDrawable(0));
|
|
|
|
|
else sendButton.setImageDrawable(drawables.getDrawable(1));
|
|
|
|
|
} else {
|
|
|
|
|
this.isEncryptedConversation = false;
|
|
|
|
|
this.characterCalculator = new CharacterCalculator();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isPushDestination) {
|
|
|
|
|
sendButton.setImageDrawable(drawables.getDrawable(0));
|
|
|
|
|
setComposeTextHint(getString(R.string.conversation_activity__type_message_push));
|
|
|
|
|
} else if (isSecureDestination) {
|
|
|
|
|
sendButton.setImageDrawable(drawables.getDrawable(1));
|
|
|
|
|
setComposeTextHint(attachmentManager.isAttachmentPresent() ?
|
|
|
|
|
getString(R.string.conversation_activity__type_message_mms_secure) :
|
|
|
|
|
getString(R.string.conversation_activity__type_message_sms_secure));
|
|
|
|
|
} else {
|
|
|
|
|
sendButton.setImageDrawable(drawables.getDrawable(2));
|
|
|
|
|
setComposeTextHint((attachmentManager.isAttachmentPresent() || !recipients.isSingleRecipient()) ?
|
|
|
|
|
getString(R.string.conversation_activity__type_message_mms_insecure) :
|
|
|
|
|
getString(R.string.conversation_activity__type_message_sms_insecure));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
drawables.recycle();
|
|
|
|
|
|
|
|
|
|
calculateCharactersRemaining();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void initializeScreenshotSecurity() {
|
|
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
|
|
|
|
|
if (TextSecurePreferences.isScreenSecurityEnabled(this)) {
|
|
|
|
|
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
|
|
|
|
@ -751,7 +768,7 @@ public class ConversationActivity extends PassphraseRequiredSherlockFragmentActi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
attachmentAdapter = new AttachmentTypeSelectorAdapter(this);
|
|
|
|
|
attachmentManager = new AttachmentManager(this);
|
|
|
|
|
attachmentManager = new AttachmentManager(this, this);
|
|
|
|
|
|
|
|
|
|
SendButtonListener sendButtonListener = new SendButtonListener();
|
|
|
|
|
ComposeKeyPressedListener composeKeyPressedListener = new ComposeKeyPressedListener();
|
|
|
|
@ -1182,4 +1199,18 @@ public class ConversationActivity extends PassphraseRequiredSherlockFragmentActi
|
|
|
|
|
this.composeText.setText(text);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void setComposeTextHint(String hint){
|
|
|
|
|
if (hint == null) {
|
|
|
|
|
this.composeText.setHint(null);
|
|
|
|
|
} else {
|
|
|
|
|
SpannableString span = new SpannableString(hint);
|
|
|
|
|
span.setSpan(new RelativeSizeSpan(0.8f), 0, hint.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
|
|
|
|
|
this.composeText.setHint(span);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onAttachmentChanged() {
|
|
|
|
|
initializeSecurity();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|