mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-24 00:37:47 +00:00
Add preview of encryption channel in compose text hint.
This commit is contained in:
parent
359fe280e8
commit
ea0fa58265
@ -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"
|
||||
|
@ -441,7 +441,11 @@
|
||||
<string name="contact_selection_recent_activity__no_recent_calls">No recent calls.</string>
|
||||
|
||||
<!-- conversation_activity -->
|
||||
<string name="conversation_activity__type_message"><small>Send a message</small></string>
|
||||
<string name="conversation_activity__type_message_push">Send TextSecure message</string>
|
||||
<string name="conversation_activity__type_message_sms_secure">Send secure SMS</string>
|
||||
<string name="conversation_activity__type_message_sms_insecure">Send insecure SMS</string>
|
||||
<string name="conversation_activity__type_message_mms_secure">Send secure MMS</string>
|
||||
<string name="conversation_activity__type_message_mms_insecure">Send insecure MMS</string>
|
||||
<string name="conversation_activity__send">Send</string>
|
||||
<string name="conversation_activity__remove">Remove</string>
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user