Permalink
Browse files

Convert to Kotlin 1.3.0, Coroutines 1.0.0

  • Loading branch information...
ianhanniballake committed Nov 3, 2018
1 parent 3c01fac commit f104f8c4206e992de159cddf0459ff60e5d8a662
Showing with 172 additions and 181 deletions.
  1. +0 −2 android-client-common/build.gradle
  2. +3 −3 android-client-common/src/main/java/com/google/android/apps/muzei/provider/Background.kt
  3. +4 −4 android-client-common/src/main/java/com/google/android/apps/muzei/provider/DirectBootCache.kt
  4. +1 −1 android-client-common/src/main/java/com/google/android/apps/muzei/provider/MuzeiDocumentsProvider.kt
  5. +1 −1 android-client-common/src/main/java/com/google/android/apps/muzei/provider/MuzeiProvider.kt
  6. +2 −2 android-client-common/src/main/java/com/google/android/apps/muzei/render/ImageLoader.kt
  7. +2 −2 android-client-common/src/main/java/com/google/android/apps/muzei/room/ArtworkDao.kt
  8. +7 −5 android-client-common/src/main/java/com/google/android/apps/muzei/room/InstalledProvidersLiveData.kt
  9. +2 −2 android-client-common/src/main/java/com/google/android/apps/muzei/room/ProviderDao.kt
  10. +2 −2 android-client-common/src/main/java/com/google/android/apps/muzei/room/SourceDao.kt
  11. +3 −3 android-client-common/src/main/java/com/google/android/apps/muzei/sync/ArtworkLoadWorker.kt
  12. +1 −1 android-client-common/src/main/java/com/google/android/apps/muzei/sync/ProviderChangedWorker.kt
  13. +11 −8 android-client-common/src/main/java/com/google/android/apps/muzei/sync/ProviderManager.kt
  14. +2 −2 ...oid-client-common/src/main/java/com/google/android/apps/muzei/util/ContentProviderClientCompat.kt
  15. +2 −2 build.gradle
  16. +0 −2 extensions/build.gradle
  17. +2 −2 extensions/src/main/java/com/google/android/apps/muzei/util/BroadcastReceiverExt.kt
  18. +3 −4 extensions/src/main/java/com/google/android/apps/muzei/util/ContextExt.kt
  19. +3 −4 extensions/src/main/java/com/google/android/apps/muzei/util/LivecycleJob.kt
  20. +4 −5 extensions/src/main/java/com/google/android/apps/muzei/util/ScopedAndroidViewModel.kt
  21. +0 −2 main/build.gradle
  22. +5 −6 main/src/main/java/com/google/android/apps/muzei/ArtDetailFragment.kt
  23. +1 −1 main/src/main/java/com/google/android/apps/muzei/ArtworkInfoRedirectActivity.kt
  24. +2 −2 main/src/main/java/com/google/android/apps/muzei/ChooseProviderFragment.kt
  25. +13 −6 main/src/main/java/com/google/android/apps/muzei/ChooseProviderViewModel.kt
  26. +4 −4 main/src/main/java/com/google/android/apps/muzei/MuzeiWallpaperService.kt
  27. +2 −2 main/src/main/java/com/google/android/apps/muzei/NextArtworkActivity.kt
  28. +2 −3 main/src/main/java/com/google/android/apps/muzei/PhotoSetAsTargetActivity.kt
  29. +4 −5 main/src/main/java/com/google/android/apps/muzei/browse/BrowseProviderFragment.kt
  30. +7 −4 main/src/main/java/com/google/android/apps/muzei/browse/BrowseProviderViewModel.kt
  31. +2 −2 main/src/main/java/com/google/android/apps/muzei/notifications/NotificationUpdater.kt
  32. +3 −3 main/src/main/java/com/google/android/apps/muzei/quicksettings/NextArtworkTileService.kt
  33. +5 −5 main/src/main/java/com/google/android/apps/muzei/render/DemoRenderController.kt
  34. +3 −4 main/src/main/java/com/google/android/apps/muzei/render/RenderController.kt
  35. +3 −3 main/src/main/java/com/google/android/apps/muzei/settings/EffectsScreenFragment.kt
  36. +3 −4 main/src/main/java/com/google/android/apps/muzei/sources/SourceArtProvider.kt
  37. +4 −5 main/src/main/java/com/google/android/apps/muzei/sources/SourceManager.kt
  38. +2 −2 main/src/main/java/com/google/android/apps/muzei/sources/SourceSettingsActivity.kt
  39. +2 −2 main/src/main/java/com/google/android/apps/muzei/wearable/WearableController.kt
  40. +6 −6 main/src/main/java/com/google/android/apps/muzei/widget/AppWidgetUpdateTask.kt
  41. +2 −2 main/src/main/java/com/google/android/apps/muzei/widget/WidgetUpdater.kt
  42. +0 −2 source-featured-art/build.gradle
  43. +6 −3 source-featured-art/src/main/java/com/google/android/apps/muzei/featuredart/FeaturedArtWorker.kt
  44. +0 −2 source-gallery/build.gradle
  45. +6 −6 source-gallery/src/main/java/com/google/android/apps/muzei/gallery/ChosenPhotoDao.kt
  46. +2 −3 source-gallery/src/main/java/com/google/android/apps/muzei/gallery/GalleryAddPhotosActivity.kt
  47. +2 −2 source-gallery/src/main/java/com/google/android/apps/muzei/gallery/GalleryArtSource.kt
  48. +2 −2 source-gallery/src/main/java/com/google/android/apps/muzei/gallery/GalleryProvider.kt
  49. +2 −2 source-gallery/src/main/java/com/google/android/apps/muzei/gallery/GalleryScanWorker.kt
  50. +3 −4 source-gallery/src/main/java/com/google/android/apps/muzei/gallery/GallerySettingsActivity.kt
  51. +0 −2 source-single/build.gradle
  52. +2 −2 source-single/src/main/java/com/google/android/apps/muzei/single/SingleArtProvider.kt
  53. +2 −2 source-single/src/main/java/com/google/android/apps/muzei/single/SingleSettingsActivity.kt
  54. +0 −2 wearable/build.gradle
  55. +2 −2 wearable/src/main/java/com/google/android/apps/muzei/ChooseProviderActivity.kt
  56. +4 −5 wearable/src/main/java/com/google/android/apps/muzei/FullScreenActivity.kt
  57. +3 −4 wearable/src/main/java/com/google/android/apps/muzei/MuzeiActivity.kt
  58. +2 −2 wearable/src/main/java/com/google/android/apps/muzei/MuzeiWatchFace.kt
  59. +2 −2 ...e/src/main/java/com/google/android/apps/muzei/complications/ArtworkComplicationProviderService.kt
  60. +2 −2 wearable/src/main/java/com/google/android/apps/muzei/datalayer/CapabilityListenerService.kt
