mirror of
https://github.com/KRTirtho/spotube.git
synced 2026-11-06 11:14:00 +00:00
58 lines
2.1 KiB
Kotlin
58 lines
2.1 KiB
Kotlin
/*
|
|
* Copyright (C) 2026 Kingkor Roy Tirtho and Spotube Contributors
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU Affero General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
package dev.krtirtho.spotube
|
|
|
|
import android.content.Intent
|
|
import android.os.Build
|
|
import android.os.Bundle
|
|
import androidx.activity.ComponentActivity
|
|
import androidx.activity.compose.setContent
|
|
import androidx.activity.enableEdgeToEdge
|
|
import dev.krtirtho.spotube.core.deeplink.ExternalUriHandler
|
|
import dev.krtirtho.spotube.core.newpipe.NewPipeDownloader
|
|
import dev.krtirtho.spotube.core.paths.Paths
|
|
import dev.krtirtho.spotube.media.PlaybackService
|
|
import io.github.vinceglb.filekit.FileKit
|
|
import io.github.vinceglb.filekit.dialogs.init
|
|
|
|
class MainActivity : ComponentActivity() {
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
enableEdgeToEdge()
|
|
super.onCreate(savedInstanceState)
|
|
FileKit.init(this)
|
|
NewPipeDownloader.init(Paths())
|
|
|
|
// Start PlaybackService from Activity context (allowed on Android 12+)
|
|
val serviceIntent = Intent(this, PlaybackService::class.java)
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
startForegroundService(serviceIntent)
|
|
} else {
|
|
startService(serviceIntent)
|
|
}
|
|
|
|
intent?.dataString?.let(ExternalUriHandler::onNewUri)
|
|
setContent {
|
|
App()
|
|
}
|
|
}
|
|
|
|
override fun onNewIntent(intent: Intent) {
|
|
super.onNewIntent(intent)
|
|
intent.dataString?.let(ExternalUriHandler::onNewUri)
|
|
}
|
|
} |