From c5759ba251bfd24ce872b77d540d871916e8865b Mon Sep 17 00:00:00 2001
From: fengyuecanzhu <1021300691@qq.com>
Date: Thu, 24 Mar 2022 11:41:52 +0800
Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=BB=A3=E7=90=86=E8=AE=BE?=
=?UTF-8?q?=E7=BD=AE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.idea/assetWizardSettings.xml | 32 ---
.idea/dictionaries/fengyue.xml | 3 -
.idea/inspectionProfiles/Project_Default.xml | 36 ----
.idea/jarRepositories.xml | 10 +-
.idea/misc.xml | 83 +------
.../greendao/entity/rule/BookSource.java | 24 ++-
.../xyz/fycz/myreader/model/storage/Backup.kt | 8 +
.../fycz/myreader/model/storage/Restore.kt | 9 +
.../fycz/myreader/model/third3/BaseSource.kt | 2 +
.../model/third3/analyzeRule/AnalyzeUrl.kt | 10 +-
.../myreader/model/third3/http/HttpHelper.kt | 23 +-
.../myreader/ui/activity/AboutActivity.java | 2 +-
.../ui/activity/MoreSettingActivity.java | 170 +++++++--------
.../ui/adapter/BookcaseDetailedAdapter.java | 4 +-
.../ui/fragment/FindBook2Fragment.java | 13 +-
.../myreader/ui/fragment/ProxyFragment.kt | 189 ++++++++++++++++
.../fycz/myreader/util/utils/OkHttpUtils.java | 6 +-
.../xyz/fycz/myreader/webapi/LanZouApi.kt | 4 +-
.../main/res/layout/activity_more_setting.xml | 34 ++-
.../res/layout/fragment_proxy_setting.xml | 203 ++++++++++++++++++
app/src/main/res/values/strings.xml | 10 +
gradle.properties | 7 +-
22 files changed, 609 insertions(+), 273 deletions(-)
delete mode 100644 .idea/assetWizardSettings.xml
delete mode 100644 .idea/dictionaries/fengyue.xml
delete mode 100644 .idea/inspectionProfiles/Project_Default.xml
create mode 100644 app/src/main/java/xyz/fycz/myreader/ui/fragment/ProxyFragment.kt
create mode 100644 app/src/main/res/layout/fragment_proxy_setting.xml
diff --git a/.idea/assetWizardSettings.xml b/.idea/assetWizardSettings.xml
deleted file mode 100644
index 17390f7..0000000
--- a/.idea/assetWizardSettings.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/dictionaries/fengyue.xml b/.idea/dictionaries/fengyue.xml
deleted file mode 100644
index 58d8886..0000000
--- a/.idea/dictionaries/fengyue.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-
-
-
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
deleted file mode 100644
index 6560a98..0000000
--- a/.idea/inspectionProfiles/Project_Default.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
index ffbbbfb..ab56054 100644
--- a/.idea/jarRepositories.xml
+++ b/.idea/jarRepositories.xml
@@ -11,6 +11,11 @@
+
+
+
+
+
@@ -26,10 +31,5 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index e81aa36..c4c37ea 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -3,88 +3,13 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
-
-
-
diff --git a/app/src/main/java/xyz/fycz/myreader/greendao/entity/rule/BookSource.java b/app/src/main/java/xyz/fycz/myreader/greendao/entity/rule/BookSource.java
index d878691..2c1c453 100644
--- a/app/src/main/java/xyz/fycz/myreader/greendao/entity/rule/BookSource.java
+++ b/app/src/main/java/xyz/fycz/myreader/greendao/entity/rule/BookSource.java
@@ -57,6 +57,8 @@ public class BookSource extends BaseSource implements Parcelable, Cloneable {
private int weight;
private boolean enable;
+ private boolean noProxy;//不使用代理
+
@Transient
private transient ArrayList groupList;
@@ -76,12 +78,12 @@ public class BookSource extends BaseSource implements Parcelable, Cloneable {
@Convert(converter = FindRuleConvert.class, columnType = String.class)
private FindRule findRule;
- @Generated(hash = 798251066)
+ @Generated(hash = 945434046)
public BookSource(String sourceUrl, String sourceEName, String sourceName, String sourceGroup,
- String sourceCharset, String sourceType, String sourceHeaders, String loginUrl,
- String loginCheckJs, String sourceComment, String concurrentRate, Long lastUpdateTime,
- int orderNum, int weight, boolean enable, SearchRule searchRule, InfoRule infoRule,
- TocRule tocRule, ContentRule contentRule, FindRule findRule) {
+ String sourceCharset, String sourceType, String sourceHeaders, String loginUrl, String loginCheckJs,
+ String sourceComment, String concurrentRate, Long lastUpdateTime, int orderNum, int weight,
+ boolean enable, boolean noProxy, SearchRule searchRule, InfoRule infoRule, TocRule tocRule,
+ ContentRule contentRule, FindRule findRule) {
this.sourceUrl = sourceUrl;
this.sourceEName = sourceEName;
this.sourceName = sourceName;
@@ -97,6 +99,7 @@ public class BookSource extends BaseSource implements Parcelable, Cloneable {
this.orderNum = orderNum;
this.weight = weight;
this.enable = enable;
+ this.noProxy = noProxy;
this.searchRule = searchRule;
this.infoRule = infoRule;
this.tocRule = tocRule;
@@ -129,6 +132,7 @@ public class BookSource extends BaseSource implements Parcelable, Cloneable {
orderNum = in.readInt();
weight = in.readInt();
enable = in.readByte() != 0;
+ noProxy = in.readByte() != 0;
searchRule = in.readParcelable(SearchRule.class.getClassLoader());
infoRule = in.readParcelable(InfoRule.class.getClassLoader());
tocRule = in.readParcelable(TocRule.class.getClassLoader());
@@ -158,6 +162,7 @@ public class BookSource extends BaseSource implements Parcelable, Cloneable {
dest.writeInt(orderNum);
dest.writeInt(weight);
dest.writeByte((byte) (enable ? 1 : 0));
+ dest.writeByte((byte) (noProxy ? 1 : 0));
dest.writeParcelable(searchRule, flags);
dest.writeParcelable(infoRule, flags);
dest.writeParcelable(tocRule, flags);
@@ -188,6 +193,7 @@ public class BookSource extends BaseSource implements Parcelable, Cloneable {
if (o == null || getClass() != o.getClass()) return false;
BookSource source = (BookSource) o;
return enable == source.enable &&
+ noProxy == source.noProxy &&
stringEquals(sourceUrl, source.sourceUrl) &&
stringEquals(sourceEName, source.sourceEName) &&
stringEquals(sourceName, source.sourceName) &&
@@ -458,4 +464,12 @@ public class BookSource extends BaseSource implements Parcelable, Cloneable {
public BookSource getSource() {
return this;
}
+
+ public boolean getNoProxy() {
+ return this.noProxy;
+ }
+
+ public void setNoProxy(boolean noProxy) {
+ this.noProxy = noProxy;
+ }
}
diff --git a/app/src/main/java/xyz/fycz/myreader/model/storage/Backup.kt b/app/src/main/java/xyz/fycz/myreader/model/storage/Backup.kt
index 6a6865f..194dc40 100644
--- a/app/src/main/java/xyz/fycz/myreader/model/storage/Backup.kt
+++ b/app/src/main/java/xyz/fycz/myreader/model/storage/Backup.kt
@@ -43,6 +43,7 @@ object Backup {
"bookSource.json",
"readRecord.json",
"searchWord.json",
+ "subscribe.json",
"config.xml"
)
}
@@ -137,6 +138,13 @@ object Backup {
.writeText(json)
}
}
+ DbManager.getDaoSession().subscribeFileDao.queryBuilder().list().let {
+ if (it.isNotEmpty()) {
+ val json = GSON.toJson(it)
+ FileUtils.getFile(backupPath + File.separator + "subscribe.json")
+ .writeText(json)
+ }
+ }
try {
val setting = SysManager.getNewSetting()
val readStyles = setting.readStyles
diff --git a/app/src/main/java/xyz/fycz/myreader/model/storage/Restore.kt b/app/src/main/java/xyz/fycz/myreader/model/storage/Restore.kt
index e018276..c74a6da 100644
--- a/app/src/main/java/xyz/fycz/myreader/model/storage/Restore.kt
+++ b/app/src/main/java/xyz/fycz/myreader/model/storage/Restore.kt
@@ -139,6 +139,15 @@ object Restore {
} catch (e: Exception) {
e.printStackTrace()
}
+ try {
+ val file = FileUtils.getFile(path + File.separator + "subscribe.json")
+ val json = file.readText()
+ GSON.fromJsonArray(json)?.let {
+ DbManager.getInstance().session.subscribeFileDao.insertOrReplaceInTx(it)
+ }
+ } catch (e: Exception) {
+ e.printStackTrace()
+ }
try {
val settingFile = FileUtils.getFile(path + File.separator + "setting.json")
val settingJson = settingFile.readText()
diff --git a/app/src/main/java/xyz/fycz/myreader/model/third3/BaseSource.kt b/app/src/main/java/xyz/fycz/myreader/model/third3/BaseSource.kt
index f4f3027..b15da43 100644
--- a/app/src/main/java/xyz/fycz/myreader/model/third3/BaseSource.kt
+++ b/app/src/main/java/xyz/fycz/myreader/model/third3/BaseSource.kt
@@ -32,6 +32,8 @@ abstract class BaseSource : JsExtensions {
open fun getKey(): String = ""
+ open fun getNoProxy(): Boolean = false
+
/*fun loginUi(): List? {
return GSON.fromJsonArray(loginUi)
}*/
diff --git a/app/src/main/java/xyz/fycz/myreader/model/third3/analyzeRule/AnalyzeUrl.kt b/app/src/main/java/xyz/fycz/myreader/model/third3/analyzeRule/AnalyzeUrl.kt
index daec372..4bfdfe1 100644
--- a/app/src/main/java/xyz/fycz/myreader/model/third3/analyzeRule/AnalyzeUrl.kt
+++ b/app/src/main/java/xyz/fycz/myreader/model/third3/analyzeRule/AnalyzeUrl.kt
@@ -357,7 +357,7 @@ class AnalyzeUrl(
if (this.useWebView && useWebView) {
strResponse = when (method) {
RequestMethod.POST -> {
- val body = getProxyClient(proxy).newCallStrResponse(retry) {
+ val body = getProxyClient(proxy, source?.getNoProxy() == true).newCallStrResponse(retry) {
addHeaders(headerMap)
url(urlNoQuery)
if (fieldMap.isNotEmpty() || body.isNullOrBlank()) {
@@ -384,7 +384,7 @@ class AnalyzeUrl(
).getStrResponse()
}
} else {
- strResponse = getProxyClient(proxy).newCallStrResponse(retry) {
+ strResponse = getProxyClient(proxy, source?.getNoProxy() == true).newCallStrResponse(retry) {
addHeaders(headerMap)
when (method) {
RequestMethod.POST -> {
@@ -421,7 +421,7 @@ class AnalyzeUrl(
val concurrentRecord = fetchStart()
setCookie(source?.getKey())
@Suppress("BlockingMethodInNonBlockingContext")
- val response = getProxyClient(proxy).newCallResponse(retry) {
+ val response = getProxyClient(proxy, source?.getNoProxy() == true).newCallResponse(retry) {
addHeaders(headerMap)
when (method) {
RequestMethod.POST -> {
@@ -452,7 +452,7 @@ class AnalyzeUrl(
val concurrentRecord = fetchStart()
setCookie(source?.getKey())
@Suppress("BlockingMethodInNonBlockingContext")
- val byteArray = getProxyClient(proxy).newCallResponseBody(retry) {
+ val byteArray = getProxyClient(proxy, source?.getNoProxy() == true).newCallResponseBody(retry) {
addHeaders(headerMap)
when (method) {
RequestMethod.POST -> {
@@ -480,7 +480,7 @@ class AnalyzeUrl(
* 上传文件
*/
suspend fun upload(fileName: String, file: Any, contentType: String): StrResponse {
- return getProxyClient(proxy).newCallStrResponse(retry) {
+ return getProxyClient(proxy, source?.getNoProxy() == true).newCallStrResponse(retry) {
url(urlNoQuery)
val bodyMap = GSON.fromJsonObject>(body)!!
bodyMap.forEach { entry ->
diff --git a/app/src/main/java/xyz/fycz/myreader/model/third3/http/HttpHelper.kt b/app/src/main/java/xyz/fycz/myreader/model/third3/http/HttpHelper.kt
index d967887..50d7704 100644
--- a/app/src/main/java/xyz/fycz/myreader/model/third3/http/HttpHelper.kt
+++ b/app/src/main/java/xyz/fycz/myreader/model/third3/http/HttpHelper.kt
@@ -4,6 +4,7 @@ import okhttp3.ConnectionSpec
import okhttp3.Credentials
import okhttp3.Interceptor
import okhttp3.OkHttpClient
+import xyz.fycz.myreader.util.SharedPreUtils
import java.net.InetSocketAddress
import java.net.Proxy
import java.util.concurrent.ConcurrentHashMap
@@ -24,7 +25,7 @@ val okHttpClient: OkHttpClient by lazy {
.connectTimeout(15, TimeUnit.SECONDS)
.writeTimeout(15, TimeUnit.SECONDS)
.readTimeout(15, TimeUnit.SECONDS)
- .callTimeout(60,TimeUnit.SECONDS)
+ .callTimeout(60, TimeUnit.SECONDS)
.sslSocketFactory(SSLHelper.unsafeSSLSocketFactory, SSLHelper.unsafeTrustManager)
.retryOnConnectionFailure(true)
.hostnameVerifier(SSLHelper.unsafeHostnameVerifier)
@@ -46,17 +47,31 @@ val okHttpClient: OkHttpClient by lazy {
builder.build()
}
+val globalProxy by lazy {
+ val spu = SharedPreUtils.getInstance()
+ val type = if (spu.getInt("proxyType") == 0) {
+ "http"
+ } else {
+ "socks5"
+ }
+ val host = spu.getString("proxyHost")
+ val port = spu.getString("proxyPort")
+ val username = spu.getString("proxyUsername")
+ val password = spu.getString("proxyPassword")
+ "$type://$host:$port@$username@$password"
+}
+
/**
* 缓存代理okHttp
*/
-fun getProxyClient(proxy: String? = null): OkHttpClient {
- if (proxy.isNullOrBlank()) {
+fun getProxyClient(proxy: String? = globalProxy, noProxy: Boolean = false): OkHttpClient {
+ if (proxy.isNullOrBlank() || noProxy) {
return okHttpClient
}
proxyClientCache[proxy]?.let {
return it
}
- val r = Regex("(http|socks4|socks5)://(.*):(\\d{2,5})(@.*@.*)?")
+ val r = Regex("(http|socks4|socks5)://(.+):(\\d{2,5})(@.*@.*)?")
val ms = r.findAll(proxy)
val group = ms.first()
var username = "" //代理服务器验证用户名
diff --git a/app/src/main/java/xyz/fycz/myreader/ui/activity/AboutActivity.java b/app/src/main/java/xyz/fycz/myreader/ui/activity/AboutActivity.java
index 7021226..a784763 100644
--- a/app/src/main/java/xyz/fycz/myreader/ui/activity/AboutActivity.java
+++ b/app/src/main/java/xyz/fycz/myreader/ui/activity/AboutActivity.java
@@ -116,7 +116,7 @@ public class AboutActivity extends BaseActivity {
String[] str = new String[1];
MyAlertDialog.createInputDia(this, getString(R.string.lan_zou_parse),
"格式:链接+逗号+密码(没有密码就不用填)", "", true,
- 100, text -> str[0] = text, (dialog, which) -> {
+ 500, text -> str[0] = text, (dialog, which) -> {
LanZouApi.INSTANCE.getFileUrl(str[0])
.compose(RxUtils::toSimpleSingle)
.subscribe(new MyObserver() {
diff --git a/app/src/main/java/xyz/fycz/myreader/ui/activity/MoreSettingActivity.java b/app/src/main/java/xyz/fycz/myreader/ui/activity/MoreSettingActivity.java
index 9e205f9..9a62c9c 100644
--- a/app/src/main/java/xyz/fycz/myreader/ui/activity/MoreSettingActivity.java
+++ b/app/src/main/java/xyz/fycz/myreader/ui/activity/MoreSettingActivity.java
@@ -50,6 +50,7 @@ import xyz.fycz.myreader.ui.dialog.LoadingDialog;
import xyz.fycz.myreader.ui.dialog.MultiChoiceDialog;
import xyz.fycz.myreader.ui.dialog.MyAlertDialog;
import xyz.fycz.myreader.ui.fragment.PrivateBooksFragment;
+import xyz.fycz.myreader.ui.fragment.ProxyFragment;
import xyz.fycz.myreader.ui.fragment.WebDavFragment;
import xyz.fycz.myreader.util.SharedPreUtils;
import xyz.fycz.myreader.util.ToastUtils;
@@ -91,11 +92,10 @@ public class MoreSettingActivity extends BaseActivity {
+ binding.svContent.setVisibility(View.GONE);
+ FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
+ if (mProxyFragment == null) {
+ mProxyFragment = new ProxyFragment();
+ ft.add(R.id.ll_content, mProxyFragment);
+ } else {
+ ft.show(mProxyFragment);
+ }
+ ft.commit();
+ curFragment = mProxyFragment;
+ setUpToolbar();
+ });
+
binding.llWebdav.setOnClickListener(v -> {
binding.svContent.setVisibility(View.GONE);
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
@@ -386,48 +403,40 @@ public class MoreSettingActivity extends BaseActivity {
- App.runOnUiThread(() -> {
- if (mCloseRefreshDia != null) {
- mCloseRefreshDia.show();
- return;
- }
-
- initmBooks();
-
- if (mBooks.size() == 0) {
- ToastUtils.showWarring("当前书架没有支持禁用更新的书籍!");
- return;
- }
-
- boolean[] isCloseRefresh = new boolean[booksCount];
- int crBookCount = 0;
-
- for (int i = 0; i < booksCount; i++) {
- Book book = mBooks.get(i);
- isCloseRefresh[i] = book.getIsCloseUpdate();
- if (isCloseRefresh[i]) {
- crBookCount++;
- }
+ if (mCloseRefreshDia != null) {
+ mCloseRefreshDia.show();
+ return;
+ }
+ initmBooks();
+ if (mBooks.size() == 0) {
+ ToastUtils.showWarring("当前书架没有支持禁用更新的书籍!");
+ return;
+ }
+ boolean[] isCloseRefresh = new boolean[booksCount];
+ int crBookCount = 0;
+ for (int i = 0; i < booksCount; i++) {
+ Book book = mBooks.get(i);
+ isCloseRefresh[i] = book.getIsCloseUpdate();
+ if (isCloseRefresh[i]) {
+ crBookCount++;
}
+ }
+ mCloseRefreshDia = new MultiChoiceDialog().create(this, "禁用更新的书籍",
+ mBooksName, isCloseRefresh, crBookCount, (dialog, which) -> {
+ BookService.getInstance().updateBooks(mBooks);
+ }, null, new DialogCreator.OnMultiDialogListener() {
+ @Override
+ public void onItemClick(DialogInterface dialog, int which, boolean isChecked) {
+ mBooks.get(which).setIsCloseUpdate(isChecked);
+ }
- mCloseRefreshDia = new MultiChoiceDialog().create(this, "禁用更新的书籍",
- mBooksName, isCloseRefresh, crBookCount, (dialog, which) -> {
- BookService.getInstance().updateBooks(mBooks);
- }, null, new DialogCreator.OnMultiDialogListener() {
- @Override
- public void onItemClick(DialogInterface dialog, int which, boolean isChecked) {
- mBooks.get(which).setIsCloseUpdate(isChecked);
- }
-
- @Override
- public void onSelectAll(boolean isSelectAll) {
- for (Book book : mBooks) {
- book.setIsCloseUpdate(isSelectAll);
- }
+ @Override
+ public void onSelectAll(boolean isSelectAll) {
+ for (Book book : mBooks) {
+ book.setIsCloseUpdate(isSelectAll);
}
- });
-
- });
+ }
+ });
});
binding.llThreadNum.setOnClickListener(v -> {
@@ -467,50 +476,43 @@ public class MoreSettingActivity extends BaseActivity {
- App.runOnUiThread(() -> {
- if (mDownloadAllDia != null) {
- mDownloadAllDia.show();
- return;
- }
-
- initmBooks();
-
- if (mBooks.size() == 0) {
- ToastUtils.showWarring("当前书架没有支持缓存的书籍!");
- return;
- }
-
- int booksCount = mBooks.size();
- CharSequence[] mBooksName = new CharSequence[booksCount];
- boolean[] isDownloadAll = new boolean[booksCount];
- int daBookCount = 0;
- for (int i = 0; i < booksCount; i++) {
- Book book = mBooks.get(i);
- mBooksName[i] = book.getName();
- isDownloadAll[i] = book.getIsDownLoadAll();
- if (isDownloadAll[i]) {
- daBookCount++;
- }
+ if (mDownloadAllDia != null) {
+ mDownloadAllDia.show();
+ return;
+ }
+ initmBooks();
+ if (mBooks.size() == 0) {
+ ToastUtils.showWarring("当前书架没有支持缓存的书籍!");
+ return;
+ }
+ int booksCount = mBooks.size();
+ CharSequence[] mBooksName = new CharSequence[booksCount];
+ boolean[] isDownloadAll = new boolean[booksCount];
+ int daBookCount = 0;
+ for (int i = 0; i < booksCount; i++) {
+ Book book = mBooks.get(i);
+ mBooksName[i] = book.getName();
+ isDownloadAll[i] = book.getIsDownLoadAll();
+ if (isDownloadAll[i]) {
+ daBookCount++;
}
+ }
+ mDownloadAllDia = new MultiChoiceDialog().create(this, "一键缓存的书籍",
+ mBooksName, isDownloadAll, daBookCount, (dialog, which) -> {
+ BookService.getInstance().updateBooks(mBooks);
+ }, null, new DialogCreator.OnMultiDialogListener() {
+ @Override
+ public void onItemClick(DialogInterface dialog, int which, boolean isChecked) {
+ mBooks.get(which).setIsDownLoadAll(isChecked);
+ }
- mDownloadAllDia = new MultiChoiceDialog().create(this, "一键缓存的书籍",
- mBooksName, isDownloadAll, daBookCount, (dialog, which) -> {
- BookService.getInstance().updateBooks(mBooks);
- }, null, new DialogCreator.OnMultiDialogListener() {
- @Override
- public void onItemClick(DialogInterface dialog, int which, boolean isChecked) {
- mBooks.get(which).setIsDownLoadAll(isChecked);
- }
-
- @Override
- public void onSelectAll(boolean isSelectAll) {
- for (Book book : mBooks) {
- book.setIsDownLoadAll(isSelectAll);
- }
+ @Override
+ public void onSelectAll(boolean isSelectAll) {
+ for (Book book : mBooks) {
+ book.setIsDownLoadAll(isSelectAll);
}
- });
-
- });
+ }
+ });
});
binding.ivMatchChapterTip.setOnClickListener(v -> DialogCreator.createTipDialog(this, "智能匹配", getString(R.string.match_chapter_tip)));
diff --git a/app/src/main/java/xyz/fycz/myreader/ui/adapter/BookcaseDetailedAdapter.java b/app/src/main/java/xyz/fycz/myreader/ui/adapter/BookcaseDetailedAdapter.java
index 9f1527b..957fac6 100644
--- a/app/src/main/java/xyz/fycz/myreader/ui/adapter/BookcaseDetailedAdapter.java
+++ b/app/src/main/java/xyz/fycz/myreader/ui/adapter/BookcaseDetailedAdapter.java
@@ -95,8 +95,8 @@ public class BookcaseDetailedAdapter extends BookcaseAdapter {
viewHolder.tvBookAuthor.setText(book.getAuthor());
viewHolder.tvHistoryChapter.setText(book.getHistoryChapterId());
- assert book.getNewestChapterTitle() != null;
- viewHolder.tvNewestChapter.setText(book.getNewestChapterTitle().replace("最近更新 ", ""));
+ if (book.getNewestChapterTitle() != null)
+ viewHolder.tvNewestChapter.setText(book.getNewestChapterTitle());
if (mEditState) {
viewHolder.tvNoReadNum.setVisibility(View.GONE);
diff --git a/app/src/main/java/xyz/fycz/myreader/ui/fragment/FindBook2Fragment.java b/app/src/main/java/xyz/fycz/myreader/ui/fragment/FindBook2Fragment.java
index 304d679..5217561 100644
--- a/app/src/main/java/xyz/fycz/myreader/ui/fragment/FindBook2Fragment.java
+++ b/app/src/main/java/xyz/fycz/myreader/ui/fragment/FindBook2Fragment.java
@@ -2,7 +2,6 @@ package xyz.fycz.myreader.ui.fragment;
import android.content.Intent;
import android.os.Bundle;
-import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -16,7 +15,6 @@ import org.jetbrains.annotations.NotNull;
import java.util.List;
import io.reactivex.disposables.Disposable;
-import xyz.fycz.myreader.base.BaseFragment;
import xyz.fycz.myreader.base.BitIntentDataManager;
import xyz.fycz.myreader.base.LazyFragment;
import xyz.fycz.myreader.base.adapter.BaseListAdapter;
@@ -30,8 +28,6 @@ import xyz.fycz.myreader.entity.ad.AdBean;
import xyz.fycz.myreader.greendao.entity.Book;
import xyz.fycz.myreader.greendao.service.BookService;
import xyz.fycz.myreader.ui.activity.BookDetailedActivity;
-import xyz.fycz.myreader.ui.activity.BookstoreActivity;
-import xyz.fycz.myreader.ui.activity.ReadActivity;
import xyz.fycz.myreader.ui.adapter.holder.FindBookHolder;
import xyz.fycz.myreader.ui.dialog.SourceExchangeDialog;
import xyz.fycz.myreader.util.ToastUtils;
@@ -40,7 +36,6 @@ import xyz.fycz.myreader.util.utils.AdUtils;
import xyz.fycz.myreader.util.utils.RxUtils;
import xyz.fycz.myreader.webapi.BookApi;
import xyz.fycz.myreader.webapi.crawler.base.FindCrawler;
-import xyz.fycz.myreader.widget.RefreshLayout;
/**
* @author fengyue
@@ -180,11 +175,9 @@ public class FindBook2Fragment extends LazyFragment {
findBookAdapter.refreshItems(books);
binding.srlFindBooks.finishRefresh();
if (flow != null) {
- int index = findBookAdapter.getItemCount() - books.size() + 2;
+ int index = findBookAdapter.getItemCount() - books.size() + 5;
index = Math.min(findBookAdapter.getItemCount() - 1, index);
findBookAdapter.addOther(index, flow);
- flow = null;
- getFlow();
}
}
} else {
@@ -194,11 +187,9 @@ public class FindBook2Fragment extends LazyFragment {
findBookAdapter.addItems(books);
binding.srlFindBooks.finishLoadMore();
if (flow != null) {
- int index = findBookAdapter.getItemCount() - books.size() + 2;
+ int index = findBookAdapter.getItemCount() - books.size() + 5;
index = Math.min(findBookAdapter.getItemCount() - 1, index);
findBookAdapter.addOther(index, flow);
- flow = null;
- getFlow();
}
}
}
diff --git a/app/src/main/java/xyz/fycz/myreader/ui/fragment/ProxyFragment.kt b/app/src/main/java/xyz/fycz/myreader/ui/fragment/ProxyFragment.kt
new file mode 100644
index 0000000..6127f82
--- /dev/null
+++ b/app/src/main/java/xyz/fycz/myreader/ui/fragment/ProxyFragment.kt
@@ -0,0 +1,189 @@
+package xyz.fycz.myreader.ui.fragment
+
+import android.content.DialogInterface
+import android.os.Bundle
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import android.widget.NumberPicker
+import androidx.appcompat.app.AlertDialog
+import com.kongzue.dialogx.dialogs.BottomMenu
+import io.reactivex.disposables.Disposable
+import xyz.fycz.myreader.R
+import xyz.fycz.myreader.application.SysManager
+import xyz.fycz.myreader.base.BaseFragment
+import xyz.fycz.myreader.base.adapter2.onClick
+import xyz.fycz.myreader.base.observer.MySingleObserver
+import xyz.fycz.myreader.databinding.FragmentProxySettingBinding
+import xyz.fycz.myreader.model.sourceAnalyzer.BookSourceManager
+import xyz.fycz.myreader.ui.dialog.DialogCreator.OnMultiDialogListener
+import xyz.fycz.myreader.ui.dialog.MultiChoiceDialog
+import xyz.fycz.myreader.ui.dialog.MyAlertDialog
+import xyz.fycz.myreader.util.SharedPreUtils
+import xyz.fycz.myreader.util.ToastUtils
+
+/**
+ * @author fengyue
+ * @date 2022/3/24 10:42
+ */
+class ProxyFragment : BaseFragment() {
+
+ private lateinit var binding: FragmentProxySettingBinding
+ private var proxyType: Int = 0
+ private var enableProxy: Boolean = false
+ private lateinit var proxyHost: String
+ private lateinit var proxyPort: String
+ private lateinit var proxyUsername: String
+ private lateinit var proxyPassword: String
+ private var mNoProxySourcesDia: AlertDialog? = null
+ private val proxyTypeArr = arrayOf("http", "socks5")
+ private val spu: SharedPreUtils = SharedPreUtils.getInstance()
+
+ override fun bindView(inflater: LayoutInflater, container: ViewGroup?): View {
+ binding = FragmentProxySettingBinding.inflate(inflater, container, false)
+ return binding.root
+ }
+
+ override fun initData(savedInstanceState: Bundle?) {
+ enableProxy = spu.getBoolean("enableProxy")
+ proxyType = spu.getInt("proxyType")
+ proxyHost = spu.getString("proxyHost")
+ proxyPort = spu.getString("proxyHost")
+ proxyUsername = spu.getString("proxyUsername")
+ proxyPassword = spu.getString("proxyPassword")
+ }
+
+ override fun initWidget(savedInstanceState: Bundle?) {
+ binding.scEnableProxy.isChecked = enableProxy
+ if (enableProxy) binding.llContent.visibility = View.VISIBLE
+ binding.tvProxyType.text = proxyTypeArr[proxyType]
+ binding.tvProxyHost.text = proxyHost.ifEmpty { "请输入代理服务器地址" }
+ binding.tvProxyPort.text = proxyHost.ifEmpty { "请输入代理服务器端口" }
+ binding.tvProxyUsername.text = proxyHost.ifEmpty { "请输入代理认证用户名" }
+ binding.tvProxyPassword.text = proxyHost.ifEmpty { "请输入代理认证密码" }
+ }
+
+ override fun initClick() {
+ binding.rlEnableProxy.onClick {
+ enableProxy = !enableProxy
+ binding.scEnableProxy.isChecked = enableProxy
+ spu.putBoolean("enableProxy", enableProxy)
+ binding.llContent.visibility = if (enableProxy) View.VISIBLE else View.GONE
+ }
+
+ binding.llProxyType.onClick {
+ BottomMenu.show(getString(R.string.proxy_type), proxyTypeArr)
+ .setSelection(proxyType)
+ .setOnMenuItemClickListener { _: BottomMenu?, _: CharSequence?, which: Int ->
+ proxyType = which
+ SharedPreUtils.getInstance().putInt("proxyType", which)
+ binding.tvProxyType.text = proxyTypeArr[which]
+ false
+ }.setCancelButton(R.string.cancel)
+ }
+ binding.llProxyHost.onClick {
+ var tem = ""
+ MyAlertDialog.createInputDia(
+ context, getString(R.string.proxy_host),
+ "", proxyHost, true, 100,
+ { text: String -> tem = text }
+ ) { dialog: DialogInterface, _: Int ->
+ proxyHost = tem
+ binding.tvProxyHost.text = proxyHost
+ spu.putString("proxyHost", proxyHost)
+ dialog.dismiss()
+ }
+ }
+ binding.llProxyPort.onClick {
+ val view =
+ LayoutInflater.from(context).inflate(R.layout.dialog_number_picker, null)
+ val threadPick = view.findViewById(R.id.number_picker)
+ threadPick.maxValue = 99999
+ threadPick.minValue = 10
+ threadPick.value = proxyPort.toInt()
+ threadPick.setOnScrollListener { _: NumberPicker?, _: Int -> }
+ MyAlertDialog.build(context)
+ .setTitle(R.string.proxy_port)
+ .setView(view)
+ .setPositiveButton(R.string.confirm) { _: DialogInterface?, _: Int ->
+ proxyPort = threadPick.value.toString()
+ spu.putString("proxyPort", proxyPort)
+ binding.tvProxyPort.text = proxyPort
+ }.setNegativeButton(R.string.cancel, null)
+ .show()
+ }
+ binding.llProxyUsername.onClick {
+ var tem = ""
+ MyAlertDialog.createInputDia(
+ context, getString(R.string.proxy_username),
+ "", proxyUsername, true, 100,
+ { text: String -> tem = text }
+ ) { dialog: DialogInterface, _: Int ->
+ proxyUsername = tem
+ binding.tvProxyUsername.text = proxyUsername
+ spu.putString("proxyUsername", proxyUsername)
+ dialog.dismiss()
+ }
+ }
+ binding.llProxyPassword.onClick {
+ var tem = ""
+ MyAlertDialog.createInputDia(
+ context, getString(R.string.proxy_password),
+ "", proxyPassword, true, 100,
+ { text: String -> tem = text }
+ ) { dialog: DialogInterface, _: Int ->
+ proxyPassword = tem
+ binding.tvProxyPassword.text = proxyPassword
+ spu.putString("proxyPassword", proxyPassword)
+ dialog.dismiss()
+ }
+ }
+
+ binding.llNoProxySources.onClick {
+ if (mNoProxySourcesDia != null) {
+ mNoProxySourcesDia?.show()
+ return@onClick
+ }
+ val sources = BookSourceManager.getAllBookSourceByOrderNum()
+ val mSourcesName = arrayOfNulls(sources.size)
+ val isNoProxy = BooleanArray(sources.size)
+ var dSourceCount = 0
+ for ((i, source) in sources.withIndex()) {
+ mSourcesName[i] = source.sourceName
+ val noProxy = source.getNoProxy()
+ if (noProxy) dSourceCount++
+ isNoProxy[i] = noProxy
+ }
+ mNoProxySourcesDia = MultiChoiceDialog().create(context, getString(R.string.no_proxy_sources_tip),
+ mSourcesName, isNoProxy, dSourceCount,
+ { _: DialogInterface?, _: Int ->
+ BookSourceManager.saveDatas(sources)
+ .subscribe(object : MySingleObserver() {
+ override fun onSubscribe(d: Disposable) {
+ addDisposable(d)
+ }
+
+ override fun onSuccess(aBoolean: Boolean) {
+ if (aBoolean) {
+ ToastUtils.showSuccess("保存成功")
+ }
+ }
+ })
+ }, null, object : OnMultiDialogListener {
+ override fun onItemClick(
+ dialog: DialogInterface,
+ which: Int,
+ isChecked: Boolean
+ ) {
+ sources[which].setNoProxy(isChecked)
+ }
+
+ override fun onSelectAll(isSelectAll: Boolean) {
+ for (source in sources) {
+ source.setNoProxy(isSelectAll)
+ }
+ }
+ })
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/xyz/fycz/myreader/util/utils/OkHttpUtils.java b/app/src/main/java/xyz/fycz/myreader/util/utils/OkHttpUtils.java
index d79f9e7..2efa86f 100644
--- a/app/src/main/java/xyz/fycz/myreader/util/utils/OkHttpUtils.java
+++ b/app/src/main/java/xyz/fycz/myreader/util/utils/OkHttpUtils.java
@@ -51,7 +51,11 @@ import static xyz.fycz.myreader.util.help.SSLSocketClient.getHeaderInterceptor;
public class OkHttpUtils {
public static OkHttpClient getOkHttpClient() {
- return HttpHelperKt.getOkHttpClient();
+ return getOkHttpClient(false);
+ }
+
+ public static OkHttpClient getOkHttpClient(boolean noProxy) {
+ return HttpHelperKt.getProxyClient(HttpHelperKt.getGlobalProxy(), noProxy);
}
/**
diff --git a/app/src/main/java/xyz/fycz/myreader/webapi/LanZouApi.kt b/app/src/main/java/xyz/fycz/myreader/webapi/LanZouApi.kt
index 0faf7f6..7638299 100644
--- a/app/src/main/java/xyz/fycz/myreader/webapi/LanZouApi.kt
+++ b/app/src/main/java/xyz/fycz/myreader/webapi/LanZouApi.kt
@@ -79,9 +79,9 @@ object LanZouApi {
): Coroutine?> {
return Coroutine.async {
val params = if (page == 1) {
- getFoldParams(OkHttpUtils.getHtml(foldUrl), page, pwd)
+ getFoldParams(getProxyClient().newCallResponseBody { url(foldUrl) }.text(), page, pwd)
} else {
- paramCathe[foldUrl] ?: getFoldParams(OkHttpUtils.getHtml(foldUrl), page, pwd)
+ paramCathe[foldUrl] ?: getFoldParams(getProxyClient().newCallResponseBody { url(foldUrl) }.text(), page, pwd)
}
params["pg"] = page
paramCathe[foldUrl] = params
diff --git a/app/src/main/res/layout/activity_more_setting.xml b/app/src/main/res/layout/activity_more_setting.xml
index 4f6b905..5a978dc 100644
--- a/app/src/main/res/layout/activity_more_setting.xml
+++ b/app/src/main/res/layout/activity_more_setting.xml
@@ -24,6 +24,31 @@
android:layout_height="match_parent"
android:orientation="vertical">
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/fragment_proxy_setting.xml b/app/src/main/res/layout/fragment_proxy_setting.xml
new file mode 100644
index 0000000..8ffc599
--- /dev/null
+++ b/app/src/main/res/layout/fragment_proxy_setting.xml
@@ -0,0 +1,203 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index f91eea5..bab8c2e 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -570,6 +570,16 @@
数据解析失败
+ 代理设置
+ 设置软件及书源代理
+ 代理类型
+ 代理服务器地址
+ 代理服务器端口
+ 代理认证用户名
+ 代理认证密码
+ 禁用代理的书源
+ 选择需要禁用代理的书源
+ 启用代理
- 跟随系统
diff --git a/gradle.properties b/gradle.properties
index 6d8cf36..730bd8d 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -17,4 +17,9 @@ org.gradle.jvmargs=-Xmx1536m
# org.gradle.parallel=true
android.useAndroidX=true
android.enableJetifier=true
-
+systemProp.socks.proxyHost=127.0.0.1
+systemProp.socks.proxyPort=1080
+systemProp.http.proxyHost=127.0.0.1
+systemProp.http.proxyPort=1081
+systemProp.https.proxyHost=127.0.0.1
+systemProp.https.proxyPort=1081
\ No newline at end of file