Skip to content

Commit

Permalink
AI mute
Browse files Browse the repository at this point in the history
  • Loading branch information
Notsfsssf committed Feb 13, 2023
1 parent e30e0c1 commit b74b742
Show file tree
Hide file tree
Showing 24 changed files with 288 additions and 61 deletions.
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ android {
applicationId packageName
minSdkVersion 21
targetSdkVersion 33
versionCode 10009130
versionName "0.9.13 widget"
versionCode 10009140
versionName "0.9.14 ai"
ndk { abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86_64' }
}
compileOptions {
Expand Down
2 changes: 1 addition & 1 deletion lib/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

class Constants {
static String tagName = "0.9.13";
static String tagName = "0.9.14";
static const isGooglePlay =
bool.fromEnvironment("IS_GOOGLEPLAY", defaultValue: false);
static int type = 0;
Expand Down
8 changes: 7 additions & 1 deletion lib/exts.dart
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,13 @@ extension NovelExts on Novel {
}

extension IllustExts on Illusts {
bool hateByUser() {
bool hateByUser({bool ai = false}) {
if (ai) {
return false;
}
if (muteStore.banAIIllust && illustAIType == 2) {
return true;
}
for (var t in muteStore.banTags) {
for (var f in this.tags) {
if (f.name == t.name) return true;
Expand Down
6 changes: 5 additions & 1 deletion lib/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -251,5 +251,9 @@
"share_info_format": "Share info format",
"account_deletion": "account_deletion",
"account_deletion_subtitle": "This will log you out of your account and go to the webpage to delete your account",
"private_like_by_default": "Private like by default"
"private_like_by_default": "Private like by default",
"partially_hidden": "partially hidden",
"show": "show",
"ai_work_display_settings" : "AI generated works display settings",
"make_works_with_ai_generated_flags_invisible": "Make works with AI generated flags invisible"
}
6 changes: 5 additions & 1 deletion lib/l10n/intl_en_US.arb
Original file line number Diff line number Diff line change
Expand Up @@ -260,5 +260,9 @@
"share_info_format": "Share info format",
"account_deletion": "account_deletion",
"account_deletion_subtitle": "This will log you out of your account and go to the webpage to delete your account",
"private_like_by_default": "Private like by default"
"private_like_by_default": "Private like by default",
"partially_hidden": "partially hidden",
"show": "show",
"ai_work_display_settings" : "AI generated works display settings",
"make_works_with_ai_generated_flags_invisible": "Make works with AI generated flags invisible"
}
6 changes: 5 additions & 1 deletion lib/l10n/intl_es.arb
Original file line number Diff line number Diff line change
Expand Up @@ -251,5 +251,9 @@
"share_info_format": "Share info format",
"account_deletion": "account_deletion",
"account_deletion_subtitle": "This will log you out of your account and go to the webpage to delete your account",
"private_like_by_default": "Private like by default"
"private_like_by_default": "Private like by default",
"partially_hidden": "partially hidden",
"show": "show",
"ai_work_display_settings" : "AI generated works display settings",
"make_works_with_ai_generated_flags_invisible": "Make works with AI generated flags invisible"
}
6 changes: 5 additions & 1 deletion lib/l10n/intl_ja.arb
Original file line number Diff line number Diff line change
Expand Up @@ -260,5 +260,9 @@
"share_info_format": "シェアする詳細情報の形式",
"account_deletion": "アカウントの削除",
"account_deletion_subtitle": "アカウントからログアウトし、Pixivの退会ページに移動します。",
"private_like_by_default": "Private like by default"
"private_like_by_default": "Private like by default",
"partially_hidden": "partially hidden",
"show": "show",
"ai_work_display_settings" : "AI generated works display settings",
"make_works_with_ai_generated_flags_invisible": "Make works with AI generated flags invisible"
}
6 changes: 5 additions & 1 deletion lib/l10n/intl_ko.arb
Original file line number Diff line number Diff line change
Expand Up @@ -260,5 +260,9 @@
"share_info_format": "공유 정보 양식",
"account_deletion": "계정 삭제",
"account_deletion_subtitle": "앱에서 로그아웃한 후에 계정 삭제 페이지를 엽니다",
"private_like_by_default": "Private like by default"
"private_like_by_default": "Private like by default",
"partially_hidden": "partially hidden",
"show": "show",
"ai_work_display_settings" : "AI generated works display settings",
"make_works_with_ai_generated_flags_invisible": "Make works with AI generated flags invisible"
}
6 changes: 5 additions & 1 deletion lib/l10n/intl_ru.arb
Original file line number Diff line number Diff line change
Expand Up @@ -260,5 +260,9 @@
"share_info_format": "Share info format",
"account_deletion": "account_deletion",
"account_deletion_subtitle": "This will log you out of your account and go to the webpage to delete your account",
"private_like_by_default": "Private like by default"
"private_like_by_default": "Private like by default",
"partially_hidden": "partially hidden",
"show": "show",
"ai_work_display_settings" : "AI generated works display settings",
"make_works_with_ai_generated_flags_invisible": "Make works with AI generated flags invisible"
}
6 changes: 5 additions & 1 deletion lib/l10n/intl_tr.arb
Original file line number Diff line number Diff line change
Expand Up @@ -260,5 +260,9 @@
"share_info_format": "Bilgi paylaşma biçimi",
"account_deletion": "hesap_silme",
"account_deletion_subtitle": "Bu işlem hesabınızdan çıkış yapacak ve hesap silme web sayfasına yönlendirecektir",
"private_like_by_default": "Varsayılan olarak gizli yer imlerine kaydet"
"private_like_by_default": "Varsayılan olarak gizli yer imlerine kaydet",
"partially_hidden": "partially hidden",
"show": "show",
"ai_work_display_settings" : "AI generated works display settings",
"make_works_with_ai_generated_flags_invisible": "Make works with AI generated flags invisible"
}
6 changes: 5 additions & 1 deletion lib/l10n/intl_zh.arb
Original file line number Diff line number Diff line change
Expand Up @@ -260,5 +260,9 @@
"share_info_format": "分享信息格式",
"account_deletion": "注销账号",
"account_deletion_subtitle": "这将会登出账号然后前往网页进行账号注销",
"private_like_by_default": "默认私密收藏"
"private_like_by_default": "默认私密收藏",
"partially_hidden": "部分隐藏",
"show": "显示",
"ai_work_display_settings" : "AI生成作品显示设置",
"make_works_with_ai_generated_flags_invisible": "使带有AI生成标记的作品不可见"
}
6 changes: 5 additions & 1 deletion lib/l10n/intl_zh_CN.arb
Original file line number Diff line number Diff line change
Expand Up @@ -260,5 +260,9 @@
"share_info_format": "分享信息格式",
"account_deletion": "注销账号",
"account_deletion_subtitle": "这将会登出账号然后前往网页进行账号注销",
"private_like_by_default": "默认私密收藏"
"private_like_by_default": "默认私密收藏",
"partially_hidden": "部分隐藏",
"show": "显示",
"ai_work_display_settings" : "AI生成作品显示设置",
"make_works_with_ai_generated_flags_invisible": "使带有AI生成标记的作品不可见"
}
6 changes: 5 additions & 1 deletion lib/l10n/intl_zh_TW.arb
Original file line number Diff line number Diff line change
Expand Up @@ -260,5 +260,9 @@
"share_info_format": "資訊分享格式",
"account_deletion": "註銷帳戶",
"account_deletion_subtitle": "這將會登出帳戶並前往網頁進行帳戶註銷",
"private_like_by_default": "默認私密收藏"
"private_like_by_default": "默認私密收藏",
"partially_hidden": "部分隱藏",
"show": "顯示",
"ai_work_display_settings" : "AI生成作品顯示設置",
"make_works_with_ai_generated_flags_invisible": "使帶有AI生成標記的作品不可見"
}
12 changes: 9 additions & 3 deletions lib/lighting/lighting_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,16 @@ class LightingList extends StatefulWidget {
final bool? isNested;
final ScrollController? scrollController;
final String? portal;
final bool? ai;

const LightingList(
{Key? key,
required this.source,
this.header,
this.isNested,
this.scrollController,
this.portal})
this.portal,
this.ai})
: super(key: key);

