Merge pull request #5171 from osmandapp/PopupWindowsFix
added check for popup windows
This commit is contained in:
commit
2368d951d7
2 changed files with 66 additions and 36 deletions
|
@ -104,6 +104,8 @@ public class TrackPointFragment extends OsmandExpandableListFragment {
|
||||||
private View lineTextLayout;
|
private View lineTextLayout;
|
||||||
private View overlayView;
|
private View overlayView;
|
||||||
private View mainView;
|
private View mainView;
|
||||||
|
private PopupMenu popupItemMenu;
|
||||||
|
private Menu optionsMenu;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
|
@ -111,6 +113,17 @@ public class TrackPointFragment extends OsmandExpandableListFragment {
|
||||||
this.app = getMyApplication();
|
this.app = getMyApplication();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
if (popupItemMenu != null) {
|
||||||
|
popupItemMenu.dismiss();
|
||||||
|
}
|
||||||
|
if (optionsMenu != null) {
|
||||||
|
optionsMenu.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onActivityCreated(Bundle savedInstanceState) {
|
public void onActivityCreated(Bundle savedInstanceState) {
|
||||||
super.onActivityCreated(savedInstanceState);
|
super.onActivityCreated(savedInstanceState);
|
||||||
|
@ -445,6 +458,7 @@ public class TrackPointFragment extends OsmandExpandableListFragment {
|
||||||
createMenuItem(menu, DELETE_ID, R.string.shared_string_delete, R.drawable.ic_action_delete_dark,
|
createMenuItem(menu, DELETE_ID, R.string.shared_string_delete, R.drawable.ic_action_delete_dark,
|
||||||
R.drawable.ic_action_delete_dark, MenuItemCompat.SHOW_AS_ACTION_NEVER);
|
R.drawable.ic_action_delete_dark, MenuItemCompat.SHOW_AS_ACTION_NEVER);
|
||||||
}
|
}
|
||||||
|
this.optionsMenu = menu;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showProgressBar() {
|
public void showProgressBar() {
|
||||||
|
@ -919,10 +933,10 @@ public class TrackPointFragment extends OsmandExpandableListFragment {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
IconsCache iconsCache = getMyApplication().getIconsCache();
|
IconsCache iconsCache = getMyApplication().getIconsCache();
|
||||||
final PopupMenu optionsMenu = new PopupMenu(getActivity(), v);
|
popupItemMenu = new PopupMenu(getActivity(), v);
|
||||||
DirectionsDialogs.setupPopUpMenuIcon(optionsMenu);
|
DirectionsDialogs.setupPopUpMenuIcon(popupItemMenu);
|
||||||
|
|
||||||
MenuItem menuItem = optionsMenu.getMenu().add(R.string.shared_string_edit).setIcon(iconsCache.getThemedIcon(R.drawable.ic_action_edit_dark));
|
MenuItem menuItem = popupItemMenu.getMenu().add(R.string.shared_string_edit).setIcon(iconsCache.getThemedIcon(R.drawable.ic_action_edit_dark));
|
||||||
menuItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
menuItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onMenuItemClick(MenuItem mItem) {
|
public boolean onMenuItemClick(MenuItem mItem) {
|
||||||
|
@ -942,7 +956,7 @@ public class TrackPointFragment extends OsmandExpandableListFragment {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
optionsMenu.show();
|
popupItemMenu.show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
int groupColor = gpxItem.group.getColor();
|
int groupColor = gpxItem.group.getColor();
|
||||||
|
|
|
@ -155,6 +155,10 @@ public class TrackSegmentFragment extends OsmAndListFragment {
|
||||||
private FloatingActionButton lineFab;
|
private FloatingActionButton lineFab;
|
||||||
private View lineTextLayout;
|
private View lineTextLayout;
|
||||||
private View overlayView;
|
private View overlayView;
|
||||||
|
private IconPopupMenu generalPopupMenu;
|
||||||
|
private IconPopupMenu altitudePopupMenu;
|
||||||
|
private ListPopupWindow splitListPopupWindow;
|
||||||
|
private ListPopupWindow colorListPopupWindow;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
|
@ -407,6 +411,18 @@ public class TrackSegmentFragment extends OsmAndListFragment {
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
updateEnable = false;
|
updateEnable = false;
|
||||||
|
if (generalPopupMenu != null) {
|
||||||
|
generalPopupMenu.dismiss();
|
||||||
|
}
|
||||||
|
if (splitListPopupWindow != null) {
|
||||||
|
splitListPopupWindow.dismiss();
|
||||||
|
}
|
||||||
|
if (colorListPopupWindow != null) {
|
||||||
|
colorListPopupWindow.dismiss();
|
||||||
|
}
|
||||||
|
if (altitudePopupMenu != null) {
|
||||||
|
altitudePopupMenu.dismiss();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateHeader() {
|
private void updateHeader() {
|
||||||
|
@ -472,17 +488,17 @@ public class TrackSegmentFragment extends OsmAndListFragment {
|
||||||
colorView.setOnClickListener(new View.OnClickListener() {
|
colorView.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
final ListPopupWindow popup = new ListPopupWindow(getActivity());
|
colorListPopupWindow = new ListPopupWindow(getActivity());
|
||||||
popup.setAnchorView(colorView);
|
colorListPopupWindow.setAnchorView(colorView);
|
||||||
popup.setContentWidth(AndroidUtils.dpToPx(app, 200f));
|
colorListPopupWindow.setContentWidth(AndroidUtils.dpToPx(app, 200f));
|
||||||
popup.setModal(true);
|
colorListPopupWindow.setModal(true);
|
||||||
popup.setDropDownGravity(Gravity.RIGHT | Gravity.TOP);
|
colorListPopupWindow.setDropDownGravity(Gravity.RIGHT | Gravity.TOP);
|
||||||
popup.setVerticalOffset(AndroidUtils.dpToPx(app, -48f));
|
colorListPopupWindow.setVerticalOffset(AndroidUtils.dpToPx(app, -48f));
|
||||||
popup.setHorizontalOffset(AndroidUtils.dpToPx(app, -6f));
|
colorListPopupWindow.setHorizontalOffset(AndroidUtils.dpToPx(app, -6f));
|
||||||
final GpxAppearanceAdapter gpxApprAdapter = new GpxAppearanceAdapter(getActivity(),
|
final GpxAppearanceAdapter gpxApprAdapter = new GpxAppearanceAdapter(getActivity(),
|
||||||
getGpx().getColor(0), GpxAppearanceAdapterType.TRACK_COLOR);
|
getGpx().getColor(0), GpxAppearanceAdapterType.TRACK_COLOR);
|
||||||
popup.setAdapter(gpxApprAdapter);
|
colorListPopupWindow.setAdapter(gpxApprAdapter);
|
||||||
popup.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
colorListPopupWindow.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||||
|
@ -507,11 +523,11 @@ public class TrackSegmentFragment extends OsmAndListFragment {
|
||||||
refreshTrackBitmap();
|
refreshTrackBitmap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
popup.dismiss();
|
colorListPopupWindow.dismiss();
|
||||||
updateColorView(colorView);
|
updateColorView(colorView);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
popup.show();
|
colorListPopupWindow.show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -579,16 +595,16 @@ public class TrackSegmentFragment extends OsmAndListFragment {
|
||||||
splitIntervalView.setOnClickListener(new View.OnClickListener() {
|
splitIntervalView.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
final ListPopupWindow popup = new ListPopupWindow(getActivity());
|
splitListPopupWindow = new ListPopupWindow(getActivity());
|
||||||
popup.setAnchorView(splitIntervalView);
|
splitListPopupWindow.setAnchorView(splitIntervalView);
|
||||||
popup.setContentWidth(AndroidUtils.dpToPx(app, 200f));
|
splitListPopupWindow.setContentWidth(AndroidUtils.dpToPx(app, 200f));
|
||||||
popup.setModal(true);
|
splitListPopupWindow.setModal(true);
|
||||||
popup.setDropDownGravity(Gravity.RIGHT | Gravity.TOP);
|
splitListPopupWindow.setDropDownGravity(Gravity.RIGHT | Gravity.TOP);
|
||||||
popup.setVerticalOffset(AndroidUtils.dpToPx(app, -48f));
|
splitListPopupWindow.setVerticalOffset(AndroidUtils.dpToPx(app, -48f));
|
||||||
popup.setHorizontalOffset(AndroidUtils.dpToPx(app, -6f));
|
splitListPopupWindow.setHorizontalOffset(AndroidUtils.dpToPx(app, -6f));
|
||||||
popup.setAdapter(new ArrayAdapter<>(getTrackActivity(),
|
splitListPopupWindow.setAdapter(new ArrayAdapter<>(getTrackActivity(),
|
||||||
R.layout.popup_list_text_item, options));
|
R.layout.popup_list_text_item, options));
|
||||||
popup.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
splitListPopupWindow.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||||
|
@ -601,11 +617,11 @@ public class TrackSegmentFragment extends OsmAndListFragment {
|
||||||
updateSplitInDatabase();
|
updateSplitInDatabase();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
popup.dismiss();
|
splitListPopupWindow.dismiss();
|
||||||
updateSplitIntervalView(splitIntervalView);
|
updateSplitIntervalView(splitIntervalView);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
popup.show();
|
splitListPopupWindow.show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
splitIntervalView.setVisibility(View.VISIBLE);
|
splitIntervalView.setVisibility(View.VISIBLE);
|
||||||
|
@ -1353,12 +1369,12 @@ public class TrackSegmentFragment extends OsmAndListFragment {
|
||||||
view.findViewById(R.id.overflow_menu).setOnClickListener(new View.OnClickListener() {
|
view.findViewById(R.id.overflow_menu).setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
IconPopupMenu popupMenu = new IconPopupMenu(getTrackActivity(), view.findViewById(R.id.overflow_menu));
|
generalPopupMenu = new IconPopupMenu(getTrackActivity(), view.findViewById(R.id.overflow_menu));
|
||||||
Menu menu = popupMenu.getMenu();
|
Menu menu = generalPopupMenu.getMenu();
|
||||||
popupMenu.getMenuInflater().inflate(R.menu.track_segment_menu, menu);
|
generalPopupMenu.getMenuInflater().inflate(R.menu.track_segment_menu, menu);
|
||||||
menu.findItem(R.id.action_edit).setIcon(ic.getThemedIcon(R.drawable.ic_action_edit_dark));
|
menu.findItem(R.id.action_edit).setIcon(ic.getThemedIcon(R.drawable.ic_action_edit_dark));
|
||||||
menu.findItem(R.id.action_delete).setIcon(ic.getThemedIcon(R.drawable.ic_action_remove_dark));
|
menu.findItem(R.id.action_delete).setIcon(ic.getThemedIcon(R.drawable.ic_action_remove_dark));
|
||||||
popupMenu.setOnMenuItemClickListener(new IconPopupMenu.OnMenuItemClickListener() {
|
generalPopupMenu.setOnMenuItemClickListener(new IconPopupMenu.OnMenuItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onMenuItemClick(MenuItem item) {
|
public boolean onMenuItemClick(MenuItem item) {
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
|
@ -1390,7 +1406,7 @@ public class TrackSegmentFragment extends OsmAndListFragment {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
popupMenu.show();
|
generalPopupMenu.show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -1456,12 +1472,12 @@ public class TrackSegmentFragment extends OsmAndListFragment {
|
||||||
view.findViewById(R.id.overflow_menu).setOnClickListener(new View.OnClickListener() {
|
view.findViewById(R.id.overflow_menu).setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
IconPopupMenu popupMenu = new IconPopupMenu(getTrackActivity(), view.findViewById(R.id.overflow_menu));
|
altitudePopupMenu = new IconPopupMenu(getTrackActivity(), view.findViewById(R.id.overflow_menu));
|
||||||
Menu menu = popupMenu.getMenu();
|
Menu menu = altitudePopupMenu.getMenu();
|
||||||
popupMenu.getMenuInflater().inflate(R.menu.track_segment_menu, menu);
|
altitudePopupMenu.getMenuInflater().inflate(R.menu.track_segment_menu, menu);
|
||||||
menu.findItem(R.id.action_edit).setIcon(ic.getThemedIcon(R.drawable.ic_action_edit_dark));
|
menu.findItem(R.id.action_edit).setIcon(ic.getThemedIcon(R.drawable.ic_action_edit_dark));
|
||||||
menu.findItem(R.id.action_delete).setIcon(ic.getThemedIcon(R.drawable.ic_action_remove_dark));
|
menu.findItem(R.id.action_delete).setIcon(ic.getThemedIcon(R.drawable.ic_action_remove_dark));
|
||||||
popupMenu.setOnMenuItemClickListener(new IconPopupMenu.OnMenuItemClickListener() {
|
altitudePopupMenu.setOnMenuItemClickListener(new IconPopupMenu.OnMenuItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onMenuItemClick(MenuItem item) {
|
public boolean onMenuItemClick(MenuItem item) {
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
|
@ -1484,7 +1500,7 @@ public class TrackSegmentFragment extends OsmAndListFragment {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
popupMenu.show();
|
altitudePopupMenu.show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue