Skip to content

Commit

Permalink
support sanity level
Browse files Browse the repository at this point in the history
  • Loading branch information
Notsfsssf committed Jan 17, 2021
1 parent a8aec7d commit 30654eb
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 7 deletions.
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ android {
applicationId packageName
minSdkVersion 21
targetSdkVersion 30
versionCode 54
versionName "0.3.1X"
versionCode 56
versionName "0.3.2X"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand Down
12 changes: 12 additions & 0 deletions lib/page/platform/platform_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,18 @@ class _PlatformPageState extends State<PlatformPage> {
);
},
),
Observer(
builder: (context) {
return SwitchListTile(
secondary: Icon(Icons.folder_open),
onChanged: (bool value) async {
await userSetting.setOverSanityLevelFolder(value);
},
title: Text("Sanity Single Folder"),
value: userSetting.overSanityLevelFolder,
);
},
),
ListTile(
leading: Icon(Icons.mobile_screen_share),
onTap: () {
Expand Down
14 changes: 9 additions & 5 deletions lib/store/save_store.dart
Original file line number Diff line number Diff line change
Expand Up @@ -217,14 +217,18 @@ abstract class _SaveStoreBase with Store {
}
}

Future<void> saveToGalleryWithUser(
Uint8List uint8list, String userName, int userId, String fileName) async {
Future<void> saveToGalleryWithUser(Uint8List uint8list, String userName,
int userId, int sanityLevel, String fileName) async {
if (Platform.isAndroid) {
try {
String overFileName = fileName;
if (userSetting.singleFolder) {
String name = userName.toLegal();
String id = userId.toString();
fileName = "${name}_$id/$fileName";
fileName = "${name}_$id/$overFileName";
}
if (userSetting.overSanityLevelFolder && sanityLevel > 2) {
fileName = "sanity/$overFileName";
}
if (userSetting.isClearOldFormatFile)
DocumentPlugin.save(uint8list, fileName,
Expand All @@ -245,8 +249,8 @@ abstract class _SaveStoreBase with Store {

Future<void> saveToGallery(
Uint8List uint8list, Illusts illusts, String fileName) async {
saveToGalleryWithUser(
uint8list, illusts.user.name, illusts.user.id, fileName);
saveToGalleryWithUser(uint8list, illusts.user.name, illusts.user.id,
illusts.sanityLevel, fileName);
}

@action
Expand Down
12 changes: 12 additions & 0 deletions lib/store/user_setting.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ abstract class _UserSettingBase with Store {
static const String THEME_MODE_KEY = "theme_mode";
static const String IS_RETURN_AGAIN_TO_EXIT_KEY = "is_return_again_to_exit";
static const String IS_CLEAR_OLD_FORMAT_FILE_KEY = "is_clear_old_format_file";
static const String IS_OVER_SANITY_LEVEL_FOLDER =
"is_over_sanity_level_folder";

@observable
bool isClearOldFormatFile = false;
@observable
Expand Down Expand Up @@ -77,6 +80,8 @@ abstract class _UserSettingBase with Store {
@observable
bool singleFolder = false;
@observable
bool overSanityLevelFolder = false;
@observable
bool hIsNotAllow = false;

@observable
Expand All @@ -89,6 +94,12 @@ abstract class _UserSettingBase with Store {
isClearOldFormatFile = v;
}

@action
setOverSanityLevelFolder(bool v) async {
await prefs.setBool(IS_OVER_SANITY_LEVEL_FOLDER, v);
overSanityLevelFolder = v;
}

@action
setIsReturnAgainToExit(bool value) async {
await prefs.setBool(IS_RETURN_AGAIN_TO_EXIT_KEY, value);
Expand Down Expand Up @@ -165,6 +176,7 @@ abstract class _UserSettingBase with Store {
int themeModeIndex = prefs.getInt(THEME_MODE_KEY) ?? 0;
isReturnAgainToExit = prefs.getBool(IS_RETURN_AGAIN_TO_EXIT_KEY) ?? true;
isClearOldFormatFile = prefs.getBool(IS_CLEAR_OLD_FORMAT_FILE_KEY) ?? false;
overSanityLevelFolder = prefs.getBool(IS_OVER_SANITY_LEVEL_FOLDER) ?? false;
for (var i in ThemeMode.values) {
if (i.index == themeModeIndex) {
this.themeMode = i;
Expand Down

0 comments on commit 30654eb

Please sign in to comment.