Add coordinate input screen

This commit is contained in:
PavelRatushny 2017-09-25 19:20:47 +03:00
parent ef2f9cf76c
commit 83fd9df764
8 changed files with 280 additions and 5 deletions

View file

@ -0,0 +1,101 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:osmand="http://schemas.android.com/tools">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="@dimen/dashboard_map_toolbar">
<android.support.v7.widget.Toolbar
android:id="@+id/coordinate_input_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:contentInsetLeft="54dp"
app:contentInsetStart="54dp">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical">
<net.osmand.plus.widgets.TextViewEx
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:ellipsize="end"
android:maxLines="1"
android:gravity="center_vertical"
android:text="@string/coordinates"
android:textColor="@color/color_white"
osmand:typeface="@string/font_roboto_medium"
android:textSize="@dimen/dialog_header_text_size"/>
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/options_button"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:ellipsize="end"
android:maxLines="1"
android:paddingRight="16dp"
android:paddingLeft="16dp"
android:text="@string/shared_string_options"
osmand:typeface="@string/font_roboto_regular"
android:textAllCaps="true"
android:textSize="@dimen/default_list_text_size"
android:textColor="@color/color_white"
android:background="?attr/selectableItemBackground"/>
</LinearLayout>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
</FrameLayout>
<FrameLayout
android:layout_marginTop="@dimen/dashboard_map_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/ctx_menu_info_view_bg">
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="5dp"
android:layout_gravity="bottom"
android:alpha="0.5"
android:scaleType="fitXY"
android:src="@drawable/bg_shadow_onmap"/>
</FrameLayout>
<FrameLayout
android:layout_gravity="bottom"
android:layout_width="match_parent"
android:layout_height="200dp">
<GridView
android:id="@+id/keyboard_grid_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/dashboard_divider"
android:horizontalSpacing="1dp"
android:stretchMode="spacingWidth"
android:verticalSpacing="1dp"
android:numColumns="3"/>
</FrameLayout>
</FrameLayout>

View file

@ -5,8 +5,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:osmand="http://schemas.android.com/tools"
android:orientation="vertical"
xmlns:tools="http://schemas.android.com/tools">
android:orientation="vertical">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"

View file

@ -110,6 +110,35 @@
android:layout_marginTop="@dimen/measurement_tool_bottom_divider_margin_top"
android:background="?attr/dashboard_divider"/>
<LinearLayout
android:id="@+id/coordinate_input_row"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_list_item_height"
android:background="?attr/selectableItemBackground"
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/coordinate_input_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
tools:src="@drawable/ic_action_coordinates_longitude"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:maxLines="1"
android:text="@string/coordinate_input"
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
</LinearLayout>
<LinearLayout
android:id="@+id/build_route_row"
android:layout_width="match_parent"

View file

@ -0,0 +1,16 @@
<?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="56dp"
android:background="?attr/bg_color"
android:orientation="vertical">
<TextView
android:id="@+id/keyboard_item"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
tools:text="3"/>
</LinearLayout>

View file

@ -9,6 +9,7 @@
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="coordinate_input">Coordinate input</string>
<string name="is_saved">is saved</string>
<string name="marker_save_as_track_descr">OsmAnd will save all your markers to a separate file, you can enter filename:</string>
<string name="marker_save_as_track">Save as track</string>

View file

