Create new input area layout for coordinate input

This commit is contained in:
Alexander Sytnyk 2018-02-12 19:19:25 +02:00
parent 751ea023a5
commit 4d69a5c014
7 changed files with 486 additions and 200 deletions

View file

@ -0,0 +1,310 @@
<?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:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
tools:background="@color/ctx_menu_bg_dark">
<!-- Latitude row: -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical">
<LinearLayout
android:id="@+id/lat_side_of_the_world_btn"
android:layout_width="@dimen/side_of_the_world_button_size"
android:layout_height="@dimen/side_of_the_world_button_size"
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding"
android:orientation="vertical"
tools:background="@drawable/context_menu_controller_bg_dark">
<ImageView
android:id="@+id/south_side_iv"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="-12dp"
android:visibility="gone"
tools:src="@drawable/ic_action_coordinates_longitude"
tools:tint="@color/dashboard_blue"/>
<TextView
android:id="@+id/lat_side_of_the_world_tv"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center"
android:textColor="@color/dashboard_blue"
android:textSize="@dimen/default_list_text_size"
android:textStyle="bold"
tools:text="N"/>
<ImageView
android:id="@+id/north_side_iv"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="-12dp"
tools:src="@drawable/ic_action_coordinates_longitude"
tools:tint="@color/dashboard_blue"/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:text="@string/navigate_point_latitude"
android:textColor="@color/ctx_menu_bottom_view_secondary_text_color_light"
android:textSize="@dimen/default_sub_text_size"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/lat_first_input_et"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="xx"
android:imeOptions="actionNext"
android:maxLines="1"
tools:maxLength="2"/>
<TextView
android:id="@+id/lat_first_separator_tv"
android:layout_width="@dimen/context_menu_padding_margin_large"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="°"
android:textColor="@color/ctx_menu_bottom_view_secondary_text_color_light"
android:textSize="@dimen/dialog_header_text_size"/>
<EditText
android:id="@+id/lat_second_input_et"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="xx"
android:imeOptions="actionNext"
android:maxLines="1"
tools:maxLength="2"/>
<TextView
android:id="@+id/lat_second_separator_tv"
android:layout_width="@dimen/context_menu_padding_margin_large"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="."
android:textColor="@color/ctx_menu_bottom_view_secondary_text_color_light"
android:textSize="@dimen/dialog_header_text_size"/>
<EditText
android:id="@+id/lat_thirst_input_et"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="xxxx"
android:imeOptions="actionNext"
android:maxLines="1"
tools:maxLength="4"/>
</LinearLayout>
</LinearLayout>
<ImageView
android:id="@+id/lat_backspace_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/text_margin_small"
android:layout_marginLeft="@dimen/context_menu_padding_margin_large"
android:layout_marginRight="@dimen/text_margin_small"
android:layout_marginStart="@dimen/context_menu_padding_margin_large"
android:padding="@dimen/content_padding_small"
tools:src="@drawable/ic_keyboard_backspace"/>
</LinearLayout>
<!-- Longitude row: -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/content_padding_small"
android:gravity="center_vertical">
<LinearLayout
android:id="@+id/lon_side_of_the_world_btn"
android:layout_width="@dimen/side_of_the_world_button_size"
android:layout_height="@dimen/side_of_the_world_button_size"
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding"
tools:background="@drawable/context_menu_controller_bg_dark">
<ImageView
android:id="@+id/east_side_iv"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center_vertical"
android:layout_marginLeft="-12dp"
android:layout_marginStart="-12dp"
android:visibility="gone"
tools:src="@drawable/ic_action_coordinates_latitude"
tools:tint="@color/dashboard_blue"/>
<TextView
android:id="@+id/lon_side_of_the_world_tv"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:textColor="@color/dashboard_blue"
android:textSize="@dimen/default_list_text_size"
android:textStyle="bold"
tools:text="W"/>
<ImageView
android:id="@+id/west_side_iv"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center_vertical"
android:layout_marginEnd="-12dp"
android:layout_marginRight="-12dp"
tools:src="@drawable/ic_action_coordinates_latitude"
tools:tint="@color/dashboard_blue"/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:text="@string/navigate_point_longitude"
android:textColor="@color/ctx_menu_bottom_view_secondary_text_color_light"
android:textSize="@dimen/default_sub_text_size"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/lon_first_input_et"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="yy"
android:imeOptions="actionNext"
android:maxLines="1"
tools:maxLength="2"/>
<TextView
android:id="@+id/lon_first_separator_tv"
android:layout_width="@dimen/context_menu_padding_margin_large"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="°"
android:textColor="@color/ctx_menu_bottom_view_secondary_text_color_light"
android:textSize="@dimen/dialog_header_text_size"/>
<EditText
android:id="@+id/lon_second_input_et"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="yy"
android:imeOptions="actionNext"
android:maxLines="1"
tools:maxLength="2"/>
<TextView
android:id="@+id/lon_second_separator_tv"
android:layout_width="@dimen/context_menu_padding_margin_large"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="."
android:textColor="@color/ctx_menu_bottom_view_secondary_text_color_light"
android:textSize="@dimen/dialog_header_text_size"/>
<EditText
android:id="@+id/lon_thirst_input_et"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="yyyy"
android:imeOptions="actionNext"
android:maxLines="1"
tools:maxLength="4"/>
</LinearLayout>
</LinearLayout>
<ImageView
android:id="@+id/lon_backspace_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/text_margin_small"
android:layout_marginLeft="@dimen/context_menu_padding_margin_large"
android:layout_marginRight="@dimen/text_margin_small"
android:layout_marginStart="@dimen/context_menu_padding_margin_large"
android:padding="@dimen/content_padding_small"
tools:src="@drawable/ic_keyboard_backspace"/>
</LinearLayout>
<!-- Point name row: -->
<View
android:id="@+id/point_name_divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="@dimen/content_padding"
android:background="@color/route_info_divider_dark"/>
<LinearLayout
android:id="@+id/point_name_et_container"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_list_item_height"
tools:background="@color/route_info_bottom_view_bg_dark">
<EditText
android:id="@+id/point_name_et"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginStart="@dimen/content_padding"
android:layout_weight="1"
android:background="@null"
android:hint="@string/optional_point_name"
android:imeOptions="actionDone"/>
<ImageView
android:id="@+id/point_name_keyboard_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/text_margin_small"
android:layout_marginLeft="@dimen/context_menu_padding_margin_large"
android:layout_marginRight="@dimen/text_margin_small"
android:layout_marginStart="@dimen/context_menu_padding_margin_large"
android:padding="@dimen/content_padding_small"
tools:src="@drawable/ic_action_keyboard"/>
</LinearLayout>
</LinearLayout>

