GitHub-like ActivityView for android.
Get the AAR from GitHub Packages via Gradle:
implementation 'de.philcd:activityview:<version>'
To be able to access the library you need to authenticate to GitHub Packages. Therefore, add the GitHub Packages maven repository to your repositories list:
maven {
url 'https://maven.pkg.github.com/phil-cd/ActivityView'
credentials {
username = '<username>'
password = '<access_token>'
}
}
The following example code creates an activity view with random activities over the past 40 weeks.
// create map for activity values
val activities : MutableMap<Calendar, Int> = mutableMapOf()
// configure number of weeks that should be shown
val numWeeksToShow = 40
// generate some random activities
val currentCalendar = Calendar.getInstance()
currentCalendar.add(DAY_OF_YEAR, -7*numWeeksToShow)
while(currentCalendar < Calendar.getInstance()) {
val activityCalendar = currentCalendar.clone() as Calendar
val rand = Random().nextInt(10)
activities[activityCalendar] = if (rand < 4) 0 else rand
currentCalendar.add(DAY_OF_YEAR, 1)
}
// show activity view
ActivityView(activities = activities, numWeeksToShow = numWeeksToShow)
The color of activity items can be configured using minColor
and maxColor
.
val minColor = Color(185, 214, 245, 255)
val maxColor = Color(64, 139, 252, 255)
ActivityView(activities = activities, numWeeksToShow = numWeeksToShow, minColor = minColor, maxColor = maxColor)
The color for entries with no activity can be configured using noActivityColor
.
The shape of the activity entries and the font size of the labels can be configured using the boxShape
and monthLabelFontSize
arguments.