Merge branch 'html-with-saved-newlines' into 'master'
implement HTML with preserved newlines for app descriptions Closes #1114 See merge request fdroid/fdroidclient!618
This commit is contained in:
commit
1ef92f55cd
@ -203,7 +203,7 @@ public class RepoXMLHandler extends DefaultHandler {
|
|||||||
break;
|
break;
|
||||||
case "desc":
|
case "desc":
|
||||||
// New-style description.
|
// New-style description.
|
||||||
curapp.description = str;
|
curapp.description = App.formatDescription(str);
|
||||||
break;
|
break;
|
||||||
case "summary":
|
case "summary":
|
||||||
curapp.summary = str;
|
curapp.summary = str;
|
||||||
|
@ -382,6 +382,16 @@ public class App extends ValueObject implements Comparable<App>, Parcelable {
|
|||||||
initApkFromApkFile(context, this.installedApk, packageInfo, apkFile);
|
initApkFromApkFile(context, this.installedApk, packageInfo, apkFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* In order to format all in coming descriptions before they are written
|
||||||
|
* out to the database and used elsewhere, this is needed to intercept
|
||||||
|
* the setting of {@link App#description} to insert the format method.
|
||||||
|
*/
|
||||||
|
@JsonProperty("description")
|
||||||
|
private void setDescription(String description) { // NOPMD
|
||||||
|
this.description = formatDescription(description);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses the {@code localized} block in the incoming index metadata,
|
* Parses the {@code localized} block in the incoming index metadata,
|
||||||
* choosing the best match in terms of locale/language while filling as
|
* choosing the best match in terms of locale/language while filling as
|
||||||
@ -499,7 +509,7 @@ public class App extends ValueObject implements Comparable<App>, Parcelable {
|
|||||||
}
|
}
|
||||||
value = getLocalizedEntry(localized, localesToUse, "description");
|
value = getLocalizedEntry(localized, localesToUse, "description");
|
||||||
if (!TextUtils.isEmpty(value)) {
|
if (!TextUtils.isEmpty(value)) {
|
||||||
description = value;
|
description = formatDescription(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
featureGraphic = getLocalizedGraphicsEntry(localized, localesToUse, "featureGraphic");
|
featureGraphic = getLocalizedGraphicsEntry(localized, localesToUse, "featureGraphic");
|
||||||
@ -583,6 +593,13 @@ public class App extends ValueObject implements Comparable<App>, Parcelable {
|
|||||||
return new String[0];
|
return new String[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the app description text with all newlines replaced by {@code <br>}
|
||||||
|
*/
|
||||||
|
public static String formatDescription(String description) {
|
||||||
|
return description.replace("\n", "<br>");
|
||||||
|
}
|
||||||
|
|
||||||
public String getFeatureGraphicUrl(Context context) {
|
public String getFeatureGraphicUrl(Context context) {
|
||||||
if (TextUtils.isEmpty(featureGraphic)) {
|
if (TextUtils.isEmpty(featureGraphic)) {
|
||||||
return null;
|
return null;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user