Skip to content

Commit

Permalink
Merge updates
Browse files Browse the repository at this point in the history
  • Loading branch information
nicked committed Mar 30, 2024
2 parents 149e67b + 1a502cd commit 1cf32aa
Show file tree
Hide file tree
Showing 14 changed files with 158 additions and 48 deletions.
4 changes: 3 additions & 1 deletion app/src/main/java/ceui/lisa/activities/RankActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ protected void initView() {
mContext.getString(R.string.r_eighteen),
mContext.getString(R.string.r_eighteen_weekly_rank),
mContext.getString(R.string.r_eighteen_male_rank),
mContext.getString(R.string.r_eighteen_female_rank)
mContext.getString(R.string.r_eighteen_female_rank),
mContext.getString(R.string.r_eighteen_ai_rank),
mContext.getString(R.string.r_eighteen_guro_rank)
};

final String[] CHINESE_TITLES_MANGA = new String[]{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class FragmentRankIllust extends NetListFragment<FragmentBaseListBinding,

private static final String[] API_TITLES = new String[]{"day", "week",
"month", "day_ai", "day_male", "day_female", "week_original", "week_rookie",
"day_r18", "week_r18", "day_male_r18", "day_female_r18"};
"day_r18", "week_r18", "day_male_r18", "day_female_r18", "day_r18_ai", "week_r18g"};
private static final String[] API_TITLES_MANGA = new String[]{"day_manga",
"week_manga", "month_manga", "week_rookie_manga", "day_r18_manga"};

Expand Down
17 changes: 17 additions & 0 deletions app/src/main/java/ceui/lisa/fragments/FragmentSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,23 @@ public void onClick(View v) {
}
});

// AI作品下载至单独的目录
baseBind.aiDivideSave.setChecked(Shaft.sSettings.isAIDivideSave());
baseBind.aiDivideSave.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Shaft.sSettings.setAIDivideSave(isChecked);
Common.showToast(getString(R.string.string_428));
Local.setSettings(Shaft.sSettings);
}
});
baseBind.aiDivideSaveRela.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
baseBind.aiDivideSave.performClick();
}
});

