aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2018-02-13 16:51:56 -0500
committerGitHub <noreply@github.com>2018-02-13 16:51:56 -0500
commitcdb1bd6eec2c90abc9d3d982814552443c7fc3b2 (patch)
tree2d21dfcce61fec76384d862b410ee61579169bc2
parentf5d6ddb72a3dc369b95631a607471f9a6ea5e70f (diff)
downloadkau-cdb1bd6eec2c90abc9d3d982814552443c7fc3b2.tar.gz
kau-cdb1bd6eec2c90abc9d3d982814552443c7fc3b2.tar.bz2
kau-cdb1bd6eec2c90abc9d3d982814552443c7fc3b2.zip
Update docs (#135)
* Update docs * Update format * Update dependencies
-rw-r--r--about/src/main/kotlin/ca/allanwang/kau/about/AboutActivityBase.kt7
-rw-r--r--about/src/main/kotlin/ca/allanwang/kau/about/AboutPanelDelegate.kt6
-rw-r--r--about/src/main/kotlin/ca/allanwang/kau/about/LibraryIItem.kt9
-rw-r--r--buildSrc/src/main/groovy/ca/allanwang/kau/Versions.groovy8
-rw-r--r--colorpicker/src/main/kotlin/ca/allanwang/kau/colorpicker/CircleView.kt20
-rw-r--r--colorpicker/src/main/kotlin/ca/allanwang/kau/colorpicker/ColorPalette.kt2
-rw-r--r--colorpicker/src/main/kotlin/ca/allanwang/kau/colorpicker/ColorPickerView.kt28
-rw-r--r--core-ui/src/main/res-public/values/public.xml2
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/email/EmailBuilder.kt15
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefDelegate.kt4
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefSingleDelegate.kt4
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/logging/KL.kt2
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/logging/KauLogger.kt2
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/permissions/PermissionManager.kt11
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/permissions/PermissionResult.kt2
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/permissions/Permissions.kt3
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/ui/views/RippleCanvas.kt1
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/utils/FontUtils.kt2
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/utils/IIconUtils.kt3
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/utils/NetworkUtils.kt4
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/utils/RecyclerUtils.kt2
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/xml/Changelog.kt3
-rw-r--r--core/src/main/res-public/values/public.xml96
-rw-r--r--docs/Changelog.md1
-rw-r--r--mediapicker/src/main/res-public/values/public.xml4
25 files changed, 133 insertions, 108 deletions
diff --git a/about/src/main/kotlin/ca/allanwang/kau/about/AboutActivityBase.kt b/about/src/main/kotlin/ca/allanwang/kau/about/AboutActivityBase.kt
index 442821f..bfbc941 100644
--- a/about/src/main/kotlin/ca/allanwang/kau/about/AboutActivityBase.kt
+++ b/about/src/main/kotlin/ca/allanwang/kau/about/AboutActivityBase.kt
@@ -126,7 +126,8 @@ abstract class AboutActivityBase(val rClass: Class<*>?, private val configBuilde
* Method to fetch the library list
* This is fetched asynchronously and you may override it to customize the list
*/
- open fun getLibraries(libs: Libs): List<Library> = libs.prepareLibraries(this, null, null, true, true)!!
+ open fun getLibraries(libs: Libs): List<Library> =
+ libs.prepareLibraries(this, null, null, true, true, true)!!
/*
* -------------------------------------------------------------------
@@ -164,9 +165,9 @@ abstract class AboutActivityBase(val rClass: Class<*>?, private val configBuilde
}
}
- override fun onPageScrollStateChanged(state: Int) {}
+ override fun onPageScrollStateChanged(state: Int) = Unit
- override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {}
+ override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) = Unit
override fun onPageSelected(position: Int) {
if (pageStatus[position] == 0) pageStatus[position] = 1 // mark as seen if previously null
diff --git a/about/src/main/kotlin/ca/allanwang/kau/about/AboutPanelDelegate.kt b/about/src/main/kotlin/ca/allanwang/kau/about/AboutPanelDelegate.kt
index 47b9ac4..b6ea16b 100644
--- a/about/src/main/kotlin/ca/allanwang/kau/about/AboutPanelDelegate.kt
+++ b/about/src/main/kotlin/ca/allanwang/kau/about/AboutPanelDelegate.kt
@@ -114,7 +114,7 @@ open class AboutPanelMain : AboutPanelRecycler() {
override fun inflatePage(activity: AboutActivityBase, parent: ViewGroup, position: Int): View {
with(activity) {
- adapter = FastItemThemedAdapter<IItem<*, *>>(configs)
+ adapter = FastItemThemedAdapter(configs)
recycler = fullLinearRecycler(adapter)
adapter.add(CutoutIItem {
with(configs) {
@@ -156,7 +156,7 @@ open class AboutPanelLibs : AboutPanelRecycler() {
doAsync {
with(activity) {
items = getLibraries(if (rClass == null) Libs(activity) else Libs(this, Libs.toStringArray(rClass.fields)))
- .map { LibraryIItem(it) }
+ .map(::LibraryIItem)
if (pageStatus[position] == 1)
uiThread { addItems(activity, position) }
}
@@ -181,7 +181,7 @@ open class AboutPanelFaqs : AboutPanelRecycler() {
override fun loadItems(activity: AboutActivityBase, position: Int) {
with(activity) {
kauParseFaq(configs.faqXmlRes, configs.faqParseNewLine) {
- items = it.map { FaqIItem(it) }
+ items = it.map(::FaqIItem)
if (pageStatus[position] == 1)
addItems(activity, position)
}
diff --git a/about/src/main/kotlin/ca/allanwang/kau/about/LibraryIItem.kt b/about/src/main/kotlin/ca/allanwang/kau/about/LibraryIItem.kt
index 89906c3..d71f786 100644
--- a/about/src/main/kotlin/ca/allanwang/kau/about/LibraryIItem.kt
+++ b/about/src/main/kotlin/ca/allanwang/kau/about/LibraryIItem.kt
@@ -47,10 +47,11 @@ class LibraryIItem(val lib: Library) : KauIItem<LibraryIItem, LibraryIItem.ViewH
name.text = lib.libraryName
creator.text = lib.author
@Suppress("DEPRECATION")
- description.text = if (lib.libraryDescription.isBlank()) lib.libraryDescription
- else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
- Html.fromHtml(lib.libraryDescription, Html.FROM_HTML_MODE_LEGACY)
- else Html.fromHtml(lib.libraryDescription)
+ description.text = when {
+ lib.libraryDescription.isBlank() -> lib.libraryDescription
+ Build.VERSION.SDK_INT >= Build.VERSION_CODES.N -> Html.fromHtml(lib.libraryDescription, Html.FROM_HTML_MODE_LEGACY)
+ else -> Html.fromHtml(lib.libraryDescription)
+ }
bottomDivider.gone()
if (lib.libraryVersion?.isNotBlank() == true) {
bottomDivider.visible()
diff --git a/buildSrc/src/main/groovy/ca/allanwang/kau/Versions.groovy b/buildSrc/src/main/groovy/ca/allanwang/kau/Versions.groovy
index 4633a4d..36e444d 100644
--- a/buildSrc/src/main/groovy/ca/allanwang/kau/Versions.groovy
+++ b/buildSrc/src/main/groovy/ca/allanwang/kau/Versions.groovy
@@ -10,13 +10,13 @@ class Versions {
static def kotlin = '1.2.21'
- static def aboutLibraries = '6.0.1'
+ static def aboutLibraries = '6.0.5'
static def anko = '0.10.4'
static def blurry = '2.1.1'
- static def constraintLayout = '1.1.0-beta4'
+ static def constraintLayout = '1.1.0-beta5'
static def fastAdapter = '3.1.2'
- static def fastAdapterCommons = '3.1.2'
- static def glide = '4.5.0'
+ static def fastAdapterCommons = fastAdapter
+ static def glide = '4.6.1'
static def iconics = '3.0.2'
static def iconicsGoogle = '3.0.1.2'
diff --git a/colorpicker/src/main/kotlin/ca/allanwang/kau/colorpicker/CircleView.kt b/colorpicker/src/main/kotlin/ca/allanwang/kau/colorpicker/CircleView.kt
index 713b800..c74cba1 100644
--- a/colorpicker/src/main/kotlin/ca/allanwang/kau/colorpicker/CircleView.kt
+++ b/colorpicker/src/main/kotlin/ca/allanwang/kau/colorpicker/CircleView.kt
@@ -47,7 +47,6 @@ class CircleView @JvmOverloads constructor(context: Context, attrs: AttributeSet
private val innerPaint: Paint = Paint().apply { isAntiAlias = true }
private var selected: Boolean = false
var withBorder: Boolean = false
- get() = field
set(value) {
if (field != value) {
field = value
@@ -65,13 +64,13 @@ class CircleView @JvmOverloads constructor(context: Context, attrs: AttributeSet
outerPaint.color = shiftColorDown(color)
val selector = createSelector(color)
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ foreground = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
val states = arrayOf(intArrayOf(android.R.attr.state_pressed))
val colors = intArrayOf(shiftColorUp(color))
val rippleColors = ColorStateList(states, colors)
- foreground = RippleDrawable(rippleColors, selector, null)
+ RippleDrawable(rippleColors, selector, null)
} else {
- foreground = selector
+ selector
}
}
@@ -85,20 +84,17 @@ class CircleView @JvmOverloads constructor(context: Context, attrs: AttributeSet
setBackgroundColorRes(color)
}
-
- @Deprecated("")
+ @Deprecated("Cannot use setBackground() on CircleView", level = DeprecationLevel.ERROR)
override fun setBackground(background: Drawable) {
throw IllegalStateException("Cannot use setBackground() on CircleView.")
}
-
- @Deprecated("")
+ @Deprecated("Cannot use setBackgroundDrawable() on CircleView", level = DeprecationLevel.ERROR)
override fun setBackgroundDrawable(background: Drawable) {
throw IllegalStateException("Cannot use setBackgroundDrawable() on CircleView.")
}
-
- @Deprecated("")
+ @Deprecated("Cannot use setActivated() on CircleView", level = DeprecationLevel.ERROR)
override fun setActivated(activated: Boolean) {
throw IllegalStateException("Cannot use setActivated() on CircleView.")
}
@@ -194,10 +190,10 @@ class CircleView @JvmOverloads constructor(context: Context, attrs: AttributeSet
cheatSheet.show()
}
- companion object {
+ private companion object {
@ColorInt
- private fun translucentColor(color: Int): Int {
+ fun translucentColor(color: Int): Int {
val factor = 0.7f
val alpha = Math.round(Color.alpha(color) * factor)
val red = Color.red(color)
diff --git a/colorpicker/src/main/kotlin/ca/allanwang/kau/colorpicker/ColorPalette.kt b/colorpicker/src/main/kotlin/ca/allanwang/kau/colorpicker/ColorPalette.kt
index b08767c..68e3461 100644
--- a/colorpicker/src/main/kotlin/ca/allanwang/kau/colorpicker/ColorPalette.kt
+++ b/colorpicker/src/main/kotlin/ca/allanwang/kau/colorpicker/ColorPalette.kt
@@ -344,6 +344,6 @@ internal object ColorPalette {
"#DD2C00"))
}
- fun colorArrayOf(vararg colors: String) = colors.map { Color.parseColor(it) }.toIntArray()
+ private fun colorArrayOf(vararg colors: String) = colors.map { Color.parseColor(it) }.toIntArray()
}
diff --git a/colorpicker/src/main/kotlin/ca/allanwang/kau/colorpicker/ColorPickerView.kt b/colorpicker/src/main/kotlin/ca/allanwang/kau/colorpicker/ColorPickerView.kt
index e9da763..778b775 100644
--- a/colorpicker/src/main/kotlin/ca/allanwang/kau/colorpicker/ColorPickerView.kt
+++ b/colorpicker/src/main/kotlin/ca/allanwang/kau/colorpicker/ColorPickerView.kt
@@ -1,5 +1,6 @@
package ca.allanwang.kau.colorpicker
+import android.annotation.SuppressLint
import android.content.Context
import android.graphics.Color
import android.support.annotation.ColorInt
@@ -29,6 +30,7 @@ internal class ColorPickerView @JvmOverloads constructor(
var isInSub: Boolean = false
var isInCustom: Boolean = false
var circleSize: Int = context.dimen(R.dimen.kau_color_circle_size).toInt()
+ @SuppressLint("PrivateResource")
val backgroundColor = context.resolveColor(R.attr.md_background_color,
if (context.resolveColor(android.R.attr.textColorPrimary).isColorDark) Color.WHITE else 0xff424242.toInt())
val backgroundColorTint = backgroundColor.colorToForeground()
@@ -52,7 +54,6 @@ internal class ColorPickerView @JvmOverloads constructor(
}
}
-
val gridView: FillGridView by bindView(R.id.md_grid)
val customFrame: LinearLayout by bindView(R.id.md_colorChooserCustomFrame)
val customColorIndicator: View by bindView(R.id.md_colorIndicator)
@@ -126,10 +127,10 @@ internal class ColorPickerView @JvmOverloads constructor(
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {}
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {
- try {
- selectedColor = Color.parseColor("#" + s.toString())
+ selectedColor = try {
+ Color.parseColor("#$s")
} catch (e: IllegalArgumentException) {
- selectedColor = Color.BLACK
+ Color.BLACK
}
customColorIndicator.setBackgroundColor(selectedColor)
@@ -171,9 +172,9 @@ internal class ColorPickerView @JvmOverloads constructor(
blueValue.text = blueSeekbar.progress.toString()
}
- override fun onStartTrackingTouch(seekBar: SeekBar) {}
+ override fun onStartTrackingTouch(seekBar: SeekBar) = Unit
- override fun onStopTrackingTouch(seekBar: SeekBar) {}
+ override fun onStopTrackingTouch(seekBar: SeekBar) = Unit
}
redSeekbar.setOnSeekBarChangeListener(customRgbListener)
greenSeekbar.setOnSeekBarChangeListener(customRgbListener)
@@ -187,7 +188,7 @@ internal class ColorPickerView @JvmOverloads constructor(
findColor(selectedColor)
if (builder.allowCustom) dialog.setActionButton(DialogAction.NEUTRAL, builder.customText)
dialog.setActionButton(DialogAction.NEGATIVE, if (isInSub) builder.backText else builder.cancelText)
- gridView.fadeIn(onStart = { invalidateGrid() })
+ gridView.fadeIn(onStart = this::invalidateGrid)
customFrame.fadeOut(onFinish = { customFrame.gone() })
hexInput.removeTextChangedListener(customHexTextWatcher)
customHexTextWatcher = null
@@ -217,11 +218,10 @@ internal class ColorPickerView @JvmOverloads constructor(
hexInput.tint(visibleColor)
}
- fun findColor(@ColorInt color: Int): Boolean {
+ private fun findColor(@ColorInt color: Int): Boolean {
topIndex = -1
subIndex = -1
- colorsTop.forEachIndexed {
- index, topColor ->
+ colorsTop.forEachIndexed { index, topColor ->
if (findSubColor(color, index)) {
topIndex = index
return true
@@ -234,10 +234,9 @@ internal class ColorPickerView @JvmOverloads constructor(
return false
}
- fun findSubColor(@ColorInt color: Int, topIndex: Int): Boolean {
+ private fun findSubColor(@ColorInt color: Int, topIndex: Int): Boolean {
if (colorsSub == null || colorsSub!!.size <= topIndex) return false
- colorsSub!![topIndex].forEachIndexed {
- index, subColor ->
+ colorsSub!![topIndex].forEachIndexed { index, subColor ->
if (subColor == color) {
subIndex = index
return true
@@ -246,7 +245,7 @@ internal class ColorPickerView @JvmOverloads constructor(
return false
}
- fun invalidateGrid() {
+ private fun invalidateGrid() {
if (gridView.adapter == null) {
gridView.adapter = ColorGridAdapter()
gridView.selector = ResourcesCompat.getDrawable(resources, R.drawable.kau_transparent, null)
@@ -303,6 +302,5 @@ internal class ColorPickerView @JvmOverloads constructor(
setOnLongClickListener(this@ColorGridAdapter)
}
}
-
}
} \ No newline at end of file
diff --git a/core-ui/src/main/res-public/values/public.xml b/core-ui/src/main/res-public/values/public.xml
index dcaa583..193e088 100644
--- a/core-ui/src/main/res-public/values/public.xml
+++ b/core-ui/src/main/res-public/values/public.xml
@@ -1,8 +1,8 @@
<resources xmlns:tools='http://schemas.android.com/tools' tools:ignore='ResourceName'>
<!-- AUTO-GENERATED FILE. DO NOT MODIFY. public.xml is generated by the generatepublicxml gradle task -->
+ <public name='kau_elastic_recycler_activity' type='layout' />
<public name='kau_recycler_detached_background' type='layout' />
<public name='kau_recycler_textslider' type='layout' />
- <public name='kau_elastic_recycler_activity' type='layout' />
<public name='Kau.Translucent' type='style' />
<public name='Kau.Translucent.NoAnimation' type='style' />
<public name='Kau.Translucent.SlideBottom' type='style' />
diff --git a/core/src/main/kotlin/ca/allanwang/kau/email/EmailBuilder.kt b/core/src/main/kotlin/ca/allanwang/kau/email/EmailBuilder.kt
index 9dd5bea..804eacb 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/email/EmailBuilder.kt
+++ b/core/src/main/kotlin/ca/allanwang/kau/email/EmailBuilder.kt
@@ -15,6 +15,8 @@ import ca.allanwang.kau.utils.*
/**
* Created by Allan Wang on 2017-06-20.
+ *
+ * Helper tool to call an email intent with device information
*/
class EmailBuilder(val email: String, val subject: String) {
var message: String = "Write here."
@@ -34,6 +36,9 @@ class EmailBuilder(val email: String, val subject: String) {
attachment = uri
}
+ /**
+ * Optional handler to update the created intent
+ */
var extras: Intent.() -> Unit = {}
data class Package(val packageName: String, val appName: String)
@@ -72,10 +77,12 @@ class EmailBuilder(val email: String, val subject: String) {
}
}
- if (packages.isNotEmpty()) emailBuilder.append("\n")
- packages.forEach {
- if (context.isAppInstalled(it.packageName))
- emailBuilder.append(String.format("\n%s is installed", it.appName))
+ if (packages.isNotEmpty()) {
+ emailBuilder.append("\n")
+ packages.forEach {
+ if (context.isAppInstalled(it.packageName))
+ emailBuilder.append(String.format("\n%s is installed", it.appName))
+ }
}
if (pairs.isNotEmpty()) {
diff --git a/core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefDelegate.kt b/core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefDelegate.kt
index ca3701b..33ba807 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefDelegate.kt
+++ b/core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefDelegate.kt
@@ -21,8 +21,8 @@ class StringSet(set: Collection<String>) : LinkedHashSet<String>(set)
* Also contains an optional mutable postSetter that will be called every time a new value is given
*/
class KPrefDelegate<T : Any> internal constructor(
- private val key: String, private val fallback: T, private val pref: KPref, var postSetter: (value: T) -> Unit = {}, lock: Any? = null
-) : ILazyResettable<T>, java.io.Serializable {
+ private val key: String, private val fallback: T, private val pref: KPref, private var postSetter: (value: T) -> Unit = {}, lock: Any? = null
+) : ILazyResettable<T> {
private object UNINITIALIZED
diff --git a/core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefSingleDelegate.kt b/core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefSingleDelegate.kt
index ff08e3c..6525305 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefSingleDelegate.kt
+++ b/core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefSingleDelegate.kt
@@ -8,8 +8,8 @@ fun KPref.kprefSingle(key: String) = KPrefSingleDelegate(key, this)
* Created by Allan Wang on 2017-06-07.
*
* Singular KPref Delegate for booleans
- * When the shared pref is not initialized, it will return true then set the pref to false
- * All subsequent retrievals will be false
+ * When the shared pref is not initialized, it will return [true] then set the pref to [false]
+ * All subsequent retrievals will be [false]
* This is useful for one time toggles such as showcasing items
*/
class KPrefSingleDelegate internal constructor(private val key: String, private val pref: KPref, lock: Any? = null) : ILazyResettable<Boolean> {
diff --git a/core/src/main/kotlin/ca/allanwang/kau/logging/KL.kt b/core/src/main/kotlin/ca/allanwang/kau/logging/KL.kt
index f690571..9f48ab5 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/logging/KL.kt
+++ b/core/src/main/kotlin/ca/allanwang/kau/logging/KL.kt
@@ -4,5 +4,7 @@ import ca.allanwang.kau.BuildConfig
/**
* Created by Allan Wang on 2017-06-19.
+ *
+ * Internal KAU logger
*/
object KL : KauLogger("KAU", { BuildConfig.DEBUG }) \ No newline at end of file
diff --git a/core/src/main/kotlin/ca/allanwang/kau/logging/KauLogger.kt b/core/src/main/kotlin/ca/allanwang/kau/logging/KauLogger.kt
index e639867..799d32f 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/logging/KauLogger.kt
+++ b/core/src/main/kotlin/ca/allanwang/kau/logging/KauLogger.kt
@@ -21,6 +21,8 @@ import android.util.Log
* inline fun _d(message: () -> Any?) {
* if (BuildConfig.DEBUG) d(message)
* }
+ * This use case allows for a constant boolean check, which should be caught and removed by proguard
+ * for production builds
*/
open class KauLogger(
/**
diff --git a/core/src/main/kotlin/ca/allanwang/kau/permissions/PermissionManager.kt b/core/src/main/kotlin/ca/allanwang/kau/permissions/PermissionManager.kt
index 8b639ad..3b15e0b 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/permissions/PermissionManager.kt
+++ b/core/src/main/kotlin/ca/allanwang/kau/permissions/PermissionManager.kt
@@ -15,6 +15,9 @@ import java.lang.ref.WeakReference
/**
* Created by Allan Wang on 2017-07-03.
+ *
+ * Permission manager that is decoupled from activities
+ * Keeps track of pending requests, and warns about invalid requests
*/
internal object PermissionManager {
@@ -24,7 +27,7 @@ internal object PermissionManager {
/**
* Retrieve permissions requested in our manifest
*/
- val manifestPermission = lazyContext<Array<String>> {
+ private val manifestPermission = lazyContext<Array<String>> {
try {
it.packageManager.getPackageInfo(it.packageName, PackageManager.GET_PERMISSIONS)?.requestedPermissions ?: emptyArray()
} catch (e: Exception) {
@@ -44,7 +47,7 @@ internal object PermissionManager {
} else KL.d { "Request is postponed since another one is still in progress; did you remember to override onRequestPermissionsResult?" }
}
- @Synchronized internal fun requestPermissions(context: Context, permissions: Array<out String>) {
+ @Synchronized private fun requestPermissions(context: Context, permissions: Array<out String>) {
permissions.forEach {
if (!manifestPermission(context).contains(it)) {
KL.e { "Requested permission $it is not stated in the manifest" }
@@ -57,6 +60,10 @@ internal object PermissionManager {
ActivityCompat.requestPermissions(activity, permissions, 1)
}
+ /**
+ * Handles permission result by allowing accepted permissions for all pending requests
+ * Also cleans up destroyed or completed pending requests
+ */
fun onRequestPermissionsResult(context: Context, permissions: Array<out String>, grantResults: IntArray) {
KL.i { "On permission result: pending ${pendingResults.size}" }
val count = Math.min(permissions.size, grantResults.size)
diff --git a/core/src/main/kotlin/ca/allanwang/kau/permissions/PermissionResult.kt b/core/src/main/kotlin/ca/allanwang/kau/permissions/PermissionResult.kt
index 14bfdff..ba3e6dd 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/permissions/PermissionResult.kt
+++ b/core/src/main/kotlin/ca/allanwang/kau/permissions/PermissionResult.kt
@@ -4,6 +4,8 @@ import android.content.pm.PackageManager
/**
* Created by Allan Wang on 2017-07-03.
+ *
+ * Pending permission collector
*/
class PermissionResult(permissions: Array<out String>, val callback: (granted: Boolean, deniedPerm: String?) -> Unit) {
val permissions = mutableSetOf(*permissions)
diff --git a/core/src/main/kotlin/ca/allanwang/kau/permissions/Permissions.kt b/core/src/main/kotlin/ca/allanwang/kau/permissions/Permissions.kt
index 36ad52f..4de6695 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/permissions/Permissions.kt
+++ b/core/src/main/kotlin/ca/allanwang/kau/permissions/Permissions.kt
@@ -3,6 +3,8 @@ package ca.allanwang.kau.permissions
import android.Manifest
import android.app.Activity
import android.content.Context
+import android.os.Build
+import android.support.annotation.RequiresApi
/**
@@ -60,6 +62,7 @@ const val PERMISSION_ADD_VOICEMAIL = Manifest.permission.ADD_VOICEMAIL
const val PERMISSION_USE_SIP = Manifest.permission.USE_SIP
const val PERMISSION_PROCESS_OUTGOING_CALLS = Manifest.permission.PROCESS_OUTGOING_CALLS
+@RequiresApi(Build.VERSION_CODES.KITKAT_WATCH)
const val PERMISSION_BODY_SENSORS = Manifest.permission.BODY_SENSORS
const val PERMISSION_SEND_SMS = Manifest.permission.SEND_SMS
diff --git a/core/src/main/kotlin/ca/allanwang/kau/ui/views/RippleCanvas.kt b/core/src/main/kotlin/ca/allanwang/kau/ui/views/RippleCanvas.kt
index 86aba6e..62a16d9 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/ui/views/RippleCanvas.kt
+++ b/core/src/main/kotlin/ca/allanwang/kau/ui/views/RippleCanvas.kt
@@ -12,7 +12,6 @@ import android.view.View
/**
* Created by Allan Wang on 2016-11-17.
*
- *
* Canvas drawn ripples that keep the previous color
* Extends to view dimensions
* Supports multiple ripples from varying locations
diff --git a/core/src/main/kotlin/ca/allanwang/kau/utils/FontUtils.kt b/core/src/main/kotlin/ca/allanwang/kau/utils/FontUtils.kt
index 3fc509d..05073c7 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/utils/FontUtils.kt
+++ b/core/src/main/kotlin/ca/allanwang/kau/utils/FontUtils.kt
@@ -8,7 +8,7 @@ import android.graphics.Typeface
*/
object FontUtils {
- val sTypefaceCache: MutableMap<String, Typeface> = mutableMapOf()
+ private val sTypefaceCache: MutableMap<String, Typeface> = mutableMapOf()
fun get(context: Context, font: String): Typeface {
synchronized(sTypefaceCache) {
diff --git a/core/src/main/kotlin/ca/allanwang/kau/utils/IIconUtils.kt b/core/src/main/kotlin/ca/allanwang/kau/utils/IIconUtils.kt
index a8c710e..51691af 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/utils/IIconUtils.kt
+++ b/core/src/main/kotlin/ca/allanwang/kau/utils/IIconUtils.kt
@@ -14,7 +14,8 @@ import com.mikepenz.iconics.typeface.IIcon
@KauUtils
fun IIcon.toDrawable(c: Context, sizeDp: Int = 24, @ColorInt color: Int = Color.WHITE, builder: IconicsDrawable.() -> Unit = {}): Drawable {
val state = ColorStateList.valueOf(color)
- val icon = IconicsDrawable(c).icon(this).sizeDp(sizeDp).color(state)
+ val icon = IconicsDrawable(c).icon(this).color(state)
+ if (sizeDp > 0) icon.sizeDp(sizeDp)
icon.builder()
return icon
} \ No newline at end of file
diff --git a/core/src/main/kotlin/ca/allanwang/kau/utils/NetworkUtils.kt b/core/src/main/kotlin/ca/allanwang/kau/utils/NetworkUtils.kt
index 53016be..2271c16 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/utils/NetworkUtils.kt
+++ b/core/src/main/kotlin/ca/allanwang/kau/utils/NetworkUtils.kt
@@ -1,5 +1,6 @@
package ca.allanwang.kau.utils
+import android.annotation.SuppressLint
import android.content.Context
import android.net.ConnectivityManager
@@ -7,6 +8,7 @@ import android.net.ConnectivityManager
* Created by Allan Wang on 2017-07-07.
*/
inline val Context.isNetworkAvailable: Boolean
+ @SuppressLint("MissingPermission")
get() {
val connectivityManager = getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
val activeNetworkInfo = connectivityManager.activeNetworkInfo
@@ -14,6 +16,7 @@ inline val Context.isNetworkAvailable: Boolean
}
inline val Context.isWifiConnected: Boolean
+ @SuppressLint("MissingPermission")
get() {
val connectivityManager = getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
val activeNetworkInfo = connectivityManager.activeNetworkInfo
@@ -21,6 +24,7 @@ inline val Context.isWifiConnected: Boolean
}
inline val Context.isMobileDataConnected: Boolean
+ @SuppressLint("MissingPermission")
get() {
val connectivityManager = getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
val activeNetworkInfo = connectivityManager.activeNetworkInfo
diff --git a/core/src/main/kotlin/ca/allanwang/kau/utils/RecyclerUtils.kt b/core/src/main/kotlin/ca/allanwang/kau/utils/RecyclerUtils.kt
index f80c85e..3a34db5 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/utils/RecyclerUtils.kt
+++ b/core/src/main/kotlin/ca/allanwang/kau/utils/RecyclerUtils.kt
@@ -13,7 +13,7 @@ fun RecyclerView.withMarginDecoration(sizeDp: Int, edgeFlags: Int) {
class MarginItemDecoration(sizeDp: Int, val edgeFlags: Int) : RecyclerView.ItemDecoration() {
- val sizePx = sizeDp.dpToPx
+ private val sizePx = sizeDp.dpToPx
override fun getItemOffsets(outRect: Rect, view: View, parent: RecyclerView, state: RecyclerView.State) {
super.getItemOffsets(outRect, view, parent, state)
diff --git a/core/src/main/kotlin/ca/allanwang/kau/xml/Changelog.kt b/core/src/main/kotlin/ca/allanwang/kau/xml/Changelog.kt
index cbebd55..83b182f 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/xml/Changelog.kt
+++ b/core/src/main/kotlin/ca/allanwang/kau/xml/Changelog.kt
@@ -23,8 +23,9 @@ import org.xmlpull.v1.XmlPullParser
/**
* Created by Allan Wang on 2017-05-28.
+ *
+ * Easy changelog loader
*/
-
fun Context.showChangelog(@XmlRes xmlRes: Int, @ColorInt textColor: Int? = null, customize: MaterialDialog.Builder.() -> Unit = {}) {
doAsync {
val items = parse(this@showChangelog, xmlRes)
diff --git a/core/src/main/res-public/values/public.xml b/core/src/main/res-public/values/public.xml
index f831c6d..2163b10 100644
--- a/core/src/main/res-public/values/public.xml
+++ b/core/src/main/res-public/values/public.xml
@@ -1,29 +1,56 @@
<resources xmlns:tools='http://schemas.android.com/tools' tools:ignore='ResourceName'>
<!-- AUTO-GENERATED FILE. DO NOT MODIFY. public.xml is generated by the generatepublicxml gradle task -->
- <public name='kau_exit_slide_bottom' type='transition' />
- <public name='kau_exit_slide_left' type='transition' />
- <public name='kau_enter_slide_right' type='transition' />
- <public name='kau_exit_slide_top' type='transition' />
- <public name='kau_exit_slide_right' type='transition' />
- <public name='kau_enter_slide_bottom' type='transition' />
- <public name='kau_enter_slide_top' type='transition' />
- <public name='kau_enter_slide_left' type='transition' />
- <public name='kau_selectable_white' type='drawable' />
- <public name='kau_transparent' type='drawable' />
- <public name='kau_fade_out' type='anim' />
- <public name='kau_slide_in_right' type='anim' />
<public name='kau_fade_in' type='anim' />
- <public name='kau_slide_out_right' type='anim' />
- <public name='kau_slide_out_left' type='anim' />
+ <public name='kau_fade_out' type='anim' />
+ <public name='kau_slide_in_bottom' type='anim' />
<public name='kau_slide_in_left' type='anim' />
+ <public name='kau_slide_in_right' type='anim' />
+ <public name='kau_slide_in_top' type='anim' />
<public name='kau_slide_out_bottom' type='anim' />
+ <public name='kau_slide_out_left' type='anim' />
+ <public name='kau_slide_out_left_top' type='anim' />
+ <public name='kau_slide_out_right' type='anim' />
<public name='kau_slide_out_right_top' type='anim' />
- <public name='kau_slide_in_top' type='anim' />
<public name='kau_slide_out_top' type='anim' />
- <public name='kau_slide_in_bottom' type='anim' />
- <public name='kau_slide_out_left_top' type='anim' />
- <public name='Kau' type='style' />
- <public name='Kau.Translucent' type='style' />
+ <public name='kau_selectable_white' type='drawable' />
+ <public name='kau_transparent' type='drawable' />
+ <public name='kau_enter_slide_bottom' type='transition' />
+ <public name='kau_enter_slide_left' type='transition' />
+ <public name='kau_enter_slide_right' type='transition' />
+ <public name='kau_enter_slide_top' type='transition' />
+ <public name='kau_exit_slide_bottom' type='transition' />
+ <public name='kau_exit_slide_left' type='transition' />
+ <public name='kau_exit_slide_right' type='transition' />
+ <public name='kau_exit_slide_top' type='transition' />
+ <public name='kau_shadow_overlay' type='color' />
+ <public name='kau_activity_horizontal_margin' type='dimen' />
+ <public name='kau_activity_vertical_margin' type='dimen' />
+ <public name='kau_dialog_margin' type='dimen' />
+ <public name='kau_dialog_margin_bottom' type='dimen' />
+ <public name='kau_fab_margin' type='dimen' />
+ <public name='kau_appbar_padding_top' type='dimen' />
+ <public name='kau_splash_logo' type='dimen' />
+ <public name='kau_progress_bar_height' type='dimen' />
+ <public name='kau_account_image_size' type='dimen' />
+ <public name='kau_status_bar_height' type='dimen' />
+ <public name='kau_drag_dismiss_distance' type='dimen' />
+ <public name='kau_drag_dismiss_distance_large' type='dimen' />
+ <public name='kau_spacing_normal' type='dimen' />
+ <public name='kau_spacing_micro' type='dimen' />
+ <public name='kau_spacing_large' type='dimen' />
+ <public name='kau_spacing_xlarge' type='dimen' />
+ <public name='kau_spacing_huge' type='dimen' />
+ <public name='kau_padding_small' type='dimen' />
+ <public name='kau_padding_normal' type='dimen' />
+ <public name='kau_padding_large' type='dimen' />
+ <public name='kau_fab_size' type='dimen' />
+ <public name='kau_fab_radius' type='dimen' />
+ <public name='kau_display_4_text_size' type='dimen' />
+ <public name='kau_avatar_size' type='dimen' />
+ <public name='kau_avatar_bounds' type='dimen' />
+ <public name='kau_avatar_padding' type='dimen' />
+ <public name='kau_avatar_margin' type='dimen' />
+ <public name='kau_avatar_ripple_radius' type='dimen' />
<public name='kau_about_app' type='string' />
<public name='kau_about_x' type='string' />
<public name='kau_add_account' type='string' />
@@ -79,7 +106,8 @@
<public name='kau_permission_denied' type='string' />
<public name='kau_0' type='string' />
<public name='kau_bullet_point' type='string' />
- <public name='kau_shadow_overlay' type='color' />
+ <public name='Kau' type='style' />
+ <public name='Kau.Translucent' type='style' />
<public name='KauFadeIn' type='style' />
<public name='KauFadeInFadeOut' type='style' />
<public name='KauSlideInRight' type='style' />
@@ -87,32 +115,4 @@
<public name='KauSlideInFadeOut' type='style' />
<public name='KauSlideInSlideOutRight' type='style' />
<public name='KauSlideInSlideOutBottom' type='style' />
- <public name='kau_activity_horizontal_margin' type='dimen' />
- <public name='kau_activity_vertical_margin' type='dimen' />
- <public name='kau_dialog_margin' type='dimen' />
- <public name='kau_dialog_margin_bottom' type='dimen' />
- <public name='kau_fab_margin' type='dimen' />
- <public name='kau_appbar_padding_top' type='dimen' />
- <public name='kau_splash_logo' type='dimen' />
- <public name='kau_progress_bar_height' type='dimen' />
- <public name='kau_account_image_size' type='dimen' />
- <public name='kau_status_bar_height' type='dimen' />
- <public name='kau_drag_dismiss_distance' type='dimen' />
- <public name='kau_drag_dismiss_distance_large' type='dimen' />
- <public name='kau_spacing_normal' type='dimen' />
- <public name='kau_spacing_micro' type='dimen' />
- <public name='kau_spacing_large' type='dimen' />
- <public name='kau_spacing_xlarge' type='dimen' />
- <public name='kau_spacing_huge' type='dimen' />
- <public name='kau_padding_small' type='dimen' />
- <public name='kau_padding_normal' type='dimen' />
- <public name='kau_padding_large' type='dimen' />
- <public name='kau_fab_size' type='dimen' />
- <public name='kau_fab_radius' type='dimen' />
- <public name='kau_display_4_text_size' type='dimen' />
- <public name='kau_avatar_size' type='dimen' />
- <public name='kau_avatar_bounds' type='dimen' />
- <public name='kau_avatar_padding' type='dimen' />
- <public name='kau_avatar_margin' type='dimen' />
- <public name='kau_avatar_ripple_radius' type='dimen' />
</resources> \ No newline at end of file
diff --git a/docs/Changelog.md b/docs/Changelog.md
index 2b8f6d1..782db6e 100644
--- a/docs/Changelog.md
+++ b/docs/Changelog.md
@@ -3,6 +3,7 @@
## v3.6.3
* :core: Check for tablet in email builder
* :kpref-activity: Simplify internal code and add better encapsulation
+* :kpref-activity: Disable seekbar when kprefseekbar is disabled
* Add Chinese, Indonesian, Norwegian, Polish, Thai, and Turkish translations
* Add back git versioning
* Created gradle plugin for getting version updates
diff --git a/mediapicker/src/main/res-public/values/public.xml b/mediapicker/src/main/res-public/values/public.xml
index 3c6f0fa..ac608bb 100644
--- a/mediapicker/src/main/res-public/values/public.xml
+++ b/mediapicker/src/main/res-public/values/public.xml
@@ -1,7 +1,7 @@
<resources xmlns:tools='http://schemas.android.com/tools' tools:ignore='ResourceName'>
<!-- AUTO-GENERATED FILE. DO NOT MODIFY. public.xml is generated by the generatepublicxml gradle task -->
- <public name='Kau.MediaPicker' type='style' />
- <public name='Kau.MediaPicker.Overlay' type='style' />
<public name='kau_blurred_image_selection_overlay' type='color' />
<public name='kau_image_minimum_size' type='dimen' />
+ <public name='Kau.MediaPicker' type='style' />
+ <public name='Kau.MediaPicker.Overlay' type='style' />
</resources> \ No newline at end of file