View file

@ -2,32 +2,32 @@
<FrameLayout <FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android" 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"
android:layout_width="match_parent" xmlns:tools="http://schemas.android.com/tools"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.design.widget.AppBarLayout <android.support.design.widget.AppBarLayout
android:id="@+id/app_bar" android:id="@+id/app_bar"
android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content"
android:orientation="vertical"
tools:background="@color/route_info_bg_dark">
<android.support.v7.widget.Toolbar <android.support.v7.widget.Toolbar
android:id="@+id/coordinate_input_toolbar" android:id="@+id/coordinate_input_toolbar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/dashboard_map_toolbar" android:layout_height="@dimen/dashboard_map_toolbar"
osmand:contentInsetEnd="0dp"
osmand:contentInsetLeft="4dp" osmand:contentInsetLeft="4dp"
osmand:contentInsetStart="4dp"
osmand:contentInsetRight="0dp" osmand:contentInsetRight="0dp"
osmand:contentInsetEnd="0dp"> osmand:contentInsetStart="4dp">
<LinearLayout <LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:gravity="center_vertical"> android:gravity="center_vertical">
@ -37,37 +37,38 @@
style="@style/Widget.AppCompat.ActionButton" style="@style/Widget.AppCompat.ActionButton"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:src="@drawable/ic_arrow_back" android:layout_marginEnd="16dp"
android:layout_marginRight="16dp" android:layout_marginRight="16dp"
android:layout_marginEnd="16dp"/> tools:src="@drawable/ic_arrow_back"/>
<net.osmand.plus.widgets.TextViewEx <net.osmand.plus.widgets.TextViewEx
android:id="@+id/toolbar_text"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="1"
android:ellipsize="end" android:ellipsize="end"
android:maxLines="1"
android:gravity="center_vertical" android:gravity="center_vertical"
android:maxLines="1"
android:text="@string/coordinates" android:text="@string/coordinates"
android:textColor="@color/color_white" android:textSize="@dimen/dialog_header_text_size"
osmand:typeface="@string/font_roboto_medium" osmand:typeface="@string/font_roboto_medium"
android:textSize="@dimen/dialog_header_text_size"/> tools:textColor="@color/color_white"/>
<net.osmand.plus.widgets.TextViewEx <net.osmand.plus.widgets.TextViewEx
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:id="@+id/options_button" android:id="@+id/options_button"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:gravity="center_vertical" android:background="?attr/selectableItemBackground"
android:ellipsize="end" android:ellipsize="end"
android:gravity="center_vertical"
android:maxLines="1" android:maxLines="1"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:text="@string/shared_string_options" android:text="@string/shared_string_options"
osmand:typeface="@string/font_roboto_regular"
android:textAllCaps="true" android:textAllCaps="true"
android:textColor="@color/dashboard_blue"
android:textSize="@dimen/default_list_text_size" android:textSize="@dimen/default_list_text_size"
android:textColor="@color/color_white" osmand:typeface="@string/font_roboto_regular"/>
android:background="?attr/selectableItemBackground"/>
</LinearLayout> </LinearLayout>
</android.support.v7.widget.Toolbar> </android.support.v7.widget.Toolbar>
@ -78,117 +79,35 @@
android:focusable="true" android:focusable="true"
android:focusableInTouchMode="true"/> android:focusableInTouchMode="true"/>
<LinearLayout <include layout="@layout/coordinate_input_data_area"/>
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<net.osmand.plus.widgets.OsmandTextFieldBoxes
android:theme="@style/OsmandTextFieldBoxes"
android:id="@+id/latitude_box"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
osmand:labelText="@string/navigate_point_latitude"
android:layout_marginRight="16dp"
android:layout_marginEnd="16dp">
<studio.carbonylgroup.textfieldboxes.ExtendedEditText
android:textColor="@color/color_white"
android:textColorHint="@color/white_50_transparent"
android:inputType="numberSigned|numberDecimal"
android:imeOptions="actionNext"
android:id="@+id/latitude_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</net.osmand.plus.widgets.OsmandTextFieldBoxes>
<net.osmand.plus.widgets.OsmandTextFieldBoxes
android:theme="@style/OsmandTextFieldBoxes"
android:id="@+id/longitude_box"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
osmand:labelText="@string/navigate_point_longitude">
<studio.carbonylgroup.textfieldboxes.ExtendedEditText
android:textColor="@color/color_white"
android:textColorHint="@color/white_50_transparent"
android:inputType="numberSigned|numberDecimal"
android:imeOptions="actionNext"
android:id="@+id/longitude_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</net.osmand.plus.widgets.OsmandTextFieldBoxes>
</LinearLayout>
<LinearLayout
android:padding="16dp"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<net.osmand.plus.widgets.OsmandTextFieldBoxes
android:theme="@style/OsmandTextFieldBoxes"
android:id="@+id/name_box"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
osmand:labelText="@string/shared_string_name"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp">
<studio.carbonylgroup.textfieldboxes.ExtendedEditText
android:textColor="@color/color_white"
android:textColorHint="@color/white_50_transparent"
android:inputType="text"
android:imeOptions="actionDone"
android:hint="@string/access_hint_enter_name"
android:id="@+id/name_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</net.osmand.plus.widgets.OsmandTextFieldBoxes>
<View
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"/>
</LinearLayout>
</android.support.design.widget.AppBarLayout> </android.support.design.widget.AppBarLayout>
<android.support.v7.widget.RecyclerView <android.support.v7.widget.RecyclerView
android:paddingTop="16dp"
android:paddingBottom="72dp"
android:id="@+id/markers_recycler_view" android:id="@+id/markers_recycler_view"
android:clipToPadding="false"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"/> android:layout_height="match_parent"
android:clipToPadding="false"
android:paddingBottom="72dp"
android:paddingTop="16dp"/>
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/keyboard_layout" android:id="@+id/keyboard_layout"
android:layout_gravity="bottom"
android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:orientation="vertical">
<GridView <GridView
android:id="@+id/keyboard_grid_view" android:id="@+id/keyboard_grid_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:horizontalSpacing="1dp" android:horizontalSpacing="1dp"
android:verticalSpacing="1dp" android:numColumns="4"
android:stretchMode="columnWidth" android:stretchMode="columnWidth"
android:numColumns="4"/> android:verticalSpacing="1dp"/>
<View <View
android:id="@+id/keyboard_divider" android:id="@+id/keyboard_divider"
@ -197,22 +116,22 @@
android:background="?attr/keyboard_controls_divider"/> android:background="?attr/keyboard_controls_divider"/>
<LinearLayout <LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="56dp"> android:layout_height="56dp"
android:orientation="horizontal">
<android.support.v7.widget.AppCompatTextView <android.support.v7.widget.AppCompatTextView
android:maxLines="1"
android:ellipsize="end"
android:id="@+id/add_marker_button" android:id="@+id/add_marker_button"
android:textAllCaps="true"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_weight="3"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="3"
android:ellipsize="end"
android:gravity="center" android:gravity="center"
android:maxLines="1"
android:text="@string/shared_string_add"
android:textAllCaps="true"
android:textColor="@color/keyboard_item_button_text_color" android:textColor="@color/keyboard_item_button_text_color"
android:textSize="@dimen/default_list_text_size" android:textSize="@dimen/default_list_text_size"/>
android:text="@string/shared_string_add"/>
<View <View
android:layout_width="1dp" android:layout_width="1dp"
@ -221,10 +140,10 @@
<ImageView <ImageView
android:id="@+id/show_hide_keyboard_icon" android:id="@+id/show_hide_keyboard_icon"
android:layout_gravity="center_vertical"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:scaleType="center" android:scaleType="center"
tools:src="@drawable/ic_action_arrow_down"/> tools:src="@drawable/ic_action_arrow_down"/>

