master
fengyuecanzhu 3 years ago
parent f8d061236e
commit 638bfd4deb
  1. 3
      .idea/dictionaries/fengyue.xml
  2. 2
      .idea/misc.xml
  3. 3
      app/src/main/java/xyz/fycz/myreader/model/storage/WebDavHelp.kt
  4. 97
      app/src/main/java/xyz/fycz/myreader/ui/activity/MoreSettingActivity.java
  5. 18
      app/src/main/java/xyz/fycz/myreader/ui/fragment/WebDavFragment.java
  6. 3
      app/src/main/java/xyz/fycz/myreader/util/webdav/WebDav.kt
  7. 26
      app/src/main/res/layout/fragment_webdav_setting.xml
  8. 1
      app/src/main/res/values/strings.xml

@ -0,0 +1,3 @@
<component name="ProjectDictionaryState">
<dictionary name="fengyue" />
</component>

@ -4,6 +4,8 @@
<option name="filePathToZoomLevelMap">
<map>
<entry key="..\:/android/FYReader/app/src/main/res/layout/activity_more_setting.xml" value="0.264" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/fingerprint_dialog.xml" value="0.20425724637681159" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/fragment_webdav_setting.xml" value="0.4" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/listview_search_book_item.xml" value="0.22010869565217392" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/view_file_picker.xml" value="0.12132725430597771" />
<entry key="..\:/android/FYReader/app/src/main/res/menu/menu_book.xml" value="0.13703703703703704" />

