Skip to content

Commit

Permalink
v1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Aghajari committed Aug 14, 2021
1 parent 174a970 commit 5e0403c
Show file tree
Hide file tree
Showing 29 changed files with 415 additions and 644 deletions.
Binary file modified .DS_Store
Binary file not shown.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
.DS_Store
.DS_Store
ZoomHelper/.DS_Store
Binary file modified ZoomHelper/.DS_Store
Binary file not shown.
173 changes: 0 additions & 173 deletions ZoomHelper/ZoomHelper.iml

This file was deleted.

142 changes: 73 additions & 69 deletions ZoomHelper/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@ apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'


android {
compileSdkVersion 29

compileSdkVersion 30

defaultConfig {
minSdkVersion 16
targetSdkVersion 29
targetSdkVersion 30
versionCode 1
versionName "1.0"

Expand All @@ -29,70 +27,20 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

implementation 'androidx.appcompat:appcompat:1.2.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.3.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation "androidx.core:core-ktx:1.3.2"
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.4.21"
implementation 'androidx.appcompat:appcompat:1.3.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test:runner:1.4.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation "androidx.core:core-ktx:1.6.0"
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.5.10"

}

apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'
// PUBLISH

def artifact = new Properties()
artifact.load(new FileInputStream("deploy.settings"))

version=artifact.version
group=artifact.groupId

install {
repositories.mavenInstaller {
pom.project {
packaging 'aar'
groupId artifact.groupId
artifactId artifact.id
version artifact.version
name artifact.id // pom.project.name must be same as bintray.pkg.name
url artifact.siteUrl
inceptionYear '2020' // HARDCODED
licenses {
license { // HARDCODED
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
scm {
connection artifact.gitUrl
developerConnection artifact.gitUrl
url artifact.siteUrl
}
}
}
}

def properties = new Properties()
properties.load(new FileInputStream("local.properties"))

bintray {
user = properties.getProperty("bintray.user")
key = properties.getProperty("bintray.apikey")

configurations = ['archives']
pkg {
repo = "Aghajari"
name = artifact.id
websiteUrl = artifact.siteUrl
vcsUrl = artifact.gitUrl
licenses = artifact.licenses
publish = true
version {
name = artifact.version
}
}
}
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'signing'

task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
Expand All @@ -107,16 +55,72 @@ task javadoc(type: Javadoc) {
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
// options.encoding = 'UTF-8'
//./gradlew javadocJar --stacktrace
}

artifacts {
archives javadocJar
archives sourcesJar
}
repositories {
maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
mavenCentral()

signing {
useInMemoryPgpKeys(
rootProject.ext["signing.keyId"],
rootProject.ext["signing.key"],
rootProject.ext["signing.password"],
)
sign publishing.publications
}

tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
options.addStringOption('encoding', 'UTF-8')
options.addStringOption('charSet', 'UTF-8')
}

def artifact = new Properties()
artifact.load(new FileInputStream(rootProject.rootDir.getAbsolutePath() + "/deploy.settings"))

version = artifact.version
group = artifact.groupId
archivesBaseName = artifact.id

afterEvaluate {
publishing {
publications {
release(MavenPublication) {
groupId artifact.groupId
artifactId artifact.id
version artifact.version
from components.release

pom {
name = artifact.id
packaging = 'aar'
description = 'ZoomHelper will make any view to be zoomable just like Instagram pinch-to-zoom'
url = artifact.siteUrl

scm {
connection = artifact.gitUrl
developerConnection = artifact.gitUrl
url = artifact.siteUrl
}

licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}

developers {
developer {
id = 'Aghajari'
name = 'AmirHossein Aghajari'
email = '[email protected]'
}
}
}
}
}
}
}
Binary file modified ZoomHelper/src/.DS_Store
Binary file not shown.
Binary file removed ZoomHelper/src/main/.DS_Store
Binary file not shown.
Binary file removed ZoomHelper/src/main/java/.DS_Store
Binary file not shown.
Binary file removed ZoomHelper/src/main/java/com/.DS_Store
Binary file not shown.
Binary file removed ZoomHelper/src/main/java/com/aghajari/.DS_Store
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package com.aghajari.zoomhelper
internal object InstanceState {
private var helper: ZoomHelper? = null

fun getZoomHelper():ZoomHelper {
if (helper==null) helper = ZoomHelper()
fun getZoomHelper(): ZoomHelper {
if (helper == null) helper = ZoomHelper()
return helper!!
}

fun release(){
fun release() {
helper = null
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import android.graphics.Canvas
import android.view.View

internal class PlaceHolderView(context: Context?) : View(context) {
private var view:View?=null
private var view: View? = null

constructor(view: View) : this(view.context) {
this.view = view
}

override fun onDraw(canvas: Canvas?) {
if (view!=null && isEnabled){
if (view != null && isEnabled) {
view!!.draw(canvas)
return
}
Expand Down
27 changes: 14 additions & 13 deletions ZoomHelper/src/main/java/com/aghajari/zoomhelper/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,24 @@ import android.view.ViewGroup

internal object Utils {

fun findZoomableView (ev: MotionEvent, vararg parents: View): View? {
fun findZoomableView(ev: MotionEvent, vararg parents: View): View? {
if (parents.isEmpty()) return null;
val p1 = MotionEvent.PointerCoords()
ev.getPointerCoords(0,p1)
ev.getPointerCoords(0, p1)

val p2 = MotionEvent.PointerCoords()
ev.getPointerCoords(1,p2)
ev.getPointerCoords(1, p2)

for (parent in parents) {
if (!ZoomHelper.isSkippingLayout(parent)) {

if (isViewInArea(parent, p1.x, p1.y, p2.x, p2.y)
&& ZoomHelper.isZoomableView(parent)) return parent
&& ZoomHelper.isZoomableView(parent)
) return parent

if (parent is ViewGroup) {
val v= checkChild(parent, p1.x, p1.y, p2.x, p2.y)
if (v!=null) return v
val v = checkChild(parent, p1.x, p1.y, p2.x, p2.y)
if (v != null) return v
}
}
}
Expand All @@ -33,10 +34,10 @@ internal object Utils {
}

private fun checkChild(vg: ViewGroup?, x1: Float, y1: Float, x2: Float, y2: Float): View? {
if (vg==null) return null
if (vg == null) return null

val childCount = vg.childCount
for (i in 0 until childCount){
for (i in 0 until childCount) {
val child = vg.getChildAt(i)
if (!ZoomHelper.isSkippingLayout(child)) {
if (isViewInArea(child, x1, y1, x2, y2)) {
Expand All @@ -52,8 +53,8 @@ internal object Utils {
return null
}

private fun isViewInArea(view: View?, x1: Float, y1: Float, x2: Float, y2: Float):Boolean {
if (view==null) return false
private fun isViewInArea(view: View?, x1: Float, y1: Float, x2: Float, y2: Float): Boolean {
if (view == null) return false
val location = IntArray(2)
view.getLocationOnScreen(location)

Expand All @@ -64,10 +65,10 @@ internal object Utils {
visibleRect.bottom = visibleRect.top + view.height

return (visibleRect.contains(x1.toInt(), y1.toInt())
&& visibleRect.contains(x2.toInt(),y2.toInt()))
&& visibleRect.contains(x2.toInt(), y2.toInt()))
}

fun getDistance(x1: Double,y1: Double,x2: Double,y2: Double) : Int {
return Math.sqrt(Math.pow(x2-x1, 2.0)+Math.pow(y2-y1, 2.0)).toInt()
fun getDistance(x1: Double, y1: Double, x2: Double, y2: Double): Int {
return Math.sqrt(Math.pow(x2 - x1, 2.0) + Math.pow(y2 - y1, 2.0)).toInt()
}
}
Loading

0 comments on commit 5e0403c

Please sign in to comment.