formatting

This commit is contained in:
veliymolfar 2020-04-17 16:34:51 +03:00
parent 038088feb8
commit d4ebb6b836
2 changed files with 58 additions and 58 deletions

View file

@ -567,16 +567,16 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
// Action buttons // Action buttons
// TODO refactor section // TODO refactor section
ContextMenuAdapter adapter = menu.getActionsContextMenuAdapter(false); ContextMenuAdapter adapter = menu.getActionsContextMenuAdapter(false);
List<ContextMenuItem> items = new ArrayList<>(); List<ContextMenuItem> items = new ArrayList<>();
for (ContextMenuItem item : adapter.getItems()) { for (ContextMenuItem item : adapter.getItems()) {
if (!item.isHidden()) { if (!item.isHidden()) {
items.add(item); items.add(item);
} }
} }
ContextMenuAdapter mainAdapter = new ContextMenuAdapter(requireMyApplication()); ContextMenuAdapter mainAdapter = new ContextMenuAdapter(requireMyApplication());
ContextMenuAdapter additionalAdapter = new ContextMenuAdapter(requireMyApplication()); ContextMenuAdapter additionalAdapter = new ContextMenuAdapter(requireMyApplication());
for (int i = 0; i < items.size(); i++) { for (int i = 0; i < items.size(); i++) {
if (i < MAIN_BUTTONS_QUANTITY) { if (i < MAIN_BUTTONS_QUANTITY) {
mainAdapter.addItem(items.get(i)); mainAdapter.addItem(items.get(i));
} else { } else {
additionalAdapter.addItem(items.get(i)); additionalAdapter.addItem(items.get(i));
@ -591,8 +591,8 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
ContextMenuItemClickListener mainListener = menu.getContextMenuItemClickListener(mainAdapter); ContextMenuItemClickListener mainListener = menu.getContextMenuItemClickListener(mainAdapter);
ContextMenuItemClickListener additionalListener = menu.getContextMenuItemClickListener(additionalAdapter); ContextMenuItemClickListener additionalListener = menu.getContextMenuItemClickListener(additionalAdapter);
int mainButtonsQuantity = Math.min(MAIN_BUTTONS_QUANTITY, items.size()); int mainButtonsQuantity = Math.min(MAIN_BUTTONS_QUANTITY, items.size());
for (int i = 0; i < mainButtonsQuantity; i++) { for (int i = 0; i < mainButtonsQuantity; i++) {
buttons.addView(getActionView(items.get(i), i, mainAdapter, additionalAdapter, mainListener, additionalListener), params); buttons.addView(getActionView(items.get(i), i, mainAdapter, additionalAdapter, mainListener, additionalListener), params);
} }
buttons.setGravity(Gravity.CENTER); buttons.setGravity(Gravity.CENTER);
@ -655,11 +655,11 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
} }
private View getActionView(ContextMenuItem contextMenuItem, private View getActionView(ContextMenuItem contextMenuItem,
final int position, final int position,
final ContextMenuAdapter mainAdapter, final ContextMenuAdapter mainAdapter,
final ContextMenuAdapter additionalAdapter, final ContextMenuAdapter additionalAdapter,
final ContextMenuItemClickListener mainListener, final ContextMenuItemClickListener mainListener,
final ContextMenuItemClickListener additionalListener) { final ContextMenuItemClickListener additionalListener) {
UiUtilities uiUtilities = requireMyApplication().getUIUtilities(); UiUtilities uiUtilities = requireMyApplication().getUIUtilities();
LayoutInflater inflater = UiUtilities.getInflater(getMyApplication(), nightMode); LayoutInflater inflater = UiUtilities.getInflater(getMyApplication(), nightMode);
View view = inflater.inflate(R.layout.context_menu_action_item, null); View view = inflater.inflate(R.layout.context_menu_action_item, null);

View file

@ -89,7 +89,7 @@ public class ConfigureMenuItemsFragment extends BaseOsmAndFragment
outState.putSerializable(ITEMS_ORDER_KEY, menuItemsOrder); outState.putSerializable(ITEMS_ORDER_KEY, menuItemsOrder);
outState.putSerializable(ITEM_TYPE_KEY, screenType); outState.putSerializable(ITEM_TYPE_KEY, screenType);
outState.putString(APP_MODE_KEY, appMode.getStringKey()); outState.putString(APP_MODE_KEY, appMode.getStringKey());
outState.putBoolean(IS_CHANGED_KEY, isChanged); outState.putBoolean(IS_CHANGED_KEY, isChanged);
} }
public static ConfigureMenuItemsFragment showInstance( public static ConfigureMenuItemsFragment showInstance(
@ -129,12 +129,12 @@ public class ConfigureMenuItemsFragment extends BaseOsmAndFragment
app = requireMyApplication(); app = requireMyApplication();
nightMode = !app.getSettings().isLightContent(); nightMode = !app.getSettings().isLightContent();
mInflater = UiUtilities.getInflater(app, nightMode); mInflater = UiUtilities.getInflater(app, nightMode);
if (savedInstanceState != null) { if (savedInstanceState != null) {
appMode = ApplicationMode.valueOfStringKey(savedInstanceState.getString(APP_MODE_KEY), null); appMode = ApplicationMode.valueOfStringKey(savedInstanceState.getString(APP_MODE_KEY), null);
screenType = (ScreenType) savedInstanceState.getSerializable(ITEM_TYPE_KEY); screenType = (ScreenType) savedInstanceState.getSerializable(ITEM_TYPE_KEY);
hiddenMenuItems = savedInstanceState.getStringArrayList(HIDDEN_ITEMS_KEY); hiddenMenuItems = savedInstanceState.getStringArrayList(HIDDEN_ITEMS_KEY);
menuItemsOrder = (HashMap<String, Integer>) savedInstanceState.getSerializable(ITEMS_ORDER_KEY); menuItemsOrder = (HashMap<String, Integer>) savedInstanceState.getSerializable(ITEMS_ORDER_KEY);
isChanged = savedInstanceState.getBoolean(IS_CHANGED_KEY); isChanged = savedInstanceState.getBoolean(IS_CHANGED_KEY);
} else { } else {
hiddenMenuItems = new ArrayList<>(getSettingForScreen(app, screenType).getModeValue(appMode).getHiddenIds()); hiddenMenuItems = new ArrayList<>(getSettingForScreen(app, screenType).getModeValue(appMode).getHiddenIds());
menuItemsOrder = new HashMap<>(); menuItemsOrder = new HashMap<>();
@ -142,15 +142,15 @@ public class ConfigureMenuItemsFragment extends BaseOsmAndFragment
for (int i = 0; i < orderIds.size(); i++) { for (int i = 0; i < orderIds.size(); i++) {
menuItemsOrder.put(orderIds.get(i), i); menuItemsOrder.put(orderIds.get(i), i);
} }
} }
instantiateContextMenuAdapter(); instantiateContextMenuAdapter();
if (menuItemsOrder.isEmpty()) { if (menuItemsOrder.isEmpty()) {
List<ContextMenuItem> defItems = contextMenuAdapter.getDefaultItems(); List<ContextMenuItem> defItems = contextMenuAdapter.getDefaultItems();
initDefaultOrders(defItems); initDefaultOrders(defItems);
for (int i = 0; i < defItems.size(); i++) { for (int i = 0; i < defItems.size(); i++) {
menuItemsOrder.put(defItems.get(i).getId(), i); menuItemsOrder.put(defItems.get(i).getId(), i);
} }
} }
} }
private void instantiateContextMenuAdapter() { private void instantiateContextMenuAdapter() {
@ -177,26 +177,26 @@ public class ConfigureMenuItemsFragment extends BaseOsmAndFragment
@Override @Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable final ViewGroup container, @Nullable Bundle savedInstanceState) { 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); View root = mInflater.inflate(R.layout.edit_arrangement_list_fragment, container, false);
AppBarLayout appbar = root.findViewById(R.id.appbar); AppBarLayout appbar = root.findViewById(R.id.appbar);
View toolbar = mInflater.inflate(R.layout.global_preference_toolbar, container, false); View toolbar = mInflater.inflate(R.layout.global_preference_toolbar, container, false);
TextView toolbarTitle = toolbar.findViewById(R.id.toolbar_title); TextView toolbarTitle = toolbar.findViewById(R.id.toolbar_title);
ImageButton toolbarButton = toolbar.findViewById(R.id.close_button); ImageButton toolbarButton = toolbar.findViewById(R.id.close_button);
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));
toolbarTitle.setTextColor(nightMode toolbarTitle.setTextColor(nightMode
? getResources().getColor(R.color.text_color_primary_dark) ? getResources().getColor(R.color.text_color_primary_dark)
: getResources().getColor(R.color.list_background_color_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))); toolbarButton.setImageDrawable(getPaintedContentIcon(R.drawable.ic_arrow_back, getResources().getColor(R.color.text_color_secondary_light)));
toolbarTitle.setText(screenType.titleRes); toolbarTitle.setText(screenType.titleRes);
toolbarButton.setOnClickListener(new View.OnClickListener() { toolbarButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
exitFragment(); exitFragment();
} }
}); });
appbar.addView(toolbar); appbar.addView(toolbar);
RecyclerView recyclerView = root.findViewById(R.id.profiles_list); RecyclerView recyclerView = root.findViewById(R.id.profiles_list);
recyclerView.setPadding(0, 0, 0, (int) app.getResources().getDimension(R.dimen.dialog_button_ex_min_width)); recyclerView.setPadding(0, 0, 0, (int) app.getResources().getDimension(R.dimen.dialog_button_ex_min_width));
rearrangeAdapter = new RearrangeMenuItemsAdapter(app, getAdapterItems()); rearrangeAdapter = new RearrangeMenuItemsAdapter(app, getAdapterItems());
recyclerView.setLayoutManager(new LinearLayoutManager(app)); 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> visible = getItemsForRearrangeAdapter(hiddenMenuItems, wasReset ? null : menuItemsOrder, false);
List<RearrangeMenuAdapterItem> 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) {
int buttonMoreIndex = MAIN_BUTTONS_QUANTITY - 1; int buttonMoreIndex = MAIN_BUTTONS_QUANTITY - 1;
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) && i > buttonMoreIndex) { if (value.getId() != null && value.getId().equals(MAP_CONTEXT_MENU_MORE_ID) && i > buttonMoreIndex) {
RearrangeMenuAdapterItem third = visible.get(buttonMoreIndex); RearrangeMenuAdapterItem third = visible.get(buttonMoreIndex);
visible.set(buttonMoreIndex, visible.get(i)); visible.set(buttonMoreIndex, visible.get(i));
visible.set(i, third); visible.set(i, third);
value.setOrder(buttonMoreIndex); value.setOrder(buttonMoreIndex);
((ContextMenuItem) third.getValue()).setOrder(i); ((ContextMenuItem) third.getValue()).setOrder(i);
break; break;
} }
} }
List<RearrangeMenuAdapterItem> main = new ArrayList<>(); List<RearrangeMenuAdapterItem> main = new ArrayList<>();
int actionsIndex = Math.min(MAIN_BUTTONS_QUANTITY, visible.size()); int actionsIndex = Math.min(MAIN_BUTTONS_QUANTITY, visible.size());