Add history marker menu
This commit is contained in:
parent
c42d8b8114
commit
a30b123b89
7 changed files with 280 additions and 10 deletions
|
@ -0,0 +1,160 @@
|
|||
<?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:background="?attr/bg_color"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ScrollView
|
||||
android:id="@+id/history_marker_scroll_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="8dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/bottom_sheet_selected_item_title_height"
|
||||
android:minHeight="@dimen/bottom_sheet_selected_item_title_height"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
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/map_marker_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
|
||||
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
|
||||
tools:src="@drawable/ic_action_flag_dark"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/map_marker_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxLines="1"
|
||||
android:ellipsize="end"
|
||||
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
||||
tools:text="Bloemstraat 179"/>
|
||||
|
||||
<android.support.v7.widget.AppCompatTextView
|
||||
android:id="@+id/map_marker_passed_info"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="@dimen/default_list_text_size"
|
||||
tools:text="Passed: July 28"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="?attr/dashboard_divider"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/make_active_row"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/bottom_sheet_list_item_height"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="@dimen/bottom_sheet_list_item_height"
|
||||
android:paddingEnd="@dimen/bottom_sheet_content_padding"
|
||||
android:paddingLeft="@dimen/bottom_sheet_content_padding"
|
||||
android:paddingRight="@dimen/bottom_sheet_content_padding"
|
||||
android:paddingStart="@dimen/bottom_sheet_content_padding">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/make_active_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
|
||||
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
|
||||
tools:src="@drawable/ic_action_reset_to_default_dark"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxLines="1"
|
||||
android:text="@string/make_active"
|
||||
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/delete_row"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/bottom_sheet_list_item_height"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="@dimen/bottom_sheet_list_item_height"
|
||||
android:paddingEnd="@dimen/bottom_sheet_content_padding"
|
||||
android:paddingLeft="@dimen/bottom_sheet_content_padding"
|
||||
android:paddingRight="@dimen/bottom_sheet_content_padding"
|
||||
android:paddingStart="@dimen/bottom_sheet_content_padding">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/delete_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
|
||||
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
|
||||
tools:src="@drawable/ic_action_delete_dark"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxLines="1"
|
||||
android:text="@string/shared_string_delete"
|
||||
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="?attr/dashboard_divider"/>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/cancel_row"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/bottom_sheet_cancel_button_height"
|
||||
android:background="?attr/selectableItemBackground">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/cancel_row_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:text="@string/shared_string_close"
|
||||
android:textAllCaps="true"
|
||||
android:textColor="?attr/color_dialog_buttons"
|
||||
android:textSize="@dimen/default_desc_text_size"
|
||||
android:textStyle="bold"/>
|
||||
</FrameLayout>
|
||||
|
||||
</LinearLayout>
|
|
@ -20,8 +20,8 @@
|
|||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/measurement_tool_selected_point_title_height"
|
||||
android:minHeight="@dimen/measurement_tool_selected_point_title_height"
|
||||
android:layout_height="@dimen/bottom_sheet_selected_item_title_height"
|
||||
android:minHeight="@dimen/bottom_sheet_selected_item_title_height"
|
||||
android:paddingEnd="@dimen/bottom_sheet_content_padding"
|
||||
android:paddingLeft="@dimen/bottom_sheet_content_padding"
|
||||
android:paddingRight="@dimen/bottom_sheet_content_padding"
|
||||
|
|
|
@ -121,6 +121,6 @@
|
|||
<dimen name="measurement_tool_bottom_divider_margin_bottom">12dp</dimen>
|
||||
<dimen name="measurement_tool_bottom_divider_margin_start">96dp</dimen>
|
||||
<dimen name="bottom_sheet_image_text_margin_start">15dp</dimen>
|
||||
<dimen name="measurement_tool_selected_point_title_height">84dp</dimen>
|
||||
<dimen name="bottom_sheet_selected_item_title_height">84dp</dimen>
|
||||
|
||||
</resources>
|
|
@ -186,5 +186,5 @@
|
|||
<dimen name="measurement_tool_bottom_divider_margin_bottom">8dp</dimen>
|
||||
<dimen name="measurement_tool_bottom_divider_margin_start">64dp</dimen>
|
||||
<dimen name="bottom_sheet_image_text_margin_start">10dp</dimen>
|
||||
<dimen name="measurement_tool_selected_point_title_height">56dp</dimen>
|
||||
<dimen name="bottom_sheet_selected_item_title_height">56dp</dimen>
|
||||
</resources>
|
|
@ -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="make_active">Make active</string>
|
||||
<string name="today">Today</string>
|
||||
<string name="yesterday">Yesterday</string>
|
||||
<string name="last_seven_days">Last 7 days</string>
|
||||
|
|
|
@ -0,0 +1,112 @@
|
|||
package net.osmand.plus.mapmarkers;
|
||||
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.base.BottomSheetDialogFragment;
|
||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
|
||||
public class HistoryMarkerMenuBottomSheetDialogFragment extends BottomSheetDialogFragment {
|
||||
|
||||
public final static String TAG = "HistoryMarkerMenuBottomSheetDialogFragment";
|
||||
|
||||
private HistoryMarkerMenuFragmentListener listener;
|
||||
private boolean portrait;
|
||||
private MapMarker marker;
|
||||
|
||||
public void setListener(HistoryMarkerMenuFragmentListener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
public void setMarker(MapMarker marker) {
|
||||
this.marker = marker;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
portrait = AndroidUiHelper.isOrientationPortrait(getActivity());
|
||||
boolean nightMode = getMyApplication().getDaynightHelper().isNightModeForMapControls();
|
||||
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
||||
|
||||
final View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_marker_history_bottom_sheet_dialog, container);
|
||||
if (portrait) {
|
||||
AndroidUtils.setBackground(getActivity(), mainView, nightMode, R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);
|
||||
}
|
||||
((ImageView) mainView.findViewById(R.id.make_active_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_reset_to_default_dark));
|
||||
((ImageView) mainView.findViewById(R.id.delete_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_delete_dark));
|
||||
|
||||
mainView.findViewById(R.id.cancel_row).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
final int screenHeight = AndroidUtils.getScreenHeight(getActivity());
|
||||
final int statusBarHeight = AndroidUtils.getStatusBarHeight(getActivity());
|
||||
final int navBarHeight = AndroidUtils.getNavBarHeight(getActivity());
|
||||
|
||||
mainView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||
@Override
|
||||
public void onGlobalLayout() {
|
||||
final View scrollView = mainView.findViewById(R.id.history_marker_scroll_view);
|
||||
int scrollViewHeight = scrollView.getHeight();
|
||||
int dividerHeight = AndroidUtils.dpToPx(getContext(), 1);
|
||||
int cancelButtonHeight = getContext().getResources().getDimensionPixelSize(R.dimen.bottom_sheet_cancel_button_height);
|
||||
int spaceForScrollView = screenHeight - statusBarHeight - navBarHeight - dividerHeight - cancelButtonHeight;
|
||||
if (scrollViewHeight > spaceForScrollView) {
|
||||
scrollView.getLayoutParams().height = spaceForScrollView;
|
||||
scrollView.requestLayout();
|
||||
}
|
||||
|
||||
if (!portrait) {
|
||||
if (screenHeight - statusBarHeight - mainView.getHeight()
|
||||
>= AndroidUtils.dpToPx(getActivity(), 8)) {
|
||||
AndroidUtils.setBackground(getActivity(), mainView, false,
|
||||
R.drawable.bg_bottom_sheet_topsides_landscape_light, R.drawable.bg_bottom_sheet_topsides_landscape_dark);
|
||||
} else {
|
||||
AndroidUtils.setBackground(getActivity(), mainView, false,
|
||||
R.drawable.bg_bottom_sheet_sides_landscape_light, R.drawable.bg_bottom_sheet_sides_landscape_dark);
|
||||
}
|
||||
}
|
||||
|
||||
ViewTreeObserver obs = mainView.getViewTreeObserver();
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
||||
obs.removeOnGlobalLayoutListener(this);
|
||||
} else {
|
||||
obs.removeGlobalOnLayoutListener(this);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return mainView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
if (!portrait) {
|
||||
final Window window = getDialog().getWindow();
|
||||
WindowManager.LayoutParams params = window.getAttributes();
|
||||
params.width = getActivity().getResources().getDimensionPixelSize(R.dimen.landscape_bottom_sheet_dialog_fragment_width);
|
||||
window.setAttributes(params);
|
||||
}
|
||||
}
|
||||
|
||||
interface HistoryMarkerMenuFragmentListener {
|
||||
|
||||
}
|
||||
}
|
|
@ -44,12 +44,9 @@ public class MapMarkersHistoryFragment extends Fragment implements MapMarkersHel
|
|||
int pos = recyclerView.indexOfChild(view);
|
||||
Object item = adapter.getItem(pos);
|
||||
if (item instanceof MapMarker) {
|
||||
MapMarker marker = (MapMarker) item;
|
||||
mapActivity.getMyApplication().getSettings().setMapLocationToShow(marker.getLatitude(), marker.getLongitude(),
|
||||
15, new PointDescription(PointDescription.POINT_TYPE_LOCATION, marker.getPointDescription(mapActivity).getName()),
|
||||
false, null);
|
||||
MapActivity.launchMapActivityMoveToTop(mapActivity);
|
||||
((DialogFragment) getParentFragment()).dismiss();
|
||||
HistoryMarkerMenuBottomSheetDialogFragment fragment = new HistoryMarkerMenuBottomSheetDialogFragment();
|
||||
fragment.setMarker((MapMarker) item);
|
||||
fragment.show(mapActivity.getSupportFragmentManager(), HistoryMarkerMenuBottomSheetDialogFragment.TAG);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue