mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-09-30 05:12:00 +02:00
feat(concerts): show artwork-themed event details in app
This commit is contained in:
@@ -78,6 +78,7 @@ class MainActivity: FlutterFragmentActivity() {
|
||||
private val scope = CoroutineScope(SupervisorJob() + Dispatchers.Main)
|
||||
private var backendChannel: MethodChannel? = null
|
||||
private var audioOutputChannel: MethodChannel? = null
|
||||
private var concertCalendarChannel: MethodChannel? = null
|
||||
internal val coreBackend: CoreBackend by lazy { createCoreBackend(applicationContext) }
|
||||
private val nativeBackendMethods = setOf(
|
||||
"getBackendImplementations",
|
||||
@@ -934,6 +935,8 @@ class MainActivity: FlutterFragmentActivity() {
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
concertCalendarChannel?.setMethodCallHandler(null)
|
||||
concertCalendarChannel = null
|
||||
audioOutputChannel?.setMethodCallHandler(null)
|
||||
audioOutputChannel = null
|
||||
libraryStorageReceiver?.let {
|
||||
@@ -974,6 +977,34 @@ class MainActivity: FlutterFragmentActivity() {
|
||||
onBackPressedDispatcher.addCallback(this, flutterBackCallback!!)
|
||||
|
||||
val messenger = flutterEngine.dartExecutor.binaryMessenger
|
||||
concertCalendarChannel = MethodChannel(messenger, "com.zarz.spotiflac/concert_calendar").also { channel ->
|
||||
channel.setMethodCallHandler { call, result ->
|
||||
if (call.method != "add") {
|
||||
result.notImplemented()
|
||||
} else {
|
||||
val start = call.argument<Number>("start")?.toLong()
|
||||
if (start == null) {
|
||||
result.success(false)
|
||||
} else {
|
||||
val suppliedEnd = call.argument<Number>("end")?.toLong()
|
||||
val end = suppliedEnd?.takeIf { it > start } ?: (start + 3600000)
|
||||
try {
|
||||
startActivity(Intent(Intent.ACTION_INSERT).apply {
|
||||
data = android.provider.CalendarContract.Events.CONTENT_URI
|
||||
putExtra(android.provider.CalendarContract.Events.TITLE, call.argument<String>("title"))
|
||||
putExtra(android.provider.CalendarContract.Events.EVENT_LOCATION, call.argument<String>("location"))
|
||||
putExtra(android.provider.CalendarContract.Events.DESCRIPTION, call.argument<String>("url"))
|
||||
putExtra(android.provider.CalendarContract.EXTRA_EVENT_BEGIN_TIME, start)
|
||||
putExtra(android.provider.CalendarContract.EXTRA_EVENT_END_TIME, end)
|
||||
})
|
||||
result.success(true)
|
||||
} catch (_: Exception) {
|
||||
result.success(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
audioOutputChannel = MethodChannel(messenger, "com.zarz.spotiflac/audio_output").also { channel ->
|
||||
channel.setMethodCallHandler { call, result ->
|
||||
if (call.method != "show") {
|
||||
|
||||
Reference in New Issue
Block a user