diff --git a/app/build.gradle b/app/build.gradle index c2bf5f4..059019b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -91,6 +91,9 @@ android { if (keyPropsFile.exists()) { signingConfig signingConfigs.myConifg } + ndk { + abiFilters "armeabi-v7a", "arm64-v8a" + } } debug { minifyEnabled false @@ -99,6 +102,9 @@ android { signingConfig signingConfigs.myConifg } versionNameSuffix "-debug" + ndk { + abiFilters "armeabi-v7a", "arm64-v8a" + } } android.applicationVariants.all { variant -> variant.outputs.all { diff --git a/app/libs/ddsdk-release.aar b/app/libs/ddsdk-release.aar index 05b32b5..1fb6616 100644 Binary files a/app/libs/ddsdk-release.aar and b/app/libs/ddsdk-release.aar differ diff --git a/app/src/main/assets/updatelog.fy b/app/src/main/assets/updatelog.fy index 8a41a4e..435d80d 100644 --- a/app/src/main/assets/updatelog.fy +++ b/app/src/main/assets/updatelog.fy @@ -1,8 +1,16 @@ +2022.02.23 +风月读书v2.3.8 +更新内容: +1、部分设备兼容性适配 +2、尝试解决搜索卡死的问题 +3、修复部分已知bug + 2022.02.17 风月读书v2.3.7 更新内容: 1、新增邮箱登录 2、新增开屏广告 +3、支持作者界面新增广告支持作者 注:由于广告投放次数的需要,此次更新为强制更新 2022.02.07 diff --git a/app/src/main/java/xyz/fycz/myreader/entity/AdBean.java b/app/src/main/java/xyz/fycz/myreader/entity/AdBean.java index 1a75bd6..171549f 100644 --- a/app/src/main/java/xyz/fycz/myreader/entity/AdBean.java +++ b/app/src/main/java/xyz/fycz/myreader/entity/AdBean.java @@ -13,6 +13,8 @@ public class AdBean { private int backAdTime; //应用回到前台展示广告间隔(单位:分钟) private int intervalAdTime; + //是否在详情页展示信息流广告 + private boolean showFlowAd; public AdBean() { } @@ -23,6 +25,13 @@ public class AdBean { 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() { return isCloud; } @@ -54,4 +63,12 @@ public class AdBean { public void setIntervalAdTime(int intervalAdTime) { this.intervalAdTime = intervalAdTime; } + + public boolean isShowFlowAd() { + return showFlowAd; + } + + public void setShowFlowAd(boolean showFlowAd) { + this.showFlowAd = showFlowAd; + } } diff --git a/app/src/main/java/xyz/fycz/myreader/model/SearchEngine.java b/app/src/main/java/xyz/fycz/myreader/model/SearchEngine.java index c5c4cc6..d8a1153 100644 --- a/app/src/main/java/xyz/fycz/myreader/model/SearchEngine.java +++ b/app/src/main/java/xyz/fycz/myreader/model/SearchEngine.java @@ -50,7 +50,7 @@ public class SearchEngine { private OnSearchListener searchListener; 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) { @@ -143,7 +143,8 @@ public class SearchEngine { searchSiteIndex++; if (searchSiteIndex < mSourceList.size()) { ReadCrawler crawler = mSourceList.get(searchSiteIndex); - BookApi.search(keyword, crawler, executorService) + //BookApi.search(keyword, crawler, executorService) + BookApi.search(keyword, crawler) .subscribeOn(scheduler) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Observer>() { @@ -191,7 +192,8 @@ public class SearchEngine { if (searchSiteIndex < mSourceList.size()) { ReadCrawler crawler = mSourceList.get(searchSiteIndex); String searchKey = title; - BookApi.search(searchKey, crawler, executorService) + //BookApi.search(searchKey, crawler, executorService) + BookApi.search(searchKey, crawler) .subscribeOn(scheduler) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Observer>() { diff --git a/app/src/main/java/xyz/fycz/myreader/model/user/UserService.java b/app/src/main/java/xyz/fycz/myreader/model/user/UserService.java deleted file mode 100644 index 75bb439..0000000 --- a/app/src/main/java/xyz/fycz/myreader/model/user/UserService.java +++ /dev/null @@ -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 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 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 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 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 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 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 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(); - } -} diff --git a/app/src/main/java/xyz/fycz/myreader/model/user/UserService2.kt b/app/src/main/java/xyz/fycz/myreader/model/user/UserService.kt similarity index 98% rename from app/src/main/java/xyz/fycz/myreader/model/user/UserService2.kt rename to app/src/main/java/xyz/fycz/myreader/model/user/UserService.kt index 62cdcfa..74caa55 100644 --- a/app/src/main/java/xyz/fycz/myreader/model/user/UserService2.kt +++ b/app/src/main/java/xyz/fycz/myreader/model/user/UserService.kt @@ -26,7 +26,7 @@ import java.io.File * @author fengyue * @date 2021/12/9 10:17 */ -object UserService2 { +object UserService { fun login(user: User): Single { return Single.create(SingleOnSubscribe { @@ -200,6 +200,6 @@ object UserService2 { App.getmContext(), App.getApplication().packageName, AppInfoUtils.SHA1 - ) + "&appVersion=" + App.getVersionCode() + ) + "&appVersion=" + App.getVersionCode() + "&isDebug=" + App.isDebug() } } \ No newline at end of file diff --git a/app/src/main/java/xyz/fycz/myreader/ui/activity/AuthEmailActivity.kt b/app/src/main/java/xyz/fycz/myreader/ui/activity/AuthEmailActivity.kt index e410e68..2d7a1d8 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/activity/AuthEmailActivity.kt +++ b/app/src/main/java/xyz/fycz/myreader/ui/activity/AuthEmailActivity.kt @@ -17,9 +17,9 @@ import xyz.fycz.myreader.common.APPCONST import xyz.fycz.myreader.databinding.ActivityAuthEmailBinding import xyz.fycz.myreader.model.user.Result import xyz.fycz.myreader.model.user.User -import xyz.fycz.myreader.model.user.UserService2.bindEmail -import xyz.fycz.myreader.model.user.UserService2.resetPwd -import xyz.fycz.myreader.model.user.UserService2.sendEmail +import xyz.fycz.myreader.model.user.UserService.bindEmail +import xyz.fycz.myreader.model.user.UserService.resetPwd +import xyz.fycz.myreader.model.user.UserService.sendEmail import xyz.fycz.myreader.ui.dialog.DialogCreator import xyz.fycz.myreader.ui.dialog.LoadingDialog import xyz.fycz.myreader.util.CyptoUtils diff --git a/app/src/main/java/xyz/fycz/myreader/ui/activity/BookDetailedActivity.java b/app/src/main/java/xyz/fycz/myreader/ui/activity/BookDetailedActivity.java index 7e860c6..a69c1d2 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/activity/BookDetailedActivity.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/activity/BookDetailedActivity.java @@ -257,8 +257,9 @@ public class BookDetailedActivity extends BaseActivity { } mSourceDialog.setABooks(aBooks); mSourceDialog.setSourceIndex(sourceIndex); - - //initAd(); + if (AdUtils.getAdConfig().isHasAd() && AdUtils.getAdConfig().isShowFlowAd()){ + initAd(); + } } private void initAd() { diff --git a/app/src/main/java/xyz/fycz/myreader/ui/activity/LoginActivity.java b/app/src/main/java/xyz/fycz/myreader/ui/activity/LoginActivity.java index 0333ff7..443a108 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/activity/LoginActivity.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/activity/LoginActivity.java @@ -24,7 +24,7 @@ import xyz.fycz.myreader.common.APPCONST; import xyz.fycz.myreader.databinding.ActivityLoginBinding; import xyz.fycz.myreader.model.user.Result; 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.LoadingDialog; import xyz.fycz.myreader.util.CodeUtil; @@ -73,7 +73,7 @@ public class LoginActivity extends BaseActivity implements TextWatcher { protected void initWidget() { super.initWidget(); createCaptcha(); - String username = UserService2.INSTANCE.readUsername(); + String username = UserService.INSTANCE.readUsername(); binding.etUser.getEditText().setText(username); binding.etUser.getEditText().requestFocus(username.length()); //监听内容改变 -> 控制按钮的点击状态 @@ -101,7 +101,7 @@ public class LoginActivity extends BaseActivity implements TextWatcher { String loginPwd = binding.etPassword.getEditText().getText().toString(); user = new User(loginName, CyptoUtils.encode(APPCONST.KEY, loginPwd)); dialog.show(); - UserService2.INSTANCE.login(user).subscribe(new MySingleObserver() { + UserService.INSTANCE.login(user).subscribe(new MySingleObserver() { @Override public void onSubscribe(Disposable d) { addDisposable(d); @@ -154,8 +154,8 @@ public class LoginActivity extends BaseActivity implements TextWatcher { } private void loginSuccess() { - UserService2.INSTANCE.writeConfig(user); - UserService2.INSTANCE.writeUsername(user.getUserName()); + UserService.INSTANCE.writeConfig(user); + UserService.INSTANCE.writeUsername(user.getUserName()); Intent intent = new Intent(); intent.putExtra("isLogin", true); setResult(Activity.RESULT_OK, intent); diff --git a/app/src/main/java/xyz/fycz/myreader/ui/activity/RegisterActivity.java b/app/src/main/java/xyz/fycz/myreader/ui/activity/RegisterActivity.java index 6037308..2b354a2 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/activity/RegisterActivity.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/activity/RegisterActivity.java @@ -19,7 +19,7 @@ import xyz.fycz.myreader.common.APPCONST; import xyz.fycz.myreader.databinding.ActivityRegisterBinding; import xyz.fycz.myreader.model.user.Result; 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.LoadingDialog; import xyz.fycz.myreader.util.CodeUtil; @@ -153,7 +153,7 @@ public class RegisterActivity extends BaseActivity { } dialog.show(); dialog.setmMessage("正在发送"); - UserService2.INSTANCE.sendEmail(email, "reg", keyc).subscribe(new MySingleObserver() { + UserService.INSTANCE.sendEmail(email, "reg", keyc).subscribe(new MySingleObserver() { @Override public void onSubscribe(Disposable d) { addDisposable(d); @@ -202,7 +202,7 @@ public class RegisterActivity extends BaseActivity { dialog.show(); dialog.setmMessage("正在注册"); User user = new User(username, CyptoUtils.encode(APPCONST.KEY, password), email); - UserService2.INSTANCE.register(user, emailCode, keyc).subscribe(new MySingleObserver() { + UserService.INSTANCE.register(user, emailCode, keyc).subscribe(new MySingleObserver() { @Override public void onSubscribe(Disposable d) { addDisposable(d); @@ -212,7 +212,7 @@ public class RegisterActivity extends BaseActivity { @Override public void onSuccess(@NonNull Result result) { if (result.getCode() == 101) { - UserService2.INSTANCE.writeUsername(user.getUserName()); + UserService.INSTANCE.writeUsername(user.getUserName()); ToastUtils.showSuccess(result.getResult().toString()); finish(); } else { diff --git a/app/src/main/java/xyz/fycz/myreader/ui/activity/SplashActivity.java b/app/src/main/java/xyz/fycz/myreader/ui/activity/SplashActivity.java index d67da16..c2116cf 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/activity/SplashActivity.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/activity/SplashActivity.java @@ -16,6 +16,7 @@ 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; @@ -350,6 +351,11 @@ public class SplashActivity extends BaseActivity { private void requestPermission() { //获取读取和写入SD卡的权限 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) .request(new OnPermissionCallback() { @Override @@ -359,7 +365,8 @@ public class SplashActivity extends BaseActivity { @Override public void onDenied(List permissions, boolean never) { - ToastUtils.showWarring("储存权限被拒绝,部分功能可能无法正常运行!"); + if (permissions.contains(Permission.WRITE_EXTERNAL_STORAGE)) + ToastUtils.showWarring("储存权限被拒绝,部分功能可能无法正常运行!"); start(); } }); diff --git a/app/src/main/java/xyz/fycz/myreader/ui/fragment/MineFragment.java b/app/src/main/java/xyz/fycz/myreader/ui/fragment/MineFragment.java index 8989968..a5bdffe 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/fragment/MineFragment.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/fragment/MineFragment.java @@ -45,12 +45,11 @@ import xyz.fycz.myreader.model.storage.Restore; import xyz.fycz.myreader.model.storage.WebDavHelp; import xyz.fycz.myreader.model.user.Result; 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.AdSettingActivity; import xyz.fycz.myreader.ui.activity.BookSourceActivity; 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.MainActivity; import xyz.fycz.myreader.ui.activity.MoreSettingActivity; @@ -109,7 +108,7 @@ public class MineFragment extends BaseFragment { @Override protected void initData(Bundle savedInstanceState) { super.initData(savedInstanceState); - user = UserService2.INSTANCE.readConfig(); + user = UserService.INSTANCE.readConfig(); isLogin = user != null && !TextUtils.isEmpty(user.getUserName()); mSetting = SysManager.getSetting(); webSynMenu = new String[]{ @@ -502,7 +501,7 @@ public class MineFragment extends BaseFragment { String synTime = spb.getString(getString(R.string.synTime)); if (!nowTimeStr.equals(synTime) || !isAutoSyn) { dialog.show(); - UserService2.INSTANCE.webBackup(user).subscribe(new MySingleObserver() { + UserService.INSTANCE.webBackup(user).subscribe(new MySingleObserver() { @Override public void onSubscribe(Disposable d) { addDisposable(d); @@ -548,17 +547,8 @@ public class MineFragment extends BaseFragment { DialogCreator.createCommonDialog(getContext(), "确认同步吗?", "将书架从网络同步至本地会覆盖原有书架!", true, (dialogInterface, i) -> { 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(); - UserService2.INSTANCE.webRestore(user).subscribe(new MySingleObserver() { + UserService.INSTANCE.webRestore(user).subscribe(new MySingleObserver() { @Override public void onSubscribe(Disposable d) { addDisposable(d); @@ -600,7 +590,7 @@ public class MineFragment extends BaseFragment { case APPCONST.REQUEST_LOGIN: assert data != null; isLogin = data.getBooleanExtra("isLogin", false); - user = UserService2.INSTANCE.readConfig(); + user = UserService.INSTANCE.readConfig(); if (isLogin && user != null) { binding.tvUser.setText(user.getUserName()); } diff --git a/app/src/main/java/xyz/fycz/myreader/ui/presenter/BookcasePresenter.java b/app/src/main/java/xyz/fycz/myreader/ui/presenter/BookcasePresenter.java index 1a7c4ed..a8968eb 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/presenter/BookcasePresenter.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/presenter/BookcasePresenter.java @@ -56,7 +56,7 @@ import xyz.fycz.myreader.greendao.service.BookGroupService; import xyz.fycz.myreader.greendao.service.BookService; import xyz.fycz.myreader.greendao.service.ChapterService; 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.GroupManagerActivity; import xyz.fycz.myreader.ui.activity.MainActivity; @@ -175,7 +175,7 @@ public class BookcasePresenter implements BasePresenter { getData(); - if (mSetting.isAutoSyn() && UserService2.INSTANCE.isLogin()) { + if (mSetting.isAutoSyn() && UserService.INSTANCE.isLogin()) { synBookcaseToWeb(true); } @@ -986,7 +986,7 @@ public class BookcasePresenter implements BasePresenter { SharedPreUtils spb = SharedPreUtils.getInstance(); String synTime = spb.getString(mMainActivity.getString(R.string.synTime)); if (!nowTimeStr.equals(synTime) || !isAutoSyn) { - UserService2.INSTANCE.webBackup(UserService2.INSTANCE.readConfig()).subscribe(new MySingleObserver() { + UserService.INSTANCE.webBackup(UserService.INSTANCE.readConfig()).subscribe(new MySingleObserver() { @Override public void onSubscribe(Disposable d) { mMainActivity.addDisposable(d); diff --git a/app/src/main/java/xyz/fycz/myreader/util/utils/AdUtils.java b/app/src/main/java/xyz/fycz/myreader/util/utils/AdUtils.java index 028e971..0996fa9 100644 --- a/app/src/main/java/xyz/fycz/myreader/util/utils/AdUtils.java +++ b/app/src/main/java/xyz/fycz/myreader/util/utils/AdUtils.java @@ -19,7 +19,6 @@ import xyz.fycz.myreader.base.observer.MySingleObserver; import xyz.fycz.myreader.common.URLCONST; import xyz.fycz.myreader.entity.AdBean; 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.help.DateHelper; @@ -30,7 +29,7 @@ import xyz.fycz.myreader.util.help.DateHelper; public class AdUtils { public static final String TAG = AdUtils.class.getSimpleName(); private static boolean hasInitAd = false; - public static AdBean adConfig; + private static AdBean adConfig; static { String config = SharedPreUtils.getInstance(true).getString("adConfig"); @@ -45,7 +44,7 @@ public class AdUtils { boolean hasAd = false; if (!adConfig.isCloud()) { 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); String jsonStr = OkHttpUtils.getHtml(URLCONST.AD_URL, requestBody, "UTF-8"); try { @@ -60,6 +59,7 @@ public class AdUtils { String res = jsonObject.getString("result"); SharedPreUtils.getInstance(true).putString("adConfig", res); adConfig = GsonExtensionsKt.getGSON().fromJson(res, AdBean.class); + adConfig.setCloud(true); hasAd = adConfig.isHasAd(); } Log.i(TAG, "hasAd:" + hasAd); @@ -76,7 +76,7 @@ public class AdUtils { public static void adRecord(String type, String name) { Single.create((SingleOnSubscribe) emitter -> { 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); OkHttpUtils.getHtml(URLCONST.AD_URL, requestBody, "UTF-8"); emitter.onSuccess(true); @@ -96,7 +96,7 @@ public class AdUtils { public static Single adTimes() { return Single.create((SingleOnSubscribe) emitter -> { 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); String jsonStr = OkHttpUtils.getHtml(URLCONST.AD_URL, requestBody, "UTF-8"); JSONObject jsonObject = new JSONObject(jsonStr); @@ -144,6 +144,7 @@ public class AdUtils { } public static boolean backSplashAd() { + if (!adConfig.isHasAd()) return false; SharedPreUtils sp = SharedPreUtils.getInstance(true); Long splashAdTime = sp.getLong("splashAdTime"); Long backTime = sp.getLong("backTime"); @@ -152,6 +153,10 @@ public class AdUtils { currentTime - backTime >= adConfig.getBackAdTime() * 60L * 1000; } + public static AdBean getAdConfig() { + return adConfig; + } + public static void initAd() { /*if (!hasInitAd) { hasInitAd = true; diff --git a/app/version_code.properties b/app/version_code.properties index f81802c..2b9fdba 100644 --- a/app/version_code.properties +++ b/app/version_code.properties @@ -1,3 +1,3 @@ #Fri Jun 18 21:45:31 CST 2021 -VERSION_CODE=236 +VERSION_CODE=238 NEED_CREATE_RELEASE=true