Small fixes with gpx description

This commit is contained in:
Vitaliy 2021-01-25 03:46:49 +02:00
parent a8406fda7d
commit 0d704a93c3
7 changed files with 199 additions and 199 deletions

View file

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<shape <shape xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"> android:shape="rectangle">
<corners android:radius="4dp" /> <corners android:radius="4dp" />

View file

@ -109,16 +109,13 @@
<FrameLayout <FrameLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="wrap_content"
android:minHeight="@dimen/card_row_min_height" android:background="?attr/activity_background_basic">
android:layout_weight="1"
android:foreground="@drawable/bg_contextmenu_shadow" <include
android:foregroundGravity="top|fill_horizontal"> android:id="@+id/shadow"
layout="@layout/card_bottom_divider" />
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/activity_background_basic" />
</FrameLayout> </FrameLayout>
</LinearLayout> </LinearLayout>

View file

@ -34,7 +34,6 @@ import com.squareup.picasso.Picasso;
import com.squareup.picasso.RequestCreator; import com.squareup.picasso.RequestCreator;
import net.osmand.AndroidUtils; import net.osmand.AndroidUtils;
import net.osmand.GPXUtilities;
import net.osmand.GPXUtilities.GPXFile; import net.osmand.GPXUtilities.GPXFile;
import net.osmand.GPXUtilities.Metadata; import net.osmand.GPXUtilities.Metadata;
import net.osmand.GPXUtilities.WptPt; import net.osmand.GPXUtilities.WptPt;
@ -409,7 +408,7 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
} }
@Nullable @Nullable
private String getMetadataImageLink(@NonNull Metadata metadata) { public static String getMetadataImageLink(@NonNull Metadata metadata) {
String link = metadata.link; String link = metadata.link;
if (!TextUtils.isEmpty(link)) { if (!TextUtils.isEmpty(link)) {
String lowerCaseLink = link.toLowerCase(); String lowerCaseLink = link.toLowerCase();

View file

@ -1,13 +1,14 @@
package net.osmand.plus.track; package net.osmand.plus.track;
import android.text.TextUtils;
import android.view.View; import android.view.View;
import androidx.annotation.NonNull;
import androidx.appcompat.widget.AppCompatImageView;
import com.squareup.picasso.Callback; import com.squareup.picasso.Callback;
import com.squareup.picasso.Picasso; import com.squareup.picasso.Picasso;
import com.squareup.picasso.RequestCreator; import com.squareup.picasso.RequestCreator;
import net.osmand.GPXUtilities;
import net.osmand.GPXUtilities.GPXFile; import net.osmand.GPXUtilities.GPXFile;
import net.osmand.PicassoUtils; import net.osmand.PicassoUtils;
import net.osmand.plus.R; import net.osmand.plus.R;
@ -16,16 +17,15 @@ import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.routepreparationmenu.cards.BaseCard; import net.osmand.plus.routepreparationmenu.cards.BaseCard;
import net.osmand.plus.widgets.TextViewEx; import net.osmand.plus.widgets.TextViewEx;
import net.osmand.plus.wikipedia.WikiArticleHelper; import net.osmand.plus.wikipedia.WikiArticleHelper;
import net.osmand.util.Algorithms;
import androidx.annotation.NonNull; import static net.osmand.plus.myplaces.TrackActivityFragmentAdapter.getMetadataImageLink;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.AppCompatImageView;
public class DescriptionCard extends BaseCard { public class DescriptionCard extends BaseCard {
private final GPXFile gpxFile; private final GPXFile gpxFile;
public DescriptionCard(MapActivity mapActivity, GPXFile gpxFile) { public DescriptionCard(@NonNull MapActivity mapActivity, @NonNull GPXFile gpxFile) {
super(mapActivity); super(mapActivity);
this.gpxFile = gpxFile; this.gpxFile = gpxFile;
} }
@ -37,9 +37,11 @@ public class DescriptionCard extends BaseCard {
@Override @Override
protected void updateContent() { protected void updateContent() {
if (gpxFile == null || gpxFile.metadata == null || gpxFile.metadata.getDescription() == null) { if (gpxFile.metadata == null || gpxFile.metadata.getDescription() == null) {
AndroidUiHelper.updateVisibility(view, false); AndroidUiHelper.updateVisibility(view, false);
return; return;
} else {
AndroidUiHelper.updateVisibility(view, true);
} }
final String title = gpxFile.metadata.getArticleTitle(); final String title = gpxFile.metadata.getArticleTitle();
@ -62,31 +64,15 @@ public class DescriptionCard extends BaseCard {
editBtn.setOnClickListener(new View.OnClickListener() { editBtn.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
GpxEditDescriptionDialogFragment.showInstance(mapActivity, descriptionHtml); GpxEditDescriptionDialogFragment.showInstance(mapActivity, descriptionHtml, null);
} }
}); });
} }
@Nullable
private String getMetadataImageLink(@NonNull GPXUtilities.Metadata metadata) {
String link = metadata.link;
if (!TextUtils.isEmpty(link)) {
String lowerCaseLink = link.toLowerCase();
if (lowerCaseLink.contains(".jpg")
|| lowerCaseLink.contains(".jpeg")
|| lowerCaseLink.contains(".png")
|| lowerCaseLink.contains(".bmp")
|| lowerCaseLink.contains(".webp")) {
return link;
}
}
return null;
}
private String getFirstParagraph(String descriptionHtml) { private String getFirstParagraph(String descriptionHtml) {
if (descriptionHtml != null) { if (descriptionHtml != null) {
String firstParagraph = WikiArticleHelper.getPartialContent(descriptionHtml); String firstParagraph = WikiArticleHelper.getPartialContent(descriptionHtml);
if (!TextUtils.isEmpty(firstParagraph)) { if (!Algorithms.isEmpty(firstParagraph)) {
return firstParagraph; return firstParagraph;
} }
} }
@ -113,5 +99,4 @@ public class DescriptionCard extends BaseCard {
} }
}); });
} }
} }

