Skip to content
Permalink
Browse files

Remove usages of MuzeiArtSource

  • Loading branch information...
ianhanniballake committed Sep 3, 2019
1 parent fe2a2fb commit 0f7527483e88bd44eb64a2686bf99fdb625a5f3e
@@ -16,10 +16,18 @@

package com.google.android.apps.muzei.legacy

import android.content.Intent

/**
* Constants used as the protocol to communicate with the LegacySourceService.
*/
object LegacySourceServiceProtocol {
/**
* The [Intent] action representing a Muzei art source. This service should
* declare an `<intent-filter>` for this action in order to register with
* Muzei.
*/
const val ACTION_MUZEI_ART_SOURCE = "com.google.android.apps.muzei.api.MuzeiArtSource"
const val LEGACY_COMMAND_ID_NEXT_ARTWORK = 1001
const val LEGACY_SOURCE_ACTION = "com.google.android.apps.muzei.legacy"

@@ -42,7 +42,6 @@ import androidx.lifecycle.MediatorLiveData
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.observe
import androidx.room.withTransaction
import com.google.android.apps.muzei.api.MuzeiArtSource
import com.google.android.apps.muzei.api.internal.ProtocolConstants.ACTION_SUBSCRIBE
import com.google.android.apps.muzei.api.internal.ProtocolConstants.EXTRA_SUBSCRIBER_COMPONENT
import com.google.android.apps.muzei.api.internal.ProtocolConstants.EXTRA_TOKEN
@@ -135,7 +134,7 @@ class LegacySourceService : Service(), LifecycleOwner {
Log.d(TAG, "Sending next artwork command to ${source.componentName}")
}
source.sendAction(this@LegacySourceService,
MuzeiArtSource.BUILTIN_COMMAND_ID_NEXT_ARTWORK)
LegacySourceServiceProtocol.LEGACY_COMMAND_ID_NEXT_ARTWORK)
}
}
LegacySourceServiceProtocol.WHAT_ALLOWS_NEXT_ARTWORK -> {
@@ -199,7 +198,7 @@ class LegacySourceService : Service(), LifecycleOwner {
}

private suspend fun updateSources(packageName: String? = null) {
val queryIntent = Intent(MuzeiArtSource.ACTION_MUZEI_ART_SOURCE)
val queryIntent = Intent(LegacySourceServiceProtocol.ACTION_MUZEI_ART_SOURCE)
if (packageName != null) {
queryIntent.`package` = packageName
}
@@ -22,7 +22,6 @@ import android.annotation.SuppressLint
import android.app.PendingIntent
import android.content.Intent
import android.util.Log
import com.google.android.apps.muzei.api.MuzeiArtSource
import com.google.android.apps.muzei.api.UserCommand
import com.google.android.apps.muzei.api.provider.Artwork
import com.google.android.apps.muzei.api.provider.MuzeiArtProvider
@@ -49,7 +48,7 @@ class SourceArtProvider : MuzeiArtProvider() {
override fun onLoadRequested(initial: Boolean) {
if (initial) {
// If there's no artwork at all, immediately queue up the next artwork
sendAction(MuzeiArtSource.BUILTIN_COMMAND_ID_NEXT_ARTWORK)
sendAction(LegacySourceServiceProtocol.LEGACY_COMMAND_ID_NEXT_ARTWORK)
}
// else, Sources will load on their own schedule
}
@@ -68,7 +67,7 @@ class SourceArtProvider : MuzeiArtProvider() {
LegacyDatabase.getInstance(context).sourceDao().currentSourceBlocking?.run {
mutableListOf<UserCommand>().apply {
if (supportsNextArtwork) {
add(UserCommand(MuzeiArtSource.BUILTIN_COMMAND_ID_NEXT_ARTWORK,
add(UserCommand(LegacySourceServiceProtocol.LEGACY_COMMAND_ID_NEXT_ARTWORK,
context.getString(R.string.legacy_action_next_artwork)))
}
addAll(commands)
@@ -51,7 +51,7 @@ import androidx.core.text.buildSpannedString
import androidx.core.view.isVisible
import androidx.lifecycle.LiveData
import androidx.lifecycle.observe
import com.google.android.apps.muzei.api.MuzeiArtSource
import com.google.android.apps.muzei.api.provider.MuzeiArtProvider
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.google.firebase.analytics.FirebaseAnalytics
import kotlinx.coroutines.GlobalScope
@@ -225,7 +225,7 @@ class SourceSettingsActivity : AppCompatActivity() {
try {
val settingsIntent = Intent()
.setComponent(source.settingsActivity)
.putExtra(MuzeiArtSource.EXTRA_FROM_MUZEI_SETTINGS, true)
.putExtra(MuzeiArtProvider.EXTRA_FROM_MUZEI, true)
startActivity(settingsIntent)
} catch (e: ActivityNotFoundException) {
Log.e(TAG, "Can't launch source settings.", e)
@@ -238,7 +238,7 @@ class SourceSettingsActivity : AppCompatActivity() {
try {
val setupIntent = Intent()
.setComponent(source.setupActivity)
.putExtra(MuzeiArtSource.EXTRA_FROM_MUZEI_SETTINGS, true)
.putExtra(MuzeiArtProvider.EXTRA_FROM_MUZEI, true)
startActivityForResult(setupIntent, REQUEST_EXTENSION_SETUP)
} catch (e: ActivityNotFoundException) {
Log.e(TAG, "Can't launch source setup.", e)
@@ -28,7 +28,7 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.DialogFragment
import androidx.fragment.app.Fragment
import androidx.lifecycle.observe
import com.google.android.apps.muzei.api.MuzeiArtSource
import com.google.android.apps.muzei.api.provider.MuzeiArtProvider
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import net.nurik.roman.muzei.legacy.R

@@ -58,8 +58,8 @@ class SourceSetupActivity : AppCompatActivity() {
SourceSettingsActivity::class.java)

if (getIntent().getBooleanExtra(
MuzeiArtSource.EXTRA_FROM_MUZEI_SETTINGS, false)) {
intent.putExtra(MuzeiArtSource.EXTRA_FROM_MUZEI_SETTINGS, true)
MuzeiArtProvider.EXTRA_FROM_MUZEI, false)) {
intent.putExtra(MuzeiArtProvider.EXTRA_FROM_MUZEI, true)
}
startActivityForResult(intent, REQUEST_CHOOSE_SOURCE)
}
@@ -23,14 +23,14 @@ import android.content.Intent
import android.util.Log
import androidx.core.net.toUri
import androidx.room.withTransaction
import com.google.android.apps.muzei.api.MuzeiArtSource
import com.google.android.apps.muzei.api.internal.ProtocolConstants.ACTION_PUBLISH_STATE
import com.google.android.apps.muzei.api.internal.ProtocolConstants.EXTRA_STATE
import com.google.android.apps.muzei.api.internal.ProtocolConstants.EXTRA_TOKEN
import com.google.android.apps.muzei.api.internal.SourceState
import com.google.android.apps.muzei.api.provider.Artwork
import com.google.android.apps.muzei.api.provider.ProviderContract
import com.google.android.apps.muzei.legacy.LegacyDatabase
import com.google.android.apps.muzei.legacy.LegacySourceServiceProtocol
import com.google.android.apps.muzei.legacy.SourceDao
import kotlinx.coroutines.runBlocking
import net.nurik.roman.muzei.legacy.BuildConfig
@@ -79,7 +79,7 @@ class SourceSubscriberService : IntentService("SourceSubscriberService") {
for (i in 0 until numSourceActions) {
val command = state.getUserCommandAt(i)
when (state.getUserCommandAt(i)?.id) {
MuzeiArtSource.BUILTIN_COMMAND_ID_NEXT_ARTWORK -> source.supportsNextArtwork = true
LegacySourceServiceProtocol.LEGACY_COMMAND_ID_NEXT_ARTWORK -> source.supportsNextArtwork = true
else -> source.commands.add(command)
}
}
@@ -40,7 +40,6 @@ import androidx.core.content.edit
import androidx.core.net.toUri
import androidx.lifecycle.MutableLiveData
import androidx.navigation.NavDeepLinkBuilder
import com.google.android.apps.muzei.api.MuzeiArtSource
import com.google.android.apps.muzei.settings.Prefs
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
@@ -111,7 +110,7 @@ class LegacySourcePackageListener(
}

private fun queryLegacySources() {
val queryIntent = Intent(MuzeiArtSource.ACTION_MUZEI_ART_SOURCE)
val queryIntent = Intent(LegacySourceServiceProtocol.ACTION_MUZEI_ART_SOURCE)
val pm = applicationContext.packageManager
val resolveInfos = pm.queryIntentServices(queryIntent,
PackageManager.GET_META_DATA)

0 comments on commit 0f75274

Please sign in to comment.
You can’t perform that action at this time.