Fix options menu

This commit is contained in:
PavelRatushny 2017-11-01 19:00:15 +02:00
parent 0e247c3c79
commit 99a24260a6
6 changed files with 397 additions and 488 deletions

View file

@ -1,73 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/bg_color"
android:orientation="vertical">
<ScrollView
android:id="@+id/marker_coordinate_input_scroll_view"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="@dimen/bottom_sheet_content_padding_small">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/coordinate_input_title"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_title_height"
android:gravity="center_vertical"
android:paddingEnd="@dimen/content_padding"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
android:paddingStart="@dimen/content_padding"
android:text="@string/fast_coordinates_input"
android:textAppearance="@style/TextAppearance.ListItemTitle"
osmand:typeface="@string/font_roboto_medium"/>
<TextView
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_descr_height"
android:paddingEnd="@dimen/content_padding"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
android:paddingStart="@dimen/content_padding"
android:text="@string/fast_coordinates_input_descr"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"/>
<include layout="@layout/marker_coordinate_formats"/>
</LinearLayout>
</ScrollView>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/dashboard_divider"/>
<FrameLayout
android:id="@+id/cancel_row"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_cancel_button_height"
android:background="?attr/selectableItemBackground">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/shared_string_close"
android:textAllCaps="true"
android:textColor="?attr/color_dialog_buttons"
android:textSize="@dimen/default_desc_text_size"
android:textStyle="bold"/>
</FrameLayout>
</LinearLayout>

View file

