Loading commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Context.kt +4 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ import android.provider.OpenableColumns import android.support.v4.content.ContextCompat import android.support.v4.content.CursorLoader import android.support.v4.content.FileProvider import android.view.View import android.view.ViewGroup import android.widget.Toast import com.github.ajalt.reprint.core.Reprint Loading @@ -33,6 +34,7 @@ import java.io.File fun Context.isOnMainThread() = Looper.myLooper() == Looper.getMainLooper() fun Context.getSharedPrefs() = getSharedPreferences(PREFS_KEY, Context.MODE_PRIVATE) fun Context.isJellyBean1Plus() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 fun Context.isAndroidFour() = Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT_WATCH fun Context.isKitkatPlus() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT fun Context.isLollipopPlus() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP Loading @@ -40,6 +42,8 @@ fun Context.isMarshmallowPlus() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.M fun Context.isNougatPlus() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.N fun Context.isOreoPlus() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O val Context.isRTLLayout: Boolean get() = if (isJellyBean1Plus()) resources.configuration.layoutDirection == View.LAYOUT_DIRECTION_RTL else false fun Context.updateTextColors(viewGroup: ViewGroup, tmpTextColor: Int = 0, tmpAccentColor: Int = 0) { val textColor = if (tmpTextColor == 0) baseConfig.textColor else tmpTextColor val accentColor = if (tmpAccentColor == 0) baseConfig.primaryColor else tmpAccentColor Loading commons/src/main/kotlin/com/simplemobiletools/commons/views/LineColorPicker.kt +5 −1 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ import android.view.LayoutInflater import android.view.MotionEvent import android.widget.LinearLayout import com.simplemobiletools.commons.R import com.simplemobiletools.commons.extensions.isRTLLayout import com.simplemobiletools.commons.extensions.onGlobalLayout import com.simplemobiletools.commons.interfaces.LineColorPickerListener import java.util.* Loading Loading @@ -81,7 +82,10 @@ class LineColorPicker(context: Context, attrs: AttributeSet) : LinearLayout(cont } private fun touchAt(touchX: Int) { val colorIndex = touchX / stripeWidth var colorIndex = touchX / stripeWidth if (context.isRTLLayout) { colorIndex = colors.size - colorIndex - 1 } val index = Math.max(0, Math.min(colorIndex, colorsCount - 1)) if (lastColorIndex != index) { updateItemMargin(lastColorIndex, true) Loading Loading
commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Context.kt +4 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ import android.provider.OpenableColumns import android.support.v4.content.ContextCompat import android.support.v4.content.CursorLoader import android.support.v4.content.FileProvider import android.view.View import android.view.ViewGroup import android.widget.Toast import com.github.ajalt.reprint.core.Reprint Loading @@ -33,6 +34,7 @@ import java.io.File fun Context.isOnMainThread() = Looper.myLooper() == Looper.getMainLooper() fun Context.getSharedPrefs() = getSharedPreferences(PREFS_KEY, Context.MODE_PRIVATE) fun Context.isJellyBean1Plus() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 fun Context.isAndroidFour() = Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT_WATCH fun Context.isKitkatPlus() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT fun Context.isLollipopPlus() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP Loading @@ -40,6 +42,8 @@ fun Context.isMarshmallowPlus() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.M fun Context.isNougatPlus() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.N fun Context.isOreoPlus() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O val Context.isRTLLayout: Boolean get() = if (isJellyBean1Plus()) resources.configuration.layoutDirection == View.LAYOUT_DIRECTION_RTL else false fun Context.updateTextColors(viewGroup: ViewGroup, tmpTextColor: Int = 0, tmpAccentColor: Int = 0) { val textColor = if (tmpTextColor == 0) baseConfig.textColor else tmpTextColor val accentColor = if (tmpAccentColor == 0) baseConfig.primaryColor else tmpAccentColor Loading
commons/src/main/kotlin/com/simplemobiletools/commons/views/LineColorPicker.kt +5 −1 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ import android.view.LayoutInflater import android.view.MotionEvent import android.widget.LinearLayout import com.simplemobiletools.commons.R import com.simplemobiletools.commons.extensions.isRTLLayout import com.simplemobiletools.commons.extensions.onGlobalLayout import com.simplemobiletools.commons.interfaces.LineColorPickerListener import java.util.* Loading Loading @@ -81,7 +82,10 @@ class LineColorPicker(context: Context, attrs: AttributeSet) : LinearLayout(cont } private fun touchAt(touchX: Int) { val colorIndex = touchX / stripeWidth var colorIndex = touchX / stripeWidth if (context.isRTLLayout) { colorIndex = colors.size - colorIndex - 1 } val index = Math.max(0, Math.min(colorIndex, colorsCount - 1)) if (lastColorIndex != index) { updateItemMargin(lastColorIndex, true) Loading