Skip to content

Commit f84c977

Browse files
committed
Unify naming of attributes, update readme
1 parent 9f3255b commit f84c977

File tree

6 files changed

+35
-27
lines changed

6 files changed

+35
-27
lines changed

README.md

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,16 @@ behavior of classic ViewPager
2020

2121
| :heavy_check_mark: Overflowed indicators | :x: Classic confusing indicators |
2222
| ----------------------- | ------------------------------- |
23-
| ![Widget effect animation preview](docs/images/overflow-pager-indicator.gif "Preview of widget effect of animating dots during pages swiping") | ![Classic ](docs/images/classic-indicators.png "Fujky") |
23+
| ![Widget effect animation preview](docs/images/overflow-pager-indicator.gif "Preview of widget effect of animating dots during pages swiping") | ![Classic ](docs/images/classic-indicators.png "Confusing") |
2424

2525
_Disclaimer: Having too many pages in recycler means that user needs to swipe a lot. Different layout/ui may be more user friendly._
2626

2727
## Usage
2828

29+
### Migration to 3.1 from 3.0
30+
31+
`dotFillColor` and `dotStrokeColor` were renamed to `indicatorFillColor` and `indicatorStrokeColor`
32+
2933
### Migration to 3.0 from 2.x
3034

3135
Make sure you have Jitpack dependency in root gradle file.
@@ -49,7 +53,7 @@ buildscript {
4953
In you module gradle add dependency to library:
5054

5155
```gradle
52-
implementation "cz.intik:overflow-pager-indicator:$latestVersion" // 3.0.1
56+
implementation "cz.intik:overflow-pager-indicator:$latestVersion" // 3.1.0
5357
```
5458

5559
### Layout
@@ -73,8 +77,8 @@ Some layout with RecyclerView and OverflowPagerIndicator
7377
android:layout_width="wrap_content"
7478
android:layout_height="wrap_content"
7579
android:layout_gravity="center_horizontal|bottom"
76-
app:dotFillColor="#FF0000"
77-
app:dotStrokeColor="#0000FF"
80+
app:indicatorFillColor="#FF0000"
81+
app:indicatorStrokeColor="#0000FF"
7882
/>
7983

8084
</FrameLayout>
@@ -115,13 +119,17 @@ viewOverflowPagerIndicator.onPageSelected(position)
115119
You can easily change dot fill color and dot stroke color via xml attributes like this:
116120
```xml
117121
<cz.intik.overflowindicator.OverflowPagerIndicator
118-
app:dotFillColor="#FF0000"
119-
app:dotStrokeColor="@color/heavenlyBlue"
122+
app:indicatorFillColor="#FF0000"
123+
app:indicatorStrokeColor="@color/heavenlyBlue"
124+
app:indicatorMargin="6dp"
125+
app:indicatorSize="22dp"
120126
/>
121127
```
122128

123129
### Changelog
124130

131+
3.1.0 Add customization of indicator size and margin. Unify naming of attributes to "indicatorXxx" instead of "dotXxx"
132+
125133
3.0.1 Remove library from Bintray, use simply Jitpack. Convert library to Kotlin and update to TransitionsEverywhere 2.0 (which uses androidx.transition.X heavily)
126134

127135
2.0.0 Migrate to AndroidX, add color customization options (big thanks [Javi Chaqués](https://github.com/javichaques))

overflow-library/src/main/java/cz/intik/overflowindicator/OverflowPagerIndicator.kt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,22 @@ class OverflowPagerIndicator(context: Context, attrs: AttributeSet) : LinearLayo
3434
var indicatorMargin: Int = -1
3535
private set
3636

37-
var dotStrokeColor: Int = -1
37+
var indicatorStrokeColor: Int = -1
3838
private set
3939

40-
var dotFillColor: Int = -1
40+
var indicatorFillColor: Int = -1
4141
private set
4242

4343
private val dataObserver: OverflowDataObserver
4444
private var indicatorCount: Int = 0
4545
private var lastSelected: Int = 0
4646
private var recyclerView: RecyclerView? = null
4747

48-
private val dotDrawable: Drawable
48+
private val indicatorDrawable: Drawable
4949
get() = GradientDrawable().apply {
5050
shape = GradientDrawable.OVAL
51-
setColor(dotFillColor)
52-
setStroke(Util.dpToPx(0.5), dotStrokeColor)
51+
setColor(indicatorFillColor)
52+
setStroke(Util.dpToPx(0.5), indicatorStrokeColor)
5353
}
5454

5555
init {
@@ -59,8 +59,8 @@ class OverflowPagerIndicator(context: Context, attrs: AttributeSet) : LinearLayo
5959
}
6060

6161
private fun initAttrs(context: Context, attrs: AttributeSet?) {
62-
dotFillColor = ContextCompat.getColor(context, R.color.dot_fill)
63-
dotStrokeColor = ContextCompat.getColor(context, R.color.dot_stroke)
62+
indicatorFillColor = ContextCompat.getColor(context, R.color.indicatorFill)
63+
indicatorStrokeColor = ContextCompat.getColor(context, R.color.indicatorStroke)
6464
indicatorSize = context.resources.getDimensionPixelSize(R.dimen.indicator_size)
6565
indicatorMargin = context.resources.getDimensionPixelSize(R.dimen.indicator_margin)
6666

@@ -70,11 +70,11 @@ class OverflowPagerIndicator(context: Context, attrs: AttributeSet) : LinearLayo
7070
context.obtainStyledAttributes(attrs, R.styleable.OverflowPagerIndicator)
7171

7272
try {
73-
dotFillColor = attributeArray
74-
.getColor(R.styleable.OverflowPagerIndicator_dotFillColor, dotFillColor)
73+
indicatorFillColor = attributeArray
74+
.getColor(R.styleable.OverflowPagerIndicator_indicatorFillColor, indicatorFillColor)
7575

76-
dotStrokeColor = attributeArray
77-
.getColor(R.styleable.OverflowPagerIndicator_dotStrokeColor, dotStrokeColor)
76+
indicatorStrokeColor = attributeArray
77+
.getColor(R.styleable.OverflowPagerIndicator_indicatorStrokeColor, indicatorStrokeColor)
7878

7979
indicatorSize = attributeArray
8080
.getDimensionPixelSize(
@@ -216,7 +216,7 @@ class OverflowPagerIndicator(context: Context, attrs: AttributeSet) : LinearLayo
216216

217217
private fun addIndicator(isOverflowState: Boolean, indicatorSize: Int, margin: Int) {
218218
val view = View(context)
219-
view.background = dotDrawable
219+
view.background = indicatorDrawable
220220

221221
animateViewScale(view, if (isOverflowState) STATE_SMALLEST else STATE_NORMAL)
222222

overflow-library/src/main/res/drawable/dot.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
<stroke
66
android:width="0.5dp"
7-
android:color="@color/dot_stroke"/>
7+
android:color="@color/indicatorStroke"/>
88

9-
<solid android:color="@color/dot_fill"/>
9+
<solid android:color="@color/indicatorFill"/>
1010

1111
</shape>

overflow-library/src/main/res/values/attrs.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources>
33
<declare-styleable name="OverflowPagerIndicator">
4-
<attr name="dotFillColor" format="color"/>
5-
<attr name="dotStrokeColor" format="color"/>
4+
<attr name="indicatorFillColor" format="color"/>
5+
<attr name="indicatorStrokeColor" format="color"/>
66
<attr name="indicatorSize" format="dimension" />
77
<attr name="indicatorMargin" format="dimension" />
88
</declare-styleable>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources>
3-
<color name="dot_fill">#EEFFFFFF</color>
4-
<color name="dot_stroke">#99CCCCCC</color>
3+
<color name="indicatorFill">#EEFFFFFF</color>
4+
<color name="indicatorStroke">#99CCCCCC</color>
55
</resources>

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
xmlns:tools="http://schemas.android.com/tools"
55
android:layout_width="match_parent"
66
android:layout_height="match_parent"
7-
android:background="@color/dot_stroke"
7+
android:background="@color/indicatorStroke"
88
android:orientation="vertical"
99
tools:context=".MainActivity">
1010

@@ -40,8 +40,8 @@
4040
android:layout_width="wrap_content"
4141
android:layout_height="wrap_content"
4242
android:layout_gravity="center"
43-
app:dotFillColor="@color/colorAccent"
44-
app:dotStrokeColor="#0000FF" />
43+
app:indicatorFillColor="@color/colorAccent"
44+
app:indicatorStrokeColor="#0000FF" />
4545
</FrameLayout>
4646

4747
<FrameLayout

0 commit comments

Comments
 (0)