Skip to content

Commit 7425958

Browse files
committed
Fix metadata for notification
1 parent 78d954c commit 7425958

File tree

7 files changed

+78
-9
lines changed

7 files changed

+78
-9
lines changed

app/schemas/org.schabi.newpipe.database.AppDatabase/10.json

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"formatVersion": 1,
33
"database": {
44
"version": 10,
5-
"identityHash": "8401456768674521d2a28a221a37406c",
5+
"identityHash": "97b77504ce430e914b8e8628f548c03c",
66
"entities": [
77
{
88
"tableName": "subscriptions",
@@ -722,7 +722,7 @@
722722
},
723723
{
724724
"tableName": "download",
725-
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`creation_date` INTEGER NOT NULL, `id_key` TEXT NOT NULL, `url_key` TEXT NOT NULL, `uri_value` TEXT NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL)",
725+
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`creation_date` INTEGER NOT NULL, `id_key` TEXT NOT NULL, `url_key` TEXT NOT NULL, `uri_value` TEXT NOT NULL, `name` TEXT NOT NULL, `uploader_name` TEXT NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL)",
726726
"fields": [
727727
{
728728
"fieldPath": "creationDate",
@@ -748,6 +748,18 @@
748748
"affinity": "TEXT",
749749
"notNull": true
750750
},
751+
{
752+
"fieldPath": "name",
753+
"columnName": "name",
754+
"affinity": "TEXT",
755+
"notNull": true
756+
},
757+
{
758+
"fieldPath": "uploaderName",
759+
"columnName": "uploader_name",
760+
"affinity": "TEXT",
761+
"notNull": true
762+
},
751763
{
752764
"fieldPath": "id",
753765
"columnName": "id",
@@ -768,7 +780,7 @@
768780
"views": [],
769781
"setupQueries": [
770782
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
771-
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '8401456768674521d2a28a221a37406c')"
783+
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '97b77504ce430e914b8e8628f548c03c')"
772784
]
773785
}
774786
}

app/src/main/java/org/schabi/newpipe/database/download/entry/DownloadEntry.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ data class DownloadEntry(
1010
@field:ColumnInfo(name = CREATION_DATE) var creationDate: OffsetDateTime,
1111
@field:ColumnInfo(name = ID_KEY) var idKey: String,
1212
@field:ColumnInfo(name = URL_KEY) var url: String,
13-
@field:ColumnInfo(name = URI_VALUE) var uriValue: String
13+
@field:ColumnInfo(name = URI_VALUE) var uriValue: String,
14+
@field:ColumnInfo(name = NAME) var name: String,
15+
@field:ColumnInfo(name = UPLOADER_NAME) var uploaderName: String
1416
) {
1517
@ColumnInfo(name = ID)
1618
@PrimaryKey(autoGenerate = true)
@@ -23,5 +25,7 @@ data class DownloadEntry(
2325
const val URL_KEY = "url_key"
2426
const val URI_VALUE = "uri_value"
2527
const val CREATION_DATE = "creation_date"
28+
const val NAME = "name"
29+
const val UPLOADER_NAME = "uploader_name"
2630
}
2731
}

app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1156,9 +1156,12 @@ private void continueSelectedDownload(@NonNull final StoredFileHelper storage) {
11561156
Log.d("GERRR", "continueSelectedDownload: " + data);
11571157
}
11581158

