diff --git a/res/layout/conversation_activity.xml b/res/layout/conversation_activity.xml
index 0057771baf..94600c89b1 100644
--- a/res/layout/conversation_activity.xml
+++ b/res/layout/conversation_activity.xml
@@ -88,7 +88,6 @@
android:background="#00ffffff"
android:padding="12dp"
android:paddingRight="0dp"
- android:hint="@string/conversation_activity__type_message"
android:imeOptions="actionSend|flagNoEnterAction"
android:inputType="textShortMessage|textAutoCorrect|textCapSentences|textMultiLine"
android:maxLength="1000"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index d57c71c72e..ec4d293fd8 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -441,7 +441,11 @@
No recent calls.
- Send a message
+ Send TextSecure message
+ Send secure SMS
+ Send insecure SMS
+ Send secure MMS
+ Send insecure MMS
Send
Remove
diff --git a/src/org/thoughtcrime/securesms/ConversationActivity.java b/src/org/thoughtcrime/securesms/ConversationActivity.java
index 691fb7e15a..e6a6257a37 100644
--- a/src/org/thoughtcrime/securesms/ConversationActivity.java
+++ b/src/org/thoughtcrime/securesms/ConversationActivity.java
@@ -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();
+ }
}
diff --git a/src/org/thoughtcrime/securesms/mms/AttachmentManager.java b/src/org/thoughtcrime/securesms/mms/AttachmentManager.java
index b80aa94464..d1dedc6fb5 100644
--- a/src/org/thoughtcrime/securesms/mms/AttachmentManager.java
+++ b/src/org/thoughtcrime/securesms/mms/AttachmentManager.java
@@ -37,13 +37,15 @@ public class AttachmentManager {
private final ImageView thumbnail;
private final Button removeButton;
private final SlideDeck slideDeck;
+ private final AttachmentListener attachmentListener;
- public AttachmentManager(Activity view) {
- this.attachmentView = (View)view.findViewById(R.id.attachment_editor);
- this.thumbnail = (ImageView)view.findViewById(R.id.attachment_thumbnail);
- this.removeButton = (Button)view.findViewById(R.id.remove_image_button);
- this.slideDeck = new SlideDeck();
- this.context = view;
+ public AttachmentManager(Activity view, AttachmentListener listener) {
+ this.attachmentView = (View)view.findViewById(R.id.attachment_editor);
+ this.thumbnail = (ImageView)view.findViewById(R.id.attachment_thumbnail);
+ this.removeButton = (Button)view.findViewById(R.id.remove_image_button);
+ this.slideDeck = new SlideDeck();
+ this.context = view;
+ this.attachmentListener = listener;
this.removeButton.setOnClickListener(new RemoveButtonListener());
}
@@ -51,6 +53,7 @@ public class AttachmentManager {
public void clear() {
slideDeck.clear();
attachmentView.setVisibility(View.GONE);
+ attachmentListener.onAttachmentChanged();
}
public void setImage(Uri image) throws IOException, BitmapDecodingException {
@@ -58,6 +61,7 @@ public class AttachmentManager {
slideDeck.addSlide(slide);
thumbnail.setImageDrawable(slide.getThumbnail(345, 261));
attachmentView.setVisibility(View.VISIBLE);
+ attachmentListener.onAttachmentChanged();
}
public void setVideo(Uri video) throws IOException, MediaTooLargeException {
@@ -65,6 +69,7 @@ public class AttachmentManager {
slideDeck.addSlide(slide);
thumbnail.setImageDrawable(slide.getThumbnail(thumbnail.getWidth(), thumbnail.getHeight()));
attachmentView.setVisibility(View.VISIBLE);
+ attachmentListener.onAttachmentChanged();
}
public void setAudio(Uri audio)throws IOException, MediaTooLargeException {
@@ -72,6 +77,7 @@ public class AttachmentManager {
slideDeck.addSlide(slide);
thumbnail.setImageDrawable(slide.getThumbnail(thumbnail.getWidth(), thumbnail.getHeight()));
attachmentView.setVisibility(View.VISIBLE);
+ attachmentListener.onAttachmentChanged();
}
public boolean isAttachmentPresent() {
@@ -114,4 +120,7 @@ public class AttachmentManager {
}
}
+ public interface AttachmentListener {
+ public void onAttachmentChanged();
+ }
}