Merge branch 'r3.9'

This commit is contained in:
Vitaliy 2021-02-09 11:06:12 +02:00
commit 2823d6f591
22 changed files with 277 additions and 70 deletions

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/wikivoyage_card_bg_dark" android:state_selected="false" />
<item android:drawable="@drawable/navigation_item_active_bg_dark" android:state_selected="true" />
</selector>

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/wikivoyage_card_bg_light" android:state_selected="false" />
<item android:drawable="@drawable/navigation_item_active_bg_light" android:state_selected="true" />
</selector>

View file

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="@color/active_color_primary_dark" />
</shape>
</item>
<item android:top="2dp">
<shape android:shape="rectangle">
<solid android:color="@color/wikivoyage_card_bg_dark" />
</shape>
</item>
</layer-list>

View file

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="@color/active_color_primary_light" />
</shape>
</item>
<item android:top="2dp">
<shape android:shape="rectangle">
<solid android:color="@color/wikivoyage_card_bg_light" />
</shape>
</item>
</layer-list>

View file

@ -6,6 +6,22 @@
android:layout_height="wrap_content"
android:orientation="vertical">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding"
android:ellipsize="end"
android:letterSpacing="@dimen/description_letter_spacing"
android:maxLines="2"
android:minHeight="@dimen/default_desc_line_height"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"
osmand:lineHeight="@dimen/default_desc_line_height"
osmand:typeface="@string/font_roboto_regular"
tools:text="Amsterdam is the Netherlands' capital and financial, cultural and creative centre with more" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_overview"
android:layout_width="match_parent"

View file

@ -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"
@ -206,7 +249,7 @@
android:layout_height="@dimen/context_menu_action_buttons_height"
android:layout_gravity="bottom"
android:background="?attr/wikivoyage_card_bg_color"
osmand:itemBackground="?attr/wikivoyage_card_bg_color"
osmand:itemBackground="?attr/bottom_navigation_item_background"
osmand:itemIconTint="@color/bottom_navigation_color_selector_light"
osmand:itemTextColor="@color/bottom_navigation_color_selector_light"
osmand:labelVisibilityMode="labeled"

View file

@ -142,6 +142,7 @@
<attr name="text_input_background" format="reference"/>
<attr name="image_help_announcement_time" format="reference"/>
<attr name="switch_button_active" format="reference" />
<attr name="bottom_navigation_item_background" format="reference" />
</declare-styleable>
<declare-styleable name="PagerSlidingTabStrip">

View file

@ -249,6 +249,7 @@
<item name="text_input_background">@color/text_input_background_light</item>
<item name="image_help_announcement_time">@drawable/img_help_announcement_time_day</item>
<item name="switch_button_active">@color/switch_button_active_light</item>
<item name="bottom_navigation_item_background">@drawable/bottom_navigation_item_bg_light</item>
</style>
<style name="ToolbarStyle" parent="@style/Widget.AppCompat.Toolbar">
@ -547,6 +548,7 @@
<item name="text_input_background">@color/text_input_background_dark</item>
<item name="image_help_announcement_time">@drawable/img_help_announcement_time_night</item>
<item name="switch_button_active">@color/switch_button_active_dark</item>
<item name="bottom_navigation_item_background">@drawable/bottom_navigation_item_bg_dark</item>
</style>
<style name="FreeVersionBanner" parent="OsmandDarkTheme">

View file