View file

@ -2,119 +2,130 @@ package net.osmand.plus.track;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
import android.text.Editable;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import net.osmand.GPXUtilities; import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;
import net.osmand.GPXUtilities.GPXFile;
import net.osmand.PlatformUtil; import net.osmand.PlatformUtil;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.BaseOsmAndDialogFragment; import net.osmand.plus.base.BaseOsmAndDialogFragment;
import net.osmand.plus.track.SaveGpxAsyncTask.SaveGpxListener;
import net.osmand.plus.widgets.EditTextEx; import net.osmand.plus.widgets.EditTextEx;
import net.osmand.util.Algorithms;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import java.io.File; import java.io.File;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
public class GpxEditDescriptionDialogFragment extends BaseOsmAndDialogFragment { public class GpxEditDescriptionDialogFragment extends BaseOsmAndDialogFragment {
public static final String TAG = GpxEditDescriptionDialogFragment.class.getSimpleName(); public static final String TAG = GpxEditDescriptionDialogFragment.class.getSimpleName();
private static final Log log = PlatformUtil.getLog(GpxEditDescriptionDialogFragment.class); private static final Log log = PlatformUtil.getLog(GpxEditDescriptionDialogFragment.class);
public static final String CONTENT_KEY = "content_key"; private static final String CONTENT_KEY = "content_key";
private EditTextEx editableHtml; private EditTextEx editableHtml;
@Nullable @Nullable
@Override @Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.dialog_edit_gpx_description, container, false); OsmandApplication app = getMyApplication();
editableHtml = view.findViewById(R.id.description); boolean nightMode = app.getDaynightHelper().isNightModeForMapControls();
LayoutInflater themedInflater = UiUtilities.getInflater(requireContext(), nightMode);
View view = themedInflater.inflate(R.layout.dialog_edit_gpx_description, container, false);
view.findViewById(R.id.btn_close).setOnClickListener(new View.OnClickListener() { editableHtml = view.findViewById(R.id.description);
@Override
public void onClick(View v) {
dismiss();
}
});
view.findViewById(R.id.btn_save).setOnClickListener(new View.OnClickListener() { view.findViewById(R.id.btn_close).setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if (!saveGpx(editableHtml.getText().toString())) { dismiss();
dismiss(); }
} });
}
});
Bundle args = getArguments(); view.findViewById(R.id.btn_save).setOnClickListener(new View.OnClickListener() {
if (args != null) { @Override
String html = args.getString(CONTENT_KEY); public void onClick(View v) {
if (html != null) { Editable editable = editableHtml.getText();
editableHtml.setText(html); if (!Algorithms.isEmpty(editable) && !saveGpx(editable.toString())) {
} dismiss();
} }
}
});
return view; Bundle args = getArguments();
} if (args != null) {
String html = args.getString(CONTENT_KEY);
if (html != null) {
editableHtml.setText(html);
}
}
private boolean saveGpx(final String html) { return view;
if (html == null) { }
return false;
}
final FragmentManager manager = getFragmentManager();
if (manager == null) {
return false;
}
final Fragment readGpxFragment = manager.findFragmentByTag(GpxReadDescriptionDialogFragment.TAG); private boolean saveGpx(final String html) {
final TrackMenuFragment trackMenuFragment = (TrackMenuFragment) manager.findFragmentByTag(TrackMenuFragment.TAG); MapActivity mapActivity = getMapActivity();
if (trackMenuFragment == null) { if (mapActivity == null || mapActivity.getTrackMenuFragment() == null) {
return false; return false;
} }
TrackMenuFragment trackMenuFragment = mapActivity.getTrackMenuFragment();
File file = trackMenuFragment.getDisplayHelper().getFile(); GPXFile gpx = trackMenuFragment.getGpx();
GPXUtilities.GPXFile gpx = trackMenuFragment.getGpx(); gpx.metadata.getExtensionsToWrite().put("desc", html);
gpx.metadata.getExtensionsToWrite().put("desc", html);
new SaveGpxAsyncTask(file, gpx, new SaveGpxAsyncTask.SaveGpxListener() { File file = trackMenuFragment.getDisplayHelper().getFile();
@Override new SaveGpxAsyncTask(file, gpx, new SaveGpxListener() {
public void gpxSavingStarted() { @Override
} public void gpxSavingStarted() {
}
@Override @Override
public void gpxSavingFinished(Exception errorMessage) { public void gpxSavingFinished(Exception errorMessage) {
if (errorMessage != null) { if (errorMessage != null) {
log.error(errorMessage); log.error(errorMessage);
} }
MapActivity mapActivity = getMapActivity();
if (mapActivity == null || mapActivity.getTrackMenuFragment() == null) {
TrackMenuFragment trackMenuFragment = mapActivity.getTrackMenuFragment();
trackMenuFragment.updateContent();
}
Fragment target = getTargetFragment();
if (target instanceof GpxReadDescriptionDialogFragment) {
((GpxReadDescriptionDialogFragment) target).updateContent(html);
}
dismiss();
}
}).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
return true;
}
trackMenuFragment.updateContent(); @Nullable
if (readGpxFragment != null) { private MapActivity getMapActivity() {
Bundle args = readGpxFragment.getArguments(); return (MapActivity) getActivity();
if (args != null) { }
args.putString(GpxReadDescriptionDialogFragment.CONTENT_KEY, html);
readGpxFragment.onResume();
}
}
dismiss();
} public static void showInstance(@NonNull FragmentActivity activity, @NonNull String description, @Nullable Fragment target) {
}).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); FragmentManager fragmentManager = activity.getSupportFragmentManager();
return true; if (!fragmentManager.isStateSaved()) {
} Bundle args = new Bundle();
args.putString(CONTENT_KEY, description);
public static void showInstance(AppCompatActivity activity, String description) {
Bundle args = new Bundle();
args.putString(GpxEditDescriptionDialogFragment.CONTENT_KEY, description);
GpxEditDescriptionDialogFragment fragment = new GpxEditDescriptionDialogFragment();
fragment.setArguments(args);
fragment.show(activity.getSupportFragmentManager(), GpxEditDescriptionDialogFragment.TAG);
}
GpxEditDescriptionDialogFragment fragment = new GpxEditDescriptionDialogFragment();
fragment.setArguments(args);
fragment.setTargetFragment(target, 0);
fragment.show(fragmentManager, GpxEditDescriptionDialogFragment.TAG);
}
}
} }

