Skip to content

Commit b412c9c

Browse files
committed
refactor app to utilize new compose activity
1 parent c55c636 commit b412c9c

File tree

12 files changed

+122
-381
lines changed

12 files changed

+122
-381
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,6 @@
9595
android:exported="false"
9696
android:label="@string/settings" />
9797

98-
<activity
99-
android:name=".settings.SettingsV2Activity"
100-
android:exported="true"
101-
android:label="@string/settings" />
10298

10399
<activity
104100
android:name=".about.AboutActivity"
@@ -133,10 +129,6 @@
133129
android:label="@string/general_error"
134130
android:theme="@android:style/Theme.NoDisplay" />
135131

136-
<activity
137-
android:name=".error.ErrorActivity"
138-
android:exported="false" />
139-
140132
<!-- giga get related -->
141133
<activity
142134
android:name=".download.DownloadActivity"

app/src/main/java/org/schabi/newpipe/BaseActivity.kt

Lines changed: 0 additions & 41 deletions
This file was deleted.

app/src/main/java/org/schabi/newpipe/ComposeActivity.kt

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import androidx.activity.ComponentActivity
1414
import androidx.activity.SystemBarStyle
1515
import androidx.activity.compose.setContent
1616
import androidx.activity.enableEdgeToEdge
17-
import androidx.core.content.IntentCompat
1817
import androidx.navigation3.runtime.NavKey
1918
import dagger.hilt.android.AndroidEntryPoint
2019
import org.schabi.newpipe.error.ErrorInfo
@@ -28,11 +27,11 @@ import org.schabi.newpipe.ui.theme.AppTheme
2827
* via Intent with extras specifying which screen to display.
2928
*/
3029
@AndroidEntryPoint
31-
class ComposeActivity: ComponentActivity() {
30+
class ComposeActivity : ComponentActivity() {
3231

3332
override fun onCreate(savedInstanceState: Bundle?) {
3433
enableEdgeToEdge(
35-
navigationBarStyle = SystemBarStyle.Companion.auto(Color.TRANSPARENT, Color.TRANSPARENT)
34+
navigationBarStyle = SystemBarStyle.auto(Color.TRANSPARENT, Color.TRANSPARENT)
3635
)
3736
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
3837
window.isNavigationBarContrastEnforced = false
@@ -50,13 +49,10 @@ class ComposeActivity: ComponentActivity() {
5049

5150
private fun resolveStartDestination(intent: Intent): NavKey {
5251
return when (intent.getStringExtra(EXTRA_SCREEN)) {
53-
SCREEN_ERROR -> {
54-
val errorInfo = IntentCompat.getParcelableExtra(
55-
intent, EXTRA_ERROR_INFO, ErrorInfo::class.java
56-
) ?: throw IllegalArgumentException("ErrorInfo is required for error screen")
57-
Screen.Error(errorInfo)
58-
}
52+
SCREEN_ERROR -> Screen.Error
53+
5954
SCREEN_SETTINGS -> Screen.Settings.Home
55+
6056
else -> throw IllegalArgumentException(
6157
"Unknown screen: ${intent.getStringExtra(EXTRA_SCREEN)}"
6258
)
@@ -70,15 +66,18 @@ class ComposeActivity: ComponentActivity() {
7066
const val SCREEN_ERROR = "error"
7167
const val SCREEN_SETTINGS = "settings"
7268

73-
/**
74-
* Creates an intent to launch the error report screen.
75-
*/
7669
fun errorIntent(context: Context, errorInfo: ErrorInfo): Intent {
7770
return Intent(context, ComposeActivity::class.java).apply {
7871
putExtra(EXTRA_SCREEN, SCREEN_ERROR)
7972
putExtra(EXTRA_ERROR_INFO, errorInfo)
8073
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
8174
}
8275
}
76+
77+
fun settingsIntent(context: Context): Intent {
78+
return Intent(context, ComposeActivity::class.java).apply {
79+
putExtra(EXTRA_SCREEN, SCREEN_SETTINGS)
80+
}
81+
}
8382
}
84-
}
83+
}

app/src/main/java/org/schabi/newpipe/error/ErrorActivity.kt

Lines changed: 0 additions & 190 deletions
This file was deleted.

app/src/main/java/org/schabi/newpipe/error/ErrorInfo.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import com.google.android.exoplayer2.upstream.HttpDataSource
99
import com.google.android.exoplayer2.upstream.Loader
1010
import java.net.UnknownHostException
1111
import kotlinx.parcelize.Parcelize
12-
import kotlinx.serialization.Serializable
1312
import org.schabi.newpipe.R
1413
import org.schabi.newpipe.extractor.Info
1514
import org.schabi.newpipe.extractor.ServiceList
@@ -36,7 +35,6 @@ import org.schabi.newpipe.util.text.getText
3635
* An error has occurred in the app. This class contains plain old parcelable data that can be used
3736
* to report the error and to show it to the user along with correct action buttons.
3837
*/
39-
@Serializable
4038
@Parcelize
4139
class ErrorInfo private constructor(
4240
val stackTraces: Array<String>,
@@ -143,7 +141,6 @@ class ErrorInfo private constructor(
143141
}
144142

145143
companion object {
146-
@Serializable
147144
@Parcelize
148145
class ErrorMessage(
149146
@StringRes

app/src/main/java/org/schabi/newpipe/error/ErrorReportHelper.kt

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ import android.os.Build
1111
import android.util.Log
1212
import androidx.core.net.toUri
1313
import com.grack.nanojson.JsonWriter
14+
import java.time.ZonedDateTime
15+
import java.time.format.DateTimeFormatter
1416
import org.schabi.newpipe.BuildConfig
1517
import org.schabi.newpipe.R
1618
import org.schabi.newpipe.util.Localization
1719
import org.schabi.newpipe.util.external_communication.ShareUtils
18-
import java.time.ZonedDateTime
19-
import java.time.format.DateTimeFormatter
2020

2121
/**
2222
* Pure utility functions for building and sending error reports.
@@ -131,22 +131,17 @@ object ErrorReportHelper {
131131
ShareUtils.openUrlInApp(context, context.getString(R.string.privacy_policy_url))
132132
}
133133

134-
private fun getContentLanguage(context: Context): String =
135-
Localization.getPreferredLocalization(context).localizationCode
134+
private fun getContentLanguage(context: Context): String = Localization.getPreferredLocalization(context).localizationCode
136135

137-
private fun getContentCountry(context: Context): String =
138-
Localization.getPreferredContentCountry(context).countryCode
136+
private fun getContentCountry(context: Context): String = Localization.getPreferredContentCountry(context).countryCode
139137

140-
private fun getAppLanguage(): String =
141-
Localization.getAppLocale().toString()
138+
private fun getAppLanguage(): String = Localization.getAppLocale().toString()
142139

143140
private fun getOsString(): String {
144141
val name = System.getProperty("os.name")!!
145142
val osBase = Build.VERSION.BASE_OS.ifEmpty { "Android" }
146143
return "$name $osBase ${Build.VERSION.RELEASE} - ${Build.VERSION.SDK_INT}"
147144
}
148145

149-
private fun getCurrentTimestamp(): String =
150-
ZonedDateTime.now().format(DateTimeFormatter.ISO_OFFSET_DATE_TIME)
146+
private fun getCurrentTimestamp(): String = ZonedDateTime.now().format(DateTimeFormatter.ISO_OFFSET_DATE_TIME)
151147
}
152-

0 commit comments

Comments
 (0)