@ -55,7 +55,8 @@ object WebDavHelp {
try {
if (initWebDav()) {
var files = WebDav(url + "FYReader/").listFiles()
files = files.reversed()
val sortType = SharedPreUtils.getInstance().getInt("sortType")
if (sortType == 0) files = files.reversed()
val max = SharedPreUtils.getInstance().getInt("restoreNum", 30)
for (index: Int in 0 until min(max, files.size)) {
files[index].displayName?.let {

@ -28,11 +28,15 @@ import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import io.reactivex.Single;
import io.reactivex.SingleOnSubscribe;
import io.reactivex.disposables.Disposable;
import xyz.fycz.myreader.R;
import xyz.fycz.myreader.application.App;
import xyz.fycz.myreader.application.SysManager;
import xyz.fycz.myreader.base.BaseActivity;
import xyz.fycz.myreader.base.BaseFragment;
import xyz.fycz.myreader.base.observer.MySingleObserver;
import xyz.fycz.myreader.common.APPCONST;
import xyz.fycz.myreader.databinding.ActivityMoreSettingBinding;
import xyz.fycz.myreader.entity.Setting;
@ -42,6 +46,7 @@ import xyz.fycz.myreader.model.storage.Backup;
import xyz.fycz.myreader.model.storage.BackupRestoreUi;
import xyz.fycz.myreader.model.storage.BackupRestoreUiKt;
import xyz.fycz.myreader.ui.dialog.DialogCreator;
import xyz.fycz.myreader.ui.dialog.LoadingDialog;
import xyz.fycz.myreader.ui.dialog.MultiChoiceDialog;
import xyz.fycz.myreader.ui.dialog.MyAlertDialog;
import xyz.fycz.myreader.ui.fragment.PrivateBooksFragment;
@ -49,6 +54,7 @@ import xyz.fycz.myreader.ui.fragment.WebDavFragment;
import xyz.fycz.myreader.util.SharedPreUtils;
import xyz.fycz.myreader.util.ToastUtils;
import xyz.fycz.myreader.util.utils.FileUtils;
import xyz.fycz.myreader.util.utils.RxUtils;
import static xyz.fycz.myreader.common.APPCONST.BOOK_CACHE_PATH;
@ -495,34 +501,73 @@ public class MoreSettingActivity extends BaseActivity implements SharedPreferenc
binding.rlCatheGap.setOnClickListener(v -> binding.scCatheGap.performClick());
binding.rlDeleteCathe.setOnClickListener(v -> {
final Disposable[] catheDis = new Disposable[2];
LoadingDialog loadingDialog = new LoadingDialog(this,
"正在计算", () -> {
for (Disposable d : catheDis) {
if (d != null) {
d.dispose();
}
}
});
loadingDialog.show();
File catheFile = getCacheDir();
String catheFileSize = FileUtils.getFileSize(FileUtils.getDirSize(catheFile));
Single.create((SingleOnSubscribe<CharSequence[]>) emitter -> {
String catheFileSize = FileUtils.getFileSize(FileUtils.getDirSize(catheFile));
File eCatheFile = new File(BOOK_CACHE_PATH);
String eCatheFileSize;
if (eCatheFile.exists() && eCatheFile.isDirectory()) {
eCatheFileSize = FileUtils.getFileSize(FileUtils.getDirSize(eCatheFile));
} else {
eCatheFileSize = "0";
}
CharSequence[] cathe = {"章节缓存:" + eCatheFileSize, "图片缓存:" + catheFileSize};
emitter.onSuccess(cathe);
}).compose(RxUtils::toSimpleSingle).subscribe(new MySingleObserver<CharSequence[]>() {
@Override
public void onSubscribe(Disposable d) {
catheDis[0] = d;
addDisposable(d);
}
File eCatheFile = new File(BOOK_CACHE_PATH);
String eCatheFileSize;
if (eCatheFile.exists() && eCatheFile.isDirectory()) {
eCatheFileSize = FileUtils.getFileSize(FileUtils.getDirSize(eCatheFile));
} else {
eCatheFileSize = "0";
}
CharSequence[] cathes = {"章节缓存:" + eCatheFileSize, "图片缓存:" + catheFileSize};
boolean[] catheCheck = {true, true};
new MultiChoiceDialog().create(this, "清除缓存", cathes, catheCheck, 2,
(dialog, which) -> {
String tip = "";
if (catheCheck[0]) {
BookService.getInstance().deleteAllBookCathe();
tip += "章节缓存 ";
}
if (catheCheck[1]) {
FileUtils.deleteFile(catheFile.getAbsolutePath());
tip += "图片缓存 ";
}
if (tip.length() > 0) {
tip += "清除成功";
ToastUtils.showSuccess(tip);
}
}, null, null);
@Override
public void onSuccess(@NonNull CharSequence[] cathe) {
loadingDialog.dismiss();
boolean[] catheCheck = {true, true};
new MultiChoiceDialog().create(MoreSettingActivity.this, "清除缓存", cathe, catheCheck, 2,
(dialog, which) -> {
loadingDialog.setmMessage("正在清除");
loadingDialog.show();
Single.create((SingleOnSubscribe<String>) e -> {
String tip = "";
if (catheCheck[0]) {
BookService.getInstance().deleteAllBookCathe();
tip += "章节缓存 ";
}
if (catheCheck[1]) {
FileUtils.deleteFile(catheFile.getAbsolutePath());
tip += "图片缓存 ";
}
e.onSuccess(tip);
}).compose(RxUtils::toSimpleSingle).subscribe(new MySingleObserver<String>() {
@Override
public void onSubscribe(Disposable d) {
catheDis[1] = d;
addDisposable(d);
}
@Override
public void onSuccess(@NonNull String tip) {
loadingDialog.dismiss();
if (tip.length() > 0) {
tip += "清除成功";
ToastUtils.showSuccess(tip);
}
}
});
}, null, null);
}
});
});
}

@ -8,6 +8,9 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.NumberPicker;
import com.kongzue.dialogx.dialogs.BottomMenu;
import com.kongzue.dialogx.interfaces.OnMenuItemClickListener;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
@ -43,6 +46,8 @@ public class WebDavFragment extends BaseFragment {
private String webdavAccount;
private String webdavPassword;
private int restoreNum;
private int sortType;
private String[] sortTypeArr = new String[]{"逆序", "顺序"};
@Override
protected View bindView(LayoutInflater inflater, ViewGroup container) {
@ -57,6 +62,7 @@ public class WebDavFragment extends BaseFragment {
webdavAccount = SharedPreUtils.getInstance().getString("webdavAccount", "");
webdavPassword = SharedPreUtils.getInstance().getString("webdavPassword", "");
restoreNum = SharedPreUtils.getInstance().getInt("restoreNum", 30);
sortType = SharedPreUtils.getInstance().getInt("sortType");
}
@Override
@ -66,6 +72,7 @@ public class WebDavFragment extends BaseFragment {
binding.tvWebdavAccount.setText(StringHelper.isEmpty(webdavAccount) ? "请输入WebDav账号" : webdavAccount);
binding.tvWebdavPassword.setText(StringHelper.isEmpty(webdavPassword) ? "请输入WebDav授权密码" : "************");
binding.tvRestoreNum.setText(getString(R.string.cur_restore_list_num, restoreNum));
binding.tvRestoreSort.setText(sortType == 0 ? sortTypeArr[0] : sortTypeArr[1]);
}
@Override
@ -164,5 +171,16 @@ public class WebDavFragment extends BaseFragment {
}).setNegativeButton("取消", null)
.show();
});
binding.llRestoreSort.setOnClickListener(v -> {
BottomMenu.show(getString(R.string.sort_type), sortTypeArr)
.setSelection(sortType)
.setOnMenuItemClickListener((dialog, text, which) -> {
sortType = which;
SharedPreUtils.getInstance().putInt("sortType", which);
binding.tvRestoreSort.setText(sortType == 0 ? sortTypeArr[0] : sortTypeArr[1]);
return false;
}).setCancelButton(R.string.cancel);
});
}
}

@ -111,8 +111,7 @@ constructor(urlStr: String) {
for (p in propsList) {
requestProps.append("<a:").append(p).append("/>\n")
}
val requestPropsStr: String
requestPropsStr = if (requestProps.toString().isEmpty()) {
val requestPropsStr: String = if (requestProps.toString().isEmpty()) {
DIR.replace("%s", "")
} else {
String.format(DIR, requestProps.toString() + "\n")

@ -127,4 +127,30 @@
android:textColor="@color/textAssist" />
</LinearLayout>
<LinearLayout
android:id="@+id/ll_restore_sort"
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="@drawable/selector_common_bg"
android:orientation="vertical"
android:paddingLeft="20dp"
android:paddingTop="8dp"
android:paddingRight="20dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/sort_type"
android:textColor="@color/textSecondary"
android:textSize="@dimen/text_normal_size" />
<TextView
android:id="@+id/tv_restore_sort"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="5dp"
android:text="@string/sort_type"
android:textColor="@color/textAssist" />
</LinearLayout>
</LinearLayout>

@ -505,6 +505,7 @@
<string name="re_seg">章节内容智能分段</string>
<string name="backup_path">备份路径</string>
<string name="cathe_path">缓存路径</string>
<string name="sort_type">排序方式</string>
<string-array name="reset_screen_time">

Loading…
Cancel
Save