-
Notifications
You must be signed in to change notification settings - Fork 35
Replicate element coloring with icons #305
Replicate element coloring with icons #305
Conversation
Do we actually need a setting for this feature? These icons look very nice and don't seem to clutter the view. It seems to me like they could be always on. |
I think we can just rephrase and enable it by default, something like "More icons", because I'm sure some people like cleaner look more (like me :P) |
I'm personally more into "Less settings is better" thinking nowadays in aspect of UI and UX. The argument for it is based on the fact that growing amount of possible settings increases code and UX complexity. Not only we have more code paths to maintain, we make it harder (marginally but still) for the app to define its own distinguishing style. As settings like this will grow the app will become more and more confusing for the majority of users entering settings screen. In this case I don't see huge value in a new setting and don't see how the interface becomes cluttered with new icons, but perhaps I'm missing something 😄 But if others disagree with me then let's go with enabling it by default with changed text. |
I removed preference from this branch. When time comes for the next release, if nobody else will voice their opinion, let's merge it as is. I also added some vertical offset for icons to center them properly. Span centers them between borders of tallest and lowest glyph so with the "common case" text they was visually skewed to the top. This offset should look identical on all devices |
I hope the icons are the same as reddit so users have the same feeling when moving from reddit website to this app |
…ture Replicate element coloring with icons * github.com:Tunous/Dawn: Update changelog entry Remove preference gates Revert c3598f8, 9d13eca (remove preference) Add vertical offset sp to px units conversion Fix tests Changelog Add preference use centering based on font metrics OP comment icon Vote icon for comments Vote direction icon CenterAlignedImageSpan fix invalid icon name
app/src/main/java/me/saket/dank/ui/submission/SubmissionCommentTreeUiConstructor.java
Outdated
Show resolved
Hide resolved
app/src/main/java/me/saket/dank/widgets/span/CenterAlignedImageSpan.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/me/saket/dank/widgets/span/CenterAlignedImageSpan.kt
Outdated
Show resolved
Hide resolved
Looks like this approach is inconsistent between different fonts and current implementation is optimal exclusively for Roboto. On the contrary, |
50f9a59
to
688993b
Compare
I've pushed a modification where I'm passing in the extra line spacing where it's used. Not the best solution but it appears to look correctly with the fonts I've tested (didn't check all). |
val b = getCachedDrawable() | ||
val drawable = getCachedDrawable() | ||
val drawableHeight = drawable.bounds.height() | ||
val translationY = (bottom - top - drawableHeight - lineSpacingExtra) / 2f |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The thing is extra line spacing is not applied to the last line of text. For some reason, it's included in bottom
value (unlike ordinary line spacing) and thus it's different for last line and all other lines. So this change just "inverts" vertical skew, making icon offset negative for single-line textviews
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I forgot to mark this as resolved, I was still thinking what to do with it at the moment of posting this :)
@@ -13,7 +13,8 @@ class CenterAlignedImageSpan(drawable: Drawable, private val lineSpacingExtra: I | |||
start: Int, end: Int, x: Float, | |||
top: Int, y: Int, bottom: Int, paint: Paint) { | |||
val drawableHeight = drawable.bounds.height() | |||
val translationY = (bottom - top - drawableHeight - lineSpacingExtra) / 2f | |||
val realExtraSpacing = if (canvas.clipBounds.bottom != bottom) lineSpacingExtra else 0 // extra line spacing is not applied to last line |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dirty but works
@@ -13,7 +13,8 @@ class CenterAlignedImageSpan(drawable: Drawable, private val lineSpacingExtra: I | |||
start: Int, end: Int, x: Float, | |||
top: Int, y: Int, bottom: Int, paint: Paint) { | |||
val drawableHeight = drawable.bounds.height() | |||
val translationY = (bottom - top - drawableHeight - lineSpacingExtra) / 2f | |||
val realExtraSpacing = if (canvas.clipBounds.bottom != bottom) lineSpacingExtra else 0 // extra line spacing is not applied to last line | |||
val translationY = top + (bottom - top - drawableHeight - realExtraSpacing) / 2f |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
top +
allows to use this span in lines other than first
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For me looks good
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been using it for a while and haven't found any obvious flaws with either the code or the actual functionality.
|
||
object ColorReplicationIcons { | ||
@JvmStatic fun pushIcon(context: Context, builder: Truss, sizeDimenResId: Int, | ||
drawableResId: Int, tintColor: Int, lineSpacingExtra: Int) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure what the project policy is but annotating these parameters with @DrawableRes
, @ColorRes
and @DimenRes
would probably not be a bad idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm voting for including these :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for such a long delay, I'll address it in a separate PR
Well, guess it's too late to comment on this. To me these arrows seem like an unnecessary duplication. |
Fixes #301
