From b79fef6f6594d8bd4ede38f244b8b8ff05571de7 Mon Sep 17 00:00:00 2001 From: Invinciblelee <1760316362@qq.com> Date: Thu, 23 May 2019 18:30:29 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../monkeybook/help/ReadBookControl.java | 13 +++++++ .../model/analyzeRule/AnalyzeUrl.java | 2 +- .../analyzeRule/BaseAnalyzerPresenter.java | 4 +-- .../monke/monkeybook/model/content/Debug.java | 4 +-- .../presenter/ReadBookPresenterImpl.java | 20 +++++------ .../com/monke/monkeybook/utils/URLUtils.java | 34 ++++++------------- .../view/activity/ReadBookActivity.java | 1 - .../view/fragment/BookmarkListFragment.java | 2 +- 8 files changed, 40 insertions(+), 40 deletions(-) diff --git a/app/src/main/java/com/monke/monkeybook/help/ReadBookControl.java b/app/src/main/java/com/monke/monkeybook/help/ReadBookControl.java index 920bb50..d337783 100644 --- a/app/src/main/java/com/monke/monkeybook/help/ReadBookControl.java +++ b/app/src/main/java/com/monke/monkeybook/help/ReadBookControl.java @@ -49,6 +49,7 @@ public class ReadBookControl { private Boolean canKeyTurn; private Boolean readAloudCanKeyTurn; private int clickSensitivity; + private Boolean showTitle; private Boolean clickAllNext; private Boolean showTimeBattery; private String lastNoteUrl; @@ -183,6 +184,7 @@ private ReadBookControl() { this.paddingBottom = readPreference.getInt("paddingBottom", 0); this.pageMode = readPreference.getInt("pageMode", 0); this.spaceModeIndex = readPreference.getInt("spaceModeIndex", 3); + this.showTitle = readPreference.getBoolean("showTitle", true); initPageConfiguration(); } @@ -766,6 +768,17 @@ public boolean getLightIsFollowSys() { return readPreference.getBoolean("isfollowsys", true); } + public void setShowTitle(boolean showTitle){ + this.showTitle = showTitle; + SharedPreferences.Editor editor = readPreference.edit(); + editor.putBoolean("showTitle", showTitle); + editor.apply(); + } + + public boolean getShowTitle(){ + return showTitle; + } + @NonNull private Integer getConfigValue(int index, String key) { Map configMap = textDrawables.get(index); diff --git a/app/src/main/java/com/monke/monkeybook/model/analyzeRule/AnalyzeUrl.java b/app/src/main/java/com/monke/monkeybook/model/analyzeRule/AnalyzeUrl.java index 468c169..9df6e45 100644 --- a/app/src/main/java/com/monke/monkeybook/model/analyzeRule/AnalyzeUrl.java +++ b/app/src/main/java/com/monke/monkeybook/model/analyzeRule/AnalyzeUrl.java @@ -245,7 +245,7 @@ private byte[] generatePostData() { } private void generateUrlPath(String ruleUrl) { - url = URLUtils.getAbsoluteURL(baseUrl, ruleUrl); + url = URLUtils.getAbsUrl(baseUrl, ruleUrl); host = StringUtils.getBaseUrl(url); urlPath = url.substring(host.length()); } diff --git a/app/src/main/java/com/monke/monkeybook/model/analyzeRule/BaseAnalyzerPresenter.java b/app/src/main/java/com/monke/monkeybook/model/analyzeRule/BaseAnalyzerPresenter.java index d27b213..729d547 100644 --- a/app/src/main/java/com/monke/monkeybook/model/analyzeRule/BaseAnalyzerPresenter.java +++ b/app/src/main/java/com/monke/monkeybook/model/analyzeRule/BaseAnalyzerPresenter.java @@ -127,7 +127,7 @@ final void processRawUrls(@NonNull List result, @NonNull RulePattern rul ListIterator iterator = result.listIterator(); while (iterator.hasNext()) { - iterator.set(URLUtils.getAbsoluteURL(getBaseURL(), iterator.next())); + iterator.set(URLUtils.getAbsUrl(getBaseURL(), iterator.next())); } } @@ -161,7 +161,7 @@ final String processResultUrl(@NonNull String result, @NonNull RulePattern ruleP final String processRawUrl(@NonNull String result, @NonNull RulePattern rulePattern) { result = matchRegex(result, rulePattern); - result = URLUtils.getAbsoluteURL(getBaseURL(), result); + result = URLUtils.getAbsUrl(getBaseURL(), result); return result; } diff --git a/app/src/main/java/com/monke/monkeybook/model/content/Debug.java b/app/src/main/java/com/monke/monkeybook/model/content/Debug.java index 1fbef11..d336c7a 100644 --- a/app/src/main/java/com/monke/monkeybook/model/content/Debug.java +++ b/app/src/main/java/com/monke/monkeybook/model/content/Debug.java @@ -185,7 +185,7 @@ public void onNext(BookShelfBean bookShelfBean) { printLog("●成功获取目录列表» 共" + size + "个章节"); ChapterBean chapterBean = bookShelfBean.getChapter(0); printLog("●章节名称» " + chapterBean.getDurChapterName()); - printLog("●章节网址» " + URLUtils.getAbsoluteURL(bookShelfBean.getBookInfoBean().getChapterListUrl(), chapterBean.getDurChapterUrl())); + printLog("●章节网址» " + URLUtils.getAbsUrl(bookShelfBean.getBookInfoBean().getChapterListUrl(), chapterBean.getDurChapterUrl())); printLog(String.format("★%s 目录结束", getDoTime())); bookContentDebug(bookShelfBean.getBookInfoBean(), chapterBean); } else { @@ -230,7 +230,7 @@ public void onSubscribe(Disposable d) { @Override public void onNext(BookContentBean bookContentBean) { - printLog("●成功获取正文页» " + URLUtils.getAbsoluteURL(bookInfoBean.getChapterListUrl(), bookContentBean.getDurChapterUrl())); + printLog("●成功获取正文页» " + URLUtils.getAbsUrl(bookInfoBean.getChapterListUrl(), bookContentBean.getDurChapterUrl())); final String content = bookContentBean.getDurChapterContent(); if (content != null && content.length() > 3000) { printLog("●章节内容» " + content.substring(0, 3000) + "\u00B7\u00B7\u00B7"); diff --git a/app/src/main/java/com/monke/monkeybook/presenter/ReadBookPresenterImpl.java b/app/src/main/java/com/monke/monkeybook/presenter/ReadBookPresenterImpl.java index af4aa46..14dd3da 100644 --- a/app/src/main/java/com/monke/monkeybook/presenter/ReadBookPresenterImpl.java +++ b/app/src/main/java/com/monke/monkeybook/presenter/ReadBookPresenterImpl.java @@ -265,18 +265,18 @@ public void onError(Throwable e) { @Override public void saveBookmark(BookmarkBean bookmarkBean) { - Observable.create((ObservableOnSubscribe) e -> { + Observable.create((ObservableOnSubscribe) e -> { BookshelfHelp.saveBookmark(bookmarkBean); bookShelf.setBookmarkList(BookshelfHelp.queryBookmarkList(bookmarkBean.getBookName())); - e.onNext(bookmarkBean); + e.onNext(bookShelf); e.onComplete(); }) .subscribeOn(Schedulers.single()) .observeOn(AndroidSchedulers.mainThread()) - .subscribe(new SimpleObserver() { + .subscribe(new SimpleObserver() { @Override - public void onNext(BookmarkBean bookmarkBean) { - mView.updateBookmark(bookShelf); + public void onNext(BookShelfBean bookShelfBean) { + mView.updateBookmark(bookShelfBean); } @Override @@ -288,18 +288,18 @@ public void onError(Throwable e) { @Override public void delBookmark(BookmarkBean bookmarkBean) { - Observable.create((ObservableOnSubscribe) e -> { + Observable.create((ObservableOnSubscribe) e -> { BookshelfHelp.delBookmark(bookmarkBean); bookShelf.setBookmarkList(BookshelfHelp.queryBookmarkList(bookmarkBean.getBookName())); - e.onNext(bookmarkBean); + e.onNext(bookShelf); e.onComplete(); }) .subscribeOn(Schedulers.single()) .observeOn(AndroidSchedulers.mainThread()) - .subscribe(new SimpleObserver() { + .subscribe(new SimpleObserver() { @Override - public void onNext(BookmarkBean bookmarkBean) { - mView.updateBookmark(bookShelf); + public void onNext(BookShelfBean bookShelfBean) { + mView.updateBookmark(bookShelfBean); } @Override diff --git a/app/src/main/java/com/monke/monkeybook/utils/URLUtils.java b/app/src/main/java/com/monke/monkeybook/utils/URLUtils.java index def808a..978367d 100644 --- a/app/src/main/java/com/monke/monkeybook/utils/URLUtils.java +++ b/app/src/main/java/com/monke/monkeybook/utils/URLUtils.java @@ -1,7 +1,5 @@ package com.monke.monkeybook.utils; -import org.jsoup.helper.StringUtil; - import java.net.MalformedURLException; import java.net.URL; @@ -13,42 +11,32 @@ private URLUtils() { /** * 获取绝对地址 */ - public static String getAbsoluteURL(String baseUrl, String relPath) { + public static String getAbsUrl(String baseUrl, String relPath) { try { - String header = null; + final String header; int index = indexOfHeader(relPath); - if (index >= 0) { - header = relPath.substring(0, index + 1); - relPath = relPath.substring(index + 1); - } + header = index == -1 ? "" : relPath.substring(0, index + 1); + relPath = relPath.substring(index + 1); + index = indexOfHeader(baseUrl); - if (index >= 0) { - baseUrl = baseUrl.substring(index + 1); - } + baseUrl = index == -1 ? baseUrl : baseUrl.substring(index + 1); - relPath = resolve(baseUrl, relPath); + relPath = header + resolve(baseUrl, relPath); - if (header != null) { - relPath = header + relPath; - } } catch (Exception ignore) { } return relPath; } private static int indexOfHeader(String url) { - if (StringUtils.startWithIgnoreCase(url, "@header:")) { - return url.indexOf("}"); - } - return -1; + return url.indexOf("}"); } - public static String resolve(String baseUrl, String relPath){ + public static String resolve(String baseUrl, String relPath) { try { - URL absoluteUrl = new URL(baseUrl); - URL parseUrl = new URL(absoluteUrl, relPath); + URL parseUrl = new URL(new URL(baseUrl), relPath); return parseUrl.toString(); - }catch (MalformedURLException ignore) { + } catch (MalformedURLException ignore) { } return relPath; } diff --git a/app/src/main/java/com/monke/monkeybook/view/activity/ReadBookActivity.java b/app/src/main/java/com/monke/monkeybook/view/activity/ReadBookActivity.java index e2d2bcc..b0e9939 100644 --- a/app/src/main/java/com/monke/monkeybook/view/activity/ReadBookActivity.java +++ b/app/src/main/java/com/monke/monkeybook/view/activity/ReadBookActivity.java @@ -1201,7 +1201,6 @@ public void delBookmark(BookmarkBean bookmarkBean) { public void openBookmark(BookmarkBean bookmarkBean) { closeDrawer(); drawerLayout.postDelayed(() -> mPageLoader.skipToChapter(bookmarkBean.getChapterIndex(), bookmarkBean.getPageIndex()), DELAY_MIDDLE); - } }); } diff --git a/app/src/main/java/com/monke/monkeybook/view/fragment/BookmarkListFragment.java b/app/src/main/java/com/monke/monkeybook/view/fragment/BookmarkListFragment.java index 57646ed..a9f5b06 100644 --- a/app/src/main/java/com/monke/monkeybook/view/fragment/BookmarkListFragment.java +++ b/app/src/main/java/com/monke/monkeybook/view/fragment/BookmarkListFragment.java @@ -50,6 +50,6 @@ public void itemLongClick(BookmarkBean bookmarkBean) { @Override public void updateBookShelf(BookShelfBean bookShelfBean) { - getAdapter().setDataList(bookShelfBean.getBookmarkList()); + getAdapter().setDataList(bookShelfBean.getBookmarkList()); } } From 0d4b1c943ba79b40eb4c97b17af9165c412f285e Mon Sep 17 00:00:00 2001 From: Invinciblelee <1760316362@qq.com> Date: Sat, 25 May 2019 11:17:39 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../monke/monkeybook/bean/BookmarkBean.java | 16 +++++++++++ .../monkeybook/bean/DownloadBookBean.java | 5 ++-- .../presenter/ReadBookPresenterImpl.java | 2 -- .../monkeybook/service/DownloadService.java | 21 +++++++++++++-- .../view/activity/ReadBookActivity.java | 5 +++- .../view/fragment/dialog/BookmarkDialog.java | 6 ++--- .../fragment/dialog/ChangeSourceDialog.java | 4 ++- .../view/fragment/dialog/DownLoadDialog.java | 2 +- .../view/fragment/dialog/LargeTextDialog.java | 5 +++- .../view/popupwindow/MoreSettingPop.java | 12 +++++++++ .../widget/page/ChapterProvider.java | 3 ++- .../res/layout/dialog_download_choice.xml | 8 +++--- app/src/main/res/layout/pop_more_setting.xml | 27 +++++++++++++++++++ app/src/main/res/values/strings.xml | 1 + .../monke/basemvplib/BasePresenterImpl.java | 2 +- 15 files changed, 100 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/com/monke/monkeybook/bean/BookmarkBean.java b/app/src/main/java/com/monke/monkeybook/bean/BookmarkBean.java index bca70f2..94e0260 100644 --- a/app/src/main/java/com/monke/monkeybook/bean/BookmarkBean.java +++ b/app/src/main/java/com/monke/monkeybook/bean/BookmarkBean.java @@ -3,6 +3,8 @@ import android.os.Parcel; import android.os.Parcelable; +import androidx.annotation.NonNull; + import org.greenrobot.greendao.annotation.Entity; import org.greenrobot.greendao.annotation.Generated; import org.greenrobot.greendao.annotation.Id; @@ -148,4 +150,18 @@ public void setPageIndex(Integer pageIndex) { public String[] getFilters() { return new String[]{chapterName, content}; } + + @NonNull + @Override + public String toString() { + return "BookmarkBean{" + + "id=" + id + + ", noteUrl='" + noteUrl + '\'' + + ", bookName='" + bookName + '\'' + + ", chapterName='" + chapterName + '\'' + + ", chapterIndex=" + chapterIndex + + ", pageIndex=" + pageIndex + + ", content='" + content + '\'' + + '}'; + } } diff --git a/app/src/main/java/com/monke/monkeybook/bean/DownloadBookBean.java b/app/src/main/java/com/monke/monkeybook/bean/DownloadBookBean.java index c7f5029..46a1cf8 100644 --- a/app/src/main/java/com/monke/monkeybook/bean/DownloadBookBean.java +++ b/app/src/main/java/com/monke/monkeybook/bean/DownloadBookBean.java @@ -32,6 +32,7 @@ public DownloadBookBean(String name, String author, String tag, String noteUrl, this.end = end; } + protected DownloadBookBean(Parcel in) { name = in.readString(); author = in.readString(); @@ -147,12 +148,12 @@ public int getSuccessCount() { return successCount; } - public int getWaitingCount(){ + public int getWaitingCount() { return this.downloadCount - this.successCount; } public synchronized void successCountAdd() { - if(this.successCount < this.downloadCount) { + if (this.successCount < this.downloadCount) { this.successCount += 1; } } diff --git a/app/src/main/java/com/monke/monkeybook/presenter/ReadBookPresenterImpl.java b/app/src/main/java/com/monke/monkeybook/presenter/ReadBookPresenterImpl.java index 14dd3da..1734bf7 100644 --- a/app/src/main/java/com/monke/monkeybook/presenter/ReadBookPresenterImpl.java +++ b/app/src/main/java/com/monke/monkeybook/presenter/ReadBookPresenterImpl.java @@ -281,7 +281,6 @@ public void onNext(BookShelfBean bookShelfBean) { @Override public void onError(Throwable e) { - } }); } @@ -304,7 +303,6 @@ public void onNext(BookShelfBean bookShelfBean) { @Override public void onError(Throwable e) { - } }); } diff --git a/app/src/main/java/com/monke/monkeybook/service/DownloadService.java b/app/src/main/java/com/monke/monkeybook/service/DownloadService.java index 913bc73..f26a6f9 100644 --- a/app/src/main/java/com/monke/monkeybook/service/DownloadService.java +++ b/app/src/main/java/com/monke/monkeybook/service/DownloadService.java @@ -86,8 +86,11 @@ public int onStartCommand(Intent intent, int flags, int startId) { } break; case removeDownloadAction: - int id = intent.getIntExtra("taskId", -1); - removeDownload(id); + if (intent.hasExtra("noteUrl")) { + removeDownload(intent.getStringExtra("noteUrl")); + } else { + removeDownload(intent.getIntExtra("taskId", -1)); + } break; case cancelAction: cancelDownload(); @@ -187,6 +190,20 @@ private void removeDownload(int id) { } } + private void removeDownload(String noteUrl) { + if (noteUrl == null) { + return; + } + + for (int i = downloadTasks.size() - 1; i >= 0; i--) { + IDownloadTask downloadTask = downloadTasks.valueAt(i); + if (noteUrl.equals(downloadTask.getDownloadBook().getNoteUrl())) { + downloadTask.stopDownload(); + break; + } + } + } + private void refreshDownloadList() { ArrayList downloadBookBeans = new ArrayList<>(); for (int i = downloadTasks.size() - 1; i >= 0; i--) { diff --git a/app/src/main/java/com/monke/monkeybook/view/activity/ReadBookActivity.java b/app/src/main/java/com/monke/monkeybook/view/activity/ReadBookActivity.java index b0e9939..2d733e0 100644 --- a/app/src/main/java/com/monke/monkeybook/view/activity/ReadBookActivity.java +++ b/app/src/main/java/com/monke/monkeybook/view/activity/ReadBookActivity.java @@ -54,6 +54,7 @@ import com.monke.monkeybook.service.ReadAloudService; import com.monke.monkeybook.utils.StringUtils; import com.monke.monkeybook.utils.SystemUtil; +import com.monke.monkeybook.utils.URLUtils; import com.monke.monkeybook.view.fragment.ChapterDrawerFragment; import com.monke.monkeybook.view.fragment.dialog.AlertDialog; import com.monke.monkeybook.view.fragment.dialog.BookmarkDialog; @@ -75,6 +76,7 @@ import com.monke.monkeybook.widget.page.PageView; import com.monke.monkeybook.widget.theme.AppCompat; +import java.net.URL; import java.util.List; import butterknife.BindView; @@ -480,7 +482,8 @@ private void showHideUrlViews() { atvLayout.setVisibility(View.GONE); } else { int chapterIndex = mPresenter.getBookShelf().getDurChapter(); - atvUrl.setText(mPresenter.getBookShelf().getChapter(chapterIndex).getDurChapterUrl()); + atvUrl.setText(URLUtils.getAbsUrl(mPresenter.getBookShelf().getBookInfoBean().getChapterListUrl(), + mPresenter.getBookShelf().getChapter(chapterIndex).getDurChapterUrl())); atvSourceName.setText(mPresenter.getBookShelf().getBookInfoBean().getOrigin()); if (TextUtils.isEmpty(atvUrl.getText())) { atvDivider.setVisibility(View.GONE); diff --git a/app/src/main/java/com/monke/monkeybook/view/fragment/dialog/BookmarkDialog.java b/app/src/main/java/com/monke/monkeybook/view/fragment/dialog/BookmarkDialog.java index 48ef30f..2997a34 100644 --- a/app/src/main/java/com/monke/monkeybook/view/fragment/dialog/BookmarkDialog.java +++ b/app/src/main/java/com/monke/monkeybook/view/fragment/dialog/BookmarkDialog.java @@ -72,7 +72,7 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat dismissAllowingStateLoss(); bookmarkBean.setContent(StringUtils.valueOf(tvContent.getText())); if(bookmarkClick != null) { - bookmarkClick.openBookmark(bookmarkBean); + bookmarkClick.saveBookmark(bookmarkBean); } }); @@ -81,14 +81,14 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat dismissAllowingStateLoss(); bookmarkBean.setContent(StringUtils.valueOf(tvContent.getText())); if(bookmarkClick != null) { - bookmarkClick.openBookmark(bookmarkBean); + bookmarkClick.saveBookmark(bookmarkBean); } }); View tvDel = findViewById(R.id.tv_del); tvDel.setOnClickListener(v -> { dismissAllowingStateLoss(); if(bookmarkClick != null) { - bookmarkClick.openBookmark(bookmarkBean); + bookmarkClick.delBookmark(bookmarkBean); } }); diff --git a/app/src/main/java/com/monke/monkeybook/view/fragment/dialog/ChangeSourceDialog.java b/app/src/main/java/com/monke/monkeybook/view/fragment/dialog/ChangeSourceDialog.java index a1d99f5..852efe5 100644 --- a/app/src/main/java/com/monke/monkeybook/view/fragment/dialog/ChangeSourceDialog.java +++ b/app/src/main/java/com/monke/monkeybook/view/fragment/dialog/ChangeSourceDialog.java @@ -29,6 +29,7 @@ import com.monke.monkeybook.model.SearchBookModel; import com.monke.monkeybook.utils.ListUtils; import com.monke.monkeybook.utils.NetworkUtil; +import com.monke.monkeybook.utils.ScreenUtils; import com.monke.monkeybook.utils.ToastUtils; import com.monke.monkeybook.view.adapter.ChangeSourceAdapter; import com.monke.monkeybook.widget.refreshview.RefreshRecyclerView; @@ -135,7 +136,8 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat @Override protected void onDialogAttachWindow(@NonNull Window window) { window.setGravity(Gravity.CENTER); - window.setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT); + int height = getResources().getDisplayMetrics().heightPixels - ScreenUtils.getStatusBarHeight(); + window.setLayout(WindowManager.LayoutParams.MATCH_PARENT, height); } @Override diff --git a/app/src/main/java/com/monke/monkeybook/view/fragment/dialog/DownLoadDialog.java b/app/src/main/java/com/monke/monkeybook/view/fragment/dialog/DownLoadDialog.java index 08f01b5..50364a1 100644 --- a/app/src/main/java/com/monke/monkeybook/view/fragment/dialog/DownLoadDialog.java +++ b/app/src/main/java/com/monke/monkeybook/view/fragment/dialog/DownLoadDialog.java @@ -61,7 +61,7 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat TextView tvDownload = findViewById(R.id.tv_download); edtStart.setText(String.valueOf(start + 1)); - edtEnd.setText(String.valueOf(total - 1)); + edtEnd.setText(String.valueOf(total)); edtStart.addTextChangedListener(new TextWatcher() { @Override diff --git a/app/src/main/java/com/monke/monkeybook/view/fragment/dialog/LargeTextDialog.java b/app/src/main/java/com/monke/monkeybook/view/fragment/dialog/LargeTextDialog.java index ac985fa..77cfffb 100644 --- a/app/src/main/java/com/monke/monkeybook/view/fragment/dialog/LargeTextDialog.java +++ b/app/src/main/java/com/monke/monkeybook/view/fragment/dialog/LargeTextDialog.java @@ -14,7 +14,9 @@ import androidx.fragment.app.FragmentManager; import com.monke.monkeybook.R; +import com.monke.monkeybook.utils.DensityUtil; import com.monke.monkeybook.utils.MarkdownUtils; +import com.monke.monkeybook.utils.ScreenUtils; import io.reactivex.schedulers.Schedulers; @@ -58,6 +60,7 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat @Override protected void onDialogAttachWindow(@NonNull Window window) { window.setGravity(Gravity.CENTER); - window.setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT); + int height = getResources().getDisplayMetrics().heightPixels - ScreenUtils.getStatusBarHeight(); + window.setLayout(WindowManager.LayoutParams.MATCH_PARENT, height); } } diff --git a/app/src/main/java/com/monke/monkeybook/view/popupwindow/MoreSettingPop.java b/app/src/main/java/com/monke/monkeybook/view/popupwindow/MoreSettingPop.java index 6e1ca66..bc82f9d 100644 --- a/app/src/main/java/com/monke/monkeybook/view/popupwindow/MoreSettingPop.java +++ b/app/src/main/java/com/monke/monkeybook/view/popupwindow/MoreSettingPop.java @@ -60,6 +60,10 @@ public class MoreSettingPop extends PopupWindow { View llswReadAloudKey; @BindView(R.id.sw_read_aloud_key) Switch swReadAloudKey; + @BindView(R.id.ll_sb_showTitle) + View llswShowTitle; + @BindView(R.id.sb_showTitle) + Switch swShowTitle; @BindView(R.id.ll_sb_showBatteryNumber) View llswShowBatteryNumber; @BindView(R.id.sb_showBatteryNumber) @@ -184,6 +188,13 @@ private void bindEvent() { .create(); dialog.show(); }); + + llswShowTitle.setOnClickListener(view -> { + boolean isChecked = swShowTitle.isChecked(); + swShowTitle.setChecked(!isChecked); + readBookControl.setShowTitle(!isChecked); + changeProListener.refresh(); + }); } private void initData() { @@ -198,6 +209,7 @@ private void initData() { sbImmersionBar.setChecked(readBookControl.getImmersionStatusBar()); swShowBatteryNumber.setChecked(readBookControl.getShowBatteryNumber()); swShowDividerLine.setChecked(readBookControl.getShowBottomLine()); + swShowTitle.setChecked(readBookControl.getShowTitle()); upView(); } diff --git a/app/src/main/java/com/monke/monkeybook/widget/page/ChapterProvider.java b/app/src/main/java/com/monke/monkeybook/widget/page/ChapterProvider.java index da75605..d062fb8 100644 --- a/app/src/main/java/com/monke/monkeybook/widget/page/ChapterProvider.java +++ b/app/src/main/java/com/monke/monkeybook/widget/page/ChapterProvider.java @@ -12,6 +12,7 @@ import com.monke.monkeybook.bean.BookShelfBean; import com.monke.monkeybook.bean.ChapterBean; import com.monke.monkeybook.help.ChapterContentHelp; +import com.monke.monkeybook.help.ReadBookControl; import com.monke.monkeybook.help.RxBusTag; import com.monke.monkeybook.model.WebBookModel; import com.monke.monkeybook.utils.IOUtils; @@ -84,7 +85,7 @@ private TxtChapter loadChapter(ChapterBean chapter, BufferedReader br) { int rHeight = mPageLoader.getVisibleHeight(); int titleLinesCount = 0; try { - boolean showTitle = true; // 是否展示标题 + boolean showTitle = ReadBookControl.getInstance().getShowTitle(); // 是否展示标题 String paragraph = chapter.getDurChapterName() + "\n"; //默认展示标题 if (collBook.isLocalBook()) { br.readLine(); diff --git a/app/src/main/res/layout/dialog_download_choice.xml b/app/src/main/res/layout/dialog_download_choice.xml index f345fda..2b0421a 100644 --- a/app/src/main/res/layout/dialog_download_choice.xml +++ b/app/src/main/res/layout/dialog_download_choice.xml @@ -49,13 +49,13 @@ + + + + + + + + 书源同步 无最新章节信息 显示时间和电量 + 显示正文标题 显示电量数字 显示分隔线 深色状态栏图标 diff --git a/basemvplib/src/main/java/com/monke/basemvplib/BasePresenterImpl.java b/basemvplib/src/main/java/com/monke/basemvplib/BasePresenterImpl.java index db7c96c..7dcbccb 100644 --- a/basemvplib/src/main/java/com/monke/basemvplib/BasePresenterImpl.java +++ b/basemvplib/src/main/java/com/monke/basemvplib/BasePresenterImpl.java @@ -8,7 +8,7 @@ public abstract class BasePresenterImpl implements IPresenter { protected T mView; - @SuppressWarnings(value="unchecked") + @SuppressWarnings(value = "unchecked") @Override public void attachView(@NonNull IView iView) { mView = (T) iView; From 3c6782286db531f4e3fbd4a204451327ba2273f6 Mon Sep 17 00:00:00 2001 From: Invinciblelee <1760316362@qq.com> Date: Sat, 25 May 2019 17:30:17 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E6=B7=B7=E5=90=88=E8=A7=84=E5=88=99?= =?UTF-8?q?=E4=BD=BF=E7=94=A8##=E6=AD=A3=E5=88=99##=E6=9B=BF=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../monke/monkeybook/model/analyzeRule/RulePattern.java | 9 ++++++--- app/src/main/res/layout/item_bookshelf_list.xml | 3 ++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/monke/monkeybook/model/analyzeRule/RulePattern.java b/app/src/main/java/com/monke/monkeybook/model/analyzeRule/RulePattern.java index 504c5a3..0cd0f7a 100644 --- a/app/src/main/java/com/monke/monkeybook/model/analyzeRule/RulePattern.java +++ b/app/src/main/java/com/monke/monkeybook/model/analyzeRule/RulePattern.java @@ -33,19 +33,22 @@ final class RulePattern { private RulePattern(@NonNull String rawRule, @Nullable VariableStore variableStore, @Nullable RuleMode ruleMode) { elementsRule = new Rule(); + final boolean regexTrait; if (ruleMode == null) { Rule rule = RootRule.fromStringRule(rawRule); elementsRule.setMode(rule.getMode()); rawRule = rule.getRule(); + regexTrait = true; } else { + regexTrait = false; elementsRule.setMode(ruleMode); } - initRulePattern(rawRule, variableStore, elementsRule.getMode()); + initRulePattern(rawRule, variableStore, elementsRule.getMode(), regexTrait); } - private void initRulePattern(String rawRule, VariableStore variableStore, RuleMode ruleMode) { + private void initRulePattern(String rawRule, VariableStore variableStore, RuleMode ruleMode, boolean regexTrait) { //分离get规则 rawRule = VariablesPattern.fromGetterRule(rawRule, variableStore).rule; @@ -56,7 +59,7 @@ private void initRulePattern(String rawRule, VariableStore variableStore, RuleMo rawRule = ensureRedirectRule(rawRule); //分离正则表达式 - rawRule = ensureRegexRule(rawRule, ruleMode == RuleMode.CSS || ruleMode == RuleMode.XPath); + rawRule = ensureRegexRule(rawRule, regexTrait || ruleMode == RuleMode.CSS || ruleMode == RuleMode.XPath); //分离js int start = ensureJavaScripts(rawRule); diff --git a/app/src/main/res/layout/item_bookshelf_list.xml b/app/src/main/res/layout/item_bookshelf_list.xml index c8f56b1..42cf653 100644 --- a/app/src/main/res/layout/item_bookshelf_list.xml +++ b/app/src/main/res/layout/item_bookshelf_list.xml @@ -59,9 +59,10 @@ android:id="@+id/tv_name" android:layout_width="match_parent" android:layout_height="wrap_content" + android:paddingTop="2dp" android:layout_marginEnd="16dp" + android:includeFontPadding="false" android:ellipsize="end" - android:paddingTop="2dp" android:singleLine="true" android:text="@string/tv_book_name" android:textColor="@color/colorTextDefault" From 823d01f6e2d5e467ebe77069e4746b1095fdf90e Mon Sep 17 00:00:00 2001 From: Invinciblelee <1760316362@qq.com> Date: Sat, 25 May 2019 18:22:25 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E6=B7=B7=E5=90=88=E8=A7=84=E5=88=99?= =?UTF-8?q?=E4=BD=BF=E7=94=A8##=E6=AD=A3=E5=88=99##=E6=9B=BF=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/monke/monkeybook/bean/BookShelfBean.java | 4 ++-- app/version.properties | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/monke/monkeybook/bean/BookShelfBean.java b/app/src/main/java/com/monke/monkeybook/bean/BookShelfBean.java index 21fdc8e..e744160 100644 --- a/app/src/main/java/com/monke/monkeybook/bean/BookShelfBean.java +++ b/app/src/main/java/com/monke/monkeybook/bean/BookShelfBean.java @@ -230,7 +230,7 @@ public BookShelfBean copy() { bookShelfBean.lastChapterName = lastChapterName; bookShelfBean.chapterListSize = chapterListSize; bookShelfBean.updateOff = updateOff; - bookShelfBean.setVariableString(variableString); + bookShelfBean.variableString = getVariableString(); bookShelfBean.bookInfoBean = bookInfoBean.copy(); if (chapterList != null) { for (ChapterBean aChapterList : chapterList) { @@ -297,7 +297,7 @@ public boolean isLocalBook() { return LOCAL_TAG.equals(tag); } - public boolean isAudioBook(){ + public boolean isAudioBook() { return BookType.AUDIO.equals(bookInfoBean.getBookType()); } diff --git a/app/version.properties b/app/version.properties index 5a7b43b..875ea10 100644 --- a/app/version.properties +++ b/app/version.properties @@ -1,2 +1,2 @@ -#Tue May 21 12:18:06 CST 2019 -VERSION_CODE=3001 +#Sat May 25 18:11:03 CST 2019 +VERSION_CODE=3004