From ebeb0710fc2e25f4a30ec969e2649610c5bf322d Mon Sep 17 00:00:00 2001 From: alex Date: Thu, 1 Mar 2018 11:33:20 +0200 Subject: [PATCH] Rewrite UI in SortByMenuBottomSheetDialogFragment --- ...ragment_notes_sort_bottom_sheet_dialog.xml | 111 ------------------ .../SortByMenuBottomSheetDialogFragment.java | 59 +++++----- 2 files changed, 29 insertions(+), 141 deletions(-) delete mode 100644 OsmAnd/res/layout/fragment_notes_sort_bottom_sheet_dialog.xml diff --git a/OsmAnd/res/layout/fragment_notes_sort_bottom_sheet_dialog.xml b/OsmAnd/res/layout/fragment_notes_sort_bottom_sheet_dialog.xml deleted file mode 100644 index a307700dd6..0000000000 --- a/OsmAnd/res/layout/fragment_notes_sort_bottom_sheet_dialog.xml +++ /dev/null @@ -1,111 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/OsmAnd/src/net/osmand/plus/audionotes/SortByMenuBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/audionotes/SortByMenuBottomSheetDialogFragment.java index a8e240f26b..8f946975ea 100644 --- a/OsmAnd/src/net/osmand/plus/audionotes/SortByMenuBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/audionotes/SortByMenuBottomSheetDialogFragment.java @@ -1,17 +1,17 @@ package net.osmand.plus.audionotes; import android.os.Bundle; -import android.view.ContextThemeWrapper; import android.view.LayoutInflater; import android.view.View; -import android.view.View.OnClickListener; import android.view.ViewGroup; -import android.widget.ImageView; import net.osmand.plus.OsmandSettings; import net.osmand.plus.OsmandSettings.NotesSortByMode; import net.osmand.plus.R; import net.osmand.plus.base.MenuBottomSheetDialogFragment; +import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem; +import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem; +import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem; public class SortByMenuBottomSheetDialogFragment extends MenuBottomSheetDialogFragment { @@ -25,36 +25,35 @@ public class SortByMenuBottomSheetDialogFragment extends MenuBottomSheetDialogFr @Override public View createMenuItems(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme; + items.add(new TitleItem(getString(R.string.shared_string_sort))); - final View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), - R.layout.fragment_notes_sort_bottom_sheet_dialog, null); + BaseBottomSheetItem byTypeItem = new SimpleBottomSheetItem.Builder() + .setIcon(getContentIcon(R.drawable.ic_groped_by_type)) + .setTitle(getString(R.string.by_type)) + .setLayoutId(R.layout.bottom_sheet_item_simple) + .setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + selectSortByMode(NotesSortByMode.BY_TYPE); + } + }) + .create(); + items.add(byTypeItem); - ((ImageView) mainView.findViewById(R.id.by_type_icon)).setImageDrawable(getContentIcon(R.drawable.ic_groped_by_type)); - ((ImageView) mainView.findViewById(R.id.by_date_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_sort_by_date)); + BaseBottomSheetItem byDateItem = new SimpleBottomSheetItem.Builder() + .setIcon(getContentIcon(R.drawable.ic_action_sort_by_date)) + .setTitle(getString(R.string.by_date)) + .setLayoutId(R.layout.bottom_sheet_item_simple) + .setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + selectSortByMode(NotesSortByMode.BY_DATE); + } + }) + .create(); + items.add(byDateItem); - mainView.findViewById(R.id.by_type_row).setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - selectSortByMode(NotesSortByMode.BY_TYPE); - } - }); - mainView.findViewById(R.id.by_date_row).setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - selectSortByMode(NotesSortByMode.BY_DATE); - } - }); - mainView.findViewById(R.id.close_row).setOnClickListener(new OnClickListener() { - @Override - public void onClick(View view) { - dismiss(); - } - }); - - setupHeightAndBackground(mainView, R.id.scroll_view); - - return mainView; + return null; } private void selectSortByMode(NotesSortByMode mode) {