aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2019-06-07 14:25:56 -0400
committerAllan Wang <me@allanwang.ca>2019-06-07 14:25:56 -0400
commit1ac55ac5b029d792b2c5a93ef7548d3588c6bab2 (patch)
tree7436434a963163b7b923775eda195c838ee32b1e /core
parent940b3142f0a1364ba56e5117e16da51207c44d44 (diff)
parenteb9317015c6535bfa36166d254ec954f81d8df97 (diff)
downloadkau-1ac55ac5b029d792b2c5a93ef7548d3588c6bab2.tar.gz
kau-1ac55ac5b029d792b2c5a93ef7548d3588c6bab2.tar.bz2
kau-1ac55ac5b029d792b2c5a93ef7548d3588c6bab2.zip
Merge branch 'dev' into plugin-object
Diffstat (limited to 'core')
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/utils/NetworkUtils.kt3
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/xml/Changelog.kt16
-rw-r--r--core/src/main/res/layout/kau_changelog_content.xml2
3 files changed, 10 insertions, 11 deletions
diff --git a/core/src/main/kotlin/ca/allanwang/kau/utils/NetworkUtils.kt b/core/src/main/kotlin/ca/allanwang/kau/utils/NetworkUtils.kt
index 32cf084..39d689b 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/utils/NetworkUtils.kt
+++ b/core/src/main/kotlin/ca/allanwang/kau/utils/NetworkUtils.kt
@@ -22,6 +22,7 @@ import android.net.ConnectivityManager
/**
* Created by Allan Wang on 2017-07-07.
*/
+@Suppress("DEPRECATION")
@Deprecated("Applications should make use of network callbacks instead of individual queries")
inline val Context.isNetworkAvailable: Boolean
@SuppressLint("MissingPermission")
@@ -31,6 +32,7 @@ inline val Context.isNetworkAvailable: Boolean
return activeNetworkInfo?.isConnectedOrConnecting ?: false
}
+@Suppress("DEPRECATION")
@Deprecated("Applications should make use of network callbacks instead of individual queries")
inline val Context.isWifiConnected: Boolean
@SuppressLint("MissingPermission")
@@ -40,6 +42,7 @@ inline val Context.isWifiConnected: Boolean
return (activeNetworkInfo?.type ?: -1) == ConnectivityManager.TYPE_WIFI
}
+@Suppress("DEPRECATION")
@Deprecated("Applications should make use of network callbacks instead of individual queries")
inline val Context.isMobileDataConnected: Boolean
@SuppressLint("MissingPermission")
diff --git a/core/src/main/kotlin/ca/allanwang/kau/xml/Changelog.kt b/core/src/main/kotlin/ca/allanwang/kau/xml/Changelog.kt
index 2e66a97..9adcbf4 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/xml/Changelog.kt
+++ b/core/src/main/kotlin/ca/allanwang/kau/xml/Changelog.kt
@@ -21,7 +21,6 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
-import androidx.annotation.ColorInt
import androidx.annotation.LayoutRes
import androidx.annotation.XmlRes
import androidx.recyclerview.widget.RecyclerView
@@ -41,13 +40,13 @@ import org.xmlpull.v1.XmlPullParser
*
* Easy changelog loader
*/
-fun Context.showChangelog(@XmlRes xmlRes: Int, @ColorInt textColor: Int? = null, customize: MaterialDialog.() -> Unit = {}) {
- ctxCoroutine.launch {
- val items = withContext(Dispatchers.Default) { parse(this@showChangelog, xmlRes) }
+fun Context.showChangelog(@XmlRes xmlRes: Int, customize: MaterialDialog.() -> Unit = {}) {
+ ctxCoroutine.launch(Dispatchers.Main) {
+ val items = withContext(Dispatchers.IO) { parse(this@showChangelog, xmlRes) }
materialDialog {
title(R.string.kau_changelog)
positiveButton(R.string.kau_great)
- customListAdapter(ChangelogAdapter(items, textColor), null)
+ customListAdapter(ChangelogAdapter(items), null)
customize()
}
}
@@ -57,7 +56,7 @@ fun Context.showChangelog(@XmlRes xmlRes: Int, @ColorInt textColor: Int? = null,
* Internals of the changelog dialog
* Contains an mainAdapter for each item, as well as the tags to parse
*/
-internal class ChangelogAdapter(val items: List<Pair<String, ChangelogType>>, @ColorInt val textColor: Int? = null) :
+internal class ChangelogAdapter(val items: List<Pair<String, ChangelogType>>) :
RecyclerView.Adapter<ChangelogAdapter.ChangelogVH>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = ChangelogVH(
@@ -67,10 +66,6 @@ internal class ChangelogAdapter(val items: List<Pair<String, ChangelogType>>, @C
override fun onBindViewHolder(holder: ChangelogVH, position: Int) {
holder.text.text = items[position].first
- if (textColor != null) {
- holder.text.setTextColor(textColor)
- holder.bullet?.setTextColor(textColor)
- }
}
override fun getItemId(position: Int) = position.toLong()
@@ -81,7 +76,6 @@ internal class ChangelogAdapter(val items: List<Pair<String, ChangelogType>>, @C
internal class ChangelogVH(itemView: View) : RecyclerView.ViewHolder(itemView) {
val text: TextView = itemView.findViewById(R.id.kau_changelog_text)
- val bullet: TextView? = itemView.findViewById(R.id.kau_changelog_bullet)
}
}
diff --git a/core/src/main/res/layout/kau_changelog_content.xml b/core/src/main/res/layout/kau_changelog_content.xml
index ab94956..1fea88d 100644
--- a/core/src/main/res/layout/kau_changelog_content.xml
+++ b/core/src/main/res/layout/kau_changelog_content.xml
@@ -10,6 +10,7 @@
<!--padding bottom is 14sp * 0.6-->
<TextView
+ android:textColor="?android:textColorSecondary"
android:id="@+id/kau_changelog_bullet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@@ -19,6 +20,7 @@
android:textAppearance="@style/TextAppearance.AppCompat.Small" />
<TextView
+ android:textColor="?android:textColorPrimary"
android:id="@+id/kau_changelog_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"