aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAllan Wang <allanwang@google.com>2019-07-27 18:59:14 -0700
committerAllan Wang <allanwang@google.com>2019-07-27 18:59:14 -0700
commit63f6b70cc81ec9dc6e92b6521dfd78fa72fe70a5 (patch)
treea7fdc9cd1ec78a6bd43c80fec33896a3d427d2b6
parent99f1e76a4d8d35d4d3ca1aadf68bbc227a70ba01 (diff)
downloadkau-63f6b70cc81ec9dc6e92b6521dfd78fa72fe70a5.tar.gz
kau-63f6b70cc81ec9dc6e92b6521dfd78fa72fe70a5.tar.bz2
kau-63f6b70cc81ec9dc6e92b6521dfd78fa72fe70a5.zip
Fix compile errors
-rw-r--r--about/src/main/kotlin/ca/allanwang/kau/about/AboutPanelDelegate.kt8
-rw-r--r--about/src/main/kotlin/ca/allanwang/kau/about/CutoutIItem.kt6
-rw-r--r--about/src/main/kotlin/ca/allanwang/kau/about/LibraryIItem.kt4
-rw-r--r--android-lib.gradle1
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/permissions/Permissions.kt3
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/utils/Kotterknife.kt6
-rw-r--r--fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/AdapterUtils.kt7
-rw-r--r--fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/FastItemThemedAdapter.kt34
-rw-r--r--fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/RepeatedClickListener.kt18
-rw-r--r--kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/KPrefActivity.kt13
-rw-r--r--kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefCheckbox.kt5
-rw-r--r--kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefColorPicker.kt10
-rw-r--r--kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefHeader.kt8
-rw-r--r--kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefItemBase.kt8
-rw-r--r--kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefItemCore.kt4
-rw-r--r--kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefPlainText.kt3
-rw-r--r--kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefSeekbar.kt11
-rw-r--r--kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefSubItems.kt6
-rw-r--r--kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefText.kt8
-rw-r--r--kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefTimePicker.kt17
-rw-r--r--mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/BlurredImageView.kt33
-rw-r--r--mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaActionItem.kt4
-rw-r--r--mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaItem.kt2
-rw-r--r--mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaItemBasic.kt21
-rw-r--r--mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaModel.kt2
-rw-r--r--mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerActivityBase.kt30
-rw-r--r--mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerActivityOverlayBase.kt2
-rw-r--r--mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerCore.kt63
-rw-r--r--sample/build.gradle1
-rw-r--r--sample/src/main/kotlin/ca/allanwang/kau/sample/AdapterActivity.kt2
-rw-r--r--sample/src/main/kotlin/ca/allanwang/kau/sample/AnimActivity.kt10
-rw-r--r--sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt2
-rw-r--r--sample/src/main/kotlin/ca/allanwang/kau/sample/PermissionCheckbox.kt2
-rw-r--r--searchview/src/main/kotlin/ca/allanwang/kau/searchview/SearchItem.kt4
-rw-r--r--searchview/src/main/kotlin/ca/allanwang/kau/searchview/SearchView.kt48
35 files changed, 255 insertions, 151 deletions
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 aae6cb0..512516d 100644
--- a/about/src/main/kotlin/ca/allanwang/kau/about/AboutPanelDelegate.kt
+++ b/about/src/main/kotlin/ca/allanwang/kau/about/AboutPanelDelegate.kt
@@ -48,7 +48,7 @@ interface AboutPanelContract {
/**
* Model list to be added to [adapter]
*/
- var items: List<IItem<*>>?
+ var items: List<IItem<*>>
/**
* The adapter, will be late initialized as it depends on configs
*/
@@ -90,7 +90,7 @@ interface AboutPanelContract {
abstract class AboutPanelRecycler : AboutPanelContract {
- override var items: List<IItem<*>>? = null
+ override var items: List<IItem<*>> = emptyList()
override lateinit var adapter: FastItemThemedAdapter<IItem<*>>
@@ -116,7 +116,9 @@ abstract class AboutPanelRecycler : AboutPanelContract {
}
override fun addItems(activity: AboutActivityBase, position: Int) {
- if (items == null) return
+ if (items.isEmpty()) {
+ return
+ }
activity.pageStatus[position] = 2
postDelayed(300) { addItemsImpl(activity, position) }
}
diff --git a/about/src/main/kotlin/ca/allanwang/kau/about/CutoutIItem.kt b/about/src/main/kotlin/ca/allanwang/kau/about/CutoutIItem.kt
index b51c9c8..d51db46 100644
--- a/about/src/main/kotlin/ca/allanwang/kau/about/CutoutIItem.kt
+++ b/about/src/main/kotlin/ca/allanwang/kau/about/CutoutIItem.kt
@@ -27,11 +27,13 @@ import ca.allanwang.kau.ui.views.CutoutView
*
* Just a cutout item with some defaults in [R.layout.kau_iitem_cutout]
*/
-class CutoutIItem(val config: CutoutView.() -> Unit = {}) : KauIItem<CutoutIItem, CutoutIItem.ViewHolder>(
+class CutoutIItem(val config: CutoutView.() -> Unit = {}) : KauIItem<CutoutIItem.ViewHolder>(
R.layout.kau_iitem_cutout, ::ViewHolder, R.id.kau_item_cutout
), ThemableIItem by ThemableIItemDelegate() {
- override fun isSelectable(): Boolean = false
+ override var isSelectable: Boolean
+ get() = false
+ set(_) {}
override fun bindView(holder: ViewHolder, payloads: MutableList<Any>) {
super.bindView(holder, payloads)
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 445d435..dcc0874 100644
--- a/about/src/main/kotlin/ca/allanwang/kau/about/LibraryIItem.kt
+++ b/about/src/main/kotlin/ca/allanwang/kau/about/LibraryIItem.kt
@@ -54,7 +54,9 @@ class LibraryIItem(val lib: Library) : KauIItem<LibraryIItem.ViewHolder>(
}
}
- override fun isSelectable(): Boolean = false
+ override var isSelectable: Boolean
+ get() = false
+ set(_) {}
override fun bindView(holder: ViewHolder, payloads: MutableList<Any>) {
super.bindView(holder, payloads)
diff --git a/android-lib.gradle b/android-lib.gradle
index 90ec6bf..486b4ed 100644
--- a/android-lib.gradle
+++ b/android-lib.gradle
@@ -59,6 +59,7 @@ android {
packagingOptions {
pickFirst 'META-INF/core_release.kotlin_module'
pickFirst 'META-INF/library_release.kotlin_module'
+ pickFirst 'META-INF/library-core_release.kotlin_module'
}
compileOptions {
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 3c90b05..f649cc6 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/permissions/Permissions.kt
+++ b/core/src/main/kotlin/ca/allanwang/kau/permissions/Permissions.kt
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package ca.allanwang.kau.permissions
import android.Manifest
@@ -76,6 +77,8 @@ const val PERMISSION_READ_CALL_LOG = Manifest.permission.READ_CALL_LOG
const val PERMISSION_WRITE_CALL_LOG = Manifest.permission.WRITE_CALL_LOG
const val PERMISSION_ADD_VOICEMAIL = Manifest.permission.ADD_VOICEMAIL
const val PERMISSION_USE_SIP = Manifest.permission.USE_SIP
+@Deprecated(level = DeprecationLevel.WARNING, message = "Permission is deprecated")
+@Suppress("DEPRECATION")
const val PERMISSION_PROCESS_OUTGOING_CALLS = Manifest.permission.PROCESS_OUTGOING_CALLS
@RequiresApi(Build.VERSION_CODES.KITKAT_WATCH)
diff --git a/core/src/main/kotlin/ca/allanwang/kau/utils/Kotterknife.kt b/core/src/main/kotlin/ca/allanwang/kau/utils/Kotterknife.kt
index 8765c69..aaef160 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/utils/Kotterknife.kt
+++ b/core/src/main/kotlin/ca/allanwang/kau/utils/Kotterknife.kt
@@ -116,11 +116,11 @@ private inline val Dialog.viewFinder: Dialog.(Int) -> View?
private inline val DialogFragment.viewFinder: DialogFragment.(Int) -> View?
get() = { dialog.findViewById(it) }
private inline val SupportDialogFragment.viewFinder: SupportDialogFragment.(Int) -> View?
- get() = { dialog.findViewById(it) }
+ get() = { dialog?.findViewById(it) }
private inline val Fragment.viewFinder: Fragment.(Int) -> View?
- get() = { view!!.findViewById(it) }
+ get() = { view?.findViewById(it) }
private inline val SupportFragment.viewFinder: SupportFragment.(Int) -> View?
- get() = { view!!.findViewById(it) }
+ get() = { view?.findViewById(it) }
private inline val ViewHolder.viewFinder: ViewHolder.(Int) -> View?
get() = { itemView.findViewById(it) }
diff --git a/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/AdapterUtils.kt b/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/AdapterUtils.kt
index 42fe1a2..14fdc9d 100644
--- a/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/AdapterUtils.kt
+++ b/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/AdapterUtils.kt
@@ -31,14 +31,11 @@ import com.mikepenz.fastadapter.select.SelectExtension
fun <Item : IItem<*>> fastAdapter(vararg adapter: IAdapter<out Item>) =
FastAdapter.with<Item, IAdapter<out Item>>(adapter.toList())
-inline fun <reified T : IAdapterExtension<Item>, Item : IItem<*>> FastAdapter<Item>.getExtension(): T? =
- getExtension(T::class.java)
-
/**
* Returns selection size, or -1 if selection is disabled
*/
inline val <Item : IItem<*>> IAdapter<Item>.selectionSize: Int
- get() = fastAdapter?.getExtension<SelectExtension<Item>, Item>()?.selections?.size ?: -1
+ get() = fastAdapter?.getExtension<SelectExtension<Item>>()?.selections?.size ?: -1
inline val <Item : IItem<*>> IAdapter<Item>.selectedItems: Set<Item>
- get() = fastAdapter?.getExtension<SelectExtension<Item>, Item>()?.selectedItems ?: emptySet()
+ get() = fastAdapter?.getExtension<SelectExtension<Item>>()?.selectedItems ?: emptySet()
diff --git a/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/FastItemThemedAdapter.kt b/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/FastItemThemedAdapter.kt
index 01ac0e5..e6d4b24 100644
--- a/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/FastItemThemedAdapter.kt
+++ b/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/FastItemThemedAdapter.kt
@@ -24,6 +24,7 @@ import androidx.annotation.RequiresApi
import ca.allanwang.kau.ui.createSimpleRippleDrawable
import ca.allanwang.kau.utils.adjustAlpha
import com.mikepenz.fastadapter.IItem
+import com.mikepenz.fastadapter.IItemAdapter
import com.mikepenz.fastadapter.adapters.FastItemAdapter
/**
@@ -40,7 +41,11 @@ class FastItemThemedAdapter<Item : IItem<*>>(
backgroundColor: Int? = null,
accentColor: Int? = null
) : FastItemAdapter<Item>() {
- constructor(colors: ThemableIItemColors) : this(colors.textColor, colors.backgroundColor, colors.accentColor)
+ constructor(colors: ThemableIItemColors) : this(
+ colors.textColor,
+ colors.backgroundColor,
+ colors.accentColor
+ )
var textColor: Int? = textColor
set(value) {
@@ -73,46 +78,41 @@ class FastItemThemedAdapter<Item : IItem<*>>(
notifyAdapterDataSetChanged()
}
- override fun add(position: Int, items: List<Item>): FastItemAdapter<Item> {
+ override fun add(position: Int, items: List<Item>): IItemAdapter<Item, Item> {
injectTheme(items)
return super.add(position, items)
}
- override fun add(position: Int, item: Item): FastItemAdapter<Item> {
- injectTheme(item)
- return super.add(position, item)
+ override fun add(position: Int, vararg items: Item): IItemAdapter<Item, Item> {
+ injectTheme(items.toList())
+ return super.add(position, *items)
}
- override fun add(item: Item): FastItemAdapter<Item> {
- injectTheme(item)
- return super.add(item)
+ override fun add(vararg items: Item): IItemAdapter<Item, Item> {
+ injectTheme(items.toList())
+ return super.add(*items)
}
- override fun add(items: List<Item>?): FastItemAdapter<Item> {
+ override fun add(items: List<Item>): IItemAdapter<Item, Item> {
injectTheme(items)
return super.add(items)
}
- override fun set(items: List<Item>?): FastItemAdapter<Item> {
+ override fun set(items: List<Item>): IItemAdapter<Item, Item> {
injectTheme(items)
return super.set(items)
}
- override fun set(position: Int, item: Item): FastItemAdapter<Item> {
+ override fun set(position: Int, item: Item): IItemAdapter<Item, Item> {
injectTheme(item)
return super.set(position, item)
}
- override fun setNewList(items: List<Item>?, retainFilter: Boolean): FastItemAdapter<Item> {
+ override fun setNewList(items: List<Item>, retainFilter: Boolean): IItemAdapter<Item, Item> {
injectTheme(items)
return super.setNewList(items, retainFilter)
}
- override fun setNewList(items: List<Item>?): FastItemAdapter<Item> {
- injectTheme(items)
- return super.setNewList(items)
- }
-
private fun injectTheme(items: Collection<IItem<*>?>?) {
items?.forEach { injectTheme(it) }
}
diff --git a/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/RepeatedClickListener.kt b/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/RepeatedClickListener.kt
index 3e7d707..99c367b 100644
--- a/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/RepeatedClickListener.kt
+++ b/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/RepeatedClickListener.kt
@@ -17,10 +17,10 @@ package ca.allanwang.kau.adapters
import android.view.View
import androidx.annotation.IntRange
+import com.mikepenz.fastadapter.ClickListener
import com.mikepenz.fastadapter.FastAdapter
import com.mikepenz.fastadapter.IAdapter
import com.mikepenz.fastadapter.IItem
-import com.mikepenz.fastadapter.listeners.OnClickListener
/**
* Created by Allan Wang on 26/12/17.
@@ -28,9 +28,11 @@ import com.mikepenz.fastadapter.listeners.OnClickListener
fun <Item : IItem<*>> FastAdapter<Item>.withOnRepeatedClickListener(
count: Int,
duration: Long,
- event: OnClickListener<Item>
-) =
- withOnClickListener(RepeatedClickListener(count, duration, event))
+ event: ClickListener<Item>
+): FastAdapter<Item> {
+ onClickListener = RepeatedClickListener(count, duration, event)
+ return this
+}
/**
* Registers and skips each click until the designated [count] clicks are triggered,
@@ -40,8 +42,8 @@ fun <Item : IItem<*>> FastAdapter<Item>.withOnRepeatedClickListener(
private class RepeatedClickListener<Item : IItem<*>>(
@IntRange(from = 1) val count: Int,
@IntRange(from = 1) val duration: Long,
- val event: OnClickListener<Item>
-) : OnClickListener<Item> {
+ val event: ClickListener<Item>
+) : ClickListener<Item> {
init {
if (count <= 0)
@@ -53,7 +55,7 @@ private class RepeatedClickListener<Item : IItem<*>>(
private var chain = 0
private var time = -1L
- override fun onClick(v: View?, adapter: IAdapter<Item>, item: Item, position: Int): Boolean {
+ override fun invoke(v: View?, adapter: IAdapter<Item>, item: Item, position: Int): Boolean {
val now = System.currentTimeMillis()
if (time - now < duration)
chain++
@@ -62,7 +64,7 @@ private class RepeatedClickListener<Item : IItem<*>>(
time = now
if (chain == count) {
chain = 0
- event.onClick(v, adapter, item, position)
+ event(v, adapter, item, position)
return true
}
return false
diff --git a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/KPrefActivity.kt b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/KPrefActivity.kt
index b701a07..f11afde 100644
--- a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/KPrefActivity.kt
+++ b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/KPrefActivity.kt
@@ -32,6 +32,7 @@ import ca.allanwang.kau.utils.resolveColor
import ca.allanwang.kau.utils.statusBarColor
import ca.allanwang.kau.utils.withLinearAdapter
import com.mikepenz.fastadapter.adapters.FastItemAdapter
+import com.mikepenz.fastadapter.select.getSelectExtension
import kotlinx.android.synthetic.main.kau_pref_activity.*
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
@@ -82,7 +83,8 @@ abstract class KPrefActivity : KauBaseActivity(), KPrefActivityContract {
toolbar.setNavigationOnClickListener { onBackPressed() }
setDisplayShowTitleEnabled(false)
}
- window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
+ window.decorView.systemUiVisibility =
+ View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
statusBarColor = 0x30000000
kau_toolbar_ripple.set(resolveColor(R.attr.colorPrimary))
kau_ripple.set(resolveColor(android.R.attr.colorBackground))
@@ -92,8 +94,13 @@ abstract class KPrefActivity : KauBaseActivity(), KPrefActivityContract {
core.builder()
globalOptions = GlobalOptions(core, this)
kau_recycler.withLinearAdapter(adapter)
- adapter.withSelectable(false)
- .withOnClickListener { v, _, item, _ -> item.onClick(v!!); true }
+ adapter.apply {
+ getSelectExtension().isSelectable = true
+ onClickListener = { v, _, item, _ ->
+ item.onClick(v!!)
+ true
+ }
+ }
showNextPrefs(R.string.kau_settings, onCreateKPrefs(savedInstanceState), true)
}
diff --git a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefCheckbox.kt b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefCheckbox.kt
index 0f025a6..f4f4a65 100644
--- a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefCheckbox.kt
+++ b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefCheckbox.kt
@@ -34,7 +34,7 @@ open class KPrefCheckbox(builder: BaseContract<Boolean>) : KPrefItemBase<Boolean
(innerView as AppCompatCheckBox).isChecked = pref
}
- override fun bindView(holder: ViewHolder, payloads: List<Any>) {
+ override fun bindView(holder: ViewHolder, payloads: MutableList<Any>) {
super.bindView(holder, payloads)
val checkbox = holder.bindInnerView<CheckBox>(R.layout.kau_pref_checkbox)
withAccentColor(checkbox::tint)
@@ -42,5 +42,6 @@ open class KPrefCheckbox(builder: BaseContract<Boolean>) : KPrefItemBase<Boolean
checkbox.jumpDrawablesToCurrentState() //Cancel the animation
}
- override fun getType(): Int = R.id.kau_item_pref_checkbox
+ override val type: Int
+ get() = R.id.kau_item_pref_checkbox
}
diff --git a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefColorPicker.kt b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefColorPicker.kt
index 8b051c5..76cfbab 100644
--- a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefColorPicker.kt
+++ b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefColorPicker.kt
@@ -33,7 +33,7 @@ import com.afollestad.materialdialogs.MaterialDialog
*/
open class KPrefColorPicker(open val builder: KPrefColorContract) : KPrefItemBase<Int>(builder) {
- override fun bindView(holder: ViewHolder, payloads: List<Any>) {
+ override fun bindView(holder: ViewHolder, payloads: MutableList<Any>) {
super.bindView(holder, payloads)
if (builder.showPreview) {
val preview = holder.bindInnerView<CircleView>(R.layout.kau_pref_color)
@@ -63,7 +63,7 @@ open class KPrefColorPicker(open val builder: KPrefColorContract) : KPrefItemBas
/**
* Extension of the base contract and [ColorContract] along with a showPreview option
*/
- interface KPrefColorContract : KPrefItemBase.BaseContract<Int>, ColorContract {
+ interface KPrefColorContract : BaseContract<Int>, ColorContract {
var showPreview: Boolean
var dialogBuilder: MaterialDialog.() -> Unit
}
@@ -76,11 +76,13 @@ open class KPrefColorPicker(open val builder: KPrefColorContract) : KPrefItemBas
titleId: Int,
getter: () -> Int,
setter: KPrefItemActions.(value: Int) -> Unit
- ) : KPrefColorContract, KPrefItemBase.BaseContract<Int> by BaseBuilder(globalOptions, titleId, getter, setter),
+ ) : KPrefColorContract,
+ BaseContract<Int> by BaseBuilder(globalOptions, titleId, getter, setter),
ColorContract by ColorBuilder() {
override var showPreview: Boolean = true
override var dialogBuilder: MaterialDialog.() -> Unit = {}
}
- override fun getType(): Int = R.id.kau_item_pref_color_picker
+ override val type: Int
+ get() = R.id.kau_item_pref_color_picker
}
diff --git a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefHeader.kt b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefHeader.kt
index 7d73322..ca70b61 100644
--- a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefHeader.kt
+++ b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefHeader.kt
@@ -25,12 +25,14 @@ import ca.allanwang.kau.kpref.activity.R
*/
open class KPrefHeader(builder: CoreContract) : KPrefItemCore(builder) {
- override fun getLayoutRes(): Int = R.layout.kau_pref_header
+ override val layoutRes: Int
+ get() = R.layout.kau_pref_header
- override fun bindView(holder: ViewHolder, payloads: List<Any>) {
+ override fun bindView(holder: ViewHolder, payloads: MutableList<Any>) {
super.bindView(holder, payloads)
withAccentColor(holder.title::setTextColor)
}
- override fun getType() = R.id.kau_item_pref_header
+ override val type: Int
+ get() = R.id.kau_item_pref_header
}
diff --git a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefItemBase.kt b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefItemBase.kt
index c597b63..9197057 100644
--- a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefItemBase.kt
+++ b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefItemBase.kt
@@ -46,7 +46,7 @@ abstract class KPrefItemBase<T>(protected val base: BaseContract<T>) : KPrefItem
}
@CallSuper
- override fun bindView(holder: ViewHolder, payloads: List<Any>) {
+ override fun bindView(holder: ViewHolder, payloads: MutableList<Any>) {
super.bindView(holder, payloads)
_enabled = base.enabler()
with(holder) {
@@ -77,12 +77,14 @@ abstract class KPrefItemBase<T>(protected val base: BaseContract<T>) : KPrefItem
super.unbindView(holder)
holder.container?.apply {
isEnabled = true
- background = holder.itemView.context.resolveDrawable(android.R.attr.selectableItemBackground)
+ background =
+ holder.itemView.context.resolveDrawable(android.R.attr.selectableItemBackground)
alpha = 1.0f
}
}
- final override fun getLayoutRes(): Int = R.layout.kau_pref_core
+ final override val layoutRes: Int
+ get() = R.layout.kau_pref_core
/**
* Extension of the core contract
diff --git a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefItemCore.kt b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefItemCore.kt
index 36bf670..79b7e82 100644
--- a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefItemCore.kt
+++ b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefItemCore.kt
@@ -48,7 +48,7 @@ import com.mikepenz.iconics.typeface.IIcon
* Core class containing nothing but the view items
*/
-abstract class KPrefItemCore(val core: CoreContract) : AbstractItem<KPrefItemCore, KPrefItemCore.ViewHolder>(), KPrefItemActions by core,
+abstract class KPrefItemCore(val core: CoreContract) : AbstractItem<KPrefItemCore.ViewHolder>(), KPrefItemActions by core,
ThemableIItem by ThemableIItemDelegate() {
final override fun getViewHolder(v: View) = ViewHolder(v)
@@ -70,7 +70,7 @@ abstract class KPrefItemCore(val core: CoreContract) : AbstractItem<KPrefItemCor
*/
@SuppressLint("NewApi")
@CallSuper
- override fun bindView(holder: ViewHolder, payloads: List<Any>) {
+ override fun bindView(holder: ViewHolder, payloads: MutableList<Any>) {
super.bindView(holder, payloads)
with(holder) {
updateTitle()
diff --git a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefPlainText.kt b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefPlainText.kt
index 6a0aaf5..7381a07 100644
--- a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefPlainText.kt
+++ b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefPlainText.kt
@@ -36,5 +36,6 @@ open class KPrefPlainText(open val builder: KPrefPlainTextBuilder) : KPrefItemBa
titleId: Int
) : BaseContract<Unit> by BaseBuilder(globalOptions, titleId, {}, {})
- override fun getType(): Int = R.id.kau_item_pref_plain_text
+ override val type: Int
+ get() = R.id.kau_item_pref_plain_text
}
diff --git a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefSeekbar.kt b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefSeekbar.kt
index a582ec4..5de1f83 100644
--- a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefSeekbar.kt
+++ b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefSeekbar.kt
@@ -37,7 +37,7 @@ open class KPrefSeekbar(val builder: KPrefSeekbarContract) : KPrefItemBase<Int>(
override fun KClick<Int>.defaultOnClick() = Unit
- override fun bindView(holder: ViewHolder, payloads: List<Any>) {
+ override fun bindView(holder: ViewHolder, payloads: MutableList<Any>) {
super.bindView(holder, payloads)
val text = holder.bindInnerView<TextView>(R.layout.kau_pref_seekbar_text)
withTextColor(text::setTextColor)
@@ -60,7 +60,8 @@ open class KPrefSeekbar(val builder: KPrefSeekbarContract) : KPrefItemBase<Int>(
})
}
withAccentColor(seekbar::tint)
- text.text = builder.toText(seekbar.progress.fromProgress) //set initial text in case no change occurs
+ text.text =
+ builder.toText(seekbar.progress.fromProgress) //set initial text in case no change occurs
seekbar.progress = pref.toProgress
seekbar.isEnabled = builder.enabler()
}
@@ -87,7 +88,8 @@ open class KPrefSeekbar(val builder: KPrefSeekbarContract) : KPrefItemBase<Int>(
titleId: Int,
getter: () -> Int,
setter: KPrefItemActions.(value: Int) -> Unit
- ) : KPrefSeekbarContract, BaseContract<Int> by BaseBuilder(globalOptions, titleId, getter, setter) {
+ ) : KPrefSeekbarContract,
+ BaseContract<Int> by BaseBuilder(globalOptions, titleId, getter, setter) {
override var min: Int = 0
@@ -118,5 +120,6 @@ open class KPrefSeekbar(val builder: KPrefSeekbarContract) : KPrefItemBase<Int>(
protected inline val Int.fromProgress: Int
get() = this * increment + min
- override fun getType(): Int = R.id.kau_item_pref_seekbar
+ override val type: Int
+ get() = R.id.kau_item_pref_seekbar
}
diff --git a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefSubItems.kt b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefSubItems.kt
index 1fa528b..8474627 100644
--- a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefSubItems.kt
+++ b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefSubItems.kt
@@ -33,7 +33,8 @@ open class KPrefSubItems(open val builder: KPrefSubItemsContract) : KPrefItemCor
builder.globalOptions.showNextPrefs(builder.titleFun(), builder.itemBuilder)
}
- override fun getLayoutRes(): Int = R.layout.kau_pref_core
+ override val layoutRes: Int
+ get() = R.layout.kau_pref_core
/**
* Extension of the base contract with an optional text getter
@@ -51,5 +52,6 @@ open class KPrefSubItems(open val builder: KPrefSubItemsContract) : KPrefItemCor
override val itemBuilder: KPrefAdapterBuilder.() -> Unit
) : KPrefSubItemsContract, CoreContract by CoreBuilder(globalOptions, titleId)
- override fun getType(): Int = R.id.kau_item_pref_sub_item
+ override val type: Int
+ get() = R.id.kau_item_pref_sub_item
}
diff --git a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefText.kt b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefText.kt
index 76c9e20..50f0c62 100644
--- a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefText.kt
+++ b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefText.kt
@@ -46,7 +46,7 @@ open class KPrefText<T>(open val builder: KPrefTextContract<T>) : KPrefItemBase<
context.toast("No click function set")
}
- override fun bindView(holder: ViewHolder, payloads: List<Any>) {
+ override fun bindView(holder: ViewHolder, payloads: MutableList<Any>) {
super.bindView(holder, payloads)
val textView = holder.bindInnerView<TextView>(R.layout.kau_pref_text)
withTextColor(textView::setTextColor)
@@ -68,9 +68,11 @@ open class KPrefText<T>(open val builder: KPrefTextContract<T>) : KPrefItemBase<
titleId: Int,
getter: () -> T,
setter: KPrefItemActions.(value: T) -> Unit
- ) : KPrefTextContract<T>, BaseContract<T> by BaseBuilder<T>(globalOptions, titleId, getter, setter) {
+ ) : KPrefTextContract<T>,
+ BaseContract<T> by BaseBuilder<T>(globalOptions, titleId, getter, setter) {
override var textGetter: (T) -> String? = { it?.toString() }
}
- override fun getType(): Int = R.id.kau_item_pref_text
+ override val type: Int
+ get() = R.id.kau_item_pref_text
}
diff --git a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefTimePicker.kt b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefTimePicker.kt
index f50397c..318b630 100644
--- a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefTimePicker.kt
+++ b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefTimePicker.kt
@@ -33,7 +33,8 @@ import java.util.Locale
*/
open class KPrefTimePicker(override val builder: KPrefTimeContract) : KPrefText<Int>(builder) {
- interface KPrefTimeContract : KPrefText.KPrefTextContract<Int>, TimePickerDialog.OnTimeSetListener {
+ interface KPrefTimeContract : KPrefText.KPrefTextContract<Int>,
+ TimePickerDialog.OnTimeSetListener {
var use24HourFormat: Boolean
}
@@ -50,7 +51,8 @@ open class KPrefTimePicker(override val builder: KPrefTimeContract) : KPrefText<
titleId: Int,
getter: () -> Int,
setter: KPrefItemActions.(value: Int) -> Unit
- ) : KPrefTimeContract, BaseContract<Int> by BaseBuilder(globalOptions, titleId, getter, setter) {
+ ) : KPrefTimeContract,
+ BaseContract<Int> by BaseBuilder(globalOptions, titleId, getter, setter) {
override var use24HourFormat: Boolean = false
@@ -64,11 +66,18 @@ open class KPrefTimePicker(override val builder: KPrefTimeContract) : KPrefText<
if (use24HourFormat)
String.format(Locale.CANADA, "%d:%02d", hour, min)
else
- String.format(Locale.CANADA, "%d:%02d %s", hour % 12, min, if (hour >= 12) "PM" else "AM")
+ String.format(
+ Locale.CANADA,
+ "%d:%02d %s",
+ hour % 12,
+ min,
+ if (hour >= 12) "PM" else "AM"
+ )
}
}
- override fun getType(): Int = R.id.kau_item_pref_time_picker
+ override val type: Int
+ get() = R.id.kau_item_pref_time_picker
}
private val Int.splitTime: Pair<Int, Int>
diff --git a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/BlurredImageView.kt b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/BlurredImageView.kt
index 739bf47..e430dff 100644
--- a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/BlurredImageView.kt
+++ b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/BlurredImageView.kt
@@ -28,7 +28,7 @@ import ca.allanwang.kau.utils.scaleXY
import ca.allanwang.kau.utils.setBackgroundColorRes
import ca.allanwang.kau.utils.setIcon
import ca.allanwang.kau.utils.visible
-import com.mikepenz.google_material_typeface_library.GoogleMaterial
+import com.mikepenz.iconics.typeface.library.googlematerial.GoogleMaterial
import jp.wasabeef.blurry.internal.BlurFactor
import jp.wasabeef.blurry.internal.BlurTask
import kotlinx.android.synthetic.main.kau_blurred_imageview.view.*
@@ -48,7 +48,9 @@ class BlurredImageView @JvmOverloads constructor(
defStyleAttr: Int = 0
) : FrameLayout(context, attrs, defStyleAttr), MeasureSpecContract by MeasureSpecDelegate() {
- private var blurred = false
+ var isBlurred = false
+ private set
+
val imageBase: ImageView get() = image_base
init {
@@ -69,20 +71,19 @@ class BlurredImageView @JvmOverloads constructor(
image_foreground.clearAnimation()
}
- private fun View.scaleAnimate(scale: Float) = animate().scaleXY(scale).setDuration(ANIMATION_DURATION)
- private fun View.alphaAnimate(alpha: Float) = animate().alpha(alpha).setDuration(ANIMATION_DURATION)
+ private fun View.scaleAnimate(scale: Float) =
+ animate().scaleXY(scale).setDuration(ANIMATION_DURATION)
- fun isBlurred(): Boolean {
- return blurred
- }
+ private fun View.alphaAnimate(alpha: Float) =
+ animate().alpha(alpha).setDuration(ANIMATION_DURATION)
/**
* Applies a blur and fills the blur image asynchronously
* When ready, scales the image down and shows the blur & foreground
*/
fun blur() {
- if (blurred) return
- blurred = true
+ if (isBlurred) return
+ isBlurred = true
val factor = BlurFactor()
factor.width = width
factor.height = height
@@ -100,7 +101,7 @@ class BlurredImageView @JvmOverloads constructor(
* is still asynchronous and takes time
*/
fun blurInstantly() {
- blurred = true
+ isBlurred = true
clearAnimation()
val factor = BlurFactor()
factor.width = width
@@ -117,8 +118,8 @@ class BlurredImageView @JvmOverloads constructor(
* Animate view back to original state and remove drawable when finished
*/
fun removeBlur() {
- if (!blurred) return
- blurred = false
+ if (!isBlurred) return
+ isBlurred = false
scaleAnimate(1.0f).start()
image_blur.alphaAnimate(0f).withEndAction { image_blur.setImageDrawable(null) }.start()
image_foreground.alphaAnimate(0f).start()
@@ -128,7 +129,7 @@ class BlurredImageView @JvmOverloads constructor(
* Clear all animations and unblur the image
*/
fun removeBlurInstantly() {
- blurred = false
+ isBlurred = false
clearAnimation()
scaleX = 1.0f
scaleX = 1.0f
@@ -143,9 +144,9 @@ class BlurredImageView @JvmOverloads constructor(
* @return true if new state is blurred; false otherwise
*/
fun toggleBlur(): Boolean {
- if (blurred) removeBlur()
+ if (isBlurred) removeBlur()
else blur()
- return blurred
+ return isBlurred
}
/**
@@ -162,7 +163,7 @@ class BlurredImageView @JvmOverloads constructor(
*/
fun fullReset() {
reset()
- fullAction({ it.visible().background = null })
+ fullAction { it.visible().background = null }
image_foreground.setBackgroundColorRes(R.color.kau_blurred_image_selection_overlay)
image_foreground.setIcon(GoogleMaterial.Icon.gmd_check, 30, Color.WHITE)
}
diff --git a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaActionItem.kt b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaActionItem.kt
index 55b448e..552bf0f 100644
--- a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaActionItem.kt
+++ b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaActionItem.kt
@@ -42,6 +42,10 @@ class MediaActionItem(
R.id.kau_item_media_action
) {
+ override var isSelectable: Boolean
+ get() = false
+ set(_) {}
+
override fun bindView(holder: MediaItemBasic.ViewHolder, payloads: MutableList<Any>) {
super.bindView(holder, payloads)
holder.image.apply {
diff --git a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaItem.kt b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaItem.kt
index 5d47590..88a304f 100644
--- a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaItem.kt
+++ b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaItem.kt
@@ -52,7 +52,7 @@ class MediaItem(val data: MediaModel) :
override var isSelectable: Boolean
get() = !failedToLoad
- set(value) {}
+ set(_) {}
override fun bindView(holder: ViewHolder, payloads: MutableList<Any>) {
super.bindView(holder, payloads)
diff --git a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaItemBasic.kt b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaItemBasic.kt
index 73647b8..873289f 100644
--- a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaItemBasic.kt
+++ b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaItemBasic.kt
@@ -27,29 +27,32 @@ import com.bumptech.glide.load.engine.GlideException
import com.bumptech.glide.request.RequestListener
import com.bumptech.glide.request.target.Target
import com.mikepenz.fastadapter.FastAdapter
+import com.mikepenz.fastadapter.select.getSelectExtension
/**
* Created by Allan Wang on 2017-07-04.
*/
class MediaItemBasic(val data: MediaModel) :
- KauIItem<MediaItem, MediaItemBasic.ViewHolder>(R.layout.kau_iitem_image_basic, { ViewHolder(it) }),
+ KauIItem<MediaItemBasic.ViewHolder>(R.layout.kau_iitem_image_basic, { ViewHolder(it) }),
GlideContract by GlideDelegate() {
companion object {
@SuppressLint("NewApi")
fun bindEvents(activity: Activity, fastAdapter: FastAdapter<MediaItemBasic>) {
- fastAdapter.withSelectable(false)
- //add image data and return right away
- .withOnClickListener { _, _, item, _ ->
- activity.finish(arrayListOf(item.data))
- true
- }
+ fastAdapter.getSelectExtension().isSelectable = true
+ //add image data and return right away
+ fastAdapter.onClickListener = { _, _, item, _ ->
+ activity.finish(arrayListOf(item.data))
+ true
+ }
}
}
- override fun isSelectable(): Boolean = false
+ override var isSelectable: Boolean
+ get() = false
+ set(_) {}
- override fun bindView(holder: ViewHolder, payloads: List<Any>) {
+ override fun bindView(holder: ViewHolder, payloads: MutableList<Any>) {
super.bindView(holder, payloads)
glide(holder.itemView)
.load(data.data)
diff --git a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaModel.kt b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaModel.kt
index edd6199..1ba8041 100644
--- a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaModel.kt
+++ b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaModel.kt
@@ -85,6 +85,8 @@ data class MediaModel(
}
companion object CREATOR : Parcelable.Creator<MediaModel> {
+ @Suppress("DEPRECATION")
+ // TODO verify data deprecation
val projection = arrayOf(
MediaStore.MediaColumns.DATA,
MediaStore.MediaColumns.MIME_TYPE,
diff --git a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerActivityBase.kt b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerActivityBase.kt
index 5e5d1ed..c7cff55 100644
--- a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerActivityBase.kt
+++ b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerActivityBase.kt
@@ -26,7 +26,9 @@ import ca.allanwang.kau.utils.setIcon
import ca.allanwang.kau.utils.toDrawable
import ca.allanwang.kau.utils.toast
import com.google.android.material.appbar.AppBarLayout
-import com.mikepenz.google_material_typeface_library.GoogleMaterial
+import com.mikepenz.fastadapter.ISelectionListener
+import com.mikepenz.fastadapter.select.selectExtension
+import com.mikepenz.iconics.typeface.library.googlematerial.GoogleMaterial
import kotlinx.android.synthetic.main.kau_activity_image_picker.*
/**
@@ -46,21 +48,37 @@ abstract class MediaPickerActivityBase(
setContentView(R.layout.kau_activity_image_picker)
- kau_selection_count.setCompoundDrawables(null, null, GoogleMaterial.Icon.gmd_image.toDrawable(this, 18), null)
+ kau_selection_count.setCompoundDrawables(
+ null,
+ null,
+ GoogleMaterial.Icon.gmd_image.toDrawable(this, 18),
+ null
+ )
setSupportActionBar(kau_toolbar)
supportActionBar?.apply {
setDisplayHomeAsUpEnabled(true)
setDisplayShowHomeEnabled(true)
- setHomeAsUpIndicator(GoogleMaterial.Icon.gmd_close.toDrawable(this@MediaPickerActivityBase, 18))
+ setHomeAsUpIndicator(
+ GoogleMaterial.Icon.gmd_close.toDrawable(
+ this@MediaPickerActivityBase,
+ 18
+ )
+ )
}
kau_toolbar.setNavigationOnClickListener { onBackPressed() }
initializeRecycler(kau_recyclerview)
- MediaItem.bindEvents(adapter.fastAdapter)
- adapter.fastAdapter.withSelectionListener { _, _ ->
- kau_selection_count.text = adapter.selectionSize.toString()
+ adapter.fastAdapter!!.let {
+ MediaItem.bindEvents(it)
+ it.selectExtension {
+ selectionListener = object : ISelectionListener<MediaItem> {
+ override fun onSelectionChanged(item: MediaItem?, selected: Boolean) {
+ kau_selection_count.text = adapter.selectionSize.toString()
+ }
+ }
+ }
}
kau_fab.apply {
diff --git a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerActivityOverlayBase.kt b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerActivityOverlayBase.kt
index a7ee63d..df47688 100644
--- a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerActivityOverlayBase.kt
+++ b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerActivityOverlayBase.kt
@@ -39,7 +39,7 @@ abstract class MediaPickerActivityOverlayBase(
super.onCreate(savedInstanceState)
setContentView(R.layout.kau_activity_image_picker_overlay)
initializeRecycler(kau_recyclerview)
- MediaItemBasic.bindEvents(this, adapter.fastAdapter)
+ MediaItemBasic.bindEvents(this, adapter.fastAdapter!!)
kau_draggable.addExitListener(this, R.transition.kau_image_exit_bottom, R.transition.kau_image_exit_top)
kau_draggable.setOnClickListener { finishAfterTransition() }
diff --git a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerCore.kt b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerCore.kt
index c928e04..116f511 100644
--- a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerCore.kt
+++ b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerCore.kt
@@ -46,13 +46,10 @@ import com.bumptech.glide.Glide
import com.bumptech.glide.RequestManager
import com.mikepenz.fastadapter.IItem
import com.mikepenz.fastadapter.adapters.ItemAdapter
-import com.mikepenz.iconics.IconicsDrawable
-import com.mikepenz.iconics.colorInt
-import com.mikepenz.iconics.paddingPx
-import com.mikepenz.iconics.sizePx
+import com.mikepenz.iconics.dsl.ExperimentalIconicsDSL
+import com.mikepenz.iconics.dsl.iconicsDrawable
import com.mikepenz.iconics.typeface.IIcon
import com.mikepenz.iconics.typeface.library.googlematerial.GoogleMaterial
-import com.mikepenz.iconics.utils.toIconicsColor
import kotlinx.coroutines.CancellationException
import java.io.File
@@ -91,16 +88,19 @@ abstract class MediaPickerCore<T : IItem<*>>(
/**
* Create error tile for a given item
*/
+ @ExperimentalIconicsDSL
fun getErrorDrawable(context: Context) =
getIconDrawable(context, GoogleMaterial.Icon.gmd_error, accentColor)
+ @ExperimentalIconicsDSL
fun getIconDrawable(context: Context, iicon: IIcon, color: Int): Drawable {
- val sizePx = MediaPickerCore.computeViewSize(context)
- return IconicsDrawable(context, iicon)
- .sizePx(sizePx)
- .backgroundColor(color.toIconicsColor())
- .paddingPx(sizePx / 3)
- .colorInt(Color.WHITE)
+ val sizePx = computeViewSize(context)
+ return context.iconicsDrawable(iicon) {
+ size = sizePx(sizePx)
+ backgroundColor = colorInt(color)
+ padding = sizePx(sizePx / 3)
+ this.color = colorInt(Color.WHITE)
+ }
}
var accentColor: Int = 0xff666666.toInt()
@@ -110,12 +110,12 @@ abstract class MediaPickerCore<T : IItem<*>>(
* This is used for both single and multiple photo picks
*/
fun onMediaPickerResult(resultCode: Int, data: Intent?): List<MediaModel> {
- if (resultCode != Activity.RESULT_OK || data == null || !data.hasExtra(
- MEDIA_PICKER_RESULT
- )
- )
+ if (resultCode != Activity.RESULT_OK ||
+ data?.hasExtra(MEDIA_PICKER_RESULT) != true
+ ) {
return emptyList()
- return data.getParcelableArrayListExtra(MEDIA_PICKER_RESULT)
+ }
+ return data.getParcelableArrayListExtra(MEDIA_PICKER_RESULT) ?: emptyList()
}
/**
@@ -278,8 +278,8 @@ abstract class MediaPickerCore<T : IItem<*>>(
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
if (resultCode != RESULT_OK) {
- if (tempPath != null) {
- val f = File(tempPath)
+ tempPath?.let {
+ val f = File(it)
if (f.exists()) f.delete()
tempPath = null
}
@@ -295,14 +295,18 @@ abstract class MediaPickerCore<T : IItem<*>>(
private fun onCameraResult(data: Intent?) {
val f: File
- if (tempPath != null) {
- f = File(tempPath)
- tempPath = null
- } else if (data?.data != null) {
- f = File(data.data!!.path)
- } else {
- KL.d { "Media camera no file found" }
- return
+ val tempPath = tempPath
+ val dataPath = data?.data?.path
+ when {
+ tempPath != null -> {
+ f = File(tempPath)
+ this.tempPath = null
+ }
+ dataPath != null -> f = File(dataPath)
+ else -> {
+ KL.d { "Media camera no file found" }
+ return
+ }
}
if (f.exists()) {
KL.v { "Media camera path found: ${f.absolutePath}" }
@@ -315,9 +319,10 @@ abstract class MediaPickerCore<T : IItem<*>>(
private fun onPickerResult(data: Intent?) {
val items = mutableListOf<Uri>()
- if (data?.data != null) {
- KL.v { "Media picker data uri: ${data.data!!.path}" }
- items.add(data.data!!)
+ val _data = data?.data
+ if (_data != null) {
+ KL.v { "Media picker data uri: ${_data.path}" }
+ items.add(_data)
} else if (data != null) {
val clip = data.clipData
if (clip != null) {
diff --git a/sample/build.gradle b/sample/build.gradle
index cacd21f..1441cf0 100644
--- a/sample/build.gradle
+++ b/sample/build.gradle
@@ -76,6 +76,7 @@ android {
packagingOptions {
pickFirst 'META-INF/core_release.kotlin_module'
pickFirst 'META-INF/library_release.kotlin_module'
+ pickFirst 'META-INF/library-core_release.kotlin_module'
}
compileOptions {
diff --git a/sample/src/main/kotlin/ca/allanwang/kau/sample/AdapterActivity.kt b/sample/src/main/kotlin/ca/allanwang/kau/sample/AdapterActivity.kt
index 8c35c77..2fedbeb 100644
--- a/sample/src/main/kotlin/ca/allanwang/kau/sample/AdapterActivity.kt
+++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/AdapterActivity.kt
@@ -22,7 +22,7 @@ import ca.allanwang.kau.ui.activities.ElasticRecyclerActivity
import ca.allanwang.kau.utils.toast
import com.mikepenz.fastadapter.IItem
import com.mikepenz.fastadapter.adapters.ItemAdapter
-import com.mikepenz.google_material_typeface_library.GoogleMaterial
+import com.mikepenz.iconics.typeface.library.googlematerial.GoogleMaterial
/**
* Created by Allan Wang on 2017-07-17.
diff --git a/sample/src/main/kotlin/ca/allanwang/kau/sample/AnimActivity.kt b/sample/src/main/kotlin/ca/allanwang/kau/sample/AnimActivity.kt
index aaa6143..f6d5ccc 100644
--- a/sample/src/main/kotlin/ca/allanwang/kau/sample/AnimActivity.kt
+++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/AnimActivity.kt
@@ -43,14 +43,20 @@ class AnimActivity : KauBaseActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val adapter = FastItemAdapter<PermissionCheckbox>()
- setContentView(fullLinearRecycler(adapter).apply { setBackgroundColor(KPrefSample.bgColor.withAlpha(255)) })
+ setContentView(fullLinearRecycler(adapter).apply {
+ setBackgroundColor(
+ KPrefSample.bgColor.withAlpha(
+ 255
+ )
+ )
+ })
adapter.add(listOf(
PERMISSION_ACCESS_COARSE_LOCATION,
PERMISSION_ACCESS_FINE_LOCATION,
PERMISSION_CAMERA
).map { PermissionCheckbox(it) })
- adapter.withOnClickListener { _, _, item, _ ->
+ adapter.onClickListener = { _, _, item, _ ->
KL.d { "Perm Click" }
kauRequestPermissions(item.permission) { granted, _ ->
toast("${item.permission} enabled: $granted")
diff --git a/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt b/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt
index f4a09cf..11d19e5 100644
--- a/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt
+++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt
@@ -39,7 +39,7 @@ import ca.allanwang.kau.utils.toast
import ca.allanwang.kau.utils.withSceneTransitionAnimation
import ca.allanwang.kau.xml.showChangelog
import com.afollestad.materialdialogs.input.input
-import com.mikepenz.google_material_typeface_library.GoogleMaterial
+import com.mikepenz.iconics.typeface.library.googlematerial.GoogleMaterial
class MainActivity : KPrefActivity() {
diff --git a/sample/src/main/kotlin/ca/allanwang/kau/sample/PermissionCheckbox.kt b/sample/src/main/kotlin/ca/allanwang/kau/sample/PermissionCheckbox.kt
index 025179d..7cf6cc1 100644
--- a/sample/src/main/kotlin/ca/allanwang/kau/sample/PermissionCheckbox.kt
+++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/PermissionCheckbox.kt
@@ -25,7 +25,7 @@ import ca.allanwang.kau.utils.hasPermission
/**
* Created by Allan Wang on 2017-07-03.
*/
-class PermissionCheckbox(val permission: String) : KauIItem<PermissionCheckbox, PermissionCheckbox.ViewHolder>(
+class PermissionCheckbox(val permission: String) : KauIItem<PermissionCheckbox.ViewHolder>(
R.layout.permission_checkbox, { ViewHolder(it) }) {
override fun bindView(holder: ViewHolder, payloads: MutableList<Any>) {
diff --git a/searchview/src/main/kotlin/ca/allanwang/kau/searchview/SearchItem.kt b/searchview/src/main/kotlin/ca/allanwang/kau/searchview/SearchItem.kt
index 7747d81..7bf01b3 100644
--- a/searchview/src/main/kotlin/ca/allanwang/kau/searchview/SearchItem.kt
+++ b/searchview/src/main/kotlin/ca/allanwang/kau/searchview/SearchItem.kt
@@ -32,7 +32,7 @@ import ca.allanwang.kau.utils.setIcon
import ca.allanwang.kau.utils.setRippleBackground
import ca.allanwang.kau.utils.visible
import com.mikepenz.iconics.typeface.IIcon
-import com.mikepenz.google_material_typeface_library.GoogleMaterial
+import com.mikepenz.iconics.typeface.library.googlematerial.GoogleMaterial
/**
* Created by Allan Wang on 2017-06-23.
@@ -47,7 +47,7 @@ class SearchItem(
val description: String? = null,
val iicon: IIcon? = GoogleMaterial.Icon.gmd_search,
val image: Drawable? = null
-) : KauIItem<SearchItem, SearchItem.ViewHolder>(
+) : KauIItem<SearchItem.ViewHolder>(
R.layout.kau_search_iitem,
{ ViewHolder(it) },
R.id.kau_item_search
diff --git a/searchview/src/main/kotlin/ca/allanwang/kau/searchview/SearchView.kt b/searchview/src/main/kotlin/ca/allanwang/kau/searchview/SearchView.kt
index 18eb675..da06ec4 100644
--- a/searchview/src/main/kotlin/ca/allanwang/kau/searchview/SearchView.kt
+++ b/searchview/src/main/kotlin/ca/allanwang/kau/searchview/SearchView.kt
@@ -63,8 +63,9 @@ import ca.allanwang.kau.utils.toDrawable
import ca.allanwang.kau.utils.visible
import ca.allanwang.kau.utils.withLinearAdapter
import com.mikepenz.fastadapter.adapters.FastItemAdapter
+import com.mikepenz.fastadapter.select.selectExtension
import com.mikepenz.iconics.typeface.IIcon
-import com.mikepenz.google_material_typeface_library.GoogleMaterial
+import com.mikepenz.iconics.typeface.library.googlematerial.GoogleMaterial
import kotlinx.android.synthetic.main.kau_search_view.view.*
/**
@@ -255,7 +256,11 @@ class SearchView @JvmOverloads constructor(
val list = if (value.isEmpty() && configs.noResultsFound != INVALID_ID)
listOf(SearchItem("", context.string(configs.noResultsFound), iicon = null))
else value
- if (configs.highlightQueryText && value.isNotEmpty()) list.forEach { it.withHighlights(kau_search_edit_text.text?.toString()) }
+ if (configs.highlightQueryText && value.isNotEmpty()) list.forEach {
+ it.withHighlights(
+ kau_search_edit_text.text?.toString()
+ )
+ }
cardTransition()
adapter.setNewList(list)
}
@@ -297,7 +302,8 @@ class SearchView @JvmOverloads constructor(
View.inflate(context, R.layout.kau_search_view, this)
z = 99f
kau_search_nav.setSearchIcon(configs.navIcon).setOnClickListener { revealClose() }
- kau_search_clear.setSearchIcon(configs.clearIcon).setOnClickListener { kau_search_edit_text.text?.clear() }
+ kau_search_clear.setSearchIcon(configs.clearIcon)
+ .setOnClickListener { kau_search_edit_text.text?.clear() }
tintForeground(configs.foregroundColor)
tintBackground(configs.backgroundColor)
with(kau_search_recycler) {
@@ -312,11 +318,18 @@ class SearchView @JvmOverloads constructor(
itemAnimator = null
}
with(adapter) {
- withSelectable(true)
- withOnClickListener { _, _, item, position ->
- if (item.key.isNotBlank()) configs.onItemClick(position, item.key, item.content, this@SearchView); true
+ selectExtension {
+ isSelectable = true
+ }
+ onClickListener = { _, _, item, position ->
+ if (item.key.isNotBlank()) configs.onItemClick(
+ position,
+ item.key,
+ item.content,
+ this@SearchView
+ ); true
}
- withOnLongClickListener { _, _, item, position ->
+ onLongClickListener = { _, _, item, position ->
if (item.key.isNotBlank()) configs.onItemLongClick(
position,
item.key,
@@ -420,7 +433,8 @@ class SearchView @JvmOverloads constructor(
menuX = (locations[0] + view.width / 2)
menuHalfHeight = view.height / 2
menuY = (locations[1] + menuHalfHeight)
- kau_search_cardview.viewTreeObserver.addOnPreDrawListener(object : ViewTreeObserver.OnPreDrawListener {
+ kau_search_cardview.viewTreeObserver.addOnPreDrawListener(object :
+ ViewTreeObserver.OnPreDrawListener {
override fun onPreDraw(): Boolean {
view.viewTreeObserver.removeOnPreDrawListener(this)
kau_search_cardview.setMarginTop(menuY - kau_search_cardview.height / 2)
@@ -474,7 +488,11 @@ class SearchView @JvmOverloads constructor(
configs.openListener?.invoke(this@SearchView)
kau_search_shadow.fadeIn()
kau_search_edit_text.showKeyboard()
- kau_search_cardview.circularReveal(menuX, menuHalfHeight, duration = configs.revealDuration) {
+ kau_search_cardview.circularReveal(
+ menuX,
+ menuHalfHeight,
+ duration = configs.revealDuration
+ ) {
cardTransition()
kau_search_recycler.visible()
}
@@ -487,7 +505,9 @@ class SearchView @JvmOverloads constructor(
kau_search_shadow.fadeOut(duration = configs.transitionDuration)
cardTransition {
addEndListener {
- kau_search_cardview.circularHide(menuX, menuHalfHeight, duration = configs.revealDuration,
+ kau_search_cardview.circularHide(menuX,
+ menuHalfHeight,
+ duration = configs.revealDuration,
onFinish = {
configs.closeListener?.invoke(this@SearchView)
if (configs.shouldClearOnClose) kau_search_edit_text.text?.clear()
@@ -512,7 +532,8 @@ fun Activity.bindSearchView(
@IdRes id: Int,
@ColorInt menuIconColor: Int = Color.WHITE,
config: Configs.() -> Unit = {}
-): SearchView = findViewById<ViewGroup>(android.R.id.content).bindSearchView(menu, id, menuIconColor, config)
+): SearchView =
+ findViewById<ViewGroup>(android.R.id.content).bindSearchView(menu, id, menuIconColor, config)
/**
* Bind searchView to a menu item; call this in [Activity.onCreateOptionsMenu]
@@ -528,7 +549,10 @@ fun ViewGroup.bindSearchView(
): SearchView {
val searchView = SearchView(context)
searchView.layoutParams =
- FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT)
+ FrameLayout.LayoutParams(
+ FrameLayout.LayoutParams.MATCH_PARENT,
+ FrameLayout.LayoutParams.MATCH_PARENT
+ )
addView(searchView)
searchView.bind(menu, id, menuIconColor, config)
return searchView