From 8296d4a5067fccf52f03cabd13f056e41a5576c1 Mon Sep 17 00:00:00 2001 From: fengyuecanzhu <1021300691@qq.com> Date: Sat, 15 May 2021 12:04:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=B9=A6=E6=BA=90=E7=BB=93?= =?UTF-8?q?=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../myreader/ExampleInstrumentedTest.java | 14 --- app/src/main/AndroidManifest.xml | 1 + .../entity/sourceedit/EditEntityUtil.kt | 2 + .../xyz/fycz/myreader/model/SearchEngine.java | 8 +- .../analyzeRule/AnalyzeByJSonPath.java | 2 +- .../analyzeRule/AnalyzeByJSoup.java | 2 +- .../analyzeRule/AnalyzeByRegex.java | 2 +- .../analyzeRule/AnalyzeByXPath.java | 2 +- .../analyzeRule/AnalyzeRule.java | 2 +- .../analyzeRule/AnalyzeUrl.java | 2 +- .../content/AnalyzeNextUrlTask.java | 4 +- .../content/BookChapterList.java | 12 +- .../content/BookContent.java | 6 +- .../{third => third2}/content/BookInfo.java | 4 +- .../{third => third2}/content/BookList.java | 6 +- .../ui/activity/BookDetailedActivity.java | 6 +- .../myreader/ui/activity/ReadActivity.java | 7 +- .../ui/activity/SourceEditActivity.java | 13 ++ .../ui/activity/SourceLoginActivity.java | 111 ++++++++++++++++++ .../myreader/ui/adapter/FontsAdapter.java | 4 +- .../myreader/ui/dialog/APPDownloadTip.java | 4 +- .../fycz/myreader/ui/dialog/UpdateDialog.java | 4 +- .../ui/fragment/DIYSourceFragment.java | 16 +++ .../ui/presenter/BookcasePresenter.java | 6 +- .../ui/presenter/CatalogPresenter.java | 4 +- .../fycz/myreader/util/help/JsExtensions.java | 2 +- .../xyz/fycz/myreader/util/utils/AdUtils.java | 6 +- .../fycz/myreader/util/utils/OkHttpUtils.java | 3 +- .../webapi/{CommonApi.java => BookApi.java} | 61 +--------- .../xyz/fycz/myreader/webapi/LanZousApi.java | 44 +++++++ .../fycz/myreader/webapi/ThirdSourceApi.java | 10 +- .../myreader/widget/page/NetPageLoader.java | 4 +- app/src/main/res/drawable/ic_check.xml | 2 +- .../main/res/layout/activity_source_login.xml | 19 +++ app/src/main/res/menu/menu_source_edit.xml | 5 + app/src/main/res/menu/menu_source_login.xml | 11 ++ app/src/main/res/values/strings.xml | 5 + 37 files changed, 284 insertions(+), 132 deletions(-) rename app/src/main/java/xyz/fycz/myreader/model/{third => third2}/analyzeRule/AnalyzeByJSonPath.java (99%) rename app/src/main/java/xyz/fycz/myreader/model/{third => third2}/analyzeRule/AnalyzeByJSoup.java (99%) rename app/src/main/java/xyz/fycz/myreader/model/{third => third2}/analyzeRule/AnalyzeByRegex.java (99%) rename app/src/main/java/xyz/fycz/myreader/model/{third => third2}/analyzeRule/AnalyzeByXPath.java (99%) rename app/src/main/java/xyz/fycz/myreader/model/{third => third2}/analyzeRule/AnalyzeRule.java (99%) rename app/src/main/java/xyz/fycz/myreader/model/{third => third2}/analyzeRule/AnalyzeUrl.java (99%) rename app/src/main/java/xyz/fycz/myreader/model/{third => third2}/content/AnalyzeNextUrlTask.java (95%) rename app/src/main/java/xyz/fycz/myreader/model/{third => third2}/content/BookChapterList.java (97%) rename app/src/main/java/xyz/fycz/myreader/model/{third => third2}/content/BookContent.java (97%) rename app/src/main/java/xyz/fycz/myreader/model/{third => third2}/content/BookInfo.java (96%) rename app/src/main/java/xyz/fycz/myreader/model/{third => third2}/content/BookList.java (98%) create mode 100644 app/src/main/java/xyz/fycz/myreader/ui/activity/SourceLoginActivity.java rename app/src/main/java/xyz/fycz/myreader/webapi/{CommonApi.java => BookApi.java} (70%) create mode 100644 app/src/main/res/layout/activity_source_login.xml create mode 100644 app/src/main/res/menu/menu_source_login.xml diff --git a/app/src/androidTest/java/xyz/fycz/myreader/ExampleInstrumentedTest.java b/app/src/androidTest/java/xyz/fycz/myreader/ExampleInstrumentedTest.java index 3544927..12dbf9b 100644 --- a/app/src/androidTest/java/xyz/fycz/myreader/ExampleInstrumentedTest.java +++ b/app/src/androidTest/java/xyz/fycz/myreader/ExampleInstrumentedTest.java @@ -1,28 +1,14 @@ package xyz.fycz.myreader; import android.content.Context; -import android.util.Log; import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.platform.app.InstrumentationRegistry; -import com.liulishuo.filedownloader.BaseDownloadTask; -import com.liulishuo.filedownloader.FileDownloadLargeFileListener; -import com.liulishuo.filedownloader.FileDownloader; - import org.junit.Test; import org.junit.runner.RunWith; -import java.io.File; -import java.util.List; - -import xyz.fycz.myreader.common.APPCONST; -import xyz.fycz.myreader.common.URLCONST; -import xyz.fycz.myreader.util.utils.GsonUtils; -import xyz.fycz.myreader.webapi.CommonApi; -import xyz.fycz.myreader.webapi.ResultCallback; - import static org.junit.Assert.assertEquals; /** diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index dc5f2eb..aecd0ff 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -135,6 +135,7 @@ + diff --git a/app/src/main/java/xyz/fycz/myreader/entity/sourceedit/EditEntityUtil.kt b/app/src/main/java/xyz/fycz/myreader/entity/sourceedit/EditEntityUtil.kt index bea6aea..bee5c97 100644 --- a/app/src/main/java/xyz/fycz/myreader/entity/sourceedit/EditEntityUtil.kt +++ b/app/src/main/java/xyz/fycz/myreader/entity/sourceedit/EditEntityUtil.kt @@ -17,6 +17,7 @@ object EditEntityUtil { add(EditEntity("sourceGroup", source?.sourceGroup, R.string.source_group, "不同分组以;/,隔开")) add(EditEntity("sourceCharset", source?.sourceCharset, R.string.source_charset, "默认UTF-8")) add(EditEntity("sourceHeaders", source?.sourceHeaders, R.string.source_headers, "json格式")) + add(EditEntity("loginUrl", source?.loginUrl, R.string.login_url)) add(EditEntity("sourceComment", source?.sourceComment, R.string.comment, "这是您留给使用者的说明")) } return sourceEntities @@ -106,6 +107,7 @@ object EditEntityUtil { "sourceGroup" -> source.sourceGroup = it.value "sourceCharset" -> source.sourceCharset = it.value "sourceHeaders" -> source.sourceHeaders = it.value + "loginUrl" -> source.loginUrl = it.value "sourceComment" -> source.sourceComment = it.value } } diff --git a/app/src/main/java/xyz/fycz/myreader/model/SearchEngine.java b/app/src/main/java/xyz/fycz/myreader/model/SearchEngine.java index 6f52800..eaed847 100644 --- a/app/src/main/java/xyz/fycz/myreader/model/SearchEngine.java +++ b/app/src/main/java/xyz/fycz/myreader/model/SearchEngine.java @@ -16,7 +16,7 @@ import xyz.fycz.myreader.greendao.entity.Chapter; import xyz.fycz.myreader.model.mulvalmap.ConMVMap; import xyz.fycz.myreader.util.SharedPreUtils; import xyz.fycz.myreader.util.ToastUtils; -import xyz.fycz.myreader.webapi.CommonApi; +import xyz.fycz.myreader.webapi.BookApi; import xyz.fycz.myreader.webapi.crawler.base.BookInfoCrawler; import xyz.fycz.myreader.webapi.crawler.base.ReadCrawler; @@ -135,7 +135,7 @@ public class SearchEngine { searchSiteIndex++; if (searchSiteIndex < mSourceList.size()) { ReadCrawler crawler = mSourceList.get(searchSiteIndex); - CommonApi.search(keyword, crawler) + BookApi.search(keyword, crawler) .subscribeOn(scheduler) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Observer>() { @@ -182,7 +182,7 @@ public class SearchEngine { if (searchSiteIndex < mSourceList.size()) { ReadCrawler crawler = mSourceList.get(searchSiteIndex); String searchKey = title; - CommonApi.search(searchKey, crawler) + BookApi.search(searchKey, crawler) .subscribeOn(scheduler) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Observer>() { @@ -229,7 +229,7 @@ public class SearchEngine { } public synchronized void getBookInfo(Book book, BookInfoCrawler bic, OnGetBookInfoListener listener){ - CommonApi.getBookInfo(book, bic) + BookApi.getBookInfo(book, bic) .subscribeOn(scheduler) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Observer() { diff --git a/app/src/main/java/xyz/fycz/myreader/model/third/analyzeRule/AnalyzeByJSonPath.java b/app/src/main/java/xyz/fycz/myreader/model/third2/analyzeRule/AnalyzeByJSonPath.java similarity index 99% rename from app/src/main/java/xyz/fycz/myreader/model/third/analyzeRule/AnalyzeByJSonPath.java rename to app/src/main/java/xyz/fycz/myreader/model/third2/analyzeRule/AnalyzeByJSonPath.java index 63b26ac..39ecab5 100644 --- a/app/src/main/java/xyz/fycz/myreader/model/third/analyzeRule/AnalyzeByJSonPath.java +++ b/app/src/main/java/xyz/fycz/myreader/model/third2/analyzeRule/AnalyzeByJSonPath.java @@ -1,4 +1,4 @@ -package xyz.fycz.myreader.model.third.analyzeRule; +package xyz.fycz.myreader.model.third2.analyzeRule; import android.text.TextUtils; diff --git a/app/src/main/java/xyz/fycz/myreader/model/third/analyzeRule/AnalyzeByJSoup.java b/app/src/main/java/xyz/fycz/myreader/model/third2/analyzeRule/AnalyzeByJSoup.java similarity index 99% rename from app/src/main/java/xyz/fycz/myreader/model/third/analyzeRule/AnalyzeByJSoup.java rename to app/src/main/java/xyz/fycz/myreader/model/third2/analyzeRule/AnalyzeByJSoup.java index c25c097..620eae2 100644 --- a/app/src/main/java/xyz/fycz/myreader/model/third/analyzeRule/AnalyzeByJSoup.java +++ b/app/src/main/java/xyz/fycz/myreader/model/third2/analyzeRule/AnalyzeByJSoup.java @@ -1,4 +1,4 @@ -package xyz.fycz.myreader.model.third.analyzeRule; +package xyz.fycz.myreader.model.third2.analyzeRule; import android.text.TextUtils; diff --git a/app/src/main/java/xyz/fycz/myreader/model/third/analyzeRule/AnalyzeByRegex.java b/app/src/main/java/xyz/fycz/myreader/model/third2/analyzeRule/AnalyzeByRegex.java similarity index 99% rename from app/src/main/java/xyz/fycz/myreader/model/third/analyzeRule/AnalyzeByRegex.java rename to app/src/main/java/xyz/fycz/myreader/model/third2/analyzeRule/AnalyzeByRegex.java index 4a69f88..5484626 100644 --- a/app/src/main/java/xyz/fycz/myreader/model/third/analyzeRule/AnalyzeByRegex.java +++ b/app/src/main/java/xyz/fycz/myreader/model/third2/analyzeRule/AnalyzeByRegex.java @@ -1,4 +1,4 @@ -package xyz.fycz.myreader.model.third.analyzeRule; +package xyz.fycz.myreader.model.third2.analyzeRule; import android.os.Build; import android.text.TextUtils; diff --git a/app/src/main/java/xyz/fycz/myreader/model/third/analyzeRule/AnalyzeByXPath.java b/app/src/main/java/xyz/fycz/myreader/model/third2/analyzeRule/AnalyzeByXPath.java similarity index 99% rename from app/src/main/java/xyz/fycz/myreader/model/third/analyzeRule/AnalyzeByXPath.java rename to app/src/main/java/xyz/fycz/myreader/model/third2/analyzeRule/AnalyzeByXPath.java index 9f97c66..f86dda4 100644 --- a/app/src/main/java/xyz/fycz/myreader/model/third/analyzeRule/AnalyzeByXPath.java +++ b/app/src/main/java/xyz/fycz/myreader/model/third2/analyzeRule/AnalyzeByXPath.java @@ -1,4 +1,4 @@ -package xyz.fycz.myreader.model.third.analyzeRule; +package xyz.fycz.myreader.model.third2.analyzeRule; import android.text.TextUtils; diff --git a/app/src/main/java/xyz/fycz/myreader/model/third/analyzeRule/AnalyzeRule.java b/app/src/main/java/xyz/fycz/myreader/model/third2/analyzeRule/AnalyzeRule.java similarity index 99% rename from app/src/main/java/xyz/fycz/myreader/model/third/analyzeRule/AnalyzeRule.java rename to app/src/main/java/xyz/fycz/myreader/model/third2/analyzeRule/AnalyzeRule.java index 9aa0d76..8add536 100644 --- a/app/src/main/java/xyz/fycz/myreader/model/third/analyzeRule/AnalyzeRule.java +++ b/app/src/main/java/xyz/fycz/myreader/model/third2/analyzeRule/AnalyzeRule.java @@ -1,4 +1,4 @@ -package xyz.fycz.myreader.model.third.analyzeRule; +package xyz.fycz.myreader.model.third2.analyzeRule; import android.annotation.SuppressLint; diff --git a/app/src/main/java/xyz/fycz/myreader/model/third/analyzeRule/AnalyzeUrl.java b/app/src/main/java/xyz/fycz/myreader/model/third2/analyzeRule/AnalyzeUrl.java similarity index 99% rename from app/src/main/java/xyz/fycz/myreader/model/third/analyzeRule/AnalyzeUrl.java rename to app/src/main/java/xyz/fycz/myreader/model/third2/analyzeRule/AnalyzeUrl.java index 760e4cf..c51b4b1 100644 --- a/app/src/main/java/xyz/fycz/myreader/model/third/analyzeRule/AnalyzeUrl.java +++ b/app/src/main/java/xyz/fycz/myreader/model/third2/analyzeRule/AnalyzeUrl.java @@ -1,4 +1,4 @@ -package xyz.fycz.myreader.model.third.analyzeRule; +package xyz.fycz.myreader.model.third2.analyzeRule; import android.annotation.SuppressLint; import android.text.TextUtils; diff --git a/app/src/main/java/xyz/fycz/myreader/model/third/content/AnalyzeNextUrlTask.java b/app/src/main/java/xyz/fycz/myreader/model/third2/content/AnalyzeNextUrlTask.java similarity index 95% rename from app/src/main/java/xyz/fycz/myreader/model/third/content/AnalyzeNextUrlTask.java rename to app/src/main/java/xyz/fycz/myreader/model/third2/content/AnalyzeNextUrlTask.java index 047c24c..ef87498 100644 --- a/app/src/main/java/xyz/fycz/myreader/model/third/content/AnalyzeNextUrlTask.java +++ b/app/src/main/java/xyz/fycz/myreader/model/third2/content/AnalyzeNextUrlTask.java @@ -1,4 +1,4 @@ -package xyz.fycz.myreader.model.third.content; +package xyz.fycz.myreader.model.third2.content; import java.util.List; import java.util.Map; @@ -9,7 +9,7 @@ import xyz.fycz.myreader.base.observer.MyObserver; import xyz.fycz.myreader.entity.WebChapterBean; import xyz.fycz.myreader.greendao.entity.Book; import xyz.fycz.myreader.greendao.entity.Chapter; -import xyz.fycz.myreader.model.third.analyzeRule.AnalyzeUrl; +import xyz.fycz.myreader.model.third2.analyzeRule.AnalyzeUrl; import xyz.fycz.myreader.util.utils.OkHttpUtils; public class AnalyzeNextUrlTask { diff --git a/app/src/main/java/xyz/fycz/myreader/model/third/content/BookChapterList.java b/app/src/main/java/xyz/fycz/myreader/model/third2/content/BookChapterList.java similarity index 97% rename from app/src/main/java/xyz/fycz/myreader/model/third/content/BookChapterList.java rename to app/src/main/java/xyz/fycz/myreader/model/third2/content/BookChapterList.java index 2f39a08..5b3a4aa 100644 --- a/app/src/main/java/xyz/fycz/myreader/model/third/content/BookChapterList.java +++ b/app/src/main/java/xyz/fycz/myreader/model/third2/content/BookChapterList.java @@ -1,4 +1,4 @@ -package xyz.fycz.myreader.model.third.content; +package xyz.fycz.myreader.model.third2.content; import android.os.Build; import android.text.TextUtils; @@ -25,9 +25,9 @@ import xyz.fycz.myreader.greendao.entity.Book; import xyz.fycz.myreader.greendao.entity.Chapter; import xyz.fycz.myreader.greendao.entity.rule.BookSource; import xyz.fycz.myreader.greendao.entity.rule.TocRule; -import xyz.fycz.myreader.model.third.analyzeRule.AnalyzeByRegex; -import xyz.fycz.myreader.model.third.analyzeRule.AnalyzeRule; -import xyz.fycz.myreader.model.third.analyzeRule.AnalyzeUrl; +import xyz.fycz.myreader.model.third2.analyzeRule.AnalyzeByRegex; +import xyz.fycz.myreader.model.third2.analyzeRule.AnalyzeRule; +import xyz.fycz.myreader.model.third2.analyzeRule.AnalyzeUrl; import xyz.fycz.myreader.util.utils.OkHttpUtils; public class BookChapterList { @@ -53,8 +53,8 @@ public class BookChapterList { e.onError(new Throwable("目录获取失败" + book.getChapterUrl())); return; } else { - Log.d(tag, "┌成功获取目录页" + analyzeNextUrl); - Log.d(tag, "└" + book.getChapterUrl() + analyzeNextUrl); + Log.d(tag, "┌成功获取目录页"); + Log.d(tag, "└" + book.getChapterUrl()); } book.setTag(tag); AnalyzeRule analyzer = new AnalyzeRule(book); diff --git a/app/src/main/java/xyz/fycz/myreader/model/third/content/BookContent.java b/app/src/main/java/xyz/fycz/myreader/model/third2/content/BookContent.java similarity index 97% rename from app/src/main/java/xyz/fycz/myreader/model/third/content/BookContent.java rename to app/src/main/java/xyz/fycz/myreader/model/third2/content/BookContent.java index c889bd6..1942c8b 100644 --- a/app/src/main/java/xyz/fycz/myreader/model/third/content/BookContent.java +++ b/app/src/main/java/xyz/fycz/myreader/model/third2/content/BookContent.java @@ -1,4 +1,4 @@ -package xyz.fycz.myreader.model.third.content; +package xyz.fycz.myreader.model.third2.content; import android.text.TextUtils; import android.util.Log; @@ -17,8 +17,8 @@ import xyz.fycz.myreader.greendao.entity.Chapter; import xyz.fycz.myreader.greendao.entity.rule.BookSource; import xyz.fycz.myreader.greendao.entity.rule.ContentRule; import xyz.fycz.myreader.greendao.gen.ChapterDao; -import xyz.fycz.myreader.model.third.analyzeRule.AnalyzeRule; -import xyz.fycz.myreader.model.third.analyzeRule.AnalyzeUrl; +import xyz.fycz.myreader.model.third2.analyzeRule.AnalyzeRule; +import xyz.fycz.myreader.model.third2.analyzeRule.AnalyzeUrl; import xyz.fycz.myreader.util.utils.NetworkUtils; import xyz.fycz.myreader.util.utils.OkHttpUtils; import xyz.fycz.myreader.util.utils.StringUtils; diff --git a/app/src/main/java/xyz/fycz/myreader/model/third/content/BookInfo.java b/app/src/main/java/xyz/fycz/myreader/model/third2/content/BookInfo.java similarity index 96% rename from app/src/main/java/xyz/fycz/myreader/model/third/content/BookInfo.java rename to app/src/main/java/xyz/fycz/myreader/model/third2/content/BookInfo.java index 083f258..4a033c5 100644 --- a/app/src/main/java/xyz/fycz/myreader/model/third/content/BookInfo.java +++ b/app/src/main/java/xyz/fycz/myreader/model/third2/content/BookInfo.java @@ -1,4 +1,4 @@ -package xyz.fycz.myreader.model.third.content; +package xyz.fycz.myreader.model.third2.content; import android.text.TextUtils; import android.util.Log; @@ -8,7 +8,7 @@ import io.reactivex.Observable; import xyz.fycz.myreader.greendao.entity.Book; import xyz.fycz.myreader.greendao.entity.rule.BookSource; import xyz.fycz.myreader.greendao.entity.rule.InfoRule; -import xyz.fycz.myreader.model.third.analyzeRule.AnalyzeRule; +import xyz.fycz.myreader.model.third2.analyzeRule.AnalyzeRule; import xyz.fycz.myreader.util.utils.StringUtils; import static android.text.TextUtils.isEmpty; diff --git a/app/src/main/java/xyz/fycz/myreader/model/third/content/BookList.java b/app/src/main/java/xyz/fycz/myreader/model/third2/content/BookList.java similarity index 98% rename from app/src/main/java/xyz/fycz/myreader/model/third/content/BookList.java rename to app/src/main/java/xyz/fycz/myreader/model/third2/content/BookList.java index 77cd464..ca81311 100644 --- a/app/src/main/java/xyz/fycz/myreader/model/third/content/BookList.java +++ b/app/src/main/java/xyz/fycz/myreader/model/third2/content/BookList.java @@ -1,4 +1,4 @@ -package xyz.fycz.myreader.model.third.content; +package xyz.fycz.myreader.model.third2.content; import android.os.Build; import android.text.TextUtils; @@ -20,8 +20,8 @@ import xyz.fycz.myreader.greendao.entity.rule.BookSource; import xyz.fycz.myreader.greendao.entity.rule.FindRule; import xyz.fycz.myreader.greendao.entity.rule.InfoRule; import xyz.fycz.myreader.greendao.entity.rule.SearchRule; -import xyz.fycz.myreader.model.third.analyzeRule.AnalyzeByRegex; -import xyz.fycz.myreader.model.third.analyzeRule.AnalyzeRule; +import xyz.fycz.myreader.model.third2.analyzeRule.AnalyzeByRegex; +import xyz.fycz.myreader.model.third2.analyzeRule.AnalyzeRule; import xyz.fycz.myreader.util.utils.NetworkUtils; import xyz.fycz.myreader.util.utils.StringUtils; diff --git a/app/src/main/java/xyz/fycz/myreader/ui/activity/BookDetailedActivity.java b/app/src/main/java/xyz/fycz/myreader/ui/activity/BookDetailedActivity.java index 7b0fff5..4c9c0be 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/activity/BookDetailedActivity.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/activity/BookDetailedActivity.java @@ -77,7 +77,7 @@ import xyz.fycz.myreader.util.utils.GsonExtensionsKt; import xyz.fycz.myreader.util.utils.NetworkUtils; import xyz.fycz.myreader.util.utils.RxUtils; import xyz.fycz.myreader.util.utils.StringUtils; -import xyz.fycz.myreader.webapi.CommonApi; +import xyz.fycz.myreader.webapi.BookApi; import xyz.fycz.myreader.webapi.crawler.ReadCrawlerUtil; import xyz.fycz.myreader.webapi.crawler.base.BookInfoCrawler; import xyz.fycz.myreader.webapi.crawler.base.ReadCrawler; @@ -413,7 +413,7 @@ public class BookDetailedActivity extends BaseActivity { if ((rc instanceof BookInfoCrawler && StringHelper.isEmpty(mBook.getImgUrl())) || (thirdSource && !isCollected)) { binding.pbLoading.setVisibility(View.VISIBLE); BookInfoCrawler bic = (BookInfoCrawler) rc; - CommonApi.getBookInfo(mBook, bic).compose(RxUtils::toSimpleSingle).subscribe(new MyObserver() { + BookApi.getBookInfo(mBook, bic).compose(RxUtils::toSimpleSingle).subscribe(new MyObserver() { @Override public void onNext(@NotNull Book book) { if (!App.isDestroy(BookDetailedActivity.this)) { @@ -476,7 +476,7 @@ public class BookDetailedActivity extends BaseActivity { mChapters = mChapterService.findBookAllChapterByBookId(mBook.getId()); } if (chaptersDis != null) chaptersDis.dispose(); - CommonApi.getBookChapters(mBook, mReadCrawler) + BookApi.getBookChapters(mBook, mReadCrawler) .flatMap((Function, ObservableSource>) chapters -> saveChapters(chapters, isChangeSource)).compose(RxUtils::toSimpleSingle) .subscribe(new MyObserver() { @Override diff --git a/app/src/main/java/xyz/fycz/myreader/ui/activity/ReadActivity.java b/app/src/main/java/xyz/fycz/myreader/ui/activity/ReadActivity.java index 7f9d440..62ecf91 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/activity/ReadActivity.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/activity/ReadActivity.java @@ -47,7 +47,6 @@ import java.util.List; import java.util.Locale; import io.reactivex.Observable; -import io.reactivex.internal.schedulers.ExecutorScheduler; import io.reactivex.schedulers.Schedulers; import xyz.fycz.myreader.ActivityManage; import xyz.fycz.myreader.R; @@ -97,7 +96,7 @@ import xyz.fycz.myreader.util.utils.RxUtils; import xyz.fycz.myreader.util.utils.ScreenUtils; import xyz.fycz.myreader.util.utils.StringUtils; import xyz.fycz.myreader.util.utils.SystemBarUtils; -import xyz.fycz.myreader.webapi.CommonApi; +import xyz.fycz.myreader.webapi.BookApi; import xyz.fycz.myreader.webapi.ResultCallback; import xyz.fycz.myreader.webapi.crawler.ReadCrawlerUtil; import xyz.fycz.myreader.webapi.crawler.base.ReadCrawler; @@ -1008,7 +1007,7 @@ public class ReadActivity extends BaseActivity implements ColorPickerDialogListe }); } else { mPageLoader.setmStatus(PageLoader.STATUS_LOADING_CHAPTER); - CommonApi.getBookChapters(mBook, mReadCrawler).flatMap(chapters -> Observable.create(emitter -> { + BookApi.getBookChapters(mBook, mReadCrawler).flatMap(chapters -> Observable.create(emitter -> { updateAllOldChapterData(chapters); initChapters(); emitter.onNext(chapters); @@ -1585,7 +1584,7 @@ public class ReadActivity extends BaseActivity implements ColorPickerDialogListe if (StringHelper.isEmpty(chapter.getBookId())) { chapter.setId(mBook.getId()); } - CommonApi.getChapterContent(chapter, mBook, mReadCrawler) + BookApi.getChapterContent(chapter, mBook, mReadCrawler) .subscribeOn(Schedulers.from(App.getApplication().getmFixedThreadPool())) .subscribe(new MyObserver() { @Override diff --git a/app/src/main/java/xyz/fycz/myreader/ui/activity/SourceEditActivity.java b/app/src/main/java/xyz/fycz/myreader/ui/activity/SourceEditActivity.java index d0365a5..c5d79d7 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/activity/SourceEditActivity.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/activity/SourceEditActivity.java @@ -24,6 +24,7 @@ import xyz.fycz.myreader.databinding.ActivitySourceEditBinding; import xyz.fycz.myreader.entity.sourcedebug.DebugEntity; import xyz.fycz.myreader.entity.sourceedit.EditEntity; import xyz.fycz.myreader.entity.sourceedit.EditEntityUtil; +import xyz.fycz.myreader.greendao.DbManager; import xyz.fycz.myreader.greendao.entity.rule.BookSource; import xyz.fycz.myreader.model.sourceAnalyzer.BookSourceManager; import xyz.fycz.myreader.ui.adapter.SourceEditAdapter; @@ -187,6 +188,18 @@ public class SourceEditActivity extends BaseActivity { debug(item.getTitle(), DebugEntity.TOC); } else if (item.getItemId() == R.id.action_debug_content) { debug(item.getTitle(), DebugEntity.CONTENT); + } else if (item.getItemId() == R.id.action_login) { + BookSource source = getSource(); + if (!StringHelper.isEmpty(source.getLoginUrl())) { + Intent intent = new Intent(this, SourceLoginActivity.class); + intent.putExtra(APPCONST.BOOK_SOURCE, source); + startActivity(intent); + } else { + ToastUtils.showWarring("当前书源没有配置登录地址"); + } + } else if (item.getItemId() == R.id.action_clear_cookie) { + DbManager.getDaoSession().getCookieBeanDao().deleteByKey(getSource().getSourceUrl()); + ToastUtils.showSuccess("Cookie清除成功"); } return super.onOptionsItemSelected(item); } diff --git a/app/src/main/java/xyz/fycz/myreader/ui/activity/SourceLoginActivity.java b/app/src/main/java/xyz/fycz/myreader/ui/activity/SourceLoginActivity.java new file mode 100644 index 0000000..98e02f9 --- /dev/null +++ b/app/src/main/java/xyz/fycz/myreader/ui/activity/SourceLoginActivity.java @@ -0,0 +1,111 @@ +package xyz.fycz.myreader.ui.activity; + +import android.graphics.Bitmap; +import android.os.Bundle; +import android.view.Menu; +import android.view.MenuItem; +import android.webkit.CookieManager; +import android.webkit.WebSettings; +import android.webkit.WebView; +import android.webkit.WebViewClient; + +import androidx.appcompat.widget.Toolbar; + +import xyz.fycz.myreader.R; +import xyz.fycz.myreader.base.BaseActivity; +import xyz.fycz.myreader.common.APPCONST; +import xyz.fycz.myreader.databinding.ActivitySourceLoginBinding; +import xyz.fycz.myreader.greendao.DbManager; +import xyz.fycz.myreader.greendao.entity.CookieBean; +import xyz.fycz.myreader.greendao.entity.rule.BookSource; +import xyz.fycz.myreader.util.ToastUtils; + +/** + * @author fengyue + * @date 2021/5/15 10:43 + */ +public class SourceLoginActivity extends BaseActivity { + private ActivitySourceLoginBinding binding; + private BookSource bookSource; + private boolean checking = false; + + @Override + protected void bindView() { + binding = ActivitySourceLoginBinding.inflate(getLayoutInflater()); + setContentView(binding.getRoot()); + } + + @Override + protected void onDestroy() { + super.onDestroy(); + binding.webView.destroy(); + } + + @Override + protected void setUpToolbar(Toolbar toolbar) { + super.setUpToolbar(toolbar); + setStatusBarColor(R.color.colorPrimary, true); + getSupportActionBar().setTitle(getString(R.string.text_login)); + } + + @Override + protected void initData(Bundle savedInstanceState) { + super.initData(savedInstanceState); + bookSource = getIntent().getParcelableExtra(APPCONST.BOOK_SOURCE); + } + + @Override + protected void initWidget() { + WebSettings settings = binding.webView.getSettings(); + settings.setSupportZoom(true); + settings.setBuiltInZoomControls(true); + settings.setDefaultTextEncodingName("UTF-8"); + settings.setJavaScriptEnabled(true); + CookieManager cookieManager = CookieManager.getInstance(); + binding.webView.setWebViewClient(new WebViewClient() { + @Override + public void onPageStarted(WebView view, String url, Bitmap favicon) { + String cookie = cookieManager.getCookie(url); + DbManager.getDaoSession().getCookieBeanDao().insertOrReplace(new CookieBean(bookSource.getLoginUrl(), cookie)); + super.onPageStarted(view, url, favicon); + } + + @Override + public void onPageFinished(WebView view, String url) { + String cookie = cookieManager.getCookie(url); + DbManager.getDaoSession().getCookieBeanDao().insertOrReplace(new CookieBean(bookSource.getLoginUrl(), cookie)); + if (checking) + finish(); + else + ToastUtils.showInfo(getString(R.string.click_check_after_success)); + super.onPageFinished(view, url); + } + }); + binding.webView.loadUrl(bookSource.getLoginUrl()); + } + + // 添加菜单 + @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.menu_source_login, menu); + return true; + } + + //菜单 + @Override + public boolean onOptionsItemSelected(MenuItem item) { + int id = item.getItemId(); + switch (id) { + case R.id.action_check: + if (checking) break; + checking = true; + ToastUtils.showInfo(getString(R.string.check_host_cookie)); + binding.webView.loadUrl(bookSource.getLoginUrl()); + break; + case android.R.id.home: + finish(); + break; + } + return super.onOptionsItemSelected(item); + } +} diff --git a/app/src/main/java/xyz/fycz/myreader/ui/adapter/FontsAdapter.java b/app/src/main/java/xyz/fycz/myreader/ui/adapter/FontsAdapter.java index 7e76ad8..a84775f 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/adapter/FontsAdapter.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/adapter/FontsAdapter.java @@ -29,6 +29,7 @@ import java.util.ArrayList; import xyz.fycz.myreader.R; import xyz.fycz.myreader.application.App; import xyz.fycz.myreader.application.SysManager; +import xyz.fycz.myreader.webapi.LanZousApi; import xyz.fycz.myreader.webapi.ResultCallback; import xyz.fycz.myreader.common.APPCONST; import xyz.fycz.myreader.common.URLCONST; @@ -39,7 +40,6 @@ import xyz.fycz.myreader.util.IOUtils; import xyz.fycz.myreader.util.ToastUtils; import xyz.fycz.myreader.util.utils.FileUtils; import xyz.fycz.myreader.util.utils.NetworkUtils; -import xyz.fycz.myreader.webapi.CommonApi; import xyz.fycz.myreader.widget.ProgressButton; @@ -208,7 +208,7 @@ public class FontsAdapter extends ArrayAdapter { } final String[] url = {URLCONST.FONT_DOWNLOAD_URL + font.toString() + ".ttf"}; viewHolder.btnFontUse.setText("获取连接..."); - CommonApi.getUrl(font.downloadPath, new ResultCallback() { + LanZousApi.getUrl(font.downloadPath, new ResultCallback() { @Override public void onFinish(Object o, int code) { String downloadUrl = (String) o; diff --git a/app/src/main/java/xyz/fycz/myreader/ui/dialog/APPDownloadTip.java b/app/src/main/java/xyz/fycz/myreader/ui/dialog/APPDownloadTip.java index 41fa5c1..5a10028 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/dialog/APPDownloadTip.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/dialog/APPDownloadTip.java @@ -10,6 +10,7 @@ import android.view.View; import androidx.appcompat.app.AppCompatActivity; import xyz.fycz.myreader.application.App; +import xyz.fycz.myreader.webapi.LanZousApi; import xyz.fycz.myreader.webapi.ResultCallback; import xyz.fycz.myreader.common.APPCONST; import xyz.fycz.myreader.ui.activity.MainActivity; @@ -17,7 +18,6 @@ import xyz.fycz.myreader.ui.fragment.BookcaseFragment; import xyz.fycz.myreader.util.IOUtils; import xyz.fycz.myreader.util.ToastUtils; import xyz.fycz.myreader.util.utils.FileUtils; -import xyz.fycz.myreader.webapi.CommonApi; import java.io.File; import java.io.FileOutputStream; @@ -74,7 +74,7 @@ public class APPDownloadTip { mBookcaseFragment.getRlDownloadTip().setVisibility(View.VISIBLE); mBookcaseFragment.getPbDownload().setProgress(0); mBookcaseFragment.getTvDownloadTip().setText("正在获取下载链接..."); - CommonApi.getUrl(url, new ResultCallback() { + LanZousApi.getUrl(url, new ResultCallback() { @Override public void onFinish(Object o, int code) { final String downloadUrl = (String) o; diff --git a/app/src/main/java/xyz/fycz/myreader/ui/dialog/UpdateDialog.java b/app/src/main/java/xyz/fycz/myreader/ui/dialog/UpdateDialog.java index a6246de..85955a6 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/dialog/UpdateDialog.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/dialog/UpdateDialog.java @@ -40,7 +40,7 @@ import xyz.fycz.myreader.R; import xyz.fycz.myreader.application.App; import xyz.fycz.myreader.databinding.FragmentUpdateBinding; import xyz.fycz.myreader.util.ToastUtils; -import xyz.fycz.myreader.webapi.CommonApi; +import xyz.fycz.myreader.webapi.LanZousApi; import xyz.fycz.myreader.webapi.ResultCallback; @@ -368,7 +368,7 @@ public class UpdateDialog extends Fragment { private void downloadWithLanzous(String apkUrl) { binding.tvProgress.setText("正在获取下载链接..."); binding.barPercentView.setPercentage(0); - CommonApi.getUrl(apkUrl, new ResultCallback() { + LanZousApi.getUrl(apkUrl, new ResultCallback() { @Override public void onFinish(Object o, int code) { String downloadUrl = (String) o; diff --git a/app/src/main/java/xyz/fycz/myreader/ui/fragment/DIYSourceFragment.java b/app/src/main/java/xyz/fycz/myreader/ui/fragment/DIYSourceFragment.java index 10b0ed9..2268172 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/fragment/DIYSourceFragment.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/fragment/DIYSourceFragment.java @@ -24,6 +24,7 @@ import io.reactivex.Observable; import io.reactivex.Single; import io.reactivex.SingleOnSubscribe; import io.reactivex.annotations.NonNull; +import io.reactivex.disposables.Disposable; import xyz.fycz.myreader.R; import xyz.fycz.myreader.base.BaseFragment; import xyz.fycz.myreader.base.observer.MyObserver; @@ -39,6 +40,7 @@ import xyz.fycz.myreader.ui.activity.SourceEditActivity; import xyz.fycz.myreader.ui.adapter.BookSourceAdapter; import xyz.fycz.myreader.ui.adapter.helper.ItemTouchCallback; import xyz.fycz.myreader.ui.dialog.DialogCreator; +import xyz.fycz.myreader.ui.dialog.LoadingDialog; import xyz.fycz.myreader.ui.dialog.MyAlertDialog; import xyz.fycz.myreader.util.ShareUtils; import xyz.fycz.myreader.util.ToastUtils; @@ -66,6 +68,7 @@ public class DIYSourceFragment extends BaseFragment { private boolean isSearch; private PopupMenu featuresMenu; private ItemTouchCallback itemTouchCallback; + private Disposable importSourceDis; public DIYSourceFragment() { sourceActivity = (BookSourceActivity) getActivity(); @@ -178,9 +181,20 @@ public class DIYSourceFragment extends BaseFragment { } public void importDataS(String text) { + LoadingDialog dialog = new LoadingDialog(getContext(), "正在导入", () -> { + if (importSourceDis != null) { + importSourceDis.dispose(); + } + }); + dialog.show(); Observable> observable = BookSourceManager.importSource(text); if (observable != null) { observable.subscribe(new MyObserver>() { + @Override + public void onSubscribe(Disposable d) { + importSourceDis = d; + } + @Override public void onNext(List sources) { int size = sources.size(); @@ -190,11 +204,13 @@ public class DIYSourceFragment extends BaseFragment { } else { ToastUtils.showError("格式不对"); } + dialog.dismiss(); } @Override public void onError(Throwable e) { ToastUtils.showError("格式不对"); + dialog.dismiss(); } }); } else { diff --git a/app/src/main/java/xyz/fycz/myreader/ui/presenter/BookcasePresenter.java b/app/src/main/java/xyz/fycz/myreader/ui/presenter/BookcasePresenter.java index 3e5f279..6e3c185 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/presenter/BookcasePresenter.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/presenter/BookcasePresenter.java @@ -61,7 +61,7 @@ import xyz.fycz.myreader.ui.fragment.BookcaseFragment; import xyz.fycz.myreader.util.*; import xyz.fycz.myreader.util.notification.NotificationUtil; import xyz.fycz.myreader.util.utils.NetworkUtils; -import xyz.fycz.myreader.webapi.CommonApi; +import xyz.fycz.myreader.webapi.BookApi; import static xyz.fycz.myreader.application.App.checkVersionByServer; @@ -406,7 +406,7 @@ public class BookcasePresenter implements BasePresenter { Thread update = new Thread(() -> { final ArrayList mChapters = (ArrayList) mChapterService.findBookAllChapterByBookId(book.getId()); final ReadCrawler mReadCrawler = ReadCrawlerUtil.getReadCrawler(book.getSource()); - CommonApi.getBookChapters(book, mReadCrawler).flatMap(chapters -> Observable.create(emitter -> { + BookApi.getBookChapters(book, mReadCrawler).flatMap(chapters -> Observable.create(emitter -> { int noReadNum = chapters.size() - book.getChapterTotalNum(); book.setNoReadNum(Math.max(noReadNum, 0)); book.setNewestChapterTitle(chapters.get(chapters.size() - 1).getTitle()); @@ -780,7 +780,7 @@ public class BookcasePresenter implements BasePresenter { chapter.setBookId(book.getId()); } ReadCrawler mReadCrawler = ReadCrawlerUtil.getReadCrawler(book.getSource()); - CommonApi.getChapterContent(chapter, book, mReadCrawler).flatMap(s -> Observable.create(emitter -> { + BookApi.getChapterContent(chapter, book, mReadCrawler).flatMap(s -> Observable.create(emitter -> { downloadingChapter = chapter.getTitle(); mChapterService.saveOrUpdateChapter(chapter, s); successCathe++; diff --git a/app/src/main/java/xyz/fycz/myreader/ui/presenter/CatalogPresenter.java b/app/src/main/java/xyz/fycz/myreader/ui/presenter/CatalogPresenter.java index bff16c0..6f72916 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/presenter/CatalogPresenter.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/presenter/CatalogPresenter.java @@ -20,7 +20,7 @@ import xyz.fycz.myreader.greendao.entity.Chapter; import xyz.fycz.myreader.greendao.service.ChapterService; import xyz.fycz.myreader.ui.adapter.ChapterTitleAdapter; import xyz.fycz.myreader.ui.fragment.CatalogFragment; -import xyz.fycz.myreader.webapi.CommonApi; +import xyz.fycz.myreader.webapi.BookApi; import java.util.ArrayList; import java.util.Collections; @@ -67,7 +67,7 @@ public class CatalogPresenter implements BasePresenter { return; } mCatalogFragment.getPbLoading().setVisibility(View.VISIBLE); - CommonApi.getBookChapters(mBook, ReadCrawlerUtil.getReadCrawler(mBook.getSource())) + BookApi.getBookChapters(mBook, ReadCrawlerUtil.getReadCrawler(mBook.getSource())) .compose(RxUtils::toSimpleSingle).subscribe(new MyObserver>() { @Override public void onNext(@NotNull List chapters) { diff --git a/app/src/main/java/xyz/fycz/myreader/util/help/JsExtensions.java b/app/src/main/java/xyz/fycz/myreader/util/help/JsExtensions.java index ed43a48..88317be 100644 --- a/app/src/main/java/xyz/fycz/myreader/util/help/JsExtensions.java +++ b/app/src/main/java/xyz/fycz/myreader/util/help/JsExtensions.java @@ -9,7 +9,7 @@ import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; -import xyz.fycz.myreader.model.third.analyzeRule.AnalyzeUrl; +import xyz.fycz.myreader.model.third2.analyzeRule.AnalyzeUrl; import xyz.fycz.myreader.util.utils.OkHttpUtils; import xyz.fycz.myreader.util.utils.StringUtils; diff --git a/app/src/main/java/xyz/fycz/myreader/util/utils/AdUtils.java b/app/src/main/java/xyz/fycz/myreader/util/utils/AdUtils.java index 456713e..427b4f8 100644 --- a/app/src/main/java/xyz/fycz/myreader/util/utils/AdUtils.java +++ b/app/src/main/java/xyz/fycz/myreader/util/utils/AdUtils.java @@ -123,9 +123,9 @@ public class AdUtils { public static void initAd() { if (!hasInitAd) { hasInitAd = true; - DdSdkHelper.init("1234", "216", "51716a16fbdf50905704b6575b1b3b60", - "142364", "35ce0efe5f3cc960b116db227498e238", - "8167", "85bd159309c3da1b", + DdSdkHelper.init("", "", "", + "", "", + "", "", App.getApplication(), App.isDebug()); } } 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 a7bed32..94cd892 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 @@ -21,8 +21,7 @@ import xyz.fycz.myreader.application.App; import xyz.fycz.myreader.entity.StrResponse; import xyz.fycz.myreader.greendao.DbManager; import xyz.fycz.myreader.greendao.entity.CookieBean; -import xyz.fycz.myreader.greendao.entity.rule.BookSource; -import xyz.fycz.myreader.model.third.analyzeRule.AnalyzeUrl; +import xyz.fycz.myreader.model.third2.analyzeRule.AnalyzeUrl; import java.io.IOException; import java.io.InputStream; diff --git a/app/src/main/java/xyz/fycz/myreader/webapi/CommonApi.java b/app/src/main/java/xyz/fycz/myreader/webapi/BookApi.java similarity index 70% rename from app/src/main/java/xyz/fycz/myreader/webapi/CommonApi.java rename to app/src/main/java/xyz/fycz/myreader/webapi/BookApi.java index 1dec9fd..6ddb06b 100644 --- a/app/src/main/java/xyz/fycz/myreader/webapi/CommonApi.java +++ b/app/src/main/java/xyz/fycz/myreader/webapi/BookApi.java @@ -3,24 +3,14 @@ package xyz.fycz.myreader.webapi; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.List; -import java.util.regex.Matcher; import io.reactivex.Observable; -import io.reactivex.ObservableOnSubscribe; -import io.reactivex.ObservableSource; -import io.reactivex.functions.Function; import okhttp3.MediaType; import okhttp3.RequestBody; import xyz.fycz.myreader.entity.SearchBookBean; import xyz.fycz.myreader.greendao.entity.Book; import xyz.fycz.myreader.greendao.entity.Chapter; -import xyz.fycz.myreader.greendao.entity.rule.BookSource; import xyz.fycz.myreader.model.mulvalmap.ConMVMap; -import xyz.fycz.myreader.model.third.analyzeRule.AnalyzeUrl; -import xyz.fycz.myreader.model.third.content.BookChapterList; -import xyz.fycz.myreader.model.third.content.BookContent; -import xyz.fycz.myreader.model.third.content.BookInfo; -import xyz.fycz.myreader.model.third.content.BookList; import xyz.fycz.myreader.util.utils.NetworkUtils; import xyz.fycz.myreader.util.utils.OkHttpUtils; import xyz.fycz.myreader.webapi.crawler.base.BookInfoCrawler; @@ -28,10 +18,8 @@ import xyz.fycz.myreader.webapi.crawler.base.ReadCrawler; import xyz.fycz.myreader.webapi.crawler.read.TianLaiReadCrawler; import xyz.fycz.myreader.webapi.crawler.source.ThirdCrawler; -import static xyz.fycz.myreader.common.APPCONST.JS_PATTERN; - -public class CommonApi { +public class BookApi { /** * 获取章节列表 @@ -143,51 +131,4 @@ public class CommonApi { emitter.onComplete(); }); } - - - - /** - * 通过api获取蓝奏云可下载直链 - * - * @param lanZouUrl - * @param callback - */ - public static void getUrl(final String lanZouUrl, final ResultCallback callback) { - LanZousApi.getUrl1(lanZouUrl, new ResultCallback() { - @Override - public void onFinish(final Object o, int code) { - LanZousApi.getKey((String) o, new ResultCallback() { - final String referer = (String) o; - - @Override - public void onFinish(Object o, int code) { - LanZousApi.getUrl2((String) o, new ResultCallback() { - @Override - public void onFinish(Object o, int code) { - LanZousApi.getRedirectUrl((String) o, callback); - } - - @Override - public void onError(Exception e) { - callback.onError(e); - } - }, referer); - } - - @Override - public void onError(Exception e) { - callback.onError(e); - } - }); - } - - @Override - public void onError(Exception e) { - callback.onError(e); - } - }); - - } - - } diff --git a/app/src/main/java/xyz/fycz/myreader/webapi/LanZousApi.java b/app/src/main/java/xyz/fycz/myreader/webapi/LanZousApi.java index ec473ff..2dc685c 100644 --- a/app/src/main/java/xyz/fycz/myreader/webapi/LanZousApi.java +++ b/app/src/main/java/xyz/fycz/myreader/webapi/LanZousApi.java @@ -26,6 +26,50 @@ import xyz.fycz.myreader.util.utils.RxUtils; */ public class LanZousApi { + /** + * 通过api获取蓝奏云可下载直链 + * + * @param lanZouUrl + * @param callback + */ + public static void getUrl(final String lanZouUrl, final ResultCallback callback) { + LanZousApi.getUrl1(lanZouUrl, new ResultCallback() { + @Override + public void onFinish(final Object o, int code) { + LanZousApi.getKey((String) o, new ResultCallback() { + final String referer = (String) o; + + @Override + public void onFinish(Object o, int code) { + LanZousApi.getUrl2((String) o, new ResultCallback() { + @Override + public void onFinish(Object o, int code) { + LanZousApi.getRedirectUrl((String) o, callback); + } + + @Override + public void onError(Exception e) { + callback.onError(e); + } + }, referer); + } + + @Override + public void onError(Exception e) { + callback.onError(e); + } + }); + } + + @Override + public void onError(Exception e) { + callback.onError(e); + } + }); + + } + + /** * 获取蓝奏云含有key的url * diff --git a/app/src/main/java/xyz/fycz/myreader/webapi/ThirdSourceApi.java b/app/src/main/java/xyz/fycz/myreader/webapi/ThirdSourceApi.java index 84b8a07..491b854 100644 --- a/app/src/main/java/xyz/fycz/myreader/webapi/ThirdSourceApi.java +++ b/app/src/main/java/xyz/fycz/myreader/webapi/ThirdSourceApi.java @@ -16,11 +16,11 @@ import xyz.fycz.myreader.greendao.entity.Chapter; import xyz.fycz.myreader.greendao.entity.CookieBean; import xyz.fycz.myreader.greendao.entity.rule.BookSource; import xyz.fycz.myreader.model.mulvalmap.ConMVMap; -import xyz.fycz.myreader.model.third.analyzeRule.AnalyzeUrl; -import xyz.fycz.myreader.model.third.content.BookChapterList; -import xyz.fycz.myreader.model.third.content.BookContent; -import xyz.fycz.myreader.model.third.content.BookInfo; -import xyz.fycz.myreader.model.third.content.BookList; +import xyz.fycz.myreader.model.third2.analyzeRule.AnalyzeUrl; +import xyz.fycz.myreader.model.third2.content.BookChapterList; +import xyz.fycz.myreader.model.third2.content.BookContent; +import xyz.fycz.myreader.model.third2.content.BookInfo; +import xyz.fycz.myreader.model.third2.content.BookList; import xyz.fycz.myreader.util.utils.OkHttpUtils; import xyz.fycz.myreader.webapi.crawler.source.ThirdCrawler; diff --git a/app/src/main/java/xyz/fycz/myreader/widget/page/NetPageLoader.java b/app/src/main/java/xyz/fycz/myreader/widget/page/NetPageLoader.java index 400ae04..8440270 100644 --- a/app/src/main/java/xyz/fycz/myreader/widget/page/NetPageLoader.java +++ b/app/src/main/java/xyz/fycz/myreader/widget/page/NetPageLoader.java @@ -22,7 +22,7 @@ import xyz.fycz.myreader.greendao.service.ChapterService; import xyz.fycz.myreader.util.StringHelper; import xyz.fycz.myreader.util.utils.FileUtils; import xyz.fycz.myreader.util.utils.RxUtils; -import xyz.fycz.myreader.webapi.CommonApi; +import xyz.fycz.myreader.webapi.BookApi; import xyz.fycz.myreader.webapi.crawler.base.ReadCrawler; public class NetPageLoader extends PageLoader { @@ -226,7 +226,7 @@ public class NetPageLoader extends PageLoader { * @param chapter */ public void getChapterContent(Chapter chapter) { - CommonApi.getChapterContent(chapter, mCollBook, mReadCrawler).flatMap(s -> Observable.create(emitter -> { + BookApi.getChapterContent(chapter, mCollBook, mReadCrawler).flatMap(s -> Observable.create(emitter -> { loadingChapters.remove(chapter); String content = StringHelper.isEmpty(s) ? "章节内容为空" : s; mChapterService.saveOrUpdateChapter(chapter, content); diff --git a/app/src/main/res/drawable/ic_check.xml b/app/src/main/res/drawable/ic_check.xml index 620bc91..4f4262b 100644 --- a/app/src/main/res/drawable/ic_check.xml +++ b/app/src/main/res/drawable/ic_check.xml @@ -4,6 +4,6 @@ android:viewportWidth="24.0" android:viewportHeight="24.0"> diff --git a/app/src/main/res/layout/activity_source_login.xml b/app/src/main/res/layout/activity_source_login.xml new file mode 100644 index 0000000..f3d443a --- /dev/null +++ b/app/src/main/res/layout/activity_source_login.xml @@ -0,0 +1,19 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/menu/menu_source_edit.xml b/app/src/main/res/menu/menu_source_edit.xml index 8b333cd..af64189 100644 --- a/app/src/main/res/menu/menu_source_edit.xml +++ b/app/src/main/res/menu/menu_source_edit.xml @@ -33,4 +33,9 @@ android:title="@string/text_login" app:showAsAction="never" /> + + \ No newline at end of file diff --git a/app/src/main/res/menu/menu_source_login.xml b/app/src/main/res/menu/menu_source_login.xml new file mode 100644 index 0000000..6885270 --- /dev/null +++ b/app/src/main/res/menu/menu_source_login.xml @@ -0,0 +1,11 @@ + + + + + + \ 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 26485c5..9c01dc6 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -482,6 +482,11 @@ 跳过 | %ds 插屏广告 插屏视频 + 登录成功后请点击右上角图标进行首页访问测试 + 成功 + 正在打开首页,成功自动返回主界面 + 清除Cookie + 跟随系统