mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-27 12:05:22 +00:00
parent
90d5e9dccd
commit
12b8eee86f
@ -29,7 +29,6 @@ import android.graphics.Color;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuff.Mode;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.Bitmap;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
@ -55,7 +54,6 @@ import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.TextView;
|
||||
import android.widget.TextView.OnEditorActionListener;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.afollestad.materialdialogs.AlertDialogWrapper;
|
||||
@ -247,7 +245,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
initializeSecurity();
|
||||
initializeEnabledCheck();
|
||||
initializeMmsEnabledCheck();
|
||||
initializeIme();
|
||||
composeText.setTransport(sendButton.getSelectedTransport());
|
||||
|
||||
titleView.setTitle(recipients);
|
||||
setActionBarColor(recipients.getColor());
|
||||
@ -268,6 +266,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
|
||||
@Override public void onConfigurationChanged(Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
composeText.setTransport(sendButton.getSelectedTransport());
|
||||
quickAttachmentDrawer.onConfigurationChanged();
|
||||
hideEmojiDrawer(false);
|
||||
}
|
||||
@ -758,25 +757,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
}.execute();
|
||||
}
|
||||
|
||||
private void initializeIme() {
|
||||
if (TextSecurePreferences.isEnterSendsEnabled(this)) {
|
||||
composeText.setInputType (composeText.getInputType() & ~InputType.TYPE_TEXT_FLAG_MULTI_LINE);
|
||||
composeText.setImeOptions(composeText.getImeOptions() & ~EditorInfo.IME_FLAG_NO_ENTER_ACTION);
|
||||
} else {
|
||||
composeText.setInputType (composeText.getInputType() | InputType.TYPE_TEXT_FLAG_MULTI_LINE);
|
||||
composeText.setImeOptions(composeText.getImeOptions() | EditorInfo.IME_FLAG_NO_ENTER_ACTION);
|
||||
}
|
||||
composeText.setOnEditorActionListener(new OnEditorActionListener() {
|
||||
@Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||
if (actionId == EditorInfo.IME_ACTION_SEND) {
|
||||
sendMessage();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initializeViews() {
|
||||
titleView = (ConversationTitleView) getSupportActionBar().getCustomView();
|
||||
buttonToggle = (AnimatingToggle) findViewById(R.id.button_toggle);
|
||||
@ -816,6 +796,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
SendButtonListener sendButtonListener = new SendButtonListener();
|
||||
ComposeKeyPressedListener composeKeyPressedListener = new ComposeKeyPressedListener();
|
||||
|
||||
composeText.setOnEditorActionListener(sendButtonListener);
|
||||
attachButton.setOnClickListener(new AttachButtonListener());
|
||||
sendButton.setOnClickListener(sendButtonListener);
|
||||
sendButton.setEnabled(true);
|
||||
@ -823,9 +804,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
@Override
|
||||
public void onChange(TransportOption newTransport) {
|
||||
calculateCharactersRemaining();
|
||||
composeText.setHint(newTransport.getComposeHint());
|
||||
composeText.setImeActionLabel(newTransport.getComposeHint(), EditorInfo.IME_ACTION_SEND);
|
||||
composeText.setInputType(composeText.getInputType());
|
||||
composeText.setTransport(newTransport);
|
||||
buttonToggle.getBackground().setColorFilter(newTransport.getBackgroundColor(), Mode.MULTIPLY);
|
||||
}
|
||||
});
|
||||
|
@ -1,16 +1,20 @@
|
||||
package org.thoughtcrime.securesms.components;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v7.widget.AppCompatEditText;
|
||||
import android.text.InputType;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextUtils.TruncateAt;
|
||||
import android.text.style.RelativeSizeSpan;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
|
||||
import org.thoughtcrime.securesms.TransportOption;
|
||||
import org.thoughtcrime.securesms.components.emoji.EmojiEditText;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
|
||||
public class ComposeText extends EmojiEditText {
|
||||
public ComposeText(Context context) {
|
||||
@ -48,4 +52,30 @@ public class ComposeText extends EmojiEditText {
|
||||
|
||||
append(invite);
|
||||
}
|
||||
|
||||
private boolean isLandscape() {
|
||||
return getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
|
||||
}
|
||||
|
||||
public void setTransport(TransportOption transport) {
|
||||
final boolean enterSends = TextSecurePreferences.isEnterSendsEnabled(getContext());
|
||||
|
||||
int imeOptions = (getImeOptions() & ~EditorInfo.IME_MASK_ACTION) | EditorInfo.IME_ACTION_SEND;
|
||||
int inputType = getInputType();
|
||||
|
||||
if (isLandscape()) setImeActionLabel(transport.getComposeHint(), EditorInfo.IME_ACTION_SEND);
|
||||
else setImeActionLabel(null, 0);
|
||||
|
||||
inputType = !isLandscape() && enterSends
|
||||
? inputType & ~InputType.TYPE_TEXT_FLAG_MULTI_LINE
|
||||
: inputType | InputType.TYPE_TEXT_FLAG_MULTI_LINE;
|
||||
|
||||
imeOptions = enterSends
|
||||
? imeOptions & ~EditorInfo.IME_FLAG_NO_ENTER_ACTION
|
||||
: imeOptions | EditorInfo.IME_FLAG_NO_ENTER_ACTION;
|
||||
|
||||
setInputType(inputType);
|
||||
setImeOptions(imeOptions);
|
||||
setHint(transport.getComposeHint());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user