Skip to content

Commit

Permalink
Merge pull request #6 from AbdElraoufSabri/develop
Browse files Browse the repository at this point in the history
fix fading area in ruler on RTL
  • Loading branch information
abd3lraouf authored Feb 7, 2020
2 parents 8092d0b + 4c05f6c commit 22628e5
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
4 changes: 2 additions & 2 deletions ruler/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ android {
defaultConfig {
minSdkVersion 19
targetSdkVersion 29
versionCode 9
versionName "1.4.0"
versionCode 10
versionName "1.4.1"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'consumer-rules.pro'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ class ObservableHorizontalScrollView : HorizontalScrollView {
}

override fun getRightFadingEdgeStrength(): Float {
return 0F
return if (isRtl()) 2F else 0F
}

override fun getLeftFadingEdgeStrength(): Float {
return 2F
return if (isRtl()) 0F else 2F
}

private var disposable: Disposable? = null
Expand Down
7 changes: 7 additions & 0 deletions ruler/src/main/java/io/abdelraoufsabri/learn/ruler/Utils.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package io.abdelraoufsabri.learn.ruler

import android.text.TextUtils
import androidx.core.view.ViewCompat
import java.util.*

fun isRtl() = TextUtils.getLayoutDirectionFromLocale(Locale.getDefault()) == ViewCompat.LAYOUT_DIRECTION_RTL
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import androidx.core.content.ContextCompat
import androidx.core.view.ViewCompat
import io.abdelraoufsabri.learn.ruler.ObservableHorizontalScrollView
import io.abdelraoufsabri.learn.ruler.R
import io.abdelraoufsabri.learn.ruler.isRtl
import kotlinx.android.synthetic.main.units.view.*
import java.util.*
import kotlin.math.abs
Expand Down Expand Up @@ -369,7 +370,6 @@ class FancyRuler : LinearLayout {
return value
}

private fun isRtl() = TextUtils.getLayoutDirectionFromLocale(Locale.getDefault()) == ViewCompat.LAYOUT_DIRECTION_RTL

override fun onSaveInstanceState(): Parcelable? {
val bundle = Bundle()
Expand Down

0 comments on commit 22628e5

Please sign in to comment.