add two digit option
This commit is contained in:
parent
ad93fde386
commit
fe2273f154
6 changed files with 68 additions and 25 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,7 +9,8 @@
|
|||
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="shared_string_travel">Travel</string>
|
||||
<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>
|
||||
<string name="select_waypoints_category_description">You can add all of the track\'s waypoints, or select separate categories.</string>
|
||||
|
|
|
@ -722,7 +722,7 @@ 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", Build.VERSION.SDK_INT >= 16).makeGlobal();
|
||||
public final CommonPreference<Boolean> COORDS_INPUT_TWO_DIGITS_LONGTITUDE = new BooleanPreference("coords_input_two_digits_longitude", true).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();
|
||||
|
|
|
@ -89,6 +89,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
|||
private boolean orientationPortrait;
|
||||
|
||||
private boolean isSoftKeyboardShown = true;
|
||||
private boolean useTwoDigitsLongtitude;
|
||||
private boolean north = true;
|
||||
private boolean east = true;
|
||||
|
||||
|
@ -106,7 +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);
|
||||
isSoftKeyboardShown = !getMyApplication().getSettings().COORDS_INPUT_USE_OSMAND_KEYBOARD.get();
|
||||
useTwoDigitsLongtitude = getMyApplication().getSettings().COORDS_INPUT_TWO_DIGITS_LONGTITUDE.get();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
@ -363,28 +364,29 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
|||
@Override
|
||||
public void onClick(View view) {
|
||||
boolean isCurrentlyVisible = isOsmandKeyboardCurrentlyVisible();
|
||||
if (isOsmandKeyboardOn()&&!isSoftKeyboardShown) {
|
||||
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);
|
||||
} 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();
|
||||
}
|
||||
changeEditTextSelections();
|
||||
}}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void setupKeyboardItems(View keyboardView, View.OnClickListener listener, @IdRes int... itemsIds) {
|
||||
@DrawableRes int itemBg = lightTheme ? R.drawable.keyboard_item_light_bg : R.drawable.keyboard_item_dark_bg;
|
||||
|
@ -489,6 +491,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
|||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
isSoftKeyboardShown = true;
|
||||
AndroidUtils.showSoftKeyboard(focusedView);
|
||||
}
|
||||
}, 200);
|
||||
|
@ -716,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);
|
||||
|
@ -810,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();
|
||||
|
@ -833,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