1
0
mirror of https://github.com/moparisthebest/Yaaic synced 2025-01-08 12:18:07 -05:00

IME behavior changes for the ConversationActivity

(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?)
This commit is contained in:
Steven Luo 2011-05-29 17:50:00 -07:00 committed by Sebastian Kaspari
parent aa355c4283
commit 35609e5529
6 changed files with 65 additions and 6 deletions

View File

@ -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"

View File

@ -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>

View File

@ -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>

View File

@ -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"

View File

@ -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
}
}
else {
setInputTypeFlag = 0;
if (settings.autoCapSentences()) {
setInputTypeFlags |= InputType.TYPE_TEXT_FLAG_CAP_SENTENCES;
}
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();

View File

@ -248,6 +248,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.
*