Skip to content

Commit

Permalink
Update gradle set up and refactor entire code formats
Browse files Browse the repository at this point in the history
  • Loading branch information
skydoves committed Sep 3, 2022
1 parent d200025 commit e4af041
Show file tree
Hide file tree
Showing 42 changed files with 476 additions and 132 deletions.
31 changes: 23 additions & 8 deletions androidveil/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,35 @@ android {
versionCode versions.versionCode
versionName versions.versionName
}

resourcePrefix "veil"

buildFeatures {
buildConfig false
viewBinding true
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

kotlinOptions {
jvmTarget = "1.8"
}

lintOptions {
abortOnError false
}
}

apiValidation {
ignoredPackages += [
"com/skydoves/androidveil/databinding",
]
nonPublicMarkers += [
"kotlin.PublishedApi",
]
ignoredPackages += ["com/skydoves/androidveil/databinding"]
nonPublicMarkers += ["kotlin.PublishedApi"]
}

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
kotlinOptions.freeCompilerArgs += ["-Xexplicit-api=strict"]
}

dependencies {
Expand All @@ -33,5 +49,4 @@ dependencies {
api "com.facebook.shimmer:shimmer:$versions.shimmer"
}

apply plugin: "com.vanniktech.maven.publish"
apply from: '../spotless.gradle'
apply plugin: "com.vanniktech.maven.publish"
16 changes: 16 additions & 0 deletions androidveil/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Designed and developed by 2018 skydoves (Jaewoong Eum)
Licensed under the Stream License;
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<manifest package="com.skydoves.androidveil" />
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 skydoves
* Designed and developed by 2018 skydoves (Jaewoong Eum)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
91 changes: 56 additions & 35 deletions androidveil/src/main/java/com/skydoves/androidveil/VeilLayout.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 skydoves
* Designed and developed by 2018 skydoves (Jaewoong Eum)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -38,17 +38,17 @@ import com.facebook.shimmer.ShimmerFrameLayout

/** create a [Shimmer] by [Shimmer.AlphaHighlightBuilder] using dsl. */
@JvmSynthetic
inline fun alphaShimmer(crossinline block: Shimmer.AlphaHighlightBuilder.() -> Unit): Shimmer =
public inline fun alphaShimmer(crossinline block: Shimmer.AlphaHighlightBuilder.() -> Unit): Shimmer =
Shimmer.AlphaHighlightBuilder().apply(block).build()

/** create a [Shimmer] by [Shimmer.ColorHighlightBuilder] using dsl. */
@JvmSynthetic
inline fun colorShimmer(crossinline block: Shimmer.ColorHighlightBuilder.() -> Unit): Shimmer =
public inline fun colorShimmer(crossinline block: Shimmer.ColorHighlightBuilder.() -> Unit): Shimmer =
Shimmer.ColorHighlightBuilder().apply(block).build()

/** VeilLayout creates skeletons about the complex child views with shimmering effect. */
@Suppress("HasPlatformType", "MemberVisibilityCanBePrivate")
class VeilLayout : FrameLayout {
public class VeilLayout : FrameLayout {

@ColorInt
private var baseColor = Color.LTGRAY
Expand All @@ -66,56 +66,66 @@ class VeilLayout : FrameLayout {
private var dropOff = 0.5f

@Px
var radius = 8f.dp2px(this)
var drawable: Drawable? = null
public var radius: Float = 8f.dp2px(this)
public var drawable: Drawable? = null

@LayoutRes
var layout = -1
public var layout: Int = -1
set(value) {
field = value
invalidateLayout(value)
}

var isVeiled = false
public var isVeiled: Boolean = false
private set

val shimmerContainer = ShimmerFrameLayout(context)
val nonShimmer = Shimmer.AlphaHighlightBuilder().setBaseAlpha(1.0f).setDropoff(1.0f).build()
var shimmer = Shimmer.AlphaHighlightBuilder().build()
public val shimmerContainer: ShimmerFrameLayout = ShimmerFrameLayout(context)
public val nonShimmer: Shimmer =
Shimmer.AlphaHighlightBuilder().setBaseAlpha(1.0f).setDropoff(1.0f).build()
public var shimmer: Shimmer = Shimmer.AlphaHighlightBuilder().build()
set(value) {
field = value
shimmerContainer.setShimmer(value)
}
var shimmerEnable: Boolean = true
public var shimmerEnable: Boolean = true
set(value) {
field = value
when (value) {
true -> shimmerContainer.setShimmer(shimmer)
false -> shimmerContainer.setShimmer(nonShimmer)
}
}
var defaultChildVisible = false
public var defaultChildVisible: Boolean = false

constructor(context: Context) : super(context) {
public constructor(context: Context) : super(context) {
onCreate()
}

constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) {
public constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) {
getAttrs(attrs)
onCreate()
}

constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(
context, attrs,
public constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(
context,
attrs,
defStyleAttr
) {
getAttrs(attrs)
onCreate()
}

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int) : super(
context, attrs, defStyleAttr, defStyleRes
public constructor(
context: Context,
attrs: AttributeSet?,
defStyleAttr: Int,
defStyleRes: Int
) : super(
context,
attrs,
defStyleAttr,
defStyleRes
) {
getAttrs(attrs)
onCreate()
Expand All @@ -124,31 +134,42 @@ class VeilLayout : FrameLayout {
private fun getAttrs(attrs: AttributeSet?) {
val a = context.obtainStyledAttributes(attrs, R.styleable.VeilLayout)
try {
if (a.hasValue(R.styleable.VeilLayout_veilLayout_veiled))
if (a.hasValue(R.styleable.VeilLayout_veilLayout_veiled)) {
isVeiled = a.getBoolean(R.styleable.VeilLayout_veilLayout_veiled, isVeiled)
if (a.hasValue(R.styleable.VeilLayout_veilLayout_layout))
}
if (a.hasValue(R.styleable.VeilLayout_veilLayout_layout)) {
layout = a.getResourceId(R.styleable.VeilLayout_veilLayout_layout, -1)
if (a.hasValue(R.styleable.VeilLayout_veilLayout_drawable))
}
if (a.hasValue(R.styleable.VeilLayout_veilLayout_drawable)) {
drawable = a.getDrawable(R.styleable.VeilLayout_veilLayout_drawable)
if (a.hasValue(R.styleable.VeilLayout_veilLayout_radius))
}
if (a.hasValue(R.styleable.VeilLayout_veilLayout_radius)) {
radius = a.getDimension(R.styleable.VeilLayout_veilLayout_radius, radius)
if (a.hasValue(R.styleable.VeilLayout_veilLayout_shimmerEnable))
}
if (a.hasValue(R.styleable.VeilLayout_veilLayout_shimmerEnable)) {
shimmerEnable = a.getBoolean(R.styleable.VeilLayout_veilLayout_shimmerEnable, shimmerEnable)
if (a.hasValue(R.styleable.VeilLayout_veilLayout_baseColor))
}
if (a.hasValue(R.styleable.VeilLayout_veilLayout_baseColor)) {
baseColor = a.getColor(R.styleable.VeilLayout_veilLayout_baseColor, baseColor)
if (a.hasValue(R.styleable.VeilLayout_veilLayout_highlightColor))
}
if (a.hasValue(R.styleable.VeilLayout_veilLayout_highlightColor)) {
highlightColor =
a.getColor(R.styleable.VeilLayout_veilLayout_highlightColor, highlightColor)
if (a.hasValue(R.styleable.VeilLayout_veilLayout_baseAlpha))
}
if (a.hasValue(R.styleable.VeilLayout_veilLayout_baseAlpha)) {
baseAlpha = a.getFloat(R.styleable.VeilLayout_veilLayout_baseAlpha, baseAlpha)
if (a.hasValue(R.styleable.VeilLayout_veilLayout_highlightAlpha))
}
if (a.hasValue(R.styleable.VeilLayout_veilLayout_highlightAlpha)) {
highlightAlpha =
a.getFloat(R.styleable.VeilLayout_veilLayout_highlightAlpha, highlightAlpha)
if (a.hasValue(R.styleable.VeilLayout_veilLayout_dropOff))
}
if (a.hasValue(R.styleable.VeilLayout_veilLayout_dropOff)) {
dropOff = a.getFloat(R.styleable.VeilLayout_veilLayout_dropOff, dropOff)
if (a.hasValue(R.styleable.VeilLayout_veilLayout_defaultChildVisible))
}
if (a.hasValue(R.styleable.VeilLayout_veilLayout_defaultChildVisible)) {
defaultChildVisible =
a.getBoolean(R.styleable.VeilLayout_veilLayout_defaultChildVisible, defaultChildVisible)
}
} finally {
a.recycle()
}
Expand All @@ -170,7 +191,7 @@ class VeilLayout : FrameLayout {
}

/** Remove previous views and inflate a new layout using an inflated view. */
fun setLayout(layout: View) {
public fun setLayout(layout: View) {
removeAllViews()
addView(layout)
shimmerContainer.removeAllViews()
Expand Down Expand Up @@ -242,7 +263,7 @@ class VeilLayout : FrameLayout {
}

/** Make appear the mask. */
fun veil() {
public fun veil() {
if (!this.isVeiled) {
this.isVeiled = true
startShimmer()
Expand All @@ -251,7 +272,7 @@ class VeilLayout : FrameLayout {
}

/** Make disappear the mask. */
fun unVeil() {
public fun unVeil() {
if (this.isVeiled) {
this.isVeiled = false
stopShimmer()
Expand All @@ -260,7 +281,7 @@ class VeilLayout : FrameLayout {
}

/** Starts the shimmer animation. */
fun startShimmer() {
public fun startShimmer() {
this.shimmerContainer.visible()
if (this.shimmerEnable) {
this.shimmerContainer.startShimmer()
Expand All @@ -271,7 +292,7 @@ class VeilLayout : FrameLayout {
}

/** Stops the shimmer animation. */
fun stopShimmer() {
public fun stopShimmer() {
this.shimmerContainer.invisible()
this.shimmerContainer.stopShimmer()
if (!this.defaultChildVisible) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 skydoves
* Designed and developed by 2018 skydoves (Jaewoong Eum)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Loading

0 comments on commit e4af041

Please sign in to comment.