Bugfix: track list should show description.

Fixes #2127.
This commit is contained in:
Dennis Guse
2025-07-12 16:50:08 +02:00
parent 792e88acaa
commit 93eefe5cf2
2 changed files with 7 additions and 18 deletions
@@ -234,11 +234,9 @@ public class TrackListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
viewBinding.trackListItemTime.setText(null); viewBinding.trackListItemTime.setText(null);
} }
//TODO Check if this is needed or a leftover from the MarkerList migration String categoryDescription = StringUtils.getCategoryDescription(activityTypeLocalized, description);
String category = activityType == null ? activityTypeLocalized : null;
String categoryDescription = StringUtils.getCategoryDescription(category, description);
viewBinding.trackListItemCategoryDescription.setText(categoryDescription); viewBinding.trackListItemCategoryDescription.setText(categoryDescription);
viewBinding.trackListItemCategoryDescription.setVisibility("".equals(categoryDescription) ? View.GONE : View.VISIBLE); viewBinding.trackListItemCategoryDescription.setVisibility(categoryDescription.isEmpty() ? View.GONE : View.VISIBLE);
setSelected(selection.get((int) getId())); setSelected(selection.get((int) getId()));
} }
@@ -174,32 +174,23 @@ public class StringUtils {
return new Pair<>(value, context.getString(R.string.sensor_unit_power)); return new Pair<>(value, context.getString(R.string.sensor_unit_power));
} }
/** @Deprecated //TODO Move to strings.xml
* Gets a string for category.
*
* @param category the category
*/
public static String getCategory(String category) { public static String getCategory(String category) {
if (category == null || category.length() == 0) { if (category == null || category.isEmpty()) {
return null; return null;
} }
return "[" + category + "]"; return "[" + category + "]";
} }
/** @Deprecated //TODO use separate UI elements rather than concatenating strings.
* Gets a string for category and description.
*
* @param category the category
* @param description the description
*/
public static String getCategoryDescription(String category, String description) { public static String getCategoryDescription(String category, String description) {
if (category == null || category.length() == 0) { if (category == null || category.isEmpty()) {
return description; return description;
} }
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append(getCategory(category)); builder.append(getCategory(category));
if (description != null && description.length() != 0) { if (description != null && !description.isEmpty()) {
builder.append(" ").append(description); builder.append(" ").append(description);
} }
return builder.toString(); return builder.toString();