Skip to content

Commit

Permalink
Merge pull request #43 from Trendyol/refactor/touch-delegator
Browse files Browse the repository at this point in the history
Extract touch-delegator from image-slider module
  • Loading branch information
MertNYuksel authored May 28, 2020
2 parents f435c9d + 4b35abc commit 44909d0
Show file tree
Hide file tree
Showing 14 changed files with 92 additions and 5 deletions.
4 changes: 3 additions & 1 deletion buildSrc/src/main/kotlin/ComponentVersions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ object ComponentVersions {
const val toolbarVersion = "1.0.1"
const val suggestionInputViewVersion = "1.0.12"
const val ratingBarVersion = "1.0.2"
const val imageSliderVersion = "1.0.5"
const val phoneNumberVersion = "1.0.2"
const val imageSliderVersion = "1.0.4"
const val dialogsVersion = "1.0.7"
const val cardInputViewVersion = "1.0.5"
const val quantityPickerViewVersion = "1.1.1"
const val timelineViewVersion = "0.1.0"
const val touchDelegatorVersion = "1.0.0"

}
2 changes: 2 additions & 0 deletions buildSrc/src/main/kotlin/Components.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ object Components {
const val cardInputView = ":libraries:card-input-view"
const val quantityPickerView = ":libraries:quantity-picker-view"
const val timelineView = ":libraries:timeline-view"
const val touchDelegator = ":libraries:touch-delegator"

}
2 changes: 2 additions & 0 deletions libraries/image-slider/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,7 @@ dependencies {
implementation(Dependencies.circleIndicator)
implementation(Dependencies.constraintLayout)
implementation(Dependencies.glide)
implementation(project(Components.touchDelegator))

kapt(Dependencies.glideCompiler)
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import androidx.annotation.ColorInt
import androidx.databinding.DataBindingUtil
import androidx.viewpager.widget.PagerAdapter
import com.trendyol.uicomponents.imageslider.databinding.ViewImageBinding
import com.trendyol.uicomponents.imageslider.touchdelegator.WindowTouchDelegator
import com.trendyol.uicomponents.touchdelegator.WindowTouchDelegator
import com.trendyol.uicomponents.imageslider.touchdelegator.ZoomWindowTouchListener
import java.lang.ref.WeakReference

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.trendyol.uicomponents.imageslider.touchdelegator
import android.view.MotionEvent
import android.view.Window
import com.trendyol.uicomponents.imageslider.CVFloatingZoomView
import com.trendyol.uicomponents.touchdelegator.WindowTouchListener

class ZoomWindowTouchListener : WindowTouchListener, CVFloatingZoomView.FloatingZoomListener {

Expand Down
1 change: 1 addition & 0 deletions libraries/touch-delegator/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
31 changes: 31 additions & 0 deletions libraries/touch-delegator/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
plugins {
id(Plugins.androidLibrary)
id(Plugins.kotlinAndroid)
id(Plugins.kotlinAndroidExtensions)
id(Plugins.kotlinKapt)
id(Plugins.androidMaven)
}

group = Configs.group
version = ComponentVersions.touchDelegatorVersion

android {
compileSdkVersion(Configs.compileSdkVersion)
buildToolsVersion(Configs.buildToolsVersion)

defaultConfig {
minSdkVersion(Configs.minSdkVersion)
targetSdkVersion(Configs.targetSdkVersion)
vectorDrawables.useSupportLibrary = true

consumerProguardFiles("consumer-rules.pro")
}
buildTypes {
getByName<com.android.build.gradle.internal.dsl.BuildType>("release") {
isMinifyEnabled = false
setProguardFiles(mutableListOf(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"))
}
}

dataBinding.isEnabled = true
}
Empty file.
21 changes: 21 additions & 0 deletions libraries/touch-delegator/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.kts.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
2 changes: 2 additions & 0 deletions libraries/touch-delegator/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.trendyol.uicomponents.touchdelegator" />
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.trendyol.uicomponents.touchdelegator

import android.view.MotionEvent
import android.view.Window

class ActivityWindowTouchDelegator constructor(): WindowTouchListener {

private val touchListeners = mutableSetOf<WindowTouchListener>()

fun addListener(windowTouchListener: WindowTouchListener) {
touchListeners.add(windowTouchListener)
}

override fun onTouchEvent(window: Window, event: MotionEvent): Boolean {
for (touchListener in touchListeners) {
if (touchListener.onTouchEvent(window, event)) {
return true
}
}
return false
}

fun getWindowTouchListeners() = touchListeners
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.trendyol.uicomponents.imageslider.touchdelegator
package com.trendyol.uicomponents.touchdelegator

import android.view.MotionEvent
import android.view.Window
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.trendyol.uicomponents.imageslider.touchdelegator
package com.trendyol.uicomponents.touchdelegator

import android.view.MotionEvent
import android.view.Window
Expand Down
3 changes: 2 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ include(":libraries:toolbar")
include(":libraries:suggestion-input-view")
include(":libraries:card-input-view")
include(":libraries:quantity-picker-view")
include (":libraries:timeline-view")
include(":libraries:timeline-view")
include(":libraries:touch-delegator")

rootProject.name = "UI Components"

0 comments on commit 44909d0

Please sign in to comment.