@override
Expand All @@ -69,6 +71,7 @@ class _LightingListState extends State<LightingList> {
late LightingStore _store;
late bool _isNested;
late ScrollController _scrollController;
late bool _ai;

@override
void didUpdateWidget(LightingList oldWidget) {
Expand All @@ -90,6 +93,7 @@ class _LightingListState extends State<LightingList> {

@override
void initState() {
_ai = widget.ai ?? false;
_isNested = widget.isNested ?? false;
_scrollController = widget.scrollController ?? ScrollController();
_refreshController = EasyRefreshController(
Expand Down Expand Up @@ -126,7 +130,8 @@ class _LightingListState extends State<LightingList> {
late EasyRefreshController _refreshController;

Widget _buildWithoutHeader(context) {
_store.iStores.removeWhere((element) => element.illusts!.hateByUser());
_store.iStores
.removeWhere((element) => element.illusts!.hateByUser(ai: _ai));
return NotificationListener<ScrollNotification>(
onNotification: (ScrollNotification notification) {
if (widget.isNested == true) {
Expand Down Expand Up @@ -267,7 +272,8 @@ class _LightingListState extends State<LightingList> {

SliverChildBuilderDelegate _buildSliverChildBuilderDelegate(
BuildContext context) {
_store.iStores.removeWhere((element) => element.illusts!.hateByUser());
_store.iStores
.removeWhere((element) => element.illusts!.hateByUser(ai: _ai));
return SliverChildBuilderDelegate((BuildContext context, int index) {
return IllustCard(
store: _store.iStores[index],
Expand Down
1 change: 1 addition & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
userSetting.init();
accountStore.fetch();
bookTagStore.init();
muteStore.fetchBanAI();
muteStore.fetchBanUserIds();
muteStore.fetchBanIllusts();
muteStore.fetchBanTags();
Expand Down
18 changes: 18 additions & 0 deletions lib/models/show_ai_response.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import 'package:json_annotation/json_annotation.dart';

part 'show_ai_response.g.dart';

@JsonSerializable()
class ShowAIResponse {
@JsonKey(name: 'show_ai')
bool showAI;

ShowAIResponse({
required this.showAI,
});

factory ShowAIResponse.fromJson(Map<String, dynamic> json) =>
_$ShowAIResponseFromJson(json);

Map<String, dynamic> toJson() => _$ShowAIResponseToJson(this);
}
28 changes: 22 additions & 6 deletions lib/models/task_persist.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class TaskPersist {
String fileName;
String title;
String url;
String? medium;
int userId;
int illustId;
int sanityLevel;
Expand All @@ -37,6 +38,7 @@ class TaskPersist {
required this.fileName,
this.sanityLevel = 0,
this.id,
this.medium,
required this.status});

factory TaskPersist.fromJson(Map<String, dynamic> json) {
Expand All @@ -49,7 +51,8 @@ class TaskPersist {
sanityLevel: json[columnSanityLevel],
illustId: json[columnIllustId],
status: json[columnStatus],
fileName: json[columnFileName]);
fileName: json[columnFileName],
medium: json[columnMedium]);
}

Map<String, dynamic> toJson() {
Expand Down Expand Up @@ -78,7 +81,8 @@ class TaskPersist {
id: this.illustId,
title: this.title,
type: 'type',
imageUrls: ImageUrls(squareMedium: '', medium: '', large: ''),
imageUrls:
ImageUrls(squareMedium: '', medium: this.medium ?? '', large: ''),
caption: 'caption',
restrict: 0,
user: user2,
Expand Down Expand Up @@ -115,6 +119,7 @@ final String columnIllustId = 'illust_id';
final String columnUserId = 'user_id';
final String columnStatus = 'status';
final String columnFileName = 'file_name';
final String columnMedium = 'medium';
final String columnSanityLevel = 'sanity_level';

class TaskPersistProvider {
Expand All @@ -124,7 +129,7 @@ class TaskPersistProvider {
String databasesPath = (await getDatabasesPath());
String path =
join(databasesPath, 'task1.db'); //某个版本出的bug,升级table无法定位问题,只能改了
db = await openDatabase(path, version: 1,
db = await openDatabase(path, version: 2,
onCreate: (Database db, int version) async {
await db.execute('''
create table $tableAccount (
Expand All @@ -136,9 +141,17 @@ create table $tableAccount (
$columnIllustId integer not null,
$columnUserId integer not null,
$columnStatus integer not null,
$columnFileName text not null
$columnFileName text not null,
$columnMedium text
)
''');
}, onUpgrade: (Database db, int oldVersion, int newVersion) async {
if (oldVersion == 1 && newVersion == 2) {
await db.execute('''
ALTER TABLE $tableAccount
ADD $columnMedium text;
''');
}
});
}

Expand All @@ -160,7 +173,8 @@ create table $tableAccount (
columnSanityLevel,
columnUserName,
columnUrl,
columnStatus
columnStatus,
columnMedium
],
where: '$columnUrl = ?',
whereArgs: [id]);
Expand Down Expand Up @@ -198,6 +212,7 @@ create table $tableAccount (
firstWhere.status = todo.status;
firstWhere.userId = todo.userId;
firstWhere.userName = todo.userName;
firstWhere.medium = todo.medium;
} catch (e) {}

return result;
Expand All @@ -215,7 +230,8 @@ create table $tableAccount (
columnUrl,
columnFileName,
columnSanityLevel,
columnStatus
columnStatus,
columnMedium
],
orderBy: "${columnId} ASC",
);
Expand Down
11 changes: 11 additions & 0 deletions lib/network/api_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -590,4 +590,15 @@ class ApiClient {
final result = await httpClient.get(previewUrl);
return result;
}

Future<Response> getUserAISettings() async {
final result = await httpClient.get('/v1/user/ai-show-settings');
return result;
}

Future<Response> postUserAIShowSettings(bool show) async {
return httpClient.post('/v1/user/ai-show-settings/edit',
data: notNullMap({"show_ai": show}),
options: Options(contentType: Headers.formUrlEncodedContentType));
}
}
13 changes: 9 additions & 4 deletions lib/page/hello/ranking/ranking_mode/rank_mode_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ class RankModePage extends StatefulWidget {
class _RankModePageState extends State<RankModePage> {
late ScrollController _scrollController;
late StreamSubscription<String> subscription;
var list = [
"day_ai",
"day_r18_ai",
];

@override
void dispose() {
Expand All @@ -59,11 +63,12 @@ class _RankModePageState extends State<RankModePage> {
@override
Widget build(BuildContext context) {
return LightingList(
scrollController: _scrollController,
source: ApiForceSource(
scrollController: _scrollController,
source: ApiForceSource(
futureGet: (e) =>
apiClient.getIllustRanking(widget.mode!, widget.date, force: e),
glanceKey: "rank"),
);
glanceKey: "rank",
),
ai: list.contains(widget.mode ?? ""));
}
}
Loading

0 comments on commit b74b742

Please sign in to comment.