View file

@ -187,4 +187,6 @@
<dimen name="grid_menu_item_sides_margin">60dp</dimen> <dimen name="grid_menu_item_sides_margin">60dp</dimen>
<dimen name="bottom_sheet_menu_peek_height">450dp</dimen> <dimen name="bottom_sheet_menu_peek_height">450dp</dimen>
<dimen name="side_of_the_world_button_size">54dp</dimen>
</resources> </resources>

View file

@ -300,12 +300,12 @@
<color name="keyboard_divider_light">#e6e6e6</color> <color name="keyboard_divider_light">#e6e6e6</color>
<color name="keyboard_divider_dark">#2a2f33</color> <color name="keyboard_divider_dark">#2a2f33</color>
<color name="coordinate_input_status_bar_color_light">#4257c9</color>
<color name="coordinate_input_status_bar_color_dark">#1b224d</color> <color name="coordinate_input_status_bar_color_dark">#1b224d</color>
<color name="coordinate_input_app_bar_color_light">#536dfe</color> <color name="coordinate_input_app_bar_color_light">#536dfe</color>
<color name="coordinate_input_app_bar_color_dark">#2d3980</color> <color name="coordinate_input_app_bar_color_dark">#2d3980</color>
<color name="coordinate_input_keyboard_icon_color">#9fadfc</color> <color name="coordinate_input_keyboard_icon_color">#9fadfc</color>
<color name="coordinate_input_error_color">#ed5421</color> <color name="coordinate_input_error_color">#ed5421</color>
<color name="coordinate_input_active_icon_dark">#c0c0c0</color>
<color name="color_osm_edit_create">#78cc5c</color> <color name="color_osm_edit_create">#78cc5c</color>
<color name="color_osm_edit_modify">#fac403</color> <color name="color_osm_edit_modify">#fac403</color>

