Fix dismiss and back navigation
This commit is contained in:
parent
26e31fb9bf
commit
f1961eb031
5 changed files with 40 additions and 9 deletions
|
@ -36,6 +36,7 @@ import java.util.List;
|
||||||
public class TrackActivity extends TabActivity {
|
public class TrackActivity extends TabActivity {
|
||||||
|
|
||||||
public static final String TRACK_FILE_NAME = "TRACK_FILE_NAME";
|
public static final String TRACK_FILE_NAME = "TRACK_FILE_NAME";
|
||||||
|
public static final String OPEN_POINTS_TAB = "OPEN_POINTS_TAB";
|
||||||
public static final String CURRENT_RECORDING = "CURRENT_RECORDING";
|
public static final String CURRENT_RECORDING = "CURRENT_RECORDING";
|
||||||
protected List<WeakReference<Fragment>> fragList = new ArrayList<>();
|
protected List<WeakReference<Fragment>> fragList = new ArrayList<>();
|
||||||
protected PagerSlidingTabStrip slidingTabLayout;
|
protected PagerSlidingTabStrip slidingTabLayout;
|
||||||
|
@ -47,6 +48,7 @@ public class TrackActivity extends TabActivity {
|
||||||
private List<GpxDisplayGroup> displayGroups;
|
private List<GpxDisplayGroup> displayGroups;
|
||||||
private List<GpxDisplayGroup> originalGroups = new ArrayList<>();
|
private List<GpxDisplayGroup> originalGroups = new ArrayList<>();
|
||||||
private boolean stopped = false;
|
private boolean stopped = false;
|
||||||
|
public boolean openPointsTab = false;
|
||||||
|
|
||||||
public PagerSlidingTabStrip getSlidingTabLayout() {
|
public PagerSlidingTabStrip getSlidingTabLayout() {
|
||||||
return slidingTabLayout;
|
return slidingTabLayout;
|
||||||
|
@ -75,6 +77,9 @@ public class TrackActivity extends TabActivity {
|
||||||
}
|
}
|
||||||
actionBar.setElevation(0);
|
actionBar.setElevation(0);
|
||||||
}
|
}
|
||||||
|
if (intent.hasExtra(OPEN_POINTS_TAB)) {
|
||||||
|
openPointsTab = true;
|
||||||
|
}
|
||||||
setContentView(R.layout.tab_content);
|
setContentView(R.layout.tab_content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,6 +193,9 @@ public class TrackActivity extends TabActivity {
|
||||||
if (isHavingWayPoints() || isHavingRoutePoints()) {
|
if (isHavingWayPoints() || isHavingRoutePoints()) {
|
||||||
((OsmandFragmentPagerAdapter) mViewPager.getAdapter()).addTab(
|
((OsmandFragmentPagerAdapter) mViewPager.getAdapter()).addTab(
|
||||||
getTabIndicator(R.string.points, TrackPointFragment.class));
|
getTabIndicator(R.string.points, TrackPointFragment.class));
|
||||||
|
if (openPointsTab) {
|
||||||
|
mViewPager.setCurrentItem(1, false);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
slidingTabLayout.setVisibility(View.GONE);
|
slidingTabLayout.setVisibility(View.GONE);
|
||||||
getSupportActionBar().setElevation(AndroidUtils.dpToPx(getMyApplication(), 4f));
|
getSupportActionBar().setElevation(AndroidUtils.dpToPx(getMyApplication(), 4f));
|
||||||
|
|
|
@ -13,6 +13,7 @@ public class WptPtEditor extends PointEditor {
|
||||||
private GPXFile gpxFile;
|
private GPXFile gpxFile;
|
||||||
private WptPt wpt;
|
private WptPt wpt;
|
||||||
private boolean gpxSelected;
|
private boolean gpxSelected;
|
||||||
|
private boolean newGpxPointProcessing;
|
||||||
|
|
||||||
public static final String TAG = "WptPtEditorFragment";
|
public static final String TAG = "WptPtEditorFragment";
|
||||||
|
|
||||||
|
@ -20,8 +21,16 @@ public class WptPtEditor extends PointEditor {
|
||||||
super(mapActivity);
|
super(mapActivity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setNewGpxPointProcessing(boolean newGpxPointProcessing) {
|
||||||
|
this.newGpxPointProcessing = newGpxPointProcessing;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isNewGpxPointProcessing() {
|
||||||
|
return newGpxPointProcessing;
|
||||||
|
}
|
||||||
|
|
||||||
public interface OnDismissListener {
|
public interface OnDismissListener {
|
||||||
void openTrackActivity();
|
void onDismiss();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOnDismissListener(OnDismissListener listener) {
|
public void setOnDismissListener(OnDismissListener listener) {
|
||||||
|
|
|
@ -14,6 +14,7 @@ import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
|
||||||
import net.osmand.plus.GPXUtilities;
|
import net.osmand.plus.GPXUtilities;
|
||||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||||
import net.osmand.plus.GPXUtilities.WptPt;
|
import net.osmand.plus.GPXUtilities.WptPt;
|
||||||
|
import net.osmand.plus.mapcontextmenu.editors.WptPtEditor.OnDismissListener;
|
||||||
import net.osmand.plus.GpxSelectionHelper;
|
import net.osmand.plus.GpxSelectionHelper;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
@ -75,12 +76,13 @@ public class WptPtEditorFragment extends PointEditorFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dismiss() {
|
public void dismiss(boolean includingMenu) {
|
||||||
super.dismiss();
|
super.dismiss(includingMenu);
|
||||||
WptPtEditor.OnDismissListener listener = editor.getOnDismissListener();
|
OnDismissListener listener = editor.getOnDismissListener();
|
||||||
if (listener != null) {
|
if (listener != null) {
|
||||||
listener.openTrackActivity();
|
listener.onDismiss();
|
||||||
}
|
}
|
||||||
|
editor.setNewGpxPointProcessing(false);
|
||||||
editor.setOnDismissListener(null);
|
editor.setOnDismissListener(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,10 +93,14 @@ public class WptPtEditorFragment extends PointEditorFragment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getToolbarTitle() {
|
public String getToolbarTitle() {
|
||||||
if (editor.isNew()) {
|
if (editor.isNewGpxPointProcessing()) {
|
||||||
return getMapActivity().getResources().getString(R.string.context_menu_item_add_waypoint);
|
return getMapActivity().getResources().getString(R.string.save_gpx_waypoint);
|
||||||
} else {
|
} else {
|
||||||
return getMapActivity().getResources().getString(R.string.shared_string_edit);
|
if (editor.isNew()) {
|
||||||
|
return getMapActivity().getResources().getString(R.string.context_menu_item_add_waypoint);
|
||||||
|
} else {
|
||||||
|
return getMapActivity().getResources().getString(R.string.shared_string_edit);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -178,6 +178,10 @@ public class TrackPointFragment extends OsmandExpandableListFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addPoint(PointDescription pointDescription) {
|
private void addPoint(PointDescription pointDescription) {
|
||||||
|
Intent currentIntent = getTrackActivity().getIntent();
|
||||||
|
if (currentIntent != null) {
|
||||||
|
currentIntent.putExtra(TrackActivity.OPEN_POINTS_TAB, true);
|
||||||
|
}
|
||||||
final OsmandSettings settings = app.getSettings();
|
final OsmandSettings settings = app.getSettings();
|
||||||
GPXFile gpx = getGpx();
|
GPXFile gpx = getGpx();
|
||||||
LatLon location = settings.getLastKnownMapLocation();
|
LatLon location = settings.getLastKnownMapLocation();
|
||||||
|
@ -339,6 +343,7 @@ public class TrackPointFragment extends OsmandExpandableListFragment {
|
||||||
@Override
|
@Override
|
||||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||||
menu.clear();
|
menu.clear();
|
||||||
|
getTrackActivity().getClearToolbar(false);
|
||||||
MenuItem mi = createMenuItem(menu, SEARCH_ID, R.string.search_poi_filter, R.drawable.ic_action_search_dark,
|
MenuItem mi = createMenuItem(menu, SEARCH_ID, R.string.search_poi_filter, R.drawable.ic_action_search_dark,
|
||||||
R.drawable.ic_action_search_dark, MenuItemCompat.SHOW_AS_ACTION_ALWAYS | MenuItemCompat.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
|
R.drawable.ic_action_search_dark, MenuItemCompat.SHOW_AS_ACTION_ALWAYS | MenuItemCompat.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
|
||||||
searchView = new SearchView(getActivity());
|
searchView = new SearchView(getActivity());
|
||||||
|
|
|
@ -52,10 +52,12 @@ public class AddGpxPointBottomSheetHelper implements OnDismissListener {
|
||||||
if (pointDescription.isWpt()) {
|
if (pointDescription.isWpt()) {
|
||||||
WptPtEditor editor = activity.getContextMenu().getWptPtPointEditor();
|
WptPtEditor editor = activity.getContextMenu().getWptPtPointEditor();
|
||||||
editor.setOnDismissListener(AddGpxPointBottomSheetHelper.this);
|
editor.setOnDismissListener(AddGpxPointBottomSheetHelper.this);
|
||||||
|
editor.setNewGpxPointProcessing(true);
|
||||||
editor.add(gpx, latLon, titleText);
|
editor.add(gpx, latLon, titleText);
|
||||||
} else if (pointDescription.isRte()) {
|
} else if (pointDescription.isRte()) {
|
||||||
RtePtEditor editor = activity.getContextMenu().getRtePtPointEditor();
|
RtePtEditor editor = activity.getContextMenu().getRtePtPointEditor();
|
||||||
editor.setOnDismissListener(AddGpxPointBottomSheetHelper.this);
|
editor.setOnDismissListener(AddGpxPointBottomSheetHelper.this);
|
||||||
|
editor.setNewGpxPointProcessing(true);
|
||||||
editor.add(gpx, latLon, titleText);
|
editor.add(gpx, latLon, titleText);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -126,9 +128,10 @@ public class AddGpxPointBottomSheetHelper implements OnDismissListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void openTrackActivity() {
|
public void onDismiss() {
|
||||||
Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization().getTrackActivity());
|
Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization().getTrackActivity());
|
||||||
newIntent.putExtra(TrackActivity.TRACK_FILE_NAME, newGpxPoint.getGpx().path);
|
newIntent.putExtra(TrackActivity.TRACK_FILE_NAME, newGpxPoint.getGpx().path);
|
||||||
|
newIntent.putExtra(TrackActivity.OPEN_POINTS_TAB, true);
|
||||||
newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||||
mapActivity.startActivity(newIntent);
|
mapActivity.startActivity(newIntent);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue