Git Product home page Git Product logo

Comments (3)

curioustechizen avatar curioustechizen commented on August 14, 2024

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.

ryandt avatar ryandt commented on August 14, 2024

@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.

curioustechizen avatar curioustechizen commented on August 14, 2024

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.