@ -1,120 +1,289 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:osmand="http://schemas.android.com/apk/res-auto" xmlns:osmand="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/bg_color" android:background="?attr/bg_color"
android:orientation="vertical"> android:orientation="vertical">
<ScrollView <ScrollView
android:id="@+id/marker_coordinate_input_scroll_view" android:id="@+id/marker_coordinate_input_scroll_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
android:paddingBottom="@dimen/bottom_sheet_content_padding_small"> android:paddingBottom="@dimen/bottom_sheet_content_padding_small">
<net.osmand.plus.widgets.TextViewEx <net.osmand.plus.widgets.TextViewEx
android:id="@+id/coordinate_input_title" android:id="@+id/coordinate_input_title"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_title_height" android:layout_height="@dimen/bottom_sheet_title_height"
android:gravity="center_vertical" android:gravity="center_vertical"
android:paddingEnd="@dimen/content_padding" android:paddingEnd="@dimen/content_padding"
android:paddingLeft="@dimen/content_padding" android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding" android:paddingRight="@dimen/content_padding"
android:paddingStart="@dimen/content_padding" android:paddingStart="@dimen/content_padding"
android:text="@string/shared_string_options" android:text="@string/shared_string_options"
android:textAppearance="@style/TextAppearance.ListItemTitle" android:textAppearance="@style/TextAppearance.ListItemTitle"
osmand:typeface="@string/font_roboto_medium"/> osmand:typeface="@string/font_roboto_medium"/>
<LinearLayout <LinearLayout
android:id="@+id/use_system_keyboard_row" android:id="@+id/use_system_keyboard_row"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_list_item_height" android:layout_height="@dimen/bottom_sheet_list_item_height"
android:background="?attr/selectableItemBackground" android:background="?attr/selectableItemBackground"
android:descendantFocusability="blocksDescendants" android:descendantFocusability="blocksDescendants"
android:minHeight="@dimen/bottom_sheet_list_item_height" android:minHeight="@dimen/bottom_sheet_list_item_height"
android:paddingLeft="@dimen/content_padding" android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"> android:paddingRight="@dimen/content_padding">
<ImageView <ImageView
android:layout_gravity="center_vertical" android:id="@+id/use_system_keyboard_icon"
android:id="@+id/use_system_keyboard_icon" android:layout_width="wrap_content"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_height="wrap_content" android:layout_gravity="center_vertical"
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin" android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
android:layout_marginRight="@dimen/bottom_sheet_icon_margin" android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
tools:src="@drawable/ic_action_keyboard"/> tools:src="@drawable/ic_action_keyboard"/>
<TextView <TextView
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_weight="1" android:layout_weight="1"
android:ellipsize="end" android:ellipsize="end"
android:maxLines="1" android:maxLines="1"
android:text="@string/use_system_keyboard" android:text="@string/use_system_keyboard"
android:textAppearance="@style/TextAppearance.ListItemTitle"/> android:textAppearance="@style/TextAppearance.ListItemTitle"/>
<android.support.v7.widget.SwitchCompat <android.support.v7.widget.SwitchCompat
android:id="@+id/use_system_keyboard_switch" android:id="@+id/use_system_keyboard_switch"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical|end" android:layout_gravity="center_vertical|end"
android:background="@null" android:background="@null"
android:clickable="false" android:clickable="false"
android:focusable="false" android:focusable="false"
android:focusableInTouchMode="false"/> android:focusableInTouchMode="false"/>
</LinearLayout> </LinearLayout>
<View <View
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="1dp" android:layout_height="1dp"
android:background="?attr/dashboard_divider"/> android:background="?attr/dashboard_divider"/>
<TextView <LinearLayout
android:textColor="?android:textColorSecondary" android:id="@+id/go_to_next_field_row"
android:ellipsize="end" android:layout_width="match_parent"
android:maxLines="1" android:layout_height="@dimen/bottom_sheet_list_item_height"
android:textAllCaps="true" android:background="?attr/selectableItemBackground"
android:paddingTop="@dimen/bottom_sheet_content_padding_small" android:descendantFocusability="blocksDescendants"
android:paddingBottom="@dimen/bottom_sheet_content_padding_small" android:minHeight="@dimen/bottom_sheet_list_item_height"
android:paddingLeft="@dimen/content_padding" android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding" android:paddingRight="@dimen/content_padding">
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/coordinates_format"/>
<include layout="@layout/marker_coordinate_formats"/> <ImageView
android:id="@+id/go_to_next_field_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
tools:src="@drawable/ic_action_keyboard"/>
</LinearLayout> <TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:ellipsize="end"
android:maxLines="1"
android:text="@string/go_to_next_field"
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
</ScrollView> <android.support.v7.widget.SwitchCompat
android:id="@+id/go_to_next_field_switch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|end"
android:background="@null"
android:clickable="false"
android:focusable="false"
android:focusableInTouchMode="false"/>
</LinearLayout>
<View <TextView
android:layout_width="match_parent" android:id="@+id/coordinate_input_accuracy_descr"
android:layout_height="1dp" android:layout_width="match_parent"
android:background="?attr/dashboard_divider"/> android:layout_height="@dimen/bottom_sheet_descr_height"
android:paddingEnd="@dimen/content_padding"
android:paddingLeft="@dimen/bottom_sheet_divider_margin_start"
android:paddingRight="@dimen/content_padding"
android:paddingStart="@dimen/bottom_sheet_divider_margin_start"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"
tools:text="@string/coordinate_input_accuracy_description"/>
<FrameLayout <LinearLayout
android:id="@+id/cancel_row" android:id="@+id/four_digits_row"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_cancel_button_height" android:layout_height="@dimen/bottom_sheet_list_item_height"
android:background="?attr/selectableItemBackground"> android:background="?attr/selectableItemBackground"
android:gravity="center_vertical"
android:minHeight="@dimen/bottom_sheet_list_item_height"
android:paddingEnd="@dimen/content_padding"
android:paddingLeft="@dimen/bottom_sheet_divider_margin_start"
android:paddingRight="@dimen/content_padding"
android:paddingStart="@dimen/bottom_sheet_divider_margin_start">
<TextView <LinearLayout
android:layout_width="wrap_content" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:layout_gravity="center" android:layout_weight="1"
android:text="@string/shared_string_close" android:gravity="center_vertical"
android:textAllCaps="true" android:orientation="vertical">
android:textColor="?attr/color_dialog_buttons"
android:textSize="@dimen/default_desc_text_size" <TextView
android:textStyle="bold"/> android:id="@+id/four_digits_title"
</FrameLayout> android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:textAppearance="@style/TextAppearance.ListItemTitle"
tools:text="4 digits"/>
<TextView
android:id="@+id/four_digits_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="00:00.0000"/>
</LinearLayout>
<RadioButton
android:id="@+id/four_digits_radio_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:clickable="false"
android:focusable="false"/>
</LinearLayout>
<LinearLayout
android:id="@+id/three_digits_row"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_list_item_height"
android:background="?attr/selectableItemBackground"
android:gravity="center_vertical"
android:minHeight="@dimen/bottom_sheet_list_item_height"
android:paddingEnd="@dimen/content_padding"
android:paddingLeft="@dimen/bottom_sheet_divider_margin_start"
android:paddingRight="@dimen/content_padding"
android:paddingStart="@dimen/bottom_sheet_divider_margin_start">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:orientation="vertical">
<TextView
android:id="@+id/three_digits_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:textAppearance="@style/TextAppearance.ListItemTitle"
tools:text="3 digits"/>
<TextView
android:id="@+id/three_digits_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="00:00.000"/>
</LinearLayout>
<RadioButton
android:id="@+id/three_digits_radio_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:clickable="false"
android:focusable="false"/>
</LinearLayout>
<LinearLayout
android:id="@+id/two_digits_row"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_list_item_height"
android:background="?attr/selectableItemBackground"
android:gravity="center_vertical"
android:minHeight="@dimen/bottom_sheet_list_item_height"
android:paddingEnd="@dimen/content_padding"
android:paddingLeft="@dimen/bottom_sheet_divider_margin_start"
android:paddingRight="@dimen/content_padding"
android:paddingStart="@dimen/bottom_sheet_divider_margin_start">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:orientation="vertical">
<TextView
android:id="@+id/two_digits_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:textAppearance="@style/TextAppearance.ListItemTitle"
tools:text="2 digits"/>
<TextView
android:id="@+id/two_digits_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="00:00.00"/>
</LinearLayout>
<RadioButton
android:id="@+id/two_digits_radio_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:clickable="false"
android:focusable="false"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/dashboard_divider"/>
<FrameLayout
android:id="@+id/cancel_row"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_cancel_button_height"
android:background="?attr/selectableItemBackground">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/shared_string_close"
android:textAllCaps="true"
android:textColor="?attr/color_dialog_buttons"
android:textSize="@dimen/default_desc_text_size"
android:textStyle="bold"/>
</FrameLayout>
</LinearLayout> </LinearLayout>

