(1) Let full-screen IMEs wrap the text into multiple lines instead of making the text scroll off the screen.
(2) Provide a preference to let the user choose whether or not to enable autocorrection of typed text. (3) Provide a preference to let the user choose whether or not to enable autocapitalization of sentences. Note that even when this is enabled, autocapitalization will only happen if the option is also enabled in the IME. (4) In landscape mode only, don't replace the Enter key with a Send button, to make it harder to accidentally send a message. (We can't do this in portrait, because we would be left without any send button at all -- perhaps the input line should be changed to be similar to the text message application, which has a send button next to the input line?) --- application/res/layout/conversations.xml | 2 +- application/res/values/settings.xml | 6 ++++ application/res/values/strings.xml | 4 +++ application/res/xml/preferences.xml | 10 +++++++ .../org/yaaic/activity/ConversationActivity.java | 27 ++++++++++++++++--- application/src/org/yaaic/model/Settings.java | 22 ++++++++++++++++ 6 files changed, 65 insertions(+), 6 deletions(-) diff --git a/application/res/layout/conversations.xml b/application/res/layout/conversations.xml index fbc43b9..b235430 100644 --- a/application/res/layout/conversations.xml +++ b/application/res/layout/conversations.xml @@ -72,7 +72,7 @@ along with Yaaic. If not, see <http://www.gnu.org/licenses/>. android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" - android:singleLine="true" + android:inputType="textImeMultiLine" android:imeOptions="actionSend" /> <Button android:id="@+id/speech" diff --git a/application/res/values/settings.xml b/application/res/values/settings.xml index e77cf5e..4bc3bb5 100644 --- a/application/res/values/settings.xml +++ b/application/res/values/settings.xml @@ -45,6 +45,12 @@ <string name="key_graphical_smilies">graphical_smilies</string> <string name="default_graphical_smilies">false</string> + <string name="key_autocorrect_text">autocorrect_text</string> + <string name="default_autocorrect_text">false</string> + + <string name="key_autocap_sentences">autocap_sentences</string> + <string name="default_autocap_sentences">false</string> + <string name="key_history_size">history_size</string> <string name="default_history_size">30</string> </resources> diff --git a/application/res/values/strings.xml b/application/res/values/strings.xml index c3e234a..8267af0 100644 --- a/application/res/values/strings.xml +++ b/application/res/values/strings.xml @@ -203,6 +203,10 @@ <string name="settings_mirc_colors_desc">Show mIRC colors in messages</string> <string name="settings_graphical_smilies_title">Show graphical smilies</string> <string name="settings_graphical_smilies_desc">Text smilies will be displayed as images in chat</string> + <string name="settings_autocorrect_text_title">Autocorrect input</string> + <string name="settings_autocorrect_text_desc">Use dictionary to autocorrect typed text in chat</string> + <string name="settings_autocap_sentences_title">Auto-capitalize sentences</string> + <string name="settings_autocap_sentences_desc">Automatically capitalize the first word of sentences</string> <string name="settings_history_size_title">History size</string> <string name="settings_history_size_desc">Number of lines of conversation history to keep</string> </resources> diff --git a/application/res/xml/preferences.xml b/application/res/xml/preferences.xml index e190eb3..7101259 100644 --- a/application/res/xml/preferences.xml +++ b/application/res/xml/preferences.xml @@ -85,6 +85,16 @@ along with Yaaic. If not, see <http://www.gnu.org/licenses/>. android:summary="@string/settings_graphical_smilies_desc" android:key="@string/key_graphical_smilies" android:defaultValue="@string/default_graphical_smilies" /> + <CheckBoxPreference + android:title="@string/settings_autocorrect_text_title" + android:summary="@string/settings_autocorrect_text_desc" + android:key="@string/key_autocorrect_text" + android:defaultValue="@string/default_autocorrect_text" /> + <CheckBoxPreference + android:title="@string/settings_autocap_sentences_title" + android:summary="@string/settings_autocap_sentences_desc" + android:key="@string/key_autocap_sentences" + android:defaultValue="@string/default_autocap_sentences" /> <EditTextPreference android:title="@string/settings_history_size_title" android:summary="@string/settings_history_size_desc" diff --git a/application/src/org/yaaic/activity/ConversationActivity.java b/application/src/org/yaaic/activity/ConversationActivity.java index f9b77cd..4a772d1 100644 --- a/application/src/org/yaaic/activity/ConversationActivity.java +++ b/application/src/org/yaaic/activity/ConversationActivity.java @@ -65,10 +65,12 @@ import android.content.IntentFilter; import android.content.ServiceConnection; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; +import android.content.res.Configuration; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.speech.RecognizerIntent; +import android.text.InputType; import android.view.KeyEvent; import android.view.Menu; import android.view.MenuInflater; @@ -191,6 +193,8 @@ public class ConversationActivity extends Activity implements ServiceConnection, setContentView(R.layout.conversations); + boolean isLandscape = (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE); + ((TextView) findViewById(R.id.title)).setText(server.getTitle()); EditText input = (EditText) findViewById(R.id.input); @@ -229,13 +233,26 @@ public class ConversationActivity extends Activity implements ServiceConnection, } } - // keep compatibility with api level 3 - if ((android.os.Build.VERSION.SDK.charAt(0) - '0') >= 5) { - setInputTypeFlag = 0x80000; // InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS + int setInputTypeFlags = 0; + if (settings.autoCorrectText()) { + setInputTypeFlags |= InputType.TYPE_TEXT_FLAG_AUTO_CORRECT; + } else { + // keep compatibility with api level 3 + if ((android.os.Build.VERSION.SDK.charAt(0) - '0') >= 5) { + setInputTypeFlags |= 0x80000; // InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS + } + } + if (settings.autoCapSentences()) { + setInputTypeFlags |= InputType.TYPE_TEXT_FLAG_CAP_SENTENCES; } - else { - setInputTypeFlag = 0; + if (isLandscape) { + /* Replace the Enter key with a smiley instead of Send, to make it + more difficult to accidentally hit send + We'd like to do this in portrait too, but wouldn't have a Send + button in that case */ + setInputTypeFlags |= InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE; } + input.setInputType(input.getInputType() | setInputTypeFlags); // Create a new scrollback history scrollback = new Scrollback(); diff --git a/application/src/org/yaaic/model/Settings.java b/application/src/org/yaaic/model/Settings.java index 5bc08aa..349d631 100644 --- a/application/src/org/yaaic/model/Settings.java +++ b/application/src/org/yaaic/model/Settings.java @@ -249,6 +249,28 @@ public class Settings } /** + * Whether message text should be autocorrected. + */ + public boolean autoCorrectText() + { + return preferences.getBoolean( + resources.getString(R.string.key_autocorrect_text), + Boolean.parseBoolean(resources.getString(R.string.default_autocorrect_text)) + ); + } + + /** + * Whether sentences in messages should be automatically capitalized. + */ + public boolean autoCapSentences() + { + return preferences.getBoolean( + resources.getString(R.string.key_autocap_sentences), + Boolean.parseBoolean(resources.getString(R.string.default_autocap_sentences)) + ); + } + + /** * Get the conversation history size. * * @return The conversation history size -- 1.7.2.5