1159+
final String name = currentInfo.getName();
1160+
final String uploaderName = currentInfo.getUploaderName();
1161+
11591162
// TODO improve error handling
11601163
disposables.add(recordManager.insert(currentInfo.getId(), storage.getUri().toString(),
1161-
currentInfo.getUrl()).onErrorComplete()
1164+
currentInfo.getUrl(), name, uploaderName).onErrorComplete()
11621165
.subscribe(
11631166
ignored -> {
11641167
/* successful */

app/src/main/java/org/schabi/newpipe/download/DownloadHelper.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,11 @@ private fun continueSelectedDownload(
353353

354354
val disposables = CompositeDisposable()
355355

356+
val name = currentInfo.name
357+
val uploaderName = currentInfo.uploaderName
358+
356359
disposables.add(
357-
recordManager.insert(currentInfo.id, storage.uri.toString(), currentInfo.url).onErrorComplete()
360+
recordManager.insert(currentInfo.id, storage.uri.toString(), currentInfo.url, name, uploaderName).onErrorComplete()
358361
.subscribe(
359362
{ ignored: Long? ->
360363
/* successful */

app/src/main/java/org/schabi/newpipe/local/download/DownloadRecordManager.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ class DownloadRecordManager(context: Context) {
2020
downloadTable = database.downloadDAO()
2121
}
2222

23-
fun insert(key: String, uri: String, url: String): Maybe<Long> {
23+
fun insert(key: String, uri: String, url: String, name: String, uploaderName: String): Maybe<Long> {
2424
return Maybe.fromCallable {
2525
database.runInTransaction<Long> {
2626
val currentTime = OffsetDateTime.now(ZoneOffset.UTC)
27-
downloadTable.insert(DownloadEntry(currentTime, key, url, uri))
27+
downloadTable.insert(DownloadEntry(currentTime, key, url, uri, name, uploaderName))
2828
}
2929
}.subscribeOn(Schedulers.io())
3030
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package org.schabi.newpipe.player.mediaitem
2+
3+
import org.schabi.newpipe.extractor.stream.StreamType
4+
import java.util.Optional
5+
6+
class MediaTagImpl(private val pTitle: String, private val pUploaderName: String) : MediaItemTag {
7+
8+
private val extras: Any? = null
9+
override fun getErrors(): MutableList<Exception> = mutableListOf()
10+
11+
override fun getServiceId(): Int = -1
12+
13+
override fun getTitle(): String {
14+
return pTitle
15+
}
16+
17+
override fun getUploaderName(): String {
18+
return pUploaderName
19+
}
20+
21+
override fun getDurationSeconds(): Long = 0L
22+
23+
override fun getStreamUrl(): String = ""
24+
25+
override fun getThumbnailUrl(): String = ""
26+
27+
override fun getUploaderUrl(): String = ""
28+
29+
override fun getStreamType(): StreamType = StreamType.AUDIO_STREAM
30+
31+
override fun <T> getMaybeExtras(type: Class<T>): Optional<T>? {
32+
return Optional.ofNullable<Any>(extras).map<T> { obj: Any? ->
33+
type.cast(
34+
obj
35+
)
36+
}
37+
}
38+
39+
override fun <T : Any?> withExtras(extra: T & Any): MediaItemTag {
40+
return MediaTagImpl("withExtras", "withExtras")
41+
}
42+
}

app/src/main/java/org/schabi/newpipe/player/playback/MediaSourceManager.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
1818
import org.schabi.newpipe.local.download.DownloadRecordManager;
1919
import org.schabi.newpipe.player.mediaitem.MediaItemTag;
20+
import org.schabi.newpipe.player.mediaitem.MediaTagImpl;
2021
import org.schabi.newpipe.player.mediasource.FailedMediaSource;
2122
import org.schabi.newpipe.player.mediasource.LoadedMediaSource;
2223
import org.schabi.newpipe.player.mediasource.LocalMediaSource;
@@ -447,7 +448,11 @@ private void maybeLoadItem(@NonNull final PlayQueueItem item) {
447448
final MediaItem mediaItem = new MediaItem.Builder()
448449
.setUri(audioUri)
449450
.setMediaId(item.getUrl())
450-
.setTag(audioUri)
451+
.setTag(
452+
new MediaTagImpl(
453+
downloadEntry.getName(),
454+
downloadEntry.getUploaderName())
455+
)
451456
.build();
452457

453458
final ProgressiveMediaSource mediaSource =

0 commit comments

Comments
 (0)