formatting
This commit is contained in:
parent
038088feb8
commit
d4ebb6b836
2 changed files with 58 additions and 58 deletions
|
@ -567,16 +567,16 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
|
|||
// Action buttons
|
||||
// TODO refactor section
|
||||
ContextMenuAdapter adapter = menu.getActionsContextMenuAdapter(false);
|
||||
List<ContextMenuItem> items = new ArrayList<>();
|
||||
for (ContextMenuItem item : adapter.getItems()) {
|
||||
if (!item.isHidden()) {
|
||||
items.add(item);
|
||||
}
|
||||
}
|
||||
List<ContextMenuItem> items = new ArrayList<>();
|
||||
for (ContextMenuItem item : adapter.getItems()) {
|
||||
if (!item.isHidden()) {
|
||||
items.add(item);
|
||||
}
|
||||
}
|
||||
ContextMenuAdapter mainAdapter = new ContextMenuAdapter(requireMyApplication());
|
||||
ContextMenuAdapter additionalAdapter = new ContextMenuAdapter(requireMyApplication());
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
if (i < MAIN_BUTTONS_QUANTITY) {
|
||||
if (i < MAIN_BUTTONS_QUANTITY) {
|
||||
mainAdapter.addItem(items.get(i));
|
||||
} else {
|
||||
additionalAdapter.addItem(items.get(i));
|
||||
|
@ -591,8 +591,8 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
|
|||
ContextMenuItemClickListener mainListener = menu.getContextMenuItemClickListener(mainAdapter);
|
||||
ContextMenuItemClickListener additionalListener = menu.getContextMenuItemClickListener(additionalAdapter);
|
||||
|
||||
int mainButtonsQuantity = Math.min(MAIN_BUTTONS_QUANTITY, items.size());
|
||||
for (int i = 0; i < mainButtonsQuantity; i++) {
|
||||
int mainButtonsQuantity = Math.min(MAIN_BUTTONS_QUANTITY, items.size());
|
||||
for (int i = 0; i < mainButtonsQuantity; i++) {
|
||||
buttons.addView(getActionView(items.get(i), i, mainAdapter, additionalAdapter, mainListener, additionalListener), params);
|
||||
}
|
||||
buttons.setGravity(Gravity.CENTER);
|
||||
|
@ -655,11 +655,11 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
|
|||
}
|
||||
|
||||
private View getActionView(ContextMenuItem contextMenuItem,
|
||||
final int position,
|
||||
final ContextMenuAdapter mainAdapter,
|
||||
final ContextMenuAdapter additionalAdapter,
|
||||
final ContextMenuItemClickListener mainListener,
|
||||
final ContextMenuItemClickListener additionalListener) {
|
||||
final int position,
|
||||
final ContextMenuAdapter mainAdapter,
|
||||
final ContextMenuAdapter additionalAdapter,
|
||||
final ContextMenuItemClickListener mainListener,
|
||||
final ContextMenuItemClickListener additionalListener) {
|
||||
UiUtilities uiUtilities = requireMyApplication().getUIUtilities();
|
||||
LayoutInflater inflater = UiUtilities.getInflater(getMyApplication(), nightMode);
|
||||
View view = inflater.inflate(R.layout.context_menu_action_item, null);
|
||||
|
|
|
@ -89,7 +89,7 @@ public class ConfigureMenuItemsFragment extends BaseOsmAndFragment
|
|||
outState.putSerializable(ITEMS_ORDER_KEY, menuItemsOrder);
|
||||
outState.putSerializable(ITEM_TYPE_KEY, screenType);
|
||||
outState.putString(APP_MODE_KEY, appMode.getStringKey());
|
||||
outState.putBoolean(IS_CHANGED_KEY, isChanged);
|
||||
outState.putBoolean(IS_CHANGED_KEY, isChanged);
|
||||
}
|
||||
|
||||
public static ConfigureMenuItemsFragment showInstance(
|
||||
|
@ -129,12 +129,12 @@ public class ConfigureMenuItemsFragment extends BaseOsmAndFragment
|
|||
app = requireMyApplication();
|
||||
nightMode = !app.getSettings().isLightContent();
|
||||
mInflater = UiUtilities.getInflater(app, nightMode);
|
||||
if (savedInstanceState != null) {
|
||||
if (savedInstanceState != null) {
|
||||
appMode = ApplicationMode.valueOfStringKey(savedInstanceState.getString(APP_MODE_KEY), null);
|
||||
screenType = (ScreenType) savedInstanceState.getSerializable(ITEM_TYPE_KEY);
|
||||
hiddenMenuItems = savedInstanceState.getStringArrayList(HIDDEN_ITEMS_KEY);
|
||||
menuItemsOrder = (HashMap<String, Integer>) savedInstanceState.getSerializable(ITEMS_ORDER_KEY);
|
||||
isChanged = savedInstanceState.getBoolean(IS_CHANGED_KEY);
|
||||
menuItemsOrder = (HashMap<String, Integer>) savedInstanceState.getSerializable(ITEMS_ORDER_KEY);
|
||||
isChanged = savedInstanceState.getBoolean(IS_CHANGED_KEY);
|
||||
} else {
|
||||
hiddenMenuItems = new ArrayList<>(getSettingForScreen(app, screenType).getModeValue(appMode).getHiddenIds());
|
||||
menuItemsOrder = new HashMap<>();
|
||||
|
@ -142,15 +142,15 @@ public class ConfigureMenuItemsFragment extends BaseOsmAndFragment
|
|||
for (int i = 0; i < orderIds.size(); i++) {
|
||||
menuItemsOrder.put(orderIds.get(i), i);
|
||||
}
|
||||
}
|
||||
instantiateContextMenuAdapter();
|
||||
if (menuItemsOrder.isEmpty()) {
|
||||
List<ContextMenuItem> defItems = contextMenuAdapter.getDefaultItems();
|
||||
initDefaultOrders(defItems);
|
||||
for (int i = 0; i < defItems.size(); i++) {
|
||||
menuItemsOrder.put(defItems.get(i).getId(), i);
|
||||
}
|
||||
}
|
||||
}
|
||||
instantiateContextMenuAdapter();
|
||||
if (menuItemsOrder.isEmpty()) {
|
||||
List<ContextMenuItem> defItems = contextMenuAdapter.getDefaultItems();
|
||||
initDefaultOrders(defItems);
|
||||
for (int i = 0; i < defItems.size(); i++) {
|
||||
menuItemsOrder.put(defItems.get(i).getId(), i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void instantiateContextMenuAdapter() {
|
||||
|
@ -177,26 +177,26 @@ public class ConfigureMenuItemsFragment extends BaseOsmAndFragment
|
|||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable final ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
View root = mInflater.inflate(R.layout.edit_arrangement_list_fragment, container, false);
|
||||
AppBarLayout appbar = root.findViewById(R.id.appbar);
|
||||
View toolbar = mInflater.inflate(R.layout.global_preference_toolbar, container, false);
|
||||
TextView toolbarTitle = toolbar.findViewById(R.id.toolbar_title);
|
||||
ImageButton toolbarButton = toolbar.findViewById(R.id.close_button);
|
||||
toolbar.setBackgroundColor(nightMode
|
||||
? getResources().getColor(R.color.list_background_color_dark)
|
||||
: getResources().getColor(R.color.list_background_color_light));
|
||||
toolbarTitle.setTextColor(nightMode
|
||||
? getResources().getColor(R.color.text_color_primary_dark)
|
||||
: getResources().getColor(R.color.list_background_color_dark));
|
||||
toolbarButton.setImageDrawable(getPaintedContentIcon(R.drawable.ic_arrow_back, getResources().getColor(R.color.text_color_secondary_light)));
|
||||
toolbarTitle.setText(screenType.titleRes);
|
||||
toolbarButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
exitFragment();
|
||||
}
|
||||
});
|
||||
appbar.addView(toolbar);
|
||||
RecyclerView recyclerView = root.findViewById(R.id.profiles_list);
|
||||
AppBarLayout appbar = root.findViewById(R.id.appbar);
|
||||
View toolbar = mInflater.inflate(R.layout.global_preference_toolbar, container, false);
|
||||
TextView toolbarTitle = toolbar.findViewById(R.id.toolbar_title);
|
||||
ImageButton toolbarButton = toolbar.findViewById(R.id.close_button);
|
||||
toolbar.setBackgroundColor(nightMode
|
||||
? getResources().getColor(R.color.list_background_color_dark)
|
||||
: getResources().getColor(R.color.list_background_color_light));
|
||||
toolbarTitle.setTextColor(nightMode
|
||||
? getResources().getColor(R.color.text_color_primary_dark)
|
||||
: getResources().getColor(R.color.list_background_color_dark));
|
||||
toolbarButton.setImageDrawable(getPaintedContentIcon(R.drawable.ic_arrow_back, getResources().getColor(R.color.text_color_secondary_light)));
|
||||
toolbarTitle.setText(screenType.titleRes);
|
||||
toolbarButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
exitFragment();
|
||||
}
|
||||
});
|
||||
appbar.addView(toolbar);
|
||||
RecyclerView recyclerView = root.findViewById(R.id.profiles_list);
|
||||
recyclerView.setPadding(0, 0, 0, (int) app.getResources().getDimension(R.dimen.dialog_button_ex_min_width));
|
||||
rearrangeAdapter = new RearrangeMenuItemsAdapter(app, getAdapterItems());
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(app));
|
||||
|
@ -308,18 +308,18 @@ public class ConfigureMenuItemsFragment extends BaseOsmAndFragment
|
|||
List<RearrangeMenuAdapterItem> visible = getItemsForRearrangeAdapter(hiddenMenuItems, wasReset ? null : menuItemsOrder, false);
|
||||
List<RearrangeMenuAdapterItem> hiddenItems = getItemsForRearrangeAdapter(hiddenMenuItems, wasReset ? null : menuItemsOrder, true);
|
||||
if (screenType == ScreenType.CONTEXT_MENU_ACTIONS) {
|
||||
int buttonMoreIndex = MAIN_BUTTONS_QUANTITY - 1;
|
||||
int buttonMoreIndex = MAIN_BUTTONS_QUANTITY - 1;
|
||||
for (int i = 0; i < visible.size(); i++) {
|
||||
ContextMenuItem value = (ContextMenuItem) visible.get(i).getValue();
|
||||
if (value.getId() != null && value.getId().equals(MAP_CONTEXT_MENU_MORE_ID) && i > buttonMoreIndex) {
|
||||
RearrangeMenuAdapterItem third = visible.get(buttonMoreIndex);
|
||||
visible.set(buttonMoreIndex, visible.get(i));
|
||||
visible.set(i, third);
|
||||
value.setOrder(buttonMoreIndex);
|
||||
((ContextMenuItem) third.getValue()).setOrder(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
ContextMenuItem value = (ContextMenuItem) visible.get(i).getValue();
|
||||
if (value.getId() != null && value.getId().equals(MAP_CONTEXT_MENU_MORE_ID) && i > buttonMoreIndex) {
|
||||
RearrangeMenuAdapterItem third = visible.get(buttonMoreIndex);
|
||||
visible.set(buttonMoreIndex, visible.get(i));
|
||||
visible.set(i, third);
|
||||
value.setOrder(buttonMoreIndex);
|
||||
((ContextMenuItem) third.getValue()).setOrder(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
List<RearrangeMenuAdapterItem> main = new ArrayList<>();
|
||||
int actionsIndex = Math.min(MAIN_BUTTONS_QUANTITY, visible.size());
|
||||
|
|
Loading…
Reference in a new issue