diff options
author | Bananeweizen <bananeweizen@gmx.de> | 2014-01-17 18:51:53 +0100 |
---|---|---|
committer | Bananeweizen <bananeweizen@gmx.de> | 2014-01-17 18:51:53 +0100 |
commit | 8b517dc0504da184b6b671addfad685aef884150 (patch) | |
tree | 85a6c8c6becce2c7fc1b71722b3fa9aab23d0b96 | |
parent | e7ce767a011eaac66bbc3f3ea1702840d5e9c32c (diff) | |
download | cgeo-8b517dc0504da184b6b671addfad685aef884150.zip cgeo-8b517dc0504da184b6b671addfad685aef884150.tar.gz cgeo-8b517dc0504da184b6b671addfad685aef884150.tar.bz2 |
fix #3100: Set cursor in personal notes at the end
8 files changed, 27 insertions, 4 deletions
diff --git a/main/src/cgeo/geocaching/EditWaypointActivity.java b/main/src/cgeo/geocaching/EditWaypointActivity.java index df6e9c5..eee7505 100644 --- a/main/src/cgeo/geocaching/EditWaypointActivity.java +++ b/main/src/cgeo/geocaching/EditWaypointActivity.java @@ -21,6 +21,7 @@ import com.googlecode.androidannotations.annotations.EActivity; import com.googlecode.androidannotations.annotations.Extra; import com.googlecode.androidannotations.annotations.InstanceState; import com.googlecode.androidannotations.annotations.ViewById; + import org.apache.commons.lang3.StringUtils; import android.app.ProgressDialog; @@ -109,12 +110,14 @@ public class EditWaypointActivity extends AbstractActivity { buttonLon.setText(waypoint.getCoords().format(GeopointFormatter.Format.LON_DECMINUTE)); } waypointName.setText(Html.fromHtml(StringUtils.trimToEmpty(waypoint.getName())).toString()); + Dialogs.moveCursorToEnd(waypointName); if (TextUtils.containsHtml(waypoint.getNote())) { note.setText(Html.fromHtml(StringUtils.trimToEmpty(waypoint.getNote())).toString()); } else { note.setText(StringUtils.trimToEmpty(waypoint.getNote())); } + Dialogs.moveCursorToEnd(note); } final Geocache cache = DataStore.loadCache(geocode, LoadFlags.LOAD_CACHE_ONLY); setCoordsModificationVisibility(ConnectorFactory.getConnector(geocode), cache); diff --git a/main/src/cgeo/geocaching/ImageSelectActivity.java b/main/src/cgeo/geocaching/ImageSelectActivity.java index 9e0a37d..a9230c9 100644 --- a/main/src/cgeo/geocaching/ImageSelectActivity.java +++ b/main/src/cgeo/geocaching/ImageSelectActivity.java @@ -5,6 +5,7 @@ import butterknife.InjectView; import cgeo.geocaching.activity.AbstractActivity; import cgeo.geocaching.settings.Settings; +import cgeo.geocaching.ui.dialog.Dialogs; import cgeo.geocaching.utils.ImageUtils; import cgeo.geocaching.utils.Log; @@ -103,10 +104,12 @@ public class ImageSelectActivity extends AbstractActivity { if (StringUtils.isNotBlank(imageCaption)) { captionView.setText(imageCaption); + Dialogs.moveCursorToEnd(captionView); } if (StringUtils.isNotBlank(imageDescription)) { descriptionView.setText(imageDescription); + Dialogs.moveCursorToEnd(captionView); } scaleView.setSelection(scaleChoiceIndex); diff --git a/main/src/cgeo/geocaching/LogCacheActivity.java b/main/src/cgeo/geocaching/LogCacheActivity.java index c8b785c..729ec60 100644 --- a/main/src/cgeo/geocaching/LogCacheActivity.java +++ b/main/src/cgeo/geocaching/LogCacheActivity.java @@ -13,6 +13,7 @@ import cgeo.geocaching.settings.Settings; import cgeo.geocaching.twitter.Twitter; import cgeo.geocaching.ui.Formatter; import cgeo.geocaching.ui.dialog.DateDialog; +import cgeo.geocaching.ui.dialog.Dialogs; import cgeo.geocaching.utils.AsyncTaskWithProgress; import cgeo.geocaching.utils.DateUtils; import cgeo.geocaching.utils.Log; @@ -301,6 +302,7 @@ public class LogCacheActivity extends AbstractLoggingActivity implements DateDia final EditText logView = (EditText) findViewById(R.id.log); if (StringUtils.isBlank(currentLogText()) && StringUtils.isNotBlank(text)) { logView.setText(text); + Dialogs.moveCursorToEnd(logView); } tweetCheck.setChecked(true); diff --git a/main/src/cgeo/geocaching/LogTrackableActivity.java b/main/src/cgeo/geocaching/LogTrackableActivity.java index 50a837a..fabe391 100644 --- a/main/src/cgeo/geocaching/LogTrackableActivity.java +++ b/main/src/cgeo/geocaching/LogTrackableActivity.java @@ -13,6 +13,7 @@ import cgeo.geocaching.settings.Settings; import cgeo.geocaching.twitter.Twitter; import cgeo.geocaching.ui.Formatter; import cgeo.geocaching.ui.dialog.DateDialog; +import cgeo.geocaching.ui.dialog.Dialogs; import cgeo.geocaching.utils.Log; import cgeo.geocaching.utils.LogTemplateProvider.LogContext; @@ -127,6 +128,7 @@ public class LogTrackableActivity extends AbstractLoggingActivity implements Dat if (StringUtils.isNotBlank(extras.getString(Intents.EXTRA_TRACKING_CODE))) { trackingEditText.setText(extras.getString(Intents.EXTRA_TRACKING_CODE)); + Dialogs.moveCursorToEnd(trackingEditText); } } diff --git a/main/src/cgeo/geocaching/activity/ActivityMixin.java b/main/src/cgeo/geocaching/activity/ActivityMixin.java index c1a2678..bfd45da 100644 --- a/main/src/cgeo/geocaching/activity/ActivityMixin.java +++ b/main/src/cgeo/geocaching/activity/ActivityMixin.java @@ -125,6 +125,6 @@ public final class ActivityMixin { editText.getText().replace(start, end, completeText); int newCursor = moveCursor ? start + completeText.length() : start; - editText.setSelection(newCursor, newCursor); + editText.setSelection(newCursor); } } diff --git a/main/src/cgeo/geocaching/settings/TemplateTextPreference.java b/main/src/cgeo/geocaching/settings/TemplateTextPreference.java index a703231..667b02b 100644 --- a/main/src/cgeo/geocaching/settings/TemplateTextPreference.java +++ b/main/src/cgeo/geocaching/settings/TemplateTextPreference.java @@ -2,6 +2,7 @@ package cgeo.geocaching.settings; import cgeo.geocaching.R; import cgeo.geocaching.activity.ActivityMixin; +import cgeo.geocaching.ui.dialog.Dialogs; import cgeo.geocaching.utils.LogTemplateProvider; import cgeo.geocaching.utils.LogTemplateProvider.LogTemplate; @@ -49,6 +50,7 @@ public class TemplateTextPreference extends DialogPreference { editText = (EditText) view.findViewById(R.id.signature_dialog_text); editText.setText(getPersistedString(initialValue != null ? initialValue : StringUtils.EMPTY)); + Dialogs.moveCursorToEnd(editText); Button button = (Button) view.findViewById(R.id.signature_templates); button.setOnClickListener(new View.OnClickListener() { diff --git a/main/src/cgeo/geocaching/ui/EditNoteDialog.java b/main/src/cgeo/geocaching/ui/EditNoteDialog.java index 2af1cb8..4bfa140 100644 --- a/main/src/cgeo/geocaching/ui/EditNoteDialog.java +++ b/main/src/cgeo/geocaching/ui/EditNoteDialog.java @@ -1,6 +1,7 @@ package cgeo.geocaching.ui; import cgeo.geocaching.R; +import cgeo.geocaching.ui.dialog.Dialogs; import android.app.AlertDialog; import android.app.Dialog; @@ -40,6 +41,7 @@ public class EditNoteDialog extends DialogFragment { String initialNote = getArguments().getString(ARGUMENT_INITIAL_NOTE); if (initialNote != null) { mEditText.setText(initialNote); + Dialogs.moveCursorToEnd(mEditText); getArguments().remove(ARGUMENT_INITIAL_NOTE); } diff --git a/main/src/cgeo/geocaching/ui/dialog/Dialogs.java b/main/src/cgeo/geocaching/ui/dialog/Dialogs.java index 4f6de39..cbd5c94 100644 --- a/main/src/cgeo/geocaching/ui/dialog/Dialogs.java +++ b/main/src/cgeo/geocaching/ui/dialog/Dialogs.java @@ -4,6 +4,7 @@ import cgeo.geocaching.CgeoApplication; import org.apache.commons.lang3.StringUtils; import org.eclipse.jdt.annotation.Nullable; + import rx.util.functions.Action1; import android.app.Activity; @@ -298,7 +299,7 @@ public final class Dialogs { /** * Show a message dialog for input from the user. The okay button is only enabled on non empty input. - * + * * @param context * activity owning the dialog * @param title @@ -357,8 +358,16 @@ public final class Dialogs { dialog.show(); enableDialogButtonIfNotEmpty(dialog, defaultValue); - // position cursor after text - input.setSelection(input.getText().length()); + moveCursorToEnd(input); + } + + /** + * Move the cursor to the end of the input field. + * + * @param input + */ + public static void moveCursorToEnd(final EditText input) { + input.setSelection(input.getText().length(), input.getText().length()); } private static void enableDialogButtonIfNotEmpty(final AlertDialog dialog, final String input) { |