Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Nielssg committed May 23, 2022
2 parents 65ca1c0 + 1d94160 commit b499057
Show file tree
Hide file tree
Showing 11 changed files with 426 additions and 176 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ If applicable, add screenshots to help explain your problem.
**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Library version [e.g. 0.5.1]
- Library version [e.g. 0.6.0]

**Additional context**
Add any other context about the problem here.
44 changes: 44 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Build APK

on:
push:
branches: [ develop ]

jobs:
build:
name: Setup Environment and build
runs-on: ubuntu-latest
timeout-minutes: 20

steps:
- uses: actions/[email protected]

- name: Set up JDK
uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: '11'

- name: Setup Android SDK
uses: android-actions/[email protected]

- uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Make gradlew executable
run: chmod +x ./gradlew

- name: Generate apk
run: ./gradlew sample:assembleDebug --stacktrace

- name: Upload APK
uses: actions/upload-artifact@v3
with:
name: staging-debug.apk
path: sample/build/outputs/apk/debug/sample-debug.apk
80 changes: 49 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Also add the SquircleView dependency to your app build.gradle

```groovy
dependencies {
implementation "app.juky:squircleview:0.5.1"
implementation "app.juky:squircleview:0.6.0"
}
```

Expand Down Expand Up @@ -104,8 +104,8 @@ This view extends the `AppCompatTextView`, which you can use to have a squircle
android:padding="16dp"
android:text="Normal button"
android:textColor="#FFFFFF"
app:squircle_gradient_end_color="#415FFF"
app:squircle_gradient_start_color="#5BA7FF"
app:squircle_background_gradient_end_color="#415FFF"
app:squircle_background_gradient_start_color="#5BA7FF"
app:squircle_shadow_elevation="2dp"/>
```

Expand All @@ -120,8 +120,8 @@ complex layout with texts and icons.
android:layout_width="72dp"
android:layout_height="72dp"
android:padding="16dp"
app:squircle_gradient_end_color="#415FFF"
app:squircle_gradient_start_color="#5BA7FF"
app:squircle_background_gradient_end_color="#415FFF"
app:squircle_background_gradient_start_color="#5BA7FF"
app:squircle_shadow_elevation="2dp">

<!-- Embed whatever widget you would like, in this case an icon -->
Expand Down Expand Up @@ -162,21 +162,25 @@ Glide.with(this).load(R.drawable.my_image)
The following attributes can be used in your styles.xml / themes.xml or as attribute of the view in your layout xml
files.

| Attribute | Type | Default | Description |
|--------------------------------------|-----------|------------------------------------|------------------------------------------------------------|
| squircle_background_image | reference | | Background image of view |
| squircle_background_color | color | #000000 | Background color of view |
| squircle_gradient_drawable | reference | | Gradient drawable displayed in view |
| squircle_gradient_start_color | color | | Gradient start color |
| squircle_gradient_end_color | color | | Gradient end color |
| squircle_gradient_direction | enum | TOP_LEFT_BOTTOM_RIGHT | Direction of the gradient (only for the color gradient) |
| squircle_shadow_elevation | dimension | Default of the super view | Shadow elevation |
| squircle_shadow_elevation_color | color | #42000000 | Shadow elevation color |
| squircle_border_color | color | | Border color |
| squircle_border_width | dimension | 0 | Border width |
| squircle_ripple_enabled | boolean | true (false for SquircleImageView) | Ripple enabled or disabled (when a click listener is set) |
| squircle_ripple_drawable | reference | ?attr/selectableItemBackground | Drawable used for drawing the ripple |
| squircle_corner_smoothing_percentage | integer | 100% | Change the corner smoothing, a Squircle is 100% by default |
| Attribute | Type | Default | Description |
|------------------------------------------|-----------|------------------------------------|--------------------------------------------------------------------|
| squircle_background_image | reference | | Background image of view |
| squircle_background_color | color | #000000 | Background color of view |
| squircle_background_gradient_drawable | reference | | Background gradient drawable displayed in view |
| squircle_background_gradient_start_color | color | | Background gradient start color |
| squircle_background_gradient_end_color | color | | Background gradient end color |
| squircle_background_gradient_direction | enum | TOP_LEFT_BOTTOM_RIGHT | Direction of the background gradient (only for the color gradient) |
| squircle_shadow_elevation | dimension | Default of the super view | Shadow elevation |
| squircle_shadow_elevation_color | color | #42000000 | Shadow elevation color |
| squircle_border_color | color | | Border color |
| squircle_border_gradient_drawable | reference | | Border gradient drawable displayed in view |
| squircle_border_gradient_start_color | color | | Border gradient start color |
| squircle_border_gradient_end_color | color | | Border gradient end color |
| squircle_border_gradient_direction | enum | TOP_LEFT_BOTTOM_RIGHT | Direction of the border gradient (only for the color gradient) |
| squircle_border_width | dimension | 0 | Border width |
| squircle_ripple_enabled | boolean | true (false for SquircleImageView) | Ripple enabled or disabled (when a click listener is set) |
| squircle_ripple_drawable | reference | ?attr/selectableItemBackground | Drawable used for drawing the ripple |
| squircle_corner_smoothing_percentage | integer | 100% | Change the corner smoothing, a Squircle is 100% by default |

### Methods

Expand All @@ -192,23 +196,31 @@ var backgroundColorRes: Int
var shadowElevation: Float
var shadowElevationColor: Int
var shadowElevationColorRes: Int
var gradientDrawable: GradientDrawable?
var gradientStartColor: Int
var gradientStartColorRes: Int
var gradientEndColor: Int
var gradientEndColorRes: Int
var gradientDirection: GradientDirection
var backgroundGradientDrawable: GradientDrawable?
var backgroundGradientStartColor: Int
var backgroundGradientStartColorRes: Int
var backgroundGradientEndColor: Int
var backgroundGradientEndColorRes: Int
var backgroundGradientDirection: GradientDirection
var borderColor: Int
var borderColorRes: Int
var borderGradientDrawable: GradientDrawable?
var borderGradientStartColor: Int
var borderGradientStartColorRes: Int
var borderGradientEndColor: Int
var borderGradientEndColorRes: Int
var borderGradientDirection: GradientDirection
var borderWidth: Float
var rippleEnabled: Boolean

// Methods
fun setCornerSmoothing(cornerSmoothing: Int)
fun setBackgroundImage(drawable: Drawable?)
fun setBackgroundImage(resId: Int)
fun setGradientDrawable(resId: Int)
fun setGradientDirection(angle: Int)
fun setBackgroundGradientDrawable(resId: Int)
fun setBackgroundGradientDirection(angle: Int)
fun setBorderGradientDrawable(resId: Int)
fun setBorderGradientDirection(angle: Int)


fun getCornerSmoothing(): Int
Expand Down Expand Up @@ -279,11 +291,11 @@ implementation, which is called `SquircleCornerTreatment`.
- [ ] Check Java support
- [ ] Performance testing with lots of bitmaps
- [ ] Add tests
- [ ] Code documentation
- [X] Code documentation
- [ ] Option to determine text color by background / image
- [ ] Use precise angle of gradient instead of matching it to a segment
- [ ] Improve outer shadow boundaries
- [ ] Jetpack compose support
- [X] Jetpack compose support
- [ ] Reduce `invalidate()` calls when changing multiple style properties

## Contributing
Expand Down Expand Up @@ -322,6 +334,12 @@ Check out the [CONTRIBUTING.md](CONTRIBUTING.md) file to know more

## Changelog

- V0.6.0 (23 may 2022)
- Breaking change:
Border gradients have been added, so existing gradient methods are now prefixed with `background_`
- Methods renamed: `gradientDrawable` to `backgroundGradientDrawable`, `gradientStartColor` to `backgroundGradientStartColor`, `gradientStartColorRes` to `backgroundGradientStartColorRes`, `gradientEndColor` to `backgroundGradientEndColor`, `gradientEndColorRes` to `backgroundGradientEndColorRes`, `gradientDirection` to `backgroundGradientDirection`
- Attributes renamed: `squircle_gradient_drawable` to `squircle_background_gradient_drawable`, `squircle_gradient_start_color` to `squircle_background_gradient_start_color`, `squircle_gradient_end_color` to `squircle_background_gradient_end_color`, `squircle_gradient_direction` to `squircle_background_gradient_direction`
- Added border gradient support
- V0.5.1 (20 may 2022)
- Android Studio previews would fail due to issues with attributes
- V0.5.0 (8 april 2022)
Expand Down Expand Up @@ -363,7 +381,7 @@ library
```
MIT License
Copyright (c) 2021] Juky
Copyright (c) 2021 Juky
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 2 additions & 2 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ android {
minSdkVersion 23
targetSdkVersion 32
versionCode 1
versionName "0.5.1"
versionName "0.6.0"
project.archivesBaseName = "SquircleView"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
Expand All @@ -62,7 +62,7 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'com.google.android.material:material:1.5.0'
implementation 'com.google.android.material:material:1.6.0'
implementation("androidx.compose.material:material:1.1.1")

// Testing
Expand Down
45 changes: 29 additions & 16 deletions library/src/main/java/app/juky/squircleview/data/SquircleCore.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,24 @@ class SquircleCore(context: Context, attrs: AttributeSet?, view: View) {

var squirclePath = Path()

var backgroundImage: Bitmap?
@ColorInt var backgroundColor: Int

var shadowElevation: Float
@ColorInt var shadowElevationColor: Int

var gradientDrawable: GradientDrawable?
@ColorInt var gradientStartColor: Int
@ColorInt var gradientEndColor: Int
var gradientDirection: GradientDirection
var backgroundImage: Bitmap?
@ColorInt var backgroundColor: Int

var backgroundGradientDrawable: GradientDrawable?
@ColorInt var backgroundGradientStartColor: Int
@ColorInt var backgroundGradientEndColor: Int
var backgroundGradientDirection: GradientDirection

@ColorInt var borderColor: Int

var borderGradientDrawable: GradientDrawable?
@ColorInt var borderGradientStartColor: Int
@ColorInt var borderGradientEndColor: Int
var borderGradientDirection: GradientDirection

var borderWidth: Float

var rippleEnabled: Boolean
Expand All @@ -61,22 +67,29 @@ class SquircleCore(context: Context, attrs: AttributeSet?, view: View) {

init {
context.obtainStyledAttributes(attrs, R.styleable.SquircleView).apply {
backgroundImage = getDrawable(R.styleable.SquircleView_squircle_background_image)?.toBitmap()
backgroundColor = getColor(
R.styleable.SquircleView_squircle_background_color,
ContextCompat.getColor(context, android.R.color.black)
)
shadowElevation = getDimension(R.styleable.SquircleView_squircle_shadow_elevation, view.elevation)
shadowElevationColor = getColor(
R.styleable.SquircleView_squircle_shadow_elevation_color,
ContextCompat.getColor(context, R.color.squircle_default_shadow_color)
)
gradientDrawable = getDrawable(R.styleable.SquircleView_squircle_gradient_drawable) as? GradientDrawable
gradientStartColor = getColor(R.styleable.SquircleView_squircle_gradient_start_color, DEFAULT_COLOR_VALUE)
gradientEndColor = getColor(R.styleable.SquircleView_squircle_gradient_end_color, DEFAULT_COLOR_VALUE)
gradientDirection = GradientDirection.values()[getInt(R.styleable.SquircleView_squircle_gradient_direction, GradientDirection.DEFAULT.ordinal)]

backgroundImage = getDrawable(R.styleable.SquircleView_squircle_background_image)?.toBitmap()
backgroundColor = getColor(
R.styleable.SquircleView_squircle_background_color,
ContextCompat.getColor(context, android.R.color.black)
)
backgroundGradientDrawable = getDrawable(R.styleable.SquircleView_squircle_background_gradient_drawable) as? GradientDrawable
backgroundGradientStartColor = getColor(R.styleable.SquircleView_squircle_background_gradient_start_color, DEFAULT_COLOR_VALUE)
backgroundGradientEndColor = getColor(R.styleable.SquircleView_squircle_background_gradient_end_color, DEFAULT_COLOR_VALUE)
backgroundGradientDirection = GradientDirection.values()[getInt(R.styleable.SquircleView_squircle_background_gradient_direction, GradientDirection.DEFAULT.ordinal)]

borderColor = getColor(R.styleable.SquircleView_squircle_border_color, DEFAULT_COLOR_VALUE)
borderGradientDrawable = getDrawable(R.styleable.SquircleView_squircle_border_gradient_drawable) as? GradientDrawable
borderGradientStartColor = getColor(R.styleable.SquircleView_squircle_border_gradient_start_color, DEFAULT_COLOR_VALUE)
borderGradientEndColor = getColor(R.styleable.SquircleView_squircle_border_gradient_end_color, DEFAULT_COLOR_VALUE)
borderGradientDirection = GradientDirection.values()[getInt(R.styleable.SquircleView_squircle_border_gradient_direction, GradientDirection.DEFAULT.ordinal)]
borderWidth = getDimension(R.styleable.SquircleView_squircle_border_width, 0f)

rippleEnabled = getBoolean(R.styleable.SquircleView_squircle_ripple_enabled, view !is SquircleImageView)
rippleDrawable = getDrawable(R.styleable.SquircleView_squircle_ripple_drawable)
cornerSmoothing = getInteger(R.styleable.SquircleView_squircle_corner_smoothing_percentage, DEFAULT_CORNER_SMOOTHING.toInt())
Expand Down
Loading

0 comments on commit b499057

Please sign in to comment.