Skip to content

Commit 9c8e836

Browse files
committed
Merge branch 'feature/last-position-store'
2 parents 6624865 + 087b51f commit 9c8e836

File tree

26 files changed

+842
-75
lines changed

26 files changed

+842
-75
lines changed

VERSIONING.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@
1010
#
1111
# ./gradlew verifySemanticVersioning
1212
#
13+
14+
org.librarysimplified.audiobook.persistence.internal

build.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import org.jetbrains.kotlin.de.undercouch.gradle.tasks.download.Verify
55
import org.jetbrains.kotlin.gradle.dsl.KotlinAndroidProjectExtension
66
import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension
77

8-
val gradleVersionRequired = "8.10.2"
8+
val gradleVersionRequired = "8.14.3"
99
val gradleVersionReceived = gradle.gradleVersion
1010

1111
if (gradleVersionRequired != gradleVersionReceived) {
@@ -40,11 +40,11 @@ plugins {
4040
.apply(false)
4141

4242
id("com.android.library")
43-
.version("8.5.0")
43+
.version("8.11.0")
4444
.apply(false)
4545

4646
id("com.android.application")
47-
.version("8.5.0")
47+
.version("8.11.0")
4848
.apply(false)
4949

5050
/*

gradle.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ VERSION_PREVIOUS=16.1.0
2121
android.useAndroidX=true
2222
android.enableJetifier=true
2323

24-
org.thepalaceproject.build.androidSDKCompile=34
25-
org.thepalaceproject.build.androidSDKTarget=34
24+
org.thepalaceproject.build.androidSDKCompile=35
25+
org.thepalaceproject.build.androidSDKTarget=35
2626
org.thepalaceproject.build.androidSDKMinimum=26
2727
org.thepalaceproject.build.checkSemanticVersioning=true
2828
org.thepalaceproject.build.enableKtLint=true
29-
org.thepalaceproject.build.jdkBytecodeTarget=11
29+
org.thepalaceproject.build.jdkBytecodeTarget=17
3030
org.thepalaceproject.build.jdkBuild=17
3131
org.thepalaceproject.build.publishSources=true

gradle/wrapper/gradle-wrapper.jar

181 Bytes
Binary file not shown.

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

gradlew

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,7 @@ done
8686
# shellcheck disable=SC2034
8787
APP_BASE_NAME=${0##*/}
8888
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
89-
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
90-
' "$PWD" ) || exit
89+
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
9190

9291
# Use the maximum available, or set MAX_FD != -1 to use that value.
9392
MAX_FD=maximum
@@ -115,7 +114,7 @@ case "$( uname )" in #(
115114
NONSTOP* ) nonstop=true ;;
116115
esac
117116

118-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
117+
CLASSPATH="\\\"\\\""
119118

120119

121120
# Determine the Java command to use to start the JVM.
@@ -206,15 +205,15 @@ fi
206205
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
207206

208207
# Collect all arguments for the java command:
209-
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
208+
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
210209
# and any embedded shellness will be escaped.
211210
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
212211
# treated as '${Hostname}' itself on the command line.
213212

214213
set -- \
215214
"-Dorg.gradle.appname=$APP_BASE_NAME" \
216215
-classpath "$CLASSPATH" \
217-
org.gradle.wrapper.GradleWrapperMain \
216+
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
218217
"$@"
219218

220219
# Stop when "xargs" is not available.

gradlew.bat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ goto fail
7070
:execute
7171
@rem Setup the command line
7272

73-
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73+
set CLASSPATH=
7474

7575

7676
@rem Execute Gradle
77-
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
77+
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
7878

7979
:end
8080
@rem End local scope for the variables with windows NT shell

