Merge pull request #5188 from osmandapp/CoordinateInputSaveKeyboard
Coordinate input save keyboard
This commit is contained in:
commit
e0cd250e63
6 changed files with 102 additions and 12 deletions
|
@ -164,6 +164,7 @@
|
|||
<!-- Longitude row: -->
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/longitude_row"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/content_padding_small"
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
||||
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
||||
-->
|
||||
<string name="use_two_digits_longitude">Use two digits longitude</string>
|
||||
<string name="shared_string_travel">Travel</string>
|
||||
<string name="waypoints_removed_from_map_markers">Waypoints removed from map markers</string>
|
||||
<string name="nothing_found_in_radius">Nothing found within the radius:</string>
|
||||
|
|
|
@ -721,7 +721,8 @@ public class OsmandSettings {
|
|||
|
||||
public final CommonPreference<Boolean> COORDS_INPUT_USE_RIGHT_SIDE = new BooleanPreference("coords_input_use_right_side", true).makeGlobal();
|
||||
public final CommonPreference<Integer> COORDS_INPUT_FORMAT = new IntPreference("coords_input_format", CoordinateInputFormats.DD_MM_MMM);
|
||||
public final CommonPreference<Boolean> COORDS_INPUT_USE_OSMAND_KEYBOARD = new BooleanPreference("coords_input_use_osmand_keyboard", true).makeGlobal();
|
||||
public final CommonPreference<Boolean> COORDS_INPUT_USE_OSMAND_KEYBOARD = new BooleanPreference("coords_input_use_osmand_keyboard", Build.VERSION.SDK_INT >= 16).makeGlobal();
|
||||
public final CommonPreference<Boolean> COORDS_INPUT_TWO_DIGITS_LONGTITUDE = new BooleanPreference("coords_input_two_digits_longitude", false).makeGlobal();
|
||||
|
||||
public final CommonPreference<Boolean> USE_MAPILLARY_FILTER = new BooleanPreference("use_mapillary_filters", false).makeGlobal();
|
||||
public final CommonPreference<String> MAPILLARY_FILTER_USER_KEY = new StringPreference("mapillary_filter_user_key", "").makeGlobal();
|
||||
|
|
|
@ -55,6 +55,26 @@ public class CoordinateInputBottomSheetDialogFragment extends MenuBottomSheetDia
|
|||
.create();
|
||||
items.add(useSystemKeyboardItem);
|
||||
|
||||
boolean useTwoDigitsLogtitude = settings.COORDS_INPUT_TWO_DIGITS_LONGTITUDE.get();
|
||||
BaseBottomSheetItem twoDigitsLongtitudeItem = new BottomSheetItemWithCompoundButton.Builder()
|
||||
.setChecked(useTwoDigitsLogtitude)
|
||||
.setIcon(getContentIcon(R.drawable.ic_action_next_field_stroke))
|
||||
.setTitle(getString(R.string.use_two_digits_longitude))
|
||||
.setLayoutId(R.layout.bottom_sheet_item_with_switch)
|
||||
.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (listener != null) {
|
||||
OsmandSettings.CommonPreference<Boolean> pref = settings.COORDS_INPUT_TWO_DIGITS_LONGTITUDE;
|
||||
pref.set(!pref.get());
|
||||
listener.onTwoDigitsLongtitudeChanged();
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
})
|
||||
.create();
|
||||
items.add(twoDigitsLongtitudeItem);
|
||||
|
||||
if (!AndroidUiHelper.isOrientationPortrait(getActivity())) {
|
||||
boolean rightHand = settings.COORDS_INPUT_USE_RIGHT_SIDE.get();
|
||||
|
||||
|
@ -130,6 +150,8 @@ public class CoordinateInputBottomSheetDialogFragment extends MenuBottomSheetDia
|
|||
|
||||
interface CoordinateInputFormatChangeListener {
|
||||
|
||||
void onTwoDigitsLongtitudeChanged();
|
||||
|
||||
void onKeyboardChanged();
|
||||
|
||||
void onHandChanged();
|
||||
|
|
|
@ -88,6 +88,8 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
|||
private boolean lightTheme;
|
||||
private boolean orientationPortrait;
|
||||
|
||||
private boolean isSoftKeyboardShown = true;
|
||||
private boolean useTwoDigitsLongtitude;
|
||||
private boolean north = true;
|
||||
private boolean east = true;
|
||||
|
||||
|
@ -105,6 +107,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
|||
super.onCreate(savedInstanceState);
|
||||
lightTheme = getMyApplication().getSettings().isLightContent();
|
||||
setStyle(STYLE_NO_FRAME, lightTheme ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme);
|
||||
useTwoDigitsLongtitude = getMyApplication().getSettings().COORDS_INPUT_TWO_DIGITS_LONGTITUDE.get();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
@ -247,12 +250,30 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
|||
pointNameKeyboardBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (isOsmandKeyboardOn()) {
|
||||
changeKeyboard();
|
||||
if (isOsmandKeyboardCurrentlyVisible()) {
|
||||
changeOsmandKeyboardVisibility(false);
|
||||
}
|
||||
editTexts.get(6).requestFocus();
|
||||
final View focusedView = getDialog().getCurrentFocus();
|
||||
if (focusedView != null) {
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
isSoftKeyboardShown = true;
|
||||
AndroidUtils.showSoftKeyboard(focusedView);
|
||||
}
|
||||
}, 200);
|
||||
}
|
||||
}
|
||||
});
|
||||
editTexts.get(6).setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
||||
@Override
|
||||
public void onFocusChange(View v, boolean hasFocus) {
|
||||
if (!hasFocus && isOsmandKeyboardOn() && isOsmandKeyboardCurrentlyVisible()) {
|
||||
AndroidUtils.hideSoftKeyboard(getActivity(), v);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
adapter = new CoordinateInputAdapter(mapActivity, mapMarkers);
|
||||
RecyclerView recyclerView = (RecyclerView) mainView.findViewById(R.id.markers_recycler_view);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(ctx));
|
||||
|
@ -343,10 +364,25 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
|||
@Override
|
||||
public void onClick(View view) {
|
||||
boolean isCurrentlyVisible = isOsmandKeyboardCurrentlyVisible();
|
||||
if (!isCurrentlyVisible && !isOsmandKeyboardOn()) {
|
||||
changeKeyboard();
|
||||
} else {
|
||||
if (isOsmandKeyboardOn() && !isSoftKeyboardShown) {
|
||||
changeOsmandKeyboardVisibility(!isCurrentlyVisible);
|
||||
} else {
|
||||
final View focusedView = getDialog().getCurrentFocus();
|
||||
if (focusedView != null) {
|
||||
if (isSoftKeyboardShown) {
|
||||
isSoftKeyboardShown = false;
|
||||
AndroidUtils.hideSoftKeyboard(getActivity(), focusedView);
|
||||
} else {
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
isSoftKeyboardShown = true;
|
||||
AndroidUtils.showSoftKeyboard(focusedView);
|
||||
}
|
||||
}, 200);
|
||||
}
|
||||
changeEditTextSelections();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -448,6 +484,19 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
|||
super.onResume();
|
||||
adapter.setScreenOrientation(DashLocationFragment.getScreenOrientation(getActivity()));
|
||||
startLocationUpdate();
|
||||
|
||||
final View focusedView = getDialog().getCurrentFocus();
|
||||
if (focusedView != null) {
|
||||
if (!isOsmandKeyboardOn()) {
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
isSoftKeyboardShown = true;
|
||||
AndroidUtils.showSoftKeyboard(focusedView);
|
||||
}
|
||||
}, 200);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -670,8 +719,8 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
|||
|
||||
int format = getMyApplication().getSettings().COORDS_INPUT_FORMAT.get();
|
||||
|
||||
setupEditTextEx(R.id.lat_first_input_et, CoordinateInputFormats.getFirstPartSymbolsCount(format, true), true);
|
||||
setupEditTextEx(R.id.lon_first_input_et, CoordinateInputFormats.getFirstPartSymbolsCount(format, false), false);
|
||||
setupEditTextEx(R.id.lat_first_input_et, CoordinateInputFormats.getFirstPartSymbolsCount(format, true, useTwoDigitsLongtitude), true);
|
||||
setupEditTextEx(R.id.lon_first_input_et, CoordinateInputFormats.getFirstPartSymbolsCount(format, false, useTwoDigitsLongtitude), false);
|
||||
|
||||
String firstSeparator = CoordinateInputFormats.getFirstSeparator(format);
|
||||
((TextView) mainView.findViewById(R.id.lat_first_separator_tv)).setText(firstSeparator);
|
||||
|
@ -764,6 +813,11 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
|||
private CoordinateInputFormatChangeListener createCoordinateInputFormatChangeListener() {
|
||||
return new CoordinateInputFormatChangeListener() {
|
||||
|
||||
@Override
|
||||
public void onTwoDigitsLongtitudeChanged() {
|
||||
changeTwoDigitsLongtitude();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onKeyboardChanged() {
|
||||
changeKeyboard();
|
||||
|
@ -787,6 +841,13 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
|||
registerMainView();
|
||||
}
|
||||
|
||||
private void changeTwoDigitsLongtitude() {
|
||||
editTexts.get(3).setMaxSymbolsCount(getMyApplication().getSettings().COORDS_INPUT_TWO_DIGITS_LONGTITUDE.get() ? 2 : 3);
|
||||
((LinearLayout)mainView.findViewById(R.id.longitude_row)).removeView(editTexts.get(3));
|
||||
// editTexts.get(3).invalidate();
|
||||
registerMainView();
|
||||
}
|
||||
|
||||
private void changeEditTextSelections() {
|
||||
for (EditText et : editTexts) {
|
||||
et.setSelection(et.getText().length());
|
||||
|
|
|
@ -43,8 +43,12 @@ public class CoordinateInputFormats {
|
|||
return format == DD_MM_MMM || format == DD_MM_MMMM || format == DD_MM_SS;
|
||||
}
|
||||
|
||||
public static int getFirstPartSymbolsCount(@CoordinateInputFormatDef int format, boolean latitude) {
|
||||
return latitude ? 2 : 3;
|
||||
public static int getFirstPartSymbolsCount(@CoordinateInputFormatDef int format, boolean latitude, boolean isTwoDigitsLongtitute) {
|
||||
if (latitude) {
|
||||
return 2;
|
||||
} else {
|
||||
return isTwoDigitsLongtitute ? 2 : 3;
|
||||
}
|
||||
}
|
||||
|
||||
public static int getSecondPartSymbolsCount(@CoordinateInputFormatDef int format) {
|
||||
|
|
Loading…
Reference in a new issue