accName.setTextColor(Colors.primary);
accAmount.setTextColor(Colors.primary);
- SpannableString ss = new SpannableString(acc.getAccountName());
- ss.setSpan(new StyleSpan(Typeface.BOLD), 0, boldAccountName.length(),
+ SpannableString ss = new SpannableString(Misc.addWrapHints(acc.getAccountName()));
+ ss.setSpan(new StyleSpan(Typeface.BOLD), 0, Misc.addWrapHints(boldAccountName)
+ .length(),
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
accName.setText(ss);
}
.getDefaultColor();
accName.setTextColor(textColor);
accAmount.setTextColor(textColor);
- accName.setText(acc.getAccountName());
+ accName.setText(Misc.addWrapHints(acc.getAccountName()));
}
String comment = acc.getComment();
import org.jetbrains.annotations.Contract;
public class Misc {
+ public static final char ZERO_WIDTH_SPACE = '\u200B';
public static boolean isZero(float f) {
return (f < 0.005) && (f > -0.005);
}
public static void onMainThread(Runnable r) {
new Handler(Looper.getMainLooper()).post(r);
}
+ public static String addWrapHints(String input) {
+ if (input == null)
+ return null;
+ StringBuilder result = new StringBuilder();
+ int lastPos = 0;
+ int pos = input.indexOf(':');
+
+ while (pos >= 0) {
+ result.append(input.substring(lastPos, pos + 1))
+ .append(ZERO_WIDTH_SPACE);
+ lastPos = pos + 1;
+ pos = input.indexOf(':', lastPos + 1);
+ }
+ if (lastPos > 0)
+ result.append(input.substring(lastPos));
+
+ return result.toString();
+ }
}
android:id="@+id/transaction_list_acc_row_acc_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:text="another acc name"
+ android:breakStrategy="high_quality"
android:textAlignment="viewStart"
android:textAppearance="@android:style/TextAppearance.Material.Small"
tools:ignore="HardcodedText"
+ android:hyphenationFrequency="full"
+ android:text="one:very:long:account:name:that:needs:to:wrap:to:more:tnan:one:line:two:would:be:nice:but:the:more:the:better:and:the:better:"
/>
<TextView