Small edit
This commit is contained in:
parent
904c34e39c
commit
1ac271acea
11 changed files with 389 additions and 367 deletions
|
@ -4,10 +4,11 @@
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/root"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:background="?attr/activity_background_basic">
|
android:background="?attr/list_background_color">
|
||||||
|
|
||||||
<com.google.android.material.appbar.AppBarLayout
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -52,10 +53,12 @@
|
||||||
android:background="@color/color_transparent" />
|
android:background="@color/color_transparent" />
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:id="@+id/divider1"
|
android:id="@+id/divider"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="1dp"
|
android:layout_height="1dp"
|
||||||
android:background="?attr/divider_color" />
|
android:background="?attr/divider_color"
|
||||||
|
android:visibility="gone"
|
||||||
|
tools:visibility="visible"/>
|
||||||
|
|
||||||
<net.osmand.plus.widgets.TextViewEx
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
android:id="@+id/btn_edit"
|
android:id="@+id/btn_edit"
|
||||||
|
@ -73,20 +76,27 @@
|
||||||
osmand:drawableLeftCompat="@drawable/ic_action_edit_dark"
|
osmand:drawableLeftCompat="@drawable/ic_action_edit_dark"
|
||||||
osmand:drawableStartCompat="@drawable/ic_action_edit_dark"
|
osmand:drawableStartCompat="@drawable/ic_action_edit_dark"
|
||||||
osmand:drawableTint="?attr/active_color_basic"
|
osmand:drawableTint="?attr/active_color_basic"
|
||||||
|
android:visibility="gone"
|
||||||
android:text="@string/shared_string_edit"
|
android:text="@string/shared_string_edit"
|
||||||
android:textColor="?attr/active_color_basic"
|
android:textColor="?attr/active_color_basic"
|
||||||
android:textSize="@dimen/default_list_text_size"
|
android:textSize="@dimen/default_list_text_size"
|
||||||
osmand:typeface="@string/font_roboto_medium" />
|
osmand:typeface="@string/font_roboto_medium"
|
||||||
|
tools:visibility="visible" />
|
||||||
|
|
||||||
<View
|
<FrameLayout
|
||||||
android:layout_width="match_parent"
|
android:id="@+id/bottom_empty_space"
|
||||||
android:layout_height="1dp"
|
|
||||||
android:background="?attr/divider_color" />
|
|
||||||
|
|
||||||
<View
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/card_row_min_height"
|
android:layout_height="@dimen/card_row_min_height"
|
||||||
|
android:foreground="@drawable/bg_contextmenu_shadow"
|
||||||
|
android:foregroundGravity="top|fill_horizontal"
|
||||||
|
android:visibility="gone"
|
||||||
|
tools:visibility="visible">
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
android:background="?attr/activity_background_basic" />
|
android:background="?attr/activity_background_basic" />
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
|
@ -106,4 +106,19 @@
|
||||||
osmand:typeface="@string/font_roboto_medium" />
|
osmand:typeface="@string/font_roboto_medium" />
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:minHeight="@dimen/card_row_min_height"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:foreground="@drawable/bg_contextmenu_shadow"
|
||||||
|
android:foregroundGravity="top|fill_horizontal">
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="?attr/activity_background_basic" />
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
@ -196,8 +196,4 @@ public class FileUtils {
|
||||||
public interface RenameCallback {
|
public interface RenameCallback {
|
||||||
void renamedTo(File file);
|
void renamedTo(File file);
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface GpxEditedCallback {
|
|
||||||
void onGpxChanged();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +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) {
|
||||||
|
AndroidUiHelper.updateVisibility(view, false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
final String title = gpxFile.metadata.getArticleTitle();
|
final String title = gpxFile.metadata.getArticleTitle();
|
||||||
final String imageUrl = getMetadataImageLink(gpxFile.metadata);
|
final String imageUrl = getMetadataImageLink(gpxFile.metadata);
|
||||||
final String descriptionHtml = gpxFile.metadata.getDescription();
|
final String descriptionHtml = gpxFile.metadata.getDescription();
|
||||||
|
|
|
@ -94,7 +94,7 @@ public class GpxEditDescriptionDialogFragment extends BaseOsmAndDialogFragment {
|
||||||
log.error(errorMessage);
|
log.error(errorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
trackMenuFragment.onGpxChanged();
|
trackMenuFragment.updateContent();
|
||||||
if (readGpxFragment != null) {
|
if (readGpxFragment != null) {
|
||||||
Bundle args = readGpxFragment.getArguments();
|
Bundle args = readGpxFragment.getArguments();
|
||||||
if (args != null) {
|
if (args != null) {
|
||||||
|
|
|
@ -13,6 +13,7 @@ import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.webkit.WebSettings;
|
import android.webkit.WebSettings;
|
||||||
import android.webkit.WebView;
|
import android.webkit.WebView;
|
||||||
|
import android.webkit.WebViewClient;
|
||||||
|
|
||||||
import com.squareup.picasso.Callback;
|
import com.squareup.picasso.Callback;
|
||||||
import com.squareup.picasso.Picasso;
|
import com.squareup.picasso.Picasso;
|
||||||
|
@ -25,6 +26,7 @@ import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
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.WebViewEx;
|
import net.osmand.plus.widgets.WebViewEx;
|
||||||
import net.osmand.plus.wikivoyage.WikivoyageUtils;
|
import net.osmand.plus.wikivoyage.WikivoyageUtils;
|
||||||
|
|
||||||
|
@ -59,13 +61,6 @@ public class GpxReadDescriptionDialogFragment extends BaseOsmAndDialogFragment {
|
||||||
setupImage(view);
|
setupImage(view);
|
||||||
setupWebView(view);
|
setupWebView(view);
|
||||||
|
|
||||||
view.findViewById(R.id.btn_edit).setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
GpxEditDescriptionDialogFragment.showInstance(getMyActivity(), getArgument(CONTENT_KEY));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,7 +148,7 @@ public class GpxReadDescriptionDialogFragment extends BaseOsmAndDialogFragment {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupWebView(View view) {
|
private void setupWebView(final View view) {
|
||||||
webView = view.findViewById(R.id.content);
|
webView = view.findViewById(R.id.content);
|
||||||
webView.setScrollbarFadingEnabled(true);
|
webView.setScrollbarFadingEnabled(true);
|
||||||
webView.setVerticalScrollBarEnabled(false);
|
webView.setVerticalScrollBarEnabled(false);
|
||||||
|
@ -163,6 +158,13 @@ public class GpxReadDescriptionDialogFragment extends BaseOsmAndDialogFragment {
|
||||||
webView.getSettings().setDomStorageEnabled(true);
|
webView.getSettings().setDomStorageEnabled(true);
|
||||||
webView.getSettings().setLoadWithOverviewMode(true);
|
webView.getSettings().setLoadWithOverviewMode(true);
|
||||||
webView.getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH);
|
webView.getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH);
|
||||||
|
webView.setWebViewClient(new WebViewClient() {
|
||||||
|
@Override
|
||||||
|
public void onPageCommitVisible(WebView webView, String url) {
|
||||||
|
super.onPageCommitVisible(webView, url);
|
||||||
|
setupDependentViews(view);
|
||||||
|
}
|
||||||
|
});
|
||||||
loadWebviewData();
|
loadWebviewData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,6 +177,21 @@ public class GpxReadDescriptionDialogFragment extends BaseOsmAndDialogFragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setupDependentViews(final View view) {
|
||||||
|
TextViewEx readBtn = view.findViewById(R.id.btn_edit);
|
||||||
|
readBtn.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
GpxEditDescriptionDialogFragment.showInstance(getMyActivity(), getArgument(CONTENT_KEY));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
AndroidUiHelper.setVisibility(View.VISIBLE,
|
||||||
|
readBtn, view.findViewById(R.id.divider), view.findViewById(R.id.bottom_empty_space));
|
||||||
|
int backgroundColor = isNightMode(false) ?
|
||||||
|
R.color.activity_background_color_dark : R.color.activity_background_color_light;
|
||||||
|
view.findViewById(R.id.root).setBackgroundResource(backgroundColor);
|
||||||
|
}
|
||||||
|
|
||||||
private String getColoredContent(String content) {
|
private String getColoredContent(String content) {
|
||||||
return "<body style=\"color:white;\">\n" +
|
return "<body style=\"color:white;\">\n" +
|
||||||
content +
|
content +
|
||||||
|
|
|
@ -20,7 +20,6 @@ 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.GpxEditedCallback;
|
|
||||||
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.Track;
|
||||||
|
@ -97,7 +96,7 @@ import static net.osmand.plus.track.OptionsCard.SHOW_ON_MAP_BUTTON_INDEX;
|
||||||
import static net.osmand.plus.track.OptionsCard.UPLOAD_OSM_BUTTON_INDEX;
|
import static net.osmand.plus.track.OptionsCard.UPLOAD_OSM_BUTTON_INDEX;
|
||||||
|
|
||||||
public class TrackMenuFragment extends ContextMenuScrollFragment implements CardListener,
|
public class TrackMenuFragment extends ContextMenuScrollFragment implements CardListener,
|
||||||
SegmentActionsListener, RenameCallback, OnTrackFileMoveListener, GpxEditedCallback {
|
SegmentActionsListener, RenameCallback, OnTrackFileMoveListener {
|
||||||
|
|
||||||
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);
|
||||||
|
@ -222,10 +221,6 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateHeader() {
|
private void updateHeader() {
|
||||||
ViewGroup headerContainer = (ViewGroup) routeMenuTopShadowAll;
|
|
||||||
if (descriptionCard != null && descriptionCard.getView() != null) {
|
|
||||||
headerContainer.removeView(descriptionCard.getView());
|
|
||||||
}
|
|
||||||
if (menuType == TrackMenuType.OPTIONS) {
|
if (menuType == TrackMenuType.OPTIONS) {
|
||||||
headerTitle.setText(menuType.titleId);
|
headerTitle.setText(menuType.titleId);
|
||||||
AndroidUiHelper.updateVisibility(headerIcon, false);
|
AndroidUiHelper.updateVisibility(headerIcon, false);
|
||||||
|
@ -233,18 +228,8 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
||||||
String fileName = Algorithms.getFileWithoutDirs(getGpx().path);
|
String fileName = Algorithms.getFileWithoutDirs(getGpx().path);
|
||||||
headerTitle.setText(GpxUiHelper.getGpxTitle(fileName));
|
headerTitle.setText(GpxUiHelper.getGpxTitle(fileName));
|
||||||
AndroidUiHelper.updateVisibility(headerIcon, true);
|
AndroidUiHelper.updateVisibility(headerIcon, true);
|
||||||
if (menuType == TrackMenuType.OVERVIEW) {
|
|
||||||
fillOverviewTab(headerContainer);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
runLayoutListener();
|
|
||||||
headerContainer.post(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
openMenuScreen(menuType == TrackMenuType.OVERVIEW ? MenuState.HEADER_ONLY : MenuState.HALF_SCREEN, false);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setupCards() {
|
private void setupCards() {
|
||||||
MapActivity mapActivity = getMapActivity();
|
MapActivity mapActivity = getMapActivity();
|
||||||
|
@ -275,20 +260,18 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
||||||
optionsCard.setListener(this);
|
optionsCard.setListener(this);
|
||||||
cardsContainer.addView(optionsCard.build(mapActivity));
|
cardsContainer.addView(optionsCard.build(mapActivity));
|
||||||
}
|
}
|
||||||
}
|
} else if (menuType == TrackMenuType.OVERVIEW) {
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void fillOverviewTab(ViewGroup headerContainer) {
|
|
||||||
if (descriptionCard != null && descriptionCard.getView() != null) {
|
if (descriptionCard != null && descriptionCard.getView() != null) {
|
||||||
ViewGroup parent = ((ViewGroup) descriptionCard.getView().getParent());
|
ViewGroup parent = ((ViewGroup) descriptionCard.getView().getParent());
|
||||||
if (parent != null) {
|
if (parent != null) {
|
||||||
parent.removeView(descriptionCard.getView());
|
cardsContainer.removeView(descriptionCard.getView());
|
||||||
}
|
}
|
||||||
headerContainer.addView(descriptionCard.getView());
|
cardsContainer.addView(descriptionCard.getView());
|
||||||
} else {
|
} else {
|
||||||
descriptionCard = new DescriptionCard(getMapActivity(), displayHelper.getGpx());
|
descriptionCard = new DescriptionCard(getMapActivity(), displayHelper.getGpx());
|
||||||
headerContainer.addView(descriptionCard.build(getMapActivity()));
|
cardsContainer.addView(descriptionCard.build(mapActivity));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -623,6 +606,9 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
||||||
if (optionsCard != null) {
|
if (optionsCard != null) {
|
||||||
optionsCard.updateContent();
|
optionsCard.updateContent();
|
||||||
}
|
}
|
||||||
|
if (descriptionCard != null) {
|
||||||
|
descriptionCard.updateContent();
|
||||||
|
}
|
||||||
setupCards();
|
setupCards();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -814,13 +800,6 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onGpxChanged() {
|
|
||||||
if (descriptionCard != null) {
|
|
||||||
descriptionCard.update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean showInstance(@NonNull MapActivity mapActivity, String path, boolean showCurrentTrack) {
|
public static boolean showInstance(@NonNull MapActivity mapActivity, String path, boolean showCurrentTrack) {
|
||||||
try {
|
try {
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
|
|
Loading…
Reference in a new issue