Skip to content

Commit b70c74d

Browse files
committed
Arc border added
1 parent 4348f65 commit b70c74d

File tree

11 files changed

+635
-178
lines changed

11 files changed

+635
-178
lines changed

app/build.gradle

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@ android {
2222
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
2323
}
2424
}
25+
26+
compileOptions {
27+
targetCompatibility JavaVersion.VERSION_1_8
28+
sourceCompatibility JavaVersion.VERSION_1_8
29+
}
30+
31+
kotlinOptions {
32+
jvmTarget = JavaVersion.VERSION_1_8.toString()
33+
}
2534
}
2635

2736
dependencies {

app/src/main/java/com/goodayapps/avatarview/MainActivity.kt

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import android.widget.SeekBar
66
import androidx.appcompat.app.AppCompatActivity
77
import com.goodayapps.widget.AvatarDrawable
88
import com.goodayapps.widget.AvatarView
9+
import com.goodayapps.widget.avatarDrawable
910
import kotlinx.android.synthetic.main.activity_main.*
1011

1112
class MainActivity : AppCompatActivity() {
@@ -66,10 +67,10 @@ class MainActivity : AppCompatActivity() {
6667
avVolumetric.setOnCheckedChangeListener { _, checkedId ->
6768
applyToAvatars {
6869
it.volumetricType = when (checkedId) {
69-
R.id.avVolumetricAll -> AvatarDrawable.VolumetricType.ALL
70-
R.id.avVolumetricDrawable -> AvatarDrawable.VolumetricType.DRAWABLE
71-
R.id.avVolumetricPlaceholder -> AvatarDrawable.VolumetricType.PLACEHOLDER
72-
else -> AvatarDrawable.VolumetricType.NONE
70+
R.id.avVolumetricAll -> AvatarDrawable.Volumetric.ALL
71+
R.id.avVolumetricDrawable -> AvatarDrawable.Volumetric.DRAWABLE
72+
R.id.avVolumetricPlaceholder -> AvatarDrawable.Volumetric.PLACEHOLDER
73+
else -> AvatarDrawable.Volumetric.NONE
7374
}
7475
}
7576
}
@@ -81,23 +82,28 @@ class MainActivity : AppCompatActivity() {
8182
}
8283
})
8384

84-
avAngle.setOnSeekBarChangeListener(object : OnSeekBarChangeListener() {
85+
archesDegreeArea.setOnSeekBarChangeListener(object : OnSeekBarChangeListener() {
8586
override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) {
8687
applyToAvatars {
87-
it.labelTextAngle = progress
88+
it.archesDegreeArea = progress
8889
}
8990
}
9091
})
9192

92-
avLabelBgWidth.setOnSeekBarChangeListener(object : OnSeekBarChangeListener() {
93+
archesCount.setOnSeekBarChangeListener(object : OnSeekBarChangeListener() {
9394
override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) {
9495
applyToAvatars {
95-
it.labelBackgroundWidth = convertDpToPixel(progress)
96+
it.archesCount = progress
97+
}
98+
}
99+
})
100+
archesAngle.setOnSeekBarChangeListener(object : OnSeekBarChangeListener() {
101+
override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) {
102+
applyToAvatars {
103+
it.archesAngle = progress
96104
}
97105
}
98106
})
99-
100-
101107
}
102108

103109
private inline fun applyToAvatars(action: (AvatarView) -> Unit) {

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

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,22 @@
2424
android:id="@+id/avatarView0"
2525
android:layout_width="@dimen/avatar_size"
2626
android:layout_height="@dimen/avatar_size"
27+
android:src="@drawable/ic_round_bug_report"
28+
android:visibility="gone"
2729
app:avBorderColor="#FF0000"
2830
app:avBorderColorSecondary="#FF9D00"
29-
app:avBorderWidth="5dp"
3031
app:avBorderGradientAngle="135"
31-
app:placeholderText="OMG"
32-
android:src="@drawable/ic_round_bug_report" />
32+
app:avBorderWidth="5dp"
33+
app:placeholderText="OMG" />
3334

3435
<com.goodayapps.widget.AvatarView
3536
android:id="@+id/avatarView1"
3637
android:layout_width="@dimen/avatar_size"
3738
android:layout_height="@dimen/avatar_size"
3839
android:src="@drawable/ic_launcher_foreground"
40+
app:avArchesAngle="0"
41+
app:avArchesCount="4"
42+
app:avArchesDegreeArea="90"
3943
app:avAvatarMargin="5dp"
4044
app:avBackgroundColor="@color/colorPrimary"
4145
app:avBorderColor="#4D8989A8"
@@ -50,6 +54,7 @@
5054
android:layout_width="@dimen/avatar_size"
5155
android:layout_height="@dimen/avatar_size"
5256
android:src="@drawable/avatar1"
57+
android:visibility="gone"
5358
app:avBackgroundColor="@color/colorPrimary"
5459
app:avBorderColor="@color/colorAccent"
5560
app:avBorderWidth="5dp" />
@@ -59,6 +64,7 @@
5964
android:layout_width="@dimen/avatar_size"
6065
android:layout_height="@dimen/avatar_size"
6166
android:fontFamily="@font/font_19849"
67+
android:visibility="gone"
6268
app:avBackgroundColor="@color/colorPrimary"
6369
app:avBorderColor="@color/colorAccent"
6470
app:avBorderWidth="5dp"
@@ -221,17 +227,41 @@
221227
android:layout_width="match_parent"
222228
android:layout_height="wrap_content"
223229
android:layout_weight="1.5"
224-
android:text="avLabelBgWidth"
230+
android:text="archesCount"
225231
android:textColor="@android:color/white"
226232
tools:ignore="HardcodedText" />
227233

228234
<SeekBar
229-
android:id="@+id/avLabelBgWidth"
235+
android:id="@+id/archesCount"
230236
android:layout_width="match_parent"
231237
android:layout_height="wrap_content"
232238
android:layout_weight="1"
233239
android:max="15"
234-
android:progress="5" />
240+
android:progress="0" />
241+
</LinearLayout>
242+
243+
<LinearLayout
244+
android:layout_width="match_parent"
245+
android:layout_height="wrap_content"
246+
android:orientation="horizontal">
247+
248+
<androidx.appcompat.widget.AppCompatTextView
249+
android:layout_width="match_parent"
250+
android:layout_height="wrap_content"
251+
android:layout_weight="1.5"
252+
android:ellipsize="end"
253+
android:maxLines="1"
254+
android:text="archesDegreeArea"
255+
android:textColor="@android:color/white"
256+
tools:ignore="HardcodedText" />
257+
258+
<SeekBar
259+
android:id="@+id/archesDegreeArea"
260+
android:layout_width="match_parent"
261+
android:layout_height="wrap_content"
262+
android:layout_weight="1"
263+
android:max="360"
264+
android:progress="0" />
235265
</LinearLayout>
236266

237267
<LinearLayout
@@ -245,12 +275,12 @@
245275
android:layout_weight="1.5"
246276
android:ellipsize="end"
247277
android:maxLines="1"
248-
android:text="avLabelTextAngle"
278+
android:text="archesAngle"
249279
android:textColor="@android:color/white"
250280
tools:ignore="HardcodedText" />
251281

252282
<SeekBar
253-
android:id="@+id/avAngle"
283+
android:id="@+id/archesAngle"
254284
android:layout_width="match_parent"
255285
android:layout_height="wrap_content"
256286
android:layout_weight="1"

app/src/main/res/values/dimens.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources>
3-
<dimen name="avatar_size">80dp</dimen>
3+
<dimen name="avatar_size">120dp</dimen>
44
</resources>
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
22
package="com.goodayapps.widget">
33

4-
/
54
</manifest>

0 commit comments

Comments
 (0)