Skip to content
This repository has been archived by the owner on Sep 25, 2021. It is now read-only.

#683, Add thread folders #684

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ public String getKey() {
public static final BooleanSetting neverHideToolbar;
public static final BooleanSetting controllerSwipeable;
public static final BooleanSetting saveBoardFolder;
public static final BooleanSetting saveThreadFolder;
public static final BooleanSetting videoDefaultMuted;
public static final BooleanSetting videoAutoLoop;

Expand Down Expand Up @@ -214,6 +215,7 @@ public String getKey() {
neverHideToolbar = new BooleanSetting(p, "preference_never_hide_toolbar", false);
controllerSwipeable = new BooleanSetting(p, "preference_controller_swipeable", true);
saveBoardFolder = new BooleanSetting(p, "preference_save_subboard", false);
saveThreadFolder = new BooleanSetting(p, "preference_save_subthread", false);
videoDefaultMuted = new BooleanSetting(p, "preference_video_default_muted", true);
videoAutoLoop = new BooleanSetting(p, "preference_video_loop", true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,25 @@ private void saveShare(boolean share, PostImage postImage) {
ImageSaveTask task = new ImageSaveTask(postImage);
task.setShare(share);
if (ChanSettings.saveBoardFolder.get()) {
task.setSubFolder(presenter.getLoadable().site.name() +
File.separator +
presenter.getLoadable().boardCode);
String subFolderName =
presenter.getLoadable().site.name() +
File.separator +
presenter.getLoadable().boardCode;
if (ChanSettings.saveThreadFolder.get()) {
//save to op no appended with the first 50 characters of the subject
//should be unique and perfectly understandable title wise
subFolderName = subFolderName +
File.separator +
presenter.getLoadable().no +
"_";
String tempTitle = presenter.getLoadable().title
.toLowerCase()
.replaceAll(" ", "_")
.replaceAll("[^a-z0-9_]", "");
tempTitle = tempTitle.substring(0, Math.min(tempTitle.length(), 50));
subFolderName = subFolderName + tempTitle;
}
task.setSubFolder(subFolderName);
}
ImageSaver.getInstance().startDownloadTask(context, task);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@

public class MediaSettingsController extends SettingsController {
// Special setting views
private BooleanSettingView boardFolderSetting;
private BooleanSettingView threadFolderSetting;
private LinkSettingView saveLocation;
private ListSettingView<ChanSettings.MediaAutoLoadMode> imageAutoLoadView;
private ListSettingView<ChanSettings.MediaAutoLoadMode> videoAutoLoadView;
Expand All @@ -60,6 +62,8 @@ public void onCreate() {
buildPreferences();

onPreferenceChange(imageAutoLoadView);

threadFolderSetting.setEnabled(ChanSettings.saveBoardFolder.get());
}

@Override
Expand All @@ -75,6 +79,8 @@ public void onPreferenceChange(SettingView item) {

if (item == imageAutoLoadView) {
updateVideoLoadModes();
} else if (item == boardFolderSetting) {
updateThreadFolderSetting();
}
}

Expand All @@ -91,11 +97,16 @@ private void populatePreferences() {

setupSaveLocationSetting(media);

media.add(new BooleanSettingView(this,
boardFolderSetting = (BooleanSettingView) media.add(new BooleanSettingView(this,
ChanSettings.saveBoardFolder,
R.string.setting_save_board_folder,
R.string.setting_save_board_folder_description));

threadFolderSetting = (BooleanSettingView) media.add(new BooleanSettingView(this,
ChanSettings.saveThreadFolder,
R.string.setting_save_thread_folder,
R.string.setting_save_thread_folder_description));

media.add(new BooleanSettingView(this,
ChanSettings.saveOriginalFilename,
R.string.setting_save_original_filename,
Expand Down Expand Up @@ -206,4 +217,16 @@ private void setupSaveLocationSetting(SettingsGroup media) {
private void updateSaveLocationSetting() {
saveLocation.setDescription(ChanSettings.saveLocation.get());
}

private void updateThreadFolderSetting() {
if (ChanSettings.saveBoardFolder.get()) {
threadFolderSetting.setEnabled(true);
} else if (!ChanSettings.saveBoardFolder.get()) {
if (ChanSettings.saveThreadFolder.get()) {
threadFolderSetting.onClick(threadFolderSetting.view);
}
threadFolderSetting.setEnabled(false);
ChanSettings.saveThreadFolder.set(false);
}
}
}
6 changes: 4 additions & 2 deletions Clover/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -500,8 +500,10 @@ Crash reports do not collect any personally identifiable information."
<!-- Media general group -->
<string name="settings_group_media">Media</string>

<string name="setting_save_board_folder">Save images in a board folder</string>
<string name="setting_save_board_folder_description">Create a folder for each board to store images in</string>
<string name="setting_save_board_folder">Save images in board folders</string>
<string name="setting_save_board_folder_description">Create a folder for each board when saving</string>
<string name="setting_save_thread_folder">Save images in thread folders</string>
<string name="setting_save_thread_folder_description">Create a folder for each thread when saving</string>
<string name="setting_save_original_filename">Save original filename</string>
<string name="setting_save_original_filename_description">
"Save the image with the filename the site assigned.
Expand Down