新增代理设置

pull/21/head
fengyuecanzhu 3 years ago
parent aa052a8816
commit c5759ba251
  1. 32
      .idea/assetWizardSettings.xml
  2. 3
      .idea/dictionaries/fengyue.xml
  3. 36
      .idea/inspectionProfiles/Project_Default.xml
  4. 10
      .idea/jarRepositories.xml
  5. 83
      .idea/misc.xml
  6. 24
      app/src/main/java/xyz/fycz/myreader/greendao/entity/rule/BookSource.java
  7. 8
      app/src/main/java/xyz/fycz/myreader/model/storage/Backup.kt
  8. 9
      app/src/main/java/xyz/fycz/myreader/model/storage/Restore.kt
  9. 2
      app/src/main/java/xyz/fycz/myreader/model/third3/BaseSource.kt
  10. 10
      app/src/main/java/xyz/fycz/myreader/model/third3/analyzeRule/AnalyzeUrl.kt
  11. 23
      app/src/main/java/xyz/fycz/myreader/model/third3/http/HttpHelper.kt
  12. 2
      app/src/main/java/xyz/fycz/myreader/ui/activity/AboutActivity.java
  13. 40
      app/src/main/java/xyz/fycz/myreader/ui/activity/MoreSettingActivity.java
  14. 4
      app/src/main/java/xyz/fycz/myreader/ui/adapter/BookcaseDetailedAdapter.java
  15. 13
      app/src/main/java/xyz/fycz/myreader/ui/fragment/FindBook2Fragment.java
  16. 189
      app/src/main/java/xyz/fycz/myreader/ui/fragment/ProxyFragment.kt
  17. 6
      app/src/main/java/xyz/fycz/myreader/util/utils/OkHttpUtils.java
  18. 4
      app/src/main/java/xyz/fycz/myreader/webapi/LanZouApi.kt
  19. 34
      app/src/main/res/layout/activity_more_setting.xml
  20. 203
      app/src/main/res/layout/fragment_proxy_setting.xml
  21. 10
      app/src/main/res/values/strings.xml
  22. 7
      gradle.properties

@ -1,32 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="WizardSettings">
<option name="children">
<map>
<entry key="vectorWizard">
<value>
<PersistentState>
<option name="children">
<map>
<entry key="vectorAssetStep">
<value>
<PersistentState>
<option name="values">
<map>
<entry key="assetSourceType" value="FILE" />
<entry key="outputName" value="ic_info" />
<entry key="sourceFile" value="F:\SVG图标\info.svg" />
</map>
</option>
</PersistentState>
</value>
</entry>
</map>
</option>
</PersistentState>
</value>
</entry>
</map>
</option>
</component>
</project>

@ -1,3 +0,0 @@
<component name="ProjectDictionaryState">
<dictionary name="fengyue" />
</component>

@ -1,36 +0,0 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="JavaDoc" enabled="true" level="WARNING" enabled_by_default="true">
<option name="TOP_LEVEL_CLASS_OPTIONS">
<value>
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
<option name="REQUIRED_TAGS" value="" />
</value>
</option>
<option name="INNER_CLASS_OPTIONS">
<value>
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
<option name="REQUIRED_TAGS" value="" />
</value>
</option>
<option name="METHOD_OPTIONS">
<value>
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
<option name="REQUIRED_TAGS" value="@return@param@throws or @exception" />
</value>
</option>
<option name="FIELD_OPTIONS">
<value>
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
<option name="REQUIRED_TAGS" value="" />
</value>
</option>
<option name="IGNORE_DEPRECATED" value="false" />
<option name="IGNORE_JAVADOC_PERIOD" value="true" />
<option name="IGNORE_DUPLICATED_THROWS" value="false" />
<option name="IGNORE_POINT_TO_ITSELF" value="false" />
<option name="myAdditionalJavadocTags" value="date" />
</inspection_tool>
</profile>
</component>

@ -11,6 +11,11 @@
<option name="name" value="JBoss Community repository" /> <option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" /> <option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository> </remote-repository>
<remote-repository>
<option name="id" value="maven2" />
<option name="name" value="maven2" />
<option name="url" value="https://artifact.bytedance.com/repository/pangle" />
</remote-repository>
<remote-repository> <remote-repository>
<option name="id" value="BintrayJCenter" /> <option name="id" value="BintrayJCenter" />
<option name="name" value="BintrayJCenter" /> <option name="name" value="BintrayJCenter" />
@ -26,10 +31,5 @@
<option name="name" value="Google" /> <option name="name" value="Google" />
<option name="url" value="https://dl.google.com/dl/android/maven2/" /> <option name="url" value="https://dl.google.com/dl/android/maven2/" />
</remote-repository> </remote-repository>
<remote-repository>
<option name="id" value="maven2" />
<option name="name" value="maven2" />
<option name="url" value="https://artifact.bytedance.com/repository/pangle" />
</remote-repository>
</component> </component>
</project> </project>

@ -3,88 +3,13 @@
<component name="DesignSurface"> <component name="DesignSurface">
<option name="filePathToZoomLevelMap"> <option name="filePathToZoomLevelMap">
<map> <map>
<entry key="..\:/android/FYReader/app/src/main/res/drawable/ic_about.xml" value="0.20925925925925926" /> <entry key="..\:/android/FYReader/app/src/main/res/layout/activity_more_setting.xml" value="0.2" />
<entry key="..\:/android/FYReader/app/src/main/res/drawable/ic_delete.xml" value="0.18518518518518517" /> <entry key="..\:/android/FYReader/app/src/main/res/layout/fragment_private_bookcase.xml" value="0.12132725430597771" />
<entry key="..\:/android/FYReader/app/src/main/res/drawable/ic_exit.xml" value="0.20925925925925926" /> <entry key="..\:/android/FYReader/app/src/main/res/layout/fragment_proxy_setting.xml" value="0.22826086956521738" />
<entry key="..\:/android/FYReader/app/src/main/res/drawable/ic_online_syn.xml" value="0.19074074074074074" /> <entry key="..\:/android/FYReader/app/src/main/res/layout/fragment_webdav_setting.xml" value="0.2" />
<entry key="..\:/android/FYReader/app/src/main/res/drawable/ic_re_seg.xml" value="0.1962962962962963" />
<entry key="..\:/android/FYReader/app/src/main/res/drawable/ic_restore.xml" value="0.19074074074074074" />
<entry key="..\:/android/FYReader/app/src/main/res/drawable/ic_search_word.xml" value="0.21944444444444444" />
<entry key="..\:/android/FYReader/app/src/main/res/drawable/info_ic.xml" value="0.20925925925925926" />
<entry key="..\:/android/FYReader/app/src/main/res/drawable/login_btn_selector.xml" value="0.17777777777777778" />
<entry key="..\:/android/FYReader/app/src/main/res/drawable/reboot_ic.xml" value="0.20925925925925926" />
<entry key="..\:/android/FYReader/app/src/main/res/drawable/selector_btn_add.xml" value="0.17777777777777778" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/activity_about.xml" value="0.12132725430597771" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/activity_ad_setting.xml" value="0.21557971014492755" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/activity_auth_email.xml" value="0.1897644927536232" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/activity_book_detail.xml" value="0.12132725430597771" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/activity_catalog.xml" value="0.21557971014492755" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/activity_crash.xml" value="0.264" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/activity_donate.xml" value="0.32698961937716264" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/activity_feedback.xml" value="0.12132725430597771" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/activity_file_picker.xml" value="0.2318840579710145" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/activity_group_manager.xml" value="0.12132725430597771" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/activity_login.xml" value="0.176" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/activity_manage_group.xml" value="0.21195652173913043" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/activity_more_setting.xml" value="0.264" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/activity_read.xml" value="0.17028985507246377" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/activity_register.xml" value="0.2796934865900383" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/activity_remove_ad.xml" value="0.21557971014492755" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/activity_search_book.xml" value="0.26904376012965964" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/activity_search_word.xml" value="0.144" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/activity_source_debug.xml" value="0.2391304347826087" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/activity_source_subscribe.xml" value="0.21557971014492755" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/activity_user_info.xml" value="0.28027681660899656" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/dialog_book_source.xml" value="0.20969202898550723" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/dialog_loading.xml" value="0.1" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/dialog_textview.xml" value="0.1947463768115942" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/fingerprint_dialog.xml" value="0.20425724637681159" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/fragment_book_list.xml" value="0.12132725430597771" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/fragment_file_category.xml" value="0.2318840579710145" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/fragment_find_book_2.xml" value="0.12132725430597771" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/fragment_import_source.xml" value="0.12132725430597771" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/fragment_local_book.xml" value="0.21557971014492755" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/fragment_local_source.xml" value="0.1947463768115942" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/fragment_mine.xml" value="0.37037037037037035" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/fragment_private_bookcase.xml" value="0.21195652173913043" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/fragment_subscribe_source.xml" value="0.21557971014492755" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/fragment_webdav_setting.xml" value="0.4" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/gridview_book_detailed_item.xml" value="0.1947463768115942" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/item_book_source.xml" value="0.21195652173913043" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/item_file.xml" value="0.21557971014492755" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/item_find_source.xml" value="0.12132725430597771" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/item_group.xml" value="0.4" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/item_lan_zou_file.xml" value="0.21557971014492755" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/item_local_source.xml" value="0.536" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/item_read_record.xml" value="0.12132725430597771" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/item_replace_rule.xml" value="0.1947463768115942" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/item_search_book.xml" value="0.1947463768115942" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/item_search_word1.xml" value="0.2889273356401384" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/item_search_word2.xml" value="0.1947463768115942" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/item_search_word_1.xml" value="0.1947463768115942" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/item_subscribe_source.xml" value="0.21557971014492755" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/layout_about_content.xml" value="0.176" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/layout_book_detail_content.xml" value="0.17889492753623187" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/layout_book_detail_header.xml" value="0.536" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/listview_search_book_item.xml" value="0.22010869565217392" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/menu_book.xml" value="0.21557971014492755" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/search_book_item.xml" value="0.1947463768115942" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/view_file_picker.xml" value="0.12132725430597771" />
<entry key="..\:/android/FYReader/app/src/main/res/menu/menu_book.xml" value="0.13703703703703704" />
<entry key="..\:/android/FYReader/app/src/main/res/menu/menu_book_detail.xml" value="0.24947916666666667" />
<entry key="..\:/android/FYReader/app/src/main/res/menu/menu_book_detail_local.xml" value="0.24947916666666667" />
<entry key="..\:/android/FYReader/app/src/main/res/menu/menu_import_source.xml" value="0.1675925925925926" />
<entry key="..\:/android/FYReader/app/src/main/res/menu/menu_read.xml" value="0.24947916666666667" />
<entry key="..\:/android/FYReader/app/src/main/res/menu/menu_rule.xml" value="0.24947916666666667" />
<entry key="..\:/android/FYReader/app/src/main/res/menu/menu_search_word.xml" value="0.1425925925925926" />
<entry key="..\:/android/FYReader/app/src/main/res/menu/menu_source_edit.xml" value="0.2815533980582524" />
<entry key="..\:/android/FYReader/app/src/main/res/menu/menu_subscribe_source.xml" value="0.24947916666666667" />
</map> </map>
</option> </option>
</component> </component>
<component name="FrameworkDetectionExcludesConfiguration">
<file type="web" url="file://$PROJECT_DIR$" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" /> <output url="file://$PROJECT_DIR$/build/classes" />
</component> </component>

