Skip to content
This repository was archived by the owner on Jun 9, 2023. It is now read-only.

Replicate element coloring with icons #305

Merged
merged 17 commits into from
Sep 22, 2020

Conversation

AbsurdlySuspicious
Copy link
Collaborator

Fixes #301
dawn_icons_preview

@Tunous
Copy link
Owner

Tunous commented Aug 18, 2020

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.

@AbsurdlySuspicious
Copy link
Collaborator Author

AbsurdlySuspicious commented Aug 18, 2020

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)

@Tunous
Copy link
Owner

Tunous commented Aug 18, 2020

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.

@AbsurdlySuspicious
Copy link
Collaborator Author

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

@binocry
Copy link

binocry commented Sep 2, 2020

I hope the icons are the same as reddit so users have the same feeling when moving from reddit website to this app

msfjarvis added a commit to msfjarvis/Dawn that referenced this pull request Sep 8, 2020

Verified

This commit was signed with the committer’s verified signature.
msfjarvis Harsh Shandilya
…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
@AbsurdlySuspicious
Copy link
Collaborator Author

Span centers them between borders of tallest and lowest glyph

Looks like this approach is inconsistent between different fonts and current implementation is optimal exclusively for Roboto. On the contrary, ALIGN_CENTER implementation from api 29 sdk is inconsistent between single and multi-line textviews due to extra line spacing and I'm not sure which one is better. I also tried icon font approach (using TypefaceSpan) back then and it looks terrible. Any ideas?

@Tunous Tunous force-pushed the color_icons/feature branch from 50f9a59 to 688993b Compare September 11, 2020 10:39
@Tunous
Copy link
Owner

Tunous commented Sep 11, 2020

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
Copy link
Collaborator Author

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

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to know.

Copy link
Collaborator Author

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
Copy link
Collaborator Author

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
Copy link
Collaborator Author

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

Copy link
Owner

@Tunous Tunous left a 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

Copy link
Collaborator

@msfjarvis msfjarvis left a 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) {
Copy link
Collaborator

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.

Copy link
Owner

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 :)

Copy link
Collaborator Author

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

@Tunous Tunous added this to the 0.11.0 milestone Sep 22, 2020
@Tunous Tunous merged commit 1592ad5 into Tunous:master Sep 22, 2020
@Minnona
Copy link

Minnona commented Sep 23, 2020

Well, guess it's too late to comment on this. To me these arrows seem like an unnecessary duplication.

@AbsurdlySuspicious AbsurdlySuspicious deleted the color_icons/feature branch January 23, 2021 05:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Better distinguish OP's comments
5 participants