Add support for different coordinate formats
This commit is contained in:
parent
7c8e39d0eb
commit
e72d419e9a
5 changed files with 332 additions and 247 deletions
|
@ -77,7 +77,6 @@
|
||||||
|
|
||||||
<studio.carbonylgroup.textfieldboxes.ExtendedEditText
|
<studio.carbonylgroup.textfieldboxes.ExtendedEditText
|
||||||
android:hint="50:00.0000"
|
android:hint="50:00.0000"
|
||||||
android:maxLength="10"
|
|
||||||
android:id="@+id/latitude_edit_text"
|
android:id="@+id/latitude_edit_text"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"/>
|
android:layout_height="wrap_content"/>
|
||||||
|
@ -97,7 +96,6 @@
|
||||||
|
|
||||||
<studio.carbonylgroup.textfieldboxes.ExtendedEditText
|
<studio.carbonylgroup.textfieldboxes.ExtendedEditText
|
||||||
android:hint="50:00.0000"
|
android:hint="50:00.0000"
|
||||||
android:maxLength="10"
|
|
||||||
android:id="@+id/longitude_edit_text"
|
android:id="@+id/longitude_edit_text"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"/>
|
android:layout_height="wrap_content"/>
|
||||||
|
|
|
@ -42,17 +42,13 @@
|
||||||
android:textColor="?android:textColorSecondary"
|
android:textColor="?android:textColorSecondary"
|
||||||
android:textSize="@dimen/default_desc_text_size"/>
|
android:textSize="@dimen/default_desc_text_size"/>
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
android:id="@+id/degrees_frame"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="@dimen/bottom_sheet_list_item_height">
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:background="?attr/selectableItemBackground"
|
|
||||||
android:gravity="center_vertical"
|
|
||||||
android:id="@+id/degrees_row"
|
android:id="@+id/degrees_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:gravity="center_vertical"
|
||||||
android:minHeight="@dimen/bottom_sheet_list_item_height"
|
android:minHeight="@dimen/bottom_sheet_list_item_height"
|
||||||
android:paddingEnd="@dimen/bottom_sheet_content_padding"
|
android:paddingEnd="@dimen/bottom_sheet_content_padding"
|
||||||
android:paddingLeft="@dimen/bottom_sheet_content_padding"
|
android:paddingLeft="@dimen/bottom_sheet_content_padding"
|
||||||
|
@ -70,11 +66,11 @@
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/degrees_text"
|
android:id="@+id/degrees_text"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_weight="1"
|
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
tools:text="DDD.DD"
|
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
||||||
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
|
tools:text="DDD.DD"/>
|
||||||
|
|
||||||
<RadioButton
|
<RadioButton
|
||||||
android:id="@+id/degrees_radio_button"
|
android:id="@+id/degrees_radio_button"
|
||||||
|
@ -85,19 +81,13 @@
|
||||||
android:focusable="false"/>
|
android:focusable="false"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</FrameLayout>
|
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
android:id="@+id/minutes_frame"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="@dimen/bottom_sheet_list_item_height">
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:background="?attr/selectableItemBackground"
|
|
||||||
android:gravity="center_vertical"
|
|
||||||
android:id="@+id/minutes_row"
|
android:id="@+id/minutes_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:gravity="center_vertical"
|
||||||
android:minHeight="@dimen/bottom_sheet_list_item_height"
|
android:minHeight="@dimen/bottom_sheet_list_item_height"
|
||||||
android:paddingEnd="@dimen/bottom_sheet_content_padding"
|
android:paddingEnd="@dimen/bottom_sheet_content_padding"
|
||||||
android:paddingLeft="@dimen/bottom_sheet_content_padding"
|
android:paddingLeft="@dimen/bottom_sheet_content_padding"
|
||||||
|
@ -115,11 +105,11 @@
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/minutes_text"
|
android:id="@+id/minutes_text"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_weight="1"
|
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
tools:text="DDD MM.MM"
|
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
||||||
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
|
tools:text="DDD MM.MM"/>
|
||||||
|
|
||||||
<RadioButton
|
<RadioButton
|
||||||
android:id="@+id/minutes_radio_button"
|
android:id="@+id/minutes_radio_button"
|
||||||
|
@ -130,19 +120,12 @@
|
||||||
android:focusable="false"/>
|
android:focusable="false"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</FrameLayout>
|
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
android:id="@+id/seconds_frame"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="@dimen/bottom_sheet_list_item_height">
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:background="?attr/selectableItemBackground"
|
|
||||||
android:gravity="center_vertical"
|
|
||||||
android:id="@+id/seconds_row"
|
android:id="@+id/seconds_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:gravity="center_vertical"
|
||||||
android:minHeight="@dimen/bottom_sheet_list_item_height"
|
android:minHeight="@dimen/bottom_sheet_list_item_height"
|
||||||
android:paddingEnd="@dimen/bottom_sheet_content_padding"
|
android:paddingEnd="@dimen/bottom_sheet_content_padding"
|
||||||
android:paddingLeft="@dimen/bottom_sheet_content_padding"
|
android:paddingLeft="@dimen/bottom_sheet_content_padding"
|
||||||
|
@ -160,11 +143,11 @@
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/seconds_text"
|
android:id="@+id/seconds_text"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_weight="1"
|
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
tools:text="DDD MM SS.SS"
|
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
||||||
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
|
tools:text="DDD MM SS.SS"/>
|
||||||
|
|
||||||
<RadioButton
|
<RadioButton
|
||||||
android:id="@+id/seconds_radio_button"
|
android:id="@+id/seconds_radio_button"
|
||||||
|
@ -175,19 +158,12 @@
|
||||||
android:focusable="false"/>
|
android:focusable="false"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</FrameLayout>
|
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
android:id="@+id/utm_frame"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="@dimen/bottom_sheet_list_item_height">
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:background="?attr/selectableItemBackground"
|
|
||||||
android:gravity="center_vertical"
|
|
||||||
android:id="@+id/utm_row"
|
android:id="@+id/utm_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:gravity="center_vertical"
|
||||||
android:minHeight="@dimen/bottom_sheet_list_item_height"
|
android:minHeight="@dimen/bottom_sheet_list_item_height"
|
||||||
android:paddingEnd="@dimen/bottom_sheet_content_padding"
|
android:paddingEnd="@dimen/bottom_sheet_content_padding"
|
||||||
android:paddingLeft="@dimen/bottom_sheet_content_padding"
|
android:paddingLeft="@dimen/bottom_sheet_content_padding"
|
||||||
|
@ -205,11 +181,11 @@
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/utm_text"
|
android:id="@+id/utm_text"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_weight="1"
|
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
tools:text="UTM"
|
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
||||||
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
|
tools:text="UTM"/>
|
||||||
|
|
||||||
<RadioButton
|
<RadioButton
|
||||||
android:id="@+id/utm_radio_button"
|
android:id="@+id/utm_radio_button"
|
||||||
|
@ -220,19 +196,12 @@
|
||||||
android:focusable="false"/>
|
android:focusable="false"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</FrameLayout>
|
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
android:id="@+id/olc_frame"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="@dimen/bottom_sheet_list_item_height">
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:background="?attr/selectableItemBackground"
|
|
||||||
android:gravity="center_vertical"
|
|
||||||
android:id="@+id/olc_row"
|
android:id="@+id/olc_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:gravity="center_vertical"
|
||||||
android:minHeight="@dimen/bottom_sheet_list_item_height"
|
android:minHeight="@dimen/bottom_sheet_list_item_height"
|
||||||
android:paddingEnd="@dimen/bottom_sheet_content_padding"
|
android:paddingEnd="@dimen/bottom_sheet_content_padding"
|
||||||
android:paddingLeft="@dimen/bottom_sheet_content_padding"
|
android:paddingLeft="@dimen/bottom_sheet_content_padding"
|
||||||
|
@ -250,11 +219,11 @@
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/olc_text"
|
android:id="@+id/olc_text"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_weight="1"
|
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
tools:text="OLC"
|
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
||||||
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
|
tools:text="OLC"/>
|
||||||
|
|
||||||
<RadioButton
|
<RadioButton
|
||||||
android:id="@+id/olc_radio_button"
|
android:id="@+id/olc_radio_button"
|
||||||
|
@ -265,8 +234,6 @@
|
||||||
android:focusable="false"/>
|
android:focusable="false"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</FrameLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
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="fast_coordinates_input_descr">Choose oordinate format before start. YOu can always change it by tapping Options.</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="fast_coordinates_input">Fast Coordinates input</string>
|
||||||
<string name="use_location">Use location</string>
|
<string name="use_location">Use location</string>
|
||||||
<string name="add_location_as_first_point_descr">Add your location as first point to plan perfect route.</string>
|
<string name="add_location_as_first_point_descr">Add your location as first point to plan perfect route.</string>
|
||||||
|
|
|
@ -5,6 +5,7 @@ import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.DrawableRes;
|
import android.support.annotation.DrawableRes;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.view.ContextThemeWrapper;
|
import android.view.ContextThemeWrapper;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -22,8 +23,6 @@ import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.base.BottomSheetDialogFragment;
|
import net.osmand.plus.base.BottomSheetDialogFragment;
|
||||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||||
|
|
||||||
import org.w3c.dom.Text;
|
|
||||||
|
|
||||||
public class CoordinateInputBottomSheetDialogFragment extends BottomSheetDialogFragment {
|
public class CoordinateInputBottomSheetDialogFragment extends BottomSheetDialogFragment {
|
||||||
|
|
||||||
public final static String TAG = "CoordinateInputBottomSheetDialogFragment";
|
public final static String TAG = "CoordinateInputBottomSheetDialogFragment";
|
||||||
|
@ -31,15 +30,20 @@ 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 CoordinateInputFormatChangeListener listener;
|
||||||
|
|
||||||
private Format currentFormat = Format.DEGREES;
|
public void setListener(CoordinateInputFormatChangeListener listener) {
|
||||||
|
this.listener = listener;
|
||||||
|
}
|
||||||
|
|
||||||
private enum Format {
|
@Override
|
||||||
DEGREES,
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
MINUTES,
|
super.onCreate(savedInstanceState);
|
||||||
SECONDS,
|
Bundle args = getArguments();
|
||||||
UTM,
|
if (args != null) {
|
||||||
OLC
|
coordinateFormat = getArguments().getInt(CoordinateInputDialogFragment.COORDINATE_FORMAT, -1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@ -61,49 +65,89 @@ public class CoordinateInputBottomSheetDialogFragment extends BottomSheetDialogF
|
||||||
|
|
||||||
ImageView degreesIcon = (ImageView) mainView.findViewById(R.id.degrees_icon);
|
ImageView degreesIcon = (ImageView) mainView.findViewById(R.id.degrees_icon);
|
||||||
TextView degreesText = (TextView) mainView.findViewById(R.id.degrees_text);
|
TextView degreesText = (TextView) mainView.findViewById(R.id.degrees_text);
|
||||||
if (currentFormat == Format.DEGREES) {
|
if (coordinateFormat == PointDescription.FORMAT_DEGREES) {
|
||||||
degreesIcon.setImageDrawable(getIcon(R.drawable.ic_action_coordinates_latitude, R.color.dashboard_blue));
|
degreesIcon.setImageDrawable(getIcon(R.drawable.ic_action_coordinates_latitude, R.color.dashboard_blue));
|
||||||
|
degreesText.setTextColor(ContextCompat.getColor(mapActivity, R.color.dashboard_blue));
|
||||||
} else {
|
} else {
|
||||||
degreesIcon.setImageDrawable(getContentIcon(R.drawable.ic_action_coordinates_latitude));
|
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);
|
ImageView minutesIcon = (ImageView) mainView.findViewById(R.id.minutes_icon);
|
||||||
TextView minutesText = (TextView) mainView.findViewById(R.id.minutes_text);
|
TextView minutesText = (TextView) mainView.findViewById(R.id.minutes_text);
|
||||||
if (currentFormat == Format.MINUTES) {
|
if (coordinateFormat == PointDescription.FORMAT_MINUTES) {
|
||||||
minutesIcon.setImageDrawable(getIcon(R.drawable.ic_action_coordinates_latitude, R.color.dashboard_blue));
|
minutesIcon.setImageDrawable(getIcon(R.drawable.ic_action_coordinates_latitude, R.color.dashboard_blue));
|
||||||
|
minutesText.setTextColor(ContextCompat.getColor(mapActivity, R.color.dashboard_blue));
|
||||||
} else {
|
} else {
|
||||||
minutesIcon.setImageDrawable(getContentIcon(R.drawable.ic_action_coordinates_latitude));
|
minutesIcon.setImageDrawable(getContentIcon(R.drawable.ic_action_coordinates_latitude));
|
||||||
}
|
}
|
||||||
|
minutesText.setText(PointDescription.formatToHumanString(getContext(), PointDescription.FORMAT_MINUTES));
|
||||||
|
|
||||||
ImageView secondsIcon = (ImageView) mainView.findViewById(R.id.seconds_icon);
|
ImageView secondsIcon = (ImageView) mainView.findViewById(R.id.seconds_icon);
|
||||||
TextView secondsText = (TextView) mainView.findViewById(R.id.seconds_text);
|
TextView secondsText = (TextView) mainView.findViewById(R.id.seconds_text);
|
||||||
if (currentFormat == Format.SECONDS) {
|
if (coordinateFormat == PointDescription.FORMAT_SECONDS) {
|
||||||
secondsIcon.setImageDrawable(getIcon(R.drawable.ic_action_coordinates_latitude, R.color.dashboard_blue));
|
secondsIcon.setImageDrawable(getIcon(R.drawable.ic_action_coordinates_latitude, R.color.dashboard_blue));
|
||||||
|
secondsText.setTextColor(ContextCompat.getColor(mapActivity, R.color.dashboard_blue));
|
||||||
} else {
|
} else {
|
||||||
secondsIcon.setImageDrawable(getContentIcon(R.drawable.ic_action_coordinates_latitude));
|
secondsIcon.setImageDrawable(getContentIcon(R.drawable.ic_action_coordinates_latitude));
|
||||||
}
|
}
|
||||||
|
secondsText.setText(PointDescription.formatToHumanString(getContext(), PointDescription.FORMAT_SECONDS));
|
||||||
|
|
||||||
ImageView utmIcon = (ImageView) mainView.findViewById(R.id.utm_icon);
|
ImageView utmIcon = (ImageView) mainView.findViewById(R.id.utm_icon);
|
||||||
TextView utmText = (TextView) mainView.findViewById(R.id.utm_text);
|
TextView utmText = (TextView) mainView.findViewById(R.id.utm_text);
|
||||||
if (currentFormat == Format.UTM) {
|
if (coordinateFormat == PointDescription.UTM_FORMAT) {
|
||||||
utmIcon.setImageDrawable(getIcon(R.drawable.ic_action_coordinates_latitude, R.color.dashboard_blue));
|
utmIcon.setImageDrawable(getIcon(R.drawable.ic_action_coordinates_latitude, R.color.dashboard_blue));
|
||||||
|
utmText.setTextColor(ContextCompat.getColor(mapActivity, R.color.dashboard_blue));
|
||||||
} else {
|
} else {
|
||||||
utmIcon.setImageDrawable(getContentIcon(R.drawable.ic_action_coordinates_latitude));
|
utmIcon.setImageDrawable(getContentIcon(R.drawable.ic_action_coordinates_latitude));
|
||||||
}
|
}
|
||||||
|
utmText.setText(PointDescription.formatToHumanString(getContext(), PointDescription.UTM_FORMAT));
|
||||||
|
|
||||||
ImageView olcIcon = (ImageView) mainView.findViewById(R.id.olc_icon);
|
ImageView olcIcon = (ImageView) mainView.findViewById(R.id.olc_icon);
|
||||||
TextView olcText = (TextView) mainView.findViewById(R.id.olc_text);
|
TextView olcText = (TextView) mainView.findViewById(R.id.olc_text);
|
||||||
if (currentFormat == Format.OLC) {
|
if (coordinateFormat == PointDescription.OLC_FORMAT) {
|
||||||
olcIcon.setImageDrawable(getIcon(R.drawable.ic_action_coordinates_latitude, R.color.dashboard_blue));
|
olcIcon.setImageDrawable(getIcon(R.drawable.ic_action_coordinates_latitude, R.color.dashboard_blue));
|
||||||
|
olcText.setTextColor(ContextCompat.getColor(mapActivity, R.color.dashboard_blue));
|
||||||
} else {
|
} else {
|
||||||
olcIcon.setImageDrawable(getContentIcon(R.drawable.ic_action_coordinates_latitude));
|
olcIcon.setImageDrawable(getContentIcon(R.drawable.ic_action_coordinates_latitude));
|
||||||
}
|
}
|
||||||
|
olcText.setText(PointDescription.formatToHumanString(getContext(), PointDescription.OLC_FORMAT));
|
||||||
|
|
||||||
((TextView) mainView.findViewById(R.id.degrees_text)).setText(PointDescription.formatToHumanString(getContext(), PointDescription.FORMAT_DEGREES));
|
View.OnClickListener formatChangeListener = new View.OnClickListener() {
|
||||||
((TextView) mainView.findViewById(R.id.minutes_text)).setText(PointDescription.formatToHumanString(getContext(), PointDescription.FORMAT_MINUTES));
|
@Override
|
||||||
((TextView) mainView.findViewById(R.id.seconds_text)).setText(PointDescription.formatToHumanString(getContext(), PointDescription.FORMAT_SECONDS));
|
public void onClick(View view) {
|
||||||
((TextView) mainView.findViewById(R.id.utm_text)).setText(PointDescription.formatToHumanString(getContext(), PointDescription.UTM_FORMAT));
|
int format;
|
||||||
((TextView) mainView.findViewById(R.id.olc_text)).setText(PointDescription.formatToHumanString(getContext(), PointDescription.OLC_FORMAT));
|
switch (view.getId()) {
|
||||||
|
case R.id.degrees_row:
|
||||||
|
format = PointDescription.FORMAT_DEGREES;
|
||||||
|
break;
|
||||||
|
case R.id.minutes_row:
|
||||||
|
format = PointDescription.FORMAT_MINUTES;
|
||||||
|
break;
|
||||||
|
case R.id.seconds_row:
|
||||||
|
format = PointDescription.FORMAT_SECONDS;
|
||||||
|
break;
|
||||||
|
case R.id.utm_row:
|
||||||
|
format = PointDescription.UTM_FORMAT;
|
||||||
|
break;
|
||||||
|
case R.id.olc_row:
|
||||||
|
format = PointDescription.OLC_FORMAT;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException("Unsupported format");
|
||||||
|
}
|
||||||
|
if (listener != null) {
|
||||||
|
listener.onCoordinateFormatChanged(format);
|
||||||
|
}
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
mainView.findViewById(R.id.degrees_row).setOnClickListener(formatChangeListener);
|
||||||
|
mainView.findViewById(R.id.minutes_row).setOnClickListener(formatChangeListener);
|
||||||
|
mainView.findViewById(R.id.seconds_row).setOnClickListener(formatChangeListener);
|
||||||
|
mainView.findViewById(R.id.utm_row).setOnClickListener(formatChangeListener);
|
||||||
|
mainView.findViewById(R.id.olc_row).setOnClickListener(formatChangeListener);
|
||||||
|
|
||||||
mainView.findViewById(R.id.cancel_row).setOnClickListener(new View.OnClickListener() {
|
mainView.findViewById(R.id.cancel_row).setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -119,7 +163,7 @@ public class CoordinateInputBottomSheetDialogFragment extends BottomSheetDialogF
|
||||||
mainView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
mainView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onGlobalLayout() {
|
public void onGlobalLayout() {
|
||||||
final View scrollView = mainView.findViewById(R.id.marker_show_direction_scroll_view);
|
final View scrollView = mainView.findViewById(R.id.marker_coordinate_input_scroll_view);
|
||||||
int scrollViewHeight = scrollView.getHeight();
|
int scrollViewHeight = scrollView.getHeight();
|
||||||
int dividerHeight = AndroidUtils.dpToPx(getContext(), 1);
|
int dividerHeight = AndroidUtils.dpToPx(getContext(), 1);
|
||||||
int cancelButtonHeight = getContext().getResources().getDimensionPixelSize(R.dimen.bottom_sheet_cancel_button_height);
|
int cancelButtonHeight = getContext().getResources().getDimensionPixelSize(R.dimen.bottom_sheet_cancel_button_height);
|
||||||
|
@ -167,4 +211,8 @@ public class CoordinateInputBottomSheetDialogFragment extends BottomSheetDialogF
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface CoordinateInputFormatChangeListener {
|
||||||
|
void onCoordinateFormatChanged(int format);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,33 +2,29 @@ package net.osmand.plus.mapmarkers;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.LayoutRes;
|
|
||||||
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;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
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.view.Gravity;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.MotionEvent;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.WindowManager;
|
|
||||||
import android.view.inputmethod.InputMethodManager;
|
|
||||||
import android.widget.AdapterView;
|
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.TextView;
|
|
||||||
|
|
||||||
|
import net.osmand.data.PointDescription;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandSettings;
|
import net.osmand.plus.OsmandSettings;
|
||||||
import net.osmand.plus.OsmandTextFieldBoxes;
|
import net.osmand.plus.OsmandTextFieldBoxes;
|
||||||
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.helpers.FontCache;
|
|
||||||
import net.osmand.plus.widgets.TextViewEx;
|
import net.osmand.plus.widgets.TextViewEx;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -38,16 +34,23 @@ import studio.carbonylgroup.textfieldboxes.ExtendedEditText;
|
||||||
|
|
||||||
public class CoordinateInputDialogFragment extends DialogFragment {
|
public class CoordinateInputDialogFragment extends DialogFragment {
|
||||||
|
|
||||||
|
public static final String TAG = "CoordinateInputDialogFragment";
|
||||||
|
|
||||||
|
public static final String COORDINATE_FORMAT = "coordinate_format";
|
||||||
|
|
||||||
private static final int DELETE_BUTTON_POSITION = 9;
|
private static final int DELETE_BUTTON_POSITION = 9;
|
||||||
private static final int CLEAR_BUTTON_POSITION = 11;
|
private static final int CLEAR_BUTTON_POSITION = 11;
|
||||||
|
private static final int DEGREES_MAX_LENGTH = 8;
|
||||||
public static final String TAG = "CoordinateInputDialogFragment";
|
private static final int MINUTES_MAX_LENGTH = 10;
|
||||||
|
private static final int SECONDS_MAX_LENGTH = 13;
|
||||||
|
|
||||||
private boolean lightTheme;
|
private boolean lightTheme;
|
||||||
private EditText focusedEditText;
|
private EditText focusedEditText;
|
||||||
private boolean useOsmandKeyboard = true;
|
private boolean useOsmandKeyboard = true;
|
||||||
private List<OsmandTextFieldBoxes> textFieldBoxes = new ArrayList<>();
|
private List<OsmandTextFieldBoxes> textFieldBoxes;
|
||||||
private List<ExtendedEditText> extendedEditTexts = new ArrayList<>();
|
private ExtendedEditText nameEditText;
|
||||||
|
private List<ExtendedEditText> extendedLatLonEditTexts;
|
||||||
|
private int coordinateFormat = -1;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
@ -57,9 +60,12 @@ public class CoordinateInputDialogFragment extends DialogFragment {
|
||||||
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);
|
||||||
|
|
||||||
|
if (coordinateFormat == -1) {
|
||||||
CoordinateInputBottomSheetDialogFragment fragment = new CoordinateInputBottomSheetDialogFragment();
|
CoordinateInputBottomSheetDialogFragment fragment = new CoordinateInputBottomSheetDialogFragment();
|
||||||
|
fragment.setListener(createCoordinateInputFormatChangeListener());
|
||||||
fragment.show(getMapActivity().getSupportFragmentManager(), CoordinateInputBottomSheetDialogFragment.TAG);
|
fragment.show(getMapActivity().getSupportFragmentManager(), CoordinateInputBottomSheetDialogFragment.TAG);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
|
@ -67,6 +73,13 @@ public class CoordinateInputDialogFragment extends DialogFragment {
|
||||||
final View mainView = inflater.inflate(R.layout.fragment_coordinate_input_dialog, container);
|
final View mainView = inflater.inflate(R.layout.fragment_coordinate_input_dialog, container);
|
||||||
final MapActivity mapActivity = getMapActivity();
|
final MapActivity mapActivity = getMapActivity();
|
||||||
|
|
||||||
|
if (coordinateFormat == -1) {
|
||||||
|
Fragment coordinateInputBottomSheetDialogFragment = mapActivity.getSupportFragmentManager().findFragmentByTag(CoordinateInputBottomSheetDialogFragment.TAG);
|
||||||
|
if (coordinateInputBottomSheetDialogFragment != null) {
|
||||||
|
((CoordinateInputBottomSheetDialogFragment) coordinateInputBottomSheetDialogFragment).setListener(createCoordinateInputFormatChangeListener());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Toolbar toolbar = (Toolbar) mainView.findViewById(R.id.coordinate_input_toolbar);
|
Toolbar toolbar = (Toolbar) mainView.findViewById(R.id.coordinate_input_toolbar);
|
||||||
|
|
||||||
toolbar.setNavigationIcon(getMyApplication().getIconsCache().getIcon(R.drawable.ic_arrow_back));
|
toolbar.setNavigationIcon(getMyApplication().getIconsCache().getIcon(R.drawable.ic_arrow_back));
|
||||||
|
@ -80,10 +93,16 @@ public class CoordinateInputDialogFragment extends DialogFragment {
|
||||||
optionsButton.setOnClickListener(new View.OnClickListener() {
|
optionsButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
|
CoordinateInputBottomSheetDialogFragment fragment = new CoordinateInputBottomSheetDialogFragment();
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putInt(COORDINATE_FORMAT, coordinateFormat);
|
||||||
|
fragment.setArguments(args);
|
||||||
|
fragment.setListener(createCoordinateInputFormatChangeListener());
|
||||||
|
fragment.show(getMapActivity().getSupportFragmentManager(), CoordinateInputBottomSheetDialogFragment.TAG);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
textFieldBoxes = new ArrayList<>();
|
||||||
final OsmandTextFieldBoxes latitudeBox = (OsmandTextFieldBoxes) mainView.findViewById(R.id.latitude_box);
|
final OsmandTextFieldBoxes latitudeBox = (OsmandTextFieldBoxes) mainView.findViewById(R.id.latitude_box);
|
||||||
textFieldBoxes.add(latitudeBox);
|
textFieldBoxes.add(latitudeBox);
|
||||||
final OsmandTextFieldBoxes longitudeBox = (OsmandTextFieldBoxes) mainView.findViewById(R.id.longitude_box);
|
final OsmandTextFieldBoxes longitudeBox = (OsmandTextFieldBoxes) mainView.findViewById(R.id.longitude_box);
|
||||||
|
@ -91,12 +110,12 @@ public class CoordinateInputDialogFragment extends DialogFragment {
|
||||||
final OsmandTextFieldBoxes nameBox = (OsmandTextFieldBoxes) mainView.findViewById(R.id.name_box);
|
final OsmandTextFieldBoxes nameBox = (OsmandTextFieldBoxes) mainView.findViewById(R.id.name_box);
|
||||||
textFieldBoxes.add(nameBox);
|
textFieldBoxes.add(nameBox);
|
||||||
|
|
||||||
|
extendedLatLonEditTexts = new ArrayList<>();
|
||||||
final ExtendedEditText latitudeEditText = (ExtendedEditText) mainView.findViewById(R.id.latitude_edit_text);
|
final ExtendedEditText latitudeEditText = (ExtendedEditText) mainView.findViewById(R.id.latitude_edit_text);
|
||||||
extendedEditTexts.add(latitudeEditText);
|
extendedLatLonEditTexts.add(latitudeEditText);
|
||||||
final ExtendedEditText longitudeEditText = (ExtendedEditText) mainView.findViewById(R.id.longitude_edit_text);
|
final ExtendedEditText longitudeEditText = (ExtendedEditText) mainView.findViewById(R.id.longitude_edit_text);
|
||||||
extendedEditTexts.add(longitudeEditText);
|
extendedLatLonEditTexts.add(longitudeEditText);
|
||||||
final ExtendedEditText nameEditText = (ExtendedEditText) mainView.findViewById(R.id.name_edit_text);
|
nameEditText = (ExtendedEditText) mainView.findViewById(R.id.name_edit_text);
|
||||||
extendedEditTexts.add(nameEditText);
|
|
||||||
|
|
||||||
final View.OnFocusChangeListener focusChangeListener = new View.OnFocusChangeListener() {
|
final View.OnFocusChangeListener focusChangeListener = new View.OnFocusChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -147,16 +166,33 @@ public class CoordinateInputDialogFragment extends DialogFragment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void afterTextChanged(Editable editable) {
|
public void afterTextChanged(Editable editable) {
|
||||||
if (focusedEditText != null) {
|
if (focusedEditText != null && focusedEditText != nameEditText) {
|
||||||
String str = focusedEditText.getText().toString();
|
String str = focusedEditText.getText().toString();
|
||||||
if(str.length() == 2 && len < str.length()){
|
int strLength = str.length();
|
||||||
focusedEditText.append(":");
|
if (strLength == 2 && len < strLength) {
|
||||||
} else if (str.length() == 5 && len < str.length()) {
|
String strToAppend;
|
||||||
|
if (coordinateFormat == PointDescription.FORMAT_DEGREES) {
|
||||||
|
strToAppend = ".";
|
||||||
|
} else {
|
||||||
|
strToAppend = ":";
|
||||||
|
}
|
||||||
|
focusedEditText.append(strToAppend);
|
||||||
|
} else if (strLength == 5 && coordinateFormat != PointDescription.FORMAT_DEGREES && len < strLength) {
|
||||||
|
String strToAppend;
|
||||||
|
if (coordinateFormat == PointDescription.FORMAT_MINUTES) {
|
||||||
|
strToAppend = ".";
|
||||||
|
} else {
|
||||||
|
strToAppend = ":";
|
||||||
|
}
|
||||||
|
focusedEditText.append(strToAppend);
|
||||||
|
} else if (strLength == 8 && coordinateFormat == PointDescription.FORMAT_SECONDS && len < strLength) {
|
||||||
focusedEditText.append(".");
|
focusedEditText.append(".");
|
||||||
} else if (str.length() == 10) {
|
} else 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)) {
|
||||||
if (focusedEditText == latitudeEditText) {
|
if (focusedEditText == latitudeEditText) {
|
||||||
longitudeBox.select();
|
longitudeBox.select();
|
||||||
} else if (focusedEditText == longitudeEditText) {
|
} else {
|
||||||
nameBox.select();
|
nameBox.select();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -207,6 +243,40 @@ public class CoordinateInputDialogFragment extends DialogFragment {
|
||||||
return mainView;
|
return mainView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroyView() {
|
||||||
|
focusedEditText = null;
|
||||||
|
if (getDialog() != null && getRetainInstance()) {
|
||||||
|
getDialog().setDismissMessage(null);
|
||||||
|
}
|
||||||
|
super.onDestroyView();
|
||||||
|
}
|
||||||
|
|
||||||
|
private CoordinateInputBottomSheetDialogFragment.CoordinateInputFormatChangeListener createCoordinateInputFormatChangeListener() {
|
||||||
|
return new CoordinateInputBottomSheetDialogFragment.CoordinateInputFormatChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onCoordinateFormatChanged(int format) {
|
||||||
|
coordinateFormat = format;
|
||||||
|
changeEditTextLengths();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private void changeEditTextLengths() {
|
||||||
|
int maxLength;
|
||||||
|
if (coordinateFormat == PointDescription.FORMAT_DEGREES) {
|
||||||
|
maxLength = DEGREES_MAX_LENGTH;
|
||||||
|
} else if (coordinateFormat == PointDescription.FORMAT_MINUTES) {
|
||||||
|
maxLength = MINUTES_MAX_LENGTH;
|
||||||
|
} else {
|
||||||
|
maxLength = SECONDS_MAX_LENGTH;
|
||||||
|
}
|
||||||
|
InputFilter[] filtersArray = new InputFilter[] {new InputFilter.LengthFilter(maxLength)};
|
||||||
|
for (ExtendedEditText extendedEditText : extendedLatLonEditTexts) {
|
||||||
|
extendedEditText.setFilters(filtersArray);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void changeKeyboardInBoxes(boolean useOsmandKeyboard) {
|
public void changeKeyboardInBoxes(boolean useOsmandKeyboard) {
|
||||||
for (OsmandTextFieldBoxes textFieldBox : textFieldBoxes) {
|
for (OsmandTextFieldBoxes textFieldBox : textFieldBoxes) {
|
||||||
textFieldBox.setUseOsmandKeyboard(useOsmandKeyboard);
|
textFieldBox.setUseOsmandKeyboard(useOsmandKeyboard);
|
||||||
|
@ -214,9 +284,10 @@ public class CoordinateInputDialogFragment extends DialogFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void changeKeyboardInEditTexts(boolean useOsmandKeyboard) {
|
public void changeKeyboardInEditTexts(boolean useOsmandKeyboard) {
|
||||||
for (ExtendedEditText extendedEditText : extendedEditTexts) {
|
for (ExtendedEditText extendedEditText : extendedLatLonEditTexts) {
|
||||||
extendedEditText.setInputType(useOsmandKeyboard ? InputType.TYPE_NULL : InputType.TYPE_CLASS_TEXT);
|
extendedEditText.setInputType(useOsmandKeyboard ? InputType.TYPE_NULL : InputType.TYPE_CLASS_TEXT);
|
||||||
}
|
}
|
||||||
|
nameEditText.setInputType(useOsmandKeyboard ? InputType.TYPE_NULL : InputType.TYPE_CLASS_TEXT);
|
||||||
}
|
}
|
||||||
|
|
||||||
private MapActivity getMapActivity() {
|
private MapActivity getMapActivity() {
|
||||||
|
@ -233,6 +304,7 @@ public class CoordinateInputDialogFragment extends DialogFragment {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
CoordinateInputDialogFragment fragment = new CoordinateInputDialogFragment();
|
CoordinateInputDialogFragment fragment = new CoordinateInputDialogFragment();
|
||||||
|
fragment.setRetainInstance(true);
|
||||||
fragment.show(mapActivity.getSupportFragmentManager(), TAG);
|
fragment.show(mapActivity.getSupportFragmentManager(), TAG);
|
||||||
return true;
|
return true;
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
|
|
Loading…
Reference in a new issue