From 01058912580a3ecfe77eaf6af209e1c46a97f2d7 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Thu, 13 Jun 2019 01:14:21 -0700 Subject: Initial fastadapter update --- .../src/main/kotlin/ca/allanwang/kau/kpref/activity/KPrefActivity.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'kpref-activity') 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 edaf347..b701a07 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 @@ -31,7 +31,7 @@ import ca.allanwang.kau.utils.KAU_RIGHT import ca.allanwang.kau.utils.resolveColor import ca.allanwang.kau.utils.statusBarColor import ca.allanwang.kau.utils.withLinearAdapter -import com.mikepenz.fastadapter.commons.adapters.FastItemAdapter +import com.mikepenz.fastadapter.adapters.FastItemAdapter import kotlinx.android.synthetic.main.kau_pref_activity.* import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch -- cgit v1.2.3 From 63f6b70cc81ec9dc6e92b6521dfd78fa72fe70a5 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sat, 27 Jul 2019 18:59:14 -0700 Subject: Fix compile errors --- .../ca/allanwang/kau/about/AboutPanelDelegate.kt | 8 +-- .../kotlin/ca/allanwang/kau/about/CutoutIItem.kt | 6 ++- .../kotlin/ca/allanwang/kau/about/LibraryIItem.kt | 4 +- android-lib.gradle | 1 + .../ca/allanwang/kau/permissions/Permissions.kt | 3 ++ .../kotlin/ca/allanwang/kau/utils/Kotterknife.kt | 6 +-- .../ca/allanwang/kau/adapters/AdapterUtils.kt | 7 +-- .../kau/adapters/FastItemThemedAdapter.kt | 34 ++++++------ .../kau/adapters/RepeatedClickListener.kt | 18 ++++--- .../allanwang/kau/kpref/activity/KPrefActivity.kt | 13 +++-- .../kau/kpref/activity/items/KPrefCheckbox.kt | 5 +- .../kau/kpref/activity/items/KPrefColorPicker.kt | 10 ++-- .../kau/kpref/activity/items/KPrefHeader.kt | 8 +-- .../kau/kpref/activity/items/KPrefItemBase.kt | 8 +-- .../kau/kpref/activity/items/KPrefItemCore.kt | 4 +- .../kau/kpref/activity/items/KPrefPlainText.kt | 3 +- .../kau/kpref/activity/items/KPrefSeekbar.kt | 11 ++-- .../kau/kpref/activity/items/KPrefSubItems.kt | 6 ++- .../kau/kpref/activity/items/KPrefText.kt | 8 +-- .../kau/kpref/activity/items/KPrefTimePicker.kt | 17 ++++-- .../allanwang/kau/mediapicker/BlurredImageView.kt | 33 ++++++------ .../allanwang/kau/mediapicker/MediaActionItem.kt | 4 ++ .../ca/allanwang/kau/mediapicker/MediaItem.kt | 2 +- .../ca/allanwang/kau/mediapicker/MediaItemBasic.kt | 21 ++++---- .../ca/allanwang/kau/mediapicker/MediaModel.kt | 2 + .../kau/mediapicker/MediaPickerActivityBase.kt | 30 ++++++++--- .../mediapicker/MediaPickerActivityOverlayBase.kt | 2 +- .../allanwang/kau/mediapicker/MediaPickerCore.kt | 63 ++++++++++++---------- sample/build.gradle | 1 + .../ca/allanwang/kau/sample/AdapterActivity.kt | 2 +- .../kotlin/ca/allanwang/kau/sample/AnimActivity.kt | 10 +++- .../kotlin/ca/allanwang/kau/sample/MainActivity.kt | 2 +- .../ca/allanwang/kau/sample/PermissionCheckbox.kt | 2 +- .../ca/allanwang/kau/searchview/SearchItem.kt | 4 +- .../ca/allanwang/kau/searchview/SearchView.kt | 48 ++++++++++++----- 35 files changed, 255 insertions(+), 151 deletions(-) (limited to 'kpref-activity') 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>? + var items: List> /** * 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>? = null + override var items: List> = emptyList() override lateinit var adapter: FastItemThemedAdapter> @@ -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( +class CutoutIItem(val config: CutoutView.() -> Unit = {}) : KauIItem( 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) { 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( } } - override fun isSelectable(): Boolean = false + override var isSelectable: Boolean + get() = false + set(_) {} override fun bindView(holder: ViewHolder, payloads: MutableList) { 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 > fastAdapter(vararg adapter: IAdapter) = FastAdapter.with>(adapter.toList()) -inline fun , Item : IItem<*>> FastAdapter.getExtension(): T? = - getExtension(T::class.java) - /** * Returns selection size, or -1 if selection is disabled */ inline val > IAdapter.selectionSize: Int - get() = fastAdapter?.getExtension, Item>()?.selections?.size ?: -1 + get() = fastAdapter?.getExtension>()?.selections?.size ?: -1 inline val > IAdapter.selectedItems: Set - get() = fastAdapter?.getExtension, Item>()?.selectedItems ?: emptySet() + get() = fastAdapter?.getExtension>()?.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>( backgroundColor: Int? = null, accentColor: Int? = null ) : FastItemAdapter() { - 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>( notifyAdapterDataSetChanged() } - override fun add(position: Int, items: List): FastItemAdapter { + override fun add(position: Int, items: List): IItemAdapter { injectTheme(items) return super.add(position, items) } - override fun add(position: Int, item: Item): FastItemAdapter { - injectTheme(item) - return super.add(position, item) + override fun add(position: Int, vararg items: Item): IItemAdapter { + injectTheme(items.toList()) + return super.add(position, *items) } - override fun add(item: Item): FastItemAdapter { - injectTheme(item) - return super.add(item) + override fun add(vararg items: Item): IItemAdapter { + injectTheme(items.toList()) + return super.add(*items) } - override fun add(items: List?): FastItemAdapter { + override fun add(items: List): IItemAdapter { injectTheme(items) return super.add(items) } - override fun set(items: List?): FastItemAdapter { + override fun set(items: List): IItemAdapter { injectTheme(items) return super.set(items) } - override fun set(position: Int, item: Item): FastItemAdapter { + override fun set(position: Int, item: Item): IItemAdapter { injectTheme(item) return super.set(position, item) } - override fun setNewList(items: List?, retainFilter: Boolean): FastItemAdapter { + override fun setNewList(items: List, retainFilter: Boolean): IItemAdapter { injectTheme(items) return super.setNewList(items, retainFilter) } - override fun setNewList(items: List?): FastItemAdapter { - injectTheme(items) - return super.setNewList(items) - } - private fun injectTheme(items: Collection?>?) { 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 > FastAdapter.withOnRepeatedClickListener( count: Int, duration: Long, - event: OnClickListener -) = - withOnClickListener(RepeatedClickListener(count, duration, event)) + event: ClickListener +): FastAdapter { + onClickListener = RepeatedClickListener(count, duration, event) + return this +} /** * Registers and skips each click until the designated [count] clicks are triggered, @@ -40,8 +42,8 @@ fun > FastAdapter.withOnRepeatedClickListener( private class RepeatedClickListener>( @IntRange(from = 1) val count: Int, @IntRange(from = 1) val duration: Long, - val event: OnClickListener -) : OnClickListener { + val event: ClickListener +) : ClickListener { init { if (count <= 0) @@ -53,7 +55,7 @@ private class RepeatedClickListener>( private var chain = 0 private var time = -1L - override fun onClick(v: View?, adapter: IAdapter, item: Item, position: Int): Boolean { + override fun invoke(v: View?, adapter: IAdapter, item: Item, position: Int): Boolean { val now = System.currentTimeMillis() if (time - now < duration) chain++ @@ -62,7 +64,7 @@ private class RepeatedClickListener>( 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) : KPrefItemBase) { + override fun bindView(holder: ViewHolder, payloads: MutableList) { super.bindView(holder, payloads) val checkbox = holder.bindInnerView(R.layout.kau_pref_checkbox) withAccentColor(checkbox::tint) @@ -42,5 +42,6 @@ open class KPrefCheckbox(builder: BaseContract) : KPrefItemBase(builder) { - override fun bindView(holder: ViewHolder, payloads: List) { + override fun bindView(holder: ViewHolder, payloads: MutableList) { super.bindView(holder, payloads) if (builder.showPreview) { val preview = holder.bindInnerView(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, ColorContract { + interface KPrefColorContract : BaseContract, 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 by BaseBuilder(globalOptions, titleId, getter, setter), + ) : KPrefColorContract, + BaseContract 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) { + override fun bindView(holder: ViewHolder, payloads: MutableList) { 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(protected val base: BaseContract) : KPrefItem } @CallSuper - override fun bindView(holder: ViewHolder, payloads: List) { + override fun bindView(holder: ViewHolder, payloads: MutableList) { super.bindView(holder, payloads) _enabled = base.enabler() with(holder) { @@ -77,12 +77,14 @@ abstract class KPrefItemBase(protected val base: BaseContract) : 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(), KPrefItemActions by core, +abstract class KPrefItemCore(val core: CoreContract) : AbstractItem(), 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) { + override fun bindView(holder: ViewHolder, payloads: MutableList) { 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 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( override fun KClick.defaultOnClick() = Unit - override fun bindView(holder: ViewHolder, payloads: List) { + override fun bindView(holder: ViewHolder, payloads: MutableList) { super.bindView(holder, payloads) val text = holder.bindInnerView(R.layout.kau_pref_seekbar_text) withTextColor(text::setTextColor) @@ -60,7 +60,8 @@ open class KPrefSeekbar(val builder: KPrefSeekbarContract) : KPrefItemBase( }) } 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( titleId: Int, getter: () -> Int, setter: KPrefItemActions.(value: Int) -> Unit - ) : KPrefSeekbarContract, BaseContract by BaseBuilder(globalOptions, titleId, getter, setter) { + ) : KPrefSeekbarContract, + BaseContract by BaseBuilder(globalOptions, titleId, getter, setter) { override var min: Int = 0 @@ -118,5 +120,6 @@ open class KPrefSeekbar(val builder: KPrefSeekbarContract) : KPrefItemBase( 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(open val builder: KPrefTextContract) : KPrefItemBase< context.toast("No click function set") } - override fun bindView(holder: ViewHolder, payloads: List) { + override fun bindView(holder: ViewHolder, payloads: MutableList) { super.bindView(holder, payloads) val textView = holder.bindInnerView(R.layout.kau_pref_text) withTextColor(textView::setTextColor) @@ -68,9 +68,11 @@ open class KPrefText(open val builder: KPrefTextContract) : KPrefItemBase< titleId: Int, getter: () -> T, setter: KPrefItemActions.(value: T) -> Unit - ) : KPrefTextContract, BaseContract by BaseBuilder(globalOptions, titleId, getter, setter) { + ) : KPrefTextContract, + BaseContract by BaseBuilder(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(builder) { - interface KPrefTimeContract : KPrefText.KPrefTextContract, TimePickerDialog.OnTimeSetListener { + interface KPrefTimeContract : KPrefText.KPrefTextContract, + 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 by BaseBuilder(globalOptions, titleId, getter, setter) { + ) : KPrefTimeContract, + BaseContract 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 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) { 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) { 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(R.layout.kau_iitem_image_basic, { ViewHolder(it) }), + KauIItem(R.layout.kau_iitem_image_basic, { ViewHolder(it) }), GlideContract by GlideDelegate() { companion object { @SuppressLint("NewApi") fun bindEvents(activity: Activity, fastAdapter: FastAdapter) { - 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) { + override fun bindView(holder: ViewHolder, payloads: MutableList) { 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 { + @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 { + 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>( /** * 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>( * This is used for both single and multiple photo picks */ fun onMediaPickerResult(resultCode: Int, data: Intent?): List { - 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>( 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>( 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>( private fun onPickerResult(data: Intent?) { val items = mutableListOf() - 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() - 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( +class PermissionCheckbox(val permission: String) : KauIItem( R.layout.permission_checkbox, { ViewHolder(it) }) { override fun bindView(holder: ViewHolder, payloads: MutableList) { 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( +) : KauIItem( 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(android.R.id.content).bindSearchView(menu, id, menuIconColor, config) +): SearchView = + findViewById(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 -- cgit v1.2.3 From 5aefeee08f68777dd07a16bd42a7d2392db6bbc9 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Thu, 15 Aug 2019 16:04:14 -0700 Subject: Apply spotless --- .../main/kotlin/ca/allanwang/kau/about/AboutActivityBase.kt | 8 ++++---- about/src/main/kotlin/ca/allanwang/kau/about/CutoutIItem.kt | 2 +- .../src/main/kotlin/ca/allanwang/kau/ui/widgets/TextSlider.kt | 2 +- .../src/androidTest/kotlin/ca/allanwang/kau/kpref/KPrefTest.kt | 2 +- .../kotlin/ca/allanwang/kau/permissions/PermissionManager.kt | 2 +- core/src/main/kotlin/ca/allanwang/kau/swipe/RelativeSlider.kt | 2 +- core/src/main/kotlin/ca/allanwang/kau/swipe/SwipeBackHelper.kt | 2 +- core/src/main/kotlin/ca/allanwang/kau/swipe/SwipeBackLayout.kt | 8 ++++---- .../ca/allanwang/kau/ui/views/CollapsibleViewDelegate.kt | 2 +- .../kotlin/ca/allanwang/kau/ui/views/MeasureSpecDelegate.kt | 6 +++--- core/src/main/kotlin/ca/allanwang/kau/utils/ActivityUtils.kt | 2 +- core/src/main/kotlin/ca/allanwang/kau/utils/ColorUtils.kt | 2 +- core/src/main/kotlin/ca/allanwang/kau/utils/ContextUtils.kt | 6 +++--- core/src/main/kotlin/ca/allanwang/kau/utils/Kotterknife.kt | 2 +- core/src/main/kotlin/ca/allanwang/kau/utils/PackageUtils.kt | 4 ++-- core/src/main/kotlin/ca/allanwang/kau/xml/FAQ.kt | 2 +- core/src/test/kotlin/ca/allanwang/kau/kotlin/DebounceTest.kt | 8 ++++---- core/src/test/kotlin/ca/allanwang/kau/kotlin/StreamsTest.kt | 4 ++-- .../kotlin/ca/allanwang/kau/adapters/FastItemThemedAdapter.kt | 2 +- .../kotlin/ca/allanwang/kau/kpref/activity/KPrefActivity.kt | 4 ++-- .../ca/allanwang/kau/kpref/activity/items/KPrefCheckbox.kt | 2 +- .../ca/allanwang/kau/kpref/activity/items/KPrefSeekbar.kt | 2 +- .../main/kotlin/ca/allanwang/kau/mediapicker/MediaItemBasic.kt | 2 +- .../kotlin/ca/allanwang/kau/mediapicker/MediaPickerCore.kt | 6 +++--- sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt | 2 +- .../main/kotlin/ca/allanwang/kau/sample/PermissionCheckbox.kt | 2 +- .../src/main/kotlin/ca/allanwang/kau/searchview/SearchView.kt | 10 +++++----- 27 files changed, 49 insertions(+), 49 deletions(-) (limited to 'kpref-activity') 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 452d28c..d17c3ec 100644 --- a/about/src/main/kotlin/ca/allanwang/kau/about/AboutActivityBase.kt +++ b/about/src/main/kotlin/ca/allanwang/kau/about/AboutActivityBase.kt @@ -77,7 +77,7 @@ abstract class AboutActivityBase(val rClass: Class<*>?, private val configBuilde super.onCreate(savedInstanceState) setContentView(R.layout.kau_activity_about) pageStatus = IntArray(panels.size) - pageStatus[0] = 2 //the first page is instantly visible + pageStatus[0] = 2 // the first page is instantly visible if (configs.textColor != null) about_indicator.setColour(configs.textColor!!) with(about_pager) { adapter = AboutPagerAdapter() @@ -107,14 +107,14 @@ abstract class AboutActivityBase(val rClass: Class<*>?, private val configBuilde var libPageTitle: String? = null set(value) { field = value - libPageTitleRes = INVALID_ID //reset res so we don't use our default + libPageTitleRes = INVALID_ID // reset res so we don't use our default } var faqXmlRes: Int = INVALID_ID var faqPageTitleRes: Int = R.string.kau_about_faq_intro var faqPageTitle: String? = null set(value) { field = value - faqPageTitleRes = INVALID_ID //reset res so we don't use our default + faqPageTitleRes = INVALID_ID // reset res so we don't use our default } /** * Whether new lines should be included @@ -186,7 +186,7 @@ abstract class AboutActivityBase(val rClass: Class<*>?, private val configBuilde } override fun onDestroy() { - AnimHolder.decelerateInterpolator.invalidate() //clear the reference to the interpolators we've used + AnimHolder.decelerateInterpolator.invalidate() // clear the reference to the interpolators we've used super.onDestroy() } } 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 d51db46..d92f6a7 100644 --- a/about/src/main/kotlin/ca/allanwang/kau/about/CutoutIItem.kt +++ b/about/src/main/kotlin/ca/allanwang/kau/about/CutoutIItem.kt @@ -47,7 +47,7 @@ class CutoutIItem(val config: CutoutView.() -> Unit = {}) : KauIItem MIN_FLING_VELOCITY) || (edgeFlag == SWIPE_EDGE_RIGHT && xvel < -MIN_FLING_VELOCITY) || (edgeFlag == SWIPE_EDGE_TOP && yvel > MIN_FLING_VELOCITY) || @@ -400,7 +400,7 @@ internal class SwipeBackLayout @JvmOverloads constructor( ) result = exitCaptureOffsets(edgeFlag, releasedChild) } else { - //threshold met; fling to designated side + // threshold met; fling to designated side result = exitCaptureOffsets(edgeFlag, releasedChild) } dragHelper.settleCapturedViewAt(result.first, result.second) diff --git a/core/src/main/kotlin/ca/allanwang/kau/ui/views/CollapsibleViewDelegate.kt b/core/src/main/kotlin/ca/allanwang/kau/ui/views/CollapsibleViewDelegate.kt index b2a0d27..b00d951 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/ui/views/CollapsibleViewDelegate.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/ui/views/CollapsibleViewDelegate.kt @@ -116,7 +116,7 @@ class CollapsibleViewDelegate : CollapsibleView { override fun collapse(animate: Boolean) = setExpanded(false, animate) override fun setExpanded(expand: Boolean) = setExpanded(expand, true) override fun setExpanded(expand: Boolean, animate: Boolean) { - if (expand == expanded) return //state already matches + if (expand == expanded) return // state already matches val target = if (expand) 1f else 0f if (animate) animateSize(target) else expansion = target } diff --git a/core/src/main/kotlin/ca/allanwang/kau/ui/views/MeasureSpecDelegate.kt b/core/src/main/kotlin/ca/allanwang/kau/ui/views/MeasureSpecDelegate.kt index 6481306..61e6f30 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/ui/views/MeasureSpecDelegate.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/ui/views/MeasureSpecDelegate.kt @@ -113,17 +113,17 @@ class MeasureSpecDelegate : MeasureSpecContract { view.parentViewGroup.getWindowVisibleDisplayFrame(parentFrame) var width = View.MeasureSpec.getSize(widthMeasureSpec).toFloat() var height = View.MeasureSpec.getSize(heightMeasureSpec).toFloat() - //first cycle - relative to parent + // first cycle - relative to parent if (relativeHeightToParent > 0) height = relativeHeightToParent * parentFrame.height() if (relativeWidthToParent > 0) width = relativeWidthToParent * parentFrame.width() - //second cycle - relative to each other + // second cycle - relative to each other if (relativeHeight > 0) height = relativeHeight * width else if (relativeWidth > 0) width = relativeWidth * height - //third cycle - relative to each other + // third cycle - relative to each other if (postRelativeHeight > 0) height = postRelativeHeight * width else if (postRelativeWidth > 0) diff --git a/core/src/main/kotlin/ca/allanwang/kau/utils/ActivityUtils.kt b/core/src/main/kotlin/ca/allanwang/kau/utils/ActivityUtils.kt index 21141f1..fe210b2 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/utils/ActivityUtils.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/utils/ActivityUtils.kt @@ -85,7 +85,7 @@ inline fun Activity.restart(intentBuilder: Intent.() -> Unit = {}) { i.putExtras(oldExtras) i.intentBuilder() startActivity(i) - overridePendingTransition(R.anim.kau_fade_in, R.anim.kau_fade_out) //No transitions + overridePendingTransition(R.anim.kau_fade_in, R.anim.kau_fade_out) // No transitions finish() overridePendingTransition(R.anim.kau_fade_in, R.anim.kau_fade_out) } diff --git a/core/src/main/kotlin/ca/allanwang/kau/utils/ColorUtils.kt b/core/src/main/kotlin/ca/allanwang/kau/utils/ColorUtils.kt index 3de0297..ab7b341 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/utils/ColorUtils.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/utils/ColorUtils.kt @@ -157,7 +157,7 @@ fun String.toColor(): Int { return Color.parseColor(toParse) } -//Get ColorStateList +// Get ColorStateList fun Context.colorStateList(@ColorInt color: Int): ColorStateList { val disabledColor = color.adjustAlpha(0.3f) return ColorStateList( diff --git a/core/src/main/kotlin/ca/allanwang/kau/utils/ContextUtils.kt b/core/src/main/kotlin/ca/allanwang/kau/utils/ContextUtils.kt index d002fb8..62e5716 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/utils/ContextUtils.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/utils/ContextUtils.kt @@ -113,7 +113,7 @@ fun Context.startLink(vararg url: String?) { fun Context.startLink(@StringRes url: Int) = startLink(string(url)) -//Toast helpers +// Toast helpers inline fun View.toast(@StringRes id: Int, duration: Int = Toast.LENGTH_LONG, log: Boolean = false) = context.toast(id, duration, log) @@ -130,7 +130,7 @@ inline fun Context.toast(text: String, duration: Int = Toast.LENGTH_LONG, log: B const val INVALID_ID = 0 -//Resource retrievers +// Resource retrievers inline fun Context.string(@StringRes id: Int): String = getString(id) inline fun Context.string(@StringRes id: Int, fallback: String?): String? = @@ -161,7 +161,7 @@ inline fun Context.animation(@AnimRes id: Int) = AnimationUtils.loadAnimation(th inline fun Context.plural(@PluralsRes id: Int, quantity: Number) = resources.getQuantityString(id, quantity.toInt(), quantity.toInt()) -//Attr retrievers +// Attr retrievers fun Context.resolveColor(@AttrRes attr: Int, @ColorInt fallback: Int = 0): Int { val a = theme.obtainStyledAttributes(intArrayOf(attr)) try { 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 aaef160..fac9421 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/utils/Kotterknife.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/utils/Kotterknife.kt @@ -246,7 +246,7 @@ private fun requiredResettable(ids: IntArray, finder: T.(Int) -> V private fun optionalResettable(ids: IntArray, finder: T.(Int) -> View?) = LazyResettable { t: T, _ -> ids.map { t.finder(it) as V? }.filterNotNull() } -//Like Kotterknife's lazy delegate but is resettable +// Like Kotterknife's lazy delegate but is resettable private class LazyResettable(initializer: (T, KProperty<*>) -> V) : Lazy(initializer) { override fun getValue(thisRef: T, property: KProperty<*>): V { KotterknifeRegistry.register(thisRef!!, this) diff --git a/core/src/main/kotlin/ca/allanwang/kau/utils/PackageUtils.kt b/core/src/main/kotlin/ca/allanwang/kau/utils/PackageUtils.kt index 4055847..0bd534e 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/utils/PackageUtils.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/utils/PackageUtils.kt @@ -54,13 +54,13 @@ fun Context.isAppEnabled(packageName: String): Boolean { @KauUtils fun Context.showAppInfo(packageName: String) { try { - //Open the specific App Info page: + // Open the specific App Info page: val intent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS) intent.data = Uri.parse("package:$packageName") startActivity(intent) } catch (e: ActivityNotFoundException) { e.printStackTrace() - //Open the generic Apps page: + // Open the generic Apps page: val intent = Intent(Settings.ACTION_MANAGE_APPLICATIONS_SETTINGS) startActivity(intent) } diff --git a/core/src/main/kotlin/ca/allanwang/kau/xml/FAQ.kt b/core/src/main/kotlin/ca/allanwang/kau/xml/FAQ.kt index 73d7d6c..afde735 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/xml/FAQ.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/xml/FAQ.kt @@ -43,7 +43,7 @@ fun Context.kauParseFaq( resources.getXml(xmlRes).use { parser: XmlResourceParser -> var eventType = parser.eventType var question: Spanned? = null - var flag = -1 //-1, 0, 1 -> invalid, question, answer + var flag = -1 // -1, 0, 1 -> invalid, question, answer while (eventType != XmlPullParser.END_DOCUMENT) { if (eventType == XmlPullParser.START_TAG) { flag = when (parser.name) { diff --git a/core/src/test/kotlin/ca/allanwang/kau/kotlin/DebounceTest.kt b/core/src/test/kotlin/ca/allanwang/kau/kotlin/DebounceTest.kt index c406901..d43901f 100644 --- a/core/src/test/kotlin/ca/allanwang/kau/kotlin/DebounceTest.kt +++ b/core/src/test/kotlin/ca/allanwang/kau/kotlin/DebounceTest.kt @@ -50,16 +50,16 @@ class DebounceTest { fun multipleDebounces() { var i = 0 val debounce = debounce(20) { i += it } - debounce(1) //ignore -> i = 0 + debounce(1) // ignore -> i = 0 Thread.sleep(10) assertEquals(0, i) - debounce(2) //accept -> i = 2 + debounce(2) // accept -> i = 2 Thread.sleep(30) assertEquals(2, i) - debounce(4) //ignore -> i = 2 + debounce(4) // ignore -> i = 2 Thread.sleep(10) assertEquals(2, i) - debounce(8) //accept -> i = 10 + debounce(8) // accept -> i = 10 Thread.sleep(30) assertEquals(10, i) } diff --git a/core/src/test/kotlin/ca/allanwang/kau/kotlin/StreamsTest.kt b/core/src/test/kotlin/ca/allanwang/kau/kotlin/StreamsTest.kt index 4dc4a34..e3d4e5b 100644 --- a/core/src/test/kotlin/ca/allanwang/kau/kotlin/StreamsTest.kt +++ b/core/src/test/kotlin/ca/allanwang/kau/kotlin/StreamsTest.kt @@ -47,10 +47,10 @@ class StreamsTest { items.add(3, thePotato) assertEquals(result.size + 1, items.size, "Invalid list addition") assertEquals(2, items.filter { it.id == 9 }.size, "Invalid number of potatoes with id 9") - items.kauRemoveIf { it === thePotato } //removal by reference + items.kauRemoveIf { it === thePotato } // removal by reference assertEquals(result.size, items.size, "Invalid list size after removal") assertEquals(result, items) - items.kauRemoveIf { it == thePotato } //removal by equality + items.kauRemoveIf { it == thePotato } // removal by equality assertEquals(result.size - 1, items.size, "Invalid list removal based on equality") } } 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 5531f59..be98ffa 100644 --- a/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/FastItemThemedAdapter.kt +++ b/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/FastItemThemedAdapter.kt @@ -159,7 +159,7 @@ class ThemableIItemDelegate : ThemableIItem, ThemableIItemColors by ThemableIIte override fun bindBackgroundRipple(vararg views: View?) { val background = backgroundColor ?: return val foreground = accentColor ?: textColor ?: backgroundColor - ?: return //default to normal background + ?: return // default to normal background val ripple = createSimpleRippleDrawable(foreground, background) views.forEach { it?.background = ripple } } 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 f11afde..800a355 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 @@ -74,7 +74,7 @@ abstract class KPrefActivity : KauBaseActivity(), KPrefActivityContract { @SuppressLint("NewApi") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - //setup layout + // setup layout setContentView(R.layout.kau_pref_activity) setSupportActionBar(toolbar) supportActionBar?.apply { @@ -88,7 +88,7 @@ abstract class KPrefActivity : KauBaseActivity(), KPrefActivityContract { statusBarColor = 0x30000000 kau_toolbar_ripple.set(resolveColor(R.attr.colorPrimary)) kau_ripple.set(resolveColor(android.R.attr.colorBackground)) - //setup prefs + // setup prefs val core = CoreAttributeBuilder() val builder = kPrefCoreAttributes() core.builder() 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 f4f4a65..a867d06 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 @@ -39,7 +39,7 @@ open class KPrefCheckbox(builder: BaseContract) : KPrefItemBase(R.layout.kau_pref_checkbox) withAccentColor(checkbox::tint) checkbox.isChecked = pref - checkbox.jumpDrawablesToCurrentState() //Cancel the animation + checkbox.jumpDrawablesToCurrentState() // Cancel the animation } override val type: Int 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 5de1f83..9abdf09 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 @@ -61,7 +61,7 @@ open class KPrefSeekbar(val builder: KPrefSeekbarContract) : KPrefItemBase( } withAccentColor(seekbar::tint) text.text = - builder.toText(seekbar.progress.fromProgress) //set initial text in case no change occurs + builder.toText(seekbar.progress.fromProgress) // set initial text in case no change occurs seekbar.progress = pref.toProgress seekbar.isEnabled = builder.enabler() } 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 873289f..e801848 100644 --- a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaItemBasic.kt +++ b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaItemBasic.kt @@ -40,7 +40,7 @@ class MediaItemBasic(val data: MediaModel) : @SuppressLint("NewApi") fun bindEvents(activity: Activity, fastAdapter: FastAdapter) { fastAdapter.getSelectExtension().isSelectable = true - //add image data and return right away + // add image data and return right away fastAdapter.onClickListener = { _, _, item, _ -> activity.finish(arrayListOf(item.data)) true 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 dceb1df..9b8bdfa 100644 --- a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerCore.kt +++ b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerCore.kt @@ -157,7 +157,7 @@ abstract class MediaPickerCore( } } - //Sort by descending date + // Sort by descending date var sortQuery = MediaStore.MediaColumns.DATE_MODIFIED + " DESC" override fun onCreateLoader(id: Int, args: Bundle?): Loader { @@ -264,8 +264,8 @@ abstract class MediaPickerCore( }.mapNotNull { DocumentsContract.getDocumentId(it).split(":").getOrNull(1) }.joinToString(prefix = "(", separator = ",", postfix = ")") - //? query replacements are done for one arg at a time - //since we potentially have a list of ids, we'll just format the WHERE clause ourself + // ? query replacements are done for one arg at a time + // since we potentially have a list of ids, we'll just format the WHERE clause ourself query(baseUri, MediaModel.projection, "${BaseColumns._ID} IN $ids", null, sortQuery)?.use( block ) 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 11d19e5..4fe941b 100644 --- a/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt +++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt @@ -47,7 +47,7 @@ class MainActivity : KPrefActivity() { companion object { - //some of the most common english words for show + // some of the most common english words for show val wordBank: List by lazy { listOf( "the", "name", "of", "very", "to", "through", 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 7cf6cc1..68dde2a 100644 --- a/sample/src/main/kotlin/ca/allanwang/kau/sample/PermissionCheckbox.kt +++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/PermissionCheckbox.kt @@ -33,7 +33,7 @@ class PermissionCheckbox(val permission: String) : KauIItem Unit = {}) { TransitionManager.beginDelayedTransition(kau_search_cardview, - //we are only using change bounds, as the recyclerview items may be animated as well, - //which causes a measure IllegalStateException + // we are only using change bounds, as the recyclerview items may be animated as well, + // which causes a measure IllegalStateException TransitionSet().addTransition(ChangeBounds()).apply { duration = configs.transitionDuration builder() -- cgit v1.2.3 From eafb4881cc6c33d7ae94b1f1e1b5b34fb18ebd03 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sat, 14 Sep 2019 19:01:33 -0700 Subject: Revert about library to older variant --- about/build.gradle | 1 - .../main/kotlin/ca/allanwang/kau/about/AboutActivityBase.kt | 10 +++++----- buildSrc/src/main/kotlin/kau/Versions.kt | 2 +- docs/Changelog.md | 1 - fastadapter/build.gradle | 2 +- kpref-activity/build.gradle | 2 ++ sample/src/main/res/xml/kau_changelog.xml | 1 - 7 files changed, 9 insertions(+), 10 deletions(-) (limited to 'kpref-activity') diff --git a/about/build.gradle b/about/build.gradle index 114428b..274ef5c 100644 --- a/about/build.gradle +++ b/about/build.gradle @@ -11,7 +11,6 @@ android { dependencies { implementation project(':core-ui') implementation project(':fastadapter') - implementation Dependencies.fastAdapter("utils") api Dependencies.aboutLibraries } 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 b12ad0e..7ba7811 100644 --- a/about/src/main/kotlin/ca/allanwang/kau/about/AboutActivityBase.kt +++ b/about/src/main/kotlin/ca/allanwang/kau/about/AboutActivityBase.kt @@ -148,11 +148,11 @@ abstract class AboutActivityBase( open fun getLibraries(libs: Libs): List = libs.prepareLibraries( this, - emptyArray(), - emptyArray(), - autoDetect = true, - checkCachedDetection = true, - sort = true + null, + null, + true, + true, + true ) /* diff --git a/buildSrc/src/main/kotlin/kau/Versions.kt b/buildSrc/src/main/kotlin/kau/Versions.kt index b4b08b0..3c54625 100644 --- a/buildSrc/src/main/kotlin/kau/Versions.kt +++ b/buildSrc/src/main/kotlin/kau/Versions.kt @@ -30,7 +30,7 @@ object Versions { const val coroutines = "1.3.1" // https://github.com/mikepenz/AboutLibraries/releases - const val aboutLibraries = "7.0.3" + const val aboutLibraries = "6.2.3" // https://github.com/wasabeef/Blurry/releases const val blurry = "3.0.0" diff --git a/docs/Changelog.md b/docs/Changelog.md index f76fbe4..0078430 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -2,7 +2,6 @@ ## v5.2.0 * :fastadapter: Migrate fastadapter to v4.x.x -* :fastadapter: Remove fastadapter utils from api ## v5.1.0 * :adapter: Moved fastadapter elements to new module, :fastadapter:. To migrate, simply rename the dependency. If you don't use fast adapter, no changes are necessary diff --git a/fastadapter/build.gradle b/fastadapter/build.gradle index 0fbcce9..8abe566 100644 --- a/fastadapter/build.gradle +++ b/fastadapter/build.gradle @@ -10,8 +10,8 @@ dependencies { api project(':adapter') api Dependencies.fastAdapter + api Dependencies.fastAdapter("utils") implementation Dependencies.fastAdapter("diff") - implementation Dependencies.fastAdapter("utils") } apply from: '../artifacts.gradle' diff --git a/kpref-activity/build.gradle b/kpref-activity/build.gradle index 5cce460..7df08d3 100644 --- a/kpref-activity/build.gradle +++ b/kpref-activity/build.gradle @@ -1,3 +1,5 @@ +import kau.Dependencies + ext.kauSubModuleMinSdk = kau.Versions.coreMinSdk ext.kauSubModuleResourcePrefix = "kau_pref_" diff --git a/sample/src/main/res/xml/kau_changelog.xml b/sample/src/main/res/xml/kau_changelog.xml index 82d27c2..5fee3cb 100644 --- a/sample/src/main/res/xml/kau_changelog.xml +++ b/sample/src/main/res/xml/kau_changelog.xml @@ -8,7 +8,6 @@ - -- cgit v1.2.3