Skip to content

Commit 2c1e8b3

Browse files
committed
Reapply "Merge branch 'main' into main"
This reverts commit 3eb1377.
1 parent 3eb1377 commit 2c1e8b3

File tree

38 files changed

+1250
-635
lines changed

38 files changed

+1250
-635
lines changed

.github/workflows/bump_version.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
sed -i "s/versionName = \"[^\"]*\"/versionName = \"${{ env.VERSION_NAME }}\"/g" app/build.gradle.kts
3636
3737
- name: Open pull request
38-
uses: peter-evans/create-pull-request@v6.1.0
38+
uses: peter-evans/create-pull-request@v7.0.5
3939
with:
4040
commit-message: "Build: prepare for v${{ env.VERSION_NAME }} (${{ env.VERSION_CODE }}) release"
4141
branch: "release/${{ github.event.inputs.version }}"

Gemfile.lock

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,20 @@ GEM
1010
artifactory (3.0.17)
1111
atomos (0.1.3)
1212
aws-eventstream (1.3.0)
13-
aws-partitions (1.965.0)
14-
aws-sdk-core (3.201.5)
13+
aws-partitions (1.1018.0)
14+
aws-sdk-core (3.214.0)
1515
aws-eventstream (~> 1, >= 1.3.0)
16-
aws-partitions (~> 1, >= 1.651.0)
16+
aws-partitions (~> 1, >= 1.992.0)
1717
aws-sigv4 (~> 1.9)
1818
jmespath (~> 1, >= 1.6.1)
19-
aws-sdk-kms (1.88.0)
20-
aws-sdk-core (~> 3, >= 3.201.0)
19+
aws-sdk-kms (1.96.0)
20+
aws-sdk-core (~> 3, >= 3.210.0)
2121
aws-sigv4 (~> 1.5)
22-
aws-sdk-s3 (1.158.0)
23-
aws-sdk-core (~> 3, >= 3.201.0)
22+
aws-sdk-s3 (1.176.0)
23+
aws-sdk-core (~> 3, >= 3.210.0)
2424
aws-sdk-kms (~> 1)
2525
aws-sigv4 (~> 1.5)
26-
aws-sigv4 (1.9.1)
26+
aws-sigv4 (1.10.1)
2727
aws-eventstream (~> 1, >= 1.0.2)
2828
babosa (1.0.4)
2929
base64 (0.2.0)
@@ -38,8 +38,8 @@ GEM
3838
domain_name (0.6.20240107)
3939
dotenv (2.8.1)
4040
emoji_regex (3.2.3)
41-
excon (0.111.0)
42-
faraday (1.10.3)
41+
excon (0.112.0)
42+
faraday (1.10.4)
4343
faraday-em_http (~> 1.0)
4444
faraday-em_synchrony (~> 1.0)
4545
faraday-excon (~> 1.1)
@@ -65,10 +65,10 @@ GEM
6565
faraday-patron (1.0.0)
6666
faraday-rack (1.0.0)
6767
faraday-retry (1.0.3)
68-
faraday_middleware (1.2.0)
68+
faraday_middleware (1.2.1)
6969
faraday (~> 1.0)
7070
fastimage (2.3.1)
71-
fastlane (2.222.0)
71+
fastlane (2.225.0)
7272
CFPropertyList (>= 2.3, < 4.0.0)
7373
addressable (>= 2.8, < 3.0.0)
7474
artifactory (~> 3.0)
@@ -84,6 +84,7 @@ GEM
8484
faraday-cookie_jar (~> 0.0.6)
8585
faraday_middleware (~> 1.0)
8686
fastimage (>= 2.1.0, < 3.0.0)
87+
fastlane-sirp (>= 1.0.0)
8788
gh_inspector (>= 1.1.2, < 2.0.0)
8889
google-apis-androidpublisher_v3 (~> 0.3)
8990
google-apis-playcustomapp_v1 (~> 0.1)
@@ -109,6 +110,8 @@ GEM
109110
xcodeproj (>= 1.13.0, < 2.0.0)
110111
xcpretty (~> 0.3.0)
111112
xcpretty-travis-formatter (>= 0.0.3, < 2.0.0)
113+
fastlane-sirp (1.0.0)
114+
sysrandom (~> 1.0)
112115
gh_inspector (1.1.3)
113116
google-apis-androidpublisher_v3 (0.54.0)
114117
google-apis-core (>= 0.11.0, < 2.a)
@@ -151,17 +154,17 @@ GEM
151154
domain_name (~> 0.5)
152155
httpclient (2.8.3)
153156
jmespath (1.6.2)
154-
json (2.7.2)
155-
jwt (2.8.2)
157+
json (2.9.0)
158+
jwt (2.9.3)
156159
base64
157160
mini_magick (4.13.2)
158161
mini_mime (1.1.5)
159162
multi_json (1.15.0)
160163
multipart-post (2.4.1)
161-
nanaimo (0.3.0)
164+
nanaimo (0.4.0)
162165
naturally (2.2.1)
163166
nkf (0.2.0)
164-
optparse (0.5.0)
167+
optparse (0.6.0)
165168
os (1.1.4)
166169
plist (3.7.1)
167170
public_suffix (6.0.1)
@@ -171,8 +174,7 @@ GEM
171174
trailblazer-option (>= 0.1.1, < 0.2.0)
172175
uber (< 0.2.0)
173176
retriable (3.1.2)
174-
rexml (3.3.5)
175-
strscan
177+
rexml (3.3.9)
176178
rouge (2.0.7)
177179
ruby2_keywords (0.0.5)
178180
rubyzip (2.3.2)
@@ -185,7 +187,7 @@ GEM
185187
simctl (1.6.10)
186188
CFPropertyList
187189
naturally
188-
strscan (3.1.0)
190+
sysrandom (1.0.5)
189191
terminal-notifier (2.0.0)
190192
terminal-table (3.0.2)
191193
unicode-display_width (>= 1.1.1, < 3)
@@ -195,15 +197,15 @@ GEM
195197
tty-spinner (0.9.3)
196198
tty-cursor (~> 0.7)
197199
uber (0.1.0)
198-
unicode-display_width (2.5.0)
200+
unicode-display_width (2.6.0)
199201
word_wrap (1.0.0)
200-
xcodeproj (1.25.0)
202+
xcodeproj (1.27.0)
201203
CFPropertyList (>= 2.3.3, < 4.0)
202204
atomos (~> 0.1.3)
203205
claide (>= 1.0.2, < 2.0)
204206
colored2 (~> 3.1)
205-
nanaimo (~> 0.3.0)
206-
rexml (>= 3.3.2, < 4.0)
207+
nanaimo (~> 0.4.0)
208+
rexml (>= 3.3.6, < 4.0)
207209
xcpretty (0.3.0)
208210
rouge (~> 2.0.7)
209211
xcpretty-travis-formatter (1.0.1)

