pull/5/head
fengyuecanzhu 4 years ago
parent ab7c1b6893
commit 72df439168
  1. 5
      app/src/main/assets/updatelog.fy
  2. 34
      app/src/main/java/xyz/fycz/myreader/common/APPCONST.java
  3. 5
      app/src/main/java/xyz/fycz/myreader/ui/activity/ReadActivity.java
  4. 13
      app/src/main/java/xyz/fycz/myreader/ui/activity/ReplaceRuleActivity.java
  5. 13
      app/src/main/java/xyz/fycz/myreader/ui/adapter/BookcaseAdapter.java
  6. 6
      app/src/main/java/xyz/fycz/myreader/ui/adapter/FontsAdapter.java
  7. 16
      app/src/main/java/xyz/fycz/myreader/ui/fragment/DIYSourceFragment.java
  8. 5
      app/src/main/java/xyz/fycz/myreader/ui/fragment/MineFragment.java
  9. 18
      app/src/main/java/xyz/fycz/myreader/ui/popmenu/CustomizeLayoutMenu.java
  10. 1
      app/src/main/java/xyz/fycz/myreader/util/help/JsExtensions.java
  11. 8
      app/src/main/java/xyz/fycz/myreader/util/utils/ShareBookUtil.java
  12. 54
      app/src/main/java/xyz/fycz/myreader/util/utils/StoragePermissionUtils.java

@ -1,4 +1,9 @@
2021.06.06
风月读书v2.1.1
更新内容:
1、修复阅读界面日夜间切换后底部对话框不显示的bug
2、修复存储bug
风月读书v2.1.0
更新内容:
1、储存优化

@ -29,30 +29,20 @@ public class APPCONST {
Permission.READ_EXTERNAL_STORAGE};
public static final String FILE_DIR = Environment.getExternalStorageDirectory() + "/FYReader/";
public static String TXT_BOOK_DIR = Environment.getExternalStorageDirectory().getAbsolutePath() + "/FYReader/noveltxt/";
public static String SHARE_FILE_DIR = (hasStoragePermission() ?
Environment.getExternalStorageDirectory().getAbsolutePath() :
FileUtils.getDataDir()) + "/FYReader/share/";
public static String LOG_DIR = (hasStoragePermission() ?
Environment.getExternalStorageDirectory().getAbsolutePath() :
FileUtils.getDataDir()) + "/FYReader/log/";
public static String BG_FILE_DIR = (hasStoragePermission() ?
Environment.getExternalStorageDirectory().getAbsolutePath() :
FileUtils.getDataDir()) + "/FYReader/bg/";
public static String TEM_FILE_DIR = (hasStoragePermission() ?
Environment.getExternalStorageDirectory().getAbsolutePath() :
FileUtils.getDataDir()) + "/FYReader/tem/";
public static String BACKUP_FILE_DIR = (hasStoragePermission() ?
Environment.getExternalStorageDirectory().getAbsolutePath() :
FileUtils.getDataDir()) + "/FYReader/backup/";
public static String FONT_BOOK_DIR = (hasStoragePermission() ?
Environment.getExternalStorageDirectory().getAbsolutePath() :
FileUtils.getDataDir()) + "/FYReader/font/";
public static String QQ_DATA_DIR = Environment.getExternalStorageDirectory() + "/tencent/MobileQQ/data/";
public static final String SHARE_FILE_DIR = Environment.getExternalStorageDirectory() + "/FYReader/share/";
public static String LOG_DIR = FileUtils.getCachePath() + "/log/";
public static final String BG_FILE_DIR = Environment.getExternalStorageDirectory() + "/FYReader/bg/";
public static String TEM_FILE_DIR = FileUtils.getCachePath() + "/tem/";
public static final String BACKUP_FILE_DIR = Environment.getExternalStorageDirectory() + "/FYReader/backup/";
public static final String TXT_BOOK_DIR = Environment.getExternalStorageDirectory() + "/FYReader/noveltxt/";
public static final String FONT_BOOK_DIR = Environment.getExternalStorageDirectory() + "/FYReader/font/";
public static final String UPDATE_APK_FILE_DIR = Environment.getExternalStorageDirectory() + "/FYReader/apk/";
public static final String QQ_DATA_DIR = Environment.getExternalStorageDirectory() + "/tencent/MobileQQ/data/";
//BookCachePath (因为getCachePath引用了Context,所以必须是静态变量,不能够是静态常量)
public static String BOOK_CACHE_PATH = FileUtils.getCachePath() + File.separator
+ "book_cache" + File.separator;
+ "book_cache"+ File.separator ;
public static String HTML_CACHE_PATH = FileUtils.getCachePath() + File.separator
+ "html_cache"+ File.separator ;
public static long exitTime;
public static final int exitConfirmTime = 2000;