@ -1,6 +1,7 @@
package net.osmand.plus.base;
import android.animation.Animator;
import android.animation.Animator.AnimatorListener;
import android.animation.AnimatorListenerAdapter;
import android.annotation.TargetApi;
import android.app.Activity;
@ -884,10 +885,28 @@ public abstract class ContextMenuFragment extends BaseOsmAndFragment
updateMainViewLayout(posY);
}
if (animated) {
mainView.animate().y(posY)
.setDuration(ANIMATION_DURATION)
.setInterpolator(new DecelerateInterpolator())
.setListener(new AnimatorListenerAdapter() {
animateMainView(posY, needCloseMenu, previousMenuState, newMenuState);
} else {
if (needCloseMenu && isHideable()) {
dismiss();
} else {
mainView.setY(posY);
updateMainViewLayout(posY);
if (previousMenuState != 0 && newMenuState != 0 && previousMenuState != newMenuState) {
doAfterMenuStateChange(previousMenuState, newMenuState);
}
}
}
ContextMenuFragmentListener listener = this.listener;
if (listener != null) {
listener.onContextMenuYPosChanged(this, posY, needMapAdjust, true);
}
}
return posY;
}
protected void animateMainView(final int posY, final boolean needCloseMenu, final int previousMenuState, final int newMenuState) {
animateView(mainView, posY, new AnimatorListenerAdapter() {
boolean canceled = false;
@ -909,30 +928,14 @@ public abstract class ContextMenuFragment extends BaseOsmAndFragment
}
}
}
}).start();
} else {
if (needCloseMenu && isHideable()) {
dismiss();
} else {
mainView.setY(posY);
updateMainViewLayout(posY);
if (previousMenuState != 0 && newMenuState != 0 && previousMenuState != newMenuState) {
doAfterMenuStateChange(previousMenuState, newMenuState);
}
}
}
ContextMenuFragmentListener listener = this.listener;
if (listener != null) {
listener.onContextMenuYPosChanged(this, posY, needMapAdjust, true);
}
}
return posY;
});
}
public void animateView(@NonNull View view, int y) {
public void animateView(@NonNull View view, int y, @Nullable AnimatorListener listener) {
view.animate().y(y)
.setDuration(ANIMATION_DURATION)
.setInterpolator(new DecelerateInterpolator())
.setListener(listener)
.start();
}

View file

@ -133,7 +133,7 @@ public abstract class ContextMenuScrollFragment extends ContextMenuFragment impl
if (mapControlsView != null) {
int zoomY = y - getMapControlsHeight();
if (animated) {
fragment.animateView(mapControlsView, zoomY);
fragment.animateView(mapControlsView, zoomY, null);
} else {
mapControlsView.setY(zoomY);
}

View file

@ -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);
}
}

View file

@ -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);

View file

@ -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);
}
}
}

View file

@ -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);

View file

@ -767,7 +767,7 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
int pagesY = y - getPagesViewHeight() + fragment.getShadowHeight() +
(Build.VERSION.SDK_INT >= 21 ? AndroidUtils.getStatusBarHeight(pagesView.getContext()) : 0);
if (animated) {
fragment.animateView(pagesView, pagesY);
fragment.animateView(pagesView, pagesY, null);
} else {
pagesView.setY(pagesY);
}
@ -780,7 +780,7 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
int zoomY = y - getZoomButtonsHeight() +
(Build.VERSION.SDK_INT >= 21 ? AndroidUtils.getStatusBarHeight(zoomButtonsView.getContext()) : 0);
if (animated) {
fragment.animateView(zoomButtonsView, zoomY);
fragment.animateView(zoomButtonsView, zoomY, null);
} else {
zoomButtonsView.setY(zoomY);
}

View file