org.librarysimplified.audiobook.demo/build.gradle.kts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ dependencies {
2626
implementation(project(":org.librarysimplified.audiobook.manifest_parser.webpub"))
2727
implementation(project(":org.librarysimplified.audiobook.media3"))
2828
implementation(project(":org.librarysimplified.audiobook.parser.api"))
29+
implementation(project(":org.librarysimplified.audiobook.persistence"))
2930
implementation(project(":org.librarysimplified.audiobook.time_tracking"))
3031
implementation(project(":org.librarysimplified.audiobook.views"))
3132

@@ -149,6 +150,23 @@ dependencies {
149150
implementation(libs.rxjava2)
150151
implementation(libs.slf4j)
151152

153+
// SQLite
154+
implementation(libs.io7m.anethum.api)
155+
implementation(libs.io7m.blackthorne.core)
156+
implementation(libs.io7m.blackthorne.jxe)
157+
implementation(libs.io7m.jaffirm.core)
158+
implementation(libs.io7m.jattribute.core)
159+
implementation(libs.io7m.jlexing.core)
160+
implementation(libs.io7m.junreachable)
161+
implementation(libs.io7m.jxe.core)
162+
implementation(libs.io7m.seltzer.api)
163+
implementation(libs.io7m.trasco.api)
164+
implementation(libs.io7m.trasco.vanilla)
165+
implementation(libs.io7m.trasco.xml.schemas)
166+
implementation(libs.io7m.xyloid.natives)
167+
implementation(libs.xerces)
168+
implementation(libs.xerial.sqlite)
169+
152170
if (lcpDRM) {
153171
implementation(libs.palace.liblcp) {
154172
artifact {

org.librarysimplified.audiobook.demo/src/main/java/org/librarysimplified/audiobook/demo/ExamplePlayerActivity.kt

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,17 @@ class ExamplePlayerActivity : AppCompatActivity(R.layout.example_player_activity
174174
)
175175

176176
PlayerBookmarkModel.setBookmarks(bookmarkDatabase.bookmarkList(bookId))
177+
178+
PlayerUIThread.runOnUIThread {
179+
try {
180+
Toast.makeText(this, "" +
181+
"Created bookmark",
182+
Toast.LENGTH_LONG
183+
).show()
184+
} catch (e: Throwable) {
185+
// Don't care
186+
}
187+
}
177188
}
178189

179190
is PlayerEvent.PlayerEventDeleteBookmark -> {
@@ -189,6 +200,17 @@ class ExamplePlayerActivity : AppCompatActivity(R.layout.example_player_activity
189200
bookId,
190201
event.bookmark
191202
)
203+
204+
PlayerUIThread.runOnUIThread {
205+
try {
206+
Toast.makeText(this, "" +
207+
"Deleted bookmark",
208+
Toast.LENGTH_LONG
209+
).show()
210+
} catch (e: Throwable) {
211+
// Don't care
212+
}
213+
}
192214
}
193215

194216
is PlayerEvent.PlayerEventError,
@@ -241,25 +263,14 @@ class ExamplePlayerActivity : AppCompatActivity(R.layout.example_player_activity
241263
ExampleApplication.application.bookmarkDatabase
242264
val bookmarksAll =
243265
bookmarkDatabase.bookmarkList(bookId)
244-
val bookmarkLastRead =
245-
bookmarkDatabase.bookmarkFindLastRead(bookId)
246266

247267
PlayerBookmarkModel.setBookmarks(bookmarksAll)
248268

249-
val initialPosition =
250-
if (bookmarkLastRead != null) {
251-
this.logger.debug("Restoring last-read position: {}", bookmarkLastRead.position)
252-
bookmarkLastRead.position
253-
} else {
254-
null
255-
}
256-
257269
PlayerModel.openPlayerForManifest(
258270
context = ExampleApplication.application,
259271
userAgent = PlayerUserAgent("AudioBookDemo"),
260272
manifest = state.manifest,
261273
fetchAll = true,
262-
initialPosition = initialPosition,
263274
bookSource = state.bookSource,
264275
bookCredentials = state.bookCredentials
265276
)
@@ -281,6 +292,19 @@ class ExamplePlayerActivity : AppCompatActivity(R.layout.example_player_activity
281292
PlayerModel.bookTitle = manifest.metadata.title
282293
PlayerModel.bookAuthor = "An Example Author."
283294
}
295+
296+
val start = state.positionOnOpen
297+
if (start != null) {
298+
try {
299+
Toast.makeText(this, "" +
300+
"Starting at saved position: ${start.readingOrderID.text} ${start.offsetMilliseconds.value}",
301+
Toast.LENGTH_LONG
302+
).show()
303+
} catch (e: Throwable) {
304+
// Don't care
305+
}
306+
}
307+
284308
this.switchFragment(PlayerFragment())
285309
}
286310

org.librarysimplified.audiobook.media3/src/main/java/org/librarysimplified/audiobook/media3/ExoBookmarkObserver.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import org.librarysimplified.audiobook.api.PlayerEvent.PlayerEventWithPosition.P
2121
import org.librarysimplified.audiobook.api.PlayerEvent.PlayerEventWithPosition.PlayerEventPlaybackStarted
2222
import org.librarysimplified.audiobook.api.PlayerEvent.PlayerEventWithPosition.PlayerEventPlaybackStopped
2323
import org.librarysimplified.audiobook.api.PlayerEvent.PlayerEventWithPosition.PlayerEventPlaybackWaitingForAction
24+
import org.librarysimplified.audiobook.api.PlayerPlaybackStatus
2425
import org.librarysimplified.audiobook.api.PlayerType
2526
import org.librarysimplified.audiobook.manifest.api.PlayerMillisecondsReadingOrderItem
2627
import org.slf4j.LoggerFactory
@@ -87,6 +88,16 @@ class ExoBookmarkObserver private constructor(
8788
return
8889
}
8990

91+
/*
92+
* Paranoia: Do not create bookmarks unless the player says that it is actually playing. We
93+
* have seen player bugs in the past where the player gives nonsense position updates when
94+
* it is stopped.
95+
*/
96+
97+
if (this.player.playbackStatus != PlayerPlaybackStatus.PLAYING) {
98+
return
99+
}
100+
90101
/*
91102
* Do not create bookmarks any more frequently than the waiting period.
92103
*/

0 commit comments

Comments
 (0)