From 81eda40f4f3589894109e1c4d9345ee6deb2b3e4 Mon Sep 17 00:00:00 2001 From: Chumva Date: Thu, 29 Mar 2018 18:00:26 +0300 Subject: [PATCH 01/11] add save for USE_OSMAND_KEYBOARD --- OsmAnd/src/net/osmand/plus/OsmandSettings.java | 1 + .../CoordinateInputBottomSheetDialogFragment.java | 10 ++-------- .../plus/mapmarkers/CoordinateInputDialogFragment.java | 4 +++- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java index 95afd05a63..50c31dd023 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java @@ -721,6 +721,7 @@ public class OsmandSettings { public final CommonPreference COORDS_INPUT_USE_RIGHT_SIDE = new BooleanPreference("coords_input_use_right_side", true).makeGlobal(); public final CommonPreference COORDS_INPUT_FORMAT = new IntPreference("coords_input_format", CoordinateInputFormats.DD_MM_MMM); + public final OsmandPreference COORDS_USE_OSMAND_KEYBOARD = new BooleanPreference("coords_use_osmand_keyboard", true).makeGlobal(); public final CommonPreference USE_MAPILLARY_FILTER = new BooleanPreference("use_mapillary_filters", false).makeGlobal(); public final CommonPreference MAPILLARY_FILTER_USER_KEY = new StringPreference("mapillary_filter_user_key", "").makeGlobal(); diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputBottomSheetDialogFragment.java index 4cc678cfe2..484a1088b1 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputBottomSheetDialogFragment.java @@ -37,14 +37,7 @@ public class CoordinateInputBottomSheetDialogFragment extends MenuBottomSheetDia @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); - } + useOsmandKeyboard = getMyApplication().getSettings().COORDS_USE_OSMAND_KEYBOARD.get(); } @Override @@ -65,6 +58,7 @@ public class CoordinateInputBottomSheetDialogFragment extends MenuBottomSheetDia if (listener != null) { listener.onKeyboardChanged(!useOsmandKeyboard); } + settings.COORDS_USE_OSMAND_KEYBOARD.set(!useOsmandKeyboard); dismiss(); } }) diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java index 593a874bfd..36b9f70185 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java @@ -182,7 +182,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm }); registerMainView(); - +// changeKeyboard(getMyApplication().getSettings().COORDS_USE_OSMAND_KEYBOARD.get()); return mainView; } @@ -351,6 +351,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm boolean isCurrentlyVisible = isOsmandKeyboardCurrentlyVisible(); if (!isCurrentlyVisible && !useOsmandKeyboard) { changeKeyboard(true); + getMyApplication().getSettings().COORDS_USE_OSMAND_KEYBOARD.set(true); } else { changeOsmandKeyboardVisibility(!isCurrentlyVisible); } @@ -454,6 +455,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm super.onResume(); adapter.setScreenOrientation(DashLocationFragment.getScreenOrientation(getActivity())); startLocationUpdate(); + changeKeyboard(getMyApplication().getSettings().COORDS_USE_OSMAND_KEYBOARD.get()); } @Override From a7a846130d837bbdcda6b5e81550dfa4b6a083ce Mon Sep 17 00:00:00 2001 From: Chumva Date: Thu, 29 Mar 2018 18:02:55 +0300 Subject: [PATCH 02/11] delete unnecessary comment --- .../osmand/plus/mapmarkers/CoordinateInputDialogFragment.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java index 36b9f70185..3024c9f6ff 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java @@ -182,7 +182,6 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm }); registerMainView(); -// changeKeyboard(getMyApplication().getSettings().COORDS_USE_OSMAND_KEYBOARD.get()); return mainView; } @@ -351,7 +350,6 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm boolean isCurrentlyVisible = isOsmandKeyboardCurrentlyVisible(); if (!isCurrentlyVisible && !useOsmandKeyboard) { changeKeyboard(true); - getMyApplication().getSettings().COORDS_USE_OSMAND_KEYBOARD.set(true); } else { changeOsmandKeyboardVisibility(!isCurrentlyVisible); } From 88c44dcc68b230a0473dc93feac8036596475d1c Mon Sep 17 00:00:00 2001 From: Chumva Date: Thu, 29 Mar 2018 18:29:40 +0300 Subject: [PATCH 03/11] change name of OsmandPreference --- OsmAnd/src/net/osmand/plus/OsmandSettings.java | 2 +- .../mapmarkers/CoordinateInputBottomSheetDialogFragment.java | 4 ++-- .../osmand/plus/mapmarkers/CoordinateInputDialogFragment.java | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java index 50c31dd023..a6c933b52b 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java @@ -721,7 +721,7 @@ public class OsmandSettings { public final CommonPreference COORDS_INPUT_USE_RIGHT_SIDE = new BooleanPreference("coords_input_use_right_side", true).makeGlobal(); public final CommonPreference COORDS_INPUT_FORMAT = new IntPreference("coords_input_format", CoordinateInputFormats.DD_MM_MMM); - public final OsmandPreference COORDS_USE_OSMAND_KEYBOARD = new BooleanPreference("coords_use_osmand_keyboard", true).makeGlobal(); + public final OsmandPreference COORDS_INPUT_USE_OSMAND_KEYBOARD = new BooleanPreference("coords_use_osmand_keyboard", true).makeGlobal(); public final CommonPreference USE_MAPILLARY_FILTER = new BooleanPreference("use_mapillary_filters", false).makeGlobal(); public final CommonPreference MAPILLARY_FILTER_USER_KEY = new StringPreference("mapillary_filter_user_key", "").makeGlobal(); diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputBottomSheetDialogFragment.java index 484a1088b1..013014e98b 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputBottomSheetDialogFragment.java @@ -37,7 +37,7 @@ public class CoordinateInputBottomSheetDialogFragment extends MenuBottomSheetDia @Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); - useOsmandKeyboard = getMyApplication().getSettings().COORDS_USE_OSMAND_KEYBOARD.get(); + useOsmandKeyboard = getMyApplication().getSettings().COORDS_INPUT_USE_OSMAND_KEYBOARD.get(); } @Override @@ -56,9 +56,9 @@ public class CoordinateInputBottomSheetDialogFragment extends MenuBottomSheetDia @Override public void onClick(View v) { if (listener != null) { + settings.COORDS_INPUT_USE_OSMAND_KEYBOARD.set(!useOsmandKeyboard); listener.onKeyboardChanged(!useOsmandKeyboard); } - settings.COORDS_USE_OSMAND_KEYBOARD.set(!useOsmandKeyboard); dismiss(); } }) diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java index 3024c9f6ff..af2c4aedab 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java @@ -453,7 +453,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm super.onResume(); adapter.setScreenOrientation(DashLocationFragment.getScreenOrientation(getActivity())); startLocationUpdate(); - changeKeyboard(getMyApplication().getSettings().COORDS_USE_OSMAND_KEYBOARD.get()); + changeKeyboard(getMyApplication().getSettings().COORDS_INPUT_USE_OSMAND_KEYBOARD.get()); } @Override From cae0f0ab34232a0e6c0e198f06751fcafc5c3cda Mon Sep 17 00:00:00 2001 From: Chumva Date: Thu, 29 Mar 2018 18:34:46 +0300 Subject: [PATCH 04/11] add pref variable --- .../mapmarkers/CoordinateInputBottomSheetDialogFragment.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputBottomSheetDialogFragment.java index 013014e98b..38ced128ba 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputBottomSheetDialogFragment.java @@ -56,8 +56,9 @@ public class CoordinateInputBottomSheetDialogFragment extends MenuBottomSheetDia @Override public void onClick(View v) { if (listener != null) { - settings.COORDS_INPUT_USE_OSMAND_KEYBOARD.set(!useOsmandKeyboard); - listener.onKeyboardChanged(!useOsmandKeyboard); + OsmandSettings.CommonPreference pref = settings.COORDS_INPUT_USE_RIGHT_SIDE; + pref.set(!pref.get()); + listener.onKeyboardChanged(pref.get()); } dismiss(); } From 425431af1c9365c627e76c3a25285df36d3aa747 Mon Sep 17 00:00:00 2001 From: Chumva Date: Thu, 29 Mar 2018 18:38:31 +0300 Subject: [PATCH 05/11] change type of preference to CommonPreference --- OsmAnd/src/net/osmand/plus/OsmandSettings.java | 2 +- .../mapmarkers/CoordinateInputBottomSheetDialogFragment.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java index a6c933b52b..adfa47e719 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java @@ -721,7 +721,7 @@ public class OsmandSettings { public final CommonPreference COORDS_INPUT_USE_RIGHT_SIDE = new BooleanPreference("coords_input_use_right_side", true).makeGlobal(); public final CommonPreference COORDS_INPUT_FORMAT = new IntPreference("coords_input_format", CoordinateInputFormats.DD_MM_MMM); - public final OsmandPreference COORDS_INPUT_USE_OSMAND_KEYBOARD = new BooleanPreference("coords_use_osmand_keyboard", true).makeGlobal(); + public final CommonPreference COORDS_INPUT_USE_OSMAND_KEYBOARD = new BooleanPreference("coords_input_use_osmand_keyboard", true).makeGlobal(); public final CommonPreference USE_MAPILLARY_FILTER = new BooleanPreference("use_mapillary_filters", false).makeGlobal(); public final CommonPreference MAPILLARY_FILTER_USER_KEY = new StringPreference("mapillary_filter_user_key", "").makeGlobal(); diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputBottomSheetDialogFragment.java index 38ced128ba..9d347311f5 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputBottomSheetDialogFragment.java @@ -56,7 +56,7 @@ public class CoordinateInputBottomSheetDialogFragment extends MenuBottomSheetDia @Override public void onClick(View v) { if (listener != null) { - OsmandSettings.CommonPreference pref = settings.COORDS_INPUT_USE_RIGHT_SIDE; + OsmandSettings.OsmandPreference pref = settings.COORDS_INPUT_USE_OSMAND_KEYBOARD; pref.set(!pref.get()); listener.onKeyboardChanged(pref.get()); } From 1ea5b3cff1bc883cd6018180a22eddfbda2626f4 Mon Sep 17 00:00:00 2001 From: Chumva Date: Fri, 30 Mar 2018 13:15:31 +0300 Subject: [PATCH 06/11] delete global variable useOsmandKeyboard --- ...ordinateInputBottomSheetDialogFragment.java | 16 +++------------- .../CoordinateInputDialogFragment.java | 18 ++++++++---------- 2 files changed, 11 insertions(+), 23 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputBottomSheetDialogFragment.java index 9d347311f5..567eae464a 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputBottomSheetDialogFragment.java @@ -20,16 +20,12 @@ import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem; import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.mapmarkers.CoordinateInputFormats.CoordinateInputFormatDef; -import static net.osmand.plus.mapmarkers.CoordinateInputDialogFragment.USE_OSMAND_KEYBOARD; - public class CoordinateInputBottomSheetDialogFragment extends MenuBottomSheetDialogFragment { public final static String TAG = "CoordinateInputBottomSheetDialogFragment"; private CoordinateInputFormatChangeListener listener; - private boolean useOsmandKeyboard; - public void setListener(CoordinateInputFormatChangeListener listener) { this.listener = listener; } @@ -37,7 +33,6 @@ public class CoordinateInputBottomSheetDialogFragment extends MenuBottomSheetDia @Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); - useOsmandKeyboard = getMyApplication().getSettings().COORDS_INPUT_USE_OSMAND_KEYBOARD.get(); } @Override @@ -46,6 +41,7 @@ public class CoordinateInputBottomSheetDialogFragment extends MenuBottomSheetDia final OsmandSettings settings = getMyApplication().getSettings(); items.add(new TitleItem(getString(R.string.shared_string_options))); + boolean useOsmandKeyboard = settings.COORDS_INPUT_USE_OSMAND_KEYBOARD.get(); BaseBottomSheetItem useSystemKeyboardItem = new BottomSheetItemWithCompoundButton.Builder() .setChecked(!useOsmandKeyboard) @@ -58,7 +54,7 @@ public class CoordinateInputBottomSheetDialogFragment extends MenuBottomSheetDia if (listener != null) { OsmandSettings.OsmandPreference pref = settings.COORDS_INPUT_USE_OSMAND_KEYBOARD; pref.set(!pref.get()); - listener.onKeyboardChanged(pref.get()); + listener.onKeyboardChanged(); } dismiss(); } @@ -129,12 +125,6 @@ public class CoordinateInputBottomSheetDialogFragment extends MenuBottomSheetDia } } - @Override - public void onSaveInstanceState(Bundle outState) { - outState.putBoolean(USE_OSMAND_KEYBOARD, useOsmandKeyboard); - super.onSaveInstanceState(outState); - } - @Override protected int getDismissButtonTextId() { return R.string.shared_string_close; @@ -147,7 +137,7 @@ public class CoordinateInputBottomSheetDialogFragment extends MenuBottomSheetDia interface CoordinateInputFormatChangeListener { - void onKeyboardChanged(boolean useOsmandKeyboard); + void onKeyboardChanged(); void onHandChanged(); diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java index af2c4aedab..109398266a 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java @@ -76,8 +76,6 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm public static final String TAG = "CoordinateInputDialogFragment"; - public static final String USE_OSMAND_KEYBOARD = "use_osmand_keyboard"; - private final List mapMarkers = new ArrayList<>(); private OnMapMarkersSavedListener listener; @@ -171,7 +169,6 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm @Override public void onClick(View view) { Bundle args = new Bundle(); - args.putBoolean(USE_OSMAND_KEYBOARD, useOsmandKeyboard); CoordinateInputBottomSheetDialogFragment fragment = new CoordinateInputBottomSheetDialogFragment(); fragment.setUsedOnMap(false); @@ -182,6 +179,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm }); registerMainView(); + return mainView; } @@ -253,7 +251,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm @Override public void onClick(View view) { if (useOsmandKeyboard) { - changeKeyboard(false); + changeKeyboard(); } } }); @@ -349,7 +347,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm public void onClick(View view) { boolean isCurrentlyVisible = isOsmandKeyboardCurrentlyVisible(); if (!isCurrentlyVisible && !useOsmandKeyboard) { - changeKeyboard(true); + changeKeyboard(); } else { changeOsmandKeyboardVisibility(!isCurrentlyVisible); } @@ -453,7 +451,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm super.onResume(); adapter.setScreenOrientation(DashLocationFragment.getScreenOrientation(getActivity())); startLocationUpdate(); - changeKeyboard(getMyApplication().getSettings().COORDS_INPUT_USE_OSMAND_KEYBOARD.get()); + changeKeyboard(); } @Override @@ -738,8 +736,8 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm return sb.toString(); } - private void changeKeyboard(boolean useOsmandKeyboard) { - this.useOsmandKeyboard = useOsmandKeyboard; + private void changeKeyboard() { + this.useOsmandKeyboard = getMyApplication().getSettings().COORDS_INPUT_USE_OSMAND_KEYBOARD.get(); changeOsmandKeyboardVisibility(useOsmandKeyboard); final View focusedView = getDialog().getCurrentFocus(); if (focusedView != null) { @@ -761,8 +759,8 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm return new CoordinateInputFormatChangeListener() { @Override - public void onKeyboardChanged(boolean useOsmandKeyboard) { - changeKeyboard(useOsmandKeyboard); + public void onKeyboardChanged() { + changeKeyboard(); } @Override From 8d8dce0b902026005cc7dd6618bc14f20877ae51 Mon Sep 17 00:00:00 2001 From: Chumva Date: Fri, 30 Mar 2018 13:21:49 +0300 Subject: [PATCH 07/11] add change to osmand keyboard in showHideKeyboardIcon --- .../osmand/plus/mapmarkers/CoordinateInputDialogFragment.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java index 109398266a..b3841614ff 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java @@ -54,6 +54,7 @@ import net.osmand.plus.MapMarkersHelper.MapMarker; import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener; import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener; import net.osmand.plus.OsmandApplication; +import net.osmand.plus.OsmandSettings; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.base.MapViewTrackingUtilities; @@ -347,6 +348,8 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm public void onClick(View view) { boolean isCurrentlyVisible = isOsmandKeyboardCurrentlyVisible(); if (!isCurrentlyVisible && !useOsmandKeyboard) { + OsmandSettings.OsmandPreference pref = getMyApplication().getSettings().COORDS_INPUT_USE_OSMAND_KEYBOARD; + pref.set(!pref.get()); changeKeyboard(); } else { changeOsmandKeyboardVisibility(!isCurrentlyVisible); From 76b89c5346a7fff978fe5410c703d81dafd00e78 Mon Sep 17 00:00:00 2001 From: Chumva Date: Fri, 30 Mar 2018 13:48:35 +0300 Subject: [PATCH 08/11] delete global variable useOsmandKeyboard and add two methods --- ...rdinateInputBottomSheetDialogFragment.java | 5 --- .../CoordinateInputDialogFragment.java | 31 +++++++++++-------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputBottomSheetDialogFragment.java index 567eae464a..88bca03bf5 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputBottomSheetDialogFragment.java @@ -30,11 +30,6 @@ public class CoordinateInputBottomSheetDialogFragment extends MenuBottomSheetDia this.listener = listener; } - @Override - public void onCreate(@Nullable Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - } - @Override public void createMenuItems(Bundle savedInstanceState) { final Context context = getContext(); diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java index b3841614ff..42bba50198 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java @@ -88,7 +88,6 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm private boolean lightTheme; private boolean orientationPortrait; - private boolean useOsmandKeyboard = true; private boolean north = true; private boolean east = true; @@ -169,11 +168,8 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm mainView.findViewById(R.id.options_button).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - Bundle args = new Bundle(); - CoordinateInputBottomSheetDialogFragment fragment = new CoordinateInputBottomSheetDialogFragment(); fragment.setUsedOnMap(false); - fragment.setArguments(args); fragment.setListener(createCoordinateInputFormatChangeListener()); fragment.show(getChildFragmentManager(), CoordinateInputBottomSheetDialogFragment.TAG); } @@ -251,7 +247,8 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm pointNameKeyboardBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - if (useOsmandKeyboard) { + if (getOsmandKeyboard()) { + changeOsmandKeyboard(); changeKeyboard(); } } @@ -292,7 +289,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm View.OnClickListener onClickListener = new View.OnClickListener() { @Override public void onClick(View v) { - if (useOsmandKeyboard) { + if (getOsmandKeyboard()) { View focusedView = getDialog().getCurrentFocus(); if (focusedView != null && focusedView instanceof EditText) { EditText focusedEditText = (EditText) focusedView; @@ -338,7 +335,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm R.id.keyboard_item_next_field, R.id.keyboard_item_backspace); - if (!useOsmandKeyboard && isOsmandKeyboardCurrentlyVisible()) { + if (!getOsmandKeyboard() && isOsmandKeyboardCurrentlyVisible()) { changeOsmandKeyboardVisibility(false); } @@ -347,9 +344,8 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm @Override public void onClick(View view) { boolean isCurrentlyVisible = isOsmandKeyboardCurrentlyVisible(); - if (!isCurrentlyVisible && !useOsmandKeyboard) { - OsmandSettings.OsmandPreference pref = getMyApplication().getSettings().COORDS_INPUT_USE_OSMAND_KEYBOARD; - pref.set(!pref.get()); + if (!isCurrentlyVisible && !getOsmandKeyboard()) { + changeOsmandKeyboard(); changeKeyboard(); } else { changeOsmandKeyboardVisibility(!isCurrentlyVisible); @@ -590,7 +586,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm View.OnTouchListener inputEditTextOnTouchListener = new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent motionEvent) { - if (useOsmandKeyboard) { + if (getOsmandKeyboard()) { if (!isOsmandKeyboardCurrentlyVisible()) { changeOsmandKeyboardVisibility(true); } @@ -616,7 +612,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm View.OnLongClickListener inputEditTextOnLongClickListener = new View.OnLongClickListener() { @Override public boolean onLongClick(final View view) { - if (useOsmandKeyboard) { + if (getOsmandKeyboard()) { final EditText inputEditText = (EditText) view; PopupMenu popupMenu = new PopupMenu(getContext(), inputEditText); Menu menu = popupMenu.getMenu(); @@ -739,8 +735,17 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm return sb.toString(); } + private boolean getOsmandKeyboard() { + return getMyApplication().getSettings().COORDS_INPUT_USE_OSMAND_KEYBOARD.get(); + } + + private void changeOsmandKeyboard() { + OsmandSettings.OsmandPreference pref = getMyApplication().getSettings().COORDS_INPUT_USE_OSMAND_KEYBOARD; + pref.set(!pref.get()); + } + private void changeKeyboard() { - this.useOsmandKeyboard = getMyApplication().getSettings().COORDS_INPUT_USE_OSMAND_KEYBOARD.get(); + boolean useOsmandKeyboard = getOsmandKeyboard(); changeOsmandKeyboardVisibility(useOsmandKeyboard); final View focusedView = getDialog().getCurrentFocus(); if (focusedView != null) { From fb2fc6d1fc5df537cd2d196a11455a3ab6ad19de Mon Sep 17 00:00:00 2001 From: Chumva Date: Fri, 30 Mar 2018 13:57:34 +0300 Subject: [PATCH 09/11] rename two methods --- .../CoordinateInputDialogFragment.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java index 42bba50198..1433211f43 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java @@ -247,8 +247,8 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm pointNameKeyboardBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - if (getOsmandKeyboard()) { - changeOsmandKeyboard(); + if (isOsmandKeyboardOn()) { + changeOsmandKeyboardSetting(); changeKeyboard(); } } @@ -289,7 +289,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm View.OnClickListener onClickListener = new View.OnClickListener() { @Override public void onClick(View v) { - if (getOsmandKeyboard()) { + if (isOsmandKeyboardOn()) { View focusedView = getDialog().getCurrentFocus(); if (focusedView != null && focusedView instanceof EditText) { EditText focusedEditText = (EditText) focusedView; @@ -335,7 +335,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm R.id.keyboard_item_next_field, R.id.keyboard_item_backspace); - if (!getOsmandKeyboard() && isOsmandKeyboardCurrentlyVisible()) { + if (!isOsmandKeyboardOn() && isOsmandKeyboardCurrentlyVisible()) { changeOsmandKeyboardVisibility(false); } @@ -344,8 +344,8 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm @Override public void onClick(View view) { boolean isCurrentlyVisible = isOsmandKeyboardCurrentlyVisible(); - if (!isCurrentlyVisible && !getOsmandKeyboard()) { - changeOsmandKeyboard(); + if (!isCurrentlyVisible && !isOsmandKeyboardOn()) { + changeOsmandKeyboardSetting(); changeKeyboard(); } else { changeOsmandKeyboardVisibility(!isCurrentlyVisible); @@ -586,7 +586,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm View.OnTouchListener inputEditTextOnTouchListener = new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent motionEvent) { - if (getOsmandKeyboard()) { + if (isOsmandKeyboardOn()) { if (!isOsmandKeyboardCurrentlyVisible()) { changeOsmandKeyboardVisibility(true); } @@ -612,7 +612,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm View.OnLongClickListener inputEditTextOnLongClickListener = new View.OnLongClickListener() { @Override public boolean onLongClick(final View view) { - if (getOsmandKeyboard()) { + if (isOsmandKeyboardOn()) { final EditText inputEditText = (EditText) view; PopupMenu popupMenu = new PopupMenu(getContext(), inputEditText); Menu menu = popupMenu.getMenu(); @@ -735,17 +735,17 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm return sb.toString(); } - private boolean getOsmandKeyboard() { + private boolean isOsmandKeyboardOn() { return getMyApplication().getSettings().COORDS_INPUT_USE_OSMAND_KEYBOARD.get(); } - private void changeOsmandKeyboard() { + private void changeOsmandKeyboardSetting() { OsmandSettings.OsmandPreference pref = getMyApplication().getSettings().COORDS_INPUT_USE_OSMAND_KEYBOARD; pref.set(!pref.get()); } private void changeKeyboard() { - boolean useOsmandKeyboard = getOsmandKeyboard(); + boolean useOsmandKeyboard = isOsmandKeyboardOn(); changeOsmandKeyboardVisibility(useOsmandKeyboard); final View focusedView = getDialog().getCurrentFocus(); if (focusedView != null) { From c70b29a04f721b5afbc5daa151f32f249558088e Mon Sep 17 00:00:00 2001 From: Chumva Date: Fri, 30 Mar 2018 14:29:05 +0300 Subject: [PATCH 10/11] add changeOsmandKeyboardSetting to changeKeyboard and requestFocus in onResume --- .../mapmarkers/CoordinateInputBottomSheetDialogFragment.java | 2 -- .../plus/mapmarkers/CoordinateInputDialogFragment.java | 5 ++--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputBottomSheetDialogFragment.java index 88bca03bf5..3c2056336e 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputBottomSheetDialogFragment.java @@ -47,8 +47,6 @@ public class CoordinateInputBottomSheetDialogFragment extends MenuBottomSheetDia @Override public void onClick(View v) { if (listener != null) { - OsmandSettings.OsmandPreference pref = settings.COORDS_INPUT_USE_OSMAND_KEYBOARD; - pref.set(!pref.get()); listener.onKeyboardChanged(); } dismiss(); diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java index 1433211f43..717e7ac703 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java @@ -248,7 +248,6 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm @Override public void onClick(View view) { if (isOsmandKeyboardOn()) { - changeOsmandKeyboardSetting(); changeKeyboard(); } } @@ -345,7 +344,6 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm public void onClick(View view) { boolean isCurrentlyVisible = isOsmandKeyboardCurrentlyVisible(); if (!isCurrentlyVisible && !isOsmandKeyboardOn()) { - changeOsmandKeyboardSetting(); changeKeyboard(); } else { changeOsmandKeyboardVisibility(!isCurrentlyVisible); @@ -450,7 +448,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm super.onResume(); adapter.setScreenOrientation(DashLocationFragment.getScreenOrientation(getActivity())); startLocationUpdate(); - changeKeyboard(); + editTexts.get(0).requestFocus(); } @Override @@ -745,6 +743,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm } private void changeKeyboard() { + changeOsmandKeyboardSetting(); boolean useOsmandKeyboard = isOsmandKeyboardOn(); changeOsmandKeyboardVisibility(useOsmandKeyboard); final View focusedView = getDialog().getCurrentFocus(); From 208832e0ccc2d57fc9116f7a427ef2273bcf550d Mon Sep 17 00:00:00 2001 From: Chumva Date: Fri, 30 Mar 2018 14:38:47 +0300 Subject: [PATCH 11/11] delete requestFocus --- .../osmand/plus/mapmarkers/CoordinateInputDialogFragment.java | 1 - 1 file changed, 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java index 717e7ac703..020e762248 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java @@ -448,7 +448,6 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm super.onResume(); adapter.setScreenOrientation(DashLocationFragment.getScreenOrientation(getActivity())); startLocationUpdate(); - editTexts.get(0).requestFocus(); } @Override