@ -4,6 +4,9 @@ import android.view.View;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import androidx.annotation.NonNull;
import androidx.appcompat.widget.AppCompatImageView;
import com.squareup.picasso.Callback;
import com.squareup.picasso.Picasso;
import com.squareup.picasso.RequestCreator;
@ -16,13 +19,10 @@ import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.routepreparationmenu.cards.BaseCard;
import net.osmand.plus.widgets.TextViewEx;
import net.osmand.plus.wikipedia.WikiArticleHelper;
import net.osmand.util.Algorithms;
import androidx.annotation.NonNull;
import androidx.appcompat.widget.AppCompatImageView;
import static net.osmand.plus.myplaces.TrackActivityFragmentAdapter.getMetadataImageLink;
import static net.osmand.plus.wikipedia.WikiArticleHelper.getFirstParagraph;
public class DescriptionCard extends BaseCard {
@ -98,16 +98,6 @@ public class DescriptionCard extends BaseCard {
});
}
private String getFirstParagraph(String descriptionHtml) {
if (descriptionHtml != null) {
String firstParagraph = WikiArticleHelper.getPartialContent(descriptionHtml);
if (!Algorithms.isEmpty(firstParagraph)) {
return firstParagraph;
}
}
return descriptionHtml;
}
private void setupImage(final String imageUrl) {
if (imageUrl == null) {
return;

View file

@ -16,6 +16,14 @@ import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.AppCompatImageView;
import androidx.appcompat.widget.Toolbar;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;
import com.squareup.picasso.Callback;
import com.squareup.picasso.Picasso;
import com.squareup.picasso.RequestCreator;
@ -32,14 +40,6 @@ import net.osmand.plus.widgets.WebViewEx;
import net.osmand.plus.wikivoyage.WikivoyageUtils;
import net.osmand.util.Algorithms;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.AppCompatImageView;
import androidx.appcompat.widget.Toolbar;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;
public class GpxReadDescriptionDialogFragment extends BaseOsmAndDialogFragment {
public static final String TAG = GpxReadDescriptionDialogFragment.class.getSimpleName();
@ -242,7 +242,7 @@ public class GpxReadDescriptionDialogFragment extends BaseOsmAndDialogFragment {
return "<body style=\"color:white;\">\n" + content + "</body>\n";
}
public static void showInstance(@NonNull FragmentActivity activity, @NonNull String title, @NonNull String imageUrl, @NonNull String description) {
public static void showInstance(@NonNull FragmentActivity activity, @NonNull String title, @Nullable String imageUrl, @NonNull String description) {
FragmentManager fragmentManager = activity.getSupportFragmentManager();
if (!fragmentManager.isStateSaved()) {
Bundle args = new Bundle();

View file

@ -4,7 +4,9 @@ import android.annotation.SuppressLint;
import android.graphics.drawable.Drawable;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.ColorRes;
import androidx.annotation.DrawableRes;
@ -13,18 +15,23 @@ import androidx.appcompat.widget.AppCompatImageView;
import androidx.recyclerview.widget.RecyclerView;
import net.osmand.GPXUtilities.GPXFile;
import net.osmand.GPXUtilities.Metadata;
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.myplaces.SegmentActionsListener;
import net.osmand.plus.routepreparationmenu.cards.BaseCard;
import net.osmand.util.Algorithms;
import static net.osmand.plus.myplaces.TrackActivityFragmentAdapter.getMetadataImageLink;
import static net.osmand.plus.myplaces.TrackActivityFragmentAdapter.isGpxFileSelected;
import static net.osmand.plus.track.OptionsCard.APPEARANCE_BUTTON_INDEX;
import static net.osmand.plus.track.OptionsCard.DIRECTIONS_BUTTON_INDEX;
import static net.osmand.plus.track.OptionsCard.EDIT_BUTTON_INDEX;
import static net.osmand.plus.track.OptionsCard.SHOW_ON_MAP_BUTTON_INDEX;
import static net.osmand.plus.wikipedia.WikiArticleHelper.getFirstParagraph;
public class OverviewCard extends BaseCard {
@ -63,6 +70,7 @@ public class OverviewCard extends BaseCard {
RecyclerView blocksView = view.findViewById(R.id.recycler_overview);
blockStatisticsBuilder.setBlocksView(blocksView);
setupDescription();
initShowButton(iconColorDef, iconColorPres);
initAppearanceButton(iconColorDef, iconColorPres);
if (fileAvailable) {
@ -125,6 +133,31 @@ public class OverviewCard extends BaseCard {
iv.setImageDrawable(icon);
}
private void setupDescription() {
GPXFile gpxFile = getGPXFile();
if (gpxFile.metadata == null) {
gpxFile.metadata = new Metadata();
}
TextView description = view.findViewById(R.id.description);
final String descriptionHtml = gpxFile.metadata.getDescription();
if (Algorithms.isBlank(descriptionHtml)) {
AndroidUiHelper.updateVisibility(description, false);
} else {
description.setText(getFirstParagraph(descriptionHtml));
description.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
GPXFile gpxFile = getGPXFile();
String title = gpxFile.metadata.getArticleTitle();
String imageUrl = getMetadataImageLink(gpxFile.metadata);
GpxReadDescriptionDialogFragment.showInstance(mapActivity, title, imageUrl, descriptionHtml);
}
});
AndroidUiHelper.updateVisibility(description, true);
}
}
private void setOnTouchItem(View item, final ImageView image, final ImageView filled, @DrawableRes final Integer resId, @ColorRes final int colorDef, @ColorRes final int colorPres) {
item.setOnTouchListener(new View.OnTouchListener() {
@SuppressLint("ClickableViewAccessibility")

View file

@ -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;
@ -152,6 +155,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
private LatLon latLon;
private int menuTitleHeight;
private int menuHeaderHeight;
private int toolbarHeightPx;
private boolean mapPositionAdjusted;
@ -264,6 +268,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 +285,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);
@ -292,8 +301,12 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
updateHeader();
setupButtons(view);
updateCardsLayout();
if (menuType == TrackMenuType.OVERVIEW && isPortrait()) {
calculateLayoutAndShowHeader();
} else {
calculateLayoutAndUpdateMenuState();
}
}
return view;
}
@ -391,6 +404,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() {
@ -462,8 +489,8 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
@Override
protected void calculateLayout(View view, boolean initLayout) {
menuTitleHeight = routeMenuTopShadowAll.getHeight()
+ bottomNav.getHeight();
menuHeaderHeight = headerContainer.getHeight();
menuTitleHeight = routeMenuTopShadowAll.getHeight() + bottomNav.getHeight();
super.calculateLayout(view, initLayout);
}
@ -493,6 +520,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));
@ -828,8 +857,10 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
@Override
protected void onHeaderClick() {
if (getCurrentMenuState() == MenuState.HEADER_ONLY) {
updateMenuState();
}
}
private void adjustMapPosition(int y) {
MapActivity mapActivity = getMapActivity();
@ -887,6 +918,20 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
});
}
private void calculateLayoutAndShowHeader() {
runLayoutListener(new Runnable() {
@Override
public void run() {
int posY = getViewHeight() - menuHeaderHeight - menuTitleHeight - getShadowHeight();
if (posY < getViewY()) {
updateMainViewLayout(posY);
}
animateMainView(posY, false, getCurrentMenuState(), getCurrentMenuState());
updateMapControlsPos(TrackMenuFragment.this, posY, true);
}
});
}
private void updateMenuState() {
if (menuType == TrackMenuType.OPTIONS) {
openMenuFullScreen();
@ -1096,21 +1141,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) {
@ -1119,7 +1169,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));
@ -1133,7 +1183,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)) {
@ -1146,7 +1196,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);
@ -1155,6 +1206,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);

