Skip to content

primaverahq/MonthlyActivity

Repository files navigation

MonthlyActivity

Github-style activity view for a month.

JitPack License

Features

  • Setting a month and a year to be shown.
  • Automatic selection of first day of the week based on locale.
  • Customizable tile size and color.
  • Days tiles click events.

Usage

Add the JitPack repository to your project level build.gradle:

allprojects {
 repositories {
    google()
    jcenter()
    maven { url "https://jitpack.io" }
 }
}

Add this to your app build.gradle:

dependencies {
	implementation 'com.github.primaverahq:MonthlyActivity:<latest-version>'
}

Add a view to your XML:

<com.primaverahq.monthlyactivity.MonthlyActivityView
    android:id="@+id/activityView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

Convert your data to Map<Int, Int> where keys are days of month and values are actual values. Note that following java.util.Calendar rules, days are counted from 1 and months are counted from 0. Set a ColorEvaluator and load your data:

val baseColor = Color.parseColor("#ee5454")
activityView.colorEvaluator = LinearAlphaEvaluator(baseColor)
activityView.onTileClickListener = listener
activityView.setData(2019, 11, data)

What is yet to come

  • Test coverage.
  • Animations.
  • More in-built evaluators, if needed.
  • Week and year views.

Contributing

Feel free to join us and make this small library better. Open an issue and/or submit a pull request. Contributions are very welcome.

License

MonthlyActivity is distributed under the MIT license. See LICENSE for details.