@ -1475,7 +1475,10 @@ public class ReadActivity extends BaseActivity implements ColorPickerDialogListe
SysManager.saveSetting(mSetting);
App.getApplication().setNightTheme(isNight);
mHandler.postDelayed(() -> {
BaseDialog.initActivityContext(ActivityManage.getByClass(this.getClass()));
AppCompatActivity activity = ActivityManage.getByClass(this.getClass());
if (activity != null) {
BaseDialog.initActivityContext(activity);
}
}, 1000);
//mPageLoader.setPageStyle(!isCurDayStyle);
}

@ -47,6 +47,7 @@ import xyz.fycz.myreader.util.ToastUtils;
import xyz.fycz.myreader.util.utils.ClipBoardUtil;
import xyz.fycz.myreader.util.utils.FileUtils;
import xyz.fycz.myreader.util.utils.GsonExtensionsKt;
import xyz.fycz.myreader.util.utils.StoragePermissionUtils;
import xyz.fycz.myreader.widget.DividerItemDecoration;
import xyz.fycz.myreader.widget.swipemenu.SwipeMenuLayout;
@ -246,22 +247,12 @@ public class ReplaceRuleActivity extends BaseActivity {
ToastUtils.showWarring("当前没有任何规则,无法导出!");
return true;
}
XXPermissions.with(this)
.permission(APPCONST.STORAGE_PERMISSIONS)
.request(new OnPermissionCallback() {
@Override
public void onGranted(List<String> permissions, boolean all) {
StoragePermissionUtils.request(this, (permissions, all) -> {
if (FileUtils.writeText(GsonExtensionsKt.getGSON().toJson(mReplaceRules),
FileUtils.getFile(APPCONST.FILE_DIR + "ReplaceRule.json"))) {
DialogCreator.createTipDialog(ReplaceRuleActivity.this,
"内容替换规则导出成功,导出位置:" + APPCONST.FILE_DIR + "ReplaceRule.json");
}
}
@Override
public void onDenied(List<String> permissions, boolean never) {
ToastUtils.showWarring("没有储存权限!");
}
});
} else if (itemId == R.id.action_reverse) {
for (ReplaceRuleBean ruleBean : mReplaceRules) {

@ -51,6 +51,7 @@ import xyz.fycz.myreader.ui.dialog.SourceExchangeDialog;
import xyz.fycz.myreader.util.help.StringHelper;
import xyz.fycz.myreader.util.utils.RxUtils;
import xyz.fycz.myreader.util.utils.ShareBookUtil;
import xyz.fycz.myreader.util.utils.StoragePermissionUtils;
import xyz.fycz.myreader.webapi.crawler.ReadCrawlerUtil;
import xyz.fycz.myreader.webapi.crawler.base.ReadCrawler;
import xyz.fycz.myreader.widget.CoverImageView;
@ -452,22 +453,12 @@ public abstract class BookcaseAdapter extends RecyclerView.Adapter<BookcaseAdapt
tvExport.setOnClickListener(v -> {
dialog.dismiss();
Single.create((SingleOnSubscribe<Boolean>) emitter -> {
XXPermissions.with(mContext)
.permission(APPCONST.STORAGE_PERMISSIONS)
.request(new OnPermissionCallback() {
@Override
public void onGranted(List<String> permissions, boolean all) {
StoragePermissionUtils.request(mContext, (permissions, all) -> {
try {
emitter.onSuccess(unionChapterCathe(mBook));
} catch (IOException e) {
emitter.onError(e);
}
}
@Override
public void onDenied(List<String> permissions, boolean never) {
ToastUtils.showWarring("没有储存权限!");
}
});
}).compose(RxUtils::toSimpleSingle).subscribe(new MySingleObserver<Boolean>() {
@Override

@ -29,6 +29,7 @@ import java.util.ArrayList;
import xyz.fycz.myreader.R;
import xyz.fycz.myreader.application.App;
import xyz.fycz.myreader.application.SysManager;
import xyz.fycz.myreader.util.utils.StoragePermissionUtils;
import xyz.fycz.myreader.webapi.LanZousApi;
import xyz.fycz.myreader.webapi.ResultCallback;
import xyz.fycz.myreader.common.APPCONST;
@ -165,12 +166,14 @@ public class FontsAdapter extends ArrayAdapter<Font> {
}
}).create();
dialog.show();*/
StoragePermissionUtils.request(mFontsActivity, (permissions, all) -> {
ToastUtils.showInfo("请选择一个ttf格式的字体文件");
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("*/*");
intent.addCategory(Intent.CATEGORY_OPENABLE);
mFontsActivity.startActivityForResult(intent, APPCONST.SELECT_FILE_CODE);
});
});
return;
}
if (font != Font.默认字体 && !fontFile.exists()) {
@ -178,9 +181,11 @@ public class FontsAdapter extends ArrayAdapter<Font> {
viewHolder.btnFontUse.setButtonColor(mFontsActivity.getResources().getColor(R.color.sys_blue_littler));
viewHolder.btnFontUse.setText(getContext().getString(R.string.font_download));
viewHolder.btnFontUse.setOnClickListener(v -> {
StoragePermissionUtils.request(mFontsActivity, (permissions, all) -> {
viewHolder.btnFontUse.setEnabled(false);
addDownloadFont(font, viewHolder);
});
});
} else if (setting.getFont() == font) {
viewHolder.btnFontUse.setText(getContext().getString(R.string.font_using));
viewHolder.btnFontUse.setEnabled(false);
@ -206,6 +211,7 @@ public class FontsAdapter extends ArrayAdapter<Font> {
mHandler.sendMessage(mHandler.obtainMessage(3));
return;
}
final String[] url = {URLCONST.FONT_DOWNLOAD_URL + font.toString() + ".ttf"};
viewHolder.btnFontUse.setText("获取连接...");
LanZousApi.getUrl(font.downloadPath, new ResultCallback() {

@ -54,6 +54,7 @@ import xyz.fycz.myreader.util.utils.ClipBoardUtil;
import xyz.fycz.myreader.util.utils.FileUtils;
import xyz.fycz.myreader.util.utils.GsonExtensionsKt;
import xyz.fycz.myreader.util.utils.RxUtils;
import xyz.fycz.myreader.util.utils.StoragePermissionUtils;
import xyz.fycz.myreader.widget.DividerItemDecoration;
import xyz.fycz.myreader.widget.swipemenu.SwipeMenuLayout;
@ -385,11 +386,7 @@ public class DIYSourceFragment extends BaseFragment {
ToastUtils.showWarring("当前没有选择任何书源,无法导出!");
return;
}
XXPermissions.with(this)
.permission(APPCONST.STORAGE_PERMISSIONS)
.request(new OnPermissionCallback() {
@Override
public void onGranted(List<String> permissions, boolean all) {
StoragePermissionUtils.request(this, (permissions, all) -> {
Single.create((SingleOnSubscribe<Boolean>) emitter -> {
emitter.onSuccess(FileUtils.writeText(GsonExtensionsKt.getGSON().toJson(sources),
FileUtils.getFile(APPCONST.FILE_DIR + "BookSources.json")));
@ -404,12 +401,6 @@ public class DIYSourceFragment extends BaseFragment {
}
}
});
}
@Override
public void onDenied(List<String> permissions, boolean never) {
ToastUtils.showWarring("没有储存权限!");
}
});
}
@ -418,6 +409,7 @@ public class DIYSourceFragment extends BaseFragment {
ToastUtils.showWarring("当前没有选择任何书源,无法分享!");
return;
}
StoragePermissionUtils.request(this, (permissions, all) -> {
Single.create((SingleOnSubscribe<File>) emitter -> {
File share = FileUtils.getFile(APPCONST.SHARE_FILE_DIR + "ShareBookSources.json");
if (FileUtils.writeText(GsonExtensionsKt.getGSON().toJson(bookSources), share)) {
@ -436,6 +428,8 @@ public class DIYSourceFragment extends BaseFragment {
ToastUtils.showError("书源分享失败\n" + e.getLocalizedMessage());
}
});
});
}
private void reverseSources(List<BookSource> mBookSources) {

@ -58,6 +58,7 @@ import xyz.fycz.myreader.util.ToastUtils;
import xyz.fycz.myreader.util.utils.GsonExtensionsKt;
import xyz.fycz.myreader.util.utils.ImageLoader;
import xyz.fycz.myreader.util.utils.NetworkUtils;
import xyz.fycz.myreader.util.utils.StoragePermissionUtils;
import xyz.fycz.myreader.webapi.ResultCallback;
import static android.app.Activity.RESULT_OK;
@ -374,6 +375,7 @@ public class MineFragment extends BaseFragment {
ToastUtils.showWarring("当前书架无任何书籍,无法备份!");
return;
}
StoragePermissionUtils.request(this, (permissions, all) -> {
DialogCreator.createCommonDialog(getContext(), "确认备份吗?", "新备份会替换原有备份!", true,
(dialogInterface, i) -> {
dialogInterface.dismiss();
@ -394,12 +396,14 @@ public class MineFragment extends BaseFragment {
}
}, false);
}, (dialogInterface, i) -> dialogInterface.dismiss());
});
}
/**
* 恢复
*/
private void restore() {
StoragePermissionUtils.request(this, (permissions, all) -> {
DialogCreator.createCommonDialog(getContext(), "确认恢复吗?", "恢复书架会覆盖原有书架!", true,
(dialogInterface, i) -> {
dialogInterface.dismiss();
@ -432,6 +436,7 @@ public class MineFragment extends BaseFragment {
}
});
}, (dialogInterface, i) -> dialogInterface.dismiss());
});
}
/**

@ -45,6 +45,7 @@ import xyz.fycz.myreader.util.ZipUtils;
import xyz.fycz.myreader.util.utils.FileUtils;
import xyz.fycz.myreader.util.utils.GsonExtensionsKt;
import xyz.fycz.myreader.util.utils.MeUtils;
import xyz.fycz.myreader.util.utils.StoragePermissionUtils;
public class CustomizeLayoutMenu extends FrameLayout {
@ -217,11 +218,13 @@ public class CustomizeLayoutMenu extends FrameLayout {
}
private void importLayout() {
StoragePermissionUtils.request(context, (permissions, all) -> {
ToastUtils.showInfo("请选择布局配置压缩文件");
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("application/zip");
context.startActivityForResult(intent, APPCONST.REQUEST_IMPORT_LAYOUT);
});
}
private void exportLayout() {
@ -237,26 +240,17 @@ public class CustomizeLayoutMenu extends FrameLayout {
"布局配置导出成功,导出位置:" + APPCONST.FILE_DIR + "readConfig.zip");
}
}).show();*/
StoragePermissionUtils.request(context, (permissions, all) -> {
BottomMenu.show("选择需要导出的布局", items)
.setOnMenuItemClickListener((dialog, text, which) -> {
XXPermissions.with(context)
.permission(APPCONST.STORAGE_PERMISSIONS)
.request(new OnPermissionCallback() {
@Override
public void onGranted(List<String> permissions, boolean all) {
if (setting.exportLayout(which)) {
DialogCreator.createTipDialog(context,
"布局配置导出成功,导出位置:" + APPCONST.FILE_DIR + "readConfig.zip");
}
}
@Override
public void onDenied(List<String> permissions, boolean never) {
ToastUtils.showWarring("没有储存权限!");
}
});
return false;
});
});
}
public void zip2Layout(String zipPath) {

@ -33,7 +33,6 @@ import xyz.fycz.myreader.util.utils.OkHttpUtils;
import xyz.fycz.myreader.util.utils.StringUtils;
@Keep
@SuppressWarnings({"unused"})
public interface JsExtensions {
String TAG = JsExtensions.class.getSimpleName();

@ -39,10 +39,16 @@ import xyz.fycz.myreader.util.ToastUtils;
* @date 2021/6/3 21:46
*/
public class ShareBookUtil {
public static void shareBook(Context context, Book mBook, ImageView cover) {
StoragePermissionUtils.request(context, (permissions, all) -> {
shareBook2(context, mBook, cover);
});
}
/**
* 分享书籍
*/
public static void shareBook(Context context, Book mBook, ImageView cover) {
public static void shareBook2(Context context, Book mBook, ImageView cover) {
if ("本地书籍".equals(mBook.getType())) {
File file = new File(mBook.getChapterUrl());
if (!file.exists()) {

@ -0,0 +1,54 @@
package xyz.fycz.myreader.util.utils;
import android.content.Context;
import androidx.fragment.app.Fragment;
import com.hjq.permissions.OnPermissionCallback;
import com.hjq.permissions.XXPermissions;
import java.util.List;
import xyz.fycz.myreader.common.APPCONST;
import xyz.fycz.myreader.ui.dialog.DialogCreator;
import xyz.fycz.myreader.util.ToastUtils;
/**
* @author fengyue
* @date 2021/6/6 18:37
*/
public class StoragePermissionUtils {
public static void request(Context context, OnPermissionCallback callback){
XXPermissions.with(context)
.permission(APPCONST.STORAGE_PERMISSIONS)
.request(new OnPermissionCallback() {
@Override
public void onGranted(List<String> permissions, boolean all) {
callback.onGranted(permissions, all);
}
@Override
public void onDenied(List<String> permissions, boolean never) {
ToastUtils.showWarring("没有储存权限!");
callback.onDenied(permissions, never);
}
});
}
public static void request(Fragment fragment, OnPermissionCallback callback){
XXPermissions.with(fragment)
.permission(APPCONST.STORAGE_PERMISSIONS)
.request(new OnPermissionCallback() {
@Override
public void onGranted(List<String> permissions, boolean all) {
callback.onGranted(permissions, all);
}
@Override
public void onDenied(List<String> permissions, boolean never) {
ToastUtils.showWarring("没有储存权限!");
callback.onDenied(permissions, never);
}
});
}
}
Loading…
Cancel
Save