Rewrite UI in ItemMenuBottomSheetDialogFragment
This commit is contained in:
parent
abbe3284d2
commit
b127d8c992
2 changed files with 95 additions and 300 deletions
|
@ -1,220 +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:layout_gravity="bottom"
|
||||
android:background="?attr/bg_color"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ScrollView
|
||||
android:id="@+id/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/title_text_view"
|
||||
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"
|
||||
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
tools:text="Paris Hotel"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/play_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:paddingLeft="@dimen/content_padding"
|
||||
android:paddingRight="@dimen/content_padding">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/play_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_play_dark"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/play_text_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxLines="1"
|
||||
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
||||
tools:text="Play"/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/share_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:paddingLeft="@dimen/content_padding"
|
||||
android:paddingRight="@dimen/content_padding">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/share_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_gshare_dark"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxLines="1"
|
||||
android:text="@string/shared_string_share"
|
||||
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/show_on_map_row"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
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="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_show_on_map"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:text="@string/shared_string_show_on_map"
|
||||
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/show_on_map_descr_text_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="@dimen/default_desc_text_size"
|
||||
tools:text="52.23423, 14.34578"/>
|
||||
</LinearLayout>
|
||||
|
||||
</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:id="@+id/rename_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:paddingLeft="@dimen/content_padding"
|
||||
android:paddingRight="@dimen/content_padding">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/rename_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_edit_dark"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxLines="1"
|
||||
android:text="@string/shared_string_rename"
|
||||
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:paddingLeft="@dimen/content_padding"
|
||||
android:paddingRight="@dimen/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/close_row"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/bottom_sheet_cancel_button_height"
|
||||
android:background="?attr/selectableItemBackground">
|
||||
|
||||
<TextView
|
||||
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>
|
|
@ -1,19 +1,18 @@
|
|||
package net.osmand.plus.audionotes;
|
||||
|
||||
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 android.widget.TextView;
|
||||
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.audionotes.AudioVideoNotesPlugin.Recording;
|
||||
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.NumberFormat;
|
||||
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
|
||||
import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription;
|
||||
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 ItemMenuBottomSheetDialogFragment extends MenuBottomSheetDialogFragment {
|
||||
|
@ -33,83 +32,94 @@ public class ItemMenuBottomSheetDialogFragment extends MenuBottomSheetDialogFrag
|
|||
|
||||
@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_notes_item_menu_bottom_sheet_dialog, null);
|
||||
|
||||
if (recording != null) {
|
||||
NumberFormat f = new DecimalFormat("#0.00000");
|
||||
((TextView) mainView.findViewById(R.id.title_text_view))
|
||||
.setText(recording.getName(getActivity(), true));
|
||||
((TextView) mainView.findViewById(R.id.play_text_view))
|
||||
.setText(recording.isPhoto() ? R.string.watch : R.string.recording_context_menu_play);
|
||||
((TextView) mainView.findViewById(R.id.show_on_map_descr_text_view))
|
||||
.setText(f.format(recording.getLatitude()) + ", " + f.format(recording.getLongitude()));
|
||||
((ImageView) mainView.findViewById(R.id.play_icon))
|
||||
.setImageDrawable(getContentIcon(recording.isPhoto() ? R.drawable.ic_action_view : R.drawable.ic_play_dark));
|
||||
items.add(new TitleItem(recording.getName(getContext(), true)));
|
||||
|
||||
BaseBottomSheetItem playItem = new SimpleBottomSheetItem.Builder()
|
||||
.setIcon(getContentIcon(recording.isPhoto() ? R.drawable.ic_action_view : R.drawable.ic_play_dark))
|
||||
.setTitle(getString(recording.isPhoto() ? R.string.watch : R.string.recording_context_menu_play))
|
||||
.setLayoutId(R.layout.bottom_sheet_item_simple)
|
||||
.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (listener != null) {
|
||||
listener.playOnClick(recording);
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
})
|
||||
.create();
|
||||
items.add(playItem);
|
||||
|
||||
BaseBottomSheetItem shareItem = new SimpleBottomSheetItem.Builder()
|
||||
.setIcon(getContentIcon(R.drawable.ic_action_gshare_dark))
|
||||
.setTitle(getString(R.string.shared_string_share))
|
||||
.setLayoutId(R.layout.bottom_sheet_item_simple)
|
||||
.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (listener != null) {
|
||||
listener.shareOnClick(recording);
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
})
|
||||
.create();
|
||||
items.add(shareItem);
|
||||
|
||||
BaseBottomSheetItem showOnMapItem = new BottomSheetItemWithDescription.Builder()
|
||||
.setDescription(getString(R.string.route_descr_lat_lon, recording.getLatitude(), recording.getLongitude()))
|
||||
.setIcon(getContentIcon(R.drawable.ic_show_on_map))
|
||||
.setTitle(getString(R.string.shared_string_show_on_map))
|
||||
.setLayoutId(R.layout.bottom_sheet_item_with_descr_56dp)
|
||||
.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (listener != null) {
|
||||
listener.showOnMapOnClick(recording);
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
})
|
||||
.create();
|
||||
items.add(showOnMapItem);
|
||||
|
||||
items.add(new DividerHalfItem(getContext()));
|
||||
|
||||
BaseBottomSheetItem renameItem = new SimpleBottomSheetItem.Builder()
|
||||
.setIcon(getContentIcon(R.drawable.ic_action_edit_dark))
|
||||
.setTitle(getString(R.string.shared_string_rename))
|
||||
.setLayoutId(R.layout.bottom_sheet_item_simple)
|
||||
.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (listener != null) {
|
||||
listener.renameOnClick(recording);
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
})
|
||||
.create();
|
||||
items.add(renameItem);
|
||||
|
||||
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.deleteOnClick(recording);
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
})
|
||||
.create();
|
||||
items.add(deleteItem);
|
||||
}
|
||||
|
||||
((ImageView) mainView.findViewById(R.id.share_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_gshare_dark));
|
||||
((ImageView) mainView.findViewById(R.id.show_on_map_icon)).setImageDrawable(getContentIcon(R.drawable.ic_show_on_map));
|
||||
((ImageView) mainView.findViewById(R.id.rename_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_edit_dark));
|
||||
((ImageView) mainView.findViewById(R.id.delete_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_delete_dark));
|
||||
|
||||
mainView.findViewById(R.id.play_row).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (listener != null && recording != null) {
|
||||
listener.playOnClick(recording);
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
mainView.findViewById(R.id.share_row).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (listener != null && recording != null) {
|
||||
listener.shareOnClick(recording);
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
mainView.findViewById(R.id.show_on_map_row).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (listener != null && recording != null) {
|
||||
listener.showOnMapOnClick(recording);
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
mainView.findViewById(R.id.rename_row).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (listener != null && recording != null) {
|
||||
listener.renameOnClick(recording);
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
mainView.findViewById(R.id.delete_row).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (listener != null && recording != null) {
|
||||
listener.deleteOnClick(recording);
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
mainView.findViewById(R.id.close_row).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
setupHeightAndBackground(mainView, R.id.scroll_view);
|
||||
|
||||
return mainView;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -120,6 +130,11 @@ public class ItemMenuBottomSheetDialogFragment extends MenuBottomSheetDialogFrag
|
|||
super.onDestroyView();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getCloseRowTextId() {
|
||||
return R.string.shared_string_close;
|
||||
}
|
||||
|
||||
interface ItemMenuFragmentListener {
|
||||
|
||||
void playOnClick(Recording recording);
|
||||
|
|
Loading…
Reference in a new issue