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) {
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) {
String translateName = getAdditionalInfo(tag + ":" + lang);
if (!Algorithms.isEmpty(translateName)) {
@ -293,11 +306,6 @@ public class Amenity extends MapObject {
if (!Algorithms.isEmpty(enName)) {
return enName;
}
for (String nm : getAdditionalInfoKeys()) {
if (nm.startsWith(tag + ":")) {
return getAdditionalInfo(nm);
}
}
return null;
}

View file

@ -33,50 +33,35 @@ public class WikivoyageShowPicturesDialogFragment extends BottomSheetDialogFragm
@Override
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.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
public void onClick(View v) {
OsmandApplication app = getMyApplication();
if (app != null) {
app.getSettings().WIKI_ARTICLE_SHOW_IMAGES.set(WikiArticleShowImages.OFF);
app.getSettings().WIKI_ARTICLE_SHOW_IMAGES.set(WikiArticleShowImages.WIFI);
}
sendResult();
dismiss();
}
});
TextView buttonDownload = view.findViewById(R.id.button_download);
if (getMyApplication().getSettings().isWifiConnected()) {
buttonDownload.setText(R.string.shared_string_only_with_wifi);
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.WIFI);
}
sendResult();
dismiss();
buttonDownload.setText(R.string.shared_string_always);
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);
}
});
} else {
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();
}
});
}
sendResult();
dismiss();
}
});
setupHeightAndBackground(view);
return view;
}

View file

@ -280,7 +280,7 @@ public class TravelObfHelper implements TravelHelper {
res.originalId = 0;
res.lang = 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;
}