View file

@ -1,123 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/degrees_row"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_list_item_height"
android:background="?attr/selectableItemBackground"
android:gravity="center_vertical"
android:minHeight="@dimen/bottom_sheet_list_item_height"
android:paddingEnd="@dimen/content_padding"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
android:paddingStart="@dimen/content_padding">
<ImageView
android:id="@+id/degrees_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
tools:src="@drawable/ic_action_coordinates_latitude"/>
<TextView
android:id="@+id/degrees_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLines="1"
android:textAppearance="@style/TextAppearance.ListItemTitle"
tools:text="DDD.DD"/>
<RadioButton
android:id="@+id/degrees_radio_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:clickable="false"
android:focusable="false"/>
</LinearLayout>
<LinearLayout
android:id="@+id/minutes_row"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_list_item_height"
android:background="?attr/selectableItemBackground"
android:gravity="center_vertical"
android:minHeight="@dimen/bottom_sheet_list_item_height"
android:paddingEnd="@dimen/content_padding"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
android:paddingStart="@dimen/content_padding">
<ImageView
android:id="@+id/minutes_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
tools:src="@drawable/ic_action_coordinates_latitude"/>
<TextView
android:id="@+id/minutes_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLines="1"
android:textAppearance="@style/TextAppearance.ListItemTitle"
tools:text="DDD MM.MM"/>
<RadioButton
android:id="@+id/minutes_radio_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:clickable="false"
android:focusable="false"/>
</LinearLayout>
<LinearLayout
android:id="@+id/seconds_row"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_list_item_height"
android:background="?attr/selectableItemBackground"
android:gravity="center_vertical"
android:minHeight="@dimen/bottom_sheet_list_item_height"
android:paddingEnd="@dimen/content_padding"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
android:paddingStart="@dimen/content_padding">
<ImageView
android:id="@+id/seconds_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
tools:src="@drawable/ic_action_coordinates_latitude"/>
<TextView
android:id="@+id/seconds_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLines="1"
android:textAppearance="@style/TextAppearance.ListItemTitle"
tools:text="DDD MM SS.SS"/>
<RadioButton
android:id="@+id/seconds_radio_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:clickable="false"
android:focusable="false"/>
</LinearLayout>
</LinearLayout>

View file

@ -9,6 +9,9 @@
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated). 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 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="coordinate_input_accuracy_description">Automatically switch to the next field after entering %1$d digits after the decimal point</string>
<string name="coordinate_input_accuracy">%1$d digits</string>
<string name="go_to_next_field">Go to next field</string>
<string name="import_gpx_file_description">can be imported as Favorites points, or as track file.</string> <string name="import_gpx_file_description">can be imported as Favorites points, or as track file.</string>
<string name="import_as_gpx">Import as GPX file</string> <string name="import_as_gpx">Import as GPX file</string>
<string name="import_as_favorites">Import as Favorites</string> <string name="import_as_favorites">Import as Favorites</string>

View file