View file

@ -260,4 +260,6 @@
<dimen name="grid_menu_item_sides_margin">40dp</dimen> <dimen name="grid_menu_item_sides_margin">40dp</dimen>
<dimen name="bottom_sheet_menu_peek_height">300dp</dimen> <dimen name="bottom_sheet_menu_peek_height">300dp</dimen>
<dimen name="side_of_the_world_button_size">36dp</dimen>
</resources> </resources>

View file

@ -9,6 +9,11 @@
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="east_abbreviation">E</string>
<string name="west_abbreviation">W</string>
<string name="south_abbreviation">S</string>
<string name="north_abbreviation">N</string>
<string name="optional_point_name">Optional point name</string>
<string name="make_as_start_point">Make as Start Point</string> <string name="make_as_start_point">Make as Start Point</string>
<string name="shared_string_current">Current</string> <string name="shared_string_current">Current</string>
<string name="last_intermediate_dest_description">Adds the last stop along the route</string> <string name="last_intermediate_dest_description">Adds the last stop along the route</string>

View file

@ -8,6 +8,9 @@ import android.content.res.ColorStateList;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.ColorRes;
import android.support.annotation.DrawableRes;
import android.support.annotation.IdRes;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.v4.app.DialogFragment; import android.support.v4.app.DialogFragment;
@ -37,21 +40,21 @@ import android.widget.AdapterView;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.EditText; import android.widget.EditText;
import android.widget.GridView; import android.widget.GridView;
import android.widget.ImageButton;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast;
import net.osmand.AndroidUtils; import net.osmand.AndroidUtils;
import net.osmand.Location; import net.osmand.Location;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.data.PointDescription; import net.osmand.data.PointDescription;
import net.osmand.plus.IconsCache;
import net.osmand.plus.MapMarkersHelper; import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.MapMarkersHelper.MapMarker; import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener; import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener;
import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener; import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.MapViewTrackingUtilities; import net.osmand.plus.base.MapViewTrackingUtilities;
@ -88,23 +91,26 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
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";
private OnMapMarkersSavedListener listener;
private List<MapMarker> mapMarkers = new ArrayList<>(); private List<MapMarker> mapMarkers = new ArrayList<>();
private MapMarkersHelper mapMarkersHelper;
private OnMapMarkersSavedListener listener;
private View mainView;
private List<EditText> editTexts = new ArrayList<>();
private CoordinateInputAdapter adapter; private CoordinateInputAdapter adapter;
private boolean lightTheme; private boolean lightTheme;
private boolean orientationPortrait;
private boolean useOsmandKeyboard = true; private boolean useOsmandKeyboard = true;
private boolean rightHand = true; private boolean rightHand = true;
private boolean goToNextField = true; private boolean goToNextField = true;
private int accuracy = 4; private int accuracy = 4;
private List<OsmandTextFieldBoxes> textFieldBoxes;
private View mainView;
private IconsCache iconsCache;
private Location location; private Location location;
private Float heading; private Float heading;
private boolean locationUpdateStarted; private boolean locationUpdateStarted;
private boolean compassUpdateAllowed = true; private boolean compassUpdateAllowed = true;
private MapMarkersHelper mapMarkersHelper;
private boolean orientationPortrait;
public void setListener(OnMapMarkersSavedListener listener) { public void setListener(OnMapMarkersSavedListener listener) {
this.listener = listener; this.listener = listener;
@ -113,16 +119,15 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
OsmandApplication app = getMyApplication(); lightTheme = getMyApplication().getSettings().isLightContent();
lightTheme = app.getSettings().OSMAND_THEME.get() == OsmandSettings.OSMAND_LIGHT_THEME; setStyle(STYLE_NO_FRAME, lightTheme ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme);
int themeId = lightTheme ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme;
setStyle(STYLE_NO_FRAME, themeId);
} }
@NonNull @NonNull
@Override @Override
public Dialog onCreateDialog(Bundle savedInstanceState) { public Dialog onCreateDialog(Bundle savedInstanceState) {
Dialog dialog = new Dialog(getContext(), getTheme()) { Context ctx = getContext();
Dialog dialog = new Dialog(ctx, getTheme()) {
@Override @Override
public void onBackPressed() { public void onBackPressed() {
saveMarkers(); saveMarkers();
@ -132,10 +137,8 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
Window window = dialog.getWindow(); Window window = dialog.getWindow();
if (window != null) { if (window != null) {
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN); window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (!lightTheme && Build.VERSION.SDK_INT >= 21) {
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.setStatusBarColor(ContextCompat.getColor(ctx, R.color.coordinate_input_status_bar_color_dark));
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(ContextCompat.getColor(getContext(), lightTheme ? R.color.coordinate_input_status_bar_color_light : R.color.coordinate_input_status_bar_color_dark));
} }
} }
return dialog; return dialog;
@ -144,18 +147,20 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
@Nullable @Nullable
@Override @Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
mainView = inflater.inflate(R.layout.fragment_coordinate_input_dialog, container);
final MapActivity mapActivity = getMapActivity(); final MapActivity mapActivity = getMapActivity();
iconsCache = getMyApplication().getIconsCache();
mapMarkersHelper = getMyApplication().getMapMarkersHelper(); mapMarkersHelper = getMyApplication().getMapMarkersHelper();
orientationPortrait = AndroidUiHelper.isOrientationPortrait(mapActivity); orientationPortrait = AndroidUiHelper.isOrientationPortrait(mapActivity);
Fragment coordinateInputBottomSheetDialogFragment = mapActivity.getSupportFragmentManager().findFragmentByTag(CoordinateInputBottomSheetDialogFragment.TAG); Fragment optionsFragment = getChildFragmentManager().findFragmentByTag(CoordinateInputBottomSheetDialogFragment.TAG);
if (coordinateInputBottomSheetDialogFragment != null) { if (optionsFragment != null) {
((CoordinateInputBottomSheetDialogFragment) coordinateInputBottomSheetDialogFragment).setListener(createCoordinateInputFormatChangeListener()); ((CoordinateInputBottomSheetDialogFragment) optionsFragment).setListener(createCoordinateInputFormatChangeListener());
} }
mainView.findViewById(R.id.back_button).setOnClickListener(new View.OnClickListener() { mainView = inflater.inflate(R.layout.fragment_coordinate_input_dialog, container);
ImageButton backBtn = (ImageButton) mainView.findViewById(R.id.back_button);
backBtn.setImageDrawable(getActiveIcon(R.drawable.ic_arrow_back));
backBtn.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
saveMarkers(); saveMarkers();
@ -163,9 +168,13 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
} }
}); });
mainView.findViewById(R.id.app_bar).setBackgroundColor(ContextCompat.getColor(getContext(), lightTheme ? R.color.coordinate_input_app_bar_color_light : R.color.coordinate_input_app_bar_color_dark)); ((TextView) mainView.findViewById(R.id.toolbar_text)).setTextColor(ContextCompat.getColor(getContext(),
final View optionsButton = mainView.findViewById(R.id.options_button); lightTheme ? R.color.color_black : R.color.color_white));
optionsButton.setOnClickListener(new View.OnClickListener() {
mainView.findViewById(R.id.app_bar).setBackgroundColor(ContextCompat.getColor(getContext(),
lightTheme ? R.color.route_info_bg_light : R.color.route_info_bg_dark));
mainView.findViewById(R.id.options_button).setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
View focusedView = getDialog().getCurrentFocus(); View focusedView = getDialog().getCurrentFocus();
@ -173,27 +182,71 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
focusedView.clearFocus(); focusedView.clearFocus();
AndroidUtils.hideSoftKeyboard(getMapActivity(), focusedView); AndroidUtils.hideSoftKeyboard(getMapActivity(), focusedView);
} }
CoordinateInputBottomSheetDialogFragment fragment = new CoordinateInputBottomSheetDialogFragment();
fragment.setUsedOnMap(false);
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putBoolean(USE_OSMAND_KEYBOARD, useOsmandKeyboard); args.putBoolean(USE_OSMAND_KEYBOARD, useOsmandKeyboard);
args.putBoolean(RIGHT_HAND, rightHand); args.putBoolean(RIGHT_HAND, rightHand);
args.putBoolean(GO_TO_NEXT_FIELD, goToNextField); args.putBoolean(GO_TO_NEXT_FIELD, goToNextField);
args.putInt(ACCURACY, accuracy); args.putInt(ACCURACY, accuracy);
CoordinateInputBottomSheetDialogFragment fragment = new CoordinateInputBottomSheetDialogFragment();
fragment.setUsedOnMap(false);
fragment.setArguments(args); fragment.setArguments(args);
fragment.setListener(createCoordinateInputFormatChangeListener()); fragment.setListener(createCoordinateInputFormatChangeListener());
fragment.show(getMapActivity().getSupportFragmentManager(), CoordinateInputBottomSheetDialogFragment.TAG); fragment.show(getChildFragmentManager(), CoordinateInputBottomSheetDialogFragment.TAG);
} }
}); });
textFieldBoxes = new ArrayList<>(); addEditTexts(R.id.lat_first_input_et, R.id.lat_second_input_et, R.id.lat_thirst_input_et,
final OsmandTextFieldBoxes latitudeBox = (OsmandTextFieldBoxes) mainView.findViewById(R.id.latitude_box); R.id.lon_first_input_et, R.id.lon_second_input_et, R.id.lon_thirst_input_et, R.id.point_name_et);
textFieldBoxes.add(latitudeBox);
final OsmandTextFieldBoxes longitudeBox = (OsmandTextFieldBoxes) mainView.findViewById(R.id.longitude_box); View.OnClickListener backspaceOnClickListener = new View.OnClickListener() {
textFieldBoxes.add(longitudeBox); @Override
final OsmandTextFieldBoxes nameBox = (OsmandTextFieldBoxes) mainView.findViewById(R.id.name_box); public void onClick(View v) {
nameBox.setEndIcon(iconsCache.getIcon(R.drawable.ic_action_keyboard, R.color.coordinate_input_keyboard_icon_color)); Toast.makeText(mapActivity, "backspace", Toast.LENGTH_SHORT).show();
nameBox.getEndIconImageButton().setOnClickListener(new View.OnClickListener() { }
};
View latSideOfTheWorldBtn = mainView.findViewById(R.id.lat_side_of_the_world_btn);
latSideOfTheWorldBtn.setBackgroundResource(lightTheme
? R.drawable.context_menu_controller_bg_light : R.drawable.context_menu_controller_bg_dark);
latSideOfTheWorldBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(mapActivity, "lat side of the world", Toast.LENGTH_SHORT).show();
}
});
((TextView) latSideOfTheWorldBtn.findViewById(R.id.lat_side_of_the_world_tv)).setText(getString(R.string.north_abbreviation));
ImageView northSideIv = latSideOfTheWorldBtn.findViewById(R.id.north_side_iv);
northSideIv.setImageDrawable(getColoredIcon(R.drawable.ic_action_coordinates_longitude, R.color.dashboard_blue));
View lonSideOfTheWorldBtn = mainView.findViewById(R.id.lon_side_of_the_world_btn);
lonSideOfTheWorldBtn.setBackgroundResource(lightTheme
? R.drawable.context_menu_controller_bg_light : R.drawable.context_menu_controller_bg_dark);
lonSideOfTheWorldBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(mapActivity, "lon side of the world", Toast.LENGTH_SHORT).show();
}
});
((TextView) lonSideOfTheWorldBtn.findViewById(R.id.lon_side_of_the_world_tv)).setText(getString(R.string.west_abbreviation));
ImageView westSideIv = lonSideOfTheWorldBtn.findViewById(R.id.west_side_iv);
westSideIv.setImageDrawable(getColoredIcon(R.drawable.ic_action_coordinates_latitude, R.color.dashboard_blue));
ImageView latBackspaceBtn = (ImageView) mainView.findViewById(R.id.lat_backspace_btn);
latBackspaceBtn.setImageDrawable(getActiveIcon(R.drawable.ic_keyboard_backspace));
latBackspaceBtn.setOnClickListener(backspaceOnClickListener);
ImageView lonBackspaceBtn = (ImageView) mainView.findViewById(R.id.lon_backspace_btn);
lonBackspaceBtn.setImageDrawable(getActiveIcon(R.drawable.ic_keyboard_backspace));
lonBackspaceBtn.setOnClickListener(backspaceOnClickListener);
mainView.findViewById(R.id.point_name_divider).setBackgroundColor(ContextCompat
.getColor(getContext(), lightTheme ? R.color.route_info_divider_light : R.color.route_info_divider_dark));
mainView.findViewById(R.id.point_name_et_container).setBackgroundColor(ContextCompat
.getColor(getContext(), lightTheme ? R.color.route_info_bottom_view_bg_light : R.color.route_info_bottom_view_bg_dark));
ImageView pointNameKeyboardBtn = (ImageView) mainView.findViewById(R.id.point_name_keyboard_btn);
pointNameKeyboardBtn.setImageDrawable(getActiveIcon(R.drawable.ic_action_keyboard));
pointNameKeyboardBtn.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
View focusedView = getDialog().getCurrentFocus(); View focusedView = getDialog().getCurrentFocus();
@ -204,12 +257,11 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
} }
} }
}); });
textFieldBoxes.add(nameBox);
registerInputs(); registerInputs();
if (savedInstanceState == null) { if (savedInstanceState == null) {
latitudeBox.select(); ((EditText) mainView.findViewById(R.id.lat_first_input_et)).requestFocus();
} }
registerMainView(); registerMainView();
@ -276,7 +328,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
} }
AndroidUtils.setBackground(mapActivity, keyboardLayout, !lightTheme, lightResId, darkResId); AndroidUtils.setBackground(mapActivity, keyboardLayout, !lightTheme, lightResId, darkResId);
Object[] keyboardItems = new Object[] { "1", "2", "3", R.drawable.ic_keyboard_next_field, Object[] keyboardItems = new Object[]{"1", "2", "3", R.drawable.ic_keyboard_next_field,
"4", "5", "6", "-", "4", "5", "6", "-",
"7", "8", "9", R.drawable.ic_keyboard_backspace, "7", "8", "9", R.drawable.ic_keyboard_backspace,
":", "0", ".", getString(R.string.shared_string_clear)}; ":", "0", ".", getString(R.string.shared_string_clear)};
@ -320,7 +372,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
if (orientationPortrait) { if (orientationPortrait) {
final ImageView showHideKeyboardIcon = (ImageView) mainView.findViewById(R.id.show_hide_keyboard_icon); final ImageView showHideKeyboardIcon = (ImageView) mainView.findViewById(R.id.show_hide_keyboard_icon);
showHideKeyboardIcon.setBackgroundResource(lightTheme ? R.drawable.keyboard_item_add_button_light_bg : R.drawable.keyboard_item_add_button_dark_bg); showHideKeyboardIcon.setBackgroundResource(lightTheme ? R.drawable.keyboard_item_add_button_light_bg : R.drawable.keyboard_item_add_button_dark_bg);
showHideKeyboardIcon.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_arrow_down, R.color.keyboard_item_button_text_color)); showHideKeyboardIcon.setImageDrawable(getColoredIcon(R.drawable.ic_action_arrow_down, R.color.keyboard_item_button_text_color));
showHideKeyboardIcon.setOnClickListener(new View.OnClickListener() { showHideKeyboardIcon.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
@ -365,21 +417,13 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
} }
} }
private void registerInputs() { private void addEditTexts(@IdRes int... ids) {
View.OnTouchListener textFieldBoxOnTouchListener = new View.OnTouchListener() { for (int id : ids) {
@Override editTexts.add((EditText) mainView.findViewById(id));
public boolean onTouch(View view, MotionEvent motionEvent) {
if (orientationPortrait) {
if (!useOsmandKeyboard && isOsmandKeyboardCurrentlyVisible()) {
changeOsmandKeyboardVisibility(false);
} else if (useOsmandKeyboard && !isOsmandKeyboardCurrentlyVisible()) {
changeOsmandKeyboardVisibility(true);
} }
} }
return false;
}
};
private void registerInputs() {
TextWatcher textWatcher = new TextWatcher() { TextWatcher textWatcher = new TextWatcher() {
private int strLength; private int strLength;
@ -524,15 +568,13 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
} }
}; };
for (OsmandTextFieldBoxes textFieldBox : textFieldBoxes) { for (EditText et : editTexts) {
textFieldBox.getPanel().setOnTouchListener(textFieldBoxOnTouchListener); if (et.getId() != R.id.point_name_et) {
EditText editText = textFieldBox.getEditText(); et.addTextChangedListener(textWatcher);
if (editText.getId() != R.id.name_edit_text) {
editText.addTextChangedListener(textWatcher);
} }
editText.setOnTouchListener(inputEditTextOnTouchListener); et.setOnTouchListener(inputEditTextOnTouchListener);
editText.setOnLongClickListener(inputEditTextOnLongClickListener); et.setOnLongClickListener(inputEditTextOnLongClickListener);
editText.setOnEditorActionListener(inputTextViewOnEditorActionListener); et.setOnEditorActionListener(inputTextViewOnEditorActionListener);
} }
changeKeyboardInBoxes(); changeKeyboardInBoxes();
@ -580,9 +622,8 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
} }
private void changeEditTextSelections() { private void changeEditTextSelections() {
for (OsmandTextFieldBoxes textFieldBox : textFieldBoxes) { for (EditText et : editTexts) {
EditText editText = textFieldBox.getEditText(); et.setSelection(et.getText().length());
editText.setSelection(editText.getText().length());
} }
} }
@ -595,13 +636,13 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
mainView.findViewById(R.id.keyboard_grid_view).setVisibility(visibility); mainView.findViewById(R.id.keyboard_grid_view).setVisibility(visibility);
mainView.findViewById(R.id.keyboard_divider).setVisibility(visibility); mainView.findViewById(R.id.keyboard_divider).setVisibility(visibility);
((ImageView) mainView.findViewById(R.id.show_hide_keyboard_icon)) ((ImageView) mainView.findViewById(R.id.show_hide_keyboard_icon))
.setImageDrawable(iconsCache.getIcon(show ? R.drawable.ic_action_arrow_down : R.drawable.ic_action_arrow_up, R.color.keyboard_item_button_text_color)); .setImageDrawable(getColoredIcon(show ? R.drawable.ic_action_arrow_down : R.drawable.ic_action_arrow_up, R.color.keyboard_item_button_text_color));
} }
private void changeKeyboardInBoxes() { private void changeKeyboardInBoxes() {
for (OsmandTextFieldBoxes textFieldBox : textFieldBoxes) { // for (OsmandTextFieldBoxes textFieldBox : editTexts) {
textFieldBox.setUseOsmandKeyboard(useOsmandKeyboard); // textFieldBox.setUseOsmandKeyboard(useOsmandKeyboard);
} // }
} }
private void switchToNextInput(int id) { private void switchToNextInput(int id) {
@ -667,11 +708,19 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
} }
private void clearInputs() { private void clearInputs() {
for (OsmandTextFieldBoxes osmandTextFieldBox : textFieldBoxes) { for (EditText et : editTexts) {
osmandTextFieldBox.getEditText().setText(""); et.setText("");
osmandTextFieldBox.deactivate(); et.clearFocus();
} }
((OsmandTextFieldBoxes) mainView.findViewById(R.id.latitude_box)).select(); ((EditText) mainView.findViewById(R.id.lat_first_input_et)).requestFocus();
}
private Drawable getActiveIcon(@DrawableRes int resId) {
return getColoredIcon(resId, lightTheme ? R.color.icon_color : R.color.coordinate_input_active_icon_dark);
}
private Drawable getColoredIcon(@DrawableRes int resId, @ColorRes int colorResId) {
return getMyApplication().getIconsCache().getIcon(resId, colorResId);
} }
private MapActivity getMapActivity() { private MapActivity getMapActivity() {
@ -822,7 +871,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
icon = DrawableCompat.wrap(getResources().getDrawable((Integer) item)); icon = DrawableCompat.wrap(getResources().getDrawable((Integer) item));
DrawableCompat.setTintList(icon, numberColorStateList); DrawableCompat.setTintList(icon, numberColorStateList);
} else { } else {
icon = iconsCache.getIcon((Integer) item, R.color.keyboard_item_divider_control_color_dark); icon = getColoredIcon((Integer) item, R.color.keyboard_item_divider_control_color_dark);
} }
keyboardItemImage.setImageDrawable(icon); keyboardItemImage.setImageDrawable(icon);
} }
@ -834,5 +883,4 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
interface OnMapMarkersSavedListener { interface OnMapMarkersSavedListener {
void onMapMarkersSaved(); void onMapMarkersSaved();
} }
} }