Option to always hide new mark for podcast.
This commit is contained in:
parent
522481ad93
commit
48922e65cc
|
@ -28,7 +28,7 @@ class DBHelper {
|
||||||
var documentsDirectory = await getDatabasesPath();
|
var documentsDirectory = await getDatabasesPath();
|
||||||
var path = join(documentsDirectory, "podcasts.db");
|
var path = join(documentsDirectory, "podcasts.db");
|
||||||
var theDb = await openDatabase(path,
|
var theDb = await openDatabase(path,
|
||||||
version: 6, onCreate: _onCreate, onUpgrade: _onUpgrade);
|
version: 7, onCreate: _onCreate, onUpgrade: _onUpgrade);
|
||||||
return theDb;
|
return theDb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,8 @@ class DBHelper {
|
||||||
background_image TEXT DEFAULT '', hosts TEXT DEFAULT '',update_count INTEGER DEFAULT 0,
|
background_image TEXT DEFAULT '', hosts TEXT DEFAULT '',update_count INTEGER DEFAULT 0,
|
||||||
episode_count INTEGER DEFAULT 0, skip_seconds INTEGER DEFAULT 0,
|
episode_count INTEGER DEFAULT 0, skip_seconds INTEGER DEFAULT 0,
|
||||||
auto_download INTEGER DEFAULT 0, skip_seconds_end INTEGER DEFAULT 0,
|
auto_download INTEGER DEFAULT 0, skip_seconds_end INTEGER DEFAULT 0,
|
||||||
never_update INTEGER DEFAULT 0, funding TEXT DEFAULT '[]')""");
|
never_update INTEGER DEFAULT 0, funding TEXT DEFAULT '[]',
|
||||||
|
hide_new_mark INTEGER DEFAULT 0 )""");
|
||||||
await db
|
await db
|
||||||
.execute("""CREATE TABLE Episodes(id INTEGER PRIMARY KEY,title TEXT,
|
.execute("""CREATE TABLE Episodes(id INTEGER PRIMARY KEY,title TEXT,
|
||||||
enclosure_url TEXT UNIQUE, enclosure_length INTEGER, pubDate TEXT,
|
enclosure_url TEXT UNIQUE, enclosure_length INTEGER, pubDate TEXT,
|
||||||
|
@ -90,6 +91,8 @@ class DBHelper {
|
||||||
case (5):
|
case (5):
|
||||||
await _v6Update(db);
|
await _v6Update(db);
|
||||||
break;
|
break;
|
||||||
|
case (6):
|
||||||
|
await _v7Update(db);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,6 +129,10 @@ class DBHelper {
|
||||||
""");
|
""");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> _v7Update(Database db) async {
|
||||||
|
await db.execute("ALTER TABLE PodcastLocal ADD hide_new_mark INTEGER DEFAULT 0");
|
||||||
|
}
|
||||||
|
|
||||||
Future<List<PodcastLocal>> getPodcastLocal(List<String> podcasts,
|
Future<List<PodcastLocal>> getPodcastLocal(List<String> podcasts,
|
||||||
{bool updateOnly = false}) async {
|
{bool updateOnly = false}) async {
|
||||||
var dbClient = await database;
|
var dbClient = await database;
|
||||||
|
@ -254,6 +261,21 @@ class DBHelper {
|
||||||
[boo ? 1 : 0, id]);
|
[boo ? 1 : 0, id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<bool> getHideNewMark(String id) async {
|
||||||
|
var dbClient = await database;
|
||||||
|
List<Map> list = await dbClient
|
||||||
|
.rawQuery('SELECT hide_new_mark FROM PodcastLocal WHERE id = ?', [id]);
|
||||||
|
if (list.isNotEmpty) return list.first['hide_new_mark'] == 1;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<int> saveHideNewMark(String id, {bool boo}) async {
|
||||||
|
var dbClient = await database;
|
||||||
|
return await dbClient.rawUpdate(
|
||||||
|
"UPDATE PodcastLocal SET hide_new_mark = ? WHERE id = ?",
|
||||||
|
[boo ? 1 : 0, id]);
|
||||||
|
}
|
||||||
|
|
||||||
Future<int> getPodcastUpdateCounts(String id) async {
|
Future<int> getPodcastUpdateCounts(String id) async {
|
||||||
var dbClient = await database;
|
var dbClient = await database;
|
||||||
List<Map> list = await dbClient.rawQuery(
|
List<Map> list = await dbClient.rawQuery(
|
||||||
|
@ -682,10 +704,11 @@ class DBHelper {
|
||||||
|
|
||||||
Future<int> updatePodcastRss(PodcastLocal podcastLocal,
|
Future<int> updatePodcastRss(PodcastLocal podcastLocal,
|
||||||
{int removeMark = 0}) async {
|
{int removeMark = 0}) async {
|
||||||
var options = BaseOptions(
|
final options = BaseOptions(
|
||||||
connectTimeout: 20000,
|
connectTimeout: 20000,
|
||||||
receiveTimeout: 20000,
|
receiveTimeout: 20000,
|
||||||
);
|
);
|
||||||
|
final hideNewMark = await getHideNewMark(podcastLocal.id);
|
||||||
try {
|
try {
|
||||||
var response = await Dio(options).get(podcastLocal.rssUrl);
|
var response = await Dio(options).get(podcastLocal.rssUrl);
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
|
@ -728,7 +751,7 @@ class DBHelper {
|
||||||
await txn.rawInsert(
|
await txn.rawInsert(
|
||||||
"""INSERT OR IGNORE INTO Episodes(title, enclosure_url, enclosure_length, pubDate,
|
"""INSERT OR IGNORE INTO Episodes(title, enclosure_url, enclosure_length, pubDate,
|
||||||
description, feed_id, milliseconds, duration, explicit, media_id, chapter_link,
|
description, feed_id, milliseconds, duration, explicit, media_id, chapter_link,
|
||||||
episode_image, is_new) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 1)""",
|
episode_image, is_new) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)""",
|
||||||
[
|
[
|
||||||
title,
|
title,
|
||||||
url,
|
url,
|
||||||
|
@ -741,7 +764,8 @@ class DBHelper {
|
||||||
explicit,
|
explicit,
|
||||||
url,
|
url,
|
||||||
chapter,
|
chapter,
|
||||||
image
|
image,
|
||||||
|
hideNewMark ? 0 : 1
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import 'dart:io';
|
||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:image/image.dart' as img;
|
import 'package:image/image.dart' as img;
|
||||||
|
import 'package:line_icons/line_icons.dart';
|
||||||
import 'package:path_provider/path_provider.dart';
|
import 'package:path_provider/path_provider.dart';
|
||||||
import 'package:permission_handler/permission_handler.dart';
|
import 'package:permission_handler/permission_handler.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
@ -63,6 +64,11 @@ class _PodcastSettingState extends State<PodcastSetting> {
|
||||||
if (mounted) setState(() {});
|
if (mounted) setState(() {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> _setHideNewMark(bool boo) async {
|
||||||
|
await _dbHelper.saveHideNewMark(widget.podcastLocal.id, boo: boo);
|
||||||
|
if (mounted) setState(() {});
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> _saveSkipSecondsStart(int seconds) async {
|
Future<void> _saveSkipSecondsStart(int seconds) async {
|
||||||
await _dbHelper.saveSkipSecondsStart(widget.podcastLocal.id, seconds);
|
await _dbHelper.saveSkipSecondsStart(widget.podcastLocal.id, seconds);
|
||||||
}
|
}
|
||||||
|
@ -79,6 +85,10 @@ class _PodcastSettingState extends State<PodcastSetting> {
|
||||||
return await _dbHelper.getNeverUpdate(id);
|
return await _dbHelper.getNeverUpdate(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<bool> _getHideNewMark(String id) async {
|
||||||
|
return await _dbHelper.getHideNewMark(id);
|
||||||
|
}
|
||||||
|
|
||||||
Future<int> _getSkipSecondStart(String id) async {
|
Future<int> _getSkipSecondStart(String id) async {
|
||||||
return await _dbHelper.getSkipSecondsStart(id);
|
return await _dbHelper.getSkipSecondsStart(id);
|
||||||
}
|
}
|
||||||
|
@ -249,6 +259,27 @@ class _PodcastSettingState extends State<PodcastSetting> {
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
|
FutureBuilder<bool>(
|
||||||
|
future: _getHideNewMark(widget.podcastLocal.id),
|
||||||
|
initialData: false,
|
||||||
|
builder: (context, snapshot) {
|
||||||
|
return ListTile(
|
||||||
|
dense: true,
|
||||||
|
onTap: () => _setHideNewMark(!snapshot.data),
|
||||||
|
title: Row(
|
||||||
|
children: [
|
||||||
|
Icon(LineIcons.eraser, size: 20),
|
||||||
|
SizedBox(width: 20),
|
||||||
|
Text('Always hide new mark', style: textStyle),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
trailing: Transform.scale(
|
||||||
|
scale: 0.8,
|
||||||
|
child:
|
||||||
|
Switch(value: snapshot.data, onChanged: _setHideNewMark),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}),
|
||||||
FutureBuilder<int>(
|
FutureBuilder<int>(
|
||||||
future: _getSkipSecondStart(widget.podcastLocal.id),
|
future: _getSkipSecondStart(widget.podcastLocal.id),
|
||||||
initialData: 0,
|
initialData: 0,
|
||||||
|
|
Loading…
Reference in New Issue