Skip to content
12 changes: 4 additions & 8 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@
</intent-filter>
</service>

<activity
android:name=".ComposeActivity"
android:exported="false" />

<activity
android:name=".player.PlayQueueActivity"
android:exported="false"
Expand All @@ -91,10 +95,6 @@
android:exported="false"
android:label="@string/settings" />

<activity
android:name=".settings.SettingsV2Activity"
android:exported="true"
android:label="@string/settings" />

<activity
android:name=".about.AboutActivity"
Expand Down Expand Up @@ -129,10 +129,6 @@
android:label="@string/general_error"
android:theme="@android:style/Theme.NoDisplay" />

<activity
android:name=".error.ErrorActivity"
android:exported="false" />

<!-- giga get related -->
<activity
android:name=".download.DownloadActivity"
Expand Down
83 changes: 83 additions & 0 deletions app/src/main/java/org/schabi/newpipe/ComposeActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
* SPDX-FileCopyrightText: 2025-2026 NewPipe e.V. <https://newpipe-ev.de>
* SPDX-License-Identifier: GPL-3.0-or-later
*/

package org.schabi.newpipe

import android.content.Context
import android.content.Intent
import android.graphics.Color
import android.os.Build
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.SystemBarStyle
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.navigation3.runtime.NavKey
import dagger.hilt.android.AndroidEntryPoint
import org.schabi.newpipe.error.ErrorInfo
import org.schabi.newpipe.navigation.NavDisplay
import org.schabi.newpipe.navigation.Screen
import org.schabi.newpipe.ui.theme.AppTheme

/**
* Single host activity for all Compose-based screens.
* Other parts of the app (including legacy View-based code) launch this activity
* via Intent with extras specifying which screen to display.
*/
@AndroidEntryPoint
class ComposeActivity : ComponentActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
enableEdgeToEdge(
navigationBarStyle = SystemBarStyle.auto(Color.TRANSPARENT, Color.TRANSPARENT)
)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
window.isNavigationBarContrastEnforced = false
}
super.onCreate(savedInstanceState)

val startDestination: NavKey = resolveStartDestination(intent)

setContent {
AppTheme {
NavDisplay(startDestination)
}
}
}

private fun resolveStartDestination(intent: Intent): NavKey {
return when (intent.getStringExtra(EXTRA_SCREEN)) {
SCREEN_ERROR -> Screen.Error

SCREEN_SETTINGS -> Screen.Settings.Home

else -> throw IllegalArgumentException(
"Unknown screen: ${intent.getStringExtra(EXTRA_SCREEN)}"
)
}
}

companion object {
const val EXTRA_SCREEN = "extra_screen"
const val EXTRA_ERROR_INFO = "extra_error_info"

const val SCREEN_ERROR = "error"
const val SCREEN_SETTINGS = "settings"

fun errorIntent(context: Context, errorInfo: ErrorInfo): Intent {
return Intent(context, ComposeActivity::class.java).apply {
putExtra(EXTRA_SCREEN, SCREEN_ERROR)
putExtra(EXTRA_ERROR_INFO, errorInfo)
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
}
}

fun settingsIntent(context: Context): Intent {
return Intent(context, ComposeActivity::class.java).apply {
putExtra(EXTRA_SCREEN, SCREEN_SETTINGS)
}
}
}
}
282 changes: 0 additions & 282 deletions app/src/main/java/org/schabi/newpipe/error/ErrorActivity.kt

This file was deleted.

Loading
Loading