Skip to content

Commit

Permalink
Rename all stream to channel(exclude database columns).
Browse files Browse the repository at this point in the history
  • Loading branch information
oxyroid committed Jun 8, 2024
1 parent 8235086 commit 80b7414
Show file tree
Hide file tree
Showing 119 changed files with 1,085 additions and 1,118 deletions.
2 changes: 1 addition & 1 deletion androidApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ dependencies {
implementation(project(":features:favorite"))
implementation(project(":features:setting"))
implementation(project(":features:playlist"))
implementation(project(":features:stream"))
implementation(project(":features:channel"))
implementation(project(":features:playlist-configuration"))
implementation(project(":features:crash"))

Expand Down
2 changes: 1 addition & 1 deletion androidApp/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
android:resource="@xml/shortcuts" />
</activity>
<activity
android:name="com.m3u.features.stream.PlayerActivity"
android:name="com.m3u.features.channel.PlayerActivity"
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation|locale|layoutDirection"
android:exported="true"
android:launchMode="singleTop"
Expand Down
6 changes: 3 additions & 3 deletions androidApp/src/main/java/com/m3u/androidApp/ui/AppNavHost.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import com.m3u.features.playlist.configuration.playlistConfigurationScreen
import com.m3u.features.playlist.navigation.navigateToPlaylist
import com.m3u.features.playlist.navigation.playlistScreen
import com.m3u.features.playlist.navigation.playlistTvScreen
import com.m3u.features.stream.PlayerActivity
import com.m3u.features.channel.PlayerActivity
import com.m3u.material.ktx.isTelevision
import com.m3u.ui.Destination
import com.m3u.ui.Events
Expand Down Expand Up @@ -46,7 +46,7 @@ fun AppNavHost(
modifier = modifier
) {
playlistScreen(
navigateToStream = {
navigateToChannel = {
if (preferences.zappingMode && PlayerActivity.isInPipMode) return@playlistScreen
val options = ActivityOptions.makeCustomAnimation(
context,
Expand All @@ -67,7 +67,7 @@ fun AppNavHost(
navigateToPlaylist = { playlist ->
navController.navigateToPlaylist(playlist.url, tv)
},
navigateToStream = {
navigateToChannel = {
if (preferences.zappingMode && PlayerActivity.isInPipMode) return@rootGraph
val options = ActivityOptions.makeCustomAnimation(
context,
Expand Down
10 changes: 5 additions & 5 deletions androidApp/src/main/java/com/m3u/androidApp/ui/RootGraph.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ fun NavController.restoreBackStack() {
fun NavGraphBuilder.rootGraph(
contentPadding: PaddingValues,
navigateToPlaylist: (Playlist) -> Unit,
navigateToStream: () -> Unit,
navigateToChannel: () -> Unit,
navigateToSettingPlaylistManagement: () -> Unit,
navigateToPlaylistConfiguration: (Playlist) -> Unit,
) {
composable(ROOT_ROUTE) {
RootGraph(
contentPadding = contentPadding,
navigateToPlaylist = navigateToPlaylist,
navigateToStream = navigateToStream,
navigateToChannel = navigateToChannel,
navigateToSettingPlaylistManagement = navigateToSettingPlaylistManagement,
navigateToPlaylistConfiguration = navigateToPlaylistConfiguration
)
Expand All @@ -49,7 +49,7 @@ fun NavGraphBuilder.rootGraph(
private fun RootGraph(
contentPadding: PaddingValues,
navigateToPlaylist: (Playlist) -> Unit,
navigateToStream: () -> Unit,
navigateToChannel: () -> Unit,
navigateToSettingPlaylistManagement: () -> Unit,
navigateToPlaylistConfiguration: (Playlist) -> Unit,
modifier: Modifier = Modifier
Expand All @@ -70,7 +70,7 @@ private fun RootGraph(
Destination.Root.Foryou -> {
ForyouRoute(
navigateToPlaylist = navigateToPlaylist,
navigateToStream = navigateToStream,
navigateToChannel = navigateToChannel,
navigateToSettingPlaylistManagement = navigateToSettingPlaylistManagement,
navigateToPlaylistConfiguration = navigateToPlaylistConfiguration,
contentPadding = contentPadding,
Expand All @@ -80,7 +80,7 @@ private fun RootGraph(

Destination.Root.Favourite -> {
FavouriteRoute(
navigateToStream = navigateToStream,
navigateToChannel = navigateToChannel,
contentPadding = contentPadding,
modifier = Modifier.fillMaxSize()
)
Expand Down
2 changes: 0 additions & 2 deletions androidApp/src/main/java/com/m3u/androidApp/ui/Scaffold.kt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.util.fastForEach
import androidx.compose.ui.util.fastMap
import androidx.compose.ui.util.fastMaxOfOrNull
import com.m3u.androidApp.ui.internal.HeadlineBackground
import com.m3u.androidApp.ui.internal.SmartphoneScaffoldImpl
import com.m3u.androidApp.ui.internal.TabletScaffoldImpl
import com.m3u.androidApp.ui.internal.TelevisionScaffoldImpl
Expand Down Expand Up @@ -225,7 +224,6 @@ internal fun MainContent(
Background {
Box {
StarBackground()
HeadlineBackground()
content(padding)
}
}
Expand Down
12 changes: 6 additions & 6 deletions androidApp/src/main/res/xml/shortcuts.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
<!-- Learn more at https://developer.android.com/guide/topics/ui/shortcuts/creating-shortcuts -->
<shortcut
android:icon="@drawable/baseline_history_toggle_off_24"
android:shortcutDisabledMessage="@string/app_shortcut_stream_recently_disabled"
android:shortcutId="stream_recently"
android:shortcutLongLabel="@string/app_shortcut_stream_recently_long_label"
android:shortcutShortLabel="@string/app_shortcut_stream_recently_short_label">
android:shortcutDisabledMessage="@string/app_shortcut_channel_recently_disabled"
android:shortcutId="channel_recently"
android:shortcutLongLabel="@string/app_shortcut_channel_recently_long_label"
android:shortcutShortLabel="@string/app_shortcut_channel_recently_short_label">
<intent
android:action="android.intent.action.VIEW"
android:targetClass="com.m3u.features.stream.PlayerActivity"
android:targetClass="com.m3u.features.channel.PlayerActivity"
android:targetPackage="com.m3u.androidApp" >
<extra
android:name="shortcut:stream-recently"
android:name="shortcut:channel-recently"
android:value="true"/>
</intent>
</shortcut>
Expand Down
6 changes: 3 additions & 3 deletions core/src/main/java/com/m3u/core/Contracts.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.m3u.core

object Contracts {
const val PLAYER_ACTIVITY = "com.m3u.features.stream.PlayerActivity"
const val PLAYER_SHORTCUT_STREAM_ID = "shortcut:stream-id"
const val PLAYER_SHORTCUT_STREAM_RECENTLY = "shortcut:stream-recently"
const val PLAYER_ACTIVITY = "com.m3u.features.channel.PlayerActivity"
const val PLAYER_SHORTCUT_CHANNEL_ID = "shortcut:channel-id"
const val PLAYER_SHORTCUT_CHANNEL_RECENTLY = "shortcut:channel-recently"
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ object Profiles {
val VIEWMODEL_FORYOU = Profile("viewmodel-foryou")
val VIEWMODEL_PLAYLIST = Profile("viewmodel-playlist")
val VIEWMODEL_SETTING = Profile("viewmodel-setting")
val VIEWMODEL_STREAM = Profile("viewmodel-stream")
val VIEWMODEL_CHANNEL = Profile("viewmodel-channel")
val VIEWMODEL_PLAYLIST_CONFIGURATION = Profile("viewmodel-playlist-configuration", Message.LEVEL_INFO)

val REPOS_PLAYLIST = Profile("repos-playlist")
val REPOS_STREAM = Profile("repos-stream")
val REPOS_CHANNEL = Profile("repos-channel")
val REPOS_PROGRAMME = Profile("repos-programme")
val REPOS_TELEVISION = Profile("repos-television")
val REPOS_MEDIA = Profile("repos-media")
Expand Down
10 changes: 5 additions & 5 deletions data/src/main/java/com/m3u/data/database/DatabaseModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import com.m3u.data.database.dao.ColorSchemeDao
import com.m3u.data.database.dao.EpisodeDao
import com.m3u.data.database.dao.PlaylistDao
import com.m3u.data.database.dao.ProgrammeDao
import com.m3u.data.database.dao.StreamDao
import com.m3u.data.database.dao.ChannelDao
import com.m3u.data.database.example.ColorSchemeExample
import dagger.Module
import dagger.Provides
Expand Down Expand Up @@ -48,9 +48,9 @@ internal object DatabaseModule {

@Provides
@Singleton
fun provideStreamDao(
fun provideChannelDao(
database: M3UDatabase
): StreamDao = database.streamDao()
): ChannelDao = database.channelDao()

@Provides
@Singleton
Expand All @@ -72,7 +72,7 @@ internal object DatabaseModule {

@Provides
@Singleton
fun provideColorPackDao(
fun provideColorSchemeDao(
database: M3UDatabase
): ColorSchemeDao = database.colorPackDao()
): ColorSchemeDao = database.colorSchemeDao()
}
16 changes: 11 additions & 5 deletions data/src/main/java/com/m3u/data/database/M3UDatabase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,25 @@ import androidx.room.AutoMigration
import androidx.room.Database
import androidx.room.RoomDatabase
import androidx.room.TypeConverters
import com.m3u.data.database.dao.ChannelDao
import com.m3u.data.database.dao.ColorSchemeDao
import com.m3u.data.database.dao.EpisodeDao
import com.m3u.data.database.dao.PlaylistDao
import com.m3u.data.database.dao.ProgrammeDao
import com.m3u.data.database.dao.StreamDao
import com.m3u.data.database.model.Channel
import com.m3u.data.database.model.ColorScheme
import com.m3u.data.database.model.Episode
import com.m3u.data.database.model.Playlist
import com.m3u.data.database.model.Programme
import com.m3u.data.database.model.Stream

@Database(
entities = [Stream::class, Playlist::class, Episode::class, Programme::class, ColorScheme::class],
entities = [
Playlist::class,
Channel::class,
Programme::class,
Episode::class,
ColorScheme::class
],
version = 18,
exportSchema = true,
autoMigrations = [
Expand Down Expand Up @@ -49,9 +55,9 @@ import com.m3u.data.database.model.Stream
)
@TypeConverters(Converters::class)
internal abstract class M3UDatabase : RoomDatabase() {
abstract fun streamDao(): StreamDao
abstract fun channelDao(): ChannelDao
abstract fun playlistDao(): PlaylistDao
abstract fun episodeDao(): EpisodeDao
abstract fun programmeDao(): ProgrammeDao
abstract fun colorPackDao(): ColorSchemeDao
abstract fun colorSchemeDao(): ColorSchemeDao
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ import androidx.room.Delete
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import com.m3u.data.database.model.Stream
import com.m3u.data.database.model.Channel
import kotlinx.coroutines.flow.Flow

@Dao
internal interface StreamDao {
internal interface ChannelDao {
@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun insertOrReplace(stream: Stream): Long
suspend fun insertOrReplace(channel: Channel): Long

@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun insertOrReplaceAll(vararg streams: Stream)
suspend fun insertOrReplaceAll(vararg channels: Channel)

@Query(
"""
Expand Down Expand Up @@ -44,7 +44,7 @@ internal interface StreamDao {
): Flow<List<String>>

@Delete
suspend fun delete(stream: Stream)
suspend fun delete(channel: Channel)

@Query("DELETE FROM streams WHERE url = :url")
suspend fun deleteByUrl(url: String)
Expand All @@ -56,16 +56,16 @@ internal interface StreamDao {
suspend fun deleteByPlaylistUrlIgnoreFavOrHidden(playlistUrl: String)

@Query("SELECT channel_id FROM streams WHERE channel_id IS NOT NULL AND playlistUrl IN (:playlistUrls) AND (favourite = 1 OR hidden = 1)")
suspend fun getFavOrHiddenChannelIdsByPlaylistUrl(vararg playlistUrls: String): List<String>
suspend fun getFavOrHiddenOriginalIdsByPlaylistUrl(vararg playlistUrls: String): List<String>

@Query("SELECT url FROM streams WHERE channel_id IS NULL AND playlistUrl IN (:playlistUrls) AND (favourite = 1 OR hidden = 1)")
suspend fun getFavOrHiddenUrlsByPlaylistUrlNotContainsChannelId(vararg playlistUrls: String): List<String>
suspend fun getFavOrHiddenUrlsByPlaylistUrlNotContainsOriginalId(vararg playlistUrls: String): List<String>

@Query("SELECT * FROM streams WHERE seen != 0 ORDER BY seen DESC LIMIT 1")
suspend fun getPlayedRecently(): Stream?
suspend fun getPlayedRecently(): Channel?

@Query("SELECT * FROM streams WHERE id = :id")
suspend fun get(id: Int): Stream?
suspend fun get(id: Int): Channel?

@Query(
"""
Expand All @@ -76,7 +76,7 @@ internal interface StreamDao {
LIMIT 1
"""
)
suspend fun randomIgnoreSeriesAndHidden(vararg seriesPlaylistUrls: String): Stream?
suspend fun randomIgnoreSeriesAndHidden(vararg seriesPlaylistUrls: String): Channel?

@Query(
"""
Expand All @@ -87,37 +87,34 @@ internal interface StreamDao {
LIMIT 1
"""
)
suspend fun randomIgnoreSeriesInFavourite(vararg seriesPlaylistUrls: String): Stream?

@Query("SELECT * FROM streams WHERE url = :url")
suspend fun getByUrl(url: String): Stream?
suspend fun randomIgnoreSeriesInFavourite(vararg seriesPlaylistUrls: String): Channel?

@Query("SELECT * FROM streams WHERE url = :url AND playlistUrl = :playlistUrl")
suspend fun getByPlaylistUrlAndUrl(playlistUrl: String, url: String): Stream?
suspend fun getByPlaylistUrlAndUrl(playlistUrl: String, url: String): Channel?

@Query("SELECT * FROM streams WHERE title = :title AND playlistUrl = :playlistUrl")
suspend fun getByPlaylistUrlAndTitle(playlistUrl: String, title: String): Stream?
suspend fun getByPlaylistUrlAndTitle(playlistUrl: String, title: String): Channel?

@Query("SELECT * FROM streams WHERE playlistUrl = :playlistUrl")
suspend fun getByPlaylistUrl(playlistUrl: String): List<Stream>
suspend fun getByPlaylistUrl(playlistUrl: String): List<Channel>

@Query("SELECT * FROM streams WHERE playlistUrl = :playlistUrl AND channel_id = :channelId")
suspend fun getByPlaylistUrlAndChannelId(playlistUrl: String, channelId: String): Stream?
@Query("SELECT * FROM streams WHERE playlistUrl = :playlistUrl AND channel_id = :originalId")
suspend fun getByPlaylistUrlAndOriginalId(playlistUrl: String, originalId: String): Channel?

@Query("SELECT * FROM streams WHERE id = :id")
fun observeById(id: Int): Flow<Stream?>
fun observeById(id: Int): Flow<Channel?>

@Query("SELECT * FROM streams WHERE playlistUrl = :playlistUrl")
fun observeAllByPlaylistUrl(playlistUrl: String): Flow<List<Stream>>
fun observeAllByPlaylistUrl(playlistUrl: String): Flow<List<Channel>>

@Query("SELECT * FROM streams WHERE hidden = 0")
fun observeAllUnhidden(): Flow<List<Stream>>
fun observeAllUnhidden(): Flow<List<Channel>>

@Query("SELECT * FROM streams WHERE favourite = 1")
fun observeAllFavourite(): Flow<List<Stream>>
fun observeAllFavourite(): Flow<List<Channel>>

@Query("SELECT * FROM streams WHERE hidden = 1")
fun observeAllHidden(): Flow<List<Stream>>
fun observeAllHidden(): Flow<List<Channel>>

@Query(
"""
Expand All @@ -131,7 +128,7 @@ internal interface StreamDao {
url: String,
category: String,
query: String
): PagingSource<Int, Stream>
): PagingSource<Int, Channel>

@Query(
"""
Expand All @@ -146,7 +143,7 @@ internal interface StreamDao {
url: String,
category: String,
query: String
): PagingSource<Int, Stream>
): PagingSource<Int, Channel>

@Query(
"""
Expand All @@ -161,7 +158,7 @@ internal interface StreamDao {
url: String,
category: String,
query: String
): PagingSource<Int, Stream>
): PagingSource<Int, Channel>

@Query(
"""
Expand All @@ -176,7 +173,7 @@ internal interface StreamDao {
url: String,
category: String,
query: String
): PagingSource<Int, Stream>
): PagingSource<Int, Channel>

@Query("SELECT COUNT(playlistUrl) FROM streams WHERE playlistUrl = :playlistUrl")
fun observeCountByPlaylistUrl(playlistUrl: String): Flow<Int>
Expand All @@ -188,7 +185,7 @@ internal interface StreamDao {
fun observeAllUnseenFavourites(
limit: Long,
current: Long
): Flow<List<Stream>>
): Flow<List<Channel>>

@Query("UPDATE streams SET favourite = :target WHERE id = :id")
suspend fun favouriteOrUnfavourite(id: Int, target: Boolean)
Expand Down
Loading

0 comments on commit 80b7414

Please sign in to comment.