From 3c58bd0c4cbf1756372fb7de44486ff4bfb4f7ed Mon Sep 17 00:00:00 2001 From: Cliff Ingham Date: Thu, 9 Oct 2014 11:51:15 -0400 Subject: [PATCH] Added auto suggest and multi line input to text entry Fixes #76 --- .../res/layout/attribute_entry_string.xml | 3 +- .../activities/AttributeEntryActivity.java | 15 ++++++--- .../activities/DataEntryActivity.java | 32 +++++++++++++++---- 3 files changed, 37 insertions(+), 13 deletions(-) diff --git a/open311-android/res/layout/attribute_entry_string.xml b/open311-android/res/layout/attribute_entry_string.xml index c1d1498..65b174e 100644 --- a/open311-android/res/layout/attribute_entry_string.xml +++ b/open311-android/res/layout/attribute_entry_string.xml @@ -3,7 +3,6 @@ android:id="@+id/input" android:layout_width="match_parent" android:layout_height="wrap_content" - android:ems="10" - android:inputType="textCapSentences"> + android:ems="10"> diff --git a/open311-android/src/gov/in/bloomington/georeporter/activities/AttributeEntryActivity.java b/open311-android/src/gov/in/bloomington/georeporter/activities/AttributeEntryActivity.java index 9f95489..de5d93f 100644 --- a/open311-android/src/gov/in/bloomington/georeporter/activities/AttributeEntryActivity.java +++ b/open311-android/src/gov/in/bloomington/georeporter/activities/AttributeEntryActivity.java @@ -82,16 +82,23 @@ private View loadAttributeEntryView() { LayoutInflater inflater = getLayoutInflater(); if (mDatatype.equals(Open311.STRING) || mDatatype.equals(Open311.NUMBER) || mDatatype.equals(Open311.TEXT)) { - View v = inflater.inflate(R.layout.attribute_entry_string, null); - EditText input = (EditText) v.findViewById(R.id.input); + EditText input = (EditText) inflater.inflate(R.layout.attribute_entry_string, null); if (mDatatype.equals(Open311.NUMBER)) { input.setInputType(InputType.TYPE_CLASS_NUMBER); } if (mDatatype.equals(Open311.TEXT)) { - input.setInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE); + input.setInputType( + InputType.TYPE_CLASS_TEXT + |InputType.TYPE_TEXT_FLAG_MULTI_LINE + |InputType.TYPE_TEXT_FLAG_AUTO_CORRECT + |InputType.TYPE_TEXT_FLAG_CAP_SENTENCES + |InputType.TYPE_TEXT_VARIATION_LONG_MESSAGE + ); + input.setMaxLines(6); + input.setHorizontallyScrolling(false); } - return v; + return input; } else if (mDatatype.equals(Open311.SINGLEVALUELIST) || mDatatype.equals(Open311.MULTIVALUELIST)) { /** diff --git a/open311-android/src/gov/in/bloomington/georeporter/activities/DataEntryActivity.java b/open311-android/src/gov/in/bloomington/georeporter/activities/DataEntryActivity.java index a2e7141..1401127 100644 --- a/open311-android/src/gov/in/bloomington/georeporter/activities/DataEntryActivity.java +++ b/open311-android/src/gov/in/bloomington/georeporter/activities/DataEntryActivity.java @@ -43,17 +43,35 @@ protected void onCreate(Bundle savedInstanceState) { mInput.setText(i.getStringExtra(VALUE)); if (mKey.equals(Open311.DESCRIPTION)) { - mInput.setInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE); + mInput.setInputType( + InputType.TYPE_CLASS_TEXT + |InputType.TYPE_TEXT_FLAG_MULTI_LINE + |InputType.TYPE_TEXT_FLAG_AUTO_CORRECT + |InputType.TYPE_TEXT_FLAG_CAP_SENTENCES + |InputType.TYPE_TEXT_VARIATION_LONG_MESSAGE + ); + mInput.setMaxLines(6); + mInput.setHorizontallyScrolling(false); } - if (mKey.equals(Open311.FIRST_NAME) || mKey.equals(Open311.LAST_NAME)) { - mInput.setInputType(InputType.TYPE_TEXT_VARIATION_PERSON_NAME); + else if (mKey.equals(Open311.FIRST_NAME) || mKey.equals(Open311.LAST_NAME)) { + mInput.setInputType(InputType.TYPE_CLASS_TEXT|InputType.TYPE_TEXT_VARIATION_PERSON_NAME); } - if (mKey.equals(Open311.EMAIL)) { - mInput.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS); + else if (mKey.equals(Open311.EMAIL)) { + mInput.setInputType(InputType.TYPE_CLASS_TEXT|InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS); } - if (mKey.equals(Open311.PHONE)) { + else if (mKey.equals(Open311.PHONE)) { mInput.setInputType(InputType.TYPE_CLASS_PHONE); - + } + else { + mInput.setInputType( + InputType.TYPE_CLASS_TEXT + |InputType.TYPE_TEXT_FLAG_MULTI_LINE + |InputType.TYPE_TEXT_FLAG_AUTO_CORRECT + |InputType.TYPE_TEXT_FLAG_CAP_SENTENCES + |InputType.TYPE_TEXT_VARIATION_LONG_MESSAGE + ); + mInput.setMaxLines(6); + mInput.setHorizontallyScrolling(false); } mLayout.addView(mInput);