View file

@ -15,47 +15,69 @@ import android.webkit.WebSettings;
import android.webkit.WebView; import android.webkit.WebView;
import android.webkit.WebViewClient; 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.Callback;
import com.squareup.picasso.Picasso; import com.squareup.picasso.Picasso;
import com.squareup.picasso.RequestCreator; import com.squareup.picasso.RequestCreator;
import net.osmand.AndroidUtils; import net.osmand.AndroidUtils;
import net.osmand.PicassoUtils; import net.osmand.PicassoUtils;
import net.osmand.PlatformUtil;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.base.BaseOsmAndDialogFragment; import net.osmand.plus.base.BaseOsmAndDialogFragment;
import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.widgets.TextViewEx; import net.osmand.plus.widgets.TextViewEx;
import net.osmand.plus.widgets.WebViewEx; import net.osmand.plus.widgets.WebViewEx;
import net.osmand.plus.wikivoyage.WikivoyageUtils; import net.osmand.plus.wikivoyage.WikivoyageUtils;
import net.osmand.util.Algorithms;
import org.apache.commons.logging.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.AppCompatImageView;
import androidx.appcompat.widget.Toolbar;
import androidx.core.content.ContextCompat;
public class GpxReadDescriptionDialogFragment extends BaseOsmAndDialogFragment { public class GpxReadDescriptionDialogFragment extends BaseOsmAndDialogFragment {
public static final String TAG = GpxReadDescriptionDialogFragment.class.getSimpleName(); public static final String TAG = GpxReadDescriptionDialogFragment.class.getSimpleName();
private static final Log log = PlatformUtil.getLog(GpxReadDescriptionDialogFragment.class);
public static final String TITLE_KEY = "title_key";
public static final String IMAGE_URL_KEY = "image_url_key";
public static final String CONTENT_KEY = "content_key";
WebViewEx webView;
private static final String TITLE_KEY = "title_key";
private static final String IMAGE_URL_KEY = "image_url_key";
private static final String CONTENT_KEY = "content_key";
private static final int EDIT_ID = 1; private static final int EDIT_ID = 1;
private WebViewEx webView;
private String title;
private String imageUrl;
private String contentHtml;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Bundle args = getArguments();
if (savedInstanceState != null) {
readBundle(savedInstanceState);
} else if (args != null) {
readBundle(args);
}
}
private void readBundle(Bundle bundle) {
title = bundle.getString(TITLE_KEY);
imageUrl = bundle.getString(IMAGE_URL_KEY);
contentHtml = bundle.getString(CONTENT_KEY);
}
@Nullable @Nullable
@Override @Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.dialog_read_gpx_description, container, false); OsmandApplication app = getMyApplication();
boolean nightMode = app.getDaynightHelper().isNightModeForMapControls();
LayoutInflater themedInflater = UiUtilities.getInflater(requireContext(), nightMode);
View view = themedInflater.inflate(R.layout.dialog_read_gpx_description, container, false);
setupToolbar(view); setupToolbar(view);
setupImage(view); setupImage(view);
@ -73,7 +95,10 @@ public class GpxReadDescriptionDialogFragment extends BaseOsmAndDialogFragment {
@Override @Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) { public boolean onOptionsItemSelected(@NonNull MenuItem item) {
if (item.getItemId() == EDIT_ID) { if (item.getItemId() == EDIT_ID) {
GpxEditDescriptionDialogFragment.showInstance(getMyActivity(), getArgument(CONTENT_KEY)); FragmentActivity activity = getActivity();
if (activity != null) {
GpxEditDescriptionDialogFragment.showInstance(activity, contentHtml, this);
}
return true; return true;
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
@ -95,6 +120,14 @@ public class GpxReadDescriptionDialogFragment extends BaseOsmAndDialogFragment {
menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
} }
@Override
public void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
outState.putString(TITLE_KEY, title);
outState.putString(IMAGE_URL_KEY, imageUrl);
outState.putString(CONTENT_KEY, contentHtml);
}
private void setupToolbar(View view) { private void setupToolbar(View view) {
Toolbar toolbar = view.findViewById(R.id.toolbar); Toolbar toolbar = view.findViewById(R.id.toolbar);
getMyActivity().setSupportActionBar(toolbar); getMyActivity().setSupportActionBar(toolbar);
@ -107,8 +140,7 @@ public class GpxReadDescriptionDialogFragment extends BaseOsmAndDialogFragment {
toolbar.setNavigationIcon(icBack); toolbar.setNavigationIcon(icBack);
toolbar.setNavigationContentDescription(R.string.access_shared_string_navigate_up); toolbar.setNavigationContentDescription(R.string.access_shared_string_navigate_up);
String title = getArgument(TITLE_KEY); if (!Algorithms.isEmpty(title)) {
if (title != null) {
toolbar.setTitle(title); toolbar.setTitle(title);
int titleColor = AndroidUtils.resolveAttribute(ctx, R.attr.pstsTextColor); int titleColor = AndroidUtils.resolveAttribute(ctx, R.attr.pstsTextColor);
toolbar.setTitleTextColor(ContextCompat.getColor(ctx, titleColor)); toolbar.setTitleTextColor(ContextCompat.getColor(ctx, titleColor));
@ -123,7 +155,6 @@ public class GpxReadDescriptionDialogFragment extends BaseOsmAndDialogFragment {
} }
private void setupImage(View view) { private void setupImage(View view) {
final String imageUrl = getArgument(IMAGE_URL_KEY);
if (imageUrl == null) { if (imageUrl == null) {
return; return;
} }
@ -168,8 +199,13 @@ public class GpxReadDescriptionDialogFragment extends BaseOsmAndDialogFragment {
loadWebviewData(); loadWebviewData();
} }
public void updateContent(String content) {
contentHtml = content;
loadWebviewData();
}
private void loadWebviewData() { private void loadWebviewData() {
String content = getArgument(CONTENT_KEY); String content = contentHtml;
if (content != null) { if (content != null) {
content = isNightMode(false) ? getColoredContent(content) : content; content = isNightMode(false) ? getColoredContent(content) : content;
String encoded = Base64.encodeToString(content.getBytes(), Base64.NO_PADDING); String encoded = Base64.encodeToString(content.getBytes(), Base64.NO_PADDING);
@ -182,7 +218,10 @@ public class GpxReadDescriptionDialogFragment extends BaseOsmAndDialogFragment {
readBtn.setOnClickListener(new View.OnClickListener() { readBtn.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
GpxEditDescriptionDialogFragment.showInstance(getMyActivity(), getArgument(CONTENT_KEY)); FragmentActivity activity = getActivity();
if (activity != null) {
GpxEditDescriptionDialogFragment.showInstance(activity, contentHtml, GpxReadDescriptionDialogFragment.this);
}
} }
}); });
AndroidUiHelper.setVisibility(View.VISIBLE, AndroidUiHelper.setVisibility(View.VISIBLE,
@ -193,27 +232,20 @@ public class GpxReadDescriptionDialogFragment extends BaseOsmAndDialogFragment {
} }
private String getColoredContent(String content) { private String getColoredContent(String content) {
return "<body style=\"color:white;\">\n" + return "<body style=\"color:white;\">\n" + content + "</body>\n";
content +
"</body>\n";
} }
private String getArgument(String key) { public static void showInstance(@NonNull FragmentActivity activity, @NonNull String title, @NonNull String imageUrl, @NonNull String description) {
Bundle args = getArguments(); FragmentManager fragmentManager = activity.getSupportFragmentManager();
if (args == null) { if (!fragmentManager.isStateSaved()) {
return null; Bundle args = new Bundle();
args.putString(TITLE_KEY, title);
args.putString(IMAGE_URL_KEY, imageUrl);
args.putString(CONTENT_KEY, description);
GpxReadDescriptionDialogFragment fragment = new GpxReadDescriptionDialogFragment();
fragment.setArguments(args);
fragment.show(fragmentManager, GpxReadDescriptionDialogFragment.TAG);
} }
return args.getString(key);
}
public static void showInstance(AppCompatActivity activity, String title, String imageUrl, String description) {
Bundle args = new Bundle();
args.putString(GpxReadDescriptionDialogFragment.TITLE_KEY, title);
args.putString(GpxReadDescriptionDialogFragment.IMAGE_URL_KEY, imageUrl);
args.putString(GpxReadDescriptionDialogFragment.CONTENT_KEY, description);
GpxReadDescriptionDialogFragment fragment = new GpxReadDescriptionDialogFragment();
fragment.setArguments(args);
fragment.show(activity.getSupportFragmentManager(), GpxReadDescriptionDialogFragment.TAG);
} }
} }

View file

@ -15,16 +15,21 @@ import android.widget.FrameLayout;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import com.github.mikephil.charting.interfaces.datasets.ILineDataSet; import androidx.annotation.DrawableRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.StringRes;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;
import com.google.android.material.bottomnavigation.BottomNavigationView; import com.google.android.material.bottomnavigation.BottomNavigationView;
import net.osmand.AndroidUtils; import net.osmand.AndroidUtils;
import net.osmand.FileUtils; import net.osmand.FileUtils;
import net.osmand.FileUtils.RenameCallback; import net.osmand.FileUtils.RenameCallback;
import net.osmand.GPXUtilities.GPXFile; import net.osmand.GPXUtilities.GPXFile;
import net.osmand.GPXUtilities.Track;
import net.osmand.GPXUtilities.TrkSegment; import net.osmand.GPXUtilities.TrkSegment;
import net.osmand.GPXUtilities.WptPt;
import net.osmand.Location; import net.osmand.Location;
import net.osmand.PlatformUtil; import net.osmand.PlatformUtil;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
@ -48,8 +53,6 @@ import net.osmand.plus.base.ContextMenuFragment;
import net.osmand.plus.base.ContextMenuScrollFragment; import net.osmand.plus.base.ContextMenuScrollFragment;
import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.helpers.GpxUiHelper; import net.osmand.plus.helpers.GpxUiHelper;
import net.osmand.plus.helpers.GpxUiHelper.GPXDataSetType;
import net.osmand.plus.helpers.GpxUiHelper.OrderedLineDataSet;
import net.osmand.plus.mapcontextmenu.MapContextMenu; import net.osmand.plus.mapcontextmenu.MapContextMenu;
import net.osmand.plus.mapcontextmenu.controllers.SelectedGpxMenuController.OpenGpxDetailsTask; import net.osmand.plus.mapcontextmenu.controllers.SelectedGpxMenuController.OpenGpxDetailsTask;
import net.osmand.plus.mapcontextmenu.other.TrackChartPoints; import net.osmand.plus.mapcontextmenu.other.TrackChartPoints;
@ -58,7 +61,6 @@ import net.osmand.plus.measurementtool.GpxData;
import net.osmand.plus.measurementtool.MeasurementEditingContext; import net.osmand.plus.measurementtool.MeasurementEditingContext;
import net.osmand.plus.measurementtool.MeasurementToolFragment; import net.osmand.plus.measurementtool.MeasurementToolFragment;
import net.osmand.plus.myplaces.AvailableGPXFragment.GpxInfo; import net.osmand.plus.myplaces.AvailableGPXFragment.GpxInfo;
import net.osmand.plus.myplaces.GPXTabItemType;
import net.osmand.plus.myplaces.MoveGpxFileBottomSheet; import net.osmand.plus.myplaces.MoveGpxFileBottomSheet;
import net.osmand.plus.myplaces.MoveGpxFileBottomSheet.OnTrackFileMoveListener; import net.osmand.plus.myplaces.MoveGpxFileBottomSheet.OnTrackFileMoveListener;
import net.osmand.plus.myplaces.SegmentActionsListener; import net.osmand.plus.myplaces.SegmentActionsListener;
@ -77,14 +79,6 @@ import org.apache.commons.logging.Log;
import java.io.File; import java.io.File;
import java.util.List; import java.util.List;
import androidx.annotation.DrawableRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.StringRes;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;
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.myplaces.TrackActivityFragmentAdapter.isGpxFileSelected; import static net.osmand.plus.myplaces.TrackActivityFragmentAdapter.isGpxFileSelected;
@ -224,8 +218,6 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
if (isPortrait()) { if (isPortrait()) {
AndroidUiHelper.updateVisibility(getTopShadow(), true); AndroidUiHelper.updateVisibility(getTopShadow(), true);
AndroidUtils.setBackground(view.getContext(), getBottomContainer(), isNightMode(),
R.color.list_background_color_light, R.color.list_background_color_dark);
} else { } else {
int widthNoShadow = getLandscapeNoShadowWidth(); int widthNoShadow = getLandscapeNoShadowWidth();
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(widthNoShadow, ViewGroup.LayoutParams.WRAP_CONTENT); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(widthNoShadow, ViewGroup.LayoutParams.WRAP_CONTENT);
@ -663,21 +655,6 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
} }
} }
/*private void updateCardsLayout() {
View mainView = getMainView();
if (mainView != null) {
View topShadow = getTopShadow();
FrameLayout bottomContainer = getBottomContainer();
if (getCurrentMenuState() == MenuState.HEADER_ONLY) {
topShadow.setVisibility(View.INVISIBLE);
bottomContainer.setBackgroundDrawable(null);
} else {
topShadow.setVisibility(View.VISIBLE);
AndroidUtils.setBackground(mainView.getContext(), bottomContainer, isNightMode(), R.color.list_background_color_light, R.color.list_background_color_dark);
}
}
}*/
private void setupButtons(View view) { private void setupButtons(View view) {
ColorStateList navColorStateList = AndroidUtils.createBottomNavColorStateList(getContext(), isNightMode()); ColorStateList navColorStateList = AndroidUtils.createBottomNavColorStateList(getContext(), isNightMode());
BottomNavigationView bottomNav = view.findViewById(R.id.bottom_navigation); BottomNavigationView bottomNav = view.findViewById(R.id.bottom_navigation);