diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index e2eb0fb..616ccfc 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -94,6 +94,7 @@
+
diff --git a/app/src/main/assets/disclaimer.fy b/app/src/main/assets/disclaimer.fy
index 344923a..00cf441 100644
--- a/app/src/main/assets/disclaimer.fy
+++ b/app/src/main/assets/disclaimer.fy
@@ -1,4 +1,7 @@
1、 风月读书是一款提供网络文学搜索的工具,为广大网络文学爱好者提供一种方便、快捷舒适的试读体验。
+
2、 当您搜索一本书的时,风月读书会将该书的书名以关键词的形式提交到各个第三方网络文学网站。各第三方网站返回的内容与风月读书无关,风月读书对其概不负责,亦不承担任何法律责任。任何通过使用风月读书而链接到的第三方网页均系他人制作或提供,您可能从第三方网页上获得其他服务,风月读书对其合法性概不负责,亦不承担任何法律责任。第三方搜索引擎结果根据您提交的书名自动搜索获得并提供试读,不代表风月读书赞成或被搜索链接到的第三方网页上的内容或立场。您应该对使用搜索引擎的结果自行承担风险。
+
3、 风月读书不做任何形式的保证:不保证第三方搜索引擎的搜索结果满足您的要求,不保证搜索服务不中断,不保证搜索结果的安全性、正确性、及时性、合法性。因网络状况、通讯线路、第三方网站等任何原因而导致您不能正常使用阅读,风月读书不承担任何法律责任。风月读书尊重并保护所有使用风月读书用户的个人隐私权,您注册的用户名、电子邮件地址等个人资料,非经您亲自许可或根据相关法律、法规的强制性规定,风月读书不会主动地泄露给第三方。
+
4、 风月读书致力于最大程度地减少网络文学阅读者在自行搜寻过程中的无意义的时间浪费,通过专业搜索展示不同网站中网络文学的最新章节。风月读书在为广大小说爱好者提供方便、快捷舒适的试读体验的同时,也使优秀网络文学得以迅速、更广泛的传播,从而达到了在一定程度促进网络文学充分繁荣发展之目的。风月读书鼓励广大小说爱好者通过风月读书发现优秀网络小说及其提供商,并建议阅读正版图书。任何单位或个人认为通过风月读书搜索链接到的第三方网页内容可能涉嫌侵犯其信息网络传播权,应该及时向风月读书提出书面权力通知,并提供身份证明、权属证明及详细侵权情况证明。风月读书在收到上述法律文件后,将会依法尽快断开相关链接内容。
\ No newline at end of file
diff --git a/app/src/main/assets/updatelog.fy b/app/src/main/assets/updatelog.fy
new file mode 100644
index 0000000..7f85ee5
--- /dev/null
+++ b/app/src/main/assets/updatelog.fy
@@ -0,0 +1,149 @@
+2020.07.31
+风月读书v1.20.073114
+1、新增书架同步功能(需要注册登录)
+2、新增每日自动同步书架功能(默认关闭)
+3、新增书籍一键缓存功能(实验功能,存在bug)
+4、新增关于界面(检查更新、免责声明移至此界面)
+5、修复正在自动翻页退出阅读时闪退的问题
+6、修复软件\字体下载api
+
+2020.07.25
+风月读书v1.20.072519
+1、新增自动翻页
+2、新增目录\书签章节标题搜索
+3、升级SDK版本,更新各种依赖(因组件升级,会重置设置)
+
+2020.07.22
+风月读书v1.20.072217
+1、修复书源“天籁小说”、“品书网”
+2、新增书签功能
+3、优化目录UI,并添加书签列表
+4、修复概率性无法搜索到书籍的问题
+5、修复阅读界面退出时概率性闪退问题
+注:本次更新修复书源,故采用强制更新
+
+2020.07.20
+风月读书v1.20.072009
+1、修复阅读界面“正在加载”时不显示章节内容的问题
+2、修复阅读界面加载时退出闪退的问题
+3、修复本地书籍重复添加的问题
+4、修复阅读设置界面刷新按钮无效的问题
+5、添加本地书籍缓存和源文件被删除后书籍无法加载的提示信息
+6、行书字体更换为方正硬笔行书
+
+2020.07.18
+风月读书v1.20.071809
+1、修复软件内更新下载字体下载失效的问题
+2、修复添加本地书籍的已知bug
+3、修复更换字体后阅读页面显示的问题
+3、优化书籍阅读时下一章节加载速度
+
+2020.07.14
+风月读书v1.20.071415
+1、新增本地书籍导入,支持直接打开txt书籍文件(如书籍文件太大,拆分章节较慢,请耐心等待)
+2、新增登录与注册
+3、新增网络备份与恢复
+4、修复已知bug
+
+2020.07.07
+风月读书v1.20.070721
+1、新增可选择本地字体
+2、新增可在书架缓存书籍
+3、新增书籍移至顶部
+4、修复已知bug
+
+2020.07.02
+风月读书v1.20.070219
+1、修复软件更新及字体下载获取连接失败的问题
+2、提高连接获取速度
+3、优化阅读界面初次加载速度
+
+2020.06.30
+风月读书v1.20.063020
+1、新增软件内更新机制
+2、优化字体下载机制,提升字体下载速度
+3、修复字体下载失败时书籍无法阅读的问题
+
+2020.06.08
+风月读书v1.20.060815
+1、优化书籍缓存机制,减小书籍章节数据占用的空间,提高章节加载速度
+2、修复书籍换源\恢复后初次加载章节内容失败的问题
+
+2020.06.05
+风月读书v1.20.060518
+1、修复部分书籍备份后无法恢复的问题
+2、优化阅读界面设置切换速度
+
+2020.05.26
+风月读书v1.20.052610
+1、优化最后一页提示
+2、修复概率性最新章节显示错误的问题
+
+2020.05.23
+风月读书v1.20.052311
+1、修复部分书籍换源时无显示的bug
+2、修复书籍详情页移除书籍后添加书架失败的bug
+3、新增缓存导出
+4、修复其他已知bug
+
+2020.05.22
+风月读书v1.20.052210
+1、安装包删除自带字体,减小安装包体积,字体可在软件内下载
+2、新增小说缓存导出
+3、修复换源时书源概率性重复的bug
+4、修复初次加载或未联网时目录倒序不显示的bug
+5、修复其他已知bug
+
+2020.05.20
+风月读书v1.20.052021
+1、新增书源品书网(当前共4个书源)
+2、新增书城笔趣阁书源可搜索
+3、修复已知bug
+
+2020.05.19
+风月读书v1.20.051921
+1、搜索界面合并不同书源的相同书籍
+2、书籍详情新增切换书源功能
+3、修复搜索是重复出现书籍列表的bug
+4、修复其他已知bug
+
+2020.05.18
+ 风月读书v1.20.051816
+1、修复更改书源后章节失去第一段的问题(需重新加载小说内容)
+2、修复未联网进入软件闪退的问题
+3、修复其他已知bug
+
+2020.05.18
+风月读书v1.20.051810
+1、新增书城
+2、新增书源天籁小说(可搜索)、笔趣阁(仅限在书城查找)
+3、修复搜索界面只显示书名和作者的问题
+4、修复其他已知bug
+
+2020.05.17
+风月读书v1.20.051716
+1、更改小说源为笔趣44(由于风月小说网的问题,部分小说无法阅读,故做此修改,以后版本会添加多个书源)
+2、特别注意:本次更新需要卸载原软件,会清除所有小说数据(可先备份书架再卸载)!!!
+3、由于更改小说源,搜索界面暂时只显示书名和作者,进入详情页即可显示书籍其他信息
+4、新增免责声明
+
+2020.04.27
+风月读书v1.20.042720
+1、新增书架备份与恢复
+2、新增登录界面(内测中,可通过网络进行书架备份与恢复)
+3、修复已知bug
+
+2020.04.24
+风月读书v1.20.042420更新内容:
+1、新增布局切换
+2、优化刷新
+3、新增阅读百分比
+4、修复进入阅读界面时的亮度偏暗bug
+5、更改更新策略:每次更新版本只会提示一次,取消后如需更新,可手动检查更新
+
+2020.04.21
+风月读书v1.1.4更新内容:
+1、更换书架布局(列表布局),将在下个版本添加布局切换
+2、新增缓存提示对话框
+3、取消自动刷新,新增下拉刷新(需要安卓6.0以上版本)
+4、修复若干已知bug
\ No newline at end of file
diff --git a/app/src/main/java/xyz/fycz/myreader/application/MyApplication.java b/app/src/main/java/xyz/fycz/myreader/application/MyApplication.java
index 170e389..480a43a 100644
--- a/app/src/main/java/xyz/fycz/myreader/application/MyApplication.java
+++ b/app/src/main/java/xyz/fycz/myreader/application/MyApplication.java
@@ -3,6 +3,7 @@ package xyz.fycz.myreader.application;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
+import android.app.Activity;
import android.app.Application;
import android.app.NotificationChannel;
import android.app.NotificationManager;
@@ -239,57 +240,59 @@ public class MyApplication extends Application {
}
});
}*/
- public static void checkVersionByServer(final MainActivity activity, final boolean isManualCheck,
+ public static void checkVersionByServer(final BaseActivity activity, final boolean isManualCheck,
final BookcaseFragment mBookcaseFragment) {
- MyApplication.getApplication().newThread(new Runnable() {
- @Override
- public void run() {
- Document doc = null;
- try {
- String url = "https://shimo.im/docs/cqkgjPRRydYYhQKt/read";
- if (isApkInDebug(getmContext())){
- url = "https://shimo.im/docs/zfzpda7MUGskOC9v/read";
- }
- doc = Jsoup.connect(url).get();
- String content = doc.getElementsByClass("ql-editor").text();
- if (StringHelper.isEmpty(content)){
- TextHelper.showText("检查更新失败!");
- return;
- }
- String[] contents = content.split(";");
- int newestVersion = 0;
- String updateContent = "";
- String downloadLink = null;
- boolean isForceUpdate = false;
- StringBuilder s = new StringBuilder();
- newestVersion = Integer.parseInt(contents[0].substring(contents[0].indexOf(":") + 1));
- isForceUpdate = Boolean.parseBoolean(contents[1].substring(contents[1].indexOf(":") + 1));
- downloadLink = contents[2].substring(contents[2].indexOf(":") + 1);
- updateContent = contents[3].substring(contents[3].indexOf(":") + 1);
- SharedPreUtils spu = SharedPreUtils.getInstance();
- spu.putString("lanzousKeyStart", contents[4].substring(contents[4].indexOf(":") + 1));
- String[] updateContents = updateContent.split("/");
- for (String string : updateContents) {
- s.append(string);
- s.append("\n");
- }
- int versionCode = getVersionCode();
- if (newestVersion > versionCode) {
- MyApplication m = new MyApplication();
- Setting setting = SysManager.getSetting();
- if (isManualCheck || setting.getNewestVersionCode() < newestVersion || isForceUpdate) {
- setting.setNewestVersionCode(newestVersion);
- SysManager.saveSetting(setting);
- m.updateApp(activity, downloadLink, newestVersion, s.toString(), isForceUpdate,
- mBookcaseFragment);
- }
- } else if (isManualCheck) {
- TextHelper.showText("已经是最新版本!");
+ MyApplication.getApplication().newThread(() -> {
+ Document doc = null;
+ try {
+ String url = "https://shimo.im/docs/cqkgjPRRydYYhQKt/read";
+ if (isApkInDebug(getmContext())){
+ url = "https://shimo.im/docs/zfzpda7MUGskOC9v/read";
+ }
+ doc = Jsoup.connect(url).get();
+ String content = doc.getElementsByClass("ql-editor").text();
+ if (StringHelper.isEmpty(content)){
+ TextHelper.showText("检查更新失败!");
+ return;
+ }
+ String[] contents = content.split(";");
+ int newestVersion = 0;
+ String updateContent = "";
+ String downloadLink = null;
+ boolean isForceUpdate = false;
+ StringBuilder s = new StringBuilder();
+ newestVersion = Integer.parseInt(contents[0].substring(contents[0].indexOf(":") + 1));
+ isForceUpdate = Boolean.parseBoolean(contents[1].substring(contents[1].indexOf(":") + 1));
+ downloadLink = contents[2].substring(contents[2].indexOf(":") + 1).trim();
+ updateContent = contents[3].substring(contents[3].indexOf(":") + 1);
+ SharedPreUtils spu = SharedPreUtils.getInstance();
+ spu.putString("lanzousKeyStart", contents[4].substring(contents[4].indexOf(":") + 1));
+ if (!StringHelper.isEmpty(downloadLink)){
+ spu.putString("downloadLink", downloadLink);
+ }else {
+ spu.putString("downloadLink", URLCONST.APP_DIR_UR);
+ }
+ String[] updateContents = updateContent.split("/");
+ for (String string : updateContents) {
+ s.append(string);
+ s.append("\n");
+ }
+ int versionCode = getVersionCode();
+ if (newestVersion > versionCode) {
+ MyApplication m = new MyApplication();
+ Setting setting = SysManager.getSetting();
+ if (isManualCheck || setting.getNewestVersionCode() < newestVersion || isForceUpdate) {
+ setting.setNewestVersionCode(newestVersion);
+ SysManager.saveSetting(setting);
+ m.updateApp(activity, downloadLink, newestVersion, s.toString(), isForceUpdate,
+ mBookcaseFragment);
}
- } catch (Exception e) {
- e.printStackTrace();
- TextHelper.showText("无网络连接!");
+ } else if (isManualCheck) {
+ TextHelper.showText("已经是最新版本!");
}
+ } catch (Exception e) {
+ e.printStackTrace();
+ TextHelper.showText("无网络连接!");
}
});
}
@@ -300,7 +303,7 @@ public class MyApplication extends Application {
* @param activity
* @param versionCode
*/
- public void updateApp(final MainActivity activity, final String url, final int versionCode, String message,
+ public void updateApp(final BaseActivity activity, final String url, final int versionCode, String message,
final boolean isForceUpdate, final BookcaseFragment mBookcaseFragment) {
//String version = (versionCode / 100 % 10) + "." + (versionCode / 10 % 10) + "." + (versionCode % 10);
String cancelTitle;
@@ -309,6 +312,12 @@ public class MyApplication extends Application {
}else {
cancelTitle = "忽略此版本";
}
+ if (mBookcaseFragment == null){
+ DialogCreator.createCommonDialog(activity, "发现新版本:", message, true, "取消", "立即更新", null,
+ (dialog, which) -> goDownload(activity, url));
+ return;
+ }
+
DialogCreator.createThreeButtonDialog(activity, "发现新版本:", message, !isForceUpdate, cancelTitle, "直接下载",
"浏览器下载", (dialog, which) -> {
if (isForceUpdate) {
@@ -329,20 +338,24 @@ public class MyApplication extends Application {
downloadTip.downloadApp();
}
}, (dialog, which) -> {
- String downloadLink = url;
- if (url == null || "".equals(url)) {
- downloadLink = URLCONST.APP_DIR_UR;
- }
- Intent intent = new Intent();
- intent.setAction(Intent.ACTION_VIEW);
- intent.setData(Uri.parse(downloadLink));
- activity.startActivity(intent);
+ goDownload(activity, url);
if (isForceUpdate) {
activity.finish();
}
});
}
+ private void goDownload(Activity activity, String url){
+ String downloadLink = url;
+ if (url == null || "".equals(url)) {
+ downloadLink = URLCONST.APP_DIR_UR;
+ }
+ Intent intent = new Intent();
+ intent.setAction(Intent.ACTION_VIEW);
+ intent.setData(Uri.parse(downloadLink));
+ activity.startActivity(intent);
+ }
+
/**
* 判断当前应用是否是debug状态
*/
diff --git a/app/src/main/java/xyz/fycz/myreader/application/SysManager.java b/app/src/main/java/xyz/fycz/myreader/application/SysManager.java
index 27b5179..8bcc1c1 100644
--- a/app/src/main/java/xyz/fycz/myreader/application/SysManager.java
+++ b/app/src/main/java/xyz/fycz/myreader/application/SysManager.java
@@ -62,6 +62,7 @@ public class SysManager {
setting.setBookcaseStyle(BookcaseStyle.listMode);
setting.setNewestVersionCode(getVersionCode());
setting.setLocalFontName("");
+ setting.setAutoSyn(false);
setting.setSettingVersion(APPCONST.SETTING_VERSION);
return setting;
}
diff --git a/app/src/main/java/xyz/fycz/myreader/backup/UserService.java b/app/src/main/java/xyz/fycz/myreader/backup/UserService.java
index dd451fc..74f2383 100644
--- a/app/src/main/java/xyz/fycz/myreader/backup/UserService.java
+++ b/app/src/main/java/xyz/fycz/myreader/backup/UserService.java
@@ -63,43 +63,40 @@ public class UserService {
}
public static void register(final Map userRegisterInfo, final ResultCallback resultCallback) {
- MyApplication.getApplication().newThread(new Runnable() {
- @Override
- public void run() {
- 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();
- }
+ MyApplication.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();
}
-
}
+
});
}
@@ -122,13 +119,7 @@ public class UserService {
e.printStackTrace();
return false;
} finally {
- if (fos != null) {
- try {
- fos.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
+ IOUtils.close(fos);
}
}
@@ -159,13 +150,7 @@ public class UserService {
} catch (IOException e) {
e.printStackTrace();
}finally {
- if (br != null) {
- try {
- br.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
+ IOUtils.close(br);
}
return null;
}
diff --git a/app/src/main/java/xyz/fycz/myreader/creator/APPDownloadTip.java b/app/src/main/java/xyz/fycz/myreader/creator/APPDownloadTip.java
index cee1252..c597b67 100644
--- a/app/src/main/java/xyz/fycz/myreader/creator/APPDownloadTip.java
+++ b/app/src/main/java/xyz/fycz/myreader/creator/APPDownloadTip.java
@@ -14,6 +14,7 @@ import android.provider.Settings;
import androidx.core.content.FileProvider;
import android.view.View;
import xyz.fycz.myreader.application.MyApplication;
+import xyz.fycz.myreader.base.BaseActivity;
import xyz.fycz.myreader.callback.ResultCallback;
import xyz.fycz.myreader.common.APPCONST;
import xyz.fycz.myreader.ui.home.MainActivity;
@@ -42,10 +43,10 @@ public class APPDownloadTip {
private MainActivity activity;
private boolean isForceUpdate;
- public APPDownloadTip(String url, BookcaseFragment mBookcaseFragment, MainActivity activity, boolean isForceUpdate) {
+ public APPDownloadTip(String url, BookcaseFragment mBookcaseFragment, BaseActivity activity, boolean isForceUpdate) {
this.url = url;
this.mBookcaseFragment = mBookcaseFragment;
- this.activity = activity;
+ this.activity = (MainActivity) activity;
this.isForceUpdate = isForceUpdate;
}
diff --git a/app/src/main/java/xyz/fycz/myreader/creator/DialogCreator.java b/app/src/main/java/xyz/fycz/myreader/creator/DialogCreator.java
index 46b6a94..3eae25f 100644
--- a/app/src/main/java/xyz/fycz/myreader/creator/DialogCreator.java
+++ b/app/src/main/java/xyz/fycz/myreader/creator/DialogCreator.java
@@ -31,8 +31,13 @@ import xyz.fycz.myreader.enums.ReadStyle;
import xyz.fycz.myreader.greendao.entity.Book;
import xyz.fycz.myreader.greendao.entity.Chapter;
import xyz.fycz.myreader.util.BrightUtil;
+import xyz.fycz.myreader.util.IOUtils;
import xyz.fycz.myreader.util.StringHelper;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
import static xyz.fycz.myreader.enums.ReadStyle.blueDeep;
import static xyz.fycz.myreader.enums.ReadStyle.breen;
import static xyz.fycz.myreader.enums.ReadStyle.common;
@@ -701,7 +706,7 @@ public class DialogCreator {
}
});
}
- public static void createTipDialog(Context mContext, String title,String message){
+ public static void createTipDialog(Context mContext, String title, String message){
DialogCreator.createCommonDialog(mContext, title,
message, true, "知道了", new DialogInterface.OnClickListener() {
@Override
@@ -711,6 +716,30 @@ public class DialogCreator {
});
}
+ /**
+ * 从assets文件夹之中读取文件并显示提示框
+ * @param mContext
+ * @param title
+ * @param assetName
+ */
+ public static void createAssetTipDialog(Context mContext, String title, String assetName){
+ BufferedReader br = null;
+ try {
+ br = new BufferedReader(new InputStreamReader(mContext.getAssets().open(assetName)));
+ StringBuilder assetText = new StringBuilder();
+ String line = null;
+ while ((line = br.readLine()) != null) {
+ assetText.append(line);
+ assetText.append("\r\n");
+ }
+ DialogCreator.createTipDialog(mContext, title, assetText.toString());
+ } catch (IOException e) {
+ e.printStackTrace();
+ } finally {
+ IOUtils.close(br);
+ }
+ }
+
public interface OnClickPositiveListener {
void onClick(Dialog dialog, View view);
}
diff --git a/app/src/main/java/xyz/fycz/myreader/entity/Setting.java b/app/src/main/java/xyz/fycz/myreader/entity/Setting.java
index e0382be..e28e94b 100644
--- a/app/src/main/java/xyz/fycz/myreader/entity/Setting.java
+++ b/app/src/main/java/xyz/fycz/myreader/entity/Setting.java
@@ -41,6 +41,8 @@ public class Setting implements Serializable {
private String localFontName;//本地字体名字
+ private boolean isAutoSyn;//是否自动同步书架
+
private int settingVersion;//设置版本号
public int getAutoScrollSpeed() {
@@ -163,6 +165,14 @@ public class Setting implements Serializable {
this.localFontName = localFontName;
}
+ public boolean isAutoSyn() {
+ return isAutoSyn;
+ }
+
+ public void setAutoSyn(boolean autoSyn) {
+ isAutoSyn = autoSyn;
+ }
+
public int getSettingVersion() {
return settingVersion;
}
diff --git a/app/src/main/java/xyz/fycz/myreader/ui/about/AboutActivity.java b/app/src/main/java/xyz/fycz/myreader/ui/about/AboutActivity.java
new file mode 100644
index 0000000..70e6868
--- /dev/null
+++ b/app/src/main/java/xyz/fycz/myreader/ui/about/AboutActivity.java
@@ -0,0 +1,86 @@
+package xyz.fycz.myreader.ui.about;
+
+import android.os.Bundle;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+import androidx.cardview.widget.CardView;
+import butterknife.BindView;
+import butterknife.ButterKnife;
+import com.google.android.material.tabs.TabLayout;
+import xyz.fycz.myreader.R;
+import xyz.fycz.myreader.base.BaseActivity;
+
+/**
+ * @author fengyue
+ * @date 2020/7/31 11:32
+ */
+public class AboutActivity extends BaseActivity {
+
+ @BindView(R.id.ll_title_back)
+ LinearLayout llTitleBack;
+ @BindView(R.id.tv_title_text)
+ TextView tvTitleText;
+ @BindView(R.id.tv_version_name)
+ TextView tvVersionName;
+ @BindView(R.id.vm_author)
+ CardView vmAuthor;
+ @BindView(R.id.vw_share)
+ CardView vmShare;
+ @BindView(R.id.vw_update)
+ CardView vmUpdate;
+ @BindView(R.id.vw_update_log)
+ CardView vmUpdateLog;
+ @BindView(R.id.vw_git)
+ CardView vmGit;
+ @BindView(R.id.vw_disclaimer)
+ CardView vmDisclaimer;
+
+ private AboutPresent mAboutPresent;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_about);
+ ButterKnife.bind(this);
+ setStatusBar(R.color.sys_line);
+ mAboutPresent = new AboutPresent(this);
+ mAboutPresent.start();
+ }
+
+
+ public LinearLayout getLlTitleBack() {
+ return llTitleBack;
+ }
+
+ public TextView getTvTitleText() {
+ return tvTitleText;
+ }
+
+ public TextView getTvVersionName() {
+ return tvVersionName;
+ }
+
+ public CardView getVmAuthor() {
+ return vmAuthor;
+ }
+
+ public CardView getVmShare() {
+ return vmShare;
+ }
+
+ public CardView getVmUpdate() {
+ return vmUpdate;
+ }
+
+ public CardView getVmUpdateLog() {
+ return vmUpdateLog;
+ }
+
+ public CardView getVmGit() {
+ return vmGit;
+ }
+
+ public CardView getVmDisclaimer() {
+ return vmDisclaimer;
+ }
+}
diff --git a/app/src/main/java/xyz/fycz/myreader/ui/about/AboutPresent.java b/app/src/main/java/xyz/fycz/myreader/ui/about/AboutPresent.java
new file mode 100644
index 0000000..b7bd3fa
--- /dev/null
+++ b/app/src/main/java/xyz/fycz/myreader/ui/about/AboutPresent.java
@@ -0,0 +1,61 @@
+package xyz.fycz.myreader.ui.about;
+
+import android.annotation.SuppressLint;
+import android.content.ClipData;
+import android.content.ClipboardManager;
+import android.content.Context;
+import android.content.Intent;
+import android.net.Uri;
+import xyz.fycz.myreader.R;
+import xyz.fycz.myreader.application.MyApplication;
+import xyz.fycz.myreader.base.BasePresenter;
+import xyz.fycz.myreader.creator.DialogCreator;
+import xyz.fycz.myreader.util.ShareUtils;
+import xyz.fycz.myreader.util.SharedPreUtils;
+import xyz.fycz.myreader.util.TextHelper;
+
+/**
+ * @author fengyue
+ * @date 2020/7/31 11:39
+ */
+public class AboutPresent implements BasePresenter {
+
+ private AboutActivity mAboutActivity;
+
+ public AboutPresent(AboutActivity mAboutActivity) {
+ this.mAboutActivity = mAboutActivity;
+ }
+
+ @SuppressLint("SetTextI18n")
+ @Override
+ public void start() {
+ mAboutActivity.getLlTitleBack().setOnClickListener(v -> mAboutActivity.finish());
+ mAboutActivity.getTvTitleText().setText("关于");
+ mAboutActivity.getTvVersionName().setText("风月读书v" + MyApplication.getStrVersionName());
+ mAboutActivity.getVmAuthor().setOnClickListener(v -> {
+ ClipboardManager mClipboardManager = (ClipboardManager) mAboutActivity.getSystemService(Context.CLIPBOARD_SERVICE);
+ //数据
+ ClipData mClipData = ClipData.newPlainText("Label", "fy@fycz.xyz");
+ //把数据设置到剪切板上
+ assert mClipboardManager != null;
+ mClipboardManager.setPrimaryClip(mClipData);
+ TextHelper.showText("邮箱复制成功!");
+ });
+ mAboutActivity.getVmShare().setOnClickListener(v -> ShareUtils.share(mAboutActivity, mAboutActivity.getString(R.string.share_text) +
+ SharedPreUtils.getInstance().getString("downloadLink")));
+ mAboutActivity.getVmUpdate().setOnClickListener(v -> MyApplication.checkVersionByServer(mAboutActivity, true, null));
+ mAboutActivity.getVmUpdateLog().setOnClickListener(v -> DialogCreator.createAssetTipDialog(mAboutActivity, "更新日志", "updatelog.fy"));
+ mAboutActivity.getVmGit().setOnClickListener(v -> openIntent(Intent.ACTION_VIEW, mAboutActivity.getString(R.string.this_github_url)));
+ mAboutActivity.getVmDisclaimer().setOnClickListener(v -> DialogCreator.createAssetTipDialog(mAboutActivity, "免责声明", "disclaimer.fy"));
+ }
+
+ void openIntent(String intentName, String address) {
+ try {
+ Intent intent = new Intent(intentName);
+ intent.setData(Uri.parse(address));
+ mAboutActivity.startActivity(intent);
+ } catch (Exception e) {
+ TextHelper.showText(e.getLocalizedMessage());
+ }
+ }
+}
diff --git a/app/src/main/java/xyz/fycz/myreader/ui/bookinfo/BookInfoPresenter.java b/app/src/main/java/xyz/fycz/myreader/ui/bookinfo/BookInfoPresenter.java
index fc7921c..d788688 100644
--- a/app/src/main/java/xyz/fycz/myreader/ui/bookinfo/BookInfoPresenter.java
+++ b/app/src/main/java/xyz/fycz/myreader/ui/bookinfo/BookInfoPresenter.java
@@ -108,29 +108,7 @@ public class BookInfoPresenter implements BasePresenter {
createChangeSourceDia();
}
});
- mBookInfoActivity.getTvDisclaimer().setOnClickListener(v -> {
- BufferedReader br = null;
- try {
- br = new BufferedReader(new InputStreamReader(mBookInfoActivity.getAssets().open("disclaimer.fy")));
- StringBuilder disclaimer = new StringBuilder();
- String line = null;
- while ((line = br.readLine()) != null) {
- disclaimer.append(line);
- disclaimer.append("\r\n\n");
- }
- DialogCreator.createTipDialog(mBookInfoActivity, "免责声明", disclaimer.toString());
- } catch (IOException e) {
- e.printStackTrace();
- } finally {
- if (br != null) {
- try {
- br.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
- });
+ mBookInfoActivity.getTvDisclaimer().setOnClickListener(v -> DialogCreator.createAssetTipDialog(mBookInfoActivity, "免责声明", "disclaimer.fy"));
if (isBookCollected()) {
mBookInfoActivity.getBtnAddBookcase().setText("移除书籍");
mBookInfoActivity.getBtnReadBook().setText("继续阅读");
diff --git a/app/src/main/java/xyz/fycz/myreader/ui/home/bookcase/BookcaseDetailedAdapter.java b/app/src/main/java/xyz/fycz/myreader/ui/home/bookcase/BookcaseDetailedAdapter.java
index 0feb0d5..58191e3 100644
--- a/app/src/main/java/xyz/fycz/myreader/ui/home/bookcase/BookcaseDetailedAdapter.java
+++ b/app/src/main/java/xyz/fycz/myreader/ui/home/bookcase/BookcaseDetailedAdapter.java
@@ -124,80 +124,65 @@ public class BookcaseDetailedAdapter extends BookcaseAdapter {
viewHolder.tvNoReadNum.setVisibility(View.GONE);
}
}
- viewHolder.llBookRead.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- Intent intent = new Intent(mContext, ReadActivity.class);
- intent.putExtra(APPCONST.BOOK, book);
- book.setNoReadNum(0);
- mBookService.updateEntity(book);
- mContext.startActivity(intent);
- }
+ viewHolder.llBookRead.setOnClickListener(v -> {
+ Intent intent = new Intent(mContext, ReadActivity.class);
+ intent.putExtra(APPCONST.BOOK, book);
+ book.setNoReadNum(0);
+ mBookService.updateEntity(book);
+ mContext.startActivity(intent);
});
- viewHolder.ivBookImg.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- Intent intent = new Intent(mContext, BookInfoActivity.class);
- intent.putExtra(APPCONST.BOOK, book);
- mContext.startActivity(intent);
- }
+ viewHolder.ivBookImg.setOnClickListener(v -> {
+ Intent intent = new Intent(mContext, BookInfoActivity.class);
+ intent.putExtra(APPCONST.BOOK, book);
+ mContext.startActivity(intent);
});
- viewHolder.llBookRead.setOnLongClickListener(new View.OnLongClickListener() {
- @Override
- public boolean onLongClick(View v) {
- if (!ismEditState()) {
- AlertDialog bookDialog = new AlertDialog.Builder(mContext)
- .setTitle(book.getName())
- .setAdapter(new ArrayAdapter<>(mContext,
- android.R.layout.simple_list_item_1, menu),
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- switch (which) {
- case 0:
- book.setSortCode(0);
- mBookService.updateBook(book);
- mBookcasePresenter.init();
- TextHelper.showText("书籍《" + book.getName() + "》移至顶部成功!");
- break;
- case 1:
- downloadBook(book);
- break;
- case 2:
- MyApplication.getApplication().newThread(new Runnable() {
- @Override
- public void run() {
- try {
- if (unionChapterCathe(book)) {
- DialogCreator.createTipDialog(mContext,
- "缓存导出成功,导出目录:"
- + APPCONST.TXT_BOOK_DIR);
- } else {
- DialogCreator.createTipDialog(mContext,
- "章节目录为空或未找到缓存文件,缓存导出失败!");
- }
- } catch (IOException e) {
- e.printStackTrace();
- DialogCreator.createTipDialog(mContext,
- "章节目录为空或未找到缓存文件,缓存导出失败!");
- }
- }
- });
- break;
- case 3:
- showDeleteBookDialog(book);
- break;
- }
- }
- })
- .setNegativeButton(null, null)
- .setPositiveButton(null, null)
- .create();
- bookDialog.show();
- return true;
- }
- return false;
+ viewHolder.llBookRead.setOnLongClickListener(v -> {
+ if (!ismEditState()) {
+ AlertDialog bookDialog = new AlertDialog.Builder(mContext)
+ .setTitle(book.getName())
+ .setAdapter(new ArrayAdapter<>(mContext,
+ android.R.layout.simple_list_item_1, menu),
+ (dialog, which) -> {
+ switch (which) {
+ case 0:
+ book.setSortCode(0);
+ mBookService.updateBook(book);
+ mBookcasePresenter.init();
+ TextHelper.showText("书籍《" + book.getName() + "》移至顶部成功!");
+ break;
+ case 1:
+ downloadBook(book);
+ break;
+ case 2:
+ MyApplication.getApplication().newThread(() -> {
+ try {
+ if (unionChapterCathe(book)) {
+ DialogCreator.createTipDialog(mContext,
+ "缓存导出成功,导出目录:"
+ + APPCONST.TXT_BOOK_DIR);
+ } else {
+ DialogCreator.createTipDialog(mContext,
+ "章节目录为空或未找到缓存文件,缓存导出失败!");
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ DialogCreator.createTipDialog(mContext,
+ "章节目录为空或未找到缓存文件,缓存导出失败!");
+ }
+ });
+ break;
+ case 3:
+ showDeleteBookDialog(book);
+ break;
+ }
+ })
+ .setNegativeButton(null, null)
+ .setPositiveButton(null, null)
+ .create();
+ bookDialog.show();
+ return true;
}
+ return false;
});
}
}
diff --git a/app/src/main/java/xyz/fycz/myreader/ui/home/bookcase/BookcasePresenter.java b/app/src/main/java/xyz/fycz/myreader/ui/home/bookcase/BookcasePresenter.java
index e47e786..696470b 100644
--- a/app/src/main/java/xyz/fycz/myreader/ui/home/bookcase/BookcasePresenter.java
+++ b/app/src/main/java/xyz/fycz/myreader/ui/home/bookcase/BookcasePresenter.java
@@ -50,12 +50,11 @@ import xyz.fycz.myreader.greendao.entity.Book;
import xyz.fycz.myreader.greendao.entity.Chapter;
import xyz.fycz.myreader.greendao.service.BookService;
import xyz.fycz.myreader.greendao.service.ChapterService;
+import xyz.fycz.myreader.ui.about.AboutActivity;
import xyz.fycz.myreader.ui.home.MainActivity;
import xyz.fycz.myreader.ui.search.SearchBookActivity;
-import xyz.fycz.myreader.util.SharedPreUtils;
-import xyz.fycz.myreader.util.SharedPreferencesUtils;
-import xyz.fycz.myreader.util.StringHelper;
-import xyz.fycz.myreader.util.TextHelper;
+import xyz.fycz.myreader.ui.user.LoginActivity;
+import xyz.fycz.myreader.util.*;
import xyz.fycz.myreader.util.utils.NetworkUtils;
import xyz.fycz.myreader.webapi.CommonApi;
@@ -71,15 +70,17 @@ public class BookcasePresenter implements BasePresenter {
private final ChapterService mChapterService;
private final MainActivity mMainActivity;
private boolean isBookcaseStyleChange;
- private final Setting mSetting;
+ private Setting mSetting;
private final List errorLoadingBooks = new ArrayList<>();
private int finishLoadBookCount = 0;
private final BackupAndRestore mBackupAndRestore;
// private int notifyId = 11;
private ExecutorService es = Executors.newFixedThreadPool(1);//更新/下载线程池
+
public ExecutorService getEs() {
return es;
}
+
private String downloadingBook;
private String downloadingChapter;
private boolean isDownloadFinish;
@@ -90,11 +91,10 @@ public class BookcasePresenter implements BasePresenter {
MyApplication.getmContext().getResources().getString(R.string.menu_backup_backup),
MyApplication.getmContext().getResources().getString(R.string.menu_backup_restore),
};
- private final String[] webBackupMenu = {
- MyApplication.getmContext().getResources().getString(R.string.menu_backup_backup),
- MyApplication.getmContext().getResources().getString(R.string.menu_backup_restore),
- MyApplication.getmContext().getResources().getString(R.string.menu_backup_webRestore)
-
+ private final String[] webSynMenu = {
+ MyApplication.getmContext().getString(R.string.menu_backup_webBackup),
+ MyApplication.getmContext().getString(R.string.menu_backup_webRestore),
+ MyApplication.getmContext().getString(R.string.menu_backup_autoSyn)
};
// private ChapterService mChapterService;
@SuppressLint("HandlerLeak")
@@ -138,12 +138,7 @@ public class BookcasePresenter implements BasePresenter {
mBookcaseFragment.getRlDownloadTip().setVisibility(View.VISIBLE);
break;
case 11:
- MyApplication.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- createMenu();
- }
- });
+ MyApplication.runOnUiThread(() -> createMenu());
break;
case 12:
mBookcaseFragment.getTvStopDownload().setVisibility(View.GONE);
@@ -170,7 +165,9 @@ public class BookcasePresenter implements BasePresenter {
if (mSetting.getBookcaseStyle() == null) {
mSetting.setBookcaseStyle(BookcaseStyle.listMode);
}
- synBookcase();
+ if (mSetting.isAutoSyn() && UserService.isLogin()) {
+ synBookcaseToWeb(true);
+ }
getData();
//是否启用下拉刷新(默认启用)
if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
@@ -206,10 +203,10 @@ public class BookcasePresenter implements BasePresenter {
//停止按钮监听器
mBookcaseFragment.getTvStopDownload().setOnClickListener(v -> {
- if (downloadProcess == 99){
+ if (downloadProcess == 99) {
TextHelper.showText("开始缓存下一本书籍!");
isDownloadFinish = true;
- }else {
+ } else {
isStopDownload = true;
}
});
@@ -306,7 +303,7 @@ public class BookcasePresenter implements BasePresenter {
mHandler.sendMessage(mHandler.obtainMessage(3));
}
for (final Book book : mBooks) {
- if ("本地书籍".equals(book.getType())){
+ if ("本地书籍".equals(book.getType())) {
mBookcaseAdapter.getIsLoading().put(book.getId(), false);
mHandler.sendMessage(mHandler.obtainMessage(1));
continue;
@@ -419,7 +416,7 @@ public class BookcasePresenter implements BasePresenter {
pm.getMenuInflater().inflate(R.menu.menu_book, pm.getMenu());
setIconEnable(pm.getMenu(), true);
if (MyApplication.isApkInDebug(mMainActivity)) {
- pm.getMenu().getItem(4).setVisible(true);
+ pm.getMenu().getItem(5).setVisible(true);
}
pm.setOnMenuItemClickListener(item -> {
switch (item.getItemId()) {
@@ -441,31 +438,64 @@ public class BookcasePresenter implements BasePresenter {
return true;
case R.id.action_addLocalBook:
TextHelper.showText("请选择一个txt格式的书籍文件");
- Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
- intent.setType("text/plain");
- intent.addCategory(Intent.CATEGORY_OPENABLE);
- mMainActivity.startActivityForResult(intent, APPCONST.SELECT_FILE_CODE);
+ Intent addIntent = new Intent(Intent.ACTION_GET_CONTENT);
+ addIntent.setType("text/plain");
+ addIntent.addCategory(Intent.CATEGORY_OPENABLE);
+ mMainActivity.startActivityForResult(addIntent, APPCONST.SELECT_FILE_CODE);
+ break;
+ case R.id.action_syn:
+ if (!UserService.isLogin()){
+ TextHelper.showText("请先登录!");
+ Intent intent = new Intent(mMainActivity, LoginActivity.class);
+ mMainActivity.startActivity(intent);
+ return true;
+ }
+ if (mSetting.isAutoSyn()) {
+ webSynMenu[2] = MyApplication.getmContext().getString(R.string.menu_backup_autoSyn) + "已开启";
+ } else {
+ webSynMenu[2] = MyApplication.getmContext().getString(R.string.menu_backup_autoSyn) + "已关闭";
+ }
+ new AlertDialog.Builder(mMainActivity)
+ .setTitle(mMainActivity.getString(R.string.menu_bookcase_syn))
+ .setAdapter(new ArrayAdapter<>(mMainActivity,
+ android.R.layout.simple_list_item_1, webSynMenu),
+ (dialog, which) -> {
+ switch (which) {
+ case 0:
+ synBookcaseToWeb(false);
+ break;
+ case 1:
+ webRestore();
+ break;
+ case 2:
+ String tip = "";
+ if (mSetting.isAutoSyn()) {
+ mSetting.setAutoSyn(false);
+ tip = "每日自动同步已关闭!";
+ } else {
+ mSetting.setAutoSyn(true);
+ tip = "每日自动同步已开启!";
+ }
+ SysManager.saveSetting(mSetting);
+ TextHelper.showText(tip);
+ break;
+ }
+ })
+ .setNegativeButton(null, null)
+ .setPositiveButton(null, null)
+ .show();
break;
case R.id.action_download_all:
DialogCreator.createCommonDialog(mMainActivity, "一键缓存(实验)",
mMainActivity.getString(R.string.all_cathe_tip), true,
(dialog, which) -> downloadAll(), null);
- return true;
- case R.id.action_update:
- checkVersionByServer(mMainActivity, true, mBookcaseFragment);
return true;
case R.id.action_backup:
- final String[] menu;
- if (UserService.isLogin()) {
- menu = webBackupMenu;
- } else {
- menu = backupMenu;
- }
AlertDialog bookDialog = new AlertDialog.Builder(mMainActivity)
.setTitle(mMainActivity.getResources().getString(R.string.menu_bookcase_backup))
.setAdapter(new ArrayAdapter<>(mMainActivity,
- android.R.layout.simple_list_item_1, menu),
+ android.R.layout.simple_list_item_1, backupMenu),
(dialog, which) -> {
switch (which) {
case 0:
@@ -474,9 +504,6 @@ public class BookcasePresenter implements BasePresenter {
case 1:
mHandler.sendMessage(mHandler.obtainMessage(6));
break;
- case 2:
- webRestore();
- break;
}
})
.setNegativeButton(null, null)
@@ -484,28 +511,9 @@ public class BookcasePresenter implements BasePresenter {
.create();
bookDialog.show();
return true;
- case R.id.action_disclaimer:
- BufferedReader br = null;
- try {
- br = new BufferedReader(new InputStreamReader(mMainActivity.getAssets().open("disclaimer.fy")));
- StringBuilder disclaimer = new StringBuilder();
- String line = null;
- while ((line = br.readLine()) != null) {
- disclaimer.append(line);
- disclaimer.append("\r\n\n");
- }
- DialogCreator.createTipDialog(mMainActivity, "免责声明", disclaimer.toString());
- } catch (IOException e) {
- e.printStackTrace();
- } finally {
- if (br != null) {
- try {
- br.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
+ case R.id.action_about:
+ Intent aboutIntent = new Intent(mMainActivity, AboutActivity.class);
+ mMainActivity.startActivity(aboutIntent);
return true;
}
return false;
@@ -538,20 +546,10 @@ public class BookcasePresenter implements BasePresenter {
DialogCreator.createCommonDialog(mMainActivity, "确认备份吗?", "新备份会替换原有备份!", true,
(dialogInterface, i) -> {
dialogInterface.dismiss();
- if (UserService.isLogin()) {
- MyApplication.getApplication().newThread(() -> {
- if (mBackupAndRestore.backup("localBackup") & UserService.webBackup()) {
- DialogCreator.createTipDialog(mMainActivity, "备份(本地和网络)成功,本地备份文件路径:" + APPCONST.BACKUP_FILE_DIR);
- } else {
- DialogCreator.createTipDialog(mMainActivity, "未登录或未给予储存权限,备份失败!");
- }
- });
+ if (mBackupAndRestore.backup("localBackup")) {
+ DialogCreator.createTipDialog(mMainActivity, "备份成功,备份文件路径:" + APPCONST.BACKUP_FILE_DIR);
} else {
- if (mBackupAndRestore.backup("localBackup")) {
- DialogCreator.createTipDialog(mMainActivity, "备份成功,备份文件路径:" + APPCONST.BACKUP_FILE_DIR);
- } else {
- DialogCreator.createTipDialog(mMainActivity, "未给予储存权限,备份失败!");
- }
+ DialogCreator.createTipDialog(mMainActivity, "未给予储存权限,备份失败!");
}
}, (dialogInterface, i) -> dialogInterface.dismiss());
}
@@ -567,6 +565,7 @@ public class BookcasePresenter implements BasePresenter {
mHandler.sendMessage(mHandler.obtainMessage(7));
// DialogCreator.createTipDialog(mMainActivity,
// "恢复成功!\n注意:本功能属于实验功能,书架恢复后,书籍初次加载时可能加载失败,返回重新加载即可!");
+ mSetting = SysManager.getSetting();
TextHelper.showText("书架恢复成功!");
} else {
DialogCreator.createTipDialog(mMainActivity, "未找到备份文件或未给予储存权限,恢复失败!");
@@ -579,7 +578,11 @@ public class BookcasePresenter implements BasePresenter {
* 恢复
*/
private void webRestore() {
- DialogCreator.createCommonDialog(mMainActivity, "确认恢复吗?", "恢复书架会覆盖原有书架!", true,
+ if (!NetworkUtils.isNetWorkAvailable()){
+ TextHelper.showText("无网络连接!");
+ return;
+ }
+ DialogCreator.createCommonDialog(mMainActivity, "确认同步吗?", "将书架从网络同步至本地会覆盖原有书架!", true,
(dialogInterface, i) -> {
dialogInterface.dismiss();
MyApplication.getApplication().newThread(() -> {
@@ -587,9 +590,10 @@ public class BookcasePresenter implements BasePresenter {
mHandler.sendMessage(mHandler.obtainMessage(7));
// DialogCreator.createTipDialog(mMainActivity,
// "恢复成功!\n注意:本功能属于实验功能,书架恢复后,书籍初次加载时可能加载失败,返回重新加载即可!");、
- TextHelper.showText("书架恢复成功!");
+ mSetting = SysManager.getSetting();
+ TextHelper.showText("成功将书架从网络同步至本地!");
} else {
- DialogCreator.createTipDialog(mMainActivity, "未找到备份文件,恢复失败!");
+ DialogCreator.createTipDialog(mMainActivity, "未找到同步文件,同步失败!");
}
});
}, (dialogInterface, i) -> dialogInterface.dismiss());
@@ -609,7 +613,7 @@ public class BookcasePresenter implements BasePresenter {
MyApplication.getApplication().newThread(() -> {
downloadFor:
for (final Book book : mBooks) {
- if (BookSource.pinshu.toString().equals(book.getSource()) || "本地书籍".equals(book.getType())){
+ if (BookSource.pinshu.toString().equals(book.getSource()) || "本地书籍".equals(book.getType())) {
continue;
}
isDownloadFinish = false;
@@ -637,17 +641,18 @@ public class BookcasePresenter implements BasePresenter {
/**
* 添加下载
+ *
* @param book
* @param mChapters
* @param begin
* @param end
*/
public void addDownload(final Book book, final ArrayList mChapters, int begin, int end) {
- if ("本地书籍".equals(book.getType())){
+ if ("本地书籍".equals(book.getType())) {
TextHelper.showText("《" + book.getName() + "》是本地书籍,不能缓存");
return;
}
- if (mChapters.size() == 0){
+ if (mChapters.size() == 0) {
TextHelper.showText("《" + book.getName() + "》章节目录为空,缓存失败,请刷新后重试");
return;
}
@@ -669,13 +674,13 @@ public class BookcasePresenter implements BasePresenter {
downloadingChapter = chapter.getTitle();
downloadProcess = curCacheChapterNum[0] * 100 / needCacheChapterNum;
mChapterService.saveOrUpdateChapter(chapter, (String) o);
- // isDownloadFinish[0] = true;
+ // isDownloadFinish[0] = true;
mHandler.sendMessage(mHandler.obtainMessage(8));
}
@Override
public void onError(Exception e) {
- // isDownloadFinish[0] = true;
+ // isDownloadFinish[0] = true;
curCacheChapterNum[0]++;
downloadProcess = curCacheChapterNum[0] * 100 / needCacheChapterNum;
mHandler.sendMessage(mHandler.obtainMessage(8));
@@ -732,11 +737,12 @@ public class BookcasePresenter implements BasePresenter {
/**
* 添加本地书籍
+ *
* @param path
*/
public void addLocalBook(String path) {
File file = new File(path);
- if (!file.exists()){
+ if (!file.exists()) {
return;
}
Book book = new Book();
@@ -751,7 +757,7 @@ public class BookcasePresenter implements BasePresenter {
//判断书籍是否已经添加
Book existsBook = mBookService.findBookByAuthorAndName(book.getName(), book.getAuthor());
- if (book.equals(existsBook)){
+ if (book.equals(existsBook)) {
TextHelper.showText("该书籍已存在,请勿重复添加!");
return;
}
@@ -763,36 +769,48 @@ public class BookcasePresenter implements BasePresenter {
/**
* 同步书架
*/
- private void synBookcase(){
- if (UserService.isLogin()){
- Date nowTime = new Date();
- SimpleDateFormat sdf = new SimpleDateFormat("yy-MM-dd");
- String nowTimeStr = sdf.format(nowTime);
- SharedPreUtils spb = SharedPreUtils.getInstance();
- String synTime = spb.getString("synTime");
- if (!nowTimeStr.equals(synTime)) {
- MyApplication.getApplication().newThread(() -> {
- if (UserService.webBackup()){
- spb.putString("synTime", nowTimeStr);
- }
- });
+ private void synBookcaseToWeb(boolean isAutoSyn) {
+ if (!NetworkUtils.isNetWorkAvailable()){
+ if (!isAutoSyn) {
+ TextHelper.showText("无网络连接!");
}
+ return;
+ }
+ Date nowTime = new Date();
+ SimpleDateFormat sdf = new SimpleDateFormat("yy-MM-dd");
+ String nowTimeStr = sdf.format(nowTime);
+ SharedPreUtils spb = SharedPreUtils.getInstance();
+ String synTime = spb.getString("synTime");
+ if (!nowTimeStr.equals(synTime) || !isAutoSyn) {
+ MyApplication.getApplication().newThread(() -> {
+ if (UserService.webBackup()) {
+ spb.putString("synTime", nowTimeStr);
+ if (!isAutoSyn) {
+ DialogCreator.createTipDialog(mMainActivity, "成功将书架同步至网络!");
+ }
+ } else {
+ if (!isAutoSyn) {
+ DialogCreator.createTipDialog(mMainActivity, "同步失败,请重试!");
+ }
+ }
+ });
}
}
- /*****************************************用于返回按钮判断*************************************/
+ /*****************************************用于返回按钮判断*************************************/
/**
* 判断是否处于编辑状态
+ *
* @return
*/
- public boolean ismEditState(){
+ public boolean ismEditState() {
return mBookcaseAdapter.ismEditState();
}
/**
* 取消编辑状态
*/
- public void cancelEdit(){
+ public void cancelEdit() {
editBookcase(false);
}
/*class NotificationService extends Service{
diff --git a/app/src/main/java/xyz/fycz/myreader/ui/search/SearchBookPrensenter.java b/app/src/main/java/xyz/fycz/myreader/ui/search/SearchBookPrensenter.java
index 4cb84ba..89c01c7 100644
--- a/app/src/main/java/xyz/fycz/myreader/ui/search/SearchBookPrensenter.java
+++ b/app/src/main/java/xyz/fycz/myreader/ui/search/SearchBookPrensenter.java
@@ -117,12 +117,7 @@ public class SearchBookPrensenter implements BasePresenter {
//换一批点击事件
mSearchBookActivity.getRenewByText().setOnClickListener(new RenewSuggestionBook());
//返回
- mSearchBookActivity.getLlTitleBack().setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- mSearchBookActivity.finish();
- }
- });
+ mSearchBookActivity.getLlTitleBack().setOnClickListener(view -> mSearchBookActivity.finish());
//搜索框改变事件
mSearchBookActivity.getEtSearchKey().addTextChangedListener(new TextWatcher() {
diff --git a/app/src/main/java/xyz/fycz/myreader/ui/user/LoginPresenter.java b/app/src/main/java/xyz/fycz/myreader/ui/user/LoginPresenter.java
index 6435f4e..946e210 100644
--- a/app/src/main/java/xyz/fycz/myreader/ui/user/LoginPresenter.java
+++ b/app/src/main/java/xyz/fycz/myreader/ui/user/LoginPresenter.java
@@ -53,12 +53,7 @@ public class LoginPresenter implements BasePresenter {
public void start() {
mHandler.sendMessage(mHandler.obtainMessage(2));
mLoginActivity.getTvTitleText().setText("登录");
- mLoginActivity.getLlTitleBack().setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- mLoginActivity.finish();
- }
- });
+ mLoginActivity.getLlTitleBack().setOnClickListener(v -> mLoginActivity.finish());
String username = UserService.readUsername();
mLoginActivity.getUser().setText(username);
mLoginActivity.getUser().requestFocus(username.length());
diff --git a/app/src/main/java/xyz/fycz/myreader/util/ShareUtils.java b/app/src/main/java/xyz/fycz/myreader/util/ShareUtils.java
new file mode 100644
index 0000000..aea07de
--- /dev/null
+++ b/app/src/main/java/xyz/fycz/myreader/util/ShareUtils.java
@@ -0,0 +1,24 @@
+package xyz.fycz.myreader.util;
+
+import android.content.Context;
+import android.content.Intent;
+import xyz.fycz.myreader.R;
+
+/**
+ * Created by Zhouas666 on 2019-04-12
+ * Github: https://github.com/zas023
+ */
+public class ShareUtils {
+ public static void share(Context context, int stringRes) {
+ share(context, context.getString(stringRes));
+ }
+
+ public static void share(Context context, String extraText) {
+ Intent intent = new Intent(Intent.ACTION_SEND);
+ intent.setType("text/plain");
+ intent.putExtra(Intent.EXTRA_SUBJECT, context.getString(R.string.share));
+ intent.putExtra(Intent.EXTRA_TEXT, extraText);
+ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ context.startActivity(Intent.createChooser(intent, context.getString(R.string.share)));
+ }
+}
diff --git a/app/src/main/res/drawable/ic_about.xml b/app/src/main/res/drawable/ic_about.xml
new file mode 100644
index 0000000..3f2b198
--- /dev/null
+++ b/app/src/main/res/drawable/ic_about.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/ic_launch.xml b/app/src/main/res/drawable/ic_launch.xml
new file mode 100644
index 0000000..6b423cd
--- /dev/null
+++ b/app/src/main/res/drawable/ic_launch.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/ic_list.xml b/app/src/main/res/drawable/ic_list.xml
new file mode 100644
index 0000000..4a1b0d5
--- /dev/null
+++ b/app/src/main/res/drawable/ic_list.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/ic_online_syn.xml b/app/src/main/res/drawable/ic_online_syn.xml
new file mode 100644
index 0000000..8a3cc9b
--- /dev/null
+++ b/app/src/main/res/drawable/ic_online_syn.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/ic_share.xml b/app/src/main/res/drawable/ic_share.xml
new file mode 100644
index 0000000..0022d3b
--- /dev/null
+++ b/app/src/main/res/drawable/ic_share.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_about.xml b/app/src/main/res/layout/activity_about.xml
new file mode 100644
index 0000000..698b317
--- /dev/null
+++ b/app/src/main/res/layout/activity_about.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/layout_about_content.xml b/app/src/main/res/layout/layout_about_content.xml
new file mode 100644
index 0000000..4adba40
--- /dev/null
+++ b/app/src/main/res/layout/layout_about_content.xml
@@ -0,0 +1,283 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/menu/menu_book.xml b/app/src/main/res/menu/menu_book.xml
index af00c67..4dcefb4 100644
--- a/app/src/main/res/menu/menu_book.xml
+++ b/app/src/main/res/menu/menu_book.xml
@@ -22,6 +22,12 @@
android:icon="@drawable/ic_backup"
android:title="@string/menu_bookcase_backup"
app:showAsAction="never"/>
+
+