aboutsummaryrefslogtreecommitdiff
path: root/about
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2018-12-24 01:17:31 -0500
committerGitHub <noreply@github.com>2018-12-24 01:17:31 -0500
commitfb90c4a4ab23f2fd246c29c1dde4d6e155a2e38b (patch)
treecc6d67461b6caa256043b9482f7646831d528a08 /about
parenta380adea1052d39f23c9c4d432a9380ce347d6c4 (diff)
downloadkau-fb90c4a4ab23f2fd246c29c1dde4d6e155a2e38b.tar.gz
kau-fb90c4a4ab23f2fd246c29c1dde4d6e155a2e38b.tar.bz2
kau-fb90c4a4ab23f2fd246c29c1dde4d6e155a2e38b.zip
Enhancement/ktlint (#179)
* Add spotless dependency * Apply ktlint * Add license headers
Diffstat (limited to 'about')
-rw-r--r--about/src/main/kotlin/ca/allanwang/kau/about/AboutActivityBase.kt27
-rw-r--r--about/src/main/kotlin/ca/allanwang/kau/about/AboutBinder.kt21
-rw-r--r--about/src/main/kotlin/ca/allanwang/kau/about/AboutPanelDelegate.kt41
-rw-r--r--about/src/main/kotlin/ca/allanwang/kau/about/CollapsibleTextView.kt23
-rw-r--r--about/src/main/kotlin/ca/allanwang/kau/about/CutoutIItem.kt22
-rw-r--r--about/src/main/kotlin/ca/allanwang/kau/about/FaqIItem.kt41
-rw-r--r--about/src/main/kotlin/ca/allanwang/kau/about/LibraryIItem.kt45
7 files changed, 167 insertions, 53 deletions
diff --git a/about/src/main/kotlin/ca/allanwang/kau/about/AboutActivityBase.kt b/about/src/main/kotlin/ca/allanwang/kau/about/AboutActivityBase.kt
index 9667f47..79077c5 100644
--- a/about/src/main/kotlin/ca/allanwang/kau/about/AboutActivityBase.kt
+++ b/about/src/main/kotlin/ca/allanwang/kau/about/AboutActivityBase.kt
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2018 Allan Wang
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package ca.allanwang.kau.about
import android.graphics.drawable.Drawable
@@ -32,7 +47,8 @@ import kotlinx.android.synthetic.main.kau_activity_about.*
* Note that for the auto detection to work, the R fields must be excluded from Proguard
* Manual lib listings and other extra modifications can be done so by overriding the open functions
*/
-abstract class AboutActivityBase(val rClass: Class<*>?, private val configBuilder: Configs.() -> Unit = {}) : KauBaseActivity(), ViewPager.OnPageChangeListener {
+abstract class AboutActivityBase(val rClass: Class<*>?, private val configBuilder: Configs.() -> Unit = {}) :
+ KauBaseActivity(), ViewPager.OnPageChangeListener {
val currentPage: Int
get() = about_pager.currentItem
@@ -73,7 +89,7 @@ abstract class AboutActivityBase(val rClass: Class<*>?, private val configBuilde
about_draggable_frame.addListener(object : ElasticDragDismissFrameLayout.SystemChromeFader(this) {
override fun onDragDismissed() {
window.returnTransition = TransitionInflater.from(this@AboutActivityBase)
- .inflateTransition(if (about_draggable_frame.translationY > 0) R.transition.kau_exit_slide_bottom else R.transition.kau_exit_slide_top)
+ .inflateTransition(if (about_draggable_frame.translationY > 0) R.transition.kau_exit_slide_bottom else R.transition.kau_exit_slide_top)
panels[currentPage].recycler?.stopScroll()
finishAfterTransition()
}
@@ -113,7 +129,6 @@ abstract class AboutActivityBase(val rClass: Class<*>?, private val configBuilde
* Feel free to add your own items to the adapter in here
*/
open fun postInflateMainPage(adapter: FastItemThemedAdapter<IItem<*, *>>) {
-
}
/**
@@ -123,7 +138,7 @@ abstract class AboutActivityBase(val rClass: Class<*>?, private val configBuilde
* This is fetched asynchronously and you may override it to customize the list
*/
open fun getLibraries(libs: Libs): List<Library> =
- libs.prepareLibraries(this, null, null, true, true, true)!!
+ libs.prepareLibraries(this, null, null, true, true, true)!!
/*
* -------------------------------------------------------------------
@@ -156,7 +171,7 @@ abstract class AboutActivityBase(val rClass: Class<*>?, private val configBuilde
*/
private fun getPage(position: Int, parent: ViewGroup): View {
if (views[position] == null) views[position] = panels[position]
- .inflatePage(this@AboutActivityBase, parent, position)
+ .inflatePage(this@AboutActivityBase, parent, position)
return views[position]!!
}
}
@@ -174,4 +189,4 @@ abstract class AboutActivityBase(val rClass: Class<*>?, private val configBuilde
AnimHolder.decelerateInterpolator.invalidate() //clear the reference to the interpolators we've used
super.onDestroy()
}
-} \ No newline at end of file
+}
diff --git a/about/src/main/kotlin/ca/allanwang/kau/about/AboutBinder.kt b/about/src/main/kotlin/ca/allanwang/kau/about/AboutBinder.kt
index c99f7c2..1183113 100644
--- a/about/src/main/kotlin/ca/allanwang/kau/about/AboutBinder.kt
+++ b/about/src/main/kotlin/ca/allanwang/kau/about/AboutBinder.kt
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2018 Allan Wang
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package ca.allanwang.kau.about
import android.content.Context
@@ -12,6 +27,6 @@ import ca.allanwang.kau.utils.withSceneTransitionAnimation
* About activity launcher
*/
inline fun <reified T : AboutActivityBase> Context.kauLaunchAbout() =
- startActivity<T>(bundleBuilder = {
- withSceneTransitionAnimation(this@kauLaunchAbout)
- }) \ No newline at end of file
+ startActivity<T>(bundleBuilder = {
+ withSceneTransitionAnimation(this@kauLaunchAbout)
+ })
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 6698dba..35c1322 100644
--- a/about/src/main/kotlin/ca/allanwang/kau/about/AboutPanelDelegate.kt
+++ b/about/src/main/kotlin/ca/allanwang/kau/about/AboutPanelDelegate.kt
@@ -1,15 +1,37 @@
+/*
+ * Copyright 2018 Allan Wang
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package ca.allanwang.kau.about
-import androidx.recyclerview.widget.RecyclerView
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
+import androidx.recyclerview.widget.RecyclerView
import ca.allanwang.kau.adapters.FastItemThemedAdapter
import ca.allanwang.kau.animators.FadeScaleAnimatorAdd
import ca.allanwang.kau.animators.KauAnimator
import ca.allanwang.kau.animators.NoAnimatorChange
import ca.allanwang.kau.iitems.HeaderIItem
-import ca.allanwang.kau.utils.*
+import ca.allanwang.kau.utils.AnimHolder
+import ca.allanwang.kau.utils.KAU_BOTTOM
+import ca.allanwang.kau.utils.colorToForeground
+import ca.allanwang.kau.utils.drawable
+import ca.allanwang.kau.utils.fullLinearRecycler
+import ca.allanwang.kau.utils.postDelayed
+import ca.allanwang.kau.utils.string
+import ca.allanwang.kau.utils.withMarginDecoration
import ca.allanwang.kau.xml.kauParseFaq
import com.mikepenz.aboutlibraries.Libs
import com.mikepenz.fastadapter.IItem
@@ -76,8 +98,8 @@ abstract class AboutPanelRecycler : AboutPanelContract {
override fun onInflatingPage(activity: AboutActivityBase, recycler: RecyclerView, position: Int) {
recycler.adapter = adapter
recycler.itemAnimator = KauAnimator(
- addAnimator = FadeScaleAnimatorAdd(scaleFactor = 0.7f, itemDelayFactor = 0.2f),
- changeAnimator = NoAnimatorChange()
+ addAnimator = FadeScaleAnimatorAdd(scaleFactor = 0.7f, itemDelayFactor = 0.2f),
+ changeAnimator = NoAnimatorChange()
).apply { addDuration = 300; interpolator = AnimHolder.decelerateInterpolator(recycler.context) }
}
@@ -136,7 +158,6 @@ open class AboutPanelMain : AboutPanelRecycler() {
}
override fun addItemsImpl(activity: AboutActivityBase, position: Int) {}
-
}
/**
@@ -155,7 +176,8 @@ open class AboutPanelLibs : AboutPanelRecycler() {
override fun loadItems(activity: AboutActivityBase, position: Int) {
doAsync {
with(activity) {
- items = getLibraries(if (rClass == null) Libs(activity) else Libs(this, Libs.toStringArray(rClass.fields)))
+ items =
+ getLibraries(if (rClass == null) Libs(activity) else Libs(this, Libs.toStringArray(rClass.fields)))
.map(::LibraryIItem)
if (pageStatus[position] == 1)
uiThread { addItems(activity, position) }
@@ -166,7 +188,7 @@ open class AboutPanelLibs : AboutPanelRecycler() {
override fun addItemsImpl(activity: AboutActivityBase, position: Int) {
with(activity.configs) {
adapter.add(HeaderIItem(text = libPageTitle, textRes = libPageTitleRes))
- .add(items)
+ .add(items)
}
}
}
@@ -191,8 +213,7 @@ open class AboutPanelFaqs : AboutPanelRecycler() {
override fun addItemsImpl(activity: AboutActivityBase, position: Int) {
with(activity.configs) {
adapter.add(HeaderIItem(text = faqPageTitle, textRes = faqPageTitleRes))
- .add(items)
+ .add(items)
}
}
-
-} \ No newline at end of file
+}
diff --git a/about/src/main/kotlin/ca/allanwang/kau/about/CollapsibleTextView.kt b/about/src/main/kotlin/ca/allanwang/kau/about/CollapsibleTextView.kt
index 3dbb87e..c9b8b93 100644
--- a/about/src/main/kotlin/ca/allanwang/kau/about/CollapsibleTextView.kt
+++ b/about/src/main/kotlin/ca/allanwang/kau/about/CollapsibleTextView.kt
@@ -1,9 +1,24 @@
+/*
+ * Copyright 2018 Allan Wang
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package ca.allanwang.kau.about
import android.content.Context
import android.content.res.Configuration
-import androidx.appcompat.widget.AppCompatTextView
import android.util.AttributeSet
+import androidx.appcompat.widget.AppCompatTextView
import ca.allanwang.kau.ui.views.CollapsibleView
import ca.allanwang.kau.ui.views.CollapsibleViewDelegate
@@ -12,7 +27,9 @@ import ca.allanwang.kau.ui.views.CollapsibleViewDelegate
*
*/
class CollapsibleTextView @JvmOverloads constructor(
- context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
+ context: Context,
+ attrs: AttributeSet? = null,
+ defStyleAttr: Int = 0
) : AppCompatTextView(context, attrs, defStyleAttr), CollapsibleView by CollapsibleViewDelegate() {
init {
@@ -29,4 +46,4 @@ class CollapsibleTextView @JvmOverloads constructor(
val result = getCollapsibleDimension()
setMeasuredDimension(result.first, result.second)
}
-} \ No newline at end of file
+}
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 630a48e..b51c9c8 100644
--- a/about/src/main/kotlin/ca/allanwang/kau/about/CutoutIItem.kt
+++ b/about/src/main/kotlin/ca/allanwang/kau/about/CutoutIItem.kt
@@ -1,7 +1,22 @@
+/*
+ * Copyright 2018 Allan Wang
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package ca.allanwang.kau.about
-import androidx.recyclerview.widget.RecyclerView
import android.view.View
+import androidx.recyclerview.widget.RecyclerView
import ca.allanwang.kau.adapters.ThemableIItem
import ca.allanwang.kau.adapters.ThemableIItemDelegate
import ca.allanwang.kau.iitems.KauIItem
@@ -13,7 +28,7 @@ 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>(
- R.layout.kau_iitem_cutout, ::ViewHolder, R.id.kau_item_cutout
+ R.layout.kau_iitem_cutout, ::ViewHolder, R.id.kau_item_cutout
), ThemableIItem by ThemableIItemDelegate() {
override fun isSelectable(): Boolean = false
@@ -37,5 +52,4 @@ class CutoutIItem(val config: CutoutView.() -> Unit = {}) : KauIItem<CutoutIItem
class ViewHolder(v: View) : RecyclerView.ViewHolder(v) {
val cutout: CutoutView = v.findViewById(R.id.kau_cutout)
}
-
-} \ No newline at end of file
+}
diff --git a/about/src/main/kotlin/ca/allanwang/kau/about/FaqIItem.kt b/about/src/main/kotlin/ca/allanwang/kau/about/FaqIItem.kt
index 5f5d0c6..755ac81 100644
--- a/about/src/main/kotlin/ca/allanwang/kau/about/FaqIItem.kt
+++ b/about/src/main/kotlin/ca/allanwang/kau/about/FaqIItem.kt
@@ -1,11 +1,26 @@
+/*
+ * Copyright 2018 Allan Wang
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package ca.allanwang.kau.about
import android.annotation.SuppressLint
-import androidx.recyclerview.widget.RecyclerView
import android.text.method.LinkMovementMethod
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
+import androidx.recyclerview.widget.RecyclerView
import ca.allanwang.kau.adapters.ThemableIItem
import ca.allanwang.kau.adapters.ThemableIItemDelegate
import ca.allanwang.kau.iitems.KauIItem
@@ -22,23 +37,24 @@ import com.mikepenz.fastadapter.listeners.ClickEventHook
* Created by Allan Wang on 2017-08-02.
*/
class FaqIItem(val content: FaqItem) : KauIItem<LibraryIItem, FaqIItem.ViewHolder>(
- R.layout.kau_iitem_faq, ::ViewHolder, R.id.kau_item_faq
+ R.layout.kau_iitem_faq, ::ViewHolder, R.id.kau_item_faq
), ThemableIItem by ThemableIItemDelegate() {
companion object {
fun bindEvents(fastAdapter: FastAdapter<IItem<*, *>>) {
fastAdapter.withSelectable(false)
- .withEventHook(object : ClickEventHook<IItem<*, *>>() {
+ .withEventHook(object : ClickEventHook<IItem<*, *>>() {
- override fun onBind(viewHolder: RecyclerView.ViewHolder): View? = (viewHolder as? ViewHolder)?.questionContainer
+ override fun onBind(viewHolder: RecyclerView.ViewHolder): View? =
+ (viewHolder as? ViewHolder)?.questionContainer
- override fun onClick(v: View, position: Int, adapter: FastAdapter<IItem<*, *>>, item: IItem<*, *>) {
- if (item !is FaqIItem) return
- item.isExpanded = !item.isExpanded
- v.parentViewGroup.findViewById<CollapsibleTextView>(R.id.faq_item_answer).setExpanded(item.isExpanded)
- }
-
- })
+ override fun onClick(v: View, position: Int, adapter: FastAdapter<IItem<*, *>>, item: IItem<*, *>) {
+ if (item !is FaqIItem) return
+ item.isExpanded = !item.isExpanded
+ v.parentViewGroup.findViewById<CollapsibleTextView>(R.id.faq_item_answer)
+ .setExpanded(item.isExpanded)
+ }
+ })
}
}
@@ -83,5 +99,4 @@ class FaqIItem(val content: FaqItem) : KauIItem<LibraryIItem, FaqIItem.ViewHolde
answer.movementMethod = LinkMovementMethod.getInstance()
}
}
-
-} \ No newline at end of file
+}
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 e1e9a76..33aac09 100644
--- a/about/src/main/kotlin/ca/allanwang/kau/about/LibraryIItem.kt
+++ b/about/src/main/kotlin/ca/allanwang/kau/about/LibraryIItem.kt
@@ -1,11 +1,26 @@
+/*
+ * Copyright 2018 Allan Wang
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package ca.allanwang.kau.about
import android.os.Build
-import androidx.recyclerview.widget.RecyclerView
import android.text.Html
import android.view.View
import android.widget.TextView
import androidx.cardview.widget.CardView
+import androidx.recyclerview.widget.RecyclerView
import ca.allanwang.kau.adapters.ThemableIItem
import ca.allanwang.kau.adapters.ThemableIItemDelegate
import ca.allanwang.kau.iitems.KauIItem
@@ -20,21 +35,21 @@ import com.mikepenz.fastadapter.IItem
* Created by Allan Wang on 2017-06-27.
*/
class LibraryIItem(val lib: Library) : KauIItem<LibraryIItem, LibraryIItem.ViewHolder>(
- R.layout.kau_iitem_library, ::ViewHolder, R.id.kau_item_library
+ R.layout.kau_iitem_library, ::ViewHolder, R.id.kau_item_library
), ThemableIItem by ThemableIItemDelegate() {
companion object {
fun bindEvents(fastAdapter: FastAdapter<IItem<*, *>>) {
fastAdapter.withSelectable(false)
- .withOnClickListener { v, _, item, _ ->
- if (item !is LibraryIItem)
- false
- else
- with(item.lib) {
- v!!.context.startLink(libraryWebsite, repositoryLink, authorWebsite)
- true
- }
- }
+ .withOnClickListener { v, _, item, _ ->
+ if (item !is LibraryIItem)
+ false
+ else
+ with(item.lib) {
+ v!!.context.startLink(libraryWebsite, repositoryLink, authorWebsite)
+ true
+ }
+ }
}
}
@@ -48,7 +63,10 @@ class LibraryIItem(val lib: Library) : KauIItem<LibraryIItem, LibraryIItem.ViewH
@Suppress("DEPRECATION")
description.text = when {
lib.libraryDescription.isBlank() -> lib.libraryDescription
- Build.VERSION.SDK_INT >= Build.VERSION_CODES.N -> Html.fromHtml(lib.libraryDescription, Html.FROM_HTML_MODE_LEGACY)
+ Build.VERSION.SDK_INT >= Build.VERSION_CODES.N -> Html.fromHtml(
+ lib.libraryDescription,
+ Html.FROM_HTML_MODE_LEGACY
+ )
else -> Html.fromHtml(lib.libraryDescription)
}
bottomDivider.gone()
@@ -90,5 +108,4 @@ class LibraryIItem(val lib: Library) : KauIItem<LibraryIItem, LibraryIItem.ViewH
val divider: View = v.findViewById(R.id.lib_item_top_divider)
val bottomDivider: View = v.findViewById(R.id.lib_item_bottom_divider)
}
-
-} \ No newline at end of file
+}