Fix image download buttons, wrong navigation

This commit is contained in:
Dima-1 2021-02-23 18:29:32 +02:00
parent 152129ec78
commit 25390e1d42
3 changed files with 30 additions and 37 deletions

View file

@ -279,6 +279,19 @@ public class Amenity extends MapObject {
} }
public String getTagContent(String tag, String lang) { public String getTagContent(String tag, String lang) {
String translateName = getStrictTagContent(tag, lang);
if (translateName != null) {
return translateName;
}
for (String nm : getAdditionalInfoKeys()) {
if (nm.startsWith(tag + ":")) {
return getAdditionalInfo(nm);
}
}
return null;
}
public String getStrictTagContent(String tag, String lang) {
if (lang != null) { if (lang != null) {
String translateName = getAdditionalInfo(tag + ":" + lang); String translateName = getAdditionalInfo(tag + ":" + lang);
if (!Algorithms.isEmpty(translateName)) { if (!Algorithms.isEmpty(translateName)) {
@ -293,11 +306,6 @@ public class Amenity extends MapObject {
if (!Algorithms.isEmpty(enName)) { if (!Algorithms.isEmpty(enName)) {
return enName; return enName;
} }
for (String nm : getAdditionalInfoKeys()) {
if (nm.startsWith(tag + ":")) {
return getAdditionalInfo(nm);
}
}
return null; return null;
} }

View file

@ -33,50 +33,35 @@ public class WikivoyageShowPicturesDialogFragment extends BottomSheetDialogFragm
@Override @Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
nightMode=!getMyApplication().getSettings().isLightContent(); nightMode = !getMyApplication().getSettings().isLightContent();
View view = inflater.inflate(R.layout.fragment_wikivoyage_show_images_first_time, container, false); View view = inflater.inflate(R.layout.fragment_wikivoyage_show_images_first_time, container, false);
view.findViewById(R.id.button_no).setOnClickListener(new View.OnClickListener() { TextView buttonNo = view.findViewById(R.id.button_no);
buttonNo.setText(R.string.shared_string_only_with_wifi);
buttonNo.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
OsmandApplication app = getMyApplication(); OsmandApplication app = getMyApplication();
if (app != null) { if (app != null) {
app.getSettings().WIKI_ARTICLE_SHOW_IMAGES.set(WikiArticleShowImages.OFF); app.getSettings().WIKI_ARTICLE_SHOW_IMAGES.set(WikiArticleShowImages.WIFI);
} }
sendResult(); sendResult();
dismiss(); dismiss();
} }
}); });
TextView buttonDownload = view.findViewById(R.id.button_download); TextView buttonDownload = view.findViewById(R.id.button_download);
if (getMyApplication().getSettings().isWifiConnected()) { buttonDownload.setText(R.string.shared_string_always);
buttonDownload.setText(R.string.shared_string_only_with_wifi); buttonDownload.setOnClickListener(new View.OnClickListener() {
buttonDownload.setOnClickListener(new View.OnClickListener() { @Override
@Override public void onClick(View v) {
public void onClick(View v) { OsmandApplication app = getMyApplication();
OsmandApplication app = getMyApplication(); if (app != null) {
if (app != null) { app.getSettings().WIKI_ARTICLE_SHOW_IMAGES.set(WikiArticleShowImages.ON);
app.getSettings().WIKI_ARTICLE_SHOW_IMAGES.set(WikiArticleShowImages.WIFI);
}
sendResult();
dismiss();
} }
}); sendResult();
} else { dismiss();
buttonDownload.setText(R.string.shared_string_show); }
buttonDownload.setOnClickListener(new View.OnClickListener() { });
@Override
public void onClick(View v) {
OsmandApplication app = getMyApplication();
if (app != null) {
app.getSettings().WIKI_ARTICLE_SHOW_IMAGES.set(WikiArticleShowImages.ON);
}
sendResult();
dismiss();
}
});
}
setupHeightAndBackground(view); setupHeightAndBackground(view);
return view; return view;
} }

View file

@ -280,7 +280,7 @@ public class TravelObfHelper implements TravelHelper {
res.originalId = 0; res.originalId = 0;
res.lang = lang; res.lang = lang;
res.contentsJson = Algorithms.emptyIfNull(amenity.getTagContent(Amenity.CONTENT_JSON, lang)); res.contentsJson = Algorithms.emptyIfNull(amenity.getTagContent(Amenity.CONTENT_JSON, lang));
res.aggregatedPartOf = Algorithms.emptyIfNull(amenity.getTagContent(Amenity.IS_AGGR_PART, lang)); res.aggregatedPartOf = Algorithms.emptyIfNull(amenity.getStrictTagContent(Amenity.IS_AGGR_PART, lang));
return res; return res;
} }