Rewrite UI in OsmEditOptionsBottomSheetDialogFragment

This commit is contained in:
Alexander Sytnyk 2018-02-28 18:42:51 +02:00
parent 0ab22fe00d
commit 670cfcf62c
2 changed files with 89 additions and 284 deletions

View file

@ -1,210 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/bg_color"
android:orientation="vertical">
<ScrollView
android:id="@+id/osm_edit_options_scroll_view"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="@dimen/bottom_sheet_content_padding_small">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/osm_edit_name"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_title_height"
android:gravity="center_vertical"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
tools:text="Universal Bank"
android:textAppearance="@style/TextAppearance.ListItemTitle"
osmand:typeface="@string/font_roboto_medium"/>
<LinearLayout
android:id="@+id/upload_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:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding">
<ImageView
android:id="@+id/upload_icon"
android:layout_width="@dimen/standard_icon_size"
android:layout_height="@dimen/standard_icon_size"
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_export"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:maxLines="1"
android:text="@string/local_openstreetmap_upload"
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
</LinearLayout>
<LinearLayout
android:id="@+id/show_on_map_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:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding">
<ImageView
android:id="@+id/show_on_map_icon"
android:layout_width="@dimen/standard_icon_size"
android:layout_height="@dimen/standard_icon_size"
android:layout_gravity="center_vertical"
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
tools:background="@drawable/ic_show_on_map"/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:ellipsize="end"
android:maxLines="1"
android:text="@string/shared_string_show_on_map"
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
</LinearLayout>
<View
android:layout_width="wrap_content"
android:layout_height="1dp"
android:layout_marginBottom="@dimen/bottom_sheet_divider_margin_bottom"
android:layout_marginLeft="@dimen/bottom_sheet_divider_margin_start"
android:layout_marginStart="@dimen/bottom_sheet_divider_margin_start"
android:layout_marginTop="@dimen/bottom_sheet_divider_margin_top"
android:background="?attr/dashboard_divider"/>
<LinearLayout
android:visibility="gone"
tools:visibility="visible"
android:id="@+id/modify_osm_change_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:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding">
<ImageView
android:id="@+id/modify_osm_change_icon"
android:layout_width="@dimen/standard_icon_size"
android:layout_height="@dimen/standard_icon_size"
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_edit_dark"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:maxLines="1"
android:text="@string/poi_context_menu_modify_osm_change"
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
</LinearLayout>
<LinearLayout
android:visibility="gone"
tools:visibility="visible"
android:id="@+id/modify_osm_note_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:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding">
<ImageView
android:id="@+id/modify_osm_note_icon"
android:layout_width="@dimen/standard_icon_size"
android:layout_height="@dimen/standard_icon_size"
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_edit_dark"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:maxLines="1"
android:text="@string/context_menu_item_modify_note"
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:minHeight="@dimen/bottom_sheet_list_item_height"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding">
<ImageView
android:id="@+id/delete_icon"
android:layout_width="@dimen/standard_icon_size"
android:layout_height="@dimen/standard_icon_size"
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_delete_dark"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
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>

View file