// 自定义下载文件名
baseBind.fileNameRela.setOnClickListener(new View.OnClickListener() {
@Override
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/java/ceui/lisa/fragments/FragmentViewPager.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,15 @@ public void onPageScrollStateChanged(int state) {
Shaft.getContext().getString(R.string.r_eighteen_weekly_rank),
Shaft.getContext().getString(R.string.r_eighteen_male_rank),
Shaft.getContext().getString(R.string.r_eighteen_female_rank),
Shaft.getContext().getString(R.string.r_eighteen_ai_rank)
};
mFragments = new ListFragment[]{
// FragmentRankIllust.newInstance(7, "", false),
FragmentRankIllust.newInstance(8, "", false),
FragmentRankIllust.newInstance(9, "", false),
FragmentRankIllust.newInstance(10, "", false),
FragmentRankIllust.newInstance(11, "", false)
FragmentRankIllust.newInstance(11, "", false),
FragmentRankIllust.newInstance(12, "", false)
};
baseBind.toolbarTitle.setText(R.string.string_r);
baseBind.viewPager.setAdapter(new FragmentPagerAdapter(getChildFragmentManager()) {
Expand Down
53 changes: 47 additions & 6 deletions app/src/main/java/ceui/lisa/helper/FileStorageHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,40 @@ public static String getIllustFileRelativeNameQ(DownloadItem downloadItem) {
}

public static String getIllustFileSAFFullName(String id, IllustsBean illustsBean, String fileName){
return id + getShaftIllustPathPartWithInnerR18Folder(illustsBean) + getAuthorPathPart(illustsBean) + File.separator + fileName;
String fullName = id;
if (isSaveToAIDir(illustsBean)) {
fullName += getShaftIllustPathPartWithInnerAIFolder(illustsBean);
} else if (isSaveToR18Dir(illustsBean)) {
fullName += getShaftIllustPathPartWithInnerR18Folder(illustsBean);
}
fullName += getAuthorPathPart(illustsBean) + File.separator + fileName;
return fullName;
}

public static String getIllustAbsolutePath(IllustsBean illustsBean){
return PathUtils.getExternalPicturesPath() + sep + getShaftIllustDirWithInnerR18Folder(isSaveToR18Dir(illustsBean)) + getAuthorPathPart(illustsBean);
String absolutePath = PathUtils.getExternalPicturesPath() + sep;
if (isSaveToAIDir(illustsBean)) {
absolutePath += getShaftIllustDirWithInnerAIFolder(true);
} else if (isSaveToR18Dir(illustsBean)) {
absolutePath += getShaftIllustDirWithInnerR18Folder(true);
}
absolutePath += getAuthorPathPart(illustsBean);
return absolutePath;
}

public static String getIllustAbsolutePath(IllustsBean illustsBean, boolean isR18){
return PathUtils.getExternalPicturesPath() + sep + getShaftIllustDirWithInnerR18Folder(isR18) + getAuthorPathPart(illustsBean);
}
// public static String getIllustAbsolutePath(IllustsBean illustsBean, boolean isR18){
// return PathUtils.getExternalPicturesPath() + sep + getShaftIllustDirWithInnerR18Folder(isR18) + getAuthorPathPart(illustsBean);
// }

public static String getIllustRelativePathQ(IllustsBean illustsBean) {
return Environment.DIRECTORY_PICTURES + sep + getShaftIllustDirWithInnerR18Folder(isSaveToR18Dir(illustsBean)) + getAuthorPathPart(illustsBean);
String relativePath = Environment.DIRECTORY_PICTURES + sep;
if (isSaveToAIDir(illustsBean)) {
relativePath += getShaftIllustDirWithInnerAIFolder(true);
} else if (isSaveToR18Dir(illustsBean)) {
relativePath += getShaftIllustDirWithInnerR18Folder(true);
}
relativePath += getAuthorPathPart(illustsBean);
return relativePath;
}

public static String getNovelRelativePathQ() {
Expand Down Expand Up @@ -75,6 +96,26 @@ private static boolean isSaveToR18Dir(IllustsBean illustsBean){
return illustsBean.isR18File() && Shaft.sSettings.isR18DivideSave();
}

public static String getShaftIllustAIDirNameWithInnerAIFolder(IllustsBean illustsBean) {
return isSaveToAIDir(illustsBean) ? "ShaftImages-AI" : "";
}

public static String getShaftIllustPathPartWithInnerAIFolder(IllustsBean illustsBean) {
return getShaftIllustPathPartWithInnerAIFolder(isSaveToAIDir(illustsBean));
}

public static String getShaftIllustPathPartWithInnerAIFolder(boolean isAI) {
return isAI ? sep + "ShaftImages-AI" : "";
}

public static String getShaftIllustDirWithInnerAIFolder(boolean isAI) {
return "ShaftImages" + getShaftIllustPathPartWithInnerAIFolder(isAI);
}

private static boolean isSaveToAIDir(IllustsBean illustsBean){
return illustsBean.isCreatedByAI() && Shaft.sSettings.isAIDivideSave();
}

private static String getAuthorPathPart(IllustsBean illustsBean) {
String name = getAuthorDirectoryName(illustsBean.getUser());
return name.length() > 0 ? sep + name : name;
Expand Down
11 changes: 11 additions & 0 deletions app/src/main/java/ceui/lisa/utils/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ public void setCurrentProgress(long currentProgress) {

private boolean r18DivideSave = false;

//AI作品下载至单独的目录
private boolean AIDivideSave = false;


//在我的收藏列表,隐藏收藏按钮,默认显示
private boolean hideStarButtonAtMyCollection = false;
Expand Down Expand Up @@ -217,6 +220,14 @@ public void setR18DivideSave(boolean r18DivideSave) {
this.r18DivideSave = r18DivideSave;
}

public boolean isAIDivideSave() {
return AIDivideSave;
}

public void setAIDivideSave(boolean AIDivideSave) {
this.AIDivideSave = AIDivideSave;
}

public String getRootPathUri() {
return rootPathUri;
}
Expand Down
16 changes: 16 additions & 0 deletions app/src/main/res/layout/fragment_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,22 @@

<View style="@style/half_divider" />

<RelativeLayout
android:id="@+id/ai_divide_save_rela"
style="@style/ripple_rela">

<TextView
style="@style/setting_text_left_and_center"
android:text="@string/string_455" />

<androidx.appcompat.widget.SwitchCompat
android:id="@+id/ai_divide_save"
style="@style/setting_right_switch"/>

</RelativeLayout>

<View style="@style/half_divider" />

<RelativeLayout
android:id="@+id/file_name_rela"
style="@style/ripple_rela">
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values-en/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,8 @@
<string name="r_eighteen_weekly_rank">This week R</string>
<string name="r_eighteen_male_rank">Male r</string>
<string name="r_eighteen_female_rank">Female r</string>
<string name="r_eighteen_ai_rank">AI Generated R</string>
<string name="r_eighteen_guro_rank">This week G</string>
<string name="string_331">Using pixivcat agent</string>
<string name="string_332">The secondary details page displays the original picture</string>
<string name="string_333">Speed up the loading of pictures. If you think the loading is slow, you can close it</string>
Expand Down Expand Up @@ -604,6 +606,7 @@
<string name="string_452">Download limit type</string>
<string name="string_453">Do not auto start</string>
<string name="string_454">Share first image</string>
<string name="string_455">AI works download to another directory</string>
<string name="refresh">Refresh</string>
<string name="now_loading">Loading…</string>
<string name="retry">Retry</string>
Expand Down
Loading

0 comments on commit 1cf32aa

Please sign in to comment.