pull/21/head
fengyuecanzhu 3 years ago
parent a70c9bb35c
commit 64abf589b1
  1. 6
      app/build.gradle
  2. BIN
      app/libs/ddsdk-release.aar
  3. 8
      app/src/main/assets/updatelog.fy
  4. 17
      app/src/main/java/xyz/fycz/myreader/entity/AdBean.java
  5. 8
      app/src/main/java/xyz/fycz/myreader/model/SearchEngine.java
  6. 335
      app/src/main/java/xyz/fycz/myreader/model/user/UserService.java
  7. 4
      app/src/main/java/xyz/fycz/myreader/model/user/UserService.kt
  8. 6
      app/src/main/java/xyz/fycz/myreader/ui/activity/AuthEmailActivity.kt
  9. 5
      app/src/main/java/xyz/fycz/myreader/ui/activity/BookDetailedActivity.java
  10. 10
      app/src/main/java/xyz/fycz/myreader/ui/activity/LoginActivity.java
  11. 8
      app/src/main/java/xyz/fycz/myreader/ui/activity/RegisterActivity.java
  12. 9
      app/src/main/java/xyz/fycz/myreader/ui/activity/SplashActivity.java
  13. 20
      app/src/main/java/xyz/fycz/myreader/ui/fragment/MineFragment.java
  14. 6
      app/src/main/java/xyz/fycz/myreader/ui/presenter/BookcasePresenter.java
  15. 15
      app/src/main/java/xyz/fycz/myreader/util/utils/AdUtils.java
  16. 2
      app/version_code.properties

@ -91,6 +91,9 @@ android {
if (keyPropsFile.exists()) { if (keyPropsFile.exists()) {
signingConfig signingConfigs.myConifg signingConfig signingConfigs.myConifg
} }
ndk {
abiFilters "armeabi-v7a", "arm64-v8a"
}
} }
debug { debug {
minifyEnabled false minifyEnabled false
@ -99,6 +102,9 @@ android {
signingConfig signingConfigs.myConifg signingConfig signingConfigs.myConifg
} }
versionNameSuffix "-debug" versionNameSuffix "-debug"
ndk {
abiFilters "armeabi-v7a", "arm64-v8a"
}
} }
android.applicationVariants.all { variant -> android.applicationVariants.all { variant ->
variant.outputs.all { variant.outputs.all {

Binary file not shown.

@ -1,8 +1,16 @@
2022.02.23
风月读书v2.3.8
更新内容:
1、部分设备兼容性适配
2、尝试解决搜索卡死的问题
3、修复部分已知bug
2022.02.17 2022.02.17
风月读书v2.3.7 风月读书v2.3.7
更新内容: 更新内容:
1、新增邮箱登录 1、新增邮箱登录
2、新增开屏广告 2、新增开屏广告
3、支持作者界面新增广告支持作者
注:由于广告投放次数的需要,此次更新为强制更新 注:由于广告投放次数的需要,此次更新为强制更新
2022.02.07 2022.02.07

@ -13,6 +13,8 @@ public class AdBean {
private int backAdTime; private int backAdTime;
//应用回到前台展示广告间隔(单位:分钟) //应用回到前台展示广告间隔(单位:分钟)
private int intervalAdTime; private int intervalAdTime;
//是否在详情页展示信息流广告
private boolean showFlowAd;
public AdBean() { public AdBean() {
} }
@ -23,6 +25,13 @@ public class AdBean {
this.intervalAdTime = intervalAdTime; this.intervalAdTime = intervalAdTime;
} }
public AdBean(boolean hasAd, int backAdTime, int intervalAdTime, boolean showFlowAd) {
this.hasAd = hasAd;
this.backAdTime = backAdTime;
this.intervalAdTime = intervalAdTime;
this.showFlowAd = showFlowAd;
}
public boolean isCloud() { public boolean isCloud() {
return isCloud; return isCloud;
} }
@ -54,4 +63,12 @@ public class AdBean {
public void setIntervalAdTime(int intervalAdTime) { public void setIntervalAdTime(int intervalAdTime) {
this.intervalAdTime = intervalAdTime; this.intervalAdTime = intervalAdTime;
} }
public boolean isShowFlowAd() {
return showFlowAd;
}
public void setShowFlowAd(boolean showFlowAd) {
this.showFlowAd = showFlowAd;
}
} }

@ -50,7 +50,7 @@ public class SearchEngine {
private OnSearchListener searchListener; private OnSearchListener searchListener;
public SearchEngine() { public SearchEngine() {
threadsNum = SharedPreUtils.getInstance().getInt(App.getmContext().getString(R.string.threadNum), 8); threadsNum = SharedPreUtils.getInstance().getInt(App.getmContext().getString(R.string.threadNum), 16);
} }
public void setOnSearchListener(OnSearchListener searchListener) { public void setOnSearchListener(OnSearchListener searchListener) {
@ -143,7 +143,8 @@ public class SearchEngine {
searchSiteIndex++; searchSiteIndex++;
if (searchSiteIndex < mSourceList.size()) { if (searchSiteIndex < mSourceList.size()) {
ReadCrawler crawler = mSourceList.get(searchSiteIndex); ReadCrawler crawler = mSourceList.get(searchSiteIndex);
BookApi.search(keyword, crawler, executorService) //BookApi.search(keyword, crawler, executorService)
BookApi.search(keyword, crawler)
.subscribeOn(scheduler) .subscribeOn(scheduler)
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<ConMVMap<SearchBookBean, Book>>() { .subscribe(new Observer<ConMVMap<SearchBookBean, Book>>() {
@ -191,7 +192,8 @@ public class SearchEngine {
if (searchSiteIndex < mSourceList.size()) { if (searchSiteIndex < mSourceList.size()) {
ReadCrawler crawler = mSourceList.get(searchSiteIndex); ReadCrawler crawler = mSourceList.get(searchSiteIndex);
String searchKey = title; String searchKey = title;
BookApi.search(searchKey, crawler, executorService) //BookApi.search(searchKey, crawler, executorService)
BookApi.search(searchKey, crawler)
.subscribeOn(scheduler) .subscribeOn(scheduler)
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<ConMVMap<SearchBookBean, Book>>() { .subscribe(new Observer<ConMVMap<SearchBookBean, Book>>() {

@ -1,335 +0,0 @@
package xyz.fycz.myreader.model.user;
import android.content.Context;
import io.reactivex.annotations.NonNull;
import xyz.fycz.myreader.application.App;
import xyz.fycz.myreader.model.storage.Backup;
import xyz.fycz.myreader.model.storage.Restore;
import xyz.fycz.myreader.webapi.ResultCallback;
import xyz.fycz.myreader.common.APPCONST;
import xyz.fycz.myreader.common.URLCONST;
import xyz.fycz.myreader.util.*;
import xyz.fycz.myreader.util.utils.FileUtils;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
/**
* @author fengyue
* @date 2020/4/26 11:03
*/
public class UserService {
/**
* 登录
* @param userLoginInfo 用户名输入的用户名和密码等登录信息
* @return 是否成功登录
*/
public static void login(final Map<String, String> userLoginInfo, final ResultCallback resultCallback) {
App.getApplication().newThread(() -> {
HttpURLConnection conn = null;
try {
URL url = new URL(URLCONST.APP_WEB_URL + "login");
conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setConnectTimeout(60 * 1000);
conn.setReadTimeout(60 * 1000);
conn.setDoInput(true);
conn.setDoOutput(true);
String params = "username=" + userLoginInfo.get("loginName") +
"&password=" + userLoginInfo.get("loginPwd") + makeSignalParam();
// 获取URLConnection对象对应的输出流
PrintWriter out = new PrintWriter(conn.getOutputStream());
// 发送请求参数
out.print(params);
// flush输出流的缓冲
out.flush();
InputStream in = conn.getInputStream();
BufferedReader bw = new BufferedReader(new InputStreamReader(in, "utf-8"));
StringBuilder sb = new StringBuilder();
String line = bw.readLine();
while (line != null) {
sb.append(line);
line = bw.readLine();
}
resultCallback.onFinish(sb.toString(), 1);
} catch (IOException e) {
e.printStackTrace();
resultCallback.onError(e);
}finally {
if (conn != null) {
conn.disconnect();
}
}
});
}
public static void register(final Map<String, String> userRegisterInfo, final ResultCallback resultCallback) {
App.getApplication().newThread(() -> {
HttpURLConnection conn = null;
try {
URL url = new URL(URLCONST.APP_WEB_URL + "reg");
conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setDoInput(true);
conn.setDoOutput(true);
String params = "username=" + userRegisterInfo.get("username") + "&password=" +
CyptoUtils.encode(APPCONST.KEY, userRegisterInfo.get("password")) + "&key=" +
CyptoUtils.encode(APPCONST.KEY, APPCONST.publicKey) + makeSignalParam();
// 获取URLConnection对象对应的输出流
PrintWriter out = new PrintWriter(conn.getOutputStream());
// 发送请求参数
out.print(params);
// flush输出流的缓冲
out.flush();
BufferedReader bw = new BufferedReader(new InputStreamReader(conn.getInputStream(), "utf-8"));
StringBuilder sb = new StringBuilder();
String line = bw.readLine();
while (line != null) {
sb.append(line);
line = bw.readLine();
}
resultCallback.onFinish(sb.toString(), 1);
} catch (IOException e) {
e.printStackTrace();
resultCallback.onError(e);
} finally {
if (conn != null) {
conn.disconnect();
}
}
});
}
/**
* 写配置
* @param userLoginInfo
* @return
*/
public static boolean writeConfig(Map<String,String> userLoginInfo){
FileOutputStream fos = null;
try {
fos = App.getApplication().openFileOutput("userConfig.fy", Context.MODE_PRIVATE);
String userInfo = "username='" + userLoginInfo.get("loginName") + "',\npassword='" + userLoginInfo.get("loginPwd") + "'";
byte[] bs = userInfo.getBytes();
fos.write(bs);
//写完后一定要刷新
fos.flush();
return true;
} catch (IOException e) {
e.printStackTrace();
return false;
} finally {
IOUtils.close(fos);
}
}
/**
* 读配置
* @return
*/
public static Map<String,String> readConfig(){
File file = App.getApplication().getFileStreamPath("userConfig.fy");
if (!file.exists()){
return null;
}
BufferedReader br = null;
try {
br = new BufferedReader(new FileReader(file));
String tem;
StringBuilder config = new StringBuilder();
while ((tem = br.readLine()) != null){
config.append(tem);
}
String[] user = config.toString().split(",");
String userName = user[0].substring(user[0].indexOf("'") + 1, user[0].lastIndexOf("'"));
String password = user[1].substring(user[1].indexOf("'") + 1, user[1].lastIndexOf("'"));
Map<String,String> userInfo = new HashMap<>();
userInfo.put("userName", userName);
userInfo.put("password", password);
return userInfo;
} catch (IOException e) {
e.printStackTrace();
}finally {
IOUtils.close(br);
}
return null;
}
public static void writeUsername(String username){
File file = FileUtils.getFile(APPCONST.QQ_DATA_DIR + "user");
BufferedWriter bw = null;
try {
bw = new BufferedWriter(new FileWriter(file));
bw.write(username);
bw.flush();
} catch (IOException e) {
e.printStackTrace();
}finally {
IOUtils.close(bw);
}
}
public static String readUsername(){
File file = new File(APPCONST.QQ_DATA_DIR + "user");
if (!file.exists()){
return "";
}
BufferedReader br = null;
try {
br = new BufferedReader(new FileReader(file));
return br.readLine();
} catch (IOException e) {
e.printStackTrace();
return "";
} finally {
IOUtils.close(br);
}
}
/**
* 网络备份
* @return
*/
public static void webBackup(ResultCallback rc){
Map<String,String> userInfo = readConfig();
if (userInfo == null){
rc.onFinish(false, 0);
}
Backup.INSTANCE.backup(App.getmContext(), APPCONST.FILE_DIR + "webBackup/", new Backup.CallBack() {
@Override
public void backupSuccess() {
App.getApplication().newThread(() ->{
File inputFile = FileUtils.getFile(APPCONST.FILE_DIR + "webBackup");
if (!inputFile.exists()) {
rc.onFinish(false, 0);
}
File zipFile = FileUtils.getFile(APPCONST.FILE_DIR + "webBackup.zip");
FileInputStream fis = null;
HttpURLConnection conn = null;
try {
//压缩文件
ZipUtils.zipFile(inputFile, zipFile);
fis = new FileInputStream(zipFile);
URL url = new URL(URLCONST.APP_WEB_URL + "bak?username=" + userInfo.get("userName") +
makeSignalParam());
conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-type", "multipart/form-data");
conn.setDoInput(true);
conn.setDoOutput(true);
OutputStream out = conn.getOutputStream();
byte[] bytes = new byte[1024];
int len = -1;
while ((len = fis.read(bytes)) != -1){
out.write(bytes, 0, len);
}
out.flush();
zipFile.delete();
BufferedReader bw = new BufferedReader(new InputStreamReader(conn.getInputStream(), "utf-8"));
StringBuilder sb = new StringBuilder();
String line = bw.readLine();
while (line != null) {
sb.append(line);
line = bw.readLine();
}
String[] info = sb.toString().split(":");
int code = Integer.parseInt(info[0].trim());
rc.onFinish(code == 104, 0);
} catch (Exception e) {
e.printStackTrace();
rc.onError(e);
} finally {
IOUtils.close(fis);
if (conn != null) {
conn.disconnect();
}
}
});
}
@Override
public void backupError(@NonNull String msg) {
ToastUtils.showError(msg);
rc.onFinish(false, 0);
}
}, false);
}
/**
* 网络恢复
* @return
*/
public static void webRestore(ResultCallback rc){
Map<String,String> userInfo = readConfig();
if (userInfo == null){
rc.onFinish(false, 0);
}
FileOutputStream fos = null;
File zipFile = FileUtils.getFile(APPCONST.FILE_DIR + "webBackup.zip");
HttpURLConnection conn = null;
try {
URL url = new URL(URLCONST.APP_WEB_URL + "ret?username=" + userInfo.get("userName") +
makeSignalParam());
conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setDoInput(true);
InputStream is = conn.getInputStream();
fos = new FileOutputStream(zipFile);
//一边读,一边写
byte[] bytes = new byte[512];
int readCount = 0;
while ((readCount = is.read(bytes)) != -1) {
fos.write(bytes,0, readCount);
}
//刷新,输出流一定要刷新
fos.flush();
if (zipFile.length() == 0){
zipFile.delete();
rc.onFinish(false, 0);
}
ZipUtils.unzipFile(zipFile.getAbsolutePath(), APPCONST.FILE_DIR);
Restore.INSTANCE.restore(APPCONST.FILE_DIR + "webBackup/", new Restore.CallBack() {
@Override
public void restoreSuccess() {
zipFile.delete();
rc.onFinish(true, 0);
}
@Override
public void restoreError(@NonNull String msg) {
ToastUtils.showError(msg);
rc.onFinish(false, 0);
}
});
} catch (Exception e) {
e.printStackTrace();
rc.onError(e);
}finally {
IOUtils.close(fos);
if (conn != null) {
conn.disconnect();
}
}
}
public static String makeSignalParam(){
return "&signal=" + AppInfoUtils.getSingInfo(App.getmContext(),
App.getApplication().getPackageName(), AppInfoUtils.SHA1);
}
/**
* 判断是否登录
* @return
*/
public static boolean isLogin(){
File file = App.getApplication().getFileStreamPath("userConfig.fy");
return file.exists();
}
}

@ -26,7 +26,7 @@ import java.io.File
* @author fengyue * @author fengyue
* @date 2021/12/9 10:17 * @date 2021/12/9 10:17
*/ */
object UserService2 { object UserService {
fun login(user: User): Single<Result> { fun login(user: User): Single<Result> {
return Single.create(SingleOnSubscribe<Result> { return Single.create(SingleOnSubscribe<Result> {
@ -200,6 +200,6 @@ object UserService2 {
App.getmContext(), App.getmContext(),
App.getApplication().packageName, App.getApplication().packageName,
AppInfoUtils.SHA1 AppInfoUtils.SHA1
) + "&appVersion=" + App.getVersionCode() ) + "&appVersion=" + App.getVersionCode() + "&isDebug=" + App.isDebug()
} }
} }

@ -17,9 +17,9 @@ import xyz.fycz.myreader.common.APPCONST
import xyz.fycz.myreader.databinding.ActivityAuthEmailBinding import xyz.fycz.myreader.databinding.ActivityAuthEmailBinding
import xyz.fycz.myreader.model.user.Result import xyz.fycz.myreader.model.user.Result
import xyz.fycz.myreader.model.user.User import xyz.fycz.myreader.model.user.User
import xyz.fycz.myreader.model.user.UserService2.bindEmail import xyz.fycz.myreader.model.user.UserService.bindEmail
import xyz.fycz.myreader.model.user.UserService2.resetPwd import xyz.fycz.myreader.model.user.UserService.resetPwd
import xyz.fycz.myreader.model.user.UserService2.sendEmail import xyz.fycz.myreader.model.user.UserService.sendEmail
import xyz.fycz.myreader.ui.dialog.DialogCreator import xyz.fycz.myreader.ui.dialog.DialogCreator
import xyz.fycz.myreader.ui.dialog.LoadingDialog import xyz.fycz.myreader.ui.dialog.LoadingDialog
import xyz.fycz.myreader.util.CyptoUtils import xyz.fycz.myreader.util.CyptoUtils

@ -257,8 +257,9 @@ public class BookDetailedActivity extends BaseActivity {
} }
mSourceDialog.setABooks(aBooks); mSourceDialog.setABooks(aBooks);
mSourceDialog.setSourceIndex(sourceIndex); mSourceDialog.setSourceIndex(sourceIndex);
if (AdUtils.getAdConfig().isHasAd() && AdUtils.getAdConfig().isShowFlowAd()){
//initAd(); initAd();
}
} }
private void initAd() { private void initAd() {

@ -24,7 +24,7 @@ import xyz.fycz.myreader.common.APPCONST;
import xyz.fycz.myreader.databinding.ActivityLoginBinding; import xyz.fycz.myreader.databinding.ActivityLoginBinding;
import xyz.fycz.myreader.model.user.Result; import xyz.fycz.myreader.model.user.Result;
import xyz.fycz.myreader.model.user.User; import xyz.fycz.myreader.model.user.User;
import xyz.fycz.myreader.model.user.UserService2; import xyz.fycz.myreader.model.user.UserService;
import xyz.fycz.myreader.ui.dialog.DialogCreator; import xyz.fycz.myreader.ui.dialog.DialogCreator;
import xyz.fycz.myreader.ui.dialog.LoadingDialog; import xyz.fycz.myreader.ui.dialog.LoadingDialog;
import xyz.fycz.myreader.util.CodeUtil; import xyz.fycz.myreader.util.CodeUtil;
@ -73,7 +73,7 @@ public class LoginActivity extends BaseActivity implements TextWatcher {
protected void initWidget() { protected void initWidget() {
super.initWidget(); super.initWidget();
createCaptcha(); createCaptcha();
String username = UserService2.INSTANCE.readUsername(); String username = UserService.INSTANCE.readUsername();
binding.etUser.getEditText().setText(username); binding.etUser.getEditText().setText(username);
binding.etUser.getEditText().requestFocus(username.length()); binding.etUser.getEditText().requestFocus(username.length());
//监听内容改变 -> 控制按钮的点击状态 //监听内容改变 -> 控制按钮的点击状态
@ -101,7 +101,7 @@ public class LoginActivity extends BaseActivity implements TextWatcher {
String loginPwd = binding.etPassword.getEditText().getText().toString(); String loginPwd = binding.etPassword.getEditText().getText().toString();
user = new User(loginName, CyptoUtils.encode(APPCONST.KEY, loginPwd)); user = new User(loginName, CyptoUtils.encode(APPCONST.KEY, loginPwd));
dialog.show(); dialog.show();
UserService2.INSTANCE.login(user).subscribe(new MySingleObserver<Result>() { UserService.INSTANCE.login(user).subscribe(new MySingleObserver<Result>() {
@Override @Override
public void onSubscribe(Disposable d) { public void onSubscribe(Disposable d) {
addDisposable(d); addDisposable(d);
@ -154,8 +154,8 @@ public class LoginActivity extends BaseActivity implements TextWatcher {
} }
private void loginSuccess() { private void loginSuccess() {
UserService2.INSTANCE.writeConfig(user); UserService.INSTANCE.writeConfig(user);
UserService2.INSTANCE.writeUsername(user.getUserName()); UserService.INSTANCE.writeUsername(user.getUserName());
Intent intent = new Intent(); Intent intent = new Intent();
intent.putExtra("isLogin", true); intent.putExtra("isLogin", true);
setResult(Activity.RESULT_OK, intent); setResult(Activity.RESULT_OK, intent);

@ -19,7 +19,7 @@ import xyz.fycz.myreader.common.APPCONST;
import xyz.fycz.myreader.databinding.ActivityRegisterBinding; import xyz.fycz.myreader.databinding.ActivityRegisterBinding;
import xyz.fycz.myreader.model.user.Result; import xyz.fycz.myreader.model.user.Result;
import xyz.fycz.myreader.model.user.User; import xyz.fycz.myreader.model.user.User;
import xyz.fycz.myreader.model.user.UserService2; import xyz.fycz.myreader.model.user.UserService;
import xyz.fycz.myreader.ui.dialog.DialogCreator; import xyz.fycz.myreader.ui.dialog.DialogCreator;
import xyz.fycz.myreader.ui.dialog.LoadingDialog; import xyz.fycz.myreader.ui.dialog.LoadingDialog;
import xyz.fycz.myreader.util.CodeUtil; import xyz.fycz.myreader.util.CodeUtil;
@ -153,7 +153,7 @@ public class RegisterActivity extends BaseActivity {
} }
dialog.show(); dialog.show();
dialog.setmMessage("正在发送"); dialog.setmMessage("正在发送");
UserService2.INSTANCE.sendEmail(email, "reg", keyc).subscribe(new MySingleObserver<Result>() { UserService.INSTANCE.sendEmail(email, "reg", keyc).subscribe(new MySingleObserver<Result>() {
@Override @Override
public void onSubscribe(Disposable d) { public void onSubscribe(Disposable d) {
addDisposable(d); addDisposable(d);
@ -202,7 +202,7 @@ public class RegisterActivity extends BaseActivity {
dialog.show(); dialog.show();
dialog.setmMessage("正在注册"); dialog.setmMessage("正在注册");
User user = new User(username, CyptoUtils.encode(APPCONST.KEY, password), email); User user = new User(username, CyptoUtils.encode(APPCONST.KEY, password), email);
UserService2.INSTANCE.register(user, emailCode, keyc).subscribe(new MySingleObserver<Result>() { UserService.INSTANCE.register(user, emailCode, keyc).subscribe(new MySingleObserver<Result>() {
@Override @Override
public void onSubscribe(Disposable d) { public void onSubscribe(Disposable d) {
addDisposable(d); addDisposable(d);
@ -212,7 +212,7 @@ public class RegisterActivity extends BaseActivity {
@Override @Override
public void onSuccess(@NonNull Result result) { public void onSuccess(@NonNull Result result) {
if (result.getCode() == 101) { if (result.getCode() == 101) {
UserService2.INSTANCE.writeUsername(user.getUserName()); UserService.INSTANCE.writeUsername(user.getUserName());
ToastUtils.showSuccess(result.getResult().toString()); ToastUtils.showSuccess(result.getResult().toString());
finish(); finish();
} else { } else {

@ -16,6 +16,7 @@ import com.bumptech.glide.request.RequestOptions;
import com.bumptech.glide.signature.ObjectKey; import com.bumptech.glide.signature.ObjectKey;
import com.gyf.immersionbar.ImmersionBar; import com.gyf.immersionbar.ImmersionBar;
import com.hjq.permissions.OnPermissionCallback; import com.hjq.permissions.OnPermissionCallback;
import com.hjq.permissions.Permission;
import com.hjq.permissions.XXPermissions; import com.hjq.permissions.XXPermissions;
import com.weaction.ddsdk.ad.DdSdkSplashAd; import com.weaction.ddsdk.ad.DdSdkSplashAd;
@ -350,6 +351,11 @@ public class SplashActivity extends BaseActivity {
private void requestPermission() { private void requestPermission() {
//获取读取和写入SD卡的权限 //获取读取和写入SD卡的权限
XXPermissions.with(this) XXPermissions.with(this)
/*.permission(new String[]{Permission.READ_PHONE_STATE,
Permission.WRITE_EXTERNAL_STORAGE,
Permission.READ_EXTERNAL_STORAGE,
Permission.ACCESS_FINE_LOCATION,
Permission.ACCESS_COARSE_LOCATION})*/
.permission(APPCONST.STORAGE_PERMISSIONS) .permission(APPCONST.STORAGE_PERMISSIONS)
.request(new OnPermissionCallback() { .request(new OnPermissionCallback() {
@Override @Override
@ -359,7 +365,8 @@ public class SplashActivity extends BaseActivity {
@Override @Override
public void onDenied(List<String> permissions, boolean never) { public void onDenied(List<String> permissions, boolean never) {
ToastUtils.showWarring("储存权限被拒绝,部分功能可能无法正常运行!"); if (permissions.contains(Permission.WRITE_EXTERNAL_STORAGE))
ToastUtils.showWarring("储存权限被拒绝,部分功能可能无法正常运行!");
start(); start();
} }
}); });

@ -45,12 +45,11 @@ import xyz.fycz.myreader.model.storage.Restore;
import xyz.fycz.myreader.model.storage.WebDavHelp; import xyz.fycz.myreader.model.storage.WebDavHelp;
import xyz.fycz.myreader.model.user.Result; import xyz.fycz.myreader.model.user.Result;
import xyz.fycz.myreader.model.user.User; import xyz.fycz.myreader.model.user.User;
import xyz.fycz.myreader.model.user.UserService2; import xyz.fycz.myreader.model.user.UserService;
import xyz.fycz.myreader.ui.activity.AboutActivity; import xyz.fycz.myreader.ui.activity.AboutActivity;
import xyz.fycz.myreader.ui.activity.AdSettingActivity; import xyz.fycz.myreader.ui.activity.AdSettingActivity;
import xyz.fycz.myreader.ui.activity.BookSourceActivity; import xyz.fycz.myreader.ui.activity.BookSourceActivity;
import xyz.fycz.myreader.ui.activity.DonateActivity; import xyz.fycz.myreader.ui.activity.DonateActivity;
import xyz.fycz.myreader.ui.activity.FeedbackActivity;
import xyz.fycz.myreader.ui.activity.LoginActivity; import xyz.fycz.myreader.ui.activity.LoginActivity;
import xyz.fycz.myreader.ui.activity.MainActivity; import xyz.fycz.myreader.ui.activity.MainActivity;
import xyz.fycz.myreader.ui.activity.MoreSettingActivity; import xyz.fycz.myreader.ui.activity.MoreSettingActivity;
@ -109,7 +108,7 @@ public class MineFragment extends BaseFragment {
@Override @Override
protected void initData(Bundle savedInstanceState) { protected void initData(Bundle savedInstanceState) {
super.initData(savedInstanceState); super.initData(savedInstanceState);
user = UserService2.INSTANCE.readConfig(); user = UserService.INSTANCE.readConfig();
isLogin = user != null && !TextUtils.isEmpty(user.getUserName()); isLogin = user != null && !TextUtils.isEmpty(user.getUserName());
mSetting = SysManager.getSetting(); mSetting = SysManager.getSetting();
webSynMenu = new String[]{ webSynMenu = new String[]{
@ -502,7 +501,7 @@ public class MineFragment extends BaseFragment {
String synTime = spb.getString(getString(R.string.synTime)); String synTime = spb.getString(getString(R.string.synTime));
if (!nowTimeStr.equals(synTime) || !isAutoSyn) { if (!nowTimeStr.equals(synTime) || !isAutoSyn) {
dialog.show(); dialog.show();
UserService2.INSTANCE.webBackup(user).subscribe(new MySingleObserver<Result>() { UserService.INSTANCE.webBackup(user).subscribe(new MySingleObserver<Result>() {
@Override @Override
public void onSubscribe(Disposable d) { public void onSubscribe(Disposable d) {
addDisposable(d); addDisposable(d);
@ -548,17 +547,8 @@ public class MineFragment extends BaseFragment {
DialogCreator.createCommonDialog(getContext(), "确认同步吗?", "将书架从网络同步至本地会覆盖原有书架!", true, DialogCreator.createCommonDialog(getContext(), "确认同步吗?", "将书架从网络同步至本地会覆盖原有书架!", true,
(dialogInterface, i) -> { (dialogInterface, i) -> {
dialogInterface.dismiss(); dialogInterface.dismiss();
/*if (UserService.webRestore()) {
mHandler.sendMessage(mHandler.obtainMessage(7));
// DialogCreator.createTipDialog(mMainActivity,
// "恢复成功!\n注意:本功能属于实验功能,书架恢复后,书籍初次加载时可能加载失败,返回重新加载即可!");、
mSetting = SysManager.getSetting();
ToastUtils.showSuccess("成功将书架从网络同步至本地!");
} else {
DialogCreator.createTipDialog(getContext(), "未找到同步文件,同步失败!");
}*/
dialog.show(); dialog.show();
UserService2.INSTANCE.webRestore(user).subscribe(new MySingleObserver<Result>() { UserService.INSTANCE.webRestore(user).subscribe(new MySingleObserver<Result>() {
@Override @Override
public void onSubscribe(Disposable d) { public void onSubscribe(Disposable d) {
addDisposable(d); addDisposable(d);
@ -600,7 +590,7 @@ public class MineFragment extends BaseFragment {
case APPCONST.REQUEST_LOGIN: case APPCONST.REQUEST_LOGIN:
assert data != null; assert data != null;
isLogin = data.getBooleanExtra("isLogin", false); isLogin = data.getBooleanExtra("isLogin", false);
user = UserService2.INSTANCE.readConfig(); user = UserService.INSTANCE.readConfig();
if (isLogin && user != null) { if (isLogin && user != null) {
binding.tvUser.setText(user.getUserName()); binding.tvUser.setText(user.getUserName());
} }

@ -56,7 +56,7 @@ import xyz.fycz.myreader.greendao.service.BookGroupService;
import xyz.fycz.myreader.greendao.service.BookService; import xyz.fycz.myreader.greendao.service.BookService;
import xyz.fycz.myreader.greendao.service.ChapterService; import xyz.fycz.myreader.greendao.service.ChapterService;
import xyz.fycz.myreader.model.user.Result; import xyz.fycz.myreader.model.user.Result;
import xyz.fycz.myreader.model.user.UserService2; import xyz.fycz.myreader.model.user.UserService;
import xyz.fycz.myreader.ui.activity.FileSystemActivity; import xyz.fycz.myreader.ui.activity.FileSystemActivity;
import xyz.fycz.myreader.ui.activity.GroupManagerActivity; import xyz.fycz.myreader.ui.activity.GroupManagerActivity;
import xyz.fycz.myreader.ui.activity.MainActivity; import xyz.fycz.myreader.ui.activity.MainActivity;
@ -175,7 +175,7 @@ public class BookcasePresenter implements BasePresenter {
getData(); getData();
if (mSetting.isAutoSyn() && UserService2.INSTANCE.isLogin()) { if (mSetting.isAutoSyn() && UserService.INSTANCE.isLogin()) {
synBookcaseToWeb(true); synBookcaseToWeb(true);
} }
@ -986,7 +986,7 @@ public class BookcasePresenter implements BasePresenter {
SharedPreUtils spb = SharedPreUtils.getInstance(); SharedPreUtils spb = SharedPreUtils.getInstance();
String synTime = spb.getString(mMainActivity.getString(R.string.synTime)); String synTime = spb.getString(mMainActivity.getString(R.string.synTime));
if (!nowTimeStr.equals(synTime) || !isAutoSyn) { if (!nowTimeStr.equals(synTime) || !isAutoSyn) {
UserService2.INSTANCE.webBackup(UserService2.INSTANCE.readConfig()).subscribe(new MySingleObserver<Result>() { UserService.INSTANCE.webBackup(UserService.INSTANCE.readConfig()).subscribe(new MySingleObserver<Result>() {
@Override @Override
public void onSubscribe(Disposable d) { public void onSubscribe(Disposable d) {
mMainActivity.addDisposable(d); mMainActivity.addDisposable(d);

@ -19,7 +19,6 @@ import xyz.fycz.myreader.base.observer.MySingleObserver;
import xyz.fycz.myreader.common.URLCONST; import xyz.fycz.myreader.common.URLCONST;
import xyz.fycz.myreader.entity.AdBean; import xyz.fycz.myreader.entity.AdBean;
import xyz.fycz.myreader.model.user.UserService; import xyz.fycz.myreader.model.user.UserService;
import xyz.fycz.myreader.model.user.UserService2;
import xyz.fycz.myreader.util.SharedPreUtils; import xyz.fycz.myreader.util.SharedPreUtils;
import xyz.fycz.myreader.util.help.DateHelper; import xyz.fycz.myreader.util.help.DateHelper;
@ -30,7 +29,7 @@ import xyz.fycz.myreader.util.help.DateHelper;
public class AdUtils { public class AdUtils {
public static final String TAG = AdUtils.class.getSimpleName(); public static final String TAG = AdUtils.class.getSimpleName();
private static boolean hasInitAd = false; private static boolean hasInitAd = false;
public static AdBean adConfig; private static AdBean adConfig;
static { static {
String config = SharedPreUtils.getInstance(true).getString("adConfig"); String config = SharedPreUtils.getInstance(true).getString("adConfig");
@ -45,7 +44,7 @@ public class AdUtils {
boolean hasAd = false; boolean hasAd = false;
if (!adConfig.isCloud()) { if (!adConfig.isCloud()) {
MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded"); MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
String body = "type=adConfig" + UserService2.INSTANCE.makeAuth(); String body = "type=adConfig" + UserService.INSTANCE.makeAuth();
RequestBody requestBody = RequestBody.create(mediaType, body); RequestBody requestBody = RequestBody.create(mediaType, body);
String jsonStr = OkHttpUtils.getHtml(URLCONST.AD_URL, requestBody, "UTF-8"); String jsonStr = OkHttpUtils.getHtml(URLCONST.AD_URL, requestBody, "UTF-8");
try { try {
@ -60,6 +59,7 @@ public class AdUtils {
String res = jsonObject.getString("result"); String res = jsonObject.getString("result");
SharedPreUtils.getInstance(true).putString("adConfig", res); SharedPreUtils.getInstance(true).putString("adConfig", res);
adConfig = GsonExtensionsKt.getGSON().fromJson(res, AdBean.class); adConfig = GsonExtensionsKt.getGSON().fromJson(res, AdBean.class);
adConfig.setCloud(true);
hasAd = adConfig.isHasAd(); hasAd = adConfig.isHasAd();
} }
Log.i(TAG, "hasAd:" + hasAd); Log.i(TAG, "hasAd:" + hasAd);
@ -76,7 +76,7 @@ public class AdUtils {
public static void adRecord(String type, String name) { public static void adRecord(String type, String name) {
Single.create((SingleOnSubscribe<Boolean>) emitter -> { Single.create((SingleOnSubscribe<Boolean>) emitter -> {
MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded"); MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
String body = "adType=" + type + "&type=" + name + UserService2.INSTANCE.makeAuth(); String body = "adType=" + type + "&type=" + name + UserService.INSTANCE.makeAuth();
RequestBody requestBody = RequestBody.create(mediaType, body); RequestBody requestBody = RequestBody.create(mediaType, body);
OkHttpUtils.getHtml(URLCONST.AD_URL, requestBody, "UTF-8"); OkHttpUtils.getHtml(URLCONST.AD_URL, requestBody, "UTF-8");
emitter.onSuccess(true); emitter.onSuccess(true);
@ -96,7 +96,7 @@ public class AdUtils {
public static Single<int[]> adTimes() { public static Single<int[]> adTimes() {
return Single.create((SingleOnSubscribe<int[]>) emitter -> { return Single.create((SingleOnSubscribe<int[]>) emitter -> {
MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded"); MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
String body = "type=adTimes" + UserService2.INSTANCE.makeAuth(); String body = "type=adTimes" + UserService.INSTANCE.makeAuth();
RequestBody requestBody = RequestBody.create(mediaType, body); RequestBody requestBody = RequestBody.create(mediaType, body);
String jsonStr = OkHttpUtils.getHtml(URLCONST.AD_URL, requestBody, "UTF-8"); String jsonStr = OkHttpUtils.getHtml(URLCONST.AD_URL, requestBody, "UTF-8");
JSONObject jsonObject = new JSONObject(jsonStr); JSONObject jsonObject = new JSONObject(jsonStr);
@ -144,6 +144,7 @@ public class AdUtils {
} }
public static boolean backSplashAd() { public static boolean backSplashAd() {
if (!adConfig.isHasAd()) return false;
SharedPreUtils sp = SharedPreUtils.getInstance(true); SharedPreUtils sp = SharedPreUtils.getInstance(true);
Long splashAdTime = sp.getLong("splashAdTime"); Long splashAdTime = sp.getLong("splashAdTime");
Long backTime = sp.getLong("backTime"); Long backTime = sp.getLong("backTime");
@ -152,6 +153,10 @@ public class AdUtils {
currentTime - backTime >= adConfig.getBackAdTime() * 60L * 1000; currentTime - backTime >= adConfig.getBackAdTime() * 60L * 1000;
} }
public static AdBean getAdConfig() {
return adConfig;
}
public static void initAd() { public static void initAd() {
/*if (!hasInitAd) { /*if (!hasInitAd) {
hasInitAd = true; hasInitAd = true;

@ -1,3 +1,3 @@
#Fri Jun 18 21:45:31 CST 2021 #Fri Jun 18 21:45:31 CST 2021
VERSION_CODE=236 VERSION_CODE=238
NEED_CREATE_RELEASE=true NEED_CREATE_RELEASE=true

Loading…
Cancel
Save