Skip to content

Commit

Permalink
Release v.1.7.0 (#114)
Browse files Browse the repository at this point in the history
* Remove all warnings

* Update dependencies and tools

* Update to Egloo

* Update docs

* Bump version to v1.7.0

* Try with bt 29.0.0

* Back to v28
  • Loading branch information
natario1 authored Aug 24, 2019
1 parent 4ab9ce3 commit a319d71
Show file tree
Hide file tree
Showing 20 changed files with 166 additions and 130 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ android:
components:
- tools
- platform-tools
# https://developer.android.com/studio/releases/build-tools
- build-tools-28.0.3
- android-28
- doc-28
Expand Down
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
### v1.7.0

- BREAKING CHANGE: To use ZoomSurfaceView, you need to use `com.otaliastudios.opengl:egloo:0.2.3` instead of `com.otaliastudios.opengl:egl-core`. ([#114][114])
- Dependencies and tools updates ([#114][114])

https://github.com/natario1/ZoomLayout/compare/v1.6.1...v1.7.0

### v1.6.1

- Enhancement: Internal refactoring into smaller components [@natario1][natario1] ([#97][97])
Expand Down Expand Up @@ -61,4 +68,5 @@ https://github.com/natario1/ZoomLayout/compare/v1.4.0...v1.5.0
[94]: https://github.com/natario1/ZoomLayout/pull/94
[97]: https://github.com/natario1/ZoomLayout/pull/97
[102]: https://github.com/natario1/ZoomLayout/pull/102
[105]: https://github.com/natario1/ZoomLayout/pull/105
[105]: https://github.com/natario1/ZoomLayout/pull/105
[114]: https://github.com/natario1/ZoomLayout/pull/114
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Flexible utilities to control and animate zoom and translation of Views and much
programmatically or through touch events.

```groovy
implementation 'com.otaliastudios:zoomlayout:1.6.1'
implementation 'com.otaliastudios:zoomlayout:1.7.0'
```

<p>
Expand Down Expand Up @@ -186,12 +186,11 @@ There are a few special things about `ZoomSurfaceView` with respect to the other
- You **must** either call `ZoomSurfaceView.setContentSize()` passing the stream size, or measure the
view so that it matches the stream aspect ratio.

To use `ZoomSurfaceView` you must add the [EglCore](https://github.com/natario1/EglCore) library to your
dependencies or the view will crash. Please take a look at the sample app to see which version you
should be using.
To use `ZoomSurfaceView` you must add the [Egloo](https://github.com/natario1/Egloo) library to your
dependencies or the view will crash. You should also use the exact version that this library is expecting.

```groovy
implementation 'com.otaliastudios.opengl:egl-core:<version>'
implementation 'com.otaliastudios.opengl:egloo:0.2.3'
```

### Usage
Expand Down
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ dependencies {
implementation "androidx.appcompat:appcompat:1.0.2"
implementation 'com.google.android.exoplayer:exoplayer-core:2.9.3'
implementation 'com.google.android.exoplayer:exoplayer-ui:2.9.3'
implementation "com.otaliastudios.opengl:egl-core:$eglCoreVersion"
implementation "com.otaliastudios.opengl:egloo:$eglooVersion"
implementation project(':library')
}
7 changes: 4 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.3.20'
ext.kotlin_version = '1.3.41'
repositories {
jcenter()
google()
}

dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
Expand All @@ -28,7 +28,8 @@ ext {
compileSdkVersion = 28
minSdkVersion = 16
targetSdkVersion = 28
eglCoreVersion = '0.1.1'
// Updating? Update readme.
eglooVersion = '0.2.3'
}

task clean(type: Delete) {
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
10 changes: 5 additions & 5 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'

ext {
libVersion = '1.6.1'
libVersion = '1.7.0'
libGroup = 'com.otaliastudios'
libName = 'ZoomLayout'
libDescription = 'A View container that supports zooming and panning of View hierarchies, images and more.'
Expand Down Expand Up @@ -35,21 +35,21 @@ android {
}

dependencies {
api "androidx.annotation:annotation:1.0.2"
api "androidx.annotation:annotation:1.1.0"
api "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
compileOnly "com.otaliastudios.opengl:egl-core:$eglCoreVersion"
compileOnly "com.otaliastudios.opengl:egloo:$eglooVersion"

testImplementation "org.junit.jupiter:junit-jupiter-api:5.3.1"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.3.1"
}

task sourcesJar(type: Jar) {
classifier = 'sources'
archiveClassifier.set('sources')
from android.sourceSets.main.java.srcDirs
}

task dokkaJar(type: Jar, dependsOn: dokka) {
classifier = 'javadoc'
archiveClassifier.set('javadoc')
from dokka.outputDirectory
}

Expand Down
30 changes: 16 additions & 14 deletions library/src/main/java/com/otaliastudios/zoom/Alignment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import android.view.Gravity
object Alignment {

// Will use one hexadecimal value for each axis, so 16 possible values.
internal const val MASK = 0xF0 // 1111 0000
private const val MASK = 0xF0 // 1111 0000

// A special value meaning that the flag for some axis was not set.
internal const val NO_VALUE = 0x0
private const val NO_VALUE = 0x0

// Vertical

Expand Down Expand Up @@ -91,37 +91,39 @@ object Alignment {
* In case [alignment] includes both axes, both are required to be 'none' or [NO_VALUE].
*/
internal fun isNone(alignment: Int): Boolean {
return alignment == Alignment.NONE
|| alignment == Alignment.NO_VALUE
|| alignment == Alignment.NONE_HORIZONTAL
|| alignment == Alignment.NONE_VERTICAL
return alignment == NONE
|| alignment == NO_VALUE
|| alignment == NONE_HORIZONTAL
|| alignment == NONE_VERTICAL
}

/**
* Transforms this alignment to a horizontal gravity value.
*/
@Suppress("MoveVariableDeclarationIntoWhen")
@SuppressLint("RtlHardcoded")
internal fun toHorizontalGravity(alignment: Int, valueIfNone: Int): Int {
val horizontalAlignment = getHorizontal(alignment)
return when (horizontalAlignment) {
Alignment.LEFT -> Gravity.LEFT
Alignment.RIGHT -> Gravity.RIGHT
Alignment.CENTER_HORIZONTAL -> Gravity.CENTER_HORIZONTAL
Alignment.NONE_HORIZONTAL -> valueIfNone
LEFT -> Gravity.LEFT
RIGHT -> Gravity.RIGHT
CENTER_HORIZONTAL -> Gravity.CENTER_HORIZONTAL
NONE_HORIZONTAL -> valueIfNone
else -> valueIfNone
}
}

/**
* Transforms this alignment to a vertical gravity value.
*/
@Suppress("MoveVariableDeclarationIntoWhen")
internal fun toVerticalGravity(alignment: Int, valueIfNone: Int): Int {
val verticalAlignment = getVertical(alignment)
return when (verticalAlignment) {
Alignment.TOP -> Gravity.TOP
Alignment.BOTTOM -> Gravity.BOTTOM
Alignment.CENTER_VERTICAL -> Gravity.CENTER_VERTICAL
Alignment.NONE_VERTICAL -> valueIfNone
TOP -> Gravity.TOP
BOTTOM -> Gravity.BOTTOM
CENTER_VERTICAL -> Gravity.CENTER_VERTICAL
NONE_VERTICAL -> valueIfNone
else -> valueIfNone
}
}
Expand Down
8 changes: 6 additions & 2 deletions library/src/main/java/com/otaliastudios/zoom/ZoomEngine.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import com.otaliastudios.zoom.internal.gestures.ScrollFlingDetector
import com.otaliastudios.zoom.internal.matrix.MatrixUpdate
import com.otaliastudios.zoom.internal.movement.PanManager
import com.otaliastudios.zoom.internal.movement.ZoomManager
import kotlin.math.max
import kotlin.math.min


/**
Expand Down Expand Up @@ -158,6 +160,7 @@ internal constructor(context: Context) : ZoomApi {
// Internal
private lateinit var container: View
private val callbacks = Callbacks()
@Suppress("LeakingThis")
private val dispatcher = UpdatesDispatcher(this)
private val stateController = StateController(callbacks)
private val panManager = PanManager { matrixController }
Expand Down Expand Up @@ -570,6 +573,7 @@ internal constructor(context: Context) : ZoomApi {
* until the view is laid out again and [ZoomEngine.setContentSize]
* is called.
*/
@Suppress("unused")
fun clear() {
zoomManager.clear()
panManager.clear()
Expand All @@ -585,13 +589,13 @@ internal constructor(context: Context) : ZoomApi {
val scaleX = containerWidth / contentWidth
val scaleY = containerHeight / contentHeight
LOG.v("computeTransformationZoom", "centerInside", "scaleX:", scaleX, "scaleY:", scaleY)
return Math.min(scaleX, scaleY)
return min(scaleX, scaleY)
}
ZoomApi.TRANSFORMATION_CENTER_CROP -> {
val scaleX = containerWidth / contentWidth
val scaleY = containerHeight / contentHeight
LOG.v("computeTransformationZoom", "centerCrop", "scaleX:", scaleX, "scaleY:", scaleY)
return Math.max(scaleX, scaleY)
return max(scaleX, scaleY)
}
ZoomApi.TRANSFORMATION_NONE -> return 1f
else -> return 1f
Expand Down
6 changes: 3 additions & 3 deletions library/src/main/java/com/otaliastudios/zoom/ZoomImageView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import android.graphics.Canvas
import android.graphics.Matrix
import android.graphics.drawable.Drawable
import android.util.AttributeSet
import android.view.Gravity
import android.view.MotionEvent
import android.widget.ImageView
import androidx.annotation.AttrRes
Expand All @@ -16,12 +15,13 @@ import com.otaliastudios.zoom.ZoomApi.ZoomType
/**
* Uses [ZoomEngine] to allow zooming and pan events to the inner drawable.
*/
@Suppress("LeakingThis")
@SuppressLint("AppCompatCustomView")
open class ZoomImageView private constructor(
context: Context,
attrs: AttributeSet?,
@AttrRes defStyleAttr: Int,
val engine: ZoomEngine = ZoomEngine(context)
@Suppress("MemberVisibilityCanBePrivate") val engine: ZoomEngine = ZoomEngine(context)
) : ImageView(context, attrs, defStyleAttr), ZoomApi by engine {

@JvmOverloads
Expand Down Expand Up @@ -86,7 +86,7 @@ open class ZoomImageView private constructor(
setMaxZoom(maxZoom, maxZoomMode)

imageMatrix = mMatrix
scaleType = ImageView.ScaleType.MATRIX
scaleType = ScaleType.MATRIX
}

override fun setImageDrawable(drawable: Drawable?) {
Expand Down
17 changes: 10 additions & 7 deletions library/src/main/java/com/otaliastudios/zoom/ZoomLayout.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.otaliastudios.zoom

import android.annotation.SuppressLint
import android.content.Context
import android.graphics.Canvas
import android.graphics.Matrix
Expand All @@ -23,11 +24,12 @@ import com.otaliastudios.zoom.ZoomApi.ZoomType
*
* Currently padding to this view / margins to the child view are NOT supported.
*/
@Suppress("LeakingThis")
open class ZoomLayout private constructor(
context: Context,
attrs: AttributeSet?,
@AttrRes defStyleAttr: Int,
val engine: ZoomEngine = ZoomEngine(context)
@Suppress("MemberVisibilityCanBePrivate") val engine: ZoomEngine = ZoomEngine(context)
) : FrameLayout(context, attrs, defStyleAttr),
ViewTreeObserver.OnGlobalLayoutListener,
ZoomApi by engine {
Expand Down Expand Up @@ -113,17 +115,17 @@ open class ZoomLayout private constructor(
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {

// Measure ourselves as MATCH_PARENT
val widthMode = View.MeasureSpec.getMode(widthMeasureSpec)
val heightMode = View.MeasureSpec.getMode(heightMeasureSpec)
if (widthMode == View.MeasureSpec.UNSPECIFIED || heightMode == View.MeasureSpec.UNSPECIFIED) {
val widthMode = MeasureSpec.getMode(widthMeasureSpec)
val heightMode = MeasureSpec.getMode(heightMeasureSpec)
if (widthMode == MeasureSpec.UNSPECIFIED || heightMode == MeasureSpec.UNSPECIFIED) {
throw RuntimeException("$TAG must be used with fixed dimensions (e.g. match_parent)")
}
val widthSize = View.MeasureSpec.getSize(widthMeasureSpec)
val heightSize = View.MeasureSpec.getSize(heightMeasureSpec)
val widthSize = MeasureSpec.getSize(widthMeasureSpec)
val heightSize = MeasureSpec.getSize(heightMeasureSpec)
setMeasuredDimension(widthSize, heightSize)

// Measure our child as unspecified.
val spec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED)
val spec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)
measureChildren(spec, spec)
}

Expand All @@ -138,6 +140,7 @@ open class ZoomLayout private constructor(
return engine.onInterceptTouchEvent(ev) || hasClickableChildren && super.onInterceptTouchEvent(ev)
}

@SuppressLint("ClickableViewAccessibility")
override fun onTouchEvent(ev: MotionEvent): Boolean {
return engine.onTouchEvent(ev) || hasClickableChildren && super.onTouchEvent(ev)
}
Expand Down
4 changes: 4 additions & 0 deletions library/src/main/java/com/otaliastudios/zoom/ZoomLogger.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class ZoomLogger private constructor(private val mTag: String) {
@Retention(AnnotationRetention.SOURCE)
internal annotation class LogLevel

@Suppress("unused")
internal fun v(message: String) {
if (should(LEVEL_VERBOSE)) {
Log.v(mTag, message)
Expand All @@ -28,6 +29,7 @@ class ZoomLogger private constructor(private val mTag: String) {
}
}

@Suppress("MemberVisibilityCanBePrivate")
internal fun w(message: String) {
if (should(LEVEL_WARNING)) {
Log.w(mTag, message)
Expand All @@ -36,6 +38,7 @@ class ZoomLogger private constructor(private val mTag: String) {
}
}

@Suppress("MemberVisibilityCanBePrivate")
internal fun e(message: String) {
if (should(LEVEL_ERROR)) {
Log.e(mTag, message)
Expand Down Expand Up @@ -67,6 +70,7 @@ class ZoomLogger private constructor(private val mTag: String) {
w(string(LEVEL_WARNING, *data))
}

@Suppress("unused")
internal fun e(vararg data: Any) {
e(string(LEVEL_ERROR, *data))
}
Expand Down
Loading

0 comments on commit a319d71

Please sign in to comment.