Add option to swap enter/emoticon key
This commit is contained in:
parent
a88824bb1d
commit
0a96bec3c1
|
@ -15,6 +15,7 @@ import android.os.SystemClock;
|
||||||
import android.provider.MediaStore;
|
import android.provider.MediaStore;
|
||||||
import android.support.v4.widget.SlidingPaneLayout;
|
import android.support.v4.widget.SlidingPaneLayout;
|
||||||
import android.support.v4.widget.SlidingPaneLayout.PanelSlideListener;
|
import android.support.v4.widget.SlidingPaneLayout.PanelSlideListener;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -32,6 +33,7 @@ import net.java.otr4j.session.SessionStatus;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import eu.siacs.conversations.Config;
|
||||||
import eu.siacs.conversations.R;
|
import eu.siacs.conversations.R;
|
||||||
import eu.siacs.conversations.entities.Account;
|
import eu.siacs.conversations.entities.Account;
|
||||||
import eu.siacs.conversations.entities.Blockable;
|
import eu.siacs.conversations.entities.Blockable;
|
||||||
|
@ -133,7 +135,7 @@ public class ConversationActivity extends XmppActivity
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(final Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
if (savedInstanceState != null) {mOpenConverstaion = savedInstanceState.getString(
|
if (savedInstanceState != null) {mOpenConverstaion = savedInstanceState.getString(
|
||||||
STATE_OPEN_CONVERSATION, null);
|
STATE_OPEN_CONVERSATION, null);
|
||||||
|
@ -536,25 +538,25 @@ public class ConversationActivity extends XmppActivity
|
||||||
}
|
}
|
||||||
attachFilePopup.setOnMenuItemClickListener(new OnMenuItemClickListener() {
|
attachFilePopup.setOnMenuItemClickListener(new OnMenuItemClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onMenuItemClick(MenuItem item) {
|
public boolean onMenuItemClick(MenuItem item) {
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case R.id.attach_choose_picture:
|
case R.id.attach_choose_picture:
|
||||||
attachFile(ATTACHMENT_CHOICE_CHOOSE_IMAGE);
|
attachFile(ATTACHMENT_CHOICE_CHOOSE_IMAGE);
|
||||||
break;
|
break;
|
||||||
case R.id.attach_take_picture:
|
case R.id.attach_take_picture:
|
||||||
attachFile(ATTACHMENT_CHOICE_TAKE_PHOTO);
|
attachFile(ATTACHMENT_CHOICE_TAKE_PHOTO);
|
||||||
break;
|
break;
|
||||||
case R.id.attach_choose_file:
|
case R.id.attach_choose_file:
|
||||||
attachFile(ATTACHMENT_CHOICE_CHOOSE_FILE);
|
attachFile(ATTACHMENT_CHOICE_CHOOSE_FILE);
|
||||||
break;
|
break;
|
||||||
case R.id.attach_record_voice:
|
case R.id.attach_record_voice:
|
||||||
attachFile(ATTACHMENT_CHOICE_RECORD_VOICE);
|
attachFile(ATTACHMENT_CHOICE_RECORD_VOICE);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
});
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
attachFilePopup.show();
|
attachFilePopup.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -750,8 +752,9 @@ public class ConversationActivity extends XmppActivity
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
int theme = findTheme();
|
final int theme = findTheme();
|
||||||
if (this.mTheme != theme) {
|
final boolean usingEnterKey = usingEnterKey();
|
||||||
|
if (this.mTheme != theme || usingEnterKey != mUsingEnterKey) {
|
||||||
recreate();
|
recreate();
|
||||||
}
|
}
|
||||||
this.mActivityPaused = false;
|
this.mActivityPaused = false;
|
||||||
|
|
|
@ -9,6 +9,7 @@ import android.content.Intent;
|
||||||
import android.content.IntentSender;
|
import android.content.IntentSender;
|
||||||
import android.content.IntentSender.SendIntentException;
|
import android.content.IntentSender.SendIntentException;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.text.InputType;
|
||||||
import android.view.ContextMenu;
|
import android.view.ContextMenu;
|
||||||
import android.view.ContextMenu.ContextMenuInfo;
|
import android.view.ContextMenu.ContextMenuInfo;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
|
@ -300,12 +301,21 @@ public class ConversationFragment extends Fragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setupIme() {
|
||||||
|
if (((ConversationActivity)getActivity()).usingEnterKey()) {
|
||||||
|
mEditMessage.setInputType(mEditMessage.getInputType() & (~InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE));
|
||||||
|
} else {
|
||||||
|
mEditMessage.setInputType(mEditMessage.getInputType() | InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(final LayoutInflater inflater,
|
public View onCreateView(final LayoutInflater inflater,
|
||||||
ViewGroup container, Bundle savedInstanceState) {
|
ViewGroup container, Bundle savedInstanceState) {
|
||||||
final View view = inflater.inflate(R.layout.fragment_conversation,
|
final View view = inflater.inflate(R.layout.fragment_conversation,
|
||||||
container, false);
|
container, false);
|
||||||
mEditMessage = (EditMessage) view.findViewById(R.id.textinput);
|
mEditMessage = (EditMessage) view.findViewById(R.id.textinput);
|
||||||
|
setupIme();
|
||||||
mEditMessage.setOnClickListener(new OnClickListener() {
|
mEditMessage.setOnClickListener(new OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -421,24 +431,24 @@ public class ConversationFragment extends Fragment {
|
||||||
|| m.getType() == Message.TYPE_PRIVATE
|
|| m.getType() == Message.TYPE_PRIVATE
|
||||||
|| m.getDownloadable() != null) {
|
|| m.getDownloadable() != null) {
|
||||||
shareWith.setVisible(false);
|
shareWith.setVisible(false);
|
||||||
}
|
}
|
||||||
if (m.getStatus() != Message.STATUS_SEND_FAILED) {
|
if (m.getStatus() != Message.STATUS_SEND_FAILED) {
|
||||||
sendAgain.setVisible(false);
|
sendAgain.setVisible(false);
|
||||||
}
|
}
|
||||||
if ((m.getType() != Message.TYPE_IMAGE && m.getDownloadable() == null)
|
if ((m.getType() != Message.TYPE_IMAGE && m.getDownloadable() == null)
|
||||||
|| m.getImageParams().url == null) {
|
|| m.getImageParams().url == null) {
|
||||||
copyUrl.setVisible(false);
|
copyUrl.setVisible(false);
|
||||||
}
|
}
|
||||||
if (m.getType() != Message.TYPE_TEXT
|
if (m.getType() != Message.TYPE_TEXT
|
||||||
|| m.getDownloadable() != null
|
|| m.getDownloadable() != null
|
||||||
|| !m.bodyContainsDownloadable()) {
|
|| !m.bodyContainsDownloadable()) {
|
||||||
downloadImage.setVisible(false);
|
downloadImage.setVisible(false);
|
||||||
}
|
}
|
||||||
if (!((m.getDownloadable() != null && !(m.getDownloadable() instanceof DownloadablePlaceholder))
|
if (!((m.getDownloadable() != null && !(m.getDownloadable() instanceof DownloadablePlaceholder))
|
||||||
|| (m.isFileOrImage() && (m.getStatus() == Message.STATUS_WAITING
|
|| (m.isFileOrImage() && (m.getStatus() == Message.STATUS_WAITING
|
||||||
|| m.getStatus() == Message.STATUS_OFFERED)))) {
|
|| m.getStatus() == Message.STATUS_OFFERED)))) {
|
||||||
cancelTransmission.setVisible(false);
|
cancelTransmission.setVisible(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -96,6 +96,7 @@ public abstract class XmppActivity extends Activity {
|
||||||
|
|
||||||
private DisplayMetrics metrics;
|
private DisplayMetrics metrics;
|
||||||
protected int mTheme;
|
protected int mTheme;
|
||||||
|
protected boolean mUsingEnterKey = false;
|
||||||
|
|
||||||
protected interface OnValueEdited {
|
protected interface OnValueEdited {
|
||||||
public void onValueEdited(String value);
|
public void onValueEdited(String value);
|
||||||
|
@ -303,9 +304,14 @@ public abstract class XmppActivity extends Activity {
|
||||||
R.color.secondarybackground);
|
R.color.secondarybackground);
|
||||||
this.mTheme = findTheme();
|
this.mTheme = findTheme();
|
||||||
setTheme(this.mTheme);
|
setTheme(this.mTheme);
|
||||||
|
this.mUsingEnterKey = usingEnterKey();
|
||||||
mUseSubject = getPreferences().getBoolean("use_subject", true);
|
mUseSubject = getPreferences().getBoolean("use_subject", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected boolean usingEnterKey() {
|
||||||
|
return getPreferences().getBoolean("display_enter_key", false);
|
||||||
|
}
|
||||||
|
|
||||||
protected SharedPreferences getPreferences() {
|
protected SharedPreferences getPreferences() {
|
||||||
return PreferenceManager
|
return PreferenceManager
|
||||||
.getDefaultSharedPreferences(getApplicationContext());
|
.getDefaultSharedPreferences(getApplicationContext());
|
||||||
|
|
|
@ -435,6 +435,8 @@
|
||||||
<string name="pref_input_options">Input options</string>
|
<string name="pref_input_options">Input options</string>
|
||||||
<string name="pref_enter_is_send">Enter is send</string>
|
<string name="pref_enter_is_send">Enter is send</string>
|
||||||
<string name="pref_enter_is_send_summary">Use enter key to send message</string>
|
<string name="pref_enter_is_send_summary">Use enter key to send message</string>
|
||||||
|
<string name="pref_display_enter_key">Show enter key</string>
|
||||||
|
<string name="pref_display_enter_key_summary">Change the emoticons key to an enter key</string>
|
||||||
<string name="audio">audio file</string>
|
<string name="audio">audio file</string>
|
||||||
<string name="video">video file</string>
|
<string name="video">video file</string>
|
||||||
<string name="pdf_document">PDF document</string>
|
<string name="pdf_document">PDF document</string>
|
||||||
|
|
|
@ -128,6 +128,11 @@
|
||||||
android:key="enter_is_send"
|
android:key="enter_is_send"
|
||||||
android:title="@string/pref_enter_is_send"
|
android:title="@string/pref_enter_is_send"
|
||||||
android:summary="@string/pref_enter_is_send_summary" />
|
android:summary="@string/pref_enter_is_send_summary" />
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:key="display_enter_key"
|
||||||
|
android:title="@string/pref_display_enter_key"
|
||||||
|
android:summary="@string/pref_display_enter_key_summary" />
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
<PreferenceCategory android:title="@string/pref_expert_options_other" >
|
<PreferenceCategory android:title="@string/pref_expert_options_other" >
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
|
|
Loading…
Reference in a new issue