@ -33,10 +33,10 @@ public class CoordinateInputBottomSheetDialogFragment extends BottomSheetDialogF
private boolean portrait; private boolean portrait;
private View mainView; private View mainView;
private boolean night; private boolean night;
private int coordinateFormat = -1;
private boolean useOsmandKeyboard = true; private boolean useOsmandKeyboard = true;
private boolean goToNextField;
private int accuracy = -1;
private CoordinateInputFormatChangeListener listener; private CoordinateInputFormatChangeListener listener;
private boolean shouldClose;
public void setListener(CoordinateInputFormatChangeListener listener) { public void setListener(CoordinateInputFormatChangeListener listener) {
this.listener = listener; this.listener = listener;
@ -47,10 +47,9 @@ public class CoordinateInputBottomSheetDialogFragment extends BottomSheetDialogF
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
Bundle args = getArguments(); Bundle args = getArguments();
if (args != null) { if (args != null) {
coordinateFormat = args.getInt(CoordinateInputDialogFragment.COORDINATE_FORMAT);
useOsmandKeyboard = args.getBoolean(CoordinateInputDialogFragment.USE_OSMAND_KEYBOARD); useOsmandKeyboard = args.getBoolean(CoordinateInputDialogFragment.USE_OSMAND_KEYBOARD);
} else { goToNextField = args.getBoolean(CoordinateInputDialogFragment.GO_TO_NEXT_FIELD);
shouldClose = true; accuracy = args.getInt(CoordinateInputDialogFragment.ACCURACY);
} }
} }
@ -62,8 +61,7 @@ public class CoordinateInputBottomSheetDialogFragment extends BottomSheetDialogF
night = !mapActivity.getMyApplication().getSettings().isLightContent(); night = !mapActivity.getMyApplication().getSettings().isLightContent();
final int themeRes = night ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme; final int themeRes = night ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), coordinateFormat == -1 ? mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_marker_coordinate_input_options_bottom_sheet_helper, container);
R.layout.fragment_marker_coordinate_input_bottom_sheet_dialog : R.layout.fragment_marker_coordinate_input_options_bottom_sheet_helper, container);
if (portrait) { if (portrait) {
AndroidUtils.setBackground(getActivity(), mainView, night, R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark); AndroidUtils.setBackground(getActivity(), mainView, night, R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);
} }
@ -72,93 +70,85 @@ public class CoordinateInputBottomSheetDialogFragment extends BottomSheetDialogF
((TextView) mainView.findViewById(R.id.coordinate_input_title)).setTextColor(getResources().getColor(R.color.ctx_menu_info_text_dark)); ((TextView) mainView.findViewById(R.id.coordinate_input_title)).setTextColor(getResources().getColor(R.color.ctx_menu_info_text_dark));
} }
ImageView degreesIcon = (ImageView) mainView.findViewById(R.id.degrees_icon); ((TextView) mainView.findViewById(R.id.coordinate_input_accuracy_descr)).setText(getString(R.string.coordinate_input_accuracy_description, accuracy));
TextView degreesText = (TextView) mainView.findViewById(R.id.degrees_text);
if (coordinateFormat == PointDescription.FORMAT_DEGREES) {
degreesIcon.setImageDrawable(getIcon(R.drawable.ic_action_coordinates_latitude, R.color.dashboard_blue));
degreesText.setTextColor(ContextCompat.getColor(mapActivity, R.color.dashboard_blue));
((RadioButton) mainView.findViewById(R.id.degrees_radio_button)).setChecked(true);
} else {
degreesIcon.setImageDrawable(getContentIcon(R.drawable.ic_action_coordinates_latitude));
}
degreesText.setText(PointDescription.formatToHumanString(getContext(), PointDescription.FORMAT_DEGREES));
ImageView minutesIcon = (ImageView) mainView.findViewById(R.id.minutes_icon); ((CompoundButton) mainView.findViewById(R.id.go_to_next_field_switch)).setChecked(goToNextField);
TextView minutesText = (TextView) mainView.findViewById(R.id.minutes_text); ((ImageView) mainView.findViewById(R.id.go_to_next_field_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_keyboard));
if (coordinateFormat == PointDescription.FORMAT_MINUTES) { mainView.findViewById(R.id.go_to_next_field_row).setOnClickListener(new View.OnClickListener() {
minutesIcon.setImageDrawable(getIcon(R.drawable.ic_action_coordinates_latitude, R.color.dashboard_blue)); @Override
minutesText.setTextColor(ContextCompat.getColor(mapActivity, R.color.dashboard_blue)); public void onClick(View view) {
((RadioButton) mainView.findViewById(R.id.minutes_radio_button)).setChecked(true); goToNextField = !goToNextField;
} else { ((CompoundButton) mainView.findViewById(R.id.go_to_next_field_switch)).setChecked(goToNextField);
minutesIcon.setImageDrawable(getContentIcon(R.drawable.ic_action_coordinates_latitude)); if (listener != null) {
} listener.onGoToNextFieldChanged(goToNextField);
minutesText.setText(PointDescription.formatToHumanString(getContext(), PointDescription.FORMAT_MINUTES));
ImageView secondsIcon = (ImageView) mainView.findViewById(R.id.seconds_icon);
TextView secondsText = (TextView) mainView.findViewById(R.id.seconds_text);
if (coordinateFormat == PointDescription.FORMAT_SECONDS) {
secondsIcon.setImageDrawable(getIcon(R.drawable.ic_action_coordinates_latitude, R.color.dashboard_blue));
secondsText.setTextColor(ContextCompat.getColor(mapActivity, R.color.dashboard_blue));
((RadioButton) mainView.findViewById(R.id.seconds_radio_button)).setChecked(true);
} else {
secondsIcon.setImageDrawable(getContentIcon(R.drawable.ic_action_coordinates_latitude));
}
secondsText.setText(PointDescription.formatToHumanString(getContext(), PointDescription.FORMAT_SECONDS));
if (coordinateFormat != -1) {
((CompoundButton) mainView.findViewById(R.id.use_system_keyboard_switch)).setChecked(!useOsmandKeyboard);
((ImageView) mainView.findViewById(R.id.use_system_keyboard_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_keyboard));
mainView.findViewById(R.id.use_system_keyboard_row).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
useOsmandKeyboard = !useOsmandKeyboard;
((CompoundButton) mainView.findViewById(R.id.use_system_keyboard_switch)).setChecked(!useOsmandKeyboard);
if (listener != null) {
listener.onKeyboardChanged(useOsmandKeyboard);
}
} }
}); }
highlightSelectedItem(true); });
}
View.OnClickListener formatChangeListener = new View.OnClickListener() { if (accuracy == 4) {
((RadioButton) mainView.findViewById(R.id.four_digits_radio_button)).setChecked(true);
}
((TextView) mainView.findViewById(R.id.four_digits_title)).setText(getString(R.string.coordinate_input_accuracy, 4));
((TextView) mainView.findViewById(R.id.four_digits_description)).setText("00:00." + "5555");
if (accuracy == 3) {
((RadioButton) mainView.findViewById(R.id.three_digits_radio_button)).setChecked(true);
}
((TextView) mainView.findViewById(R.id.three_digits_title)).setText(getString(R.string.coordinate_input_accuracy, 3));
((TextView) mainView.findViewById(R.id.three_digits_description)).setText("00:00." + "555");
if (accuracy == 2) {
((RadioButton) mainView.findViewById(R.id.two_digits_radio_button)).setChecked(true);
}
((TextView) mainView.findViewById(R.id.two_digits_title)).setText(getString(R.string.coordinate_input_accuracy, 2));
((TextView) mainView.findViewById(R.id.two_digits_description)).setText("00:00." + "55");
((CompoundButton) mainView.findViewById(R.id.use_system_keyboard_switch)).setChecked(!useOsmandKeyboard);
((ImageView) mainView.findViewById(R.id.use_system_keyboard_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_keyboard));
mainView.findViewById(R.id.use_system_keyboard_row).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
useOsmandKeyboard = !useOsmandKeyboard;
((CompoundButton) mainView.findViewById(R.id.use_system_keyboard_switch)).setChecked(!useOsmandKeyboard);
if (listener != null) {
listener.onKeyboardChanged(useOsmandKeyboard);
}
}
});
highlightSelectedItem(true);
View.OnClickListener accuracyChangedListener = new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
highlightSelectedItem(false); highlightSelectedItem(false);
switch (view.getId()) { switch (view.getId()) {
case R.id.degrees_row: case R.id.four_digits_row:
coordinateFormat = PointDescription.FORMAT_DEGREES; accuracy = 4;
break; break;
case R.id.minutes_row: case R.id.three_digits_row:
coordinateFormat = PointDescription.FORMAT_MINUTES; accuracy = 3;
break; break;
case R.id.seconds_row: case R.id.two_digits_row:
coordinateFormat = PointDescription.FORMAT_SECONDS; accuracy = 2;
break; break;
default: default:
throw new IllegalArgumentException("Unsupported format"); throw new IllegalArgumentException("Unsupported accuracy");
} }
highlightSelectedItem(true); highlightSelectedItem(true);
if (listener != null) { if (listener != null) {
listener.onCoordinateFormatChanged(coordinateFormat); listener.onAccuracyChanged(accuracy);
}
if (shouldClose) {
dismiss();
} }
} }
}; };
mainView.findViewById(R.id.degrees_row).setOnClickListener(formatChangeListener); mainView.findViewById(R.id.four_digits_row).setOnClickListener(accuracyChangedListener);
mainView.findViewById(R.id.minutes_row).setOnClickListener(formatChangeListener); mainView.findViewById(R.id.three_digits_row).setOnClickListener(accuracyChangedListener);
mainView.findViewById(R.id.seconds_row).setOnClickListener(formatChangeListener); mainView.findViewById(R.id.two_digits_row).setOnClickListener(accuracyChangedListener);
mainView.findViewById(R.id.cancel_row).setOnClickListener(new View.OnClickListener() { mainView.findViewById(R.id.cancel_row).setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
dismiss(); dismiss();
if (shouldClose && listener != null) {
listener.onCancel();
}
} }
}); });
@ -215,48 +205,32 @@ public class CoordinateInputBottomSheetDialogFragment extends BottomSheetDialogF
} }
} }
@Override
public void onCancel(DialogInterface dialog) {
super.onCancel(dialog);
if (shouldClose && listener != null) {
listener.onCancel();
}
}
@Override @Override
protected Drawable getContentIcon(@DrawableRes int id) { protected Drawable getContentIcon(@DrawableRes int id) {
return getIcon(id, night ? R.color.ctx_menu_info_text_dark : R.color.on_map_icon_color); return getIcon(id, night ? R.color.ctx_menu_info_text_dark : R.color.on_map_icon_color);
} }
private void highlightSelectedItem(boolean check) { private void highlightSelectedItem(boolean check) {
int iconColor = check ? R.color.dashboard_blue : night ? R.color.ctx_menu_info_text_dark : R.color.on_map_icon_color; switch (accuracy) {
int textColor = ContextCompat.getColor(getContext(), check ? (night ? R.color.color_dialog_buttons_dark : R.color.dashboard_blue) : night ? R.color.color_white : R.color.color_black); case 4:
switch (coordinateFormat) { ((RadioButton) mainView.findViewById(R.id.four_digits_radio_button)).setChecked(check);
case PointDescription.FORMAT_DEGREES:
((TextView) mainView.findViewById(R.id.degrees_text)).setTextColor(textColor);
((ImageView) mainView.findViewById(R.id.degrees_icon)).setImageDrawable((getIcon(R.drawable.ic_action_coordinates_latitude, iconColor)));
((RadioButton) mainView.findViewById(R.id.degrees_radio_button)).setChecked(check);
break; break;
case PointDescription.FORMAT_MINUTES: case 3:
((TextView) mainView.findViewById(R.id.minutes_text)).setTextColor(textColor); ((RadioButton) mainView.findViewById(R.id.three_digits_radio_button)).setChecked(check);
((ImageView) mainView.findViewById(R.id.minutes_icon)).setImageDrawable((getIcon(R.drawable.ic_action_coordinates_latitude, iconColor)));
((RadioButton) mainView.findViewById(R.id.minutes_radio_button)).setChecked(check);
break; break;
case PointDescription.FORMAT_SECONDS: case 2:
((TextView) mainView.findViewById(R.id.seconds_text)).setTextColor(textColor); ((RadioButton) mainView.findViewById(R.id.two_digits_radio_button)).setChecked(check);
((ImageView) mainView.findViewById(R.id.seconds_icon)).setImageDrawable((getIcon(R.drawable.ic_action_coordinates_latitude, iconColor)));
((RadioButton) mainView.findViewById(R.id.seconds_radio_button)).setChecked(check);
break; break;
} }
} }
interface CoordinateInputFormatChangeListener { interface CoordinateInputFormatChangeListener {
void onCoordinateFormatChanged(int format);
void onKeyboardChanged(boolean useOsmandKeyboard); void onKeyboardChanged(boolean useOsmandKeyboard);
void onCancel(); void onGoToNextFieldChanged(boolean goToNextField);
void onAccuracyChanged(int accuracy);
} }
} }

