diff options
-rw-r--r-- | .idea/misc.xml | 2 | ||||
-rw-r--r-- | android-lib.gradle | 5 | ||||
-rw-r--r-- | artifacts.gradle | 27 | ||||
-rw-r--r-- | buildSrc/src/main/groovy/ca/allanwang/kau/Versions.groovy | 57 | ||||
-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 |
11 files changed, 46 insertions, 94 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 e8a4c6d..28fc945 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/buildSrc/src/main/groovy/ca/allanwang/kau/Versions.groovy b/buildSrc/src/main/groovy/ca/allanwang/kau/Versions.groovy deleted file mode 100644 index d767a8a..0000000 --- a/buildSrc/src/main/groovy/ca/allanwang/kau/Versions.groovy +++ /dev/null @@ -1,57 +0,0 @@ -package ca.allanwang.kau - -class Versions { - static def coreMinSdk = 19 - static def minSdk = 21 - static def targetSdk = 28 - - // https://developer.android.com/studio/releases/build-tools - static def buildTools = '28.0.3' - - // https://developer.android.com/topic/libraries/support-library/revisions - static def supportLibs = '28.0.0' - - // https://kotlinlang.org/docs/reference/using-gradle.html - static def kotlin = '1.2.71' - - // https://github.com/mikepenz/AboutLibraries/releases - static def aboutLibraries = '6.1.1' - - // https://github.com/Kotlin/anko/releases - static def anko = '0.10.5' - - // https://github.com/wasabeef/Blurry/releases - static def blurry = '2.1.1' - - // https://dl.google.com/dl/android/maven2/com/android/support/constraint/group-index.xml - static def constraintLayout = '1.1.3' - - // https://github.com/mikepenz/FastAdapter#using-maven - static def fastAdapter = '3.2.9' - static def fastAdapterCommons = fastAdapter - - // https://github.com/bumptech/glide/releases - static def glide = '4.8.0' - - // https://github.com/mikepenz/Android-Iconics#1-provide-the-gradle-dependency - static def iconics = '3.0.4' - static def iconicsGoogle = '3.0.1.2' - static def iconicsMaterial = '2.2.0.4' - static def iconicsCommunity = '2.0.46.1' - - // https://github.com/afollestad/material-dialogs/releases - static def materialDialog = '0.9.6.0' - - static def espresso = '3.0.1' - static def junit = '4.12' - static def testRunner = '1.0.1' - - static def gradlePlugin = '3.2.1' - static def mavenPlugin = '2.1' - static def playPublishPlugin = '1.2.2' - - // https://github.com/KeepSafe/dexcount-gradle-plugin/releases - static def dexCountPlugin = '0.8.4' - // https://github.com/gladed/gradle-android-git-version/releases - static def gitVersionPlugin = '0.4.5' -}
\ No newline at end of file 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 bb7cab0..d11e5bd 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> |