Drop support for Android 4.x (#2440)

* Bump minSdkVersion

* Remove Android 4.x specific logic

* Consolidate res assets

* Add note about minimum Android version to README

* Restore incorrectly removed method, remove unneeded Lollipop TargetApi annotations
This commit is contained in:
arkon
2020-01-07 18:46:31 -05:00
committed by GitHub
parent b55814a1c0
commit 0d5099f230
33 changed files with 200 additions and 530 deletions

View File

@@ -16,32 +16,26 @@ class ElevationAppBarLayout @JvmOverloads constructor(
private var origStateAnimator: StateListAnimator? = null
init {
if (Build.VERSION.SDK_INT >= 21) {
origStateAnimator = stateListAnimator
}
origStateAnimator = stateListAnimator
}
fun enableElevation() {
if (Build.VERSION.SDK_INT >= 21) {
stateListAnimator = origStateAnimator
}
stateListAnimator = origStateAnimator
}
fun disableElevation() {
if (Build.VERSION.SDK_INT >= 21) {
stateListAnimator = StateListAnimator().apply {
val objAnimator = ObjectAnimator.ofFloat(this, "elevation", 0f)
stateListAnimator = StateListAnimator().apply {
val objAnimator = ObjectAnimator.ofFloat(this, "elevation", 0f)
// Enabled and collapsible, but not collapsed means not elevated
addState(intArrayOf(android.R.attr.enabled, R.attr.state_collapsible, -R.attr.state_collapsed),
objAnimator)
// Enabled and collapsible, but not collapsed means not elevated
addState(intArrayOf(android.R.attr.enabled, R.attr.state_collapsible, -R.attr.state_collapsed),
objAnimator)
// Default enabled state
addState(intArrayOf(android.R.attr.enabled), objAnimator)
// Default enabled state
addState(intArrayOf(android.R.attr.enabled), objAnimator)
// Disabled state
addState(IntArray(0), objAnimator)
}
// Disabled state
addState(IntArray(0), objAnimator)
}
}

View File

@@ -2,14 +2,11 @@ package eu.kanade.tachiyomi.widget
import android.animation.Animator
import android.animation.AnimatorListenerAdapter
import android.annotation.TargetApi
import android.content.Context
import android.os.Build
import android.util.AttributeSet
import android.view.View
import android.view.ViewAnimationUtils
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
class RevealAnimationView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
View(context, attrs) {
@@ -21,28 +18,25 @@ class RevealAnimationView @JvmOverloads constructor(context: Context, attrs: Att
* @param initialRadius size of radius of animation
*/
fun hideRevealEffect(centerX: Int, centerY: Int, initialRadius: Int) {
if (Build.VERSION.SDK_INT >= 21) {
// Make the view visible.
this.visibility = View.VISIBLE
// Make the view visible.
this.visibility = View.VISIBLE
// Create the animation (the final radius is zero).
val anim = ViewAnimationUtils.createCircularReveal(
this, centerX, centerY, initialRadius.toFloat(), 0f)
// Create the animation (the final radius is zero).
val anim = ViewAnimationUtils.createCircularReveal(
this, centerX, centerY, initialRadius.toFloat(), 0f)
// Set duration of animation.
anim.duration = 500
// Set duration of animation.
anim.duration = 500
// make the view invisible when the animation is done
anim.addListener(object : AnimatorListenerAdapter() {
override fun onAnimationEnd(animation: Animator) {
super.onAnimationEnd(animation)
this@RevealAnimationView.visibility = View.INVISIBLE
}
})
// make the view invisible when the animation is done
anim.addListener(object : AnimatorListenerAdapter() {
override fun onAnimationEnd(animation: Animator) {
super.onAnimationEnd(animation)
this@RevealAnimationView.visibility = View.INVISIBLE
}
})
anim.start()
}
anim.start()
}
/**
@@ -55,25 +49,20 @@ class RevealAnimationView @JvmOverloads constructor(context: Context, attrs: Att
* @return sdk version lower then 21
*/
fun showRevealEffect(centerX: Int, centerY: Int, listener: Animator.AnimatorListener): Boolean {
if (Build.VERSION.SDK_INT >= 21) {
this.visibility = View.VISIBLE
this.visibility = View.VISIBLE
val height = this.height
val height = this.height
// Create animation
val anim = ViewAnimationUtils.createCircularReveal(
this, centerX, centerY, 0f, height.toFloat())
// Create animation
val anim = ViewAnimationUtils.createCircularReveal(
this, centerX, centerY, 0f, height.toFloat())
// Set duration of animation
anim.duration = 350
// Set duration of animation
anim.duration = 350
anim.addListener(listener)
anim.start()
return true
}
return false
anim.addListener(listener)
anim.start()
return true
}
}