diff --git a/OsmAnd/res/layout-land/point_editor_fragment.xml b/OsmAnd/res/layout-land/point_editor_fragment.xml index 1206e5966b..bf7ffb95d2 100644 --- a/OsmAnd/res/layout-land/point_editor_fragment.xml +++ b/OsmAnd/res/layout-land/point_editor_fragment.xml @@ -142,6 +142,7 @@ android:layout_marginLeft="8dp" android:textColor="?android:textColorPrimary" android:textColorHint="?android:textColorSecondary" + android:imeOptions="actionDone" android:inputType="text"/> diff --git a/OsmAnd/res/layout/point_editor_fragment.xml b/OsmAnd/res/layout/point_editor_fragment.xml index 7a80306ce6..d815c61957 100644 --- a/OsmAnd/res/layout/point_editor_fragment.xml +++ b/OsmAnd/res/layout/point_editor_fragment.xml @@ -137,6 +137,7 @@ android:textColor="?android:textColorPrimary" android:textColorHint="?android:textColorSecondary" android:text="Name" + android:imeOptions="actionDone" android:inputType="text"/> diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragment.java index 5337cf0d8e..19b42ab1d3 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragment.java @@ -24,6 +24,7 @@ import android.widget.ImageButton; import android.widget.ImageView; import android.widget.TextView; +import net.osmand.AndroidUtils; import net.osmand.data.LatLon; import net.osmand.data.QuadPoint; import net.osmand.data.RotatedTileBox; @@ -44,6 +45,7 @@ public abstract class PointEditorFragment extends Fragment { private View view; private int mainViewHeight; + private EditText nameEdit; @TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override @@ -103,7 +105,7 @@ public abstract class PointEditorFragment extends Fragment { TextView categoryCaption = (TextView) view.findViewById(R.id.category_caption); categoryCaption.setText(getCategoryCaption()); - EditText nameEdit = (EditText) view.findViewById(R.id.name_edit); + nameEdit = (EditText) view.findViewById(R.id.name_edit); nameEdit.setText(getNameInitValue()); AutoCompleteTextViewEx categoryEdit = (AutoCompleteTextViewEx) view.findViewById(R.id.category_edit); categoryEdit.setText(getCategoryInitValue()); @@ -152,6 +154,16 @@ public abstract class PointEditorFragment extends Fragment { getMapActivity().getContextMenu().setBaseFragmentVisibility(false); } + @Override + public void onResume() { + super.onResume(); + if (getEditor().isNew()) { + nameEdit.selectAll(); + nameEdit.requestFocus(); + AndroidUtils.softKeyboardDelayed(nameEdit); + } + } + @Override public void onStop() { super.onStop(); @@ -233,11 +245,13 @@ public abstract class PointEditorFragment extends Fragment { private void hideKeyboard() { InputMethodManager inputMethodManager = (InputMethodManager) getActivity().getSystemService(Activity.INPUT_METHOD_SERVICE); - View currentFocus = getActivity().getCurrentFocus(); - if (currentFocus != null) { - IBinder windowToken = currentFocus.getWindowToken(); - if (windowToken != null) { - inputMethodManager.hideSoftInputFromWindow(windowToken, 0); + if (inputMethodManager != null) { + View currentFocus = getActivity().getCurrentFocus(); + if (currentFocus != null) { + IBinder windowToken = currentFocus.getWindowToken(); + if (windowToken != null) { + inputMethodManager.hideSoftInputFromWindow(windowToken, 0); + } } } }