Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 53 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ def gitCommitHash = providers.exec {


android {
compileSdk 36
compileSdk 35

defaultConfig {
applicationId "ani.saikou"
minSdk 21
minSdk 24
targetSdk 34
versionCode ((System.currentTimeMillis() / 60000).toInteger())
versionName "1.2.5"
Expand All @@ -44,6 +44,10 @@ android {
buildFeatures {
viewBinding true
buildConfig = true
compose = true
composeOptions{
kotlinCompilerExtensionVersion = "1.5.15"
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
Expand Down Expand Up @@ -105,6 +109,52 @@ dependencies {


/// mpv lib
// implementation("io.github.abdallahmehiz:mpv-android-lib:0.1.12")
implementation("io.github.abdallahmehiz:mpv-android-lib:0.1.12")

// compose
def composeBom = platform('androidx.compose:compose-bom:2024.04.01')
implementation composeBom
androidTestImplementation composeBom

// Core integration with Activities & Foundation Layouts
implementation 'androidx.activity:activity-compose:1.8.2'
implementation 'androidx.compose.ui:ui'
implementation 'androidx.compose.ui:ui-graphics'
implementation 'androidx.compose.foundation:foundation'
implementation 'androidx.compose.runtime:runtime'

// Design System (Material Design 3)
implementation 'androidx.compose.material3:material3'

// Icons (Core + Full Extended Pack)
implementation 'androidx.compose.material:material-icons-core'
implementation 'androidx.compose.material:material-icons-extended'
/// constraint layout
implementation("androidx.constraintlayout:constraintlayout-compose:1.0.1")

//animation
implementation("androidx.compose.animation:animation-graphics")

// Developer & Tooling Previews
implementation 'androidx.compose.ui:ui-tooling-preview'
debugImplementation 'androidx.compose.ui:ui-tooling'

// UI Architecture & Test utilities
implementation 'androidx.lifecycle:lifecycle-viewmodel-compose:2.7.0'
debugImplementation 'androidx.compose.ui:ui-test-manifest'

// koin
def koin_version = "3.5.6"
def koin_compose_version = "3.5.6"

implementation "io.insert-koin:koin-android:$koin_version"
implementation "io.insert-koin:koin-androidx-compose:$koin_compose_version"

//seeker
implementation "com.github.abdallahmehiz:seeker:2.0.1"

/// koylin collections
implementation("org.jetbrains.kotlinx:kotlinx-collections-immutable:0.3.8")


}
27 changes: 18 additions & 9 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,25 @@
<activity android:name=".media.CharacterDetailsActivity" />
<activity android:name=".home.NoInternet" />

<activity
android:name="ani.saikou.media.anime.ExoplayerView"
android:configChanges="orientation|screenSize|smallestScreenSize|screenLayout|keyboard|keyboardHidden|navigation"
android:excludeFromRecents="true"
android:exported="true"
android:label="@string/video"
android:launchMode="singleTask"
android:supportsPictureInPicture="true"
tools:targetApi="n" />
<!-- <activity-->
<!-- android:name="ani.saikou.media.anime.ExoplayerView"-->
<!-- android:configChanges="orientation|screenSize|smallestScreenSize|screenLayout|keyboard|keyboardHidden|navigation"-->
<!-- android:excludeFromRecents="true"-->
<!-- android:exported="true"-->
<!-- android:label="@string/video"-->
<!-- android:launchMode="singleTask"-->
<!-- android:supportsPictureInPicture="true"-->
<!-- tools:targetApi="n" />-->


<activity
android:name=".media.anime.mpv.PlayerActivity"
android:screenOrientation="sensorLandscape"
android:configChanges="orientation|screenSize|screenLayout|smallestScreenSize|keyboardHidden">
</activity>
<service
android:name=".media.anime.mpv.PlaybackService"
android:exported="false" />
<activity
android:name="ani.saikou.connections.anilist.Login"
android:configChanges="orientation|screenSize|layoutDirection"
Expand Down
7 changes: 3 additions & 4 deletions app/src/main/java/ani/saikou/media/MediaDetailsViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,12 @@ class MediaDetailsViewModel : ViewModel() {

val timeStamps = MutableLiveData<List<AniSkip.Stamp>?>()
private val timeStampsMap: MutableMap<Int, List<AniSkip.Stamp>?> = mutableMapOf()
suspend fun loadTimeStamps(malId: Int?, episodeNum: Int?, duration: Long, useProxyForTimeStamps: Boolean) {
suspend fun loadTimeStamps(malId: Int?, episodeNum: Int?, duration: Long, ) {
malId ?: return
episodeNum ?: return
if (timeStampsMap.containsKey(episodeNum))
return timeStamps.postValue(timeStampsMap[episodeNum])
val result = AniSkip.getResult(malId, episodeNum, duration, useProxyForTimeStamps)
val result = AniSkip.getResult(malId, episodeNum, duration, )
timeStampsMap[episodeNum] = result
timeStamps.postValue(result)
}
Expand Down Expand Up @@ -266,5 +266,4 @@ class MediaDetailsViewModel : ViewModel() {
book.postValue(novelSources[i].loadBook(novel.link, novel.extra))
}
}

}
}
26 changes: 3 additions & 23 deletions app/src/main/java/ani/saikou/media/anime/ExoplayerView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ class ExoplayerView : AppCompatActivity(), Player.Listener {
private var aspectRatio = Rational(16, 9)

var settings = PlayerSettings()

private var uiSettings = UserInterfaceSettings()

private val handler = Handler(Looper.getMainLooper())
Expand Down Expand Up @@ -1029,6 +1030,7 @@ class ExoplayerView : AppCompatActivity(), Player.Listener {
false,
prev
)

discordRPC.connect()
discordRPC.onDurationReady(
buildRPCConfig(),
Expand Down Expand Up @@ -1213,28 +1215,7 @@ class ExoplayerView : AppCompatActivity(), Player.Listener {
val showProgressDialog =
if (settings.askIndividual) loadData<Boolean>("${media.id}_progressDialog")
?: true else false
if (showProgressDialog && Anilist.userid != null && if (media.isAdult) settings.updateForH else true)
AlertDialog.Builder(this, R.style.DialogTheme)
.setTitle(getString(R.string.auto_update, media.userPreferredName))
.apply {
setOnCancelListener { hideSystemBars() }
setCancelable(false)
setPositiveButton(getString(R.string.yes)) { dialog, _ ->
saveData("${media.id}_progressDialog", false)
saveData("${media.id}_save_progress", true)
dialog.dismiss()
model.setEpisode(episodes[media.anime!!.selectedEpisode!!]!!, "invoke")
}
setNegativeButton(getString(R.string.no)) { dialog, _ ->
saveData("${media.id}_progressDialog", false)
saveData("${media.id}_save_progress", false)
toast(getString(R.string.reset_auto_update))
dialog.dismiss()
model.setEpisode(episodes[media.anime!!.selectedEpisode!!]!!, "invoke")
}
show()
}
else model.setEpisode(episodes[media.anime!!.selectedEpisode!!]!!, "invoke")


if (settings.timeStampsEnabled)
updateTimeStamp()
Expand Down Expand Up @@ -1598,7 +1579,6 @@ class ExoplayerView : AppCompatActivity(), Player.Listener {
media.idMAL,
media.anime?.selectedEpisode?.trim()?.toIntOrNull(),
dur / 1000,
settings.useProxyForTimeStamps
)
}
}
Expand Down
41 changes: 31 additions & 10 deletions app/src/main/java/ani/saikou/media/anime/SelectorDialogFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import ani.saikou.databinding.ItemStreamBinding
import ani.saikou.databinding.ItemUrlBinding
import ani.saikou.media.Media
import ani.saikou.media.MediaDetailsViewModel
import ani.saikou.media.anime.mpv.MediaBridge
import ani.saikou.media.anime.mpv.PlayerActivity
import ani.saikou.others.Download.download
import ani.saikou.parsers.VideoExtractor
import ani.saikou.parsers.VideoType
Expand Down Expand Up @@ -86,10 +88,10 @@ class SelectorDialogFragment : BottomSheetDialogFragment() {
if (size!=null && size >= media!!.selected!!.video) {
media!!.anime!!.episodes?.get(media!!.anime!!.selectedEpisode!!)?.selectedExtractor = selected
media!!.anime!!.episodes?.get(media!!.anime!!.selectedEpisode!!)?.selectedVideo = media!!.selected!!.video
startExoplayer(media!!)
startMPVPlayer(media!!)
} else fail()
}

if (ep.extractors.isNullOrEmpty()) {
model.getEpisode().observe(this) {
if (it != null) {
Expand Down Expand Up @@ -154,18 +156,37 @@ class SelectorDialogFragment : BottomSheetDialogFragment() {
}

@SuppressLint("UnsafeOptInUsageError")
fun startExoplayer(media: Media) {
prevEpisode = null
// fun startExoplayer(media: Media) {
// prevEpisode = null
//
// dismiss()
// if (launch!!) {
// stopAddingToList()
// val intent = Intent(activity, ExoplayerView::class.java)
// ExoplayerView.media = media
// ExoplayerView.initialized = true
//
//
// startActivity(intent)
// } else {
// model.setEpisode(media.anime!!.episodes!![media.anime.selectedEpisode!!]!!, "startExo no launch")
// }
// }


fun startMPVPlayer(media: Media) {
prevEpisode = null
dismiss()
if (launch!!) {

if (launch == true) {
stopAddingToList()
val intent = Intent(activity, ExoplayerView::class.java)
ExoplayerView.media = media
ExoplayerView.initialized = true

MediaBridge.setMedia(media)

val intent = Intent(requireActivity(), PlayerActivity::class.java)
startActivity(intent)
} else {
model.setEpisode(media.anime!!.episodes!![media.anime.selectedEpisode!!]!!, "startExo no launch")
model.setEpisode(media.anime!!.episodes!![media.anime.selectedEpisode!!]!!, "startPlayer")
}
}

Expand Down Expand Up @@ -258,7 +279,7 @@ class SelectorDialogFragment : BottomSheetDialogFragment() {
media!!.selected!!.video = bindingAdapterPosition
model.saveSelected(media!!.id, media!!.selected!!, requireActivity())
}
startExoplayer(media!!)
startMPVPlayer(media!!)
}
}
itemView.setOnLongClickListener {
Expand Down
20 changes: 20 additions & 0 deletions app/src/main/java/ani/saikou/media/anime/mpv/MediaBridge.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package ani.saikou.media.anime.mpv

import ani.saikou.media.Media


object MediaBridge {
private var activeMedia: Media? = null

fun setMedia(media: Media) {
activeMedia = media
}

fun getMedia(): Media? {
return activeMedia
}

fun clear() {
activeMedia = null
}
}
Loading
Loading