Skip to content

Commit 3aa627e

Browse files
Improved component organisation
1 parent afffb9a commit 3aa627e

15 files changed

+40
-38
lines changed

app/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ dependencies {
203203
// name and the commit hash with the commit hash of the (pushed) commit you want to test
204204
// This works thanks to JitPack: https://jitpack.io/
205205
implementation 'com.github.TeamNewPipe:nanojson:1d9e1aea9049fc9f85e68b43ba39fe7be1c1f751'
206-
implementation 'com.github.TeamNewPipe:NewPipeExtractor:v0.24.1'
206+
implementation 'com.github.TeamNewPipe:NewPipeExtractor:v0.24.2'
207207
implementation 'com.github.TeamNewPipe:NoNonsense-FilePicker:5.0.0'
208208

209209
/** Checkstyle **/

app/src/main/java/org/schabi/newpipe/fragments/list/playlist/PlaylistFragment.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import androidx.compose.ui.platform.ComposeView
77
import androidx.compose.ui.platform.ViewCompositionStrategy
88
import androidx.core.os.bundleOf
99
import androidx.fragment.app.Fragment
10-
import org.schabi.newpipe.compose.playlist.Playlist
11-
import org.schabi.newpipe.compose.theme.AppTheme
10+
import org.schabi.newpipe.ui.screens.PlaylistScreen
11+
import org.schabi.newpipe.ui.theme.AppTheme
1212
import org.schabi.newpipe.util.KEY_SERVICE_ID
1313
import org.schabi.newpipe.util.KEY_URL
1414

@@ -21,7 +21,7 @@ class PlaylistFragment : Fragment() {
2121
setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed)
2222
setContent {
2323
AppTheme {
24-
Playlist()
24+
PlaylistScreen()
2525
}
2626
}
2727
}

app/src/main/java/org/schabi/newpipe/paging/PlaylistItemsSource.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import androidx.paging.PagingSource
44
import androidx.paging.PagingState
55
import kotlinx.coroutines.Dispatchers
66
import kotlinx.coroutines.withContext
7-
import org.schabi.newpipe.compose.playlist.PlaylistInfo
87
import org.schabi.newpipe.extractor.NewPipe
98
import org.schabi.newpipe.extractor.Page
109
import org.schabi.newpipe.extractor.stream.StreamInfoItem
10+
import org.schabi.newpipe.ui.components.playlist.PlaylistInfo
1111
import org.schabi.newpipe.extractor.playlist.PlaylistInfo as ExtractorPlaylistInfo
1212

