added percentage switcher

This commit is contained in:
cranci1 2025-06-25 10:33:42 +02:00
parent fc1cff477b
commit 44c5b59601
42 changed files with 33 additions and 23 deletions

View file

@ -1642,9 +1642,10 @@ class CustomMediaPlayerViewController: UIViewController, UIGestureRecognizerDele
ContinueWatchingManager.shared.save(item: item)
}
let remainingPercentage = (self.duration - self.currentTimeVal) / self.duration
if remainingPercentage < 0.1 {
let remainingPercentage = (duration - currentTime) / duration
let threshold = (100.0 - (UserDefaults.standard.double(forKey: "remainingTimePercentage"))) / 100.0 ?? 0.1
if remainingPercentage < threshold {
if self.aniListID != 0 && !self.aniListUpdatedSuccessfully && !self.aniListUpdateImpossible {
self.tryAniListUpdate()
}

View file

@ -320,8 +320,9 @@ class VideoPlayerViewController: UIViewController {
}
let remainingPercentage = (duration - currentTime) / duration
let threshold = (100.0 - (UserDefaults.standard.double(forKey: "remainingTimePercentage"))) / 100.0 ?? 0.1
if remainingPercentage < 0.1 {
if remainingPercentage < threshold {
if self.aniListID != 0 && !self.aniListUpdateSent {
self.sendAniListUpdate()
}

View file

@ -199,6 +199,7 @@ struct SettingsViewPlayer: View {
@AppStorage("holdSpeedPlayer") private var holdSpeedPlayer: Double = 2.0
@AppStorage("skipIncrement") private var skipIncrement: Double = 10.0
@AppStorage("skipIncrementHold") private var skipIncrementHold: Double = 30.0
@AppStorage("remainingTimePercentage") private var remainingTimePercentage: Double = 90.0
@AppStorage("holdForPauseEnabled") private var holdForPauseEnabled = false
@AppStorage("skip85Visible") private var skip85Visible: Bool = true
@AppStorage("doubleTapSeekEnabled") private var doubleTapSeekEnabled: Bool = false
@ -216,7 +217,7 @@ struct SettingsViewPlayer: View {
VStack(spacing: 24) {
SettingsSection(
title: NSLocalizedString("Media Player", comment: ""),
footer: NSLocalizedString("Some features are limited to the Sora and Default player, such as ForceLandscape, holdSpeed and custom time skip increments.", comment: "")
footer: NSLocalizedString("Some features are limited to the Sora and Default player, such as ForceLandscape, holdSpeed and custom time skip increments.\n\nThe completion percentage setting determines at what point before the end of a video the app will mark it as completed on AniList and Trakt.", comment: "")
) {
SettingsPickerRow(
icon: "play.circle",
@ -245,6 +246,14 @@ struct SettingsViewPlayer: View {
isOn: $pipButtonVisible,
showDivider: false
)
SettingsPickerRow(
icon: "timer",
title: NSLocalizedString("Completion Percentage", comment: ""),
options: [60.0, 70.0, 80.0, 90.0, 95.0, 100.0],
optionToString: { "\(Int($0))%" },
selection: $remainingTimePercentage
)
}
SettingsSection(title: NSLocalizedString("Speed Settings", comment: "")) {

View file

@ -213,7 +213,7 @@ struct SettingsViewTrackers: View {
SettingsSection(title: NSLocalizedString("Trakt", comment: "")) {
VStack(spacing: 0) {
HStack(alignment: .center, spacing: 10) {
LazyImage(url: URL(string: "https://static-00.iconduck.com/assets.00/trakt-icon-2048x2048-2633ksxg.png")) { state in
LazyImage(url: URL(string: "https://cdn.iconscout.com/icon/free/png-512/free-trakt-logo-icon-download-in-svg-png-gif-file-formats--technology-social-media-company-vol-7-pack-logos-icons-2945267.png?f=webp&w=512")) { state in
if let uiImage = state.imageContainer?.image {
Image(uiImage: uiImage)
.resizable()
@ -304,7 +304,7 @@ struct SettingsViewTrackers: View {
}
SettingsSection(
title: NSLocalizedString("Info", comment: ""),
title: "",
footer: NSLocalizedString("Sora and cranci1 are not affiliated with AniList or Trakt in any way.\n\nAlso note that progress updates may not be 100% accurate.", comment: "")
) {}
}

View file

@ -42,7 +42,6 @@
04F08EDC2DE10BF3006B29D9 /* ProgressiveBlurView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04F08EDB2DE10BEC006B29D9 /* ProgressiveBlurView.swift */; };
04F08EDF2DE10C1D006B29D9 /* TabBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04F08EDE2DE10C1A006B29D9 /* TabBar.swift */; };
04F08EE22DE10C40006B29D9 /* TabItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04F08EE12DE10C27006B29D9 /* TabItem.swift */; };
130326B62DF979AC00AEF610 /* WebAuthenticationManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 130326B52DF979AC00AEF610 /* WebAuthenticationManager.swift */; };
130C6BFA2D53AB1F00DC1432 /* SettingsViewData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 130C6BF92D53AB1F00DC1432 /* SettingsViewData.swift */; };
13103E8B2D58E028000F0673 /* View.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13103E8A2D58E028000F0673 /* View.swift */; };
13103E8E2D58E04A000F0673 /* SkeletonCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13103E8D2D58E04A000F0673 /* SkeletonCell.swift */; };
@ -78,6 +77,7 @@
136BBE802DB1038000906B5E /* Notification+Name.swift in Sources */ = {isa = PBXBuildFile; fileRef = 136BBE7F2DB1038000906B5E /* Notification+Name.swift */; };
138AA1B82D2D66FD0021F9DF /* EpisodeCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 138AA1B62D2D66FD0021F9DF /* EpisodeCell.swift */; };
138AA1B92D2D66FD0021F9DF /* CircularProgressBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 138AA1B72D2D66FD0021F9DF /* CircularProgressBar.swift */; };
138B66A02E0BEA52009BE8D9 /* WebAuthenticationManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 138B669F2E0BEA52009BE8D9 /* WebAuthenticationManager.swift */; };
138FE1D02DECA00D00936D81 /* TMDB-FetchID.swift in Sources */ = {isa = PBXBuildFile; fileRef = 138FE1CF2DECA00D00936D81 /* TMDB-FetchID.swift */; };
1398FB3F2DE4E161004D3F5F /* SettingsViewAbout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1398FB3E2DE4E161004D3F5F /* SettingsViewAbout.swift */; };
139935662D468C450065CEFF /* ModuleManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 139935652D468C450065CEFF /* ModuleManager.swift */; };
@ -157,7 +157,6 @@
04F08EDB2DE10BEC006B29D9 /* ProgressiveBlurView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProgressiveBlurView.swift; sourceTree = "<group>"; };
04F08EDE2DE10C1A006B29D9 /* TabBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabBar.swift; sourceTree = "<group>"; };
04F08EE12DE10C27006B29D9 /* TabItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabItem.swift; sourceTree = "<group>"; };
130326B52DF979AC00AEF610 /* WebAuthenticationManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WebAuthenticationManager.swift; sourceTree = "<group>"; };
130C6BF82D53A4C200DC1432 /* Sora.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Sora.entitlements; sourceTree = "<group>"; };
130C6BF92D53AB1F00DC1432 /* SettingsViewData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsViewData.swift; sourceTree = "<group>"; };
13103E8A2D58E028000F0673 /* View.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = View.swift; sourceTree = "<group>"; };
@ -190,6 +189,7 @@
136BBE7F2DB1038000906B5E /* Notification+Name.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Notification+Name.swift"; sourceTree = "<group>"; };
138AA1B62D2D66FD0021F9DF /* EpisodeCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EpisodeCell.swift; sourceTree = "<group>"; };
138AA1B72D2D66FD0021F9DF /* CircularProgressBar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CircularProgressBar.swift; sourceTree = "<group>"; };
138B669F2E0BEA52009BE8D9 /* WebAuthenticationManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WebAuthenticationManager.swift; sourceTree = "<group>"; };
138FE1CF2DECA00D00936D81 /* TMDB-FetchID.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "TMDB-FetchID.swift"; sourceTree = "<group>"; };
1398FB3E2DE4E161004D3F5F /* SettingsViewAbout.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsViewAbout.swift; sourceTree = "<group>"; };
139935652D468C450065CEFF /* ModuleManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModuleManager.swift; sourceTree = "<group>"; };
@ -437,15 +437,6 @@
path = Models;
sourceTree = "<group>";
};
130326B42DF979A300AEF610 /* WebAuthentication */ = {
isa = PBXGroup;
children = (
130326B52DF979AC00AEF610 /* WebAuthenticationManager.swift */,
);
name = WebAuthentication;
path = Sora/Utils/WebAuthentication;
sourceTree = SOURCE_ROOT;
};
13103E802D589D6C000F0673 /* Tracking & Metadata */ = {
isa = PBXGroup;
children = (
@ -522,9 +513,9 @@
children = (
13103E802D589D6C000F0673 /* Tracking & Metadata */,
13530BE02E00028E0048B7DE /* Localization */,
133D7C852D2BE2640075467E /* Utlis & Misc */,
133CF6A92DFEBEAB00BD13F9 /* MediaUtils */,
133D7C7B2D2BE2630075467E /* Views */,
133D7C852D2BE2640075467E /* Utils */,
13DC0C412D2EC9BA00D0F966 /* Info.plist */,
133D7C6D2D2BE2500075467E /* SoraApp.swift */,
133D7C712D2BE2520075467E /* Assets.xcassets */,
@ -584,11 +575,11 @@
path = SettingsSubViews;
sourceTree = "<group>";
};
133D7C852D2BE2640075467E /* Utils */ = {
133D7C852D2BE2640075467E /* Utlis & Misc */ = {
isa = PBXGroup;
children = (
04F08EDA2DE10BE3006B29D9 /* ProgressiveBlurView */,
130326B42DF979A300AEF610 /* WebAuthentication */,
138B669E2E0BEA52009BE8D9 /* WebAuthentication */,
0457C5962DE7712A000AFBD9 /* ViewModifiers */,
04F08EE02DE10C22006B29D9 /* Models */,
04F08EDD2DE10C05006B29D9 /* TabBar */,
@ -601,7 +592,7 @@
13103E8C2D58E037000F0673 /* SkeletonCells */,
72443C832DC8046500A61321 /* DownloadUtils */,
);
path = Utils;
path = "Utlis & Misc";
sourceTree = "<group>";
};
133D7C862D2BE2640075467E /* Extensions */ = {
@ -705,6 +696,14 @@
path = EpisodeCell;
sourceTree = "<group>";
};
138B669E2E0BEA52009BE8D9 /* WebAuthentication */ = {
isa = PBXGroup;
children = (
138B669F2E0BEA52009BE8D9 /* WebAuthenticationManager.swift */,
);
path = WebAuthentication;
sourceTree = "<group>";
};
138FE1CE2DEC9FFA00936D81 /* TMDB */ = {
isa = PBXGroup;
children = (
@ -968,7 +967,6 @@
1E26E9E72DA9577900B9DC02 /* VolumeSlider.swift in Sources */,
136BBE802DB1038000906B5E /* Notification+Name.swift in Sources */,
13DB46902D900A38008CBC03 /* URL.swift in Sources */,
130326B62DF979AC00AEF610 /* WebAuthenticationManager.swift in Sources */,
138FE1D02DECA00D00936D81 /* TMDB-FetchID.swift in Sources */,
04AD07162E03704700EB74C1 /* BookmarkCell.swift in Sources */,
130C6BFA2D53AB1F00DC1432 /* SettingsViewData.swift in Sources */,
@ -978,6 +976,7 @@
1E47859B2DEBC5960095BF2F /* AnilistMatchPopupView.swift in Sources */,
13EA2BD92D32D98400C1EBD7 /* NormalPlayer.swift in Sources */,
133D7C932D2BE2640075467E /* Modules.swift in Sources */,
138B66A02E0BEA52009BE8D9 /* WebAuthenticationManager.swift in Sources */,
0457C5972DE7712A000AFBD9 /* DeviceScaleModifier.swift in Sources */,
13DB7CC32D7D99C0004371D3 /* SubtitleSettingsManager.swift in Sources */,
133D7C702D2BE2500075467E /* ContentView.swift in Sources */,