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
|
||||
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
|
||||
android:id="@+id/context_menu_toolbar_container"
|
||||
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.TRACK_FILE_NAME;
|
||||
import static net.osmand.plus.osmedit.oauth.OsmOAuthHelper.OsmAuthorizationListener;
|
||||
import static net.osmand.plus.track.TrackMenuFragment.RETURN_SCREEN_NAME;
|
||||
|
||||
public class IntentHelper {
|
||||
|
||||
|
@ -256,8 +257,9 @@ public class IntentHelper {
|
|||
}
|
||||
if (intent.hasExtra(TrackMenuFragment.OPEN_TRACK_MENU)) {
|
||||
String path = intent.getStringExtra(TRACK_FILE_NAME);
|
||||
String name = intent.getStringExtra(RETURN_SCREEN_NAME);
|
||||
boolean currentRecording = intent.getBooleanExtra(CURRENT_RECORDING, false);
|
||||
TrackMenuFragment.showInstance(mapActivity, path, currentRecording, null);
|
||||
TrackMenuFragment.showInstance(mapActivity, path, currentRecording, null, name);
|
||||
mapActivity.setIntent(null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ public class SelectedGpxMenuController extends MenuController {
|
|||
LatLon latLon = new LatLon(wptPt.lat, wptPt.lon);
|
||||
SelectedGpxFile selectedGpxFile = selectedGpxPoint.getSelectedGpxFile();
|
||||
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);
|
||||
|
|
|
@ -50,7 +50,7 @@ public class WptPtMenuController extends MenuController {
|
|||
SelectedGpxFile selectedGpxFile = selectionHelper.getSelectedGPXFile(wpt);
|
||||
if (selectedGpxFile != null) {
|
||||
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) {
|
||||
FragmentActivity activity = getActivity();
|
||||
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);
|
||||
|
||||
if (!selectionMode) {
|
||||
openTrack(getActivity(), item.file, storeState());
|
||||
openTrack(getActivity(), item.file, storeState(), getString(R.string.shared_string_tracks));
|
||||
} else {
|
||||
if (!selectedItems.contains(item)) {
|
||||
selectedItems.add(item);
|
||||
|
|
|
@ -116,6 +116,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
|||
OsmAndLocationListener, OsmAndCompassListener {
|
||||
|
||||
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();
|
||||
private static final Log log = PlatformUtil.getLog(TrackMenuFragment.class);
|
||||
|
@ -137,12 +138,14 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
|||
private View searchContainer;
|
||||
private ImageView searchButton;
|
||||
private EditText searchEditText;
|
||||
private View backButtonContainer;
|
||||
private TextView toolbarTextView;
|
||||
private ViewGroup headerContainer;
|
||||
private View routeMenuTopShadowAll;
|
||||
private BottomNavigationView bottomNav;
|
||||
|
||||
private String gpxTitle;
|
||||
private String returnScreenName;
|
||||
private TrackChartPoints trackChartPoints;
|
||||
|
||||
private Float heading;
|
||||
|
@ -264,6 +267,10 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
|||
this.latLon = latLon;
|
||||
}
|
||||
|
||||
public void setReturnScreenName(String returnScreenName) {
|
||||
this.returnScreenName = returnScreenName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle 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);
|
||||
searchButton = view.findViewById(R.id.search_button);
|
||||
searchContainer = view.findViewById(R.id.search_container);
|
||||
backButtonContainer = view.findViewById(R.id.back_button_container);
|
||||
|
||||
if (isPortrait()) {
|
||||
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() {
|
||||
|
@ -493,6 +515,8 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
|||
boolean changed = currentMenuState != previousMenuState;
|
||||
if (changed) {
|
||||
updateControlsVisibility(true);
|
||||
boolean backButtonVisible = !Algorithms.isEmpty(returnScreenName) && currentMenuState == MenuState.HALF_SCREEN;
|
||||
AndroidUiHelper.updateVisibility(backButtonContainer, backButtonVisible);
|
||||
}
|
||||
if (currentMenuState != MenuState.FULL_SCREEN && (changed || !mapPositionAdjusted)) {
|
||||
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) {
|
||||
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;
|
||||
String path = file != null ? file.getAbsolutePath() : null;
|
||||
if (context instanceof MapActivity) {
|
||||
TrackMenuFragment.showInstance((MapActivity) context, path, currentRecording, null);
|
||||
TrackMenuFragment.showInstance((MapActivity) context, path, currentRecording, null, null);
|
||||
} else {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(TRACK_FILE_NAME, path);
|
||||
bundle.putBoolean(OPEN_TRACK_MENU, true);
|
||||
bundle.putBoolean(CURRENT_RECORDING, currentRecording);
|
||||
bundle.putString(RETURN_SCREEN_NAME, returnScreenName);
|
||||
MapActivity.launchMapActivityMoveToTop(context, prevIntentParams, null, bundle);
|
||||
}
|
||||
}
|
||||
|
||||
public static void showInstance(@NonNull final MapActivity mapActivity, @Nullable String path,
|
||||
boolean showCurrentTrack, @Nullable final LatLon latLon) {
|
||||
public static void showInstance(@NonNull MapActivity mapActivity, @Nullable String path,
|
||||
boolean showCurrentTrack, @Nullable final LatLon latLon, @Nullable final String returnScreenName) {
|
||||
OsmandApplication app = mapActivity.getMyApplication();
|
||||
SelectedGpxFile selectedGpxFile;
|
||||
if (showCurrentTrack) {
|
||||
|
@ -1121,7 +1150,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
|||
selectedGpxFile = app.getSelectedGpxHelper().getSelectedFileByPath(path);
|
||||
}
|
||||
if (selectedGpxFile != null) {
|
||||
showInstance(mapActivity, selectedGpxFile, latLon);
|
||||
showInstance(mapActivity, selectedGpxFile, latLon, returnScreenName);
|
||||
} else if (!Algorithms.isEmpty(path)) {
|
||||
String title = app.getString(R.string.loading_smth, "");
|
||||
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();
|
||||
SelectedGpxFile selectedGpxFile = app.getSelectedGpxHelper().selectGpxFile(result, true, false);
|
||||
if (selectedGpxFile != null) {
|
||||
showInstance(mapActivity, selectedGpxFile, latLon);
|
||||
showInstance(mapActivity, selectedGpxFile, latLon, returnScreenName);
|
||||
}
|
||||
}
|
||||
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 {
|
||||
Bundle args = new Bundle();
|
||||
args.putInt(ContextMenuFragment.MENU_STATE_KEY, MenuState.HEADER_ONLY);
|
||||
|
@ -1157,6 +1187,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
|||
fragment.setArguments(args);
|
||||
fragment.setRetainInstance(true);
|
||||
fragment.setSelectedGpxFile(selectedGpxFile);
|
||||
fragment.setReturnScreenName(returnScreenName);
|
||||
|
||||
if (latLon != null) {
|
||||
fragment.setLatLon(latLon);
|
||||
|
|
|
@ -160,7 +160,7 @@ public class WikivoyageArticleDialogFragment extends WikiArticleBaseDialogFragme
|
|||
}
|
||||
TravelHelper travelHelper = getMyApplication().getTravelHelper();
|
||||
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);
|
||||
|
|
Loading…
Reference in a new issue