core/common/src/main/java/dev/anilbeesetti/nextplayer/core/common/extensions/File.kt

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,37 @@
11
package dev.anilbeesetti.nextplayer.core.common.extensions
22

3+
import android.content.Context
4+
import android.net.Uri
35
import android.os.Environment
6+
import androidx.core.net.toUri
47
import java.io.File
8+
import kotlinx.coroutines.Dispatchers
9+
import kotlinx.coroutines.withContext
510

6-
fun File.getSubtitles(): List<File> {
7-
val mediaName = this.nameWithoutExtension
8-
val subs = this.parentFile?.listFiles { file ->
9-
file.nameWithoutExtension.startsWith(mediaName) && file.isSubtitle()
10-
}?.toList() ?: emptyList()
11+
suspend fun File.getSubtitles(): List<File> = withContext(Dispatchers.IO) {
12+
val mediaName = this@getSubtitles.nameWithoutExtension
13+
val parentDir = this@getSubtitles.parentFile
14+
val subtitleExtensions = listOf("srt", "ssa", "ass", "vtt", "ttml")
15+
16+
subtitleExtensions.mapNotNull { extension ->
17+
val file = File(parentDir, "$mediaName.$extension")
18+
file.takeIf { it.exists() }
19+
}
20+
}
1121

12-
return subs
22+
suspend fun File.getLocalSubtitles(
23+
context: Context,
24+
excludeSubsList: List<Uri> = emptyList(),
25+
): List<Uri> = withContext(Dispatchers.Default) {
26+
val excludeSubsPathSet = excludeSubsList.mapNotNull { context.getPath(it) }.toSet()
27+
28+
getSubtitles().mapNotNull { file ->
29+
if (file.path !in excludeSubsPathSet) {
30+
file.toUri()
31+
} else {
32+
null
33+
}
34+
}
1335
}
1436

1537
fun String.getThumbnail(): File? {
@@ -24,7 +46,7 @@ fun String.getThumbnail(): File? {
2446

2547
fun File.isSubtitle(): Boolean {
2648
val subtitleExtensions = listOf("srt", "ssa", "ass", "vtt", "ttml")
27-
return extension in subtitleExtensions
49+
return extension.lowercase() in subtitleExtensions
2850
}
2951

3052
fun File.deleteFiles() {

core/data/src/main/java/dev/anilbeesetti/nextplayer/core/data/mappers/ToVideoState.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@ import dev.anilbeesetti.nextplayer.core.database.entities.MediumEntity
77
fun MediumEntity.toVideoState(): VideoState {
88
return VideoState(
99
path = path,
10-
position = playbackPosition,
10+
title = name,
11+
position = playbackPosition.takeIf { it != 0L },
1112
audioTrackIndex = audioTrackIndex,
1213
subtitleTrackIndex = subtitleTrackIndex,
1314
playbackSpeed = playbackSpeed,
1415
externalSubs = UriListConverter.fromStringToList(externalSubs),
1516
videoScale = videoScale,
17+
thumbnailPath = thumbnailPath,
1618
)
1719
}

core/data/src/main/java/dev/anilbeesetti/nextplayer/core/data/models/VideoState.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ import android.net.Uri
44

55
data class VideoState(
66
val path: String,
7-
val position: Long,
7+
val title: String,
8+
val position: Long?,
89
val audioTrackIndex: Int?,
910
val subtitleTrackIndex: Int?,
1011
val playbackSpeed: Float?,
1112
val externalSubs: List<Uri>,
1213
val videoScale: Float,
14+
val thumbnailPath: String?,
1315
)

core/data/src/main/java/dev/anilbeesetti/nextplayer/core/data/repository/LocalMediaRepository.kt

Lines changed: 44 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import kotlinx.coroutines.CoroutineScope
1818
import kotlinx.coroutines.flow.Flow
1919
import kotlinx.coroutines.flow.map
2020
import kotlinx.coroutines.launch
21-
import timber.log.Timber
2221

2322
class LocalMediaRepository @Inject constructor(
2423
private val mediumDao: MediumDao,
@@ -42,29 +41,52 @@ class LocalMediaRepository @Inject constructor(
4241
return mediumDao.get(uri)?.toVideoState()
4342
}
4443

45-
override suspend fun saveVideoState(
46-
uri: String,
47-
position: Long,
48-
audioTrackIndex: Int?,
49-
subtitleTrackIndex: Int?,
50-
playbackSpeed: Float?,
51-
externalSubs: List<Uri>,
52-
videoScale: Float,
53-
) {
54-
Timber.d(
55-
"save state for [$uri]: [$position, $audioTrackIndex, $subtitleTrackIndex, $playbackSpeed]",
56-
)
57-
44+
override fun updateMediumPosition(uri: String, position: Long) {
5845
applicationScope.launch {
59-
mediumDao.updateMediumState(
46+
val duration = mediumDao.get(uri)?.duration ?: position.plus(1)
47+
mediumDao.updateMediumPosition(
6048
uri = uri,
61-
position = position,
62-
audioTrackIndex = audioTrackIndex,
63-
subtitleTrackIndex = subtitleTrackIndex,
64-
playbackSpeed = playbackSpeed,
65-
externalSubs = UriListConverter.fromListToString(externalSubs),
66-
lastPlayedTime = System.currentTimeMillis(),
67-
videoScale = videoScale,
49+
position = position.takeIf { it < duration } ?: Long.MIN_VALUE.plus(1),
50+
)
51+
mediumDao.updateMediumLastPlayedTime(uri, System.currentTimeMillis())
52+
}
53+
}
54+
55+
override fun updateMediumPlaybackSpeed(uri: String, playbackSpeed: Float) {
56+
applicationScope.launch {
57+
mediumDao.updateMediumPlaybackSpeed(uri, playbackSpeed)
58+
mediumDao.updateMediumLastPlayedTime(uri, System.currentTimeMillis())
59+
}
60+
}
61+
62+
override fun updateMediumAudioTrack(uri: String, audioTrackIndex: Int) {
63+
applicationScope.launch {
64+
mediumDao.updateMediumAudioTrack(uri, audioTrackIndex)
65+
mediumDao.updateMediumLastPlayedTime(uri, System.currentTimeMillis())
66+
}
67+
}
68+
69+
override fun updateMediumSubtitleTrack(uri: String, subtitleTrackIndex: Int) {
70+
applicationScope.launch {
71+
mediumDao.updateMediumSubtitleTrack(uri, subtitleTrackIndex)
72+
mediumDao.updateMediumLastPlayedTime(uri, System.currentTimeMillis())
73+
}
74+
}
75+
76+
override fun updateMediumZoom(uri: String, zoom: Float) {
77+
applicationScope.launch {
78+
mediumDao.updateMediumZoom(uri, zoom)
79+
mediumDao.updateMediumLastPlayedTime(uri, System.currentTimeMillis())
80+
}
81+
}
82+
83+
override fun addExternalSubtitleToMedium(uri: String, subtitleUri: Uri) {
84+
applicationScope.launch {
85+
val currentExternalSubs = getVideoState(uri)?.externalSubs ?: emptyList()
86+
if (currentExternalSubs.contains(subtitleUri)) return@launch
87+
mediumDao.addExternalSubtitle(
88+
mediumUri = uri,
89+
externalSubs = UriListConverter.fromListToString(urlList = currentExternalSubs + subtitleUri),
6890
)
6991
}
7092
}

core/data/src/main/java/dev/anilbeesetti/nextplayer/core/data/repository/MediaRepository.kt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ interface MediaRepository {
1010
fun getVideosFlow(): Flow<List<Video>>
1111
fun getVideosFlowFromFolderPath(folderPath: String): Flow<List<Video>>
1212
fun getFoldersFlow(): Flow<List<Folder>>
13-
suspend fun saveVideoState(
14-
uri: String,
15-
position: Long,
16-
audioTrackIndex: Int?,
17-
subtitleTrackIndex: Int?,
18-
playbackSpeed: Float?,
19-
externalSubs: List<Uri>,
20-
videoScale: Float,
21-
)
13+
2214
suspend fun getVideoState(uri: String): VideoState?
15+
16+
fun updateMediumPosition(uri: String, position: Long)
17+
fun updateMediumPlaybackSpeed(uri: String, playbackSpeed: Float)
18+
fun updateMediumAudioTrack(uri: String, audioTrackIndex: Int)
19+
fun updateMediumSubtitleTrack(uri: String, subtitleTrackIndex: Int)
20+
fun updateMediumZoom(uri: String, zoom: Float)
21+
22+
fun addExternalSubtitleToMedium(uri: String, subtitleUri: Uri)
2323
}

core/data/src/main/java/dev/anilbeesetti/nextplayer/core/data/repository/fake/FakeMediaRepository.kt

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,25 @@ class FakeMediaRepository : MediaRepository {
2525
return flowOf(directories)
2626
}
2727

28-
override suspend fun saveVideoState(
29-
uri: String,
30-
position: Long,
31-
audioTrackIndex: Int?,
32-
subtitleTrackIndex: Int?,
33-
playbackSpeed: Float?,
34-
externalSubs: List<Uri>,
35-
videoScale: Float,
36-
) {
37-
}
38-
3928
override suspend fun getVideoState(uri: String): VideoState? {
4029
return null
4130
}
31+
32+
override fun updateMediumPosition(uri: String, position: Long) {
33+
}
34+
35+
override fun updateMediumPlaybackSpeed(uri: String, playbackSpeed: Float) {
36+
}
37+
38+
override fun updateMediumAudioTrack(uri: String, audioTrackIndex: Int) {
39+
}
40+
41+
override fun updateMediumSubtitleTrack(uri: String, subtitleTrackIndex: Int) {
42+
}
43+
44+
override fun updateMediumZoom(uri: String, zoom: Float) {
45+
}
46+
47+
override fun addExternalSubtitleToMedium(uri: String, subtitleUri: Uri) {
48+
}
4249
}

0 commit comments

Comments
 (0)