Comments (3)
The problem is this library just blindly uses the output of DateUtils. getRelativeTimeSpanString
method and sets it to the TextView.
A probable solution is to provide a way for users of the library to manipulate the output of DateUtils. getRelativeTimeSpanString
before setting it to the TextView. This would allow various customizations like adding prefixes/suffixes, changing the styles of only certain parts of the text (like making just the number bold or a different color), capitalizing etc. I still haven't figured out an elegant way to achieve this.
In the meantime one could special case the capitalization for English alone based on what you describe should be the expected behavior, but I'm not convinced about this.
from android-ago.
@curioustechizen Thanks for sharing that. I agree with allowing for text customizations before the text gets set on the TextView
.
What's your thoughts on allowing the client to pass in a "relative_time_formats.xml" file to the library that allows the client to override format values for the locales and time formats he wishes to customize? The XML file would contain specific identifiers that identify each relative time format, somewhat similar to the FORMAT_*
constants described in Android's DateUtils
class. An example ID might be format_yesterday
where the default would be "Yesterday" (from DateUtils.getRelativeTimeSpanString
). If the client provides a custom value such as That was so yesterday
, that value would be used instead. The client would also be able to pass in styling properties using CSS and format identifiers if necessary.
I'm not 100% sold on this yet. Just wanted to toss the thought out there for discussion. I'll think over this a bit more.
from android-ago.
@ryandt v1.4.0 of this library has been released. This release has a solution to the problem you put forth: you can override a method which gives you a chance to process the text returned by DateUtils before it is set to the UI.
While it is not as elegant as I hoped to make it, at least it gives maximum flexibility with minimum effort for me as the library maintainer :)
Please try it out and let me know if it works well for you. I'm closing this issue for now.
from android-ago.
Related Issues (20)
- Time ago calculation HOT 13
- Strings in Portuguese
- in 0 mins HOT 14
- Now LATEST_VERSION is what ? HOT 2
- A String Completed added prior to time HOT 3
- Once the `UpdateTimeRunnable` is detached and the `weakRefRttv` cleared, it is never attached again HOT 4
- Add automated tests HOT 4
- Change lang of "hours ago" ... HOT 1
- Locale HOT 1
- Time is one hour behind on old Galaxy Tab 3 using Android 4.4.2 HOT 3
- add font family option HOT 6
- this work fine in recyclerviews? HOT 1
- Removing the "ago" word HOT 6
- Save timeago when close the app HOT 1
- Add a `getReferenceTime()` method
- Modify time update interval HOT 1
- Text format has extra charcters in it HOT 2
- Enhancement - short suffix HOT 1
- In new update, issue with Just Now
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from android-ago.