@ -1,19 +1,20 @@
package net.osmand.plus.osmedit;
import android.os.Bundle;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import net.osmand.plus.R;
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
import net.osmand.plus.widgets.TextViewEx;
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem;
import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerHalfItem;
import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
public class OsmEditOptionsBottomSheetDialogFragment extends MenuBottomSheetDialogFragment {
public final static String TAG = "OsmEditOptionsBottomSheetDialogFragment";
public static final String TAG = "OsmEditOptionsBottomSheetDialogFragment";
public static final String OSM_POINT = "osm_point";
@ -25,91 +26,105 @@ public class OsmEditOptionsBottomSheetDialogFragment extends MenuBottomSheetDial
@Override
public View createMenuItems(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
final View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_osm_edit_options_bottom_sheet_dialog, container);
Bundle args = getArguments();
if (args != null) {
final OsmPoint osmPoint = (OsmPoint) args.getSerializable(OSM_POINT);
((TextViewEx) mainView.findViewById(R.id.osm_edit_name)).setText(OsmEditingPlugin.getName(osmPoint) + ":");
items.add(new TitleItem(OsmEditingPlugin.getName(osmPoint) + ":"));
((ImageView) mainView.findViewById(R.id.upload_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_export));
mainView.findViewById(R.id.upload_row).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (listener != null) {
listener.onUploadClick(osmPoint);
}
dismiss();
}
});
BaseBottomSheetItem uploadItem = new SimpleBottomSheetItem.Builder()
.setIcon(getContentIcon(R.drawable.ic_action_export))
.setTitle(getString(R.string.local_openstreetmap_upload))
.setLayoutId(R.layout.bottom_sheet_item_simple)
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (listener != null) {
listener.onUploadClick(osmPoint);
}
dismiss();
}
})
.create();
items.add(uploadItem);
((ImageView) mainView.findViewById(R.id.show_on_map_icon)).setImageDrawable(getContentIcon(R.drawable.ic_show_on_map));
mainView.findViewById(R.id.show_on_map_row).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (listener != null) {
listener.onShowOnMapClick(osmPoint);
}
dismiss();
}
});
BaseBottomSheetItem showOnMapItem = new SimpleBottomSheetItem.Builder()
.setIcon(getContentIcon(R.drawable.ic_show_on_map))
.setTitle(getString(R.string.shared_string_show_on_map))
.setLayoutId(R.layout.bottom_sheet_item_simple)
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (listener != null) {
listener.onShowOnMapClick(osmPoint);
}
dismiss();
}
})
.create();
items.add(showOnMapItem);
items.add(new DividerHalfItem(getContext()));
if (osmPoint instanceof OpenstreetmapPoint && osmPoint.getAction() != OsmPoint.Action.DELETE) {
mainView.findViewById(R.id.modify_osm_change_row).setVisibility(View.VISIBLE);
((ImageView) mainView.findViewById(R.id.modify_osm_change_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_edit_dark));
mainView.findViewById(R.id.modify_osm_change_row).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (listener != null) {
listener.onModifyOsmChangeClick(osmPoint);
}
dismiss();
}
});
BaseBottomSheetItem modifyOsmChangeItem = new SimpleBottomSheetItem.Builder()
.setIcon(getContentIcon(R.drawable.ic_action_edit_dark))
.setTitle(getString(R.string.poi_context_menu_modify_osm_change))
.setLayoutId(R.layout.bottom_sheet_item_simple)
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (listener != null) {
listener.onModifyOsmChangeClick(osmPoint);
}
dismiss();
}
})
.create();
items.add(modifyOsmChangeItem);
}
if (osmPoint instanceof OsmNotesPoint) {
mainView.findViewById(R.id.modify_osm_note_row).setVisibility(View.VISIBLE);
((ImageView) mainView.findViewById(R.id.modify_osm_note_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_edit_dark));
mainView.findViewById(R.id.modify_osm_note_row).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (listener != null) {
listener.onModifyOsmNoteClick(osmPoint);
BaseBottomSheetItem modifyOsmNoteItem = new SimpleBottomSheetItem.Builder()
.setIcon(getContentIcon(R.drawable.ic_action_edit_dark))
.setTitle(getString(R.string.context_menu_item_modify_note))
.setLayoutId(R.layout.bottom_sheet_item_simple)
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (listener != null) {
listener.onModifyOsmNoteClick(osmPoint);
}
dismiss();
}
})
.create();
items.add(modifyOsmNoteItem);
}
BaseBottomSheetItem deleteItem = new SimpleBottomSheetItem.Builder()
.setIcon(getContentIcon(R.drawable.ic_action_delete_dark))
.setTitle(getString(R.string.shared_string_delete))
.setLayoutId(R.layout.bottom_sheet_item_simple)
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (listener != null) {
listener.onDeleteClick(osmPoint);
}
dismiss();
}
dismiss();
}
});
}
((ImageView) mainView.findViewById(R.id.delete_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_delete_dark));
mainView.findViewById(R.id.delete_row).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (listener != null) {
listener.onDeleteClick(osmPoint);
}
dismiss();
}
});
})
.create();
items.add(deleteItem);
}
if (nightMode) {
((TextViewEx) mainView.findViewById(R.id.osm_edit_name)).setTextColor(getResources().getColor(R.color.ctx_menu_info_text_dark));
}
return null;
}
mainView.findViewById(R.id.cancel_row).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dismiss();
}
});
setupHeightAndBackground(mainView, R.id.osm_edit_options_scroll_view);
return mainView;
@Override
protected int getCloseRowTextId() {
return R.string.shared_string_close;
}
public interface OsmEditOptionsFragmentListener {