Merge pull request #5185 from osmandapp/CoordinateInputSaveKeyboard
Coordinate input save keyboard type
This commit is contained in:
commit
b4941e4637
3 changed files with 27 additions and 44 deletions
|
@ -721,6 +721,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<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<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> USE_MAPILLARY_FILTER = new BooleanPreference("use_mapillary_filters", 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();
|
public final CommonPreference<String> MAPILLARY_FILTER_USER_KEY = new StringPreference("mapillary_filter_user_key", "").makeGlobal();
|
||||||
|
|
|
@ -20,39 +20,23 @@ import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
|
||||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||||
import net.osmand.plus.mapmarkers.CoordinateInputFormats.CoordinateInputFormatDef;
|
import net.osmand.plus.mapmarkers.CoordinateInputFormats.CoordinateInputFormatDef;
|
||||||
|
|
||||||
import static net.osmand.plus.mapmarkers.CoordinateInputDialogFragment.USE_OSMAND_KEYBOARD;
|
|
||||||
|
|
||||||
public class CoordinateInputBottomSheetDialogFragment extends MenuBottomSheetDialogFragment {
|
public class CoordinateInputBottomSheetDialogFragment extends MenuBottomSheetDialogFragment {
|
||||||
|
|
||||||
public final static String TAG = "CoordinateInputBottomSheetDialogFragment";
|
public final static String TAG = "CoordinateInputBottomSheetDialogFragment";
|
||||||
|
|
||||||
private CoordinateInputFormatChangeListener listener;
|
private CoordinateInputFormatChangeListener listener;
|
||||||
|
|
||||||
private boolean useOsmandKeyboard;
|
|
||||||
|
|
||||||
public void setListener(CoordinateInputFormatChangeListener listener) {
|
public void setListener(CoordinateInputFormatChangeListener listener) {
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
if (savedInstanceState == null) {
|
|
||||||
Bundle args = getArguments();
|
|
||||||
if (args != null) {
|
|
||||||
useOsmandKeyboard = args.getBoolean(USE_OSMAND_KEYBOARD);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
useOsmandKeyboard = savedInstanceState.getBoolean(USE_OSMAND_KEYBOARD);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createMenuItems(Bundle savedInstanceState) {
|
public void createMenuItems(Bundle savedInstanceState) {
|
||||||
final Context context = getContext();
|
final Context context = getContext();
|
||||||
final OsmandSettings settings = getMyApplication().getSettings();
|
final OsmandSettings settings = getMyApplication().getSettings();
|
||||||
|
|
||||||
items.add(new TitleItem(getString(R.string.shared_string_options)));
|
items.add(new TitleItem(getString(R.string.shared_string_options)));
|
||||||
|
boolean useOsmandKeyboard = settings.COORDS_INPUT_USE_OSMAND_KEYBOARD.get();
|
||||||
|
|
||||||
BaseBottomSheetItem useSystemKeyboardItem = new BottomSheetItemWithCompoundButton.Builder()
|
BaseBottomSheetItem useSystemKeyboardItem = new BottomSheetItemWithCompoundButton.Builder()
|
||||||
.setChecked(!useOsmandKeyboard)
|
.setChecked(!useOsmandKeyboard)
|
||||||
|
@ -63,7 +47,7 @@ public class CoordinateInputBottomSheetDialogFragment extends MenuBottomSheetDia
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if (listener != null) {
|
if (listener != null) {
|
||||||
listener.onKeyboardChanged(!useOsmandKeyboard);
|
listener.onKeyboardChanged();
|
||||||
}
|
}
|
||||||
dismiss();
|
dismiss();
|
||||||
}
|
}
|
||||||
|
@ -134,12 +118,6 @@ public class CoordinateInputBottomSheetDialogFragment extends MenuBottomSheetDia
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSaveInstanceState(Bundle outState) {
|
|
||||||
outState.putBoolean(USE_OSMAND_KEYBOARD, useOsmandKeyboard);
|
|
||||||
super.onSaveInstanceState(outState);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getDismissButtonTextId() {
|
protected int getDismissButtonTextId() {
|
||||||
return R.string.shared_string_close;
|
return R.string.shared_string_close;
|
||||||
|
@ -152,7 +130,7 @@ public class CoordinateInputBottomSheetDialogFragment extends MenuBottomSheetDia
|
||||||
|
|
||||||
interface CoordinateInputFormatChangeListener {
|
interface CoordinateInputFormatChangeListener {
|
||||||
|
|
||||||
void onKeyboardChanged(boolean useOsmandKeyboard);
|
void onKeyboardChanged();
|
||||||
|
|
||||||
void onHandChanged();
|
void onHandChanged();
|
||||||
|
|
||||||
|
|
|
@ -54,6 +54,7 @@ import net.osmand.plus.MapMarkersHelper.MapMarker;
|
||||||
import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener;
|
import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener;
|
||||||
import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener;
|
import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
|
import net.osmand.plus.OsmandSettings;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.base.MapViewTrackingUtilities;
|
import net.osmand.plus.base.MapViewTrackingUtilities;
|
||||||
|
@ -76,8 +77,6 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
||||||
|
|
||||||
public static final String TAG = "CoordinateInputDialogFragment";
|
public static final String TAG = "CoordinateInputDialogFragment";
|
||||||
|
|
||||||
public static final String USE_OSMAND_KEYBOARD = "use_osmand_keyboard";
|
|
||||||
|
|
||||||
private final List<MapMarker> mapMarkers = new ArrayList<>();
|
private final List<MapMarker> mapMarkers = new ArrayList<>();
|
||||||
private OnMapMarkersSavedListener listener;
|
private OnMapMarkersSavedListener listener;
|
||||||
|
|
||||||
|
@ -89,7 +88,6 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
||||||
private boolean lightTheme;
|
private boolean lightTheme;
|
||||||
private boolean orientationPortrait;
|
private boolean orientationPortrait;
|
||||||
|
|
||||||
private boolean useOsmandKeyboard = true;
|
|
||||||
private boolean north = true;
|
private boolean north = true;
|
||||||
private boolean east = true;
|
private boolean east = true;
|
||||||
|
|
||||||
|
@ -170,12 +168,8 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
||||||
mainView.findViewById(R.id.options_button).setOnClickListener(new View.OnClickListener() {
|
mainView.findViewById(R.id.options_button).setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
Bundle args = new Bundle();
|
|
||||||
args.putBoolean(USE_OSMAND_KEYBOARD, useOsmandKeyboard);
|
|
||||||
|
|
||||||
CoordinateInputBottomSheetDialogFragment fragment = new CoordinateInputBottomSheetDialogFragment();
|
CoordinateInputBottomSheetDialogFragment fragment = new CoordinateInputBottomSheetDialogFragment();
|
||||||
fragment.setUsedOnMap(false);
|
fragment.setUsedOnMap(false);
|
||||||
fragment.setArguments(args);
|
|
||||||
fragment.setListener(createCoordinateInputFormatChangeListener());
|
fragment.setListener(createCoordinateInputFormatChangeListener());
|
||||||
fragment.show(getChildFragmentManager(), CoordinateInputBottomSheetDialogFragment.TAG);
|
fragment.show(getChildFragmentManager(), CoordinateInputBottomSheetDialogFragment.TAG);
|
||||||
}
|
}
|
||||||
|
@ -253,8 +247,8 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
||||||
pointNameKeyboardBtn.setOnClickListener(new View.OnClickListener() {
|
pointNameKeyboardBtn.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
if (useOsmandKeyboard) {
|
if (isOsmandKeyboardOn()) {
|
||||||
changeKeyboard(false);
|
changeKeyboard();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -294,7 +288,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
||||||
View.OnClickListener onClickListener = new View.OnClickListener() {
|
View.OnClickListener onClickListener = new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if (useOsmandKeyboard) {
|
if (isOsmandKeyboardOn()) {
|
||||||
View focusedView = getDialog().getCurrentFocus();
|
View focusedView = getDialog().getCurrentFocus();
|
||||||
if (focusedView != null && focusedView instanceof EditText) {
|
if (focusedView != null && focusedView instanceof EditText) {
|
||||||
EditText focusedEditText = (EditText) focusedView;
|
EditText focusedEditText = (EditText) focusedView;
|
||||||
|
@ -340,7 +334,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
||||||
R.id.keyboard_item_next_field,
|
R.id.keyboard_item_next_field,
|
||||||
R.id.keyboard_item_backspace);
|
R.id.keyboard_item_backspace);
|
||||||
|
|
||||||
if (!useOsmandKeyboard && isOsmandKeyboardCurrentlyVisible()) {
|
if (!isOsmandKeyboardOn() && isOsmandKeyboardCurrentlyVisible()) {
|
||||||
changeOsmandKeyboardVisibility(false);
|
changeOsmandKeyboardVisibility(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -349,8 +343,8 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
boolean isCurrentlyVisible = isOsmandKeyboardCurrentlyVisible();
|
boolean isCurrentlyVisible = isOsmandKeyboardCurrentlyVisible();
|
||||||
if (!isCurrentlyVisible && !useOsmandKeyboard) {
|
if (!isCurrentlyVisible && !isOsmandKeyboardOn()) {
|
||||||
changeKeyboard(true);
|
changeKeyboard();
|
||||||
} else {
|
} else {
|
||||||
changeOsmandKeyboardVisibility(!isCurrentlyVisible);
|
changeOsmandKeyboardVisibility(!isCurrentlyVisible);
|
||||||
}
|
}
|
||||||
|
@ -589,7 +583,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
||||||
View.OnTouchListener inputEditTextOnTouchListener = new View.OnTouchListener() {
|
View.OnTouchListener inputEditTextOnTouchListener = new View.OnTouchListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouch(View view, MotionEvent motionEvent) {
|
public boolean onTouch(View view, MotionEvent motionEvent) {
|
||||||
if (useOsmandKeyboard) {
|
if (isOsmandKeyboardOn()) {
|
||||||
if (!isOsmandKeyboardCurrentlyVisible()) {
|
if (!isOsmandKeyboardCurrentlyVisible()) {
|
||||||
changeOsmandKeyboardVisibility(true);
|
changeOsmandKeyboardVisibility(true);
|
||||||
}
|
}
|
||||||
|
@ -615,7 +609,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
||||||
View.OnLongClickListener inputEditTextOnLongClickListener = new View.OnLongClickListener() {
|
View.OnLongClickListener inputEditTextOnLongClickListener = new View.OnLongClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onLongClick(final View view) {
|
public boolean onLongClick(final View view) {
|
||||||
if (useOsmandKeyboard) {
|
if (isOsmandKeyboardOn()) {
|
||||||
final EditText inputEditText = (EditText) view;
|
final EditText inputEditText = (EditText) view;
|
||||||
PopupMenu popupMenu = new PopupMenu(getContext(), inputEditText);
|
PopupMenu popupMenu = new PopupMenu(getContext(), inputEditText);
|
||||||
Menu menu = popupMenu.getMenu();
|
Menu menu = popupMenu.getMenu();
|
||||||
|
@ -738,8 +732,18 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void changeKeyboard(boolean useOsmandKeyboard) {
|
private boolean isOsmandKeyboardOn() {
|
||||||
this.useOsmandKeyboard = useOsmandKeyboard;
|
return getMyApplication().getSettings().COORDS_INPUT_USE_OSMAND_KEYBOARD.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void changeOsmandKeyboardSetting() {
|
||||||
|
OsmandSettings.OsmandPreference<Boolean> pref = getMyApplication().getSettings().COORDS_INPUT_USE_OSMAND_KEYBOARD;
|
||||||
|
pref.set(!pref.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void changeKeyboard() {
|
||||||
|
changeOsmandKeyboardSetting();
|
||||||
|
boolean useOsmandKeyboard = isOsmandKeyboardOn();
|
||||||
changeOsmandKeyboardVisibility(useOsmandKeyboard);
|
changeOsmandKeyboardVisibility(useOsmandKeyboard);
|
||||||
final View focusedView = getDialog().getCurrentFocus();
|
final View focusedView = getDialog().getCurrentFocus();
|
||||||
if (focusedView != null) {
|
if (focusedView != null) {
|
||||||
|
@ -761,8 +765,8 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
||||||
return new CoordinateInputFormatChangeListener() {
|
return new CoordinateInputFormatChangeListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onKeyboardChanged(boolean useOsmandKeyboard) {
|
public void onKeyboardChanged() {
|
||||||
changeKeyboard(useOsmandKeyboard);
|
changeKeyboard();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue