refactor
This commit is contained in:
parent
18d6a67adb
commit
7aa3948188
4 changed files with 60 additions and 52 deletions
|
@ -41,7 +41,7 @@
|
||||||
<string name="shared_string_drawer">Drawer</string>
|
<string name="shared_string_drawer">Drawer</string>
|
||||||
<string name="ui_customization">UI Customization</string>
|
<string name="ui_customization">UI Customization</string>
|
||||||
<string name="ui_customization_short_descr">Drawer items, context menu</string>
|
<string name="ui_customization_short_descr">Drawer items, context menu</string>
|
||||||
<string name="ui_customization_description">Customize the quantity of items in Drawer, Configure map and context menu.\n\nYou can disable unused plugins, to hide all its controls from the application.</string>
|
<string name="ui_customization_description">Customize the quantity of items in Drawer, Configure map and context menu.\n\nYou can disable unused plugins, to hide all its controls from the application %1$s.</string>
|
||||||
<string name="shared_string_min">Min</string>
|
<string name="shared_string_min">Min</string>
|
||||||
<string name="shared_string_square">Square</string>
|
<string name="shared_string_square">Square</string>
|
||||||
<string name="shared_string_octagon">Octagon</string>
|
<string name="shared_string_octagon">Octagon</string>
|
||||||
|
|
|
@ -39,7 +39,7 @@ import net.osmand.plus.profiles.SelectCopyAppModeBottomSheet;
|
||||||
import net.osmand.plus.settings.ConfigureMenuRootFragment.ScreenType;
|
import net.osmand.plus.settings.ConfigureMenuRootFragment.ScreenType;
|
||||||
import net.osmand.plus.settings.bottomsheets.ChangeGeneralProfilesPrefBottomSheet;
|
import net.osmand.plus.settings.bottomsheets.ChangeGeneralProfilesPrefBottomSheet;
|
||||||
import net.osmand.plus.views.controls.ReorderItemTouchHelperCallback;
|
import net.osmand.plus.views.controls.ReorderItemTouchHelperCallback;
|
||||||
import net.osmand.plus.settings.RearrangeMenuItemsAdapter.AdapterItem;
|
import net.osmand.plus.settings.RearrangeMenuItemsAdapter.RearrangeMenuAdapterItem;
|
||||||
import net.osmand.plus.settings.RearrangeMenuItemsAdapter.MenuItemsAdapterListener;
|
import net.osmand.plus.settings.RearrangeMenuItemsAdapter.MenuItemsAdapterListener;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
@ -61,6 +61,7 @@ public class ConfigureMenuItemsFragment extends BaseOsmAndFragment
|
||||||
implements SelectCopyAppModeBottomSheet.CopyAppModePrefsListener {
|
implements SelectCopyAppModeBottomSheet.CopyAppModePrefsListener {
|
||||||
|
|
||||||
public static final String TAG = ConfigureMenuItemsFragment.class.getName();
|
public static final String TAG = ConfigureMenuItemsFragment.class.getName();
|
||||||
|
public static final int MAIN_BUTTONS_QUANTITY = 4;
|
||||||
private static final Log LOG = PlatformUtil.getLog(ConfigureMenuItemsFragment.class.getName());
|
private static final Log LOG = PlatformUtil.getLog(ConfigureMenuItemsFragment.class.getName());
|
||||||
private static final String APP_MODE_KEY = "app_mode_key";
|
private static final String APP_MODE_KEY = "app_mode_key";
|
||||||
private static final String ITEM_TYPE_KEY = "item_type_key";
|
private static final String ITEM_TYPE_KEY = "item_type_key";
|
||||||
|
@ -172,7 +173,7 @@ public class ConfigureMenuItemsFragment extends BaseOsmAndFragment
|
||||||
TextView toolbarTitle = root.findViewById(R.id.toolbar_title);
|
TextView toolbarTitle = root.findViewById(R.id.toolbar_title);
|
||||||
ImageButton toolbarButton = root.findViewById(R.id.close_button);
|
ImageButton toolbarButton = root.findViewById(R.id.close_button);
|
||||||
RecyclerView recyclerView = root.findViewById(R.id.profiles_list);
|
RecyclerView recyclerView = root.findViewById(R.id.profiles_list);
|
||||||
recyclerView.setPadding(0, 0, 0, AndroidUtils.dpToPx(app, 72));
|
recyclerView.setPadding(0, 0, 0, (int) app.getResources().getDimension(R.dimen.dialog_button_ex_min_width));
|
||||||
toolbar.setBackgroundColor(nightMode
|
toolbar.setBackgroundColor(nightMode
|
||||||
? getResources().getColor(R.color.list_background_color_dark)
|
? getResources().getColor(R.color.list_background_color_dark)
|
||||||
: getResources().getColor(R.color.list_background_color_light));
|
: getResources().getColor(R.color.list_background_color_light));
|
||||||
|
@ -213,9 +214,9 @@ public class ConfigureMenuItemsFragment extends BaseOsmAndFragment
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onButtonClicked(int position) {
|
public void onButtonClicked(int position) {
|
||||||
AdapterItem adapterItem = rearrangeAdapter.getItem(position);
|
RearrangeMenuAdapterItem rearrangeMenuAdapterItem = rearrangeAdapter.getItem(position);
|
||||||
if (adapterItem.getValue() instanceof ContextMenuItem) {
|
if (rearrangeMenuAdapterItem.getValue() instanceof ContextMenuItem) {
|
||||||
ContextMenuItem menuItemBase = (ContextMenuItem) adapterItem.getValue();
|
ContextMenuItem menuItemBase = (ContextMenuItem) rearrangeMenuAdapterItem.getValue();
|
||||||
menuItemBase.setHidden(!menuItemBase.isHidden());
|
menuItemBase.setHidden(!menuItemBase.isHidden());
|
||||||
if (menuItemBase.isHidden()) {
|
if (menuItemBase.isHidden()) {
|
||||||
hiddenMenuItems.add(menuItemBase.getId());
|
hiddenMenuItems.add(menuItemBase.getId());
|
||||||
|
@ -292,35 +293,36 @@ public class ConfigureMenuItemsFragment extends BaseOsmAndFragment
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<AdapterItem> getAdapterItems() {
|
private List<RearrangeMenuAdapterItem> getAdapterItems() {
|
||||||
List<AdapterItem> items = new ArrayList<>();
|
List<RearrangeMenuAdapterItem> items = new ArrayList<>();
|
||||||
items.add(new AdapterItem(DESCRIPTION, screenType));
|
items.add(new RearrangeMenuAdapterItem(DESCRIPTION, screenType));
|
||||||
|
|
||||||
List<AdapterItem> visible = getItemsForRearrangeAdapter(hiddenMenuItems, wasReset ? null : menuItemsOrder, false);
|
List<RearrangeMenuAdapterItem> visible = getItemsForRearrangeAdapter(hiddenMenuItems, wasReset ? null : menuItemsOrder, false);
|
||||||
List<AdapterItem> hiddenItems = getItemsForRearrangeAdapter(hiddenMenuItems, wasReset ? null : menuItemsOrder, true);
|
List<RearrangeMenuAdapterItem> hiddenItems = getItemsForRearrangeAdapter(hiddenMenuItems, wasReset ? null : menuItemsOrder, true);
|
||||||
if (screenType == ScreenType.CONTEXT_MENU_ACTIONS) {
|
if (screenType == ScreenType.CONTEXT_MENU_ACTIONS) {
|
||||||
for (int i =0; i<visible.size(); i++){
|
for (int i = 0; i < visible.size(); i++) {
|
||||||
ContextMenuItem value = (ContextMenuItem) visible.get(i).getValue();
|
ContextMenuItem value = (ContextMenuItem) visible.get(i).getValue();
|
||||||
if (value.getId() != null && value.getId().equals(MAP_CONTEXT_MENU_MORE_ID)){
|
if (value.getId() != null && value.getId().equals(MAP_CONTEXT_MENU_MORE_ID)) {
|
||||||
if (i >3){
|
int buttonMoreIndex = MAIN_BUTTONS_QUANTITY - 1;
|
||||||
AdapterItem third = visible.get(3);
|
if (i > buttonMoreIndex) {
|
||||||
visible.set(3,visible.get(i));
|
RearrangeMenuAdapterItem third = visible.get(buttonMoreIndex);
|
||||||
menuItemsOrder.put(((ContextMenuItem) third.getValue()).getId(),i);
|
visible.set(buttonMoreIndex, visible.get(i));
|
||||||
menuItemsOrder.put(((ContextMenuItem) visible.get(i).getValue()).getId(),3);
|
menuItemsOrder.put(((ContextMenuItem) third.getValue()).getId(), i);
|
||||||
|
menuItemsOrder.put(((ContextMenuItem) visible.get(i).getValue()).getId(), buttonMoreIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<AdapterItem> main = new ArrayList<>();
|
List<RearrangeMenuAdapterItem> main = new ArrayList<>();
|
||||||
int actionsIndex = Math.min(4, visible.size());
|
int actionsIndex = Math.min(MAIN_BUTTONS_QUANTITY, visible.size());
|
||||||
for (int i = 0; i < actionsIndex; i++) {
|
for (int i = 0; i < actionsIndex; i++) {
|
||||||
main.add(visible.get(i));
|
main.add(visible.get(i));
|
||||||
}
|
}
|
||||||
items.add(new AdapterItem(HEADER, new RearrangeMenuItemsAdapter.HeaderItem(R.string.main_actions, R.string.main_actions_descr)));
|
items.add(new RearrangeMenuAdapterItem(HEADER, new RearrangeMenuItemsAdapter.HeaderItem(R.string.main_actions, R.string.main_actions_descr)));
|
||||||
items.addAll(main);
|
items.addAll(main);
|
||||||
items.add(new AdapterItem(HEADER, new RearrangeMenuItemsAdapter.HeaderItem(R.string.additional_actions, R.string.additional_actions_descr)));
|
items.add(new RearrangeMenuAdapterItem(HEADER, new RearrangeMenuItemsAdapter.HeaderItem(R.string.additional_actions, R.string.additional_actions_descr)));
|
||||||
List<AdapterItem> additional = new ArrayList<>();
|
List<RearrangeMenuAdapterItem> additional = new ArrayList<>();
|
||||||
for (int i = 4; i < visible.size(); i++) {
|
for (int i = MAIN_BUTTONS_QUANTITY; i < visible.size(); i++) {
|
||||||
additional.add(visible.get(i));
|
additional.add(visible.get(i));
|
||||||
}
|
}
|
||||||
items.addAll(additional);
|
items.addAll(additional);
|
||||||
|
@ -328,11 +330,11 @@ public class ConfigureMenuItemsFragment extends BaseOsmAndFragment
|
||||||
items.addAll(visible);
|
items.addAll(visible);
|
||||||
}
|
}
|
||||||
if (!hiddenItems.isEmpty()) {
|
if (!hiddenItems.isEmpty()) {
|
||||||
items.add(new AdapterItem(HEADER, new RearrangeMenuItemsAdapter.HeaderItem(R.string.shared_string_hidden, R.string.hidden_items_descr)));
|
items.add(new RearrangeMenuAdapterItem(HEADER, new RearrangeMenuItemsAdapter.HeaderItem(R.string.shared_string_hidden, R.string.hidden_items_descr)));
|
||||||
items.addAll(hiddenItems);
|
items.addAll(hiddenItems);
|
||||||
}
|
}
|
||||||
items.add(new AdapterItem(DIVIDER, 1));
|
items.add(new RearrangeMenuAdapterItem(DIVIDER, 1));
|
||||||
items.add(new AdapterItem(BUTTON, new RearrangeMenuItemsAdapter.ButtonItem(
|
items.add(new RearrangeMenuAdapterItem(BUTTON, new RearrangeMenuItemsAdapter.ButtonItem(
|
||||||
R.string.reset_to_default,
|
R.string.reset_to_default,
|
||||||
R.drawable.ic_action_reset_to_default_dark,
|
R.drawable.ic_action_reset_to_default_dark,
|
||||||
new View.OnClickListener() {
|
new View.OnClickListener() {
|
||||||
|
@ -347,7 +349,7 @@ public class ConfigureMenuItemsFragment extends BaseOsmAndFragment
|
||||||
rearrangeAdapter.updateItems(getAdapterItems());
|
rearrangeAdapter.updateItems(getAdapterItems());
|
||||||
}
|
}
|
||||||
})));
|
})));
|
||||||
items.add(new AdapterItem(BUTTON, new RearrangeMenuItemsAdapter.ButtonItem(
|
items.add(new RearrangeMenuAdapterItem(BUTTON, new RearrangeMenuItemsAdapter.ButtonItem(
|
||||||
R.string.copy_from_other_profile,
|
R.string.copy_from_other_profile,
|
||||||
R.drawable.ic_action_copy,
|
R.drawable.ic_action_copy,
|
||||||
new View.OnClickListener() {
|
new View.OnClickListener() {
|
||||||
|
@ -411,7 +413,7 @@ public class ConfigureMenuItemsFragment extends BaseOsmAndFragment
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static OsmandSettings.ContextMenuItemsPreference getSettingForScreen(OsmandApplication app, ScreenType screenType) {
|
public static OsmandSettings.ContextMenuItemsPreference getSettingForScreen(OsmandApplication app, ScreenType screenType) throws IllegalArgumentException {
|
||||||
switch (screenType) {
|
switch (screenType) {
|
||||||
case DRAWER:
|
case DRAWER:
|
||||||
return app.getSettings().DRAWER_ITEMS;
|
return app.getSettings().DRAWER_ITEMS;
|
||||||
|
@ -430,23 +432,23 @@ public class ConfigureMenuItemsFragment extends BaseOsmAndFragment
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<AdapterItem> getItemsForRearrangeAdapter(@Nullable List<String> hiddenItemsIds, @Nullable HashMap<String, Integer> itemsOrderIds, boolean hidden) {
|
public List<RearrangeMenuAdapterItem> getItemsForRearrangeAdapter(@Nullable List<String> hiddenItemsIds, @Nullable HashMap<String, Integer> itemsOrderIds, boolean hidden) {
|
||||||
List<ContextMenuItem> defItems = contextMenuAdapter.getDefaultItems();
|
List<ContextMenuItem> defItems = contextMenuAdapter.getDefaultItems();
|
||||||
if (itemsOrderIds == null || itemsOrderIds.isEmpty()) {
|
if (itemsOrderIds == null || itemsOrderIds.isEmpty()) {
|
||||||
initDefaultOrders(defItems);
|
initDefaultOrders(defItems);
|
||||||
} else {
|
} else {
|
||||||
sortByCustomOrder(defItems, itemsOrderIds);
|
sortByCustomOrder(defItems, itemsOrderIds);
|
||||||
}
|
}
|
||||||
List<AdapterItem> visibleItems = new ArrayList<>();
|
List<RearrangeMenuAdapterItem> visibleItems = new ArrayList<>();
|
||||||
List<AdapterItem> hiddenItems = new ArrayList<>();
|
List<RearrangeMenuAdapterItem> hiddenItems = new ArrayList<>();
|
||||||
for (ContextMenuItem item : defItems) {
|
for (ContextMenuItem item : defItems) {
|
||||||
String id = item.getId();
|
String id = item.getId();
|
||||||
if (hiddenItemsIds != null && hiddenItemsIds.contains(id)) {
|
if (hiddenItemsIds != null && hiddenItemsIds.contains(id)) {
|
||||||
item.setHidden(true);
|
item.setHidden(true);
|
||||||
hiddenItems.add(new AdapterItem(MENU_ITEM, item));
|
hiddenItems.add(new RearrangeMenuAdapterItem(MENU_ITEM, item));
|
||||||
} else {
|
} else {
|
||||||
item.setHidden(false);
|
item.setHidden(false);
|
||||||
visibleItems.add(new AdapterItem(MENU_ITEM, item));
|
visibleItems.add(new RearrangeMenuAdapterItem(MENU_ITEM, item));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return hidden ? hiddenItems : visibleItems;
|
return hidden ? hiddenItems : visibleItems;
|
||||||
|
|
|
@ -117,7 +117,9 @@ public class ConfigureMenuRootFragment extends BaseOsmAndFragment {
|
||||||
toolbarSubTitle.setText(appMode.toHumanString());
|
toolbarSubTitle.setText(appMode.toHumanString());
|
||||||
toolbarSubTitle.setVisibility(View.VISIBLE);
|
toolbarSubTitle.setVisibility(View.VISIBLE);
|
||||||
List<Object> items = new ArrayList<>();
|
List<Object> items = new ArrayList<>();
|
||||||
items.add(getString(R.string.ui_customization_description));
|
String plugins = getString(R.string.prefs_plugins);
|
||||||
|
String description = String.format(getString(R.string.ui_customization_description), plugins);
|
||||||
|
items.add(description);
|
||||||
items.addAll(Arrays.asList(ScreenType.values()));
|
items.addAll(Arrays.asList(ScreenType.values()));
|
||||||
CustomizationItemsAdapter adapter = new CustomizationItemsAdapter(items, new OnCustomizationItemClickListener() {
|
CustomizationItemsAdapter adapter = new CustomizationItemsAdapter(items, new OnCustomizationItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -199,10 +201,9 @@ public class ConfigureMenuRootFragment extends BaseOsmAndFragment {
|
||||||
final Object currentItem = items.get(position);
|
final Object currentItem = items.get(position);
|
||||||
if (holder instanceof DescriptionHolder) {
|
if (holder instanceof DescriptionHolder) {
|
||||||
DescriptionHolder descriptionHolder = (DescriptionHolder) holder;
|
DescriptionHolder descriptionHolder = (DescriptionHolder) holder;
|
||||||
String plugins = getString(R.string.prefs_plugins) + '.';
|
String plugins = getString(R.string.prefs_plugins);
|
||||||
String description = String.format(getString(R.string.ltr_or_rtl_combine_via_space), (String) currentItem, plugins);
|
|
||||||
setupClickableText(
|
setupClickableText(
|
||||||
descriptionHolder.description, description, plugins, new Intent(app, PluginsActivity.class));
|
descriptionHolder.description, (String) currentItem, plugins, new Intent(app, PluginsActivity.class));
|
||||||
descriptionHolder.image.setVisibility(View.GONE);
|
descriptionHolder.image.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
final ScreenType item = (ScreenType) currentItem;
|
final ScreenType item = (ScreenType) currentItem;
|
||||||
|
|
|
@ -2,6 +2,7 @@ package net.osmand.plus.settings;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.util.TypedValue;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -37,6 +38,7 @@ import static net.osmand.aidlapi.OsmAndCustomizationConstants.MAP_RENDERING_CATE
|
||||||
import static net.osmand.aidlapi.OsmAndCustomizationConstants.RENDERING_ITEMS_ID_SCHEME;
|
import static net.osmand.aidlapi.OsmAndCustomizationConstants.RENDERING_ITEMS_ID_SCHEME;
|
||||||
import static net.osmand.aidlapi.OsmAndCustomizationConstants.SHOW_CATEGORY_ID;
|
import static net.osmand.aidlapi.OsmAndCustomizationConstants.SHOW_CATEGORY_ID;
|
||||||
import static net.osmand.aidlapi.OsmAndCustomizationConstants.SHOW_ITEMS_ID_SCHEME;
|
import static net.osmand.aidlapi.OsmAndCustomizationConstants.SHOW_ITEMS_ID_SCHEME;
|
||||||
|
import static net.osmand.plus.settings.ConfigureMenuItemsFragment.MAIN_BUTTONS_QUANTITY;
|
||||||
|
|
||||||
public class RearrangeMenuItemsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
public class RearrangeMenuItemsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||||
implements ReorderItemTouchHelperCallback.OnItemMoveCallback {
|
implements ReorderItemTouchHelperCallback.OnItemMoveCallback {
|
||||||
|
@ -44,14 +46,14 @@ public class RearrangeMenuItemsAdapter extends RecyclerView.Adapter<RecyclerView
|
||||||
private OsmandApplication app;
|
private OsmandApplication app;
|
||||||
private UiUtilities uiUtilities;
|
private UiUtilities uiUtilities;
|
||||||
private boolean nightMode;
|
private boolean nightMode;
|
||||||
private List<AdapterItem> items;
|
private List<RearrangeMenuAdapterItem> items;
|
||||||
private MenuItemsAdapterListener listener;
|
private MenuItemsAdapterListener listener;
|
||||||
private int activeColorRes;
|
private int activeColorRes;
|
||||||
private int textColorRes;
|
private int textColorRes;
|
||||||
|
|
||||||
|
|
||||||
public RearrangeMenuItemsAdapter(OsmandApplication app,
|
public RearrangeMenuItemsAdapter(OsmandApplication app,
|
||||||
List<AdapterItem> items) {
|
List<RearrangeMenuAdapterItem> items) {
|
||||||
this.app = app;
|
this.app = app;
|
||||||
this.items = items;
|
this.items = items;
|
||||||
uiUtilities = app.getUIUtilities();
|
uiUtilities = app.getUIUtilities();
|
||||||
|
@ -66,7 +68,7 @@ public class RearrangeMenuItemsAdapter extends RecyclerView.Adapter<RecyclerView
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getItemViewType(int position) {
|
public int getItemViewType(int position) {
|
||||||
AdapterItem item = items.get(position);
|
RearrangeMenuAdapterItem item = items.get(position);
|
||||||
return item.type.ordinal();
|
return item.type.ordinal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,12 +102,12 @@ public class RearrangeMenuItemsAdapter extends RecyclerView.Adapter<RecyclerView
|
||||||
@SuppressLint("ClickableViewAccessibility")
|
@SuppressLint("ClickableViewAccessibility")
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder holder, int position) {
|
||||||
AdapterItem item = items.get(position);
|
RearrangeMenuAdapterItem item = items.get(position);
|
||||||
if (holder instanceof DescriptionHolder) {
|
if (holder instanceof DescriptionHolder) {
|
||||||
DescriptionHolder h = (DescriptionHolder) holder;
|
DescriptionHolder h = (DescriptionHolder) holder;
|
||||||
ScreenType screenType = (ScreenType) item.value;
|
ScreenType screenType = (ScreenType) item.value;
|
||||||
int paddingStart = AndroidUtils.dpToPx(app, 56);
|
int paddingStart = (int) app.getResources().getDimension(R.dimen.toolbar_height);
|
||||||
int paddingTop = AndroidUtils.dpToPx(app, 16);
|
int paddingTop = (int) app.getResources().getDimension(R.dimen.content_padding);
|
||||||
h.description.setText(String.format(app.getString(R.string.reorder_or_hide_from), app.getString(screenType.titleRes)));
|
h.description.setText(String.format(app.getString(R.string.reorder_or_hide_from), app.getString(screenType.titleRes)));
|
||||||
h.image.setImageResource(nightMode ? screenType.imageNightRes : screenType.imageDayRes);
|
h.image.setImageResource(nightMode ? screenType.imageNightRes : screenType.imageDayRes);
|
||||||
if (screenType == ScreenType.CONTEXT_MENU_ACTIONS) {
|
if (screenType == ScreenType.CONTEXT_MENU_ACTIONS) {
|
||||||
|
@ -127,7 +129,7 @@ public class RearrangeMenuItemsAdapter extends RecyclerView.Adapter<RecyclerView
|
||||||
h.title.setText(R.string.shared_string_divider);
|
h.title.setText(R.string.shared_string_divider);
|
||||||
h.title.setTypeface(FontCache.getFont(app, app.getString(R.string.font_roboto_medium)));
|
h.title.setTypeface(FontCache.getFont(app, app.getString(R.string.font_roboto_medium)));
|
||||||
h.title.setTextColor(app.getResources().getColor(activeColorRes));
|
h.title.setTextColor(app.getResources().getColor(activeColorRes));
|
||||||
h.title.setTextSize(15);
|
h.title.setTextSize(TypedValue.COMPLEX_UNIT_PX, app.getResources().getDimension(R.dimen.default_list_text_size));
|
||||||
h.description.setText(R.string.divider_descr);
|
h.description.setText(R.string.divider_descr);
|
||||||
h.icon.setVisibility(View.GONE);
|
h.icon.setVisibility(View.GONE);
|
||||||
h.actionIcon.setVisibility(View.GONE);
|
h.actionIcon.setVisibility(View.GONE);
|
||||||
|
@ -137,7 +139,7 @@ public class RearrangeMenuItemsAdapter extends RecyclerView.Adapter<RecyclerView
|
||||||
|| MAP_RENDERING_CATEGORY_ID.equals(id)) {
|
|| MAP_RENDERING_CATEGORY_ID.equals(id)) {
|
||||||
h.title.setText(menuItem.getTitle());
|
h.title.setText(menuItem.getTitle());
|
||||||
h.title.setTypeface(FontCache.getFont(app, app.getString(R.string.font_roboto_medium)));
|
h.title.setTypeface(FontCache.getFont(app, app.getString(R.string.font_roboto_medium)));
|
||||||
h.title.setTextSize(15);
|
h.title.setTextSize(TypedValue.COMPLEX_UNIT_PX, app.getResources().getDimension(R.dimen.default_list_text_size));
|
||||||
h.description.setText(R.string.move_inside_category);
|
h.description.setText(R.string.move_inside_category);
|
||||||
h.icon.setVisibility(View.GONE);
|
h.icon.setVisibility(View.GONE);
|
||||||
h.actionIcon.setVisibility(View.GONE);
|
h.actionIcon.setVisibility(View.GONE);
|
||||||
|
@ -193,6 +195,8 @@ public class RearrangeMenuItemsAdapter extends RecyclerView.Adapter<RecyclerView
|
||||||
} else if (holder instanceof HeaderHolder) {
|
} else if (holder instanceof HeaderHolder) {
|
||||||
HeaderHolder h = (HeaderHolder) holder;
|
HeaderHolder h = (HeaderHolder) holder;
|
||||||
HeaderItem header = (HeaderItem) item.value;
|
HeaderItem header = (HeaderItem) item.value;
|
||||||
|
h.title.setTypeface(FontCache.getFont(app, app.getString(R.string.font_roboto_medium)));
|
||||||
|
h.title.setTextSize(TypedValue.COMPLEX_UNIT_PX, app.getResources().getDimension(R.dimen.default_list_text_size));
|
||||||
h.title.setText(header.titleRes);
|
h.title.setText(header.titleRes);
|
||||||
h.description.setText(header.descrRes);
|
h.description.setText(header.descrRes);
|
||||||
h.moveIcon.setVisibility(View.GONE);
|
h.moveIcon.setVisibility(View.GONE);
|
||||||
|
@ -230,12 +234,13 @@ public class RearrangeMenuItemsAdapter extends RecyclerView.Adapter<RecyclerView
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int buttonMoreIndex = MAIN_BUTTONS_QUANTITY + 1;
|
||||||
if (menuItemFrom.getId().equals(MAP_CONTEXT_MENU_MORE_ID)) {
|
if (menuItemFrom.getId().equals(MAP_CONTEXT_MENU_MORE_ID)) {
|
||||||
if (to > 5) {
|
if (to > buttonMoreIndex) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (menuItemTo.getId().equals(MAP_CONTEXT_MENU_MORE_ID)) {
|
} else if (menuItemTo.getId().equals(MAP_CONTEXT_MENU_MORE_ID)) {
|
||||||
if (from > 5) {
|
if (from > buttonMoreIndex) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -359,11 +364,11 @@ public class RearrangeMenuItemsAdapter extends RecyclerView.Adapter<RecyclerView
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class AdapterItem {
|
public static class RearrangeMenuAdapterItem {
|
||||||
private AdapterItemType type;
|
private AdapterItemType type;
|
||||||
private Object value;
|
private Object value;
|
||||||
|
|
||||||
public AdapterItem(AdapterItemType type, Object value) {
|
public RearrangeMenuAdapterItem(AdapterItemType type, Object value) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
@ -427,11 +432,11 @@ public class RearrangeMenuItemsAdapter extends RecyclerView.Adapter<RecyclerView
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AdapterItem getItem(int position) {
|
public RearrangeMenuAdapterItem getItem(int position) {
|
||||||
return items.get(position);
|
return items.get(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateItems(List<AdapterItem> items) {
|
public void updateItems(List<RearrangeMenuAdapterItem> items) {
|
||||||
this.items = items;
|
this.items = items;
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue