Skip to content

Commit 206170f

Browse files
committed
Refactor download status persistence and UI
1 parent b5cb367 commit 206170f

28 files changed

+685
-1866
lines changed

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

Lines changed: 0 additions & 856 deletions
This file was deleted.

app/src/main/java/org/schabi/newpipe/App.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import io.reactivex.rxjava3.plugins.RxJavaPlugins
2525
import org.acra.ACRA.init
2626
import org.acra.ACRA.isACRASenderServiceProcess
2727
import org.acra.config.CoreConfigurationBuilder
28-
import org.schabi.newpipe.download.DownloadMaintenance
2928
import org.schabi.newpipe.error.ReCaptchaActivity
3029
import org.schabi.newpipe.extractor.NewPipe
3130
import org.schabi.newpipe.extractor.downloader.Downloader
@@ -121,8 +120,6 @@ open class App :
121120
configureRxJavaErrorHandler()
122121

123122
YoutubeStreamExtractor.setPoTokenProvider(PoTokenProviderImpl)
124-
125-
DownloadMaintenance.schedule(this)
126123
}
127124

128125
override fun newImageLoader(context: Context): ImageLoader =

app/src/main/java/org/schabi/newpipe/NewPipeDatabase.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import static org.schabi.newpipe.database.Migrations.MIGRATION_6_7;
1010
import static org.schabi.newpipe.database.Migrations.MIGRATION_7_8;
1111
import static org.schabi.newpipe.database.Migrations.MIGRATION_8_9;
12-
import static org.schabi.newpipe.database.Migrations.MIGRATION_9_10;
1312

1413
import android.content.Context;
1514
import android.database.Cursor;
@@ -30,7 +29,7 @@ private static AppDatabase getDatabase(final Context context) {
3029
return Room
3130
.databaseBuilder(context.getApplicationContext(), AppDatabase.class, DATABASE_NAME)
3231
.addMigrations(MIGRATION_1_2, MIGRATION_2_3, MIGRATION_3_4, MIGRATION_4_5,
33-
MIGRATION_5_6, MIGRATION_6_7, MIGRATION_7_8, MIGRATION_8_9, MIGRATION_9_10)
32+
MIGRATION_5_6, MIGRATION_6_7, MIGRATION_7_8, MIGRATION_8_9)
3433
.build();
3534
}
3635

app/src/main/java/org/schabi/newpipe/database/AppDatabase.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
package org.schabi.newpipe.database;
22

3-
import static org.schabi.newpipe.database.Migrations.DB_VER_10;
3+
import static org.schabi.newpipe.database.Migrations.DB_VER_9;
44

55
import androidx.room.Database;
66
import androidx.room.RoomDatabase;
77
import androidx.room.TypeConverters;
88

9-
import org.schabi.newpipe.database.download.DownloadedStreamEntity;
10-
import org.schabi.newpipe.database.download.DownloadedStreamsDao;
119
import org.schabi.newpipe.database.feed.dao.FeedDAO;
1210
import org.schabi.newpipe.database.feed.dao.FeedGroupDAO;
1311
import org.schabi.newpipe.database.feed.model.FeedEntity;
@@ -38,9 +36,9 @@
3836
StreamEntity.class, StreamHistoryEntity.class, StreamStateEntity.class,
3937
PlaylistEntity.class, PlaylistStreamEntity.class, PlaylistRemoteEntity.class,
4038
FeedEntity.class, FeedGroupEntity.class, FeedGroupSubscriptionEntity.class,
41-
FeedLastUpdatedEntity.class, DownloadedStreamEntity.class
39+
FeedLastUpdatedEntity.class
4240
},
43-
version = DB_VER_10
41+
version = DB_VER_9
4442
)
4543
public abstract class AppDatabase extends RoomDatabase {
4644
public static final String DATABASE_NAME = "newpipe.db";
@@ -64,6 +62,4 @@ public abstract class AppDatabase extends RoomDatabase {
6462
public abstract FeedGroupDAO feedGroupDAO();
6563

6664
public abstract SubscriptionDAO subscriptionDAO();
67-
68-
public abstract DownloadedStreamsDao downloadedStreamsDao();
6965
}

app/src/main/java/org/schabi/newpipe/database/Converters.kt

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package org.schabi.newpipe.database
22

33
import androidx.room.TypeConverter
4-
import org.schabi.newpipe.database.download.DownloadedStreamStatus
54
import org.schabi.newpipe.extractor.stream.StreamType
65
import org.schabi.newpipe.local.subscription.FeedGroupIcon
76
import java.time.Instant
@@ -50,14 +49,4 @@ class Converters {
5049
fun feedGroupIconOf(id: Int): FeedGroupIcon {
5150
return FeedGroupIcon.entries.first { it.id == id }
5251
}
53-
54-
@TypeConverter
55-
fun downloadedStreamStatusOf(value: Int?): DownloadedStreamStatus? {
56-
return value?.let { DownloadedStreamStatus.fromValue(it) }
57-
}
58-
59-
@TypeConverter
60-
fun integerOf(status: DownloadedStreamStatus?): Int? {
61-
return status?.value
62-
}
6352
}

app/src/main/java/org/schabi/newpipe/database/Migrations.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ public final class Migrations {
2727
public static final int DB_VER_7 = 7;
2828
public static final int DB_VER_8 = 8;
2929
public static final int DB_VER_9 = 9;
30-
public static final int DB_VER_10 = 10;
3130

3231
private static final String TAG = Migrations.class.getName();
3332
public static final boolean DEBUG = MainActivity.DEBUG;
@@ -303,22 +302,6 @@ public void migrate(@NonNull final SupportSQLiteDatabase database) {
303302
}
304303
};
305304

306-
public static final Migration MIGRATION_9_10 = new Migration(DB_VER_9, DB_VER_10) {
307-
@Override
308-
public void migrate(@NonNull final SupportSQLiteDatabase database) {
309-
database.execSQL("CREATE TABLE IF NOT EXISTS downloaded_streams "
310-
+ "(id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "
311-
+ "stream_uid INTEGER NOT NULL, service_id INTEGER NOT NULL, "
312-
+ "url TEXT NOT NULL, file_uri TEXT NOT NULL, parent_uri TEXT, "
313-
+ "display_name TEXT, mime TEXT, size_bytes INTEGER, quality_label TEXT, "
314-
+ "duration_ms INTEGER, status INTEGER NOT NULL, added_at INTEGER NOT NULL, "
315-
+ "last_checked_at INTEGER, missing_since INTEGER, FOREIGN KEY(stream_uid) "
316-
+ "REFERENCES streams(uid) ON UPDATE CASCADE ON DELETE CASCADE)");
317-
database.execSQL("CREATE UNIQUE INDEX index_downloaded_streams_stream_uid "
318-
+ "ON downloaded_streams (stream_uid)");
319-
}
320-
};
321-
322305
private Migrations() {
323306
}
324307
}

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

Lines changed: 0 additions & 103 deletions
This file was deleted.

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

Lines changed: 0 additions & 14 deletions
This file was deleted.

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

Lines changed: 0 additions & 58 deletions
This file was deleted.

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,6 @@ public boolean onCreateOptionsMenu(final Menu menu) {
8181
return true;
8282
}
8383

84-
@Override
85-
protected void onResume() {
86-
super.onResume();
87-
new Thread(() ->
88-
DownloadMaintenance.revalidateAvailable(DownloadActivity.this, 10)
89-
).start();
90-
}
91-
9284
@Override
9385
public boolean onOptionsItemSelected(final MenuItem item) {
9486
switch (item.getItemId()) {

0 commit comments

Comments
 (0)