@ -0,0 +1,114 @@
package net.osmand.plus.mapmarkers;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.DialogFragment;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.GridView;
import android.widget.TextView;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
public class CoordinateInputDialogFragment extends DialogFragment {
public static final String TAG = "CoordinateInputDialogFragment";
private boolean lightTheme;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
OsmandApplication app = getMyApplication();
lightTheme = app.getSettings().OSMAND_THEME.get() == OsmandSettings.OSMAND_LIGHT_THEME;
int themeId = lightTheme ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme;
setStyle(STYLE_NO_FRAME, themeId);
}
@Nullable
@Override
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();
Toolbar toolbar = (Toolbar) mainView.findViewById(R.id.coordinate_input_toolbar);
if (!lightTheme) {
toolbar.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.actionbar_dark_color));
}
toolbar.setNavigationIcon(getMyApplication().getIconsCache().getIcon(R.drawable.ic_arrow_back));
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dismiss();
}
});
final View optionsButton = mainView.findViewById(R.id.options_button);
optionsButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
}
});
String[] keyboardItems = new String[] { "1", "2", "3",
"4", "5", "6",
"7", "8", "9",
getString(R.string.shared_string_delete), "0", getString(R.string.shared_string_clear) };
GridView keyboardGrid = (GridView) mainView.findViewById(R.id.keyboard_grid_view);
KeyboardAdapter keyboardAdapter = new KeyboardAdapter(mapActivity, keyboardItems);
keyboardGrid.setAdapter(keyboardAdapter);
return mainView;
}
private MapActivity getMapActivity() {
return (MapActivity) getActivity();
}
private OsmandApplication getMyApplication() {
return (OsmandApplication) getActivity().getApplication();
}
public static boolean showInstance(@NonNull MapActivity mapActivity) {
try {
if (mapActivity.isActivityDestroyed()) {
return false;
}
CoordinateInputDialogFragment fragment = new CoordinateInputDialogFragment();
fragment.show(mapActivity.getSupportFragmentManager(), TAG);
return true;
} catch (RuntimeException e) {
return false;
}
}
private class KeyboardAdapter extends ArrayAdapter<String> {
KeyboardAdapter(@NonNull Context context, String[] items) {
super(context, 0, items);
}
@NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
if (convertView == null) {
convertView = LayoutInflater.from(getContext()).inflate(R.layout.input_coordinate_keyboard_item, parent, false);
}
((TextView) convertView.findViewById(R.id.keyboard_item)).setText(getItem(position));
return convertView;
}
}
}

View file

@ -17,8 +17,6 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import net.osmand.IndexConstants;
import net.osmand.plus.GPXUtilities.GPXFile;
import net.osmand.plus.LockableViewPager;
import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.OsmandApplication;
@ -33,7 +31,6 @@ import net.osmand.plus.mapmarkers.OrderByBottomSheetDialogFragment.OrderByFragme
import net.osmand.plus.mapmarkers.SaveAsTrackBottomSheetDialogFragment.MarkerSaveAsTrackFragmentListener;
import net.osmand.plus.mapmarkers.ShowDirectionBottomSheetDialogFragment.ShowDirectionFragmentListener;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@ -203,6 +200,11 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
fragment.show(mapActivity.getSupportFragmentManager(), ShowDirectionBottomSheetDialogFragment.TAG);
}
@Override
public void coordinateInputOnClick() {
CoordinateInputDialogFragment.showInstance(mapActivity);
}
@Override
public void buildRouteOnClick() {
mapActivity.getDashboard().setDashboardVisibility(true, DashboardOnMap.DashboardType.MAP_MARKERS_SELECTION);

View file

@ -64,6 +64,8 @@ public class OptionsBottomSheetDialogFragment extends BottomSheetDialogFragment
if (imageResId != 0) {
showDirectionIcon.setImageDrawable(getIcon(imageResId, R.color.dashboard_blue));
}
((ImageView) mainView.findViewById(R.id.coordinate_input_icon))
.setImageDrawable(getContentIcon(R.drawable.ic_action_coordinates_longitude));
((ImageView) mainView.findViewById(R.id.build_route_icon))
.setImageDrawable(getContentIcon(R.drawable.map_directions));
((ImageView) mainView.findViewById(R.id.save_as_new_track_icon))
@ -92,6 +94,15 @@ public class OptionsBottomSheetDialogFragment extends BottomSheetDialogFragment
dismiss();
}
});
mainView.findViewById(R.id.coordinate_input_row).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (listener != null) {
listener.coordinateInputOnClick();
}
dismiss();
}
});
mainView.findViewById(R.id.build_route_row).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
@ -188,6 +199,8 @@ public class OptionsBottomSheetDialogFragment extends BottomSheetDialogFragment
void showDirectionOnClick();
void coordinateInputOnClick();
void buildRouteOnClick();
void saveAsNewTrackOnClick();