Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing the "ago" word #56

Closed
abdulmalekDery opened this issue Mar 20, 2018 · 6 comments
Closed

Removing the "ago" word #56

abdulmalekDery opened this issue Mar 20, 2018 · 6 comments

Comments

@abdulmalekDery
Copy link

Is there any way to remove the "ago" word from the RelativeTimeTextView?
To be more clear
for example if the RelativeTimeTextView is showing this String
"16 min. ago"
can I convert it to
"16 min."
this way is more user friendly ...you know shortest text is always better
thanks in advance

@abdulmalekDery abdulmalekDery changed the title removing the "ago" word Removing the "ago" word Mar 20, 2018
@curioustechizen
Copy link
Owner

@abdulmalekDery With the current implementation this is not possible. That's because this library does not generate the "16 min ago" string - it just uses Android's DateUtils class to get that string. The point of this library is to automatically refresh the text when the time changes.

Also, note that this string will be different depending on the locale.

Having said that, I am willing to explore making the library more flexible such that users have more control over how to display the String. Then, the role of RTTV will be reduced to just auto-refreshing the UI when the time changes, and leaving the exact formatting of the string to the user.

I don't promise anything but I'll look into it.

@abdulmalekDery
Copy link
Author

@curioustechizen Thank you so much
but I think we can remove that word "ago" with a simple hack "I wish we could do that"
because this DataUtils return that String "for example the name of that String is s" we could simply call this methods
if(s.contains(getString(R.string.ago)))
s=s.replace(getString(R.string.ago),"");
I wish this could help

@curioustechizen
Copy link
Owner

@abdulmalekDery Of course, but the point is that the code you shared should be written by the library user. The library should provide a hook for the calling code to customize the text being displayed. It does not make sense to include this code in the library itself.

@abdulmalekDery
Copy link
Author

@curioustechizen yeah ....I 'm just telling the other users how they could remove that word

@curioustechizen
Copy link
Owner

@abdulmalekDery Great idea. Maybe until I get time to improve the API, I should start a "Recipes" section in the wiki where users who have found such solutions can contribute.

@curioustechizen
Copy link
Owner

@abdulmalekDery v1.4.0 has been released with a new feature that allows you to process the relative time string before it is displayed. This can be used to achieve the behaviour you requested - i.e. trimming certain strings before displaying.

Please try out 1.4.0. I'm closing this issue in the meanwhile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants