存储优化

pull/5/head v2.1.0
fengyuecanzhu 4 years ago
parent b76df12486
commit df9054d817
  1. 3
      app/build.gradle
  2. 5
      app/src/main/assets/updatelog.fy
  3. 48
      app/src/main/java/xyz/fycz/myreader/common/APPCONST.java
  4. 18
      app/src/main/java/xyz/fycz/myreader/ui/activity/MainActivity.java
  5. 39
      app/src/main/java/xyz/fycz/myreader/ui/activity/QRCodeScanActivity.java
  6. 16
      app/src/main/java/xyz/fycz/myreader/ui/activity/ReplaceRuleActivity.java
  7. 52
      app/src/main/java/xyz/fycz/myreader/ui/activity/SplashActivity.java
  8. 18
      app/src/main/java/xyz/fycz/myreader/ui/adapter/BookcaseAdapter.java
  9. 45
      app/src/main/java/xyz/fycz/myreader/ui/dialog/UpdateDialog.java
  10. 14
      app/src/main/java/xyz/fycz/myreader/ui/fragment/DIYSourceFragment.java
  11. 2
      app/src/main/java/xyz/fycz/myreader/ui/fragment/MineFragment.java
  12. 15
      app/src/main/java/xyz/fycz/myreader/ui/popmenu/CustomizeLayoutMenu.java
  13. 36
      app/src/main/java/xyz/fycz/myreader/ui/presenter/BookcasePresenter.java
  14. 31
      app/src/main/java/xyz/fycz/myreader/util/PermissionsChecker.java
  15. 1
      app/src/main/java/xyz/fycz/myreader/util/help/JsExtensions.java
  16. 4
      app/src/main/java/xyz/fycz/myreader/util/utils/FileUtils.java
  17. 5
      app/src/main/res/values/strings.xml
  18. 4
      app/version_code.properties

@ -210,6 +210,9 @@ dependencies {
//noinspection GradleDependency
implementation 'com.github.gedoor:rhino-android:1.3'
//XXPermissions
implementation 'com.github.getActivity:XXPermissions:11.2'
}
greendao {

@ -1,3 +1,8 @@
2021.06.06
风月读书v2.1.0
更新内容:
1、储存优化
2021.06.05
风月读书v2.0.9
更新内容:

@ -3,8 +3,11 @@ package xyz.fycz.myreader.common;
import android.os.Environment;
import com.google.gson.reflect.TypeToken;
import com.hjq.permissions.Permission;
import com.hjq.permissions.XXPermissions;
import xyz.fycz.myreader.R;
import xyz.fycz.myreader.application.App;
import xyz.fycz.myreader.util.utils.FileUtils;
import java.io.File;
@ -22,21 +25,34 @@ public class APPCONST {
public static String privateKey;//app私钥
public static final String KEY = "";
public static final String[] STORAGE_PERMISSIONS = new String[]{Permission.WRITE_EXTERNAL_STORAGE,
Permission.READ_EXTERNAL_STORAGE};
public static final String FILE_DIR = Environment.getExternalStorageDirectory() + "/FYReader/";
public static final String SHARE_FILE_DIR = Environment.getExternalStorageDirectory() + "/FYReader/share/";
public static final String LOG_DIR = Environment.getExternalStorageDirectory() + "/FYReader/log/";
public static final String BG_FILE_DIR = Environment.getExternalStorageDirectory() + "/FYReader/bg/";
public static final String TEM_FILE_DIR = Environment.getExternalStorageDirectory() + "/FYReader/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/";
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/";
//BookCachePath (因为getCachePath引用了Context,所以必须是静态变量,不能够是静态常量)
public static String BOOK_CACHE_PATH = FileUtils.getCachePath() + 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;
@ -94,8 +110,6 @@ public class APPCONST {
public static final int SELECT_FILE_CODE = 10000;
public static final int PERMISSIONS_REQUEST_STORAGE = 10001;
//设置版本号
public static final int SETTING_VERSION = 11;
@ -120,4 +134,12 @@ public class APPCONST {
public static final String DEFAULT_USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4168.3 Safari/537.36";
private static Boolean hasStoragePermission = null;
public static boolean hasStoragePermission() {
if (hasStoragePermission == null) {
hasStoragePermission = XXPermissions.isGranted(App.getmContext(), STORAGE_PERMISSIONS);
}
return hasStoragePermission;
}
}

@ -386,24 +386,6 @@ public class MainActivity extends BaseActivity {
}
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
switch (requestCode) {
case APPCONST.PERMISSIONS_REQUEST_STORAGE: {
// 如果取消权限,则返回的值为0
if (grantResults.length > 0
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
//跳转到 FileSystemActivity
Intent intent = new Intent(this, FileSystemActivity.class);
startActivity(intent);
} else {
ToastUtils.showWarring("用户拒绝开启读写权限");
}
}
}
}
@Override
protected void onDestroy() {

@ -2,7 +2,6 @@ package xyz.fycz.myreader.ui.activity;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
@ -11,9 +10,13 @@ import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.appcompat.widget.Toolbar;
import androidx.core.app.ActivityCompat;
import com.hjq.permissions.OnPermissionCallback;
import com.hjq.permissions.Permission;
import com.hjq.permissions.XXPermissions;
import java.util.List;
import cn.bingoogolapple.qrcode.core.QRCodeView;
import io.reactivex.Single;
@ -22,7 +25,6 @@ import xyz.fycz.myreader.R;
import xyz.fycz.myreader.base.BaseActivity;
import xyz.fycz.myreader.base.observer.MySingleObserver;
import xyz.fycz.myreader.databinding.ActivityQrcodeCaptureBinding;
import xyz.fycz.myreader.util.PermissionsChecker;
import xyz.fycz.myreader.util.help.StringHelper;
import xyz.fycz.myreader.util.ToastUtils;
import xyz.fycz.myreader.util.utils.RxUtils;
@ -40,8 +42,6 @@ public class QRCodeScanActivity extends BaseActivity implements QRCodeView.Deleg
private ActivityQrcodeCaptureBinding binding;
private final int REQUEST_QR_IMAGE = 202;
private static final String CAMERA = "android.permission.CAMERA";
private static final int PERMISSIONS_REQUEST_CAMERA = 101;
private boolean flashlightIsOpen;
private boolean needScale = true;
private String picPath;
@ -144,32 +144,23 @@ public class QRCodeScanActivity extends BaseActivity implements QRCodeView.Deleg
}
private void requestPermission() {
//获取读取和写入SD卡的权限
if (new PermissionsChecker(this).lacksPermissions(CAMERA)) {
ActivityCompat.requestPermissions(this, new String[]{CAMERA}, PERMISSIONS_REQUEST_CAMERA);
} else {
//获取相机权限
XXPermissions.with(this)
.permission(Permission.CAMERA)
.request(new OnPermissionCallback() {
@Override
public void onGranted(List<String> permissions, boolean all) {
//申请权限成功
startScan();
}
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
switch (requestCode) {
case PERMISSIONS_REQUEST_CAMERA: {
// 如果取消权限,则返回的值为0
if (grantResults.length > 0
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
//申请权限成功
startScan();
} else {
public void onDenied(List<String> permissions, boolean never) {
//申请权限失败
finish();
ToastUtils.showWarring("请给予相机权限,否则无法进行扫码!");
}
return;
}
}
});
}
// 添加菜单

@ -17,6 +17,8 @@ import androidx.appcompat.widget.Toolbar;
import androidx.recyclerview.widget.ItemTouchHelper;
import androidx.recyclerview.widget.LinearLayoutManager;
import com.hjq.permissions.OnPermissionCallback;
import com.hjq.permissions.XXPermissions;
import com.kongzue.dialogx.dialogs.BottomMenu;
import java.util.ArrayList;
@ -244,11 +246,23 @@ 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) {
if (FileUtils.writeText(GsonExtensionsKt.getGSON().toJson(mReplaceRules),
FileUtils.getFile(APPCONST.FILE_DIR + "ReplaceRule.json"))) {
DialogCreator.createTipDialog(this,
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) {
ruleBean.setEnable(!ruleBean.getEnable());

@ -17,11 +17,15 @@ import androidx.core.app.ActivityCompat;
import com.bumptech.glide.request.RequestOptions;
import com.bumptech.glide.signature.ObjectKey;
import com.gyf.immersionbar.ImmersionBar;
import com.hjq.permissions.OnPermissionCallback;
import com.hjq.permissions.Permission;
import com.hjq.permissions.XXPermissions;
import com.weaction.ddsdk.ad.DdSdkSplashAd;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.util.List;
import xyz.fycz.myreader.R;
import xyz.fycz.myreader.application.App;
@ -33,7 +37,6 @@ import xyz.fycz.myreader.greendao.service.BookGroupService;
import xyz.fycz.myreader.ui.dialog.MyAlertDialog;
import xyz.fycz.myreader.util.help.DateHelper;
import xyz.fycz.myreader.util.IOUtils;
import xyz.fycz.myreader.util.PermissionsChecker;
import xyz.fycz.myreader.util.SharedPreUtils;
import xyz.fycz.myreader.util.ToastUtils;
import xyz.fycz.myreader.util.utils.AdUtils;
@ -46,12 +49,6 @@ public class SplashActivity extends BaseActivity {
/*************Constant**********/
public static final String TAG = SplashActivity.class.getSimpleName();
public static int WAIT_INTERVAL = 0;
private static final int PERMISSIONS_REQUEST_STORAGE = 1;
static final String[] PERMISSIONS = {
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE
};
private ActivitySplashBinding binding;
private SharedPreUtils spu;
@ -59,7 +56,6 @@ public class SplashActivity extends BaseActivity {
private int adTimes;
private boolean hasStart = false;
private PermissionsChecker mPermissionsChecker;
//创建子线程
private Runnable start = () -> {
if (!hasStart && !App.isDestroy(SplashActivity.this)) {
@ -115,22 +111,12 @@ public class SplashActivity extends BaseActivity {
//loadImage();
boolean agreePrivacyPolicy = SharedPreUtils.getInstance().getBoolean("agreePrivacyPolicy");
if (agreePrivacyPolicy) {
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M) {
mPermissionsChecker = new PermissionsChecker(this);
requestPermission();
} else {
start();
}
} else {
MyAlertDialog.showPrivacyDialog(this, (dialog, which) -> {
SharedPreUtils.getInstance().putBoolean("agreePrivacyPolicy", true);
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M) {
mPermissionsChecker = new PermissionsChecker(this);
requestPermission();
} else {
start();
}
}, (dialog, which) -> finish());
}, (dialog, which) -> android.os.Process.killProcess(android.os.Process.myPid()));
}
}
@ -348,33 +334,23 @@ public class SplashActivity extends BaseActivity {
private void requestPermission() {
//获取读取和写入SD卡的权限
if (mPermissionsChecker.lacksPermissions(PERMISSIONS)) {
ActivityCompat.requestPermissions(this, PERMISSIONS, PERMISSIONS_REQUEST_STORAGE);
} else {
XXPermissions.with(this)
.permission(APPCONST.STORAGE_PERMISSIONS)
.request(new OnPermissionCallback() {
@Override
public void onGranted(List<String> permissions, boolean all) {
start();
}
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
switch (requestCode) {
case PERMISSIONS_REQUEST_STORAGE: {
// 如果取消权限,则返回的值为0
if (grantResults.length > 0
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
//申请权限成功
public void onDenied(List<String> permissions, boolean never) {
ToastUtils.showWarring("储存权限被拒绝,部分功能可能无法正常运行!");
start();
} else {
//申请权限失败
finish();
ToastUtils.showWarring("请给予储存权限,否则程序无法正常运行!");
}
return;
}
}
});
}
private void countTodayAd() {
String today = DateHelper.getYearMonthDay1();
todayAdCount++;

@ -12,6 +12,8 @@ import androidx.annotation.NonNull;
import androidx.appcompat.widget.SwitchCompat;
import androidx.recyclerview.widget.RecyclerView;
import com.hjq.permissions.OnPermissionCallback;
import com.hjq.permissions.XXPermissions;
import com.kongzue.dialogx.dialogs.BottomDialog;
import com.kongzue.dialogx.dialogs.BottomMenu;
import com.kongzue.dialogx.interfaces.OnBindView;
@ -450,7 +452,23 @@ 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) {
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
public void onSuccess(@NotNull Boolean aBoolean) {

@ -25,6 +25,9 @@ import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentTransaction;
import com.hjq.permissions.OnPermissionCallback;
import com.hjq.permissions.Permission;
import com.hjq.permissions.XXPermissions;
import com.liulishuo.filedownloader.BaseDownloadTask;
import com.liulishuo.filedownloader.FileDownloadLargeFileListener;
import com.liulishuo.filedownloader.FileDownloader;
@ -35,9 +38,11 @@ import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLDecoder;
import java.util.List;
import xyz.fycz.myreader.R;
import xyz.fycz.myreader.application.App;
import xyz.fycz.myreader.common.APPCONST;
import xyz.fycz.myreader.databinding.FragmentUpdateBinding;
import xyz.fycz.myreader.util.ToastUtils;
import xyz.fycz.myreader.webapi.LanZousApi;
@ -91,11 +96,19 @@ public class UpdateDialog extends Fragment {
// if (listener != null) {
// listener.onConfirm(v);
// } else {
if (ActivityCompat.checkSelfPermission(mActivity, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, PERMISSION_WRITE_EXTERNAL_STORAGE);
} else {
XXPermissions.with(mActivity)
.permission(APPCONST.STORAGE_PERMISSIONS)
.request(new OnPermissionCallback() {
@Override
public void onGranted(List<String> permissions, boolean all) {
downloadApk(appUrl);
}
@Override
public void onDenied(List<String> permissions, boolean never) {
ToastUtils.showWarring("请勿拒绝储存权限,否则无法更新应用!");
}
});
// }
});
binding.btBrowser.setOnClickListener(v -> {
@ -255,7 +268,7 @@ public class UpdateDialog extends Fragment {
baseDownloadTask = FileDownloader.getImpl()
.create(decodeUrl)
.setPath(path, new File(path).isDirectory())
.setCallbackProgressMinInterval(100)
.setCallbackProgressMinInterval(30)
.setListener(new FileDownloadLargeFileListener() {
@Override
protected void pending(BaseDownloadTask task, long soFarBytes, long totalBytes) {
@ -300,30 +313,6 @@ public class UpdateDialog extends Fragment {
baseDownloadTask.start();
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (requestCode == PERMISSION_WRITE_EXTERNAL_STORAGE) {
if (grantResults.length > 0
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
// 权限被用户同意,可以去放肆了。
if (ActivityCompat.checkSelfPermission(mActivity, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
// TODO: Consider calling
// ActivityCompat#requestPermissions
// here to request the missing permissions, and then overriding
// public void onRequestPermissionsResult(int requestCode, String[] permissions,
// int[] grantResults)
// to handle the case where the user grants the permission. See the documentation
// for ActivityCompat#requestPermissions for more details.
return;
} else {
downloadApk(appUrl);
}
} else {
// 权限被用户拒绝了,洗洗睡吧。
}
}
}
/**
* 安装

@ -17,6 +17,8 @@ import androidx.recyclerview.widget.ItemTouchHelper;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.hjq.permissions.OnPermissionCallback;
import com.hjq.permissions.XXPermissions;
import com.kongzue.dialogx.dialogs.BottomMenu;
import java.io.File;
@ -383,6 +385,11 @@ 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) {
Single.create((SingleOnSubscribe<Boolean>) emitter -> {
emitter.onSuccess(FileUtils.writeText(GsonExtensionsKt.getGSON().toJson(sources),
FileUtils.getFile(APPCONST.FILE_DIR + "BookSources.json")));
@ -399,6 +406,13 @@ public class DIYSourceFragment extends BaseFragment {
});
}
@Override
public void onDenied(List<String> permissions, boolean never) {
ToastUtils.showWarring("没有储存权限!");
}
});
}
private void shareSources(List<BookSource> bookSources) {
if (bookSources == null || bookSources.size() == 0) {
ToastUtils.showWarring("当前没有选择任何书源,无法分享!");

@ -390,7 +390,7 @@ public class MineFragment extends BaseFragment {
@Override
public void backupError(@io.reactivex.annotations.NonNull String msg) {
DialogCreator.createTipDialog(getContext(), "未给予储存权限,备份失败!");
DialogCreator.createTipDialog(getContext(), "未给予储存权限,备份失败!\n" + msg);
}
}, false);
}, (dialogInterface, i) -> dialogInterface.dismiss());

@ -22,6 +22,8 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.FragmentActivity;
import com.hjq.permissions.OnPermissionCallback;
import com.hjq.permissions.XXPermissions;
import com.jaredrummler.android.colorpicker.ColorPickerDialog;
import com.kongzue.dialogx.dialogs.BottomMenu;
@ -237,10 +239,22 @@ public class CustomizeLayoutMenu extends FrameLayout {
}).show();*/
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;
});
}
@ -292,6 +306,7 @@ public class CustomizeLayoutMenu extends FrameLayout {
public interface Callback {
void upBg();
void upStyle();
}

@ -21,6 +21,9 @@ import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.ItemTouchHelper;
import androidx.recyclerview.widget.LinearLayoutManager;
import com.hjq.permissions.OnPermissionCallback;
import com.hjq.permissions.Permission;
import com.hjq.permissions.XXPermissions;
import com.kongzue.dialogx.dialogs.BottomMenu;
import org.jetbrains.annotations.NotNull;
@ -85,7 +88,6 @@ public class BookcasePresenter implements BasePresenter {
private final ChapterService mChapterService;
private final BookGroupService mBookGroupService;
private final MainActivity mMainActivity;
private PermissionsChecker mPermissionsChecker;
private boolean isBookcaseStyleChange;
private Setting mSetting;
private final List<Book> errorLoadingBooks = new ArrayList<>();
@ -487,19 +489,7 @@ public class BookcasePresenter implements BasePresenter {
showGroupManDia();
return true;
case R.id.action_addLocalBook:
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M) {
if (mPermissionsChecker == null) {
mPermissionsChecker = new PermissionsChecker(mMainActivity);
}
//获取读取和写入SD卡的权限
if (mPermissionsChecker.lacksPermissions(PERMISSIONS)) {
//请求权限
ActivityCompat.requestPermissions(mMainActivity, PERMISSIONS, APPCONST.PERMISSIONS_REQUEST_STORAGE);
return true;
}
}
Intent fileSystemIntent = new Intent(mMainActivity, FileSystemActivity.class);
mMainActivity.startActivity(fileSystemIntent);
addLocalBook();
break;
case R.id.action_download_all:
if (!SharedPreUtils.getInstance().getBoolean(mMainActivity.getString(R.string.isReadDownloadAllTip), false)) {
@ -518,6 +508,23 @@ public class BookcasePresenter implements BasePresenter {
return false;
}
private void addLocalBook() {
XXPermissions.with(mMainActivity)
.permission(APPCONST.STORAGE_PERMISSIONS)
.request(new OnPermissionCallback() {
@Override
public void onGranted(List<String> permissions, boolean all) {
Intent fileSystemIntent = new Intent(mMainActivity, FileSystemActivity.class);
mMainActivity.startActivity(fileSystemIntent);
}
@Override
public void onDenied(List<String> permissions, boolean never) {
ToastUtils.showWarring("储存权限被拒绝,无法添加本地书籍!");
}
});
}
/**
* 显示书籍分组菜单
*/
@ -884,7 +891,6 @@ public class BookcasePresenter implements BasePresenter {
}
/**
* 发送通知
*/

@ -1,31 +0,0 @@
package xyz.fycz.myreader.util;
import android.content.Context;
import android.content.pm.PackageManager;
import androidx.core.content.ContextCompat;
public class PermissionsChecker {
private final Context mContext;
public PermissionsChecker(Context context) {
mContext = context.getApplicationContext();
}
// 判断权限集合
public boolean lacksPermissions(String... permissions) {
for (String permission : permissions) {
if (lacksPermission(permission)) {
return true;
}
}
return false;
}
// 判断是否缺少权限
private boolean lacksPermission(String permission) {
return ContextCompat.checkSelfPermission(mContext, permission) ==
PackageManager.PERMISSION_DENIED;
}
}

@ -33,6 +33,7 @@ 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();

@ -72,6 +72,10 @@ public class FileUtils {
return file;
}
public static String getDataDir(){
return getFileDir().getParent();
}
//获取Cache文件夹
public static String getCachePath(){
if (isSdCardExist()){

@ -492,7 +492,10 @@
<string name="dyys">段友影视,超清无水印广告视频站</string>
<string name="all_read_time">总阅读时间:%s</string>
<string name="read_record">阅读记录</string>
<string name="privacy_tip">\n感谢您使用风月读书APP!\n我们非常重视您的个人信息和隐私保护。为了更好地保障您的个人权益,在您使用我们的产品前,请务必审慎阅读《隐私政策》内的所有条款,当您点击“同意并继续”即表示您己阅读完毕并同意以上协议的全部内容,开始使用我们的产品和服务。</string>
<string name="privacy_tip">\n感谢您使用风月读书APP!
\n\n1.我们非常重视您的个人信息和隐私保护。为了更好地保障您的个人权益,在您使用我们的产品前,请务必审慎阅读《隐私政策》内的所有条款.
\n\n2.我们可能会申请存储权限,以实现下载、分享、备份、应用升级、导入本地书籍等相关功能.
\n\n如果您己阅读完毕并同意以上协议的全部内容,请点击下方“同意并继续”按钮以开始使用我们的产品和服务.</string>
<string name="close">关闭</string>
<string name="official_web">官网</string>
<string name="privacy_policy">隐私政策</string>

@ -1,2 +1,2 @@
#Fri Jun 04 20:20:53 CST 2021
VERSION_CODE=208
#Sun Jun 06 10:44:17 CST 2021
VERSION_CODE=210

Loading…
Cancel
Save