Add back button to track menu
This commit is contained in:
parent
095c22a035
commit
6d0f17748f
7 changed files with 88 additions and 12 deletions
|
@ -125,6 +125,49 @@
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/back_button_container"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="@dimen/content_padding_half"
|
||||||
|
android:layout_marginTop="@dimen/content_padding_half"
|
||||||
|
android:layout_marginRight="@dimen/content_padding_half"
|
||||||
|
android:background="?attr/flow_toolbar_bg"
|
||||||
|
android:visibility="gone"
|
||||||
|
tools:visibility="visible">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="@dimen/setting_list_item_small_height"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingStart="@dimen/content_padding_half"
|
||||||
|
android:paddingLeft="@dimen/content_padding_half"
|
||||||
|
android:paddingEnd="@dimen/content_padding_small"
|
||||||
|
android:paddingRight="@dimen/content_padding_small">
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.AppCompatImageView
|
||||||
|
android:id="@+id/back_button_icon"
|
||||||
|
android:layout_width="@dimen/standard_icon_size"
|
||||||
|
android:layout_height="@dimen/standard_icon_size"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_marginEnd="@dimen/content_padding_half"
|
||||||
|
android:layout_marginRight="@dimen/content_padding_half"
|
||||||
|
android:tint="?attr/active_color_basic"
|
||||||
|
osmand:srcCompat="@drawable/ic_arrow_back" />
|
||||||
|
|
||||||
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
|
android:id="@+id/back_button_text"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:textColor="?attr/active_color_basic"
|
||||||
|
osmand:typeface="@string/font_roboto_medium"
|
||||||
|
tools:text="@string/shared_string_tracks" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<com.google.android.material.appbar.AppBarLayout
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
android:id="@+id/context_menu_toolbar_container"
|
android:id="@+id/context_menu_toolbar_container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
|
@ -42,6 +42,7 @@ import java.util.regex.Pattern;
|
||||||
import static net.osmand.plus.activities.TrackActivity.CURRENT_RECORDING;
|
import static net.osmand.plus.activities.TrackActivity.CURRENT_RECORDING;
|
||||||
import static net.osmand.plus.activities.TrackActivity.TRACK_FILE_NAME;
|
import static net.osmand.plus.activities.TrackActivity.TRACK_FILE_NAME;
|
||||||
import static net.osmand.plus.osmedit.oauth.OsmOAuthHelper.OsmAuthorizationListener;
|
import static net.osmand.plus.osmedit.oauth.OsmOAuthHelper.OsmAuthorizationListener;
|
||||||
|
import static net.osmand.plus.track.TrackMenuFragment.RETURN_SCREEN_NAME;
|
||||||
|
|
||||||
public class IntentHelper {
|
public class IntentHelper {
|
||||||
|
|
||||||
|
@ -256,8 +257,9 @@ public class IntentHelper {
|
||||||
}
|
}
|
||||||
if (intent.hasExtra(TrackMenuFragment.OPEN_TRACK_MENU)) {
|
if (intent.hasExtra(TrackMenuFragment.OPEN_TRACK_MENU)) {
|
||||||
String path = intent.getStringExtra(TRACK_FILE_NAME);
|
String path = intent.getStringExtra(TRACK_FILE_NAME);
|
||||||
|
String name = intent.getStringExtra(RETURN_SCREEN_NAME);
|
||||||
boolean currentRecording = intent.getBooleanExtra(CURRENT_RECORDING, false);
|
boolean currentRecording = intent.getBooleanExtra(CURRENT_RECORDING, false);
|
||||||
TrackMenuFragment.showInstance(mapActivity, path, currentRecording, null);
|
TrackMenuFragment.showInstance(mapActivity, path, currentRecording, null, name);
|
||||||
mapActivity.setIntent(null);
|
mapActivity.setIntent(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ public class SelectedGpxMenuController extends MenuController {
|
||||||
LatLon latLon = new LatLon(wptPt.lat, wptPt.lon);
|
LatLon latLon = new LatLon(wptPt.lat, wptPt.lon);
|
||||||
SelectedGpxFile selectedGpxFile = selectedGpxPoint.getSelectedGpxFile();
|
SelectedGpxFile selectedGpxFile = selectedGpxPoint.getSelectedGpxFile();
|
||||||
String path = selectedGpxFile.getGpxFile().path;
|
String path = selectedGpxFile.getGpxFile().path;
|
||||||
TrackMenuFragment.showInstance(mapActivity, path, selectedGpxFile.isShowCurrentTrack(), latLon);
|
TrackMenuFragment.showInstance(mapActivity, path, selectedGpxFile.isShowCurrentTrack(), latLon, null);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
leftTitleButtonController.caption = mapActivity.getString(R.string.shared_string_open_track);
|
leftTitleButtonController.caption = mapActivity.getString(R.string.shared_string_open_track);
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class WptPtMenuController extends MenuController {
|
||||||
SelectedGpxFile selectedGpxFile = selectionHelper.getSelectedGPXFile(wpt);
|
SelectedGpxFile selectedGpxFile = selectionHelper.getSelectedGPXFile(wpt);
|
||||||
if (selectedGpxFile != null) {
|
if (selectedGpxFile != null) {
|
||||||
String path = selectedGpxFile.getGpxFile().path;
|
String path = selectedGpxFile.getGpxFile().path;
|
||||||
TrackMenuFragment.showInstance(mapActivity, path, selectedGpxFile.isShowCurrentTrack(), new LatLon(wpt.lon, wpt.lat));
|
TrackMenuFragment.showInstance(mapActivity, path, selectedGpxFile.isShowCurrentTrack(), new LatLon(wpt.lon, wpt.lat), null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -344,7 +344,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment implement
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
FragmentActivity activity = getActivity();
|
FragmentActivity activity = getActivity();
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
openTrack(activity, null, storeState());
|
openTrack(activity, null, storeState(), getString(R.string.shared_string_tracks));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1597,7 +1597,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment implement
|
||||||
GpxInfo item = allGpxAdapter.getChild(groupPosition, childPosition);
|
GpxInfo item = allGpxAdapter.getChild(groupPosition, childPosition);
|
||||||
|
|
||||||
if (!selectionMode) {
|
if (!selectionMode) {
|
||||||
openTrack(getActivity(), item.file, storeState());
|
openTrack(getActivity(), item.file, storeState(), getString(R.string.shared_string_tracks));
|
||||||
} else {
|
} else {
|
||||||
if (!selectedItems.contains(item)) {
|
if (!selectedItems.contains(item)) {
|
||||||
selectedItems.add(item);
|
selectedItems.add(item);
|
||||||
|
|
|
@ -116,6 +116,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
||||||
OsmAndLocationListener, OsmAndCompassListener {
|
OsmAndLocationListener, OsmAndCompassListener {
|
||||||
|
|
||||||
public static final String OPEN_TRACK_MENU = "open_track_menu";
|
public static final String OPEN_TRACK_MENU = "open_track_menu";
|
||||||
|
public static final String RETURN_SCREEN_NAME = "return_screen_name";
|
||||||
|
|
||||||
public static final String TAG = TrackMenuFragment.class.getName();
|
public static final String TAG = TrackMenuFragment.class.getName();
|
||||||
private static final Log log = PlatformUtil.getLog(TrackMenuFragment.class);
|
private static final Log log = PlatformUtil.getLog(TrackMenuFragment.class);
|
||||||
|
@ -137,12 +138,14 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
||||||
private View searchContainer;
|
private View searchContainer;
|
||||||
private ImageView searchButton;
|
private ImageView searchButton;
|
||||||
private EditText searchEditText;
|
private EditText searchEditText;
|
||||||
|
private View backButtonContainer;
|
||||||
private TextView toolbarTextView;
|
private TextView toolbarTextView;
|
||||||
private ViewGroup headerContainer;
|
private ViewGroup headerContainer;
|
||||||
private View routeMenuTopShadowAll;
|
private View routeMenuTopShadowAll;
|
||||||
private BottomNavigationView bottomNav;
|
private BottomNavigationView bottomNav;
|
||||||
|
|
||||||
private String gpxTitle;
|
private String gpxTitle;
|
||||||
|
private String returnScreenName;
|
||||||
private TrackChartPoints trackChartPoints;
|
private TrackChartPoints trackChartPoints;
|
||||||
|
|
||||||
private Float heading;
|
private Float heading;
|
||||||
|
@ -264,6 +267,10 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
||||||
this.latLon = latLon;
|
this.latLon = latLon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setReturnScreenName(String returnScreenName) {
|
||||||
|
this.returnScreenName = returnScreenName;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
View view = super.onCreateView(inflater, container, savedInstanceState);
|
View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||||
|
@ -277,6 +284,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
||||||
toolbarTextView = view.findViewById(R.id.toolbar_title);
|
toolbarTextView = view.findViewById(R.id.toolbar_title);
|
||||||
searchButton = view.findViewById(R.id.search_button);
|
searchButton = view.findViewById(R.id.search_button);
|
||||||
searchContainer = view.findViewById(R.id.search_container);
|
searchContainer = view.findViewById(R.id.search_container);
|
||||||
|
backButtonContainer = view.findViewById(R.id.back_button_container);
|
||||||
|
|
||||||
if (isPortrait()) {
|
if (isPortrait()) {
|
||||||
AndroidUiHelper.updateVisibility(getTopShadow(), true);
|
AndroidUiHelper.updateVisibility(getTopShadow(), true);
|
||||||
|
@ -391,6 +399,20 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
backButtonContainer.setOnClickListener(new OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
MapActivity mapActivity = getMapActivity();
|
||||||
|
if (mapActivity != null) {
|
||||||
|
mapActivity.launchPrevActivityIntent();
|
||||||
|
}
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
TextView backButtonText = backButtonContainer.findViewById(R.id.back_button_text);
|
||||||
|
backButtonText.setText(returnScreenName);
|
||||||
|
ImageView backButtonIcon = backButtonContainer.findViewById(R.id.back_button_icon);
|
||||||
|
backButtonIcon.setImageResource(AndroidUtils.getNavigationIconResId(backButtonIcon.getContext()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupCards() {
|
private void setupCards() {
|
||||||
|
@ -493,6 +515,8 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
||||||
boolean changed = currentMenuState != previousMenuState;
|
boolean changed = currentMenuState != previousMenuState;
|
||||||
if (changed) {
|
if (changed) {
|
||||||
updateControlsVisibility(true);
|
updateControlsVisibility(true);
|
||||||
|
boolean backButtonVisible = !Algorithms.isEmpty(returnScreenName) && currentMenuState == MenuState.HALF_SCREEN;
|
||||||
|
AndroidUiHelper.updateVisibility(backButtonContainer, backButtonVisible);
|
||||||
}
|
}
|
||||||
if (currentMenuState != MenuState.FULL_SCREEN && (changed || !mapPositionAdjusted)) {
|
if (currentMenuState != MenuState.FULL_SCREEN && (changed || !mapPositionAdjusted)) {
|
||||||
adjustMapPosition(getMenuStatePosY(currentMenuState));
|
adjustMapPosition(getMenuStatePosY(currentMenuState));
|
||||||
|
@ -1098,21 +1122,26 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void openTrack(@NonNull Context context, @Nullable File file, Bundle prevIntentParams) {
|
public static void openTrack(@NonNull Context context, @Nullable File file, Bundle prevIntentParams) {
|
||||||
|
openTrack(context, file, prevIntentParams, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void openTrack(@NonNull Context context, @Nullable File file, @Nullable Bundle prevIntentParams, @Nullable String returnScreenName) {
|
||||||
boolean currentRecording = file == null;
|
boolean currentRecording = file == null;
|
||||||
String path = file != null ? file.getAbsolutePath() : null;
|
String path = file != null ? file.getAbsolutePath() : null;
|
||||||
if (context instanceof MapActivity) {
|
if (context instanceof MapActivity) {
|
||||||
TrackMenuFragment.showInstance((MapActivity) context, path, currentRecording, null);
|
TrackMenuFragment.showInstance((MapActivity) context, path, currentRecording, null, null);
|
||||||
} else {
|
} else {
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putString(TRACK_FILE_NAME, path);
|
bundle.putString(TRACK_FILE_NAME, path);
|
||||||
bundle.putBoolean(OPEN_TRACK_MENU, true);
|
bundle.putBoolean(OPEN_TRACK_MENU, true);
|
||||||
bundle.putBoolean(CURRENT_RECORDING, currentRecording);
|
bundle.putBoolean(CURRENT_RECORDING, currentRecording);
|
||||||
|
bundle.putString(RETURN_SCREEN_NAME, returnScreenName);
|
||||||
MapActivity.launchMapActivityMoveToTop(context, prevIntentParams, null, bundle);
|
MapActivity.launchMapActivityMoveToTop(context, prevIntentParams, null, bundle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void showInstance(@NonNull final MapActivity mapActivity, @Nullable String path,
|
public static void showInstance(@NonNull MapActivity mapActivity, @Nullable String path,
|
||||||
boolean showCurrentTrack, @Nullable final LatLon latLon) {
|
boolean showCurrentTrack, @Nullable final LatLon latLon, @Nullable final String returnScreenName) {
|
||||||
OsmandApplication app = mapActivity.getMyApplication();
|
OsmandApplication app = mapActivity.getMyApplication();
|
||||||
SelectedGpxFile selectedGpxFile;
|
SelectedGpxFile selectedGpxFile;
|
||||||
if (showCurrentTrack) {
|
if (showCurrentTrack) {
|
||||||
|
@ -1121,7 +1150,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
||||||
selectedGpxFile = app.getSelectedGpxHelper().getSelectedFileByPath(path);
|
selectedGpxFile = app.getSelectedGpxHelper().getSelectedFileByPath(path);
|
||||||
}
|
}
|
||||||
if (selectedGpxFile != null) {
|
if (selectedGpxFile != null) {
|
||||||
showInstance(mapActivity, selectedGpxFile, latLon);
|
showInstance(mapActivity, selectedGpxFile, latLon, returnScreenName);
|
||||||
} else if (!Algorithms.isEmpty(path)) {
|
} else if (!Algorithms.isEmpty(path)) {
|
||||||
String title = app.getString(R.string.loading_smth, "");
|
String title = app.getString(R.string.loading_smth, "");
|
||||||
final ProgressDialog progress = ProgressDialog.show(mapActivity, title, app.getString(R.string.loading_data));
|
final ProgressDialog progress = ProgressDialog.show(mapActivity, title, app.getString(R.string.loading_data));
|
||||||
|
@ -1135,7 +1164,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
||||||
OsmandApplication app = mapActivity.getMyApplication();
|
OsmandApplication app = mapActivity.getMyApplication();
|
||||||
SelectedGpxFile selectedGpxFile = app.getSelectedGpxHelper().selectGpxFile(result, true, false);
|
SelectedGpxFile selectedGpxFile = app.getSelectedGpxHelper().selectGpxFile(result, true, false);
|
||||||
if (selectedGpxFile != null) {
|
if (selectedGpxFile != null) {
|
||||||
showInstance(mapActivity, selectedGpxFile, latLon);
|
showInstance(mapActivity, selectedGpxFile, latLon, returnScreenName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (progress != null && AndroidUtils.isActivityNotDestroyed(mapActivity)) {
|
if (progress != null && AndroidUtils.isActivityNotDestroyed(mapActivity)) {
|
||||||
|
@ -1148,7 +1177,8 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean showInstance(@NonNull MapActivity mapActivity, @NonNull SelectedGpxFile selectedGpxFile, @Nullable LatLon latLon) {
|
public static boolean showInstance(@NonNull MapActivity mapActivity, @NonNull SelectedGpxFile selectedGpxFile,
|
||||||
|
@Nullable LatLon latLon, @Nullable String returnScreenName) {
|
||||||
try {
|
try {
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putInt(ContextMenuFragment.MENU_STATE_KEY, MenuState.HEADER_ONLY);
|
args.putInt(ContextMenuFragment.MENU_STATE_KEY, MenuState.HEADER_ONLY);
|
||||||
|
@ -1157,6 +1187,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
||||||
fragment.setArguments(args);
|
fragment.setArguments(args);
|
||||||
fragment.setRetainInstance(true);
|
fragment.setRetainInstance(true);
|
||||||
fragment.setSelectedGpxFile(selectedGpxFile);
|
fragment.setSelectedGpxFile(selectedGpxFile);
|
||||||
|
fragment.setReturnScreenName(returnScreenName);
|
||||||
|
|
||||||
if (latLon != null) {
|
if (latLon != null) {
|
||||||
fragment.setLatLon(latLon);
|
fragment.setLatLon(latLon);
|
||||||
|
|
|
@ -160,7 +160,7 @@ public class WikivoyageArticleDialogFragment extends WikiArticleBaseDialogFragme
|
||||||
}
|
}
|
||||||
TravelHelper travelHelper = getMyApplication().getTravelHelper();
|
TravelHelper travelHelper = getMyApplication().getTravelHelper();
|
||||||
File file = travelHelper.createGpxFile(article);
|
File file = travelHelper.createGpxFile(article);
|
||||||
openTrack(activity, new File(file.getAbsolutePath()), null);
|
openTrack(activity, new File(file.getAbsolutePath()), null, getString(R.string.icon_group_travel));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
trackButton.setVisibility(View.GONE);
|
trackButton.setVisibility(View.GONE);
|
||||||
|
|
Loading…
Reference in a new issue