Add option menu and keyboard styling

This commit is contained in:
PavelRatushny 2017-09-28 19:02:56 +03:00
parent 84bc403963
commit 27c204643d
7 changed files with 511 additions and 219 deletions

View file

@ -144,13 +144,14 @@
</LinearLayout>
<FrameLayout
<LinearLayout
android:id="@+id/keyboard_layout"
android:layout_gravity="bottom"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<GridView
osmand:visibility="gone"
android:id="@+id/keyboard_grid_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
@ -160,6 +161,47 @@
android:stretchMode="columnWidth"
android:numColumns="3"/>
</FrameLayout>
<View
android:id="@+id/keyboard_divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/dashboard_divider"/>
<LinearLayout
android:background="?attr/bg_color"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="56dp">
<ImageView
android:id="@+id/show_hide_keyboard_icon"
android:padding="@dimen/bottom_sheet_content_padding"
android:background="?attr/selectableItemBackground"
android:layout_gravity="center_vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
osmand:src="@drawable/ic_action_arrow_down"/>
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="?attr/dashboard_divider"/>
<net.osmand.plus.widgets.TextViewEx
android:maxLines="1"
android:ellipsize="end"
android:id="@+id/add_marker"
android:textAllCaps="true"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:gravity="center"
android:textColor="@color/keyboard_color"
osmand:typeface="@string/font_roboto_regular"
android:text="@string/shared_string_add"/>
</LinearLayout>
</LinearLayout>
</FrameLayout>

View file

@ -42,197 +42,7 @@
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"/>
<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/bottom_sheet_content_padding"
android:paddingLeft="@dimen/bottom_sheet_content_padding"
android:paddingRight="@dimen/bottom_sheet_content_padding"
android:paddingStart="@dimen/bottom_sheet_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/bottom_sheet_content_padding"
android:paddingLeft="@dimen/bottom_sheet_content_padding"
android:paddingRight="@dimen/bottom_sheet_content_padding"
android:paddingStart="@dimen/bottom_sheet_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/bottom_sheet_content_padding"
android:paddingLeft="@dimen/bottom_sheet_content_padding"
android:paddingRight="@dimen/bottom_sheet_content_padding"
android:paddingStart="@dimen/bottom_sheet_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
android:id="@+id/utm_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/bottom_sheet_content_padding"
android:paddingLeft="@dimen/bottom_sheet_content_padding"
android:paddingRight="@dimen/bottom_sheet_content_padding"
android:paddingStart="@dimen/bottom_sheet_content_padding">
<ImageView
android:id="@+id/utm_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/utm_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLines="1"
android:textAppearance="@style/TextAppearance.ListItemTitle"
tools:text="UTM"/>
<RadioButton
android:id="@+id/utm_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/olc_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/bottom_sheet_content_padding"
android:paddingLeft="@dimen/bottom_sheet_content_padding"
android:paddingRight="@dimen/bottom_sheet_content_padding"
android:paddingStart="@dimen/bottom_sheet_content_padding">
<ImageView
android:id="@+id/olc_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/olc_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLines="1"
android:textAppearance="@style/TextAppearance.ListItemTitle"
tools:text="OLC"/>
<RadioButton
android:id="@+id/olc_radio_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:clickable="false"
android:focusable="false"/>
</LinearLayout>
<include layout="@layout/marker_coordinate_formats"/>
</LinearLayout>

View file

@ -0,0 +1,120 @@
<?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/bottom_sheet_content_padding"
android:paddingLeft="@dimen/bottom_sheet_content_padding"
android:paddingRight="@dimen/bottom_sheet_content_padding"
android:paddingStart="@dimen/bottom_sheet_content_padding"
android:text="@string/shared_string_options"
android:textAppearance="@style/TextAppearance.ListItemTitle"
osmand:typeface="@string/font_roboto_medium"/>
<LinearLayout
android:id="@+id/use_system_keyboard_row"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_list_item_height"
android:background="?attr/selectableItemBackground"
android:descendantFocusability="blocksDescendants"
android:minHeight="@dimen/bottom_sheet_list_item_height"
android:paddingLeft="@dimen/bottom_sheet_content_padding"
android:paddingRight="@dimen/bottom_sheet_content_padding">
<ImageView
android:layout_gravity="center_vertical"
android:id="@+id/use_system_keyboard_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_keyboard"/>
<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/use_system_keyboard"
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
<android.support.v7.widget.SwitchCompat
android:id="@+id/use_system_keyboard_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
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/dashboard_divider"/>
<TextView
android:textColor="?android:textColorSecondary"
android:ellipsize="end"
android:maxLines="1"
android:textAllCaps="true"
android:paddingTop="@dimen/bottom_sheet_content_padding_small"
android:paddingBottom="@dimen/bottom_sheet_content_padding_small"
android:paddingLeft="@dimen/bottom_sheet_content_padding"
android:paddingRight="@dimen/bottom_sheet_content_padding"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/coordinates_format"/>
<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

@ -0,0 +1,199 @@
<?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/bottom_sheet_content_padding"
android:paddingLeft="@dimen/bottom_sheet_content_padding"
android:paddingRight="@dimen/bottom_sheet_content_padding"
android:paddingStart="@dimen/bottom_sheet_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/bottom_sheet_content_padding"
android:paddingLeft="@dimen/bottom_sheet_content_padding"
android:paddingRight="@dimen/bottom_sheet_content_padding"
android:paddingStart="@dimen/bottom_sheet_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/bottom_sheet_content_padding"
android:paddingLeft="@dimen/bottom_sheet_content_padding"
android:paddingRight="@dimen/bottom_sheet_content_padding"
android:paddingStart="@dimen/bottom_sheet_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
android:id="@+id/utm_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/bottom_sheet_content_padding"
android:paddingLeft="@dimen/bottom_sheet_content_padding"
android:paddingRight="@dimen/bottom_sheet_content_padding"
android:paddingStart="@dimen/bottom_sheet_content_padding">
<ImageView
android:id="@+id/utm_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/utm_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLines="1"
android:textAppearance="@style/TextAppearance.ListItemTitle"
tools:text="UTM"/>
<RadioButton
android:id="@+id/utm_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/olc_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/bottom_sheet_content_padding"
android:paddingLeft="@dimen/bottom_sheet_content_padding"
android:paddingRight="@dimen/bottom_sheet_content_padding"
android:paddingStart="@dimen/bottom_sheet_content_padding">
<ImageView
android:id="@+id/olc_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/olc_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLines="1"
android:textAppearance="@style/TextAppearance.ListItemTitle"
tools:text="OLC"/>
<RadioButton
android:id="@+id/olc_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,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="coordinates_format">Coordinates format</string>
<string name="use_system_keyboard">Use system keyboard</string>
<string name="fast_coordinates_input_descr">Choose coordinate format before start. You can always change it by tapping Options.</string>
<string name="fast_coordinates_input">Fast Coordinates input</string>
<string name="shared_string_finish">Finish</string>

View file

