Compare commits

...

3 Commits

Author SHA1 Message Date
Kelvin 6166392515 Polycentric disk caching 2024-12-04 18:20:40 +01:00
Kelvin 49d0dead7d Fix playlist wrong id for local conversion, refs 2024-12-04 01:31:53 +01:00
Kelvin 6f004830ff Fix directly opening playlists urls in wrong ui, causing wrong thread 2024-12-02 16:23:30 +01:00
15 changed files with 32 additions and 16 deletions
@@ -866,6 +866,9 @@ class Settings : FragmentedStorageFileJson() {
@FormField(R.string.enable_polycentric, FieldForm.TOGGLE, R.string.can_be_disabled_when_you_are_experiencing_issues, 3)
var polycentricEnabled: Boolean = true;
@FormField(R.string.polycentric_local_cache, FieldForm.TOGGLE, R.string.polycentric_local_cache_description, 4)
var polycentricLocalCache: Boolean = true;
}
@FormField(R.string.gesture_controls, FieldForm.GROUP, -1, 19)
@@ -834,7 +834,7 @@ class MainActivity : AppCompatActivity, IWithResultLauncher {
} else if (StatePlatform.instance.hasEnabledPlaylistClient(url)) {
Logger.i(TAG, "handleUrl(url=$url) found playlist client");
lifecycleScope.launch(Dispatchers.Main) {
navigate(_fragMainPlaylist, url);
navigate(_fragMainRemotePlaylist, url);
delay(100);
_fragVideoDetail.minimizeVideoDetail();
};
@@ -10,6 +10,7 @@ import com.futo.platformplayer.api.media.structures.IPager
import com.futo.platformplayer.api.media.structures.ReusablePager
import com.futo.platformplayer.getOrThrow
import com.futo.platformplayer.models.Playlist
import java.util.UUID
class JSPlaylistDetails: JSPlaylist, IPlatformPlaylistDetails {
override val contents: IPager<IPlatformVideo>;
@@ -37,6 +38,6 @@ class JSPlaylistDetails: JSPlaylist, IPlatformPlaylistDetails {
onProgress?.invoke(videos.size);
}
return Playlist(id.toString(), name, videos.map { SerializedPlatformVideo.fromVideo(it)});
return Playlist(UUID.randomUUID().toString(), name, videos.map { SerializedPlatformVideo.fromVideo(it)});
}
}
@@ -70,7 +70,7 @@ class PlaylistFragment : MainFragment() {
private var _editPlaylistOverlay: SlideUpMenuOverlay? = null;
private var _url: String? = null;
private val _taskLoadPlaylist: TaskHandler<String, IPlatformPlaylistDetails>;
private val _taskLoadPlaylist: TaskHandler<String, Playlist>;
constructor(fragment: PlaylistFragment, inflater: LayoutInflater) : super(inflater) {
_fragment = fragment;
@@ -137,16 +137,16 @@ class PlaylistFragment : MainFragment() {
);
};
_taskLoadPlaylist = TaskHandler<String, IPlatformPlaylistDetails>(
_taskLoadPlaylist = TaskHandler<String, Playlist>(
StateApp.instance.scopeGetter,
{
return@TaskHandler StatePlatform.instance.getPlaylist(it);
return@TaskHandler StatePlatform.instance.getPlaylist(it).toPlaylist();
})
.success {
setName(it.name);
//TODO: Implement support for pagination
setVideos(it.toPlaylist().videos, false);
setVideoCount(it.videoCount);
setVideos(it.videos, false);
setVideoCount(it.videos.size);
setLoading(false);
}
.exception<Throwable> {
@@ -47,6 +47,7 @@ import com.futo.platformplayer.services.DownloadService
import com.futo.platformplayer.stores.FragmentedStorage
import com.futo.platformplayer.stores.v2.ManagedStore
import com.futo.platformplayer.views.ToastView
import com.futo.polycentric.core.ApiMethods
import kotlinx.coroutines.*
import java.io.File
import java.util.*
@@ -156,6 +157,7 @@ class StateApp {
//Files
private var _tempDirectory: File? = null;
private var _cacheDirectory: File? = null;
private var _persistentDirectory: File? = null;
@@ -324,6 +326,9 @@ class StateApp {
_tempDirectory?.deleteRecursively();
}
_tempDirectory?.mkdirs();
_cacheDirectory = File(context.filesDir, "cache");
if(_cacheDirectory?.exists() == false)
_cacheDirectory?.mkdirs();
_persistentDirectory = File(context.filesDir, "persist");
if(_persistentDirectory?.exists() == false) {
_persistentDirectory?.mkdirs();
@@ -383,6 +388,11 @@ class StateApp {
Logger.i(TAG, "MainApp Starting");
initializeFiles(true);
if(Settings.instance.other.polycentricLocalCache) {
Logger.i(TAG, "Initialize Polycentric Disk Cache")
_cacheDirectory?.let { ApiMethods.initCache(it) };
}
val logFile = File(context.filesDir, "log.txt");
if (Settings.instance.logging.logLevel > LogLevel.NONE.value) {
val fileLogConsumer = FileLogConsumer(logFile, LogLevel.fromInt(Settings.instance.logging.logLevel), false);
+2
View File
@@ -424,6 +424,8 @@
<string name="playlist_delete_confirmation">Playlist Delete Confirmation</string>
<string name="playlist_delete_confirmation_description">Show confirmation dialog when deleting media from a playlist</string>
<string name="enable_polycentric">Enable Polycentric</string>
<string name="polycentric_local_cache">Enable Polycentric Local Caching</string>
<string name="polycentric_local_cache_description">Caches polycentric results on-device to reduce load times, changing requires app reboot</string>
<string name="can_be_disabled_when_you_are_experiencing_issues">Can be disabled when you are experiencing issues</string>
<string name="bypass_rotation_prevention_description">Allows for rotation on non-video views.\nWARNING: Not designed for it</string>
<string name="bypass_rotation_prevention_warning">This may cause unexpected behavior, and is mostly untested.</string>