View file

@ -16,7 +16,6 @@ import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.PopupMenu; import android.support.v7.widget.PopupMenu;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.text.Editable; import android.text.Editable;
import android.text.InputFilter;
import android.text.InputType; import android.text.InputType;
import android.text.TextWatcher; import android.text.TextWatcher;
import android.util.TypedValue; import android.util.TypedValue;
@ -69,17 +68,12 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
public static final String TAG = "CoordinateInputDialogFragment"; public static final String TAG = "CoordinateInputDialogFragment";
public static final String COORDINATE_FORMAT = "coordinate_format";
public static final String USE_OSMAND_KEYBOARD = "use_osmand_keyboard"; public static final String USE_OSMAND_KEYBOARD = "use_osmand_keyboard";
public static final String GO_TO_NEXT_FIELD = "go_to_next_field";
public static final String ACCURACY = "accuracy";
private static final int CLEAR_BUTTON_POSITION = 9; private static final int CLEAR_BUTTON_POSITION = 9;
private static final int DELETE_BUTTON_POSITION = 11; private static final int DELETE_BUTTON_POSITION = 11;
private static final int DEGREES_MAX_LENGTH = 6;
private static final int MINUTES_MAX_LENGTH = 9;
private static final int SECONDS_MAX_LENGTH = 12;
private static final String DEGREES_HINT = "50.000";
private static final String MINUTES_HINT = "50:00.000";
private static final String SECONDS_HINT = "50:00:00.000";
private static final String LATITUDE_LABEL = "latitude"; private static final String LATITUDE_LABEL = "latitude";
private static final String LONGITUDE_LABEL = "longitude"; private static final String LONGITUDE_LABEL = "longitude";
private static final String NAME_LABEL = "name"; private static final String NAME_LABEL = "name";
@ -89,7 +83,8 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
private CoordinateInputAdapter adapter; private CoordinateInputAdapter adapter;
private boolean lightTheme; private boolean lightTheme;
private boolean useOsmandKeyboard = true; private boolean useOsmandKeyboard = true;
private int coordinateFormat = -1; private boolean goToNextField;
private int accuracy = 4;
private List<OsmandTextFieldBoxes> textFieldBoxes; private List<OsmandTextFieldBoxes> textFieldBoxes;
private List<EditText> inputEditTexts; private List<EditText> inputEditTexts;
private View mainView; private View mainView;
@ -112,10 +107,6 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
lightTheme = app.getSettings().OSMAND_THEME.get() == OsmandSettings.OSMAND_LIGHT_THEME; lightTheme = app.getSettings().OSMAND_THEME.get() == OsmandSettings.OSMAND_LIGHT_THEME;
int themeId = lightTheme ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme; int themeId = lightTheme ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme;
setStyle(STYLE_NO_FRAME, themeId); setStyle(STYLE_NO_FRAME, themeId);
CoordinateInputBottomSheetDialogFragment fragment = new CoordinateInputBottomSheetDialogFragment();
fragment.setListener(createCoordinateInputFormatChangeListener());
fragment.show(getMapActivity().getSupportFragmentManager(), CoordinateInputBottomSheetDialogFragment.TAG);
} }
@NonNull @NonNull
@ -172,8 +163,9 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
} }
CoordinateInputBottomSheetDialogFragment fragment = new CoordinateInputBottomSheetDialogFragment(); CoordinateInputBottomSheetDialogFragment fragment = new CoordinateInputBottomSheetDialogFragment();
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putInt(COORDINATE_FORMAT, coordinateFormat);
args.putBoolean(USE_OSMAND_KEYBOARD, useOsmandKeyboard); args.putBoolean(USE_OSMAND_KEYBOARD, useOsmandKeyboard);
args.putBoolean(GO_TO_NEXT_FIELD, goToNextField);
args.putInt(ACCURACY, accuracy);
fragment.setArguments(args); fragment.setArguments(args);
fragment.setListener(createCoordinateInputFormatChangeListener()); fragment.setListener(createCoordinateInputFormatChangeListener());
fragment.show(getMapActivity().getSupportFragmentManager(), CoordinateInputBottomSheetDialogFragment.TAG); fragment.show(getMapActivity().getSupportFragmentManager(), CoordinateInputBottomSheetDialogFragment.TAG);
@ -215,10 +207,6 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
if (savedInstanceState == null) { if (savedInstanceState == null) {
latitudeBox.select(); latitudeBox.select();
} else {
changeInputEditTextHints();
changeInputEditTextsLengths();
changeKeyboardInEditTexts();
} }
final View mapMarkersLayout = mainView.findViewById(R.id.map_markers_layout); final View mapMarkersLayout = mainView.findViewById(R.id.map_markers_layout);
@ -382,42 +370,6 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
if (focusedView != null && focusedView instanceof EditText) { if (focusedView != null && focusedView instanceof EditText) {
EditText focusedEditText = (EditText) focusedView; EditText focusedEditText = (EditText) focusedView;
String str = focusedEditText.getText().toString(); String str = focusedEditText.getText().toString();
int strLength = str.length();
if (len < strLength) {
String strAfterChanging = str.substring(len);
String strDivider = null;
if (strLength == 3) {
if (coordinateFormat == PointDescription.FORMAT_DEGREES) {
strDivider = ".";
} else {
strDivider = ":";
}
} else if (strLength == 6 && coordinateFormat != PointDescription.FORMAT_DEGREES) {
if (coordinateFormat == PointDescription.FORMAT_MINUTES) {
strDivider = ".";
} else {
strDivider = ":";
}
} else if (strLength == 9 && coordinateFormat == PointDescription.FORMAT_SECONDS) {
strDivider = ".";
}
if (strDivider != null) {
String textToSet = strBeforeChanging + strDivider + strAfterChanging;
focusedEditText.setText(textToSet);
focusedEditText.setSelection(textToSet.length());
}
} else if (len > strLength) {
if (strLength > 0 && (".:").contains(str.substring(strLength - 1))) {
focusedEditText.setText(str.substring(0, str.length() - 1));
}
focusedEditText.setSelection(focusedEditText.getText().length());
}
if ((strLength == DEGREES_MAX_LENGTH && coordinateFormat == PointDescription.FORMAT_DEGREES)
|| (strLength == MINUTES_MAX_LENGTH && coordinateFormat == PointDescription.FORMAT_MINUTES)
|| (strLength == SECONDS_MAX_LENGTH && coordinateFormat == PointDescription.FORMAT_SECONDS)) {
switchToNextInput(focusedEditText.getId());
}
} }
} }
}; };
@ -429,13 +381,16 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
if (orientationPortrait && !isOsmandKeyboardCurrentlyVisible()) { if (orientationPortrait && !isOsmandKeyboardCurrentlyVisible()) {
changeOsmandKeyboardVisibility(true); changeOsmandKeyboardVisibility(true);
} }
AndroidUtils.hideSoftKeyboard(getActivity(), view); EditText editText = (EditText) view;
return false; int inType = editText.getInputType(); // Backup the input type
editText.setInputType(InputType.TYPE_NULL); // Disable standard keyboard
editText.onTouchEvent(motionEvent); // Call native handler
editText.setInputType(inType); // Restore input type
return true; // Consume touch event
} else { } else {
if (isOsmandKeyboardCurrentlyVisible()) { if (isOsmandKeyboardCurrentlyVisible()) {
changeOsmandKeyboardVisibility(false); changeOsmandKeyboardVisibility(false);
} }
AndroidUtils.showSoftKeyboard(view);
return false; return false;
} }
} }
@ -554,17 +509,14 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
textView.setOnFocusChangeListener(focusChangeListener); textView.setOnFocusChangeListener(focusChangeListener);
textView.setOnEditorActionListener(inputTextViewOnEditorActionListener); textView.setOnEditorActionListener(inputTextViewOnEditorActionListener);
} }
changeInputEditTextHints();
changeInputEditTextLengths();
changeKeyboardInEditTexts();
} }
private CoordinateInputBottomSheetDialogFragment.CoordinateInputFormatChangeListener createCoordinateInputFormatChangeListener() { private CoordinateInputBottomSheetDialogFragment.CoordinateInputFormatChangeListener createCoordinateInputFormatChangeListener() {
return new CoordinateInputBottomSheetDialogFragment.CoordinateInputFormatChangeListener() { return new CoordinateInputBottomSheetDialogFragment.CoordinateInputFormatChangeListener() {
@Override
public void onCoordinateFormatChanged(int format) {
coordinateFormat = format;
changeInputEditTextHints();
changeInputEditTextsLengths();
}
@Override @Override
public void onKeyboardChanged(boolean useOsmandKeyboard) { public void onKeyboardChanged(boolean useOsmandKeyboard) {
CoordinateInputDialogFragment.this.useOsmandKeyboard = useOsmandKeyboard; CoordinateInputDialogFragment.this.useOsmandKeyboard = useOsmandKeyboard;
@ -576,8 +528,15 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
} }
@Override @Override
public void onCancel() { public void onGoToNextFieldChanged(boolean goToNextField) {
dismiss(); CoordinateInputDialogFragment.this.goToNextField = goToNextField;
}
@Override
public void onAccuracyChanged(int accuracy) {
CoordinateInputDialogFragment.this.accuracy = accuracy;
changeInputEditTextHints();
changeInputEditTextLengths();
} }
}; };
} }
@ -608,37 +567,37 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
// } // }
} }
private void changeInputEditTextsLengths() { private void changeInputEditTextLengths() {
int maxLength; // int maxLength;
if (coordinateFormat == PointDescription.FORMAT_DEGREES) { // if (accuracy == PointDescription.FORMAT_DEGREES) {
maxLength = DEGREES_MAX_LENGTH; // maxLength = DEGREES_MAX_LENGTH;
} else if (coordinateFormat == PointDescription.FORMAT_MINUTES) { // } else if (accuracy == PointDescription.FORMAT_MINUTES) {
maxLength = MINUTES_MAX_LENGTH; // maxLength = MINUTES_MAX_LENGTH;
} else { // } else {
maxLength = SECONDS_MAX_LENGTH; // maxLength = SECONDS_MAX_LENGTH;
} // }
InputFilter[] filtersArray = new InputFilter[] {new InputFilter.LengthFilter(maxLength)}; // InputFilter[] filtersArray = new InputFilter[] {new InputFilter.LengthFilter(maxLength)};
for (EditText editText : inputEditTexts) { // for (EditText editText : inputEditTexts) {
if (editText.getId() != R.id.name_edit_text) { // if (editText.getId() != R.id.name_edit_text) {
editText.setFilters(filtersArray); // editText.setFilters(filtersArray);
} // }
} // }
} }
private void changeInputEditTextHints() { private void changeInputEditTextHints() {
String hint; // String hint;
if (coordinateFormat == PointDescription.FORMAT_DEGREES) { // if (accuracy == PointDescription.FORMAT_DEGREES) {
hint = DEGREES_HINT; // hint = DEGREES_HINT;
} else if (coordinateFormat == PointDescription.FORMAT_MINUTES) { // } else if (accuracy == PointDescription.FORMAT_MINUTES) {
hint = MINUTES_HINT; // hint = MINUTES_HINT;
} else { // } else {
hint = SECONDS_HINT; // hint = SECONDS_HINT;
} // }
for (EditText editText : inputEditTexts) { // for (EditText editText : inputEditTexts) {
if (editText.getId() != R.id.name_edit_text) { // if (editText.getId() != R.id.name_edit_text) {
editText.setHint(hint); // editText.setHint(hint);
} // }
} // }
} }
private void switchToNextInput(int id) { private void switchToNextInput(int id) {