diff options
author | Allan Wang <me@allanwang.ca> | 2019-06-07 14:25:56 -0400 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2019-06-07 14:25:56 -0400 |
commit | 1ac55ac5b029d792b2c5a93ef7548d3588c6bab2 (patch) | |
tree | 7436434a963163b7b923775eda195c838ee32b1e | |
parent | 940b3142f0a1364ba56e5117e16da51207c44d44 (diff) | |
parent | eb9317015c6535bfa36166d254ec954f81d8df97 (diff) | |
download | kau-1ac55ac5b029d792b2c5a93ef7548d3588c6bab2.tar.gz kau-1ac55ac5b029d792b2c5a93ef7548d3588c6bab2.tar.bz2 kau-1ac55ac5b029d792b2c5a93ef7548d3588c6bab2.zip |
Merge branch 'dev' into plugin-object
-rw-r--r-- | .idea/misc.xml | 2 | ||||
-rw-r--r-- | android-lib.gradle | 5 | ||||
-rw-r--r-- | artifacts.gradle | 27 | ||||
-rw-r--r-- | core/src/main/kotlin/ca/allanwang/kau/utils/NetworkUtils.kt | 3 | ||||
-rw-r--r-- | core/src/main/kotlin/ca/allanwang/kau/xml/Changelog.kt | 16 | ||||
-rw-r--r-- | core/src/main/res/layout/kau_changelog_content.xml | 2 | ||||
-rw-r--r-- | docs/Migration.md | 3 | ||||
-rw-r--r-- | sample/build.gradle | 5 | ||||
-rw-r--r-- | sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt | 14 | ||||
-rw-r--r-- | sample/src/main/res/values/colors.xml | 6 |
10 files changed, 46 insertions, 37 deletions
diff --git a/.idea/misc.xml b/.idea/misc.xml index 51fa3e5..cc04cd3 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -35,7 +35,7 @@ </value> </option> </component> - <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK"> + <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK"> <output url="file://$PROJECT_DIR$/build/classes" /> </component> <component name="ProjectType"> diff --git a/android-lib.gradle b/android-lib.gradle index fd691b2..598ddcb 100644 --- a/android-lib.gradle +++ b/android-lib.gradle @@ -61,6 +61,11 @@ android { pickFirst 'META-INF/library_release.kotlin_module' } + compileOptions { + sourceCompatibility '1.8' + targetCompatibility '1.8' + } + sourceSets { main.java.srcDirs += 'src/main/kotlin' test.java.srcDirs += 'src/test/kotlin' diff --git a/artifacts.gradle b/artifacts.gradle index ab291f7..4471d37 100644 --- a/artifacts.gradle +++ b/artifacts.gradle @@ -31,16 +31,23 @@ artifacts { // We assume resources within res-public are public task generatepublicxml { - def resDir = project.projectDir.absolutePath + "/src/main/res-public" - - def publicFolder = file(resDir + "/values") - if (!publicFolder.exists()) publicFolder.mkdirs() + def resDir = project.projectDir.absolutePath + "/src/main/res" + def publicDir = resDir + "-public" + def resFolder = file(resDir + "/values") + def publicFolder = file(publicDir + "/values") + if (!publicFolder.exists()) { + // No res; no need for contents + if (!resFolder.exists()) { + return + } + publicFolder.mkdirs() + } // Include the desired res types // Note: we don't need the qualified resource directories, // since those resources will already be defined in the unqualified directories // however, there are special cases like transition-v21 that is only available on lollipop and up - def tree = fileTree(dir: resDir, + def tree = fileTree(dir: publicDir, includes: ['**/anim/*.xml', '**/color/*.xml', '**/drawable/*.xml', @@ -54,12 +61,12 @@ task generatepublicxml { println "Generating public XML: ${project.name}" // Create new public.xml with writer - file(resDir + "/values/public.xml").withWriter { writer -> + file(publicDir + "/values/public.xml").withWriter { writer -> // Create MarkupBuilder with 4 space indent - def destXml = new MarkupBuilder(new IndentPrinter(writer, " ", true)); - def destXmlMkp = destXml.getMkp(); + def destXml = new MarkupBuilder(new IndentPrinter(writer, " ", true)) + def destXmlMkp = destXml.getMkp() - // GIST NOTE: our project needed the ResourceName suppression, but its not needed in general + // GIST NOTE: our project needed the ResourceName suppression, but it's not needed in general destXml.resources( 'xmlns:tools': 'http://schemas.android.com/tools', 'tools:ignore': 'ResourceName' @@ -74,7 +81,7 @@ task generatepublicxml { tree.each { resFile -> // use the directory name to get the type - def type = resFile.getParentFile().getName() + String type = resFile.getParentFile().getName() if (type == "values") { // Resource files under values. Parse the file, and pull out the resource definitions 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" diff --git a/docs/Migration.md b/docs/Migration.md index 593056e..203dc1d 100644 --- a/docs/Migration.md +++ b/docs/Migration.md @@ -12,6 +12,9 @@ Please refer to [MD's documents](https://github.com/afollestad/material-dialogs/ Alongside such changes, `:colorpicker` is no longer as necessary. It exists mainly to provide an internal interface for other submodules. +After Material Dialog 2.x, a decision was made to enforce theming through xml styles only to avoid reflection. +As a result, options to supply custom dialog colors are now removed (ie in the changelog dialog and color picker kprefs). + ## Update ProgressAnimator `ProgressAnimator` has been completely rewritten to be an extension of `ValueAnimator`. diff --git a/sample/build.gradle b/sample/build.gradle index 8f408be..5f795db 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -80,6 +80,11 @@ android { pickFirst 'META-INF/library_release.kotlin_module' } + compileOptions { + sourceCompatibility '1.8' + targetCompatibility '1.8' + } + sourceSets { main.java.srcDirs += 'src/main/kotlin' test.java.srcDirs += 'src/test/kotlin' 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 d9586c4..9ce3f42 100644 --- a/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt +++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt @@ -260,12 +260,7 @@ class MainActivity : KPrefActivity() { if (KPrefSample.version < BuildConfig.VERSION_CODE) { KPrefSample.version = BuildConfig.VERSION_CODE if (!BuildConfig.DEBUG) - showChangelog(R.xml.kau_changelog, KPrefSample.textColor) { - // TODO MD Color -// titleColor(KPrefSample.textColor) -// backgroundColor(KPrefSample.bgColor) -// positiveColor(KPrefSample.accentColor) - } + showChangelog(R.xml.kau_changelog) } supportActionBar?.apply { setDisplayHomeAsUpEnabled(false) @@ -298,12 +293,7 @@ class MainActivity : KPrefActivity() { override fun onOptionsItemSelected(item: MenuItem): Boolean { when (item.itemId) { - R.id.action_changelog -> showChangelog(R.xml.kau_changelog, KPrefSample.textColor) { - // TODO MD Color -// titleColor(KPrefSample.textColor) -// backgroundColor(KPrefSample.bgColor) -// positiveColor(KPrefSample.accentColor) - } + R.id.action_changelog -> showChangelog(R.xml.kau_changelog) R.id.action_settings -> startActivity<AnimActivity>() R.id.action_email -> sendEmail(R.string.your_email, R.string.your_subject) else -> return super.onOptionsItemSelected(item) diff --git a/sample/src/main/res/values/colors.xml b/sample/src/main/res/values/colors.xml index 3ab3e9c..12363c4 100644 --- a/sample/src/main/res/values/colors.xml +++ b/sample/src/main/res/values/colors.xml @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <resources> - <color name="colorPrimary">#3F51B5</color> - <color name="colorPrimaryDark">#303F9F</color> - <color name="colorAccent">#FF4081</color> + <color name="colorPrimary">#2196F3</color> + <color name="colorPrimaryDark">#1976D2</color> + <color name="colorAccent">#FF5722</color> </resources> |