@ -1,11 +1,13 @@
package net.osmand.plus.mapmarkers;
import android.content.DialogInterface;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.DrawableRes;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.SwitchCompat;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.View;
@ -13,7 +15,9 @@ import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.Window;
import android.view.WindowManager;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.TextView;
import net.osmand.AndroidUtils;
@ -31,7 +35,9 @@ public class CoordinateInputBottomSheetDialogFragment extends BottomSheetDialogF
private View mainView;
private boolean night;
private int coordinateFormat = -1;
private boolean useOsmandKeyboard = true;
private CoordinateInputFormatChangeListener listener;
private boolean shouldClose;
public void setListener(CoordinateInputFormatChangeListener listener) {
this.listener = listener;
@ -42,7 +48,10 @@ public class CoordinateInputBottomSheetDialogFragment extends BottomSheetDialogF
super.onCreate(savedInstanceState);
Bundle args = getArguments();
if (args != null) {
coordinateFormat = getArguments().getInt(CoordinateInputDialogFragment.COORDINATE_FORMAT, -1);
coordinateFormat = args.getInt(CoordinateInputDialogFragment.COORDINATE_FORMAT);
useOsmandKeyboard = args.getBoolean(CoordinateInputDialogFragment.USE_OSMAND_KEYBOARD);
} else {
shouldClose = true;
}
}
@ -54,7 +63,8 @@ public class CoordinateInputBottomSheetDialogFragment extends BottomSheetDialogF
night = !mapActivity.getMyApplication().getSettings().isLightContent();
final int themeRes = night ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_marker_coordinate_input_bottom_sheet_dialog, container);
mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), coordinateFormat == -1 ?
R.layout.fragment_marker_coordinate_input_bottom_sheet_dialog : R.layout.fragment_marker_coordinate_input_options_bottom_sheet_helper, container);
if (portrait) {
AndroidUtils.setBackground(getActivity(), mainView, night, R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);
}
@ -68,6 +78,7 @@ public class CoordinateInputBottomSheetDialogFragment extends BottomSheetDialogF
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));
}
@ -78,6 +89,7 @@ public class CoordinateInputBottomSheetDialogFragment extends BottomSheetDialogF
if (coordinateFormat == PointDescription.FORMAT_MINUTES) {
minutesIcon.setImageDrawable(getIcon(R.drawable.ic_action_coordinates_latitude, R.color.dashboard_blue));
minutesText.setTextColor(ContextCompat.getColor(mapActivity, R.color.dashboard_blue));
((RadioButton) mainView.findViewById(R.id.minutes_radio_button)).setChecked(true);
} else {
minutesIcon.setImageDrawable(getContentIcon(R.drawable.ic_action_coordinates_latitude));
}
@ -88,6 +100,7 @@ public class CoordinateInputBottomSheetDialogFragment extends BottomSheetDialogF
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));
}
@ -98,6 +111,7 @@ public class CoordinateInputBottomSheetDialogFragment extends BottomSheetDialogF
if (coordinateFormat == PointDescription.UTM_FORMAT) {
utmIcon.setImageDrawable(getIcon(R.drawable.ic_action_coordinates_latitude, R.color.dashboard_blue));
utmText.setTextColor(ContextCompat.getColor(mapActivity, R.color.dashboard_blue));
((RadioButton) mainView.findViewById(R.id.utm_radio_button)).setChecked(true);
} else {
utmIcon.setImageDrawable(getContentIcon(R.drawable.ic_action_coordinates_latitude));
}
@ -108,38 +122,58 @@ public class CoordinateInputBottomSheetDialogFragment extends BottomSheetDialogF
if (coordinateFormat == PointDescription.OLC_FORMAT) {
olcIcon.setImageDrawable(getIcon(R.drawable.ic_action_coordinates_latitude, R.color.dashboard_blue));
olcText.setTextColor(ContextCompat.getColor(mapActivity, R.color.dashboard_blue));
((RadioButton) mainView.findViewById(R.id.olc_radio_button)).setChecked(true);
} else {
olcIcon.setImageDrawable(getContentIcon(R.drawable.ic_action_coordinates_latitude));
}
olcText.setText(PointDescription.formatToHumanString(getContext(), PointDescription.OLC_FORMAT));
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() {
@Override
public void onClick(View view) {
int format;
highlightSelectedItem(false);
switch (view.getId()) {
case R.id.degrees_row:
format = PointDescription.FORMAT_DEGREES;
coordinateFormat = PointDescription.FORMAT_DEGREES;
break;
case R.id.minutes_row:
format = PointDescription.FORMAT_MINUTES;
coordinateFormat = PointDescription.FORMAT_MINUTES;
break;
case R.id.seconds_row:
format = PointDescription.FORMAT_SECONDS;
coordinateFormat = PointDescription.FORMAT_SECONDS;
break;
case R.id.utm_row:
format = PointDescription.UTM_FORMAT;
coordinateFormat = PointDescription.UTM_FORMAT;
break;
case R.id.olc_row:
format = PointDescription.OLC_FORMAT;
coordinateFormat = PointDescription.OLC_FORMAT;
break;
default:
throw new IllegalArgumentException("Unsupported format");
}
highlightSelectedItem(true);
if (listener != null) {
listener.onCoordinateFormatChanged(format);
listener.onCoordinateFormatChanged(coordinateFormat);
}
if (shouldClose) {
dismiss();
}
dismiss();
}
};
@ -153,6 +187,9 @@ public class CoordinateInputBottomSheetDialogFragment extends BottomSheetDialogF
@Override
public void onClick(View view) {
dismiss();
if (shouldClose && listener != null) {
listener.onCancel();
}
}
});
@ -207,12 +244,58 @@ public class CoordinateInputBottomSheetDialogFragment extends BottomSheetDialogF
}
}
@Override
public void onCancel(DialogInterface dialog) {
super.onCancel(dialog);
if (shouldClose && listener != null) {
listener.onCancel();
}
}
@Override
protected Drawable getContentIcon(@DrawableRes int id) {
return getIcon(id, night ? R.color.ctx_menu_info_text_dark : R.color.on_map_icon_color);
}
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;
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);
switch (coordinateFormat) {
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;
case PointDescription.FORMAT_MINUTES:
((TextView) mainView.findViewById(R.id.minutes_text)).setTextColor(textColor);
((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;
case PointDescription.FORMAT_SECONDS:
((TextView) mainView.findViewById(R.id.seconds_text)).setTextColor(textColor);
((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;
case PointDescription.UTM_FORMAT:
((TextView) mainView.findViewById(R.id.utm_text)).setTextColor(textColor);
((ImageView) mainView.findViewById(R.id.utm_icon)).setImageDrawable((getIcon(R.drawable.ic_action_coordinates_latitude, iconColor)));
((RadioButton) mainView.findViewById(R.id.utm_radio_button)).setChecked(check);
break;
case PointDescription.OLC_FORMAT:
((TextView) mainView.findViewById(R.id.olc_text)).setTextColor(textColor);
((ImageView) mainView.findViewById(R.id.olc_icon)).setImageDrawable((getIcon(R.drawable.ic_action_coordinates_latitude, iconColor)));
((RadioButton) mainView.findViewById(R.id.olc_radio_button)).setChecked(check);
break;
}
}
interface CoordinateInputFormatChangeListener {
void onCoordinateFormatChanged(int format);
void onKeyboardChanged(boolean useOsmandKeyboard);
void onCancel();
}
}

View file

@ -18,8 +18,11 @@ import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.GridView;
import android.widget.ImageView;
import net.osmand.AndroidUtils;
import net.osmand.data.PointDescription;
import net.osmand.plus.IconsCache;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.OsmandTextFieldBoxes;
@ -37,6 +40,7 @@ public class CoordinateInputDialogFragment extends DialogFragment {
public static final String TAG = "CoordinateInputDialogFragment";
public static final String COORDINATE_FORMAT = "coordinate_format";
public static final String USE_OSMAND_KEYBOARD = "use_osmand_keyboard";
private static final int DELETE_BUTTON_POSITION = 9;
private static final int CLEAR_BUTTON_POSITION = 11;
@ -47,10 +51,10 @@ public class CoordinateInputDialogFragment extends DialogFragment {
private boolean lightTheme;
private EditText focusedEditText;
private boolean useOsmandKeyboard = true;
private int coordinateFormat = -1;
private List<OsmandTextFieldBoxes> textFieldBoxes;
private ExtendedEditText nameEditText;
private List<ExtendedEditText> extendedLatLonEditTexts;
private int coordinateFormat = -1;
@Override
public void onCreate(Bundle savedInstanceState) {
@ -60,11 +64,9 @@ public class CoordinateInputDialogFragment extends DialogFragment {
int themeId = lightTheme ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme;
setStyle(STYLE_NO_FRAME, themeId);
if (coordinateFormat == -1) {
CoordinateInputBottomSheetDialogFragment fragment = new CoordinateInputBottomSheetDialogFragment();
fragment.setListener(createCoordinateInputFormatChangeListener());
fragment.show(getMapActivity().getSupportFragmentManager(), CoordinateInputBottomSheetDialogFragment.TAG);
}
CoordinateInputBottomSheetDialogFragment fragment = new CoordinateInputBottomSheetDialogFragment();
fragment.setListener(createCoordinateInputFormatChangeListener());
fragment.show(getMapActivity().getSupportFragmentManager(), CoordinateInputBottomSheetDialogFragment.TAG);
}
@Nullable
@ -72,12 +74,11 @@ public class CoordinateInputDialogFragment extends DialogFragment {
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
final View mainView = inflater.inflate(R.layout.fragment_coordinate_input_dialog, container);
final MapActivity mapActivity = getMapActivity();
final IconsCache ic = getMyApplication().getIconsCache();
if (coordinateFormat == -1) {
Fragment coordinateInputBottomSheetDialogFragment = mapActivity.getSupportFragmentManager().findFragmentByTag(CoordinateInputBottomSheetDialogFragment.TAG);
if (coordinateInputBottomSheetDialogFragment != null) {
((CoordinateInputBottomSheetDialogFragment) coordinateInputBottomSheetDialogFragment).setListener(createCoordinateInputFormatChangeListener());
}
Fragment coordinateInputBottomSheetDialogFragment = mapActivity.getSupportFragmentManager().findFragmentByTag(CoordinateInputBottomSheetDialogFragment.TAG);
if (coordinateInputBottomSheetDialogFragment != null) {
((CoordinateInputBottomSheetDialogFragment) coordinateInputBottomSheetDialogFragment).setListener(createCoordinateInputFormatChangeListener());
}
Toolbar toolbar = (Toolbar) mainView.findViewById(R.id.coordinate_input_toolbar);
@ -96,6 +97,7 @@ public class CoordinateInputDialogFragment extends DialogFragment {
CoordinateInputBottomSheetDialogFragment fragment = new CoordinateInputBottomSheetDialogFragment();
Bundle args = new Bundle();
args.putInt(COORDINATE_FORMAT, coordinateFormat);
args.putBoolean(USE_OSMAND_KEYBOARD, useOsmandKeyboard);
fragment.setArguments(args);
fragment.setListener(createCoordinateInputFormatChangeListener());
fragment.show(getMapActivity().getSupportFragmentManager(), CoordinateInputBottomSheetDialogFragment.TAG);
@ -208,8 +210,11 @@ public class CoordinateInputDialogFragment extends DialogFragment {
longitudeEditText.addTextChangedListener(textWatcher);
nameEditText.addTextChangedListener(textWatcher);
changeKeyboardInBoxes(useOsmandKeyboard);
changeKeyboardInEditTexts(useOsmandKeyboard);
changeKeyboardInBoxes();
changeKeyboardInEditTexts();
View keyboardLayout = mainView.findViewById(R.id.keyboard_layout);
AndroidUtils.setBackground(mapActivity, keyboardLayout, !lightTheme, R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);
String[] keyboardItems = new String[] { "1", "2", "3",
"4", "5", "6",
@ -240,6 +245,25 @@ public class CoordinateInputDialogFragment extends DialogFragment {
}
});
final ImageView showHideKeyBoardIcon = (ImageView) mainView.findViewById(R.id.show_hide_keyboard_icon);
final View keyboardDivider = mainView.findViewById(R.id.keyboard_divider);
showHideKeyBoardIcon.setImageDrawable(ic.getThemedIcon(R.drawable.ic_action_arrow_down));
showHideKeyBoardIcon.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
int keyboardVisibility = keyboardGrid.getVisibility();
if (keyboardVisibility == View.VISIBLE) {
keyboardGrid.setVisibility(View.GONE);
keyboardDivider.setVisibility(View.GONE);
showHideKeyBoardIcon.setImageDrawable(ic.getThemedIcon(R.drawable.ic_action_arrow_up));
} else {
keyboardGrid.setVisibility(View.VISIBLE);
keyboardDivider.setVisibility(View.VISIBLE);
showHideKeyBoardIcon.setImageDrawable(ic.getThemedIcon(R.drawable.ic_action_arrow_down));
}
}
});
return mainView;
}
@ -259,6 +283,18 @@ public class CoordinateInputDialogFragment extends DialogFragment {
coordinateFormat = format;
changeEditTextLengths();
}
@Override
public void onKeyboardChanged(boolean useOsmandKeyboard) {
CoordinateInputDialogFragment.this.useOsmandKeyboard = useOsmandKeyboard;
changeKeyboardInBoxes();
changeKeyboardInEditTexts();
}
@Override
public void onCancel() {
dismiss();
}
};
}
@ -277,13 +313,13 @@ public class CoordinateInputDialogFragment extends DialogFragment {
}
}
public void changeKeyboardInBoxes(boolean useOsmandKeyboard) {
public void changeKeyboardInBoxes() {
for (OsmandTextFieldBoxes textFieldBox : textFieldBoxes) {
textFieldBox.setUseOsmandKeyboard(useOsmandKeyboard);
}
}
public void changeKeyboardInEditTexts(boolean useOsmandKeyboard) {
public void changeKeyboardInEditTexts() {
for (ExtendedEditText extendedEditText : extendedLatLonEditTexts) {
extendedEditText.setInputType(useOsmandKeyboard ? InputType.TYPE_NULL : InputType.TYPE_CLASS_TEXT);
}