@@ -46,8 +46,6 @@ dependencies {
}
}
kotlin.experimental.coroutines "enable"
android {
compileSdkVersion rootProject.ext.compileSdkVersion
@@ -1,9 +1,9 @@
package com.google.android.apps.muzei.provider
import android.os.Looper
import kotlinx.coroutines.experimental.Dispatchers
import kotlinx.coroutines.experimental.runBlocking
import kotlinx.coroutines.experimental.withContext
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withContext
/**
* Ensures that [block] is not run on the main thread.
@@ -21,10 +21,10 @@ import android.os.Build
import android.support.v4.content.ContextCompat
import android.util.Log
import com.google.android.apps.muzei.api.MuzeiContract
import kotlinx.coroutines.experimental.GlobalScope
import kotlinx.coroutines.experimental.Job
import kotlinx.coroutines.experimental.delay
import kotlinx.coroutines.experimental.launch
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.Job
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import net.nurik.roman.muzei.androidclientcommon.BuildConfig
import java.io.File
import java.io.FileOutputStream
@@ -32,7 +32,7 @@ import android.util.Log
import com.google.android.apps.muzei.render.ImageLoader
import com.google.android.apps.muzei.room.Artwork
import com.google.android.apps.muzei.room.MuzeiDatabase
import kotlinx.coroutines.experimental.runBlocking
import kotlinx.coroutines.runBlocking
import net.nurik.roman.muzei.androidclientcommon.BuildConfig
import net.nurik.roman.muzei.androidclientcommon.R
import java.io.File
@@ -33,7 +33,7 @@ import android.util.Log
import com.google.android.apps.muzei.api.MuzeiContract
import com.google.android.apps.muzei.room.MuzeiDatabase
import com.google.android.apps.muzei.sync.ProviderManager
import kotlinx.coroutines.experimental.runBlocking
import kotlinx.coroutines.runBlocking
import net.nurik.roman.muzei.androidclientcommon.BuildConfig
import java.io.FileNotFoundException
@@ -25,8 +25,8 @@ import android.net.Uri
import android.os.Build
import android.support.media.ExifInterface
import android.util.Log
import kotlinx.coroutines.experimental.Dispatchers
import kotlinx.coroutines.experimental.withContext
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import net.nurik.roman.muzei.androidclientcommon.BuildConfig
import java.io.FileNotFoundException
import java.io.IOException
@@ -20,8 +20,8 @@ import android.arch.lifecycle.LiveData
import android.arch.persistence.room.Dao
import android.arch.persistence.room.Insert
import android.arch.persistence.room.Query
import kotlinx.coroutines.experimental.Dispatchers
import kotlinx.coroutines.experimental.withContext
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
/**
* Dao for Artwork
@@ -25,9 +25,10 @@ import android.content.IntentFilter
import android.content.pm.PackageManager
import android.content.pm.ProviderInfo
import com.google.android.apps.muzei.api.provider.MuzeiArtProvider
import kotlinx.coroutines.experimental.CoroutineScope
import kotlinx.coroutines.experimental.launch
import kotlinx.coroutines.experimental.newSingleThreadContext
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.asCoroutineDispatcher
import kotlinx.coroutines.launch
import java.util.concurrent.Executors
fun ProviderInfo.getComponentName() = ComponentName(packageName, name)
@@ -41,8 +42,9 @@ class InstalledProvidersLiveData(
private val currentProviders = HashMap<ComponentName, ProviderInfo>()
private val singleThreadContext = newSingleThreadContext("ChooseProvider")
private val singleThreadContext = Executors.newSingleThreadExecutor { target ->
Thread(target, "ChooseProvider")
}.asCoroutineDispatcher()
private val packageChangeReceiver : BroadcastReceiver = object : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent?) {
@@ -22,8 +22,8 @@ import android.arch.persistence.room.Delete
import android.arch.persistence.room.Insert
import android.arch.persistence.room.Query
import android.arch.persistence.room.Update
import kotlinx.coroutines.experimental.Dispatchers
import kotlinx.coroutines.experimental.withContext
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
/**
* Dao for Providers
@@ -25,8 +25,8 @@ import android.arch.persistence.room.TypeConverters
import android.arch.persistence.room.Update
import android.content.ComponentName
import com.google.android.apps.muzei.room.converter.ComponentNameTypeConverter
import kotlinx.coroutines.experimental.Dispatchers
import kotlinx.coroutines.experimental.withContext
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
/**
* Dao for Sources
@@ -45,8 +45,8 @@ import com.google.android.apps.muzei.room.Artwork
import com.google.android.apps.muzei.room.MuzeiDatabase
import com.google.android.apps.muzei.util.ContentProviderClientCompat
import com.google.android.apps.muzei.util.getLong
import kotlinx.coroutines.experimental.delay
import kotlinx.coroutines.experimental.runBlocking
import kotlinx.coroutines.delay
import kotlinx.coroutines.runBlocking
import net.nurik.roman.muzei.androidclientcommon.BuildConfig
import java.io.IOException
import java.util.Random
@@ -64,7 +64,7 @@ class ArtworkLoadWorker(
companion object {
private const val TAG = "ArtworkLoad"
private const val PERIODIC_TAG = "ArtworkLoadPeriodic"
private const val ARTWORK_LOAD_THROTTLE = 250 // quarter second
private const val ARTWORK_LOAD_THROTTLE = 250L // quarter second
internal fun enqueueNext() {
val workManager = WorkManager.getInstance()
@@ -43,7 +43,7 @@ import com.google.android.apps.muzei.render.isValidImage
import com.google.android.apps.muzei.room.MuzeiDatabase
import com.google.android.apps.muzei.room.Provider
import com.google.android.apps.muzei.util.ContentProviderClientCompat
import kotlinx.coroutines.experimental.runBlocking
import kotlinx.coroutines.runBlocking
import net.nurik.roman.muzei.androidclientcommon.BuildConfig
import java.io.IOException
import java.util.HashSet
@@ -40,20 +40,23 @@ import com.google.android.apps.muzei.room.Artwork
import com.google.android.apps.muzei.room.MuzeiDatabase
import com.google.android.apps.muzei.room.Provider
import com.google.android.apps.muzei.util.ContentProviderClientCompat
import kotlinx.coroutines.experimental.Dispatchers
import kotlinx.coroutines.experimental.GlobalScope
import kotlinx.coroutines.experimental.Job
import kotlinx.coroutines.experimental.delay
import kotlinx.coroutines.experimental.launch
import kotlinx.coroutines.experimental.newSingleThreadContext
import kotlinx.coroutines.experimental.withContext
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.Job
import kotlinx.coroutines.asCoroutineDispatcher
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import net.nurik.roman.muzei.androidclientcommon.BuildConfig
import java.util.concurrent.Executors
/**
* Single threaded coroutine context used for all sync operations
*/
internal val syncSingleThreadContext by lazy {
newSingleThreadContext("ProviderSync")
Executors.newSingleThreadExecutor { target ->
Thread(target, "ProviderSync")
}.asCoroutineDispatcher()
}
/**
@@ -25,8 +25,8 @@ import android.os.Build
import android.os.Bundle
import android.os.ParcelFileDescriptor
import android.os.RemoteException
import kotlinx.coroutines.experimental.Dispatchers
import kotlinx.coroutines.experimental.withContext
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import java.io.FileNotFoundException
import java.io.InputStream
View
@@ -19,8 +19,8 @@ buildscript {
compileSdkVersion = 28
targetSdkVersion = 25
kotlinVersion = "1.2.71"
coroutinesVersion = "0.26.1"
kotlinVersion = "1.3.0"
coroutinesVersion = "1.0.0"
ktxVersion = "0.3"
multidexVersion = "1.0.3"
supportLibraryVersion = "28.0.0"
View
@@ -17,8 +17,6 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
kotlin.experimental.coroutines "enable"
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"
api "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion"
@@ -17,8 +17,8 @@
package com.google.android.apps.muzei.util
import android.content.BroadcastReceiver
import kotlinx.coroutines.experimental.GlobalScope
import kotlinx.coroutines.experimental.launch
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
fun BroadcastReceiver.goAsync(block: suspend () -> Unit) {
val result = goAsync()
@@ -19,10 +19,9 @@ package com.google.android.apps.muzei.util
import android.content.Context
import android.support.annotation.StringRes
import android.widget.Toast
import kotlinx.coroutines.experimental.Dispatchers
import kotlinx.coroutines.experimental.GlobalScope
import kotlinx.coroutines.experimental.android.Main
import kotlinx.coroutines.experimental.launch
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
/**
* Creates and shows a [Toast] with the given [text]
@@ -19,10 +19,9 @@ package com.google.android.apps.muzei.util
import android.arch.lifecycle.DefaultLifecycleObserver
import android.arch.lifecycle.Lifecycle
import android.arch.lifecycle.LifecycleOwner
import kotlinx.coroutines.experimental.CoroutineScope
import kotlinx.coroutines.experimental.Dispatchers
import kotlinx.coroutines.experimental.Job
import kotlinx.coroutines.experimental.android.Main
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
private fun Lifecycle.createJob(): Job = Job().also { job ->
addObserver(object : DefaultLifecycleObserver {
@@ -19,11 +19,10 @@ package com.google.android.apps.muzei.util
import android.app.Application
import android.arch.lifecycle.AndroidViewModel
import android.support.annotation.CallSuper
import kotlinx.coroutines.experimental.CoroutineScope
import kotlinx.coroutines.experimental.Dispatchers
import kotlinx.coroutines.experimental.Job
import kotlinx.coroutines.experimental.android.Main
import kotlin.coroutines.experimental.CoroutineContext
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlin.coroutines.CoroutineContext
open class ScopedAndroidViewModel(
application: Application
View
@@ -95,8 +95,6 @@ android {
}
}
kotlin.experimental.coroutines "enable"
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"
api "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion"
@@ -64,12 +64,11 @@ import com.google.android.apps.muzei.util.makeCubicGradientScrimDrawable
import com.google.android.apps.muzei.util.observeNonNull
import com.google.android.apps.muzei.widget.showWidgetPreview
import com.google.firebase.analytics.FirebaseAnalytics
import kotlinx.coroutines.experimental.Dispatchers
import kotlinx.coroutines.experimental.GlobalScope
import kotlinx.coroutines.experimental.Job
import kotlinx.coroutines.experimental.android.Main
import kotlinx.coroutines.experimental.delay
import kotlinx.coroutines.experimental.launch
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.Job
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import net.nurik.roman.muzei.BuildConfig.SOURCES_AUTHORITY
import net.nurik.roman.muzei.R
@@ -25,7 +25,7 @@ import com.google.android.apps.muzei.room.MuzeiDatabase
import com.google.android.apps.muzei.room.openArtworkInfo
import com.google.android.apps.muzei.util.coroutineScope
import com.google.firebase.analytics.FirebaseAnalytics
import kotlinx.coroutines.experimental.launch
import kotlinx.coroutines.launch
/**
* Open the Artwork Info associated with the current artwork
@@ -61,8 +61,8 @@ import com.google.android.apps.muzei.sync.ProviderManager
import com.google.android.apps.muzei.util.observe
import com.google.android.apps.muzei.util.toast
import com.google.firebase.analytics.FirebaseAnalytics
import kotlinx.coroutines.experimental.GlobalScope
import kotlinx.coroutines.experimental.launch
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import net.nurik.roman.muzei.BuildConfig.SOURCES_AUTHORITY
import net.nurik.roman.muzei.R
@@ -31,13 +31,13 @@ import com.google.android.apps.muzei.room.MuzeiDatabase
import com.google.android.apps.muzei.room.Provider
import com.google.android.apps.muzei.sync.ProviderManager
import com.google.android.apps.muzei.util.ScopedAndroidViewModel
import kotlinx.coroutines.experimental.Dispatchers
import kotlinx.coroutines.experimental.android.Main
import kotlinx.coroutines.experimental.launch
import kotlinx.coroutines.experimental.newSingleThreadContext
import kotlinx.coroutines.experimental.withContext
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.asCoroutineDispatcher
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import net.nurik.roman.muzei.BuildConfig.SOURCES_AUTHORITY
import net.nurik.roman.muzei.R
import java.util.concurrent.Executors
data class ProviderInfo(
val authority: String,
@@ -81,7 +81,14 @@ class ChooseProviderViewModel(application: Application) : ScopedAndroidViewModel
private val currentProviders = HashMap<String, ProviderInfo>()
private var activeProvider : Provider? = null
private val singleThreadContext = newSingleThreadContext("ChooseProvider")
private val singleThreadContext = Executors.newSingleThreadExecutor { target ->
Thread(target, "ChooseProvider")
}.asCoroutineDispatcher()
override fun onCleared() {
singleThreadContext.close()
super.onCleared()
}
@SuppressLint("InlinedApi")
val playStoreIntent: Intent = Intent(Intent.ACTION_VIEW,
@@ -61,10 +61,10 @@ import com.google.android.apps.muzei.wallpaper.WallpaperAnalytics
import com.google.android.apps.muzei.wearable.WearableController
import com.google.android.apps.muzei.widget.WidgetUpdater
import com.google.firebase.analytics.FirebaseAnalytics
import kotlinx.coroutines.experimental.GlobalScope
import kotlinx.coroutines.experimental.Job
import kotlinx.coroutines.experimental.delay
import kotlinx.coroutines.experimental.launch
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.Job
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import net.rbgrn.android.glwallpaperservice.GLWallpaperService
data class WallpaperSize(val width: Int, val height: Int)
@@ -21,8 +21,8 @@ import android.os.Bundle
import androidx.core.os.bundleOf
import com.google.android.apps.muzei.sources.SourceManager
import com.google.firebase.analytics.FirebaseAnalytics
import kotlinx.coroutines.experimental.GlobalScope
import kotlinx.coroutines.experimental.launch
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
/**
* Simple activity that just triggers the 'Next Artwork' action and finishes
@@ -28,9 +28,8 @@ import com.google.android.apps.muzei.sync.ProviderManager
import com.google.android.apps.muzei.util.coroutineScope
import com.google.android.apps.muzei.util.toast
import com.google.firebase.analytics.FirebaseAnalytics
import kotlinx.coroutines.experimental.Dispatchers
import kotlinx.coroutines.experimental.android.Main
import kotlinx.coroutines.experimental.launch
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import net.nurik.roman.muzei.R
class PhotoSetAsTargetActivity : FragmentActivity() {
Oops, something went wrong.

0 comments on commit f104f8c

Please sign in to comment.