@ -57,6 +57,8 @@ public class BookSource extends BaseSource implements Parcelable, Cloneable {
private int weight; private int weight;
private boolean enable; private boolean enable;
private boolean noProxy;//不使用代理
@Transient @Transient
private transient ArrayList<String> groupList; private transient ArrayList<String> groupList;
@ -76,12 +78,12 @@ public class BookSource extends BaseSource implements Parcelable, Cloneable {
@Convert(converter = FindRuleConvert.class, columnType = String.class) @Convert(converter = FindRuleConvert.class, columnType = String.class)
private FindRule findRule; private FindRule findRule;
@Generated(hash = 798251066) @Generated(hash = 945434046)
public BookSource(String sourceUrl, String sourceEName, String sourceName, String sourceGroup, public BookSource(String sourceUrl, String sourceEName, String sourceName, String sourceGroup,
String sourceCharset, String sourceType, String sourceHeaders, String loginUrl, String sourceCharset, String sourceType, String sourceHeaders, String loginUrl, String loginCheckJs,
String loginCheckJs, String sourceComment, String concurrentRate, Long lastUpdateTime, String sourceComment, String concurrentRate, Long lastUpdateTime, int orderNum, int weight,
int orderNum, int weight, boolean enable, SearchRule searchRule, InfoRule infoRule, boolean enable, boolean noProxy, SearchRule searchRule, InfoRule infoRule, TocRule tocRule,
TocRule tocRule, ContentRule contentRule, FindRule findRule) { ContentRule contentRule, FindRule findRule) {
this.sourceUrl = sourceUrl; this.sourceUrl = sourceUrl;
this.sourceEName = sourceEName; this.sourceEName = sourceEName;
this.sourceName = sourceName; this.sourceName = sourceName;
@ -97,6 +99,7 @@ public class BookSource extends BaseSource implements Parcelable, Cloneable {
this.orderNum = orderNum; this.orderNum = orderNum;
this.weight = weight; this.weight = weight;
this.enable = enable; this.enable = enable;
this.noProxy = noProxy;
this.searchRule = searchRule; this.searchRule = searchRule;
this.infoRule = infoRule; this.infoRule = infoRule;
this.tocRule = tocRule; this.tocRule = tocRule;
@ -129,6 +132,7 @@ public class BookSource extends BaseSource implements Parcelable, Cloneable {
orderNum = in.readInt(); orderNum = in.readInt();
weight = in.readInt(); weight = in.readInt();
enable = in.readByte() != 0; enable = in.readByte() != 0;
noProxy = in.readByte() != 0;
searchRule = in.readParcelable(SearchRule.class.getClassLoader()); searchRule = in.readParcelable(SearchRule.class.getClassLoader());
infoRule = in.readParcelable(InfoRule.class.getClassLoader()); infoRule = in.readParcelable(InfoRule.class.getClassLoader());
tocRule = in.readParcelable(TocRule.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(orderNum);
dest.writeInt(weight); dest.writeInt(weight);
dest.writeByte((byte) (enable ? 1 : 0)); dest.writeByte((byte) (enable ? 1 : 0));
dest.writeByte((byte) (noProxy ? 1 : 0));
dest.writeParcelable(searchRule, flags); dest.writeParcelable(searchRule, flags);
dest.writeParcelable(infoRule, flags); dest.writeParcelable(infoRule, flags);
dest.writeParcelable(tocRule, 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; if (o == null || getClass() != o.getClass()) return false;
BookSource source = (BookSource) o; BookSource source = (BookSource) o;
return enable == source.enable && return enable == source.enable &&
noProxy == source.noProxy &&
stringEquals(sourceUrl, source.sourceUrl) && stringEquals(sourceUrl, source.sourceUrl) &&
stringEquals(sourceEName, source.sourceEName) && stringEquals(sourceEName, source.sourceEName) &&
stringEquals(sourceName, source.sourceName) && stringEquals(sourceName, source.sourceName) &&
@ -458,4 +464,12 @@ public class BookSource extends BaseSource implements Parcelable, Cloneable {
public BookSource getSource() { public BookSource getSource() {
return this; return this;
} }
public boolean getNoProxy() {
return this.noProxy;
}
public void setNoProxy(boolean noProxy) {
this.noProxy = noProxy;
}
} }

@ -43,6 +43,7 @@ object Backup {
"bookSource.json", "bookSource.json",
"readRecord.json", "readRecord.json",
"searchWord.json", "searchWord.json",
"subscribe.json",
"config.xml" "config.xml"
) )
} }
@ -137,6 +138,13 @@ object Backup {
.writeText(json) .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 { try {
val setting = SysManager.getNewSetting() val setting = SysManager.getNewSetting()
val readStyles = setting.readStyles val readStyles = setting.readStyles

@ -139,6 +139,15 @@ object Restore {
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printStackTrace()
} }
try {
val file = FileUtils.getFile(path + File.separator + "subscribe.json")
val json = file.readText()
GSON.fromJsonArray<SubscribeFile>(json)?.let {
DbManager.getInstance().session.subscribeFileDao.insertOrReplaceInTx(it)
}
} catch (e: Exception) {
e.printStackTrace()
}
try { try {
val settingFile = FileUtils.getFile(path + File.separator + "setting.json") val settingFile = FileUtils.getFile(path + File.separator + "setting.json")
val settingJson = settingFile.readText() val settingJson = settingFile.readText()

@ -32,6 +32,8 @@ abstract class BaseSource : JsExtensions {
open fun getKey(): String = "" open fun getKey(): String = ""
open fun getNoProxy(): Boolean = false
/*fun loginUi(): List<RowUi>? { /*fun loginUi(): List<RowUi>? {
return GSON.fromJsonArray(loginUi) return GSON.fromJsonArray(loginUi)
}*/ }*/

@ -357,7 +357,7 @@ class AnalyzeUrl(
if (this.useWebView && useWebView) { if (this.useWebView && useWebView) {
strResponse = when (method) { strResponse = when (method) {
RequestMethod.POST -> { RequestMethod.POST -> {
val body = getProxyClient(proxy).newCallStrResponse(retry) { val body = getProxyClient(proxy, source?.getNoProxy() == true).newCallStrResponse(retry) {
addHeaders(headerMap) addHeaders(headerMap)
url(urlNoQuery) url(urlNoQuery)
if (fieldMap.isNotEmpty() || body.isNullOrBlank()) { if (fieldMap.isNotEmpty() || body.isNullOrBlank()) {
@ -384,7 +384,7 @@ class AnalyzeUrl(
).getStrResponse() ).getStrResponse()
} }
} else { } else {
strResponse = getProxyClient(proxy).newCallStrResponse(retry) { strResponse = getProxyClient(proxy, source?.getNoProxy() == true).newCallStrResponse(retry) {
addHeaders(headerMap) addHeaders(headerMap)
when (method) { when (method) {
RequestMethod.POST -> { RequestMethod.POST -> {
@ -421,7 +421,7 @@ class AnalyzeUrl(
val concurrentRecord = fetchStart() val concurrentRecord = fetchStart()
setCookie(source?.getKey()) setCookie(source?.getKey())
@Suppress("BlockingMethodInNonBlockingContext") @Suppress("BlockingMethodInNonBlockingContext")
val response = getProxyClient(proxy).newCallResponse(retry) { val response = getProxyClient(proxy, source?.getNoProxy() == true).newCallResponse(retry) {
addHeaders(headerMap) addHeaders(headerMap)
when (method) { when (method) {
RequestMethod.POST -> { RequestMethod.POST -> {
@ -452,7 +452,7 @@ class AnalyzeUrl(
val concurrentRecord = fetchStart() val concurrentRecord = fetchStart()
setCookie(source?.getKey()) setCookie(source?.getKey())
@Suppress("BlockingMethodInNonBlockingContext") @Suppress("BlockingMethodInNonBlockingContext")
val byteArray = getProxyClient(proxy).newCallResponseBody(retry) { val byteArray = getProxyClient(proxy, source?.getNoProxy() == true).newCallResponseBody(retry) {
addHeaders(headerMap) addHeaders(headerMap)
when (method) { when (method) {
RequestMethod.POST -> { RequestMethod.POST -> {
@ -480,7 +480,7 @@ class AnalyzeUrl(
* 上传文件 * 上传文件
*/ */
suspend fun upload(fileName: String, file: Any, contentType: String): StrResponse { 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) url(urlNoQuery)
val bodyMap = GSON.fromJsonObject<HashMap<String, Any>>(body)!! val bodyMap = GSON.fromJsonObject<HashMap<String, Any>>(body)!!
bodyMap.forEach { entry -> bodyMap.forEach { entry ->

@ -4,6 +4,7 @@ import okhttp3.ConnectionSpec
import okhttp3.Credentials import okhttp3.Credentials
import okhttp3.Interceptor import okhttp3.Interceptor
import okhttp3.OkHttpClient import okhttp3.OkHttpClient
import xyz.fycz.myreader.util.SharedPreUtils
import java.net.InetSocketAddress import java.net.InetSocketAddress
import java.net.Proxy import java.net.Proxy
import java.util.concurrent.ConcurrentHashMap import java.util.concurrent.ConcurrentHashMap
@ -24,7 +25,7 @@ val okHttpClient: OkHttpClient by lazy {
.connectTimeout(15, TimeUnit.SECONDS) .connectTimeout(15, TimeUnit.SECONDS)
.writeTimeout(15, TimeUnit.SECONDS) .writeTimeout(15, TimeUnit.SECONDS)
.readTimeout(15, TimeUnit.SECONDS) .readTimeout(15, TimeUnit.SECONDS)
.callTimeout(60,TimeUnit.SECONDS) .callTimeout(60, TimeUnit.SECONDS)
.sslSocketFactory(SSLHelper.unsafeSSLSocketFactory, SSLHelper.unsafeTrustManager) .sslSocketFactory(SSLHelper.unsafeSSLSocketFactory, SSLHelper.unsafeTrustManager)
.retryOnConnectionFailure(true) .retryOnConnectionFailure(true)
.hostnameVerifier(SSLHelper.unsafeHostnameVerifier) .hostnameVerifier(SSLHelper.unsafeHostnameVerifier)
@ -46,17 +47,31 @@ val okHttpClient: OkHttpClient by lazy {
builder.build() 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 * 缓存代理okHttp
*/ */
fun getProxyClient(proxy: String? = null): OkHttpClient { fun getProxyClient(proxy: String? = globalProxy, noProxy: Boolean = false): OkHttpClient {
if (proxy.isNullOrBlank()) { if (proxy.isNullOrBlank() || noProxy) {
return okHttpClient return okHttpClient
} }
proxyClientCache[proxy]?.let { proxyClientCache[proxy]?.let {
return it 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 ms = r.findAll(proxy)
val group = ms.first() val group = ms.first()
var username = "" //代理服务器验证用户名 var username = "" //代理服务器验证用户名

@ -116,7 +116,7 @@ public class AboutActivity extends BaseActivity<ActivityAboutBinding> {
String[] str = new String[1]; String[] str = new String[1];
MyAlertDialog.createInputDia(this, getString(R.string.lan_zou_parse), MyAlertDialog.createInputDia(this, getString(R.string.lan_zou_parse),
"格式:链接+逗号+密码(没有密码就不用填)", "", true, "格式:链接+逗号+密码(没有密码就不用填)", "", true,
100, text -> str[0] = text, (dialog, which) -> { 500, text -> str[0] = text, (dialog, which) -> {
LanZouApi.INSTANCE.getFileUrl(str[0]) LanZouApi.INSTANCE.getFileUrl(str[0])
.compose(RxUtils::toSimpleSingle) .compose(RxUtils::toSimpleSingle)
.subscribe(new MyObserver<String>() { .subscribe(new MyObserver<String>() {

@ -50,6 +50,7 @@ import xyz.fycz.myreader.ui.dialog.LoadingDialog;
import xyz.fycz.myreader.ui.dialog.MultiChoiceDialog; import xyz.fycz.myreader.ui.dialog.MultiChoiceDialog;
import xyz.fycz.myreader.ui.dialog.MyAlertDialog; import xyz.fycz.myreader.ui.dialog.MyAlertDialog;
import xyz.fycz.myreader.ui.fragment.PrivateBooksFragment; 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.ui.fragment.WebDavFragment;
import xyz.fycz.myreader.util.SharedPreUtils; import xyz.fycz.myreader.util.SharedPreUtils;
import xyz.fycz.myreader.util.ToastUtils; import xyz.fycz.myreader.util.ToastUtils;
@ -91,11 +92,10 @@ public class MoreSettingActivity extends BaseActivity<ActivityMoreSettingBinding
//选择禁用更新书籍对话框 //选择禁用更新书籍对话框
private AlertDialog mCloseRefreshDia; private AlertDialog mCloseRefreshDia;
//选择禁用更新书源对话框
private AlertDialog mDisableSourceDia;
//选择一键缓存书籍对话框 //选择一键缓存书籍对话框
private AlertDialog mDownloadAllDia; private AlertDialog mDownloadAllDia;
private ProxyFragment mProxyFragment;
private WebDavFragment mWebDavFragment; private WebDavFragment mWebDavFragment;
private PrivateBooksFragment mPrivateBooksFragment; private PrivateBooksFragment mPrivateBooksFragment;
@ -148,6 +148,9 @@ public class MoreSettingActivity extends BaseActivity<ActivityMoreSettingBinding
} else if (curFragment == mPrivateBooksFragment) { } else if (curFragment == mPrivateBooksFragment) {
getSupportActionBar().setTitle(getString(R.string.private_bookcase)); getSupportActionBar().setTitle(getString(R.string.private_bookcase));
invalidateOptionsMenu(); invalidateOptionsMenu();
} else if (curFragment == mProxyFragment) {
getSupportActionBar().setTitle(getString(R.string.proxy_setting));
invalidateOptionsMenu();
} }
} }
@ -171,7 +174,7 @@ public class MoreSettingActivity extends BaseActivity<ActivityMoreSettingBinding
} }
private void initMineShowMode() { private void initMineShowMode() {
switch (mineShowMode){ switch (mineShowMode) {
case 1: case 1:
binding.tvMineShow.setText(getString(R.string.show_cloud_only)); binding.tvMineShow.setText(getString(R.string.show_cloud_only));
break; break;
@ -203,7 +206,7 @@ public class MoreSettingActivity extends BaseActivity<ActivityMoreSettingBinding
@Override @Override
public boolean onPrepareOptionsMenu(Menu menu) { public boolean onPrepareOptionsMenu(Menu menu) {
if (curFragment == null) { if (curFragment == null || curFragment != mProxyFragment) {
menu.findItem(R.id.action_tip).setVisible(false); menu.findItem(R.id.action_tip).setVisible(false);
} else { } else {
menu.findItem(R.id.action_tip).setVisible(true); menu.findItem(R.id.action_tip).setVisible(true);
@ -238,6 +241,20 @@ public class MoreSettingActivity extends BaseActivity<ActivityMoreSettingBinding
@Override @Override
protected void initClick() { protected void initClick() {
super.initClick(); super.initClick();
binding.llProxy.setOnClickListener(v -> {
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.llWebdav.setOnClickListener(v -> {
binding.svContent.setVisibility(View.GONE); binding.svContent.setVisibility(View.GONE);
FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
@ -386,22 +403,17 @@ public class MoreSettingActivity extends BaseActivity<ActivityMoreSettingBinding
); );
binding.llCloseRefresh.setOnClickListener(v -> { binding.llCloseRefresh.setOnClickListener(v -> {
App.runOnUiThread(() -> {
if (mCloseRefreshDia != null) { if (mCloseRefreshDia != null) {
mCloseRefreshDia.show(); mCloseRefreshDia.show();
return; return;
} }
initmBooks(); initmBooks();
if (mBooks.size() == 0) { if (mBooks.size() == 0) {
ToastUtils.showWarring("当前书架没有支持禁用更新的书籍!"); ToastUtils.showWarring("当前书架没有支持禁用更新的书籍!");
return; return;
} }
boolean[] isCloseRefresh = new boolean[booksCount]; boolean[] isCloseRefresh = new boolean[booksCount];
int crBookCount = 0; int crBookCount = 0;
for (int i = 0; i < booksCount; i++) { for (int i = 0; i < booksCount; i++) {
Book book = mBooks.get(i); Book book = mBooks.get(i);
isCloseRefresh[i] = book.getIsCloseUpdate(); isCloseRefresh[i] = book.getIsCloseUpdate();
@ -409,7 +421,6 @@ public class MoreSettingActivity extends BaseActivity<ActivityMoreSettingBinding
crBookCount++; crBookCount++;
} }
} }
mCloseRefreshDia = new MultiChoiceDialog().create(this, "禁用更新的书籍", mCloseRefreshDia = new MultiChoiceDialog().create(this, "禁用更新的书籍",
mBooksName, isCloseRefresh, crBookCount, (dialog, which) -> { mBooksName, isCloseRefresh, crBookCount, (dialog, which) -> {
BookService.getInstance().updateBooks(mBooks); BookService.getInstance().updateBooks(mBooks);
@ -426,8 +437,6 @@ public class MoreSettingActivity extends BaseActivity<ActivityMoreSettingBinding
} }
} }
}); });
});
}); });
binding.llThreadNum.setOnClickListener(v -> { binding.llThreadNum.setOnClickListener(v -> {
@ -467,19 +476,15 @@ public class MoreSettingActivity extends BaseActivity<ActivityMoreSettingBinding
binding.llDownloadAll.setOnClickListener(v -> { binding.llDownloadAll.setOnClickListener(v -> {
App.runOnUiThread(() -> {
if (mDownloadAllDia != null) { if (mDownloadAllDia != null) {
mDownloadAllDia.show(); mDownloadAllDia.show();
return; return;
} }
initmBooks(); initmBooks();
if (mBooks.size() == 0) { if (mBooks.size() == 0) {
ToastUtils.showWarring("当前书架没有支持缓存的书籍!"); ToastUtils.showWarring("当前书架没有支持缓存的书籍!");
return; return;
} }
int booksCount = mBooks.size(); int booksCount = mBooks.size();
CharSequence[] mBooksName = new CharSequence[booksCount]; CharSequence[] mBooksName = new CharSequence[booksCount];
boolean[] isDownloadAll = new boolean[booksCount]; boolean[] isDownloadAll = new boolean[booksCount];
@ -492,7 +497,6 @@ public class MoreSettingActivity extends BaseActivity<ActivityMoreSettingBinding
daBookCount++; daBookCount++;
} }
} }
mDownloadAllDia = new MultiChoiceDialog().create(this, "一键缓存的书籍", mDownloadAllDia = new MultiChoiceDialog().create(this, "一键缓存的书籍",
mBooksName, isDownloadAll, daBookCount, (dialog, which) -> { mBooksName, isDownloadAll, daBookCount, (dialog, which) -> {
BookService.getInstance().updateBooks(mBooks); BookService.getInstance().updateBooks(mBooks);
@ -509,8 +513,6 @@ public class MoreSettingActivity extends BaseActivity<ActivityMoreSettingBinding
} }
} }
}); });
});
}); });
binding.ivMatchChapterTip.setOnClickListener(v -> DialogCreator.createTipDialog(this, "智能匹配", getString(R.string.match_chapter_tip))); binding.ivMatchChapterTip.setOnClickListener(v -> DialogCreator.createTipDialog(this, "智能匹配", getString(R.string.match_chapter_tip)));

@ -95,8 +95,8 @@ public class BookcaseDetailedAdapter extends BookcaseAdapter {
viewHolder.tvBookAuthor.setText(book.getAuthor()); viewHolder.tvBookAuthor.setText(book.getAuthor());
viewHolder.tvHistoryChapter.setText(book.getHistoryChapterId()); viewHolder.tvHistoryChapter.setText(book.getHistoryChapterId());
assert book.getNewestChapterTitle() != null; if (book.getNewestChapterTitle() != null)
viewHolder.tvNewestChapter.setText(book.getNewestChapterTitle().replace("最近更新 ", "")); viewHolder.tvNewestChapter.setText(book.getNewestChapterTitle());
if (mEditState) { if (mEditState) {
viewHolder.tvNoReadNum.setVisibility(View.GONE); viewHolder.tvNoReadNum.setVisibility(View.GONE);

@ -2,7 +2,6 @@ package xyz.fycz.myreader.ui.fragment;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -16,7 +15,6 @@ import org.jetbrains.annotations.NotNull;
import java.util.List; import java.util.List;
import io.reactivex.disposables.Disposable; import io.reactivex.disposables.Disposable;
import xyz.fycz.myreader.base.BaseFragment;
import xyz.fycz.myreader.base.BitIntentDataManager; import xyz.fycz.myreader.base.BitIntentDataManager;
import xyz.fycz.myreader.base.LazyFragment; import xyz.fycz.myreader.base.LazyFragment;
import xyz.fycz.myreader.base.adapter.BaseListAdapter; 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.entity.Book;
import xyz.fycz.myreader.greendao.service.BookService; import xyz.fycz.myreader.greendao.service.BookService;
import xyz.fycz.myreader.ui.activity.BookDetailedActivity; 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.adapter.holder.FindBookHolder;
import xyz.fycz.myreader.ui.dialog.SourceExchangeDialog; import xyz.fycz.myreader.ui.dialog.SourceExchangeDialog;
import xyz.fycz.myreader.util.ToastUtils; 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.util.utils.RxUtils;
import xyz.fycz.myreader.webapi.BookApi; import xyz.fycz.myreader.webapi.BookApi;
import xyz.fycz.myreader.webapi.crawler.base.FindCrawler; import xyz.fycz.myreader.webapi.crawler.base.FindCrawler;
import xyz.fycz.myreader.widget.RefreshLayout;
/** /**
* @author fengyue * @author fengyue
@ -180,11 +175,9 @@ public class FindBook2Fragment extends LazyFragment {
findBookAdapter.refreshItems(books); findBookAdapter.refreshItems(books);
binding.srlFindBooks.finishRefresh(); binding.srlFindBooks.finishRefresh();
if (flow != null) { if (flow != null) {
int index = findBookAdapter.getItemCount() - books.size() + 2; int index = findBookAdapter.getItemCount() - books.size() + 5;
index = Math.min(findBookAdapter.getItemCount() - 1, index); index = Math.min(findBookAdapter.getItemCount() - 1, index);
findBookAdapter.addOther(index, flow); findBookAdapter.addOther(index, flow);
flow = null;
getFlow();
} }
} }
} else { } else {
@ -194,11 +187,9 @@ public class FindBook2Fragment extends LazyFragment {
findBookAdapter.addItems(books); findBookAdapter.addItems(books);
binding.srlFindBooks.finishLoadMore(); binding.srlFindBooks.finishLoadMore();
if (flow != null) { if (flow != null) {
int index = findBookAdapter.getItemCount() - books.size() + 2; int index = findBookAdapter.getItemCount() - books.size() + 5;
index = Math.min(findBookAdapter.getItemCount() - 1, index); index = Math.min(findBookAdapter.getItemCount() - 1, index);
findBookAdapter.addOther(index, flow); findBookAdapter.addOther(index, flow);
flow = null;
getFlow();
} }
} }
} }

@ -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<NumberPicker>(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<CharSequence>(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<Boolean?>() {
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)
}
}
})
}
}
}

@ -51,7 +51,11 @@ import static xyz.fycz.myreader.util.help.SSLSocketClient.getHeaderInterceptor;
public class OkHttpUtils { public class OkHttpUtils {
public static OkHttpClient getOkHttpClient() { public static OkHttpClient getOkHttpClient() {
return HttpHelperKt.getOkHttpClient(); return getOkHttpClient(false);
}
public static OkHttpClient getOkHttpClient(boolean noProxy) {
return HttpHelperKt.getProxyClient(HttpHelperKt.getGlobalProxy(), noProxy);
} }
/** /**

@ -79,9 +79,9 @@ object LanZouApi {
): Coroutine<List<LanZouFile>?> { ): Coroutine<List<LanZouFile>?> {
return Coroutine.async { return Coroutine.async {
val params = if (page == 1) { val params = if (page == 1) {
getFoldParams(OkHttpUtils.getHtml(foldUrl), page, pwd) getFoldParams(getProxyClient().newCallResponseBody { url(foldUrl) }.text(), page, pwd)
} else { } else {
paramCathe[foldUrl] ?: getFoldParams(OkHttpUtils.getHtml(foldUrl), page, pwd) paramCathe[foldUrl] ?: getFoldParams(getProxyClient().newCallResponseBody { url(foldUrl) }.text(), page, pwd)
} }
params["pg"] = page params["pg"] = page
paramCathe[foldUrl] = params paramCathe[foldUrl] = params

@ -24,6 +24,31 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout
android:id="@+id/ll_proxy"
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="@drawable/selector_common_bg"
android:orientation="vertical"
android:paddingLeft="20dp"
android:paddingTop="8dp"
android:paddingRight="20dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/proxy_setting"
android:textColor="@color/textSecondary"
android:textSize="@dimen/text_normal_size" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="5dp"
android:text="@string/proxy_setting_tip"
android:textColor="@color/textAssist" />
</LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/ll_webdav" android:id="@+id/ll_webdav"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -75,6 +100,7 @@
android:textColor="@color/textAssist" /> android:textColor="@color/textAssist" />
</LinearLayout> </LinearLayout>
<RelativeLayout <RelativeLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="25dp" android:layout_height="25dp"
@ -200,6 +226,7 @@
android:clickable="false" android:clickable="false"
android:longClickable="false" /> android:longClickable="false" />
</RelativeLayout> </RelativeLayout>
<RelativeLayout <RelativeLayout
android:id="@+id/rl_long_press" android:id="@+id/rl_long_press"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -226,6 +253,7 @@
android:clickable="false" android:clickable="false"
android:longClickable="false" /> android:longClickable="false" />
</RelativeLayout> </RelativeLayout>
<RelativeLayout <RelativeLayout
android:id="@+id/rl_content_replace" android:id="@+id/rl_content_replace"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -243,6 +271,7 @@
android:textSize="@dimen/text_normal_size" /> android:textSize="@dimen/text_normal_size" />
</RelativeLayout> </RelativeLayout>
<RelativeLayout <RelativeLayout
android:id="@+id/rl_read_aloud_volume_turn_page" android:id="@+id/rl_read_aloud_volume_turn_page"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -296,6 +325,7 @@
android:clickable="false" android:clickable="false"
android:longClickable="false" /> android:longClickable="false" />
</RelativeLayout> </RelativeLayout>
<RelativeLayout <RelativeLayout
android:id="@+id/rl_adapt_en_type" android:id="@+id/rl_adapt_en_type"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -403,10 +433,10 @@
android:id="@+id/tv_backup_path" android:id="@+id/tv_backup_path"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:paddingTop="5dp" android:paddingTop="5dp"
android:text="@string/backup_path" android:text="@string/backup_path"
android:maxLines="1"
android:ellipsize="end"
android:textColor="@color/textAssist" /> android:textColor="@color/textAssist" />
</LinearLayout> </LinearLayout>

@ -0,0 +1,203 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/rl_enable_proxy"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@drawable/selector_common_bg"
android:gravity="center"
android:paddingLeft="20dp"
android:paddingRight="20dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:text="@string/enable_proxy"
android:textColor="@color/textSecondary"
android:textSize="@dimen/text_normal_size" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/sc_enable_proxy"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:clickable="false"
android:longClickable="false" />
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="15dp" />
<LinearLayout
android:id="@+id/ll_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:visibility="gone">
<LinearLayout
android:id="@+id/ll_proxy_type"
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="@drawable/selector_common_bg"
android:orientation="vertical"
android:paddingLeft="20dp"
android:paddingTop="8dp"
android:paddingRight="20dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/proxy_type"
android:textColor="@color/textSecondary"
android:textSize="@dimen/text_normal_size" />
<TextView
android:id="@+id/tv_proxy_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="5dp"
android:textColor="@color/textAssist"
tools:text="socks5" />
</LinearLayout>
<LinearLayout
android:id="@+id/ll_proxy_host"
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="@drawable/selector_common_bg"
android:orientation="vertical"
android:paddingLeft="20dp"
android:paddingTop="8dp"
android:paddingRight="20dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/proxy_host"
android:textColor="@color/textSecondary"
android:textSize="@dimen/text_normal_size" />
<TextView
android:id="@+id/tv_proxy_host"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="5dp"
android:textColor="@color/textAssist"
tools:text="127.0.0.1" />
</LinearLayout>
<LinearLayout
android:id="@+id/ll_proxy_port"
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="@drawable/selector_common_bg"
android:orientation="vertical"
android:paddingLeft="20dp"
android:paddingTop="8dp"
android:paddingRight="20dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/proxy_port"
android:textColor="@color/textSecondary"
android:textSize="@dimen/text_normal_size" />
<TextView
android:id="@+id/tv_proxy_port"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="5dp"
android:textColor="@color/textAssist"
tools:text="1080" />
</LinearLayout>
<LinearLayout
android:id="@+id/ll_proxy_username"
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="@drawable/selector_common_bg"
android:orientation="vertical"
android:paddingLeft="20dp"
android:paddingTop="8dp"
android:paddingRight="20dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/proxy_username"
android:textColor="@color/textSecondary"
android:textSize="@dimen/text_normal_size" />
<TextView
android:id="@+id/tv_proxy_username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="5dp"
android:textColor="@color/textAssist"
tools:text="输入你的代理认证用户名" />
</LinearLayout>
<LinearLayout
android:id="@+id/ll_proxy_password"
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="@drawable/selector_common_bg"
android:orientation="vertical"
android:paddingLeft="20dp"
android:paddingTop="8dp"
android:paddingRight="20dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/proxy_password"
android:textColor="@color/textSecondary"
android:textSize="@dimen/text_normal_size" />
<TextView
android:id="@+id/tv_proxy_password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="5dp"
android:textColor="@color/textAssist"
tools:text="输入你的代理认证密码" />
</LinearLayout>
<LinearLayout
android:id="@+id/ll_no_proxy_sources"
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="@drawable/selector_common_bg"
android:orientation="vertical"
android:paddingLeft="20dp"
android:paddingTop="8dp"
android:paddingRight="20dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/no_proxy_sources"
android:textColor="@color/textSecondary"
android:textSize="@dimen/text_normal_size" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="5dp"
android:text="@string/no_proxy_sources_tip"
android:textColor="@color/textAssist" />
</LinearLayout>
</LinearLayout>
</LinearLayout>

@ -570,6 +570,16 @@
<string name="net_error_10003">数据解析失败</string> <string name="net_error_10003">数据解析失败</string>
<!--error string end--> <!--error string end-->
<string name="proxy_setting">代理设置</string>
<string name="proxy_setting_tip">设置软件及书源代理</string>
<string name="proxy_type">代理类型</string>
<string name="proxy_host">代理服务器地址</string>
<string name="proxy_port">代理服务器端口</string>
<string name="proxy_username">代理认证用户名</string>
<string name="proxy_password">代理认证密码</string>
<string name="no_proxy_sources">禁用代理的书源</string>
<string name="no_proxy_sources_tip">选择需要禁用代理的书源</string>
<string name="enable_proxy">启用代理</string>
<string-array name="reset_screen_time"> <string-array name="reset_screen_time">
<item>跟随系统</item> <item>跟随系统</item>

@ -17,4 +17,9 @@ org.gradle.jvmargs=-Xmx1536m
# org.gradle.parallel=true # org.gradle.parallel=true
android.useAndroidX=true android.useAndroidX=true
android.enableJetifier=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
Loading…
Cancel
Save