Skip to content

Commit f605fc4

Browse files
committed
add README
1 parent f20ee29 commit f605fc4

7 files changed

Lines changed: 197 additions & 42 deletions

File tree

README.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# TaskProgressView
2+
3+
A lightweight calendar task progress view library for Android
4+
5+
6+
## GIF
7+
8+
In-app preview
9+
10+
<img src="https://github.com/ibrahimsn98/taskprogressview/blob/master/art/gif.gif" width="480" />
11+
12+
## XML Attributes
13+
14+
```xml
15+
<me.ibrahimsn.lib.TaskProgressView
16+
android:id="@+id/taskProgressView"
17+
android:layout_width="match_parent"
18+
android:layout_height="200dp"
19+
android:layout_marginTop="40dp"
20+
app:rangeLength="7"
21+
app:sidePadding="26dp"
22+
app:taskLineWidth="10dp"
23+
app:taskLineSpacing="32dp" />
24+
```
25+
26+
## Usage
27+
28+
```kotlin
29+
val taskProgressView = findViewById<TaskProgressView>(R.id.taskProgressView)
30+
31+
// Setup with task list
32+
taskProgressView.setTasks(listOf())
33+
34+
// Focus to any date range by giving head of the range
35+
taskProgressView.focusRange(Calendar.getInstance())
36+
```
37+
38+
## Setup
39+
40+
> Follow me on Twitter [@ibrahimsn98](https://twitter.com/ibrahimsn98)
41+
42+
Step 1. Add the JitPack repository to your build file
43+
```groovy
44+
allprojects {
45+
repositories {
46+
...
47+
maven { url 'https://jitpack.io' }
48+
}
49+
}
50+
```
51+
Step 2. Add the dependency
52+
```groovy
53+
dependencies {
54+
implementation 'com.github.ibrahimsn98:taskprogressview:1.0.1'
55+
}
56+
```
57+
58+
## License
59+
```
60+
MIT License
61+
62+
Copyright (c) 2020 İbrahim Süren
63+
64+
Permission is hereby granted, free of charge, to any person obtaining a copy
65+
of this software and associated documentation files (the "Software"), to deal
66+
in the Software without restriction, including without limitation the rights
67+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
68+
copies of the Software, and to permit persons to whom the Software is
69+
furnished to do so, subject to the following conditions:
70+
71+
The above copyright notice and this permission notice shall be included in all
72+
copies or substantial portions of the Software.
73+
74+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
75+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
76+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
77+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
78+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
79+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
80+
SOFTWARE.
81+
```

app/src/main/java/me/ibrahimsn/taskprogress/MainActivity.kt

Lines changed: 49 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import android.graphics.Color
44
import androidx.appcompat.app.AppCompatActivity
55
import android.os.Bundle
66
import android.util.Log
7+
import android.widget.Button
78
import me.ibrahimsn.lib.Task
89
import me.ibrahimsn.lib.TaskProgressView
910
import java.util.*
@@ -13,76 +14,100 @@ class MainActivity : AppCompatActivity() {
1314
super.onCreate(savedInstanceState)
1415
setContentView(R.layout.activity_main)
1516

16-
val task = findViewById<TaskProgressView>(R.id.task)
17+
val taskProgressView = findViewById<TaskProgressView>(R.id.taskProgressView)
1718

18-
task.onTaskClickListener = {
19-
Log.d("###", "Task clicked: $it")
19+
val buttonToday = findViewById<Button>(R.id.buttonToday)
20+
val buttonNextWeek = findViewById<Button>(R.id.buttonNextWeek)
21+
22+
taskProgressView.onTaskClickListener = {
23+
Log.d("###", "On task click: $it")
2024
}
2125

22-
task.setTasks(
26+
taskProgressView.setTasks(
2327
listOf(
2428
Task(
25-
"",
29+
0,
2630
Calendar.getInstance().apply {
27-
this.add(Calendar.DAY_OF_WEEK, 1)
31+
add(Calendar.DAY_OF_WEEK, 1)
2832
},
2933
Calendar.getInstance().apply {
30-
this.add(Calendar.DAY_OF_WEEK, 4)
34+
add(Calendar.DAY_OF_WEEK, 4)
3135
},
3236
60,
37+
1,
3338
Color.parseColor("#f1c40f")
3439
),
3540
Task(
36-
"",
41+
1,
3742
Calendar.getInstance().apply {
38-
this.add(Calendar.DAY_OF_WEEK, 2)
43+
add(Calendar.DAY_OF_WEEK, 2)
3944
},
4045
Calendar.getInstance().apply {
41-
this.add(Calendar.DAY_OF_WEEK, 9)
46+
add(Calendar.DAY_OF_WEEK, 9)
4247
},
4348
80,
49+
2,
4450
Color.parseColor("#5eab3d")
4551
),
4652
Task(
47-
"",
53+
2,
54+
Calendar.getInstance(),
4855
Calendar.getInstance().apply {
49-
this.add(Calendar.DAY_OF_WEEK, 2)
56+
add(Calendar.DAY_OF_WEEK, 5)
5057
},
58+
40,
59+
3,
60+
Color.parseColor("#e74c3c")
61+
),
62+
Task(
63+
3,
5164
Calendar.getInstance().apply {
52-
this.add(Calendar.DAY_OF_WEEK, 5)
65+
add(Calendar.DAY_OF_WEEK, 8)
66+
},
67+
Calendar.getInstance().apply {
68+
add(Calendar.DAY_OF_WEEK, 11)
5369
},
5470
40,
71+
3,
5572
Color.parseColor("#e74c3c")
5673
),
5774
Task(
58-
"",
75+
4,
5976
Calendar.getInstance().apply {
60-
this.add(Calendar.DAY_OF_WEEK, 1)
77+
this.add(Calendar.DAY_OF_WEEK, 5)
6178
},
6279
Calendar.getInstance().apply {
63-
this.add(Calendar.DAY_OF_WEEK, 4)
80+
this.add(Calendar.DAY_OF_WEEK, 12)
6481
},
6582
60,
83+
4,
6684
Color.parseColor("#9b59b6")
6785
),
6886
Task(
69-
"",
87+
5,
7088
Calendar.getInstance().apply {
71-
this.add(Calendar.DAY_OF_WEEK, 1)
89+
add(Calendar.DAY_OF_WEEK, 1)
7290
},
7391
Calendar.getInstance().apply {
74-
this.add(Calendar.DAY_OF_WEEK, 4)
92+
add(Calendar.DAY_OF_WEEK, 4)
7593
},
7694
60,
95+
5,
7796
Color.parseColor("#3498db")
7897
),
7998
)
8099
)
81100

82-
task.focusRange(Calendar.getInstance().apply {
83-
set(Calendar.HOUR_OF_DAY, 0)
84-
set(Calendar.MINUTE, 0)
85-
set(Calendar.SECOND, 0)
86-
})
101+
taskProgressView.focusRange(Calendar.getInstance())
102+
103+
buttonToday.setOnClickListener {
104+
taskProgressView.focusRange(Calendar.getInstance())
105+
}
106+
107+
buttonNextWeek.setOnClickListener {
108+
taskProgressView.focusRange(Calendar.getInstance().apply {
109+
add(Calendar.WEEK_OF_MONTH, 1)
110+
})
111+
}
87112
}
88113
}

app/src/main/res/layout/activity_main.xml

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,54 @@
77
tools:context=".MainActivity">
88

99
<me.ibrahimsn.lib.TaskProgressView
10-
android:id="@+id/task"
10+
android:id="@+id/taskProgressView"
1111
android:layout_width="match_parent"
1212
android:layout_height="200dp"
1313
android:layout_marginTop="40dp"
14+
app:rangeLength="7"
15+
app:sidePadding="26dp"
16+
app:taskLineWidth="10dp"
17+
app:taskLineSpacing="32dp"
1418
app:layout_constraintTop_toTopOf="parent"/>
1519

20+
<LinearLayout
21+
android:layout_width="match_parent"
22+
android:layout_height="wrap_content"
23+
android:orientation="horizontal"
24+
android:paddingHorizontal="12dp"
25+
app:layout_constraintTop_toBottomOf="@id/taskProgressView">
26+
27+
<Button
28+
android:id="@+id/buttonToday"
29+
android:layout_width="wrap_content"
30+
android:layout_height="wrap_content"
31+
android:minHeight="0dp"
32+
android:minWidth="0dp"
33+
android:paddingVertical="8dp"
34+
android:paddingHorizontal="12dp"
35+
android:layout_marginVertical="12dp"
36+
android:layout_marginHorizontal="8dp"
37+
android:text="Today"
38+
android:textColor="#424242"
39+
android:textSize="13sp"
40+
android:textAllCaps="false"/>
41+
42+
<Button
43+
android:id="@+id/buttonNextWeek"
44+
android:layout_width="wrap_content"
45+
android:layout_height="wrap_content"
46+
android:minHeight="0dp"
47+
android:minWidth="0dp"
48+
android:paddingVertical="8dp"
49+
android:paddingHorizontal="12dp"
50+
android:layout_marginVertical="12dp"
51+
android:layout_marginHorizontal="8dp"
52+
android:text="Next Week"
53+
android:textColor="#424242"
54+
android:textSize="13sp"
55+
android:textAllCaps="false"/>
56+
57+
</LinearLayout>
58+
59+
1660
</androidx.constraintlayout.widget.ConstraintLayout>

app/src/main/res/values-v29/themes.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<!-- Customize your theme here. -->
1616

1717
<item name="android:windowBackground">@color/white</item>
18+
<item name="android:windowLightStatusBar">true</item>
1819
<item name="android:forceDarkAllowed">false</item>
1920

2021
</style>

art/gif.gif

2.03 MB
Loading

lib/src/main/java/me/ibrahimsn/lib/Task.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@ import androidx.annotation.ColorInt
44
import java.util.*
55

66
data class Task(
7-
val id: String,
7+
val id: Int,
88
val startDate: Calendar,
99
val endDate: Calendar,
1010
val progress: Int,
11+
val category: Int,
1112
@ColorInt val color: Int,
1213
)
1314

1415
val Task.startTime get() = startDate.timeInMillis.toFloat()
1516

16-
val Task.endTime get() = endDate.timeInMillis.toFloat()
17+
val Task.endTime get() = endDate.timeInMillis.toFloat()
18+
19+
val Task.duration get() = (endTime - startTime) / 86400000

0 commit comments

Comments
 (0)