1313
class PlaylistItemsSource(

app/src/main/java/org/schabi/newpipe/ui/components/common/Utils.kt

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
package org.schabi.newpipe.compose.util
1+
package org.schabi.newpipe.ui.components.common
22

33
import androidx.compose.material3.adaptive.currentWindowAdaptiveInfo
44
import androidx.compose.runtime.Composable
55
import androidx.compose.ui.platform.LocalContext
6+
import androidx.compose.ui.res.stringResource
67
import androidx.preference.PreferenceManager
78
import androidx.window.core.layout.WindowWidthSizeClass
89
import org.schabi.newpipe.R
910
import org.schabi.newpipe.info_list.ItemViewMode
1011

1112
@Composable
1213
fun determineItemViewMode(): ItemViewMode {
13-
val context = LocalContext.current
14-
val listMode = PreferenceManager.getDefaultSharedPreferences(context)
14+
val listMode = PreferenceManager.getDefaultSharedPreferences(LocalContext.current)
1515
.getString(
16-
context.getString(R.string.list_view_mode_key),
17-
context.getString(R.string.list_view_mode_value)
16+
stringResource(R.string.list_view_mode_key),
17+
stringResource(R.string.list_view_mode_value)
1818
)
1919

2020
return when (listMode) {
21-
context.getString(R.string.list_view_mode_list_key) -> ItemViewMode.LIST
22-
context.getString(R.string.list_view_mode_grid_key) -> ItemViewMode.GRID
23-
context.getString(R.string.list_view_mode_card_key) -> ItemViewMode.CARD
21+
stringResource(R.string.list_view_mode_list_key) -> ItemViewMode.LIST
22+
stringResource(R.string.list_view_mode_grid_key) -> ItemViewMode.GRID
23+
stringResource(R.string.list_view_mode_card_key) -> ItemViewMode.CARD
2424
else -> {
2525
// Auto mode - evaluate whether to use Grid based on screen real estate.
2626
val windowSizeClass = currentWindowAdaptiveInfo().windowSizeClass

app/src/main/java/org/schabi/newpipe/compose/playlist/PlaylistHeader.kt app/src/main/java/org/schabi/newpipe/ui/components/playlist/PlaylistHeader.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.schabi.newpipe.compose.playlist
1+
package org.schabi.newpipe.ui.components.playlist
22

33
import android.content.res.Configuration
44
import androidx.compose.animation.animateContentSize
@@ -35,12 +35,12 @@ import androidx.compose.ui.unit.dp
3535
import androidx.fragment.app.FragmentActivity
3636
import coil.compose.AsyncImage
3737
import org.schabi.newpipe.R
38-
import org.schabi.newpipe.compose.common.DescriptionText
39-
import org.schabi.newpipe.compose.theme.AppTheme
4038
import org.schabi.newpipe.error.ErrorUtil
4139
import org.schabi.newpipe.extractor.ServiceList
4240
import org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper
4341
import org.schabi.newpipe.extractor.stream.Description
42+
import org.schabi.newpipe.ui.components.common.DescriptionText
43+
import org.schabi.newpipe.ui.theme.AppTheme
4444
import org.schabi.newpipe.util.Localization
4545
import org.schabi.newpipe.util.NavigationHelper
4646
import org.schabi.newpipe.util.image.ImageStrategy

app/src/main/java/org/schabi/newpipe/compose/playlist/PlaylistInfo.kt app/src/main/java/org/schabi/newpipe/ui/components/playlist/PlaylistInfo.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.schabi.newpipe.compose.playlist
1+
package org.schabi.newpipe.ui.components.playlist
22

33
import androidx.compose.runtime.Immutable
44
import org.schabi.newpipe.extractor.Image

app/src/main/java/org/schabi/newpipe/compose/stream/StreamCardItem.kt app/src/main/java/org/schabi/newpipe/ui/components/stream/StreamCardItem.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.schabi.newpipe.compose.stream
1+
package org.schabi.newpipe.ui.components.stream
22

33
import android.content.res.Configuration
44
import androidx.compose.foundation.ExperimentalFoundationApi
@@ -19,8 +19,8 @@ import androidx.compose.ui.text.style.TextOverflow
1919
import androidx.compose.ui.tooling.preview.Preview
2020
import androidx.compose.ui.tooling.preview.PreviewParameter
2121
import androidx.compose.ui.unit.dp
22-
import org.schabi.newpipe.compose.theme.AppTheme
2322
import org.schabi.newpipe.extractor.stream.StreamInfoItem
23+
import org.schabi.newpipe.ui.theme.AppTheme
2424

2525
@OptIn(ExperimentalFoundationApi::class)
2626
@Composable

app/src/main/java/org/schabi/newpipe/compose/stream/StreamGridItem.kt app/src/main/java/org/schabi/newpipe/ui/components/stream/StreamGridItem.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.schabi.newpipe.compose.stream
1+
package org.schabi.newpipe.ui.components.stream
22

33
import android.content.res.Configuration
44
import androidx.compose.foundation.ExperimentalFoundationApi
@@ -16,8 +16,8 @@ import androidx.compose.ui.text.style.TextOverflow
1616
import androidx.compose.ui.tooling.preview.Preview
1717
import androidx.compose.ui.tooling.preview.PreviewParameter
1818
import androidx.compose.ui.unit.dp
19-
import org.schabi.newpipe.compose.theme.AppTheme
2019
import org.schabi.newpipe.extractor.stream.StreamInfoItem
20+
import org.schabi.newpipe.ui.theme.AppTheme
2121

2222
@OptIn(ExperimentalFoundationApi::class)
2323
@Composable

app/src/main/java/org/schabi/newpipe/compose/stream/StreamList.kt app/src/main/java/org/schabi/newpipe/ui/components/stream/StreamList.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.schabi.newpipe.compose.stream
1+
package org.schabi.newpipe.ui.components.stream
22

33
import androidx.compose.foundation.lazy.LazyColumn
44
import androidx.compose.foundation.lazy.LazyListScope
@@ -18,9 +18,9 @@ import androidx.fragment.app.FragmentActivity
1818
import androidx.paging.compose.LazyPagingItems
1919
import my.nanihadesuka.compose.LazyColumnScrollbar
2020
import my.nanihadesuka.compose.LazyVerticalGridScrollbar
21-
import org.schabi.newpipe.compose.util.determineItemViewMode
2221
import org.schabi.newpipe.extractor.stream.StreamInfoItem
2322
import org.schabi.newpipe.info_list.ItemViewMode
23+
import org.schabi.newpipe.ui.components.common.determineItemViewMode
2424
import org.schabi.newpipe.util.NavigationHelper
2525

2626
@Composable

app/src/main/java/org/schabi/newpipe/compose/stream/StreamListItem.kt app/src/main/java/org/schabi/newpipe/ui/components/stream/StreamListItem.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.schabi.newpipe.compose.stream
1+
package org.schabi.newpipe.ui.components.stream
22

33
import android.content.res.Configuration
44
import androidx.compose.foundation.ExperimentalFoundationApi
@@ -20,8 +20,8 @@ import androidx.compose.ui.text.style.TextOverflow
2020
import androidx.compose.ui.tooling.preview.Preview
2121
import androidx.compose.ui.tooling.preview.PreviewParameter
2222
import androidx.compose.ui.unit.dp
23-
import org.schabi.newpipe.compose.theme.AppTheme
2423
import org.schabi.newpipe.extractor.stream.StreamInfoItem
24+
import org.schabi.newpipe.ui.theme.AppTheme
2525

2626
@OptIn(ExperimentalFoundationApi::class)
2727
@Composable

app/src/main/java/org/schabi/newpipe/compose/stream/StreamMenu.kt app/src/main/java/org/schabi/newpipe/ui/components/stream/StreamMenu.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.schabi.newpipe.compose.stream
1+
package org.schabi.newpipe.ui.components.stream
22

33
import androidx.compose.material3.DropdownMenu
44
import androidx.compose.material3.DropdownMenuItem

app/src/main/java/org/schabi/newpipe/compose/stream/StreamThumbnail.kt app/src/main/java/org/schabi/newpipe/ui/components/stream/StreamThumbnail.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.schabi.newpipe.compose.stream
1+
package org.schabi.newpipe.ui.components.stream
22

33
import androidx.compose.foundation.background
44
import androidx.compose.foundation.layout.Box

app/src/main/java/org/schabi/newpipe/compose/stream/StreamUtils.kt app/src/main/java/org/schabi/newpipe/ui/components/stream/StreamUtils.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.schabi.newpipe.compose.stream
1+
package org.schabi.newpipe.ui.components.stream
22

33
import androidx.compose.runtime.Composable
44
import androidx.compose.runtime.saveable.rememberSaveable

app/src/main/java/org/schabi/newpipe/compose/playlist/Playlist.kt app/src/main/java/org/schabi/newpipe/ui/screens/PlaylistScreen.kt

+11-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.schabi.newpipe.compose.playlist
1+
package org.schabi.newpipe.ui.screens
22

33
import android.content.res.Configuration
44
import androidx.compose.foundation.lazy.grid.GridItemSpan
@@ -15,25 +15,27 @@ import androidx.paging.PagingData
1515
import androidx.paging.compose.collectAsLazyPagingItems
1616
import kotlinx.coroutines.flow.Flow
1717
import kotlinx.coroutines.flow.flowOf
18-
import org.schabi.newpipe.compose.common.LoadingIndicator
19-
import org.schabi.newpipe.compose.stream.StreamInfoItem
20-
import org.schabi.newpipe.compose.stream.StreamList
21-
import org.schabi.newpipe.compose.theme.AppTheme
2218
import org.schabi.newpipe.extractor.stream.Description
2319
import org.schabi.newpipe.extractor.stream.StreamInfoItem
2420
import org.schabi.newpipe.extractor.stream.StreamType
21+
import org.schabi.newpipe.ui.components.common.LoadingIndicator
22+
import org.schabi.newpipe.ui.components.playlist.PlaylistHeader
23+
import org.schabi.newpipe.ui.components.playlist.PlaylistInfo
24+
import org.schabi.newpipe.ui.components.stream.StreamInfoItem
25+
import org.schabi.newpipe.ui.components.stream.StreamList
26+
import org.schabi.newpipe.ui.theme.AppTheme
2527
import org.schabi.newpipe.viewmodels.PlaylistViewModel
2628

2729
@Composable
28-
fun Playlist(playlistViewModel: PlaylistViewModel = viewModel()) {
30+
fun PlaylistScreen(playlistViewModel: PlaylistViewModel = viewModel()) {
2931
Surface(color = MaterialTheme.colorScheme.background) {
3032
val playlistInfo by playlistViewModel.playlistInfo.collectAsState()
31-
Playlist(playlistInfo, playlistViewModel.streamItems)
33+
PlaylistScreen(playlistInfo, playlistViewModel.streamItems)
3234
}
3335
}
3436

3537
@Composable
36-
private fun Playlist(
38+
private fun PlaylistScreen(
3739
playlistInfo: PlaylistInfo?,
3840
streamFlow: Flow<PagingData<StreamInfoItem>>
3941
) {
@@ -75,7 +77,7 @@ private fun PlaylistPreview() {
7577

7678
AppTheme {
7779
Surface(color = MaterialTheme.colorScheme.background) {
78-
Playlist(playlistInfo, streamFlow)
80+
PlaylistScreen(playlistInfo, streamFlow)
7981
}
8082
}
8183
}

app/src/main/java/org/schabi/newpipe/viewmodels/PlaylistViewModel.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ import kotlinx.coroutines.flow.filterNotNull
1414
import kotlinx.coroutines.flow.flatMapLatest
1515
import kotlinx.coroutines.flow.flowOn
1616
import kotlinx.coroutines.flow.stateIn
17-
import org.schabi.newpipe.compose.playlist.PlaylistInfo
1817
import org.schabi.newpipe.extractor.NewPipe
1918
import org.schabi.newpipe.extractor.stream.Description
2019
import org.schabi.newpipe.paging.PlaylistItemsSource
20+
import org.schabi.newpipe.ui.components.playlist.PlaylistInfo
2121
import org.schabi.newpipe.util.KEY_SERVICE_ID
2222
import org.schabi.newpipe.util.KEY_URL
2323
import org.schabi.newpipe.util.NO_SERVICE_ID

0 commit comments

Comments
 (0)