View file

@ -26,6 +26,8 @@ import net.osmand.AndroidUtils;
import net.osmand.Collator;
import net.osmand.GPXUtilities.WptPt;
import net.osmand.OsmAndCollator;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup;
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItemType;
@ -173,6 +175,12 @@ public class TrackPointsCard extends BaseCard implements OnChildClickListener, O
@Override
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
GpxDisplayItem item = adapter.getChild(groupPosition, childPosition);
if (item != null && item.locationStart != null) {
LatLon location = new LatLon(item.locationStart.lat, item.locationStart.lon);
PointDescription description = new PointDescription(PointDescription.POINT_TYPE_WPT, item.name);
mapActivity.getContextMenu().show(location, description, item.locationStart);
}
return true;
}

View file

@ -333,6 +333,17 @@ public class WikiArticleHelper {
return res.toString();
}
@Nullable
public static String getFirstParagraph(String descriptionHtml) {
if (descriptionHtml != null) {
String firstParagraph = WikiArticleHelper.getPartialContent(descriptionHtml);
if (!Algorithms.isEmpty(firstParagraph)) {
return firstParagraph;
}
}
return descriptionHtml;
}
public static String buildTravelUrl(String url, String lang) {
String title = url.replace(" ", "_");
try {

View file

@ -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);