Coder Social home page Coder Social logo

Comments (2)

curioustechizen avatar curioustechizen commented on May 25, 2024 1

@YuvPrime With the current implementation this might be impossible. The library uses [getRelativeTimeSpanString](https://developer.android.com/reference/android/text/format/DateUtils.html#getRelativeTimeSpanString%28long, long, long, int%29) from DateUtils class in the Android SDK. It already passes the flag FORMAT_ABBREV_RELATIVE so relative times are already abbreviated. For example, instead of 5 minutes ago it displays 5 mins ago. Beyond this, the entire String is returned by the DateUtils class and android-ago simply sets this text on the TextView. Here is the code from RelativeTimeTextView.java:

private CharSequence getRelativeTimeDisplayString() {
    long now = System.currentTimeMillis();
    long difference = now - mReferenceTime; 
    return (difference >= 0 &&  difference<=DateUtils.MINUTE_IN_MILLIS) ? 
            getResources().getString(R.string.just_now): 
            DateUtils.getRelativeTimeSpanString(
                mReferenceTime,
                now,
                DateUtils.MINUTE_IN_MILLIS,
                DateUtils.FORMAT_ABBREV_RELATIVE);
}

My suggestion to you is to look at the DateUtils class - it has a very large number of options and flags - one of those might allow you to further customize the time text. You can then fork android-ago and call the appropriate method of DateUtils here.

However do note that DateUtils is locale-sensitive. The time string it returns changes based on locale settings. If you customize it you might lose the customizations in other languages.

I will keep this issue open and explore if it makes sense to expose the various flags of DateUtils class as custom attributes on RTTV. Any suggestions on this are welcome!

from android-ago.

curioustechizen avatar curioustechizen commented on May 25, 2024

@YuvPrime v1.4.0 lets you customize the text before it is displayed.

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.