Proper Post Formatting
This commit is contained in:
parent
e203250104
commit
f92db29b0a
1 changed files with 17 additions and 8 deletions
|
|
@ -248,26 +248,35 @@ public class ActivityPostProcessingService {
|
||||||
String formattedType = ActivityFormatter.formatActivityType(activity.getActivityType());
|
String formattedType = ActivityFormatter.formatActivityType(activity.getActivityType());
|
||||||
content.append(activityEmoji).append(" ").append(formattedType);
|
content.append(activityEmoji).append(" ").append(formattedType);
|
||||||
|
|
||||||
// Metrics on separate lines
|
// Metrics, each on its own line with a blank line separating from above
|
||||||
|
StringBuilder metrics = new StringBuilder();
|
||||||
|
|
||||||
if (activity.getTotalDistance() != null) {
|
if (activity.getTotalDistance() != null) {
|
||||||
content.append("\n📏 ")
|
metrics.append("📏 ")
|
||||||
.append(String.format("%.2f km", activity.getTotalDistance().doubleValue() / 1000.0));
|
.append(String.format("%.2f km", activity.getTotalDistance().doubleValue() / 1000.0))
|
||||||
|
.append("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (activity.getTotalDurationSeconds() != null) {
|
if (activity.getTotalDurationSeconds() != null) {
|
||||||
long hours = activity.getTotalDurationSeconds() / 3600;
|
long hours = activity.getTotalDurationSeconds() / 3600;
|
||||||
long minutes = (activity.getTotalDurationSeconds() % 3600) / 60;
|
long minutes = (activity.getTotalDurationSeconds() % 3600) / 60;
|
||||||
long seconds = activity.getTotalDurationSeconds() % 60;
|
long seconds = activity.getTotalDurationSeconds() % 60;
|
||||||
content.append("\n⏱️ ");
|
metrics.append("⏱️ ");
|
||||||
if (hours > 0) {
|
if (hours > 0) {
|
||||||
content.append(hours).append("h ");
|
metrics.append(hours).append("h ");
|
||||||
}
|
}
|
||||||
content.append(minutes).append("m ").append(seconds).append("s");
|
metrics.append(minutes).append("m ").append(seconds).append("s")
|
||||||
|
.append("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (activity.getElevationGain() != null) {
|
if (activity.getElevationGain() != null) {
|
||||||
content.append("\n⛰️ ")
|
metrics.append("⛰️ ")
|
||||||
.append(String.format("%.0f m", activity.getElevationGain()));
|
.append(String.format("%.0f m", activity.getElevationGain()))
|
||||||
|
.append("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (metrics.length() > 0) {
|
||||||
|
content.append("\n\n").append(metrics.toString().stripTrailing());
|
||||||
}
|
}
|
||||||
|
|
||||||
return content.toString();
|
return content.toString();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue