├── app ├── .gitignore └── src │ ├── main │ ├── assets │ │ ├── wallpaper │ │ │ ├── bg1.png │ │ │ ├── bg2.png │ │ │ ├── bg3.png │ │ │ ├── bg5.png │ │ │ └── paper.jpg │ │ └── hyphenationPatterns │ │ │ ├── LICENSES │ │ │ └── CHANGES │ ├── cpp │ │ ├── libs │ │ │ ├── armeabi-v7a │ │ │ │ ├── libonig.so │ │ │ │ ├── libexpat.so │ │ │ │ ├── libiconv.so │ │ │ │ ├── libuchardet.a │ │ │ │ └── libLineBreak.so │ │ │ └── armeabi │ │ │ │ └── libuchardet.a │ │ └── nbbook │ │ │ ├── plugin │ │ │ ├── FormatType.cpp │ │ │ ├── FormatType.h │ │ │ ├── oeb │ │ │ │ ├── ContainerReader.h │ │ │ │ ├── OebReader.h │ │ │ │ ├── ContainerReader.cpp │ │ │ │ └── OebReader.cpp │ │ │ ├── EncodingTextReader.h │ │ │ ├── PluginManager.h │ │ │ └── txt │ │ │ │ └── TxtPlugin.h │ │ │ ├── util │ │ │ ├── Boolean.cpp │ │ │ ├── CommonUtil.cpp │ │ │ ├── Constants.cpp │ │ │ ├── CommonUtil.h │ │ │ ├── Constants.h │ │ │ ├── Boolean.h │ │ │ ├── Logger.h │ │ │ ├── Logger.cpp │ │ │ ├── StringUtil.h │ │ │ └── FilePathUtil.h │ │ │ ├── filesystem │ │ │ ├── FileStat.cpp │ │ │ ├── io │ │ │ │ ├── Reader.cpp │ │ │ │ ├── InputStream.cpp │ │ │ │ ├── OutputStream.cpp │ │ │ │ ├── OutputStream.h │ │ │ │ ├── InputStreamReader.cpp │ │ │ │ ├── Reader.h │ │ │ │ ├── FileOutputStream.h │ │ │ │ ├── FileInputStream.h │ │ │ │ ├── InputStream.h │ │ │ │ └── InputStreamReader.h │ │ │ ├── asset │ │ │ │ ├── AssetManager.cpp │ │ │ │ └── AssetManager.h │ │ │ ├── FileStat.h │ │ │ ├── UnixFileDir.h │ │ │ ├── zip │ │ │ │ ├── ZipFileDir.h │ │ │ │ ├── ZipDecompressor.h │ │ │ │ ├── ZipFileDir.cpp │ │ │ │ ├── ZipEntryManager.h │ │ │ │ └── ZipEntry.h │ │ │ ├── FileDir.cpp │ │ │ ├── UnixFileDir.cpp │ │ │ └── UnixFileSystem.h │ │ │ ├── reader │ │ │ └── text │ │ │ │ ├── tag │ │ │ │ ├── TextTag.cpp │ │ │ │ ├── TextKind.cpp │ │ │ │ ├── StyleCloseTag.cpp │ │ │ │ ├── FixedHSpaceTag.cpp │ │ │ │ ├── StyleCloseTag.h │ │ │ │ ├── ParagraphTag.cpp │ │ │ │ ├── ControlTag.cpp │ │ │ │ ├── FixedHSpaceTag.h │ │ │ │ ├── ControlTag.h │ │ │ │ ├── ParagraphTag.h │ │ │ │ ├── ContentTag.h │ │ │ │ ├── TextTag.h │ │ │ │ ├── ImageTag.h │ │ │ │ └── ContentTag.cpp │ │ │ │ ├── type │ │ │ │ ├── TextTagType.cpp │ │ │ │ ├── TextResType.cpp │ │ │ │ ├── TextStyleTagType.cpp │ │ │ │ ├── TextAlignmentType.cpp │ │ │ │ ├── TextResType.h │ │ │ │ ├── TextAlignmentType.h │ │ │ │ └── TextTagType.h │ │ │ │ ├── entity │ │ │ │ ├── TextParagraph.cpp │ │ │ │ ├── TextChapter.cpp │ │ │ │ ├── TextContent.h │ │ │ │ ├── TextParagraph.h │ │ │ │ ├── TextChapter.h │ │ │ │ └── TextContent.cpp │ │ │ │ └── resource │ │ │ │ ├── TextResource.cpp │ │ │ │ ├── ImageResource.cpp │ │ │ │ ├── TextResource.h │ │ │ │ └── ImageResource.h │ │ │ ├── tools │ │ │ ├── encoding │ │ │ │ ├── Charset.cpp │ │ │ │ └── Charset.h │ │ │ ├── xml │ │ │ │ ├── SAXParserFactory.cpp │ │ │ │ ├── SAXParser.cpp │ │ │ │ ├── SAXParserFactory.h │ │ │ │ ├── SAXParser.h │ │ │ │ ├── BaseHandler.cpp │ │ │ │ ├── XMLFilter.h │ │ │ │ └── BaseHandler.h │ │ │ ├── language │ │ │ │ ├── LangUtil.cpp │ │ │ │ ├── LangUtil.h │ │ │ │ ├── StatisticsNativeReader.h │ │ │ │ └── StatisticsXMLReader.h │ │ │ └── font │ │ │ │ ├── FontManager.cpp │ │ │ │ └── FontManager.h │ │ │ ├── android │ │ │ ├── filesystem │ │ │ │ ├── AndroidFileSystem.cpp │ │ │ │ ├── AndroidFileSystem.h │ │ │ │ ├── AndroidAssetManager.h │ │ │ │ └── AndroidAssetInputStream.h │ │ │ └── application │ │ │ │ ├── AndroidFormatPluginApp.h │ │ │ │ └── AndroidFormatPluginApp.cpp │ │ │ ├── NBBookApp.cpp │ │ │ ├── NBBookMain.cpp │ │ │ └── NBBookApp.h │ ├── res │ │ ├── drawable-xxhdpi │ │ │ ├── ic_moon.png │ │ │ ├── ic_more.png │ │ │ ├── ic_sun.png │ │ │ ├── ic_bright.png │ │ │ ├── ic_filter.png │ │ │ ├── ic_red_dot.png │ │ │ ├── ic_setting.png │ │ │ ├── ic_category.png │ │ │ ├── ic_back_normal.png │ │ │ ├── ic_back_press.png │ │ │ ├── ic_bright_large.png │ │ │ ├── ic_bright_small.png │ │ │ ├── ic_font_size_plus.png │ │ │ ├── ic_image_loading.png │ │ │ ├── ic_rating_disable.png │ │ │ ├── ic_rating_enable.png │ │ │ ├── ic_read_menu_more.png │ │ │ ├── icon_find_catalog.jpg │ │ │ ├── ic_drop_down_arrow.png │ │ │ ├── ic_font_size_minus.png │ │ │ ├── ic_image_load_error.png │ │ │ ├── ic_read_menu_screen.png │ │ │ ├── icon_find_selected.png │ │ │ ├── icon_find_unselected.png │ │ │ ├── icon_mine_selected.png │ │ │ ├── icon_mine_unselected.png │ │ │ ├── icon_title_bar_add.png │ │ │ ├── ic_read_menu_auto_read.png │ │ │ ├── icon_title_bar_search.png │ │ │ ├── icon_book_shelf_selected.png │ │ │ └── icon_book_shelf_unselected.png │ │ ├── mipmap-hdpi │ │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ │ └── ic_launcher.png │ │ ├── drawable-hdpi │ │ │ ├── ic_grey_back.png │ │ │ ├── ic_back_normal.png │ │ │ ├── ic_back_press.png │ │ │ ├── ic_white_back.png │ │ │ ├── ic_rating_disable.png │ │ │ ├── ic_rating_enable.png │ │ │ ├── ic_hd_rating_enable.png │ │ │ └── ic_hd_rating_disable.png │ │ ├── drawable-xhdpi │ │ │ ├── ic_no_book.png │ │ │ ├── ic_back_press.png │ │ │ ├── ic_grey_back.png │ │ │ ├── ic_local_book.png │ │ │ ├── ic_white_back.png │ │ │ ├── ic_back_normal.png │ │ │ ├── ic_book_cached.png │ │ │ ├── ic_book_checked.png │ │ │ ├── ic_rating_enable.png │ │ │ ├── ic_book_unchecked.png │ │ │ ├── ic_rating_disable.png │ │ │ ├── ic_hd_rating_disable.png │ │ │ ├── ic_hd_rating_enable.png │ │ │ └── ic_book_detail_right_arrow.png │ │ ├── mipmap-xhdpi │ │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ │ └── ic_launcher.png │ │ ├── drawable │ │ │ ├── bg_book_type.xml │ │ │ ├── shape_btn_retry.xml │ │ │ ├── shape_standard_btn_press.xml │ │ │ ├── shape_standard_btn_normal.xml │ │ │ ├── selector_back.xml │ │ │ ├── selector_tag.xml │ │ │ ├── shape_filter_normal.xml │ │ │ ├── shape_switch_thumb_off.xml │ │ │ ├── selector_standard_btn.xml │ │ │ ├── shape_switch_thumb_on.xml │ │ │ ├── selector_seek_bar_thumb.xml │ │ │ ├── shape_shadow_bottom.xml │ │ │ ├── selector_read_setting_menu.xml │ │ │ ├── selector_switch_thumb.xml │ │ │ ├── selector_switch_track.xml │ │ │ ├── shape_seek_bar_press.xml │ │ │ ├── shape_switch_track_on.xml │ │ │ ├── selector_bg_accent_enable.xml │ │ │ ├── selector_btn.xml │ │ │ ├── shape_filter_selected.xml │ │ │ ├── shape_switch_track_off.xml │ │ │ ├── selector_bg_item_read_catalog.xml │ │ │ ├── shape_read_setting_item_selected.xml │ │ │ ├── shape_seek_bar_normal.xml │ │ │ ├── shape_read_setting_item_normal.xml │ │ │ ├── selector_btn_read_setting.xml │ │ │ ├── selector_cb_book.xml │ │ │ ├── bg_seek_bar_progress.xml │ │ │ ├── layer_rating_bar.xml │ │ │ └── layer_hd_rating_bar.xml │ │ ├── anim │ │ │ ├── slide_bottom_in.xml │ │ │ ├── slide_bottom_out.xml │ │ │ ├── slide_left_in.xml │ │ │ ├── slide_right_in.xml │ │ │ ├── slide_top_out.xml │ │ │ ├── slide_left_out.xml │ │ │ ├── slide_right_out.xml │ │ │ ├── rotate_180_to_360.xml │ │ │ ├── rotate_0_to_180.xml │ │ │ └── slide_top_in.xml │ │ ├── color │ │ │ ├── selector_chapter.xml │ │ │ ├── selector_tag.xml │ │ │ ├── selector_read_setting_menu.xml │ │ │ └── selector_text_enable.xml │ │ ├── layout │ │ │ ├── layout_shadow.xml │ │ │ ├── fragment_file_catalog.xml │ │ │ ├── item_book_list_sort.xml │ │ │ ├── layout_page_header.xml │ │ │ ├── item_tag.xml │ │ │ ├── item_smart_lookup_head.xml │ │ │ ├── layout_page.xml │ │ │ ├── layout_book_shelf_empty.xml │ │ │ ├── fragment_mine.xml │ │ │ ├── layout_toolbar.xml │ │ │ ├── item_page_anim.xml │ │ │ ├── fragment_find.xml │ │ │ ├── fragment_book_shelf.xml │ │ │ └── item_read_catalogy.xml │ │ ├── values │ │ │ └── attrs.xml │ │ └── menu │ │ │ ├── meun_main.xml │ │ │ └── menu_file_system.xml │ └── java │ │ └── com │ │ └── newbiechen │ │ └── nbreader │ │ ├── uilts │ │ ├── Void.kt │ │ ├── rxbus │ │ │ └── RxEvent.kt │ │ ├── Constants.kt │ │ ├── factory │ │ │ ├── MainFragFactory.kt │ │ │ └── ViewModelFactory.kt │ │ ├── FileUtil.kt │ │ ├── StringUtil.kt │ │ ├── NumberUtil.kt │ │ └── DensityUtil.kt │ │ ├── di │ │ ├── annotation │ │ │ ├── qualifier │ │ │ │ ├── LocalData.kt │ │ │ │ └── RemoteData.kt │ │ │ ├── scope │ │ │ │ ├── ActivityScoped.kt │ │ │ │ └── FragmentScoped.kt │ │ │ └── key │ │ │ │ └── ViewModelKey.kt │ │ └── module │ │ │ ├── UtilModule.kt │ │ │ ├── base │ │ │ └── AppModule.kt │ │ │ ├── FileSystemModule.kt │ │ │ ├── DatabaseModule.kt │ │ │ └── MainModule.kt │ │ ├── ui │ │ ├── component │ │ │ ├── book │ │ │ │ ├── type │ │ │ │ │ └── BookType.kt │ │ │ │ ├── text │ │ │ │ │ ├── config │ │ │ │ │ │ ├── TextStyleTheme.kt │ │ │ │ │ │ ├── CSSStyleInterceptor.kt │ │ │ │ │ │ ├── TextConfigure.kt │ │ │ │ │ │ └── DefaultConfigure.kt │ │ │ │ │ ├── util │ │ │ │ │ │ ├── TextConstants.kt │ │ │ │ │ │ └── TextDimenUtil.kt │ │ │ │ │ ├── entity │ │ │ │ │ │ ├── TextContent.kt │ │ │ │ │ │ ├── resource │ │ │ │ │ │ │ ├── TextResType.kt │ │ │ │ │ │ │ ├── image │ │ │ │ │ │ │ │ ├── TextImage.kt │ │ │ │ │ │ │ │ └── TextImageFactory.kt │ │ │ │ │ │ │ └── TextAttribute.kt │ │ │ │ │ │ ├── textstyle │ │ │ │ │ │ │ ├── BaseTextStyle.kt │ │ │ │ │ │ │ ├── TextAlignmentType.kt │ │ │ │ │ │ │ ├── TreeTextStyle.kt │ │ │ │ │ │ │ └── TextStyle.kt │ │ │ │ │ │ ├── TextChapter.kt │ │ │ │ │ │ ├── TextParagraph.kt │ │ │ │ │ │ ├── TextMetrics.kt │ │ │ │ │ │ ├── TextFixedPosition.kt │ │ │ │ │ │ ├── TextRegion.kt │ │ │ │ │ │ └── element │ │ │ │ │ │ │ ├── TextFixedHSpaceElement.kt │ │ │ │ │ │ │ └── TextElement.kt │ │ │ │ │ ├── language │ │ │ │ │ │ └── ExtLanguage.kt │ │ │ │ │ ├── engine │ │ │ │ │ │ └── cursor │ │ │ │ │ │ │ └── TextTagIterator.kt │ │ │ │ │ └── hyphenation │ │ │ │ │ │ └── TextHyphenInfo.kt │ │ │ │ ├── plugin │ │ │ │ │ ├── BookGroup.kt │ │ │ │ │ └── OEBNativePlugin.kt │ │ │ │ └── library │ │ │ │ │ ├── IBookLibrary.kt │ │ │ │ │ └── BookLibrary.kt │ │ │ ├── widget │ │ │ │ ├── page │ │ │ │ │ ├── action │ │ │ │ │ │ ├── PageAction.kt │ │ │ │ │ │ └── MotionAction.kt │ │ │ │ │ ├── anim │ │ │ │ │ │ ├── IPageAnimListener.kt │ │ │ │ │ │ ├── TextPageAnimation.kt │ │ │ │ │ │ ├── IPageAnimation.kt │ │ │ │ │ │ ├── IPageAnimCallback.kt │ │ │ │ │ │ └── NonePageAnimation.kt │ │ │ │ │ ├── OnPageListener.kt │ │ │ │ │ ├── DefaultActionCallback.kt │ │ │ │ │ └── PageEnum.kt │ │ │ │ ├── MineTabView.kt │ │ │ │ ├── FindTabView.kt │ │ │ │ └── BookShelfTabView.kt │ │ │ ├── adapter │ │ │ │ ├── base │ │ │ │ │ ├── IViewHolder.kt │ │ │ │ │ └── WrapViewHolder.kt │ │ │ │ ├── MainPagerAdapter.kt │ │ │ │ └── SimpleTagAdapter.kt │ │ │ ├── binding │ │ │ │ ├── ToolbarBinding.kt │ │ │ │ ├── TextViewBinding.kt │ │ │ │ ├── StatusViewBinding.kt │ │ │ │ ├── ImageViewBinding.kt │ │ │ │ ├── TabLayoutBinding.kt │ │ │ │ ├── RecyclerViewBinding.kt │ │ │ │ └── ViewGroupBinding.kt │ │ │ └── extension │ │ │ │ └── ToolbarExt.kt │ │ └── page │ │ │ ├── main │ │ │ └── MainViewModel.kt │ │ │ ├── mine │ │ │ └── MineFragment.kt │ │ │ ├── base │ │ │ └── BaseViewModel.kt │ │ │ └── filesystem │ │ │ └── ILocalBookSystem.kt │ │ ├── data │ │ ├── repository │ │ │ ├── impl │ │ │ │ ├── ICatalogRepository.kt │ │ │ │ ├── IBookDetailRepository.kt │ │ │ │ ├── IBookRepository.kt │ │ │ │ └── IBookListRepository.kt │ │ │ ├── BookDetailRepository.kt │ │ │ └── BookListRepository.kt │ │ ├── local │ │ │ ├── room │ │ │ │ ├── dao │ │ │ │ │ ├── CatalogDao.kt │ │ │ │ │ └── BookDao.kt │ │ │ │ ├── converter │ │ │ │ │ ├── BookTypeConverter.kt │ │ │ │ │ └── StringListConverter.kt │ │ │ │ └── NBDataBase.kt │ │ │ ├── CatalogLocalDataSource.kt │ │ │ └── BookLocalDataSource.kt │ │ ├── entity │ │ │ ├── LocalBookEntity.kt │ │ │ ├── CatalogLabelEntity.kt │ │ │ └── NetBookDetailEntity.kt │ │ └── remote │ │ │ ├── BookDetailRemoteDataSource.kt │ │ │ └── BookListRemoteDataSource.kt │ │ └── NBApplication.kt │ ├── test │ └── java │ │ └── com │ │ └── newbiechen │ │ └── nbreader │ │ └── ExampleUnitTest.kt │ └── androidTest │ └── java │ └── com │ └── newbiechen │ └── nbreader │ └── ExampleInstrumentedTest.kt ├── settings.gradle ├── doc ├── image │ ├── book_show.gif │ ├── find_local_book.gif │ └── nbreader_framework.png ├── support_css_attribute.md └── support_html_tag.md ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .idea ├── encodings.xml ├── codeStyles │ └── codeStyleConfig.xml ├── vcs.xml ├── render.experimental.xml ├── inspectionProfiles │ └── Project_Default.xml ├── runConfigurations.xml └── gradle.xml └── gradle.properties /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /doc/image/book_show.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/doc/image/book_show.gif -------------------------------------------------------------------------------- /doc/image/find_local_book.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/doc/image/find_local_book.gif -------------------------------------------------------------------------------- /doc/image/nbreader_framework.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/doc/image/nbreader_framework.png -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/assets/wallpaper/bg1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/assets/wallpaper/bg1.png -------------------------------------------------------------------------------- /app/src/main/assets/wallpaper/bg2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/assets/wallpaper/bg2.png -------------------------------------------------------------------------------- /app/src/main/assets/wallpaper/bg3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/assets/wallpaper/bg3.png -------------------------------------------------------------------------------- /app/src/main/assets/wallpaper/bg5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/assets/wallpaper/bg5.png -------------------------------------------------------------------------------- /app/src/main/assets/wallpaper/paper.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/assets/wallpaper/paper.jpg -------------------------------------------------------------------------------- /app/src/main/cpp/libs/armeabi-v7a/libonig.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/cpp/libs/armeabi-v7a/libonig.so -------------------------------------------------------------------------------- /app/src/main/cpp/libs/armeabi/libuchardet.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/cpp/libs/armeabi/libuchardet.a -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_moon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/res/drawable-xxhdpi/ic_moon.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_more.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/res/drawable-xxhdpi/ic_more.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_sun.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/res/drawable-xxhdpi/ic_sun.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/cpp/libs/armeabi-v7a/libexpat.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/cpp/libs/armeabi-v7a/libexpat.so -------------------------------------------------------------------------------- /app/src/main/cpp/libs/armeabi-v7a/libiconv.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/cpp/libs/armeabi-v7a/libiconv.so -------------------------------------------------------------------------------- /app/src/main/cpp/libs/armeabi-v7a/libuchardet.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/cpp/libs/armeabi-v7a/libuchardet.a -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_grey_back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/res/drawable-hdpi/ic_grey_back.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_no_book.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/res/drawable-xhdpi/ic_no_book.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_bright.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/res/drawable-xxhdpi/ic_bright.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_filter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/res/drawable-xxhdpi/ic_filter.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_red_dot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/res/drawable-xxhdpi/ic_red_dot.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_setting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/res/drawable-xxhdpi/ic_setting.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/cpp/libs/armeabi-v7a/libLineBreak.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/cpp/libs/armeabi-v7a/libLineBreak.so -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/plugin/FormatType.cpp: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2019-09-22 15:32 3 | // description : 4 | // 5 | #include "FormatType.h" -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/util/Boolean.cpp: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2020-02-15 21:43 3 | // description : 4 | // 5 | 6 | #include "Boolean.h" 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_back_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/res/drawable-hdpi/ic_back_normal.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_back_press.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/res/drawable-hdpi/ic_back_press.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_white_back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/res/drawable-hdpi/ic_white_back.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_back_press.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/res/drawable-xhdpi/ic_back_press.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_grey_back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/res/drawable-xhdpi/ic_grey_back.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_local_book.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/res/drawable-xhdpi/ic_local_book.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_white_back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/res/drawable-xhdpi/ic_white_back.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_category.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/res/drawable-xxhdpi/ic_category.png -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/util/CommonUtil.cpp: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2020-02-16 14:38 3 | // description : 4 | // 5 | 6 | #include "CommonUtil.h" 7 | -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/util/Constants.cpp: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2019-11-17 14:56 3 | // description : 4 | // 5 | 6 | #include "Constants.h" 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_rating_disable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/res/drawable-hdpi/ic_rating_disable.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_rating_enable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/res/drawable-hdpi/ic_rating_enable.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_back_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/res/drawable-xhdpi/ic_back_normal.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_book_cached.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/res/drawable-xhdpi/ic_book_cached.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_book_checked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/res/drawable-xhdpi/ic_book_checked.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_rating_enable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/res/drawable-xhdpi/ic_rating_enable.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_back_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/res/drawable-xxhdpi/ic_back_normal.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_back_press.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/res/drawable-xxhdpi/ic_back_press.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_bright_large.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/res/drawable-xxhdpi/ic_bright_large.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_bright_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/res/drawable-xxhdpi/ic_bright_small.png -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/filesystem/FileStat.cpp: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2019-09-23 11:21 3 | // description : 4 | // 5 | 6 | #include "FileStat.h" 7 | -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/filesystem/io/Reader.cpp: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2019-11-29 23:36 3 | // description : 4 | // 5 | 6 | #include "Reader.h" 7 | -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/reader/text/tag/TextTag.cpp: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2019-12-30 14:31 3 | // description : 4 | // 5 | 6 | #include "TextTag.h" 7 | -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/tools/encoding/Charset.cpp: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2019-10-07 18:55 3 | // description : 4 | // 5 | 6 | #include "Charset.h" 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_hd_rating_enable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/res/drawable-hdpi/ic_hd_rating_enable.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_book_unchecked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/res/drawable-xhdpi/ic_book_unchecked.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_rating_disable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/res/drawable-xhdpi/ic_rating_disable.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_font_size_plus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/res/drawable-xxhdpi/ic_font_size_plus.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_image_loading.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/res/drawable-xxhdpi/ic_image_loading.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_rating_disable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/res/drawable-xxhdpi/ic_rating_disable.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_rating_enable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/res/drawable-xxhdpi/ic_rating_enable.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_read_menu_more.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/res/drawable-xxhdpi/ic_read_menu_more.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/icon_find_catalog.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/res/drawable-xxhdpi/icon_find_catalog.jpg -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/filesystem/io/InputStream.cpp: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2019-09-24 10:57 3 | // description : 4 | // 5 | 6 | #include "InputStream.h" -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/reader/text/tag/TextKind.cpp: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2019-12-30 14:29 3 | // description : 4 | // 5 | 6 | #include "TextKind.h" 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_hd_rating_disable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/res/drawable-hdpi/ic_hd_rating_disable.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_hd_rating_disable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/res/drawable-xhdpi/ic_hd_rating_disable.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_hd_rating_enable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/res/drawable-xhdpi/ic_hd_rating_enable.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_drop_down_arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/res/drawable-xxhdpi/ic_drop_down_arrow.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_font_size_minus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/res/drawable-xxhdpi/ic_font_size_minus.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_image_load_error.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/res/drawable-xxhdpi/ic_image_load_error.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_read_menu_screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/res/drawable-xxhdpi/ic_read_menu_screen.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/icon_find_selected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/res/drawable-xxhdpi/icon_find_selected.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/icon_find_unselected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/res/drawable-xxhdpi/icon_find_unselected.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/icon_mine_selected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/res/drawable-xxhdpi/icon_mine_selected.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/icon_mine_unselected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/res/drawable-xxhdpi/icon_mine_unselected.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/icon_title_bar_add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/res/drawable-xxhdpi/icon_title_bar_add.png -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/filesystem/io/OutputStream.cpp: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2019-09-24 11:12 3 | // description : 4 | // 5 | 6 | #include "OutputStream.h" 7 | -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/reader/text/type/TextTagType.cpp: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2019-12-30 14:55 3 | // description : 4 | // 5 | 6 | #include "TextTagType.h" 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_read_menu_auto_read.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/res/drawable-xxhdpi/ic_read_menu_auto_read.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/icon_title_bar_search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/res/drawable-xxhdpi/icon_title_bar_search.png -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/reader/text/entity/TextParagraph.cpp: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2019-12-30 14:32 3 | // description : 4 | // 5 | 6 | #include "TextParagraph.h" 7 | -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/reader/text/resource/TextResource.cpp: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2020/3/1 9:45 PM 3 | // description : 4 | // 5 | 6 | #include "TextResource.h" 7 | -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/reader/text/type/TextResType.cpp: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2020/2/29 10:33 AM 3 | // description : 4 | // 5 | 6 | #include "TextResType.h" 7 | -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/tools/xml/SAXParserFactory.cpp: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2020-02-15 16:15 3 | // description : 4 | // 5 | 6 | #include "SAXParserFactory.h" 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_book_detail_right_arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/res/drawable-xhdpi/ic_book_detail_right_arrow.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/icon_book_shelf_selected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/res/drawable-xxhdpi/icon_book_shelf_selected.png -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/reader/text/type/TextStyleTagType.cpp: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2020-02-15 21:29 3 | // description : 4 | // 5 | 6 | #include "TextStyleTagType.h" 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/icon_book_shelf_unselected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newbiechen1024/NBReader/HEAD/app/src/main/res/drawable-xxhdpi/icon_book_shelf_unselected.png -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/android/filesystem/AndroidFileSystem.cpp: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2019-09-24 10:54 3 | // description : 4 | // 5 | 6 | #include "AndroidFileSystem.h" 7 | -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/reader/text/type/TextAlignmentType.cpp: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2020-02-15 21:27 3 | // description : 4 | // 5 | 6 | #include "TextAlignmentType.h" 7 | -------------------------------------------------------------------------------- /.idea/codeStyles/codeStyleConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/NBBookApp.cpp: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2019-10-06 19:18 3 | // description : 4 | // 5 | 6 | #include "NBBookApp.h" 7 | 8 | NBBookApp *NBBookApp::sInstance = nullptr; -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/render.experimental.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/filesystem/asset/AssetManager.cpp: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2019-10-17 15:25 3 | // description : 4 | // 5 | 6 | #include "AssetManager.h" 7 | 8 | AssetManager *AssetManager::sInstance = nullptr; -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/uilts/Void.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.uilts 2 | 3 | /** 4 | * author : newbiechen 5 | * date : 2020-02-05 21:49 6 | * description :空对象 7 | */ 8 | 9 | class Void { 10 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable/bg_book_type.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/anim/slide_bottom_in.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/anim/slide_bottom_out.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/anim/slide_left_in.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/anim/slide_right_in.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/anim/slide_top_out.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/di/annotation/qualifier/LocalData.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.di.annotation.qualifier 2 | 3 | import javax.inject.Qualifier 4 | 5 | @Qualifier 6 | @MustBeDocumented 7 | @Retention(AnnotationRetention.RUNTIME) 8 | annotation class LocalData -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/di/annotation/qualifier/RemoteData.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.di.annotation.qualifier 2 | 3 | import javax.inject.Qualifier 4 | 5 | @Qualifier 6 | @MustBeDocumented 7 | @Retention(AnnotationRetention.RUNTIME) 8 | annotation class RemoteData -------------------------------------------------------------------------------- /app/src/main/res/anim/slide_left_out.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/shape_btn_retry.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Feb 28 12:59:37 CST 2020 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip 7 | -------------------------------------------------------------------------------- /app/src/main/res/anim/slide_right_out.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/color/selector_chapter.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/color/selector_tag.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/shape_standard_btn_press.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/ui/component/book/type/BookType.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.ui.component.book.type 2 | 3 | /** 4 | * author : newbiechen 5 | * date : 2019-08-18 15:16 6 | * description :支持的书本格式 7 | */ 8 | 9 | enum class BookType { 10 | TXT, 11 | EPUB 12 | } -------------------------------------------------------------------------------- /app/src/main/res/color/selector_read_setting_menu.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/shape_standard_btn_normal.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/layout/layout_shadow.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/selector_back.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/selector_tag.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/shape_filter_normal.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/ui/component/book/text/config/TextStyleTheme.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.ui.component.book.text.config 2 | 3 | /** 4 | * author : newbiechen 5 | * date : 2019-11-10 17:29 6 | * description :文本样式主题 7 | */ 8 | 9 | enum class TextStyleTheme { 10 | PAPER, 11 | BLUE 12 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable/shape_switch_thumb_off.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/anim/rotate_180_to_360.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/selector_standard_btn.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/shape_switch_thumb_on.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 9 | -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/di/annotation/scope/ActivityScoped.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.di.annotation.scope 2 | 3 | import javax.inject.Scope 4 | 5 | /** 6 | * Created by cuongpm on 12/6/18. 7 | */ 8 | 9 | @Scope 10 | @MustBeDocumented 11 | @Retention(AnnotationRetention.RUNTIME) 12 | annotation class ActivityScoped -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/di/annotation/scope/FragmentScoped.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.di.annotation.scope 2 | 3 | import javax.inject.Scope 4 | 5 | /** 6 | * Created by cuongpm on 12/6/18. 7 | */ 8 | 9 | @Scope 10 | @MustBeDocumented 11 | @Retention(AnnotationRetention.RUNTIME) 12 | annotation class FragmentScoped -------------------------------------------------------------------------------- /app/src/main/res/anim/rotate_0_to_180.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/selector_seek_bar_thumb.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/shape_shadow_bottom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | -------------------------------------------------------------------------------- /doc/support_css_attribute.md: -------------------------------------------------------------------------------- 1 | # css:支持的属性 (3月9日) 2 | 3 | CSS 支持如下属性: 4 | 5 | 1. font-family 6 | 2. font-size 7 | 3. font-weight 8 | 4. font-style 9 | 5. text-decoration 10 | 6. hyphens 11 | 7. margin-top 12 | 8. margin-bottom 13 | 9. margin-left 14 | 10. margin-right 15 | 11. text-indent 16 | 12. text-align 17 | 13. vertical-align 18 | 14. line-height -------------------------------------------------------------------------------- /app/src/main/res/anim/slide_top_in.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/ui/component/book/plugin/BookGroup.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.ui.component.book.plugin 2 | 3 | /** 4 | * author : newbiechen 5 | * date : 2020-02-09 21:06 6 | * description :书籍信息 7 | */ 8 | 9 | data class BookGroup( 10 | val title: String, //书籍名 11 | val author: String // 作者名 12 | ) 13 | 14 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/selector_read_setting_menu.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/reader/text/tag/StyleCloseTag.cpp: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2020/3/1 10:05 PM 3 | // description : 4 | // 5 | 6 | #include "StyleCloseTag.h" 7 | 8 | StyleCloseTag::StyleCloseTag() : TextTag(TextTagType::STYLE_CLOSE) { 9 | } 10 | 11 | void StyleCloseTag::writeToParcelInternal(Parcel &parcel) const { 12 | // 不实现 13 | } 14 | -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/ui/component/book/text/util/TextConstants.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.ui.component.book.text.util 2 | 3 | /** 4 | * author : newbiechen 5 | * date : 2020/2/29 8:29 PM 6 | * description :文本常量信息 7 | */ 8 | 9 | object TextConstants { 10 | // zip 与 zip 文件的分割线 11 | const val zipSeparator: String = ":" 12 | } -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/ui/component/widget/page/action/PageAction.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.ui.component.widget.page.action 2 | 3 | /** 4 | * author : newbiechen 5 | * date : 2019-09-02 10:54 6 | * description :页面行为的集合 7 | */ 8 | 9 | // 页面行为标记 10 | interface PageAction 11 | 12 | // 点击页面菜单事件 13 | class TapMenuAction : PageAction -------------------------------------------------------------------------------- /app/src/main/res/drawable/selector_switch_thumb.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/selector_switch_track.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/tools/language/LangUtil.cpp: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2019-10-17 16:57 3 | // description : 4 | // 5 | 6 | #include "LangUtil.h" 7 | 8 | std::string LangUtil::getPatternDirectoryFromAsset() { 9 | return "languagePatterns"; 10 | } 11 | 12 | const std::vector &LangUtil::languageCodes() { 13 | // 从 asset 获取字节码 14 | } -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/ui/component/widget/page/anim/IPageAnimListener.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.ui.component.widget.page.anim 2 | 3 | /** 4 | * author : newbiechen 5 | * date : 2020-01-28 17:38 6 | * description :页面动画通知 7 | */ 8 | 9 | interface IPageAnimListener { 10 | fun onAnimationStart() 11 | fun onAnimationEnd() 12 | } -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/ui/component/adapter/base/IViewHolder.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.ui.component.adapter.base 2 | 3 | import android.view.ViewGroup 4 | import androidx.databinding.ViewDataBinding 5 | 6 | interface IViewHolder { 7 | fun createBinding(parent: ViewGroup): ViewDataBinding 8 | 9 | fun onBind(value: T, pos: Int) 10 | } -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/uilts/rxbus/RxEvent.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.uilts.rxbus 2 | 3 | /** 4 | * author : newbiechen 5 | * date : 2020-02-06 21:55 6 | * description :RxBus 用到的事件 7 | */ 8 | 9 | /** 10 | * 缓存书籍改变监听 11 | * 12 | * 1. 用于 FileSystemActivity 增加或删减的时候,通知 BookShelfBook 进行刷新 13 | */ 14 | class CacheBookChangedEvent : RxEvent -------------------------------------------------------------------------------- /app/src/main/res/color/selector_text_enable.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/shape_seek_bar_press.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/shape_switch_track_on.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/data/repository/impl/ICatalogRepository.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.data.repository.impl 2 | 3 | import com.newbiechen.nbreader.data.entity.CatalogEntity 4 | import io.reactivex.Flowable 5 | 6 | interface ICatalogRepository { 7 | fun getCatalogItems(): Flowable> 8 | fun saveCatalogItems(entities: List) 9 | } -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/plugin/FormatType.h: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2019-09-19 16:15 3 | // description : 4 | // 5 | 6 | #ifndef NBREADER_FORMATTYPE_H 7 | #define NBREADER_FORMATTYPE_H 8 | 9 | #include 10 | 11 | namespace FormatType { 12 | const std::string TXT = "txt"; 13 | const std::string EPUB = "epub"; 14 | } 15 | 16 | #endif //NBREADER_FORMATTYPE_H 17 | -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/ui/component/binding/ToolbarBinding.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.ui.component.binding 2 | 3 | import androidx.appcompat.widget.Toolbar 4 | import androidx.databinding.BindingAdapter 5 | 6 | object ToolbarBinding { 7 | 8 | @BindingAdapter("app:menuPos") 9 | @JvmStatic 10 | fun Toolbar.setCurrentMenu(position: Int) { 11 | } 12 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable/selector_bg_accent_enable.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/selector_btn.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/reader/text/type/TextResType.h: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2020/2/29 10:33 AM 3 | // description : 文本资源属性 4 | // 5 | 6 | #ifndef NBREADER_TEXTRESTYPE_H 7 | #define NBREADER_TEXTRESTYPE_H 8 | 9 | enum class TextResType : char { 10 | IMAGE = 1,// 图片资源 11 | FONT = 2, // 字体资源 12 | ID = 3 // id 资源 13 | }; 14 | 15 | 16 | #endif //NBREADER_TEXTRESTYPE_H 17 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/shape_filter_selected.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/ui/component/book/text/entity/TextContent.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.ui.component.book.text.entity 2 | 3 | /** 4 | * author : newbiechen 5 | * date : 2020/2/29 10:47 AM 6 | * description :文本内容数据 7 | */ 8 | data class TextContent( 9 | // 资源数组信息 10 | val resourceData: ByteArray?, 11 | // 内容数组信息 12 | val contentData: ByteArray 13 | ) -------------------------------------------------------------------------------- /app/src/main/res/drawable/shape_switch_track_off.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/selector_bg_item_read_catalog.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/di/annotation/key/ViewModelKey.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.di.annotation.key 2 | 3 | import androidx.lifecycle.ViewModel 4 | import dagger.MapKey 5 | import kotlin.reflect.KClass 6 | 7 | @Target(allowedTargets = [AnnotationTarget.FUNCTION]) 8 | @Retention(value = AnnotationRetention.RUNTIME) 9 | @MapKey 10 | annotation class ViewModelKey(val value: KClass) -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_file_catalog.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/uilts/Constants.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.uilts 2 | 3 | // 常量类 4 | object Constants { 5 | const val API_BASE_URL = "http://b01.zhuishushenqi.com" 6 | const val API_MORE_BASE_URL = "https://api.zhuishushenqi.com" 7 | const val LABEL_MORE_BASE_URL = "more" 8 | const val IMG_BASE_URL = "http://statics.zhuishushenqi.com" 9 | const val DB_NAME = "nbreader.db" 10 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable/shape_read_setting_item_selected.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 10 | -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/ui/component/book/text/entity/resource/TextResType.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.ui.component.book.text.entity.resource 2 | 3 | /** 4 | * author : newbiechen 5 | * date : 2020/2/29 2:36 PM 6 | * description :文本资源标签类型 7 | */ 8 | 9 | object TextResType { 10 | const val IMAGE: Byte = 1 // 图片资源 11 | const val FONT: Byte = 2 // 字体资源 12 | const val ID: Byte = 3 // 标签 id 资源 13 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable/shape_seek_bar_normal.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 8 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/reader/text/tag/FixedHSpaceTag.cpp: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2020/3/1 8:26 PM 3 | // description : 4 | // 5 | 6 | #include "FixedHSpaceTag.h" 7 | 8 | FixedHSpaceTag::FixedHSpaceTag(unsigned char length) : TextTag(TextTagType::FIXED_HSPACE) { 9 | this->length = length; 10 | } 11 | 12 | void FixedHSpaceTag::writeToParcelInternal(Parcel &parcel) const { 13 | parcel.writeInt8(length); 14 | } 15 | 16 | 17 | -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/ui/page/main/MainViewModel.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.ui.page.main 2 | 3 | import androidx.databinding.ObservableField 4 | import androidx.lifecycle.ViewModel 5 | import javax.inject.Inject 6 | 7 | class MainViewModel @Inject constructor() : ViewModel() { 8 | 9 | // 当前页面的位置 10 | val curPagePos = ObservableField(0) 11 | // 当前页面的 title 12 | val curPageTitle = ObservableField() 13 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable/shape_read_setting_item_normal.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 11 | -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/ui/component/book/text/language/ExtLanguage.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.ui.component.book.text.language 2 | 3 | /** 4 | * author : newbiechen 5 | * date : 2019-11-09 17:01 6 | * description :Text 扩展的 lang 信息 7 | */ 8 | 9 | object ExtLanguage { 10 | const val ANY_CODE = "any" 11 | const val OTHER_CODE = "other" 12 | const val MULTI_CODE = "multi" 13 | const val SYSTEM_CODE = "system" 14 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable/selector_btn_read_setting.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/tools/encoding/Charset.h: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2019-10-07 18:55 3 | // description : 字符集常量 4 | 5 | #ifndef NBREADER_CHARSET_H 6 | #define NBREADER_CHARSET_H 7 | 8 | #include 9 | 10 | namespace Charset { 11 | const std::string ASCII = "us-ascii"; 12 | const std::string UTF8 = "utf-8"; 13 | const std::string UTF16 = "utf-16"; 14 | const std::string UTF16BE = "utf-16be"; 15 | } 16 | 17 | #endif //NBREADER_CHARSET_H 18 | -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/ui/component/book/text/engine/cursor/TextTagIterator.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.ui.component.book.text.engine.cursor 2 | 3 | import com.newbiechen.nbreader.ui.component.book.text.entity.tag.TextTag 4 | 5 | /** 6 | * author : newbiechen 7 | * date : 2020-01-19 11:34 8 | * description :文本标签遍历器 9 | */ 10 | 11 | interface TextTagIterator { 12 | fun hasNext(): Boolean 13 | fun next(): TextTag 14 | fun reset() 15 | } -------------------------------------------------------------------------------- /app/src/test/java/com/newbiechen/nbreader/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader 2 | 3 | import org.junit.Test 4 | 5 | import org.junit.Assert.* 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * See [testing documentation](http://d.android.com/tools/testing). 11 | */ 12 | class ExampleUnitTest { 13 | @Test 14 | fun addition_isCorrect() { 15 | assertEquals(4, 2 + 2) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/tools/language/LangUtil.h: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2019-10-17 16:57 3 | // description : 4 | // 5 | 6 | #ifndef NBREADER_LANGUTIL_H 7 | #define NBREADER_LANGUTIL_H 8 | 9 | #include 10 | 11 | class LangUtil { 12 | public: 13 | // 获取 language 的匹配资源文件目录 14 | static std::string getPatternDirectoryFromAsset(); 15 | 16 | static const std::vector &languageCodes(); 17 | }; 18 | 19 | 20 | #endif //NBREADER_LANGUTIL_H 21 | -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/ui/component/book/plugin/OEBNativePlugin.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.ui.component.book.plugin 2 | 3 | import android.content.Context 4 | import com.newbiechen.nbreader.ui.component.book.type.BookType 5 | 6 | /** 7 | * author : newbiechen 8 | * date : 2019-09-19 17:22 9 | * description : epub 格式解析器 10 | */ 11 | 12 | class OEBNativePlugin(bookType: BookType) : 13 | NativeFormatPlugin(bookType) { 14 | // 获取封面,获取作者信息,等 15 | } -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/uilts/factory/MainFragFactory.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.uilts.factory 2 | 3 | import android.content.Context 4 | import android.view.View 5 | import androidx.fragment.app.Fragment 6 | 7 | interface MainFragFactory { 8 | fun createFragment(index: Int): Fragment 9 | fun createFragmentTabView(context: Context, index: Int): View 10 | fun getFragmentTitle(context: Context, index: Int): String 11 | fun getCount(): Int 12 | } -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/reader/text/tag/StyleCloseTag.h: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2020/3/1 10:05 PM 3 | // description : 4 | // 5 | 6 | #ifndef NBREADER_STYLECLOSETAG_H 7 | #define NBREADER_STYLECLOSETAG_H 8 | 9 | 10 | #include "TextTag.h" 11 | 12 | class StyleCloseTag : public TextTag { 13 | public: 14 | StyleCloseTag(); 15 | 16 | protected: 17 | void writeToParcelInternal(Parcel &parcel) const override; 18 | }; 19 | 20 | 21 | #endif //NBREADER_STYLECLOSETAG_H 22 | -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/data/repository/impl/IBookDetailRepository.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.data.repository.impl 2 | 3 | import com.newbiechen.nbreader.data.entity.NetBookDetailWrapper 4 | import io.reactivex.Flowable 5 | 6 | /** 7 | * author : newbiechen 8 | * date : 2019-08-14 18:28 9 | * description :书籍详细信息仓库 (NetBookDetail) 10 | */ 11 | 12 | interface IBookDetailRepository { 13 | fun getBookDetail(bookId: String): Flowable 14 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable/selector_cb_book.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/di/module/UtilModule.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.di.module 2 | 3 | import com.newbiechen.nbreader.uilts.rxbus.RxBus 4 | import dagger.Module 5 | import dagger.Provides 6 | import javax.inject.Singleton 7 | 8 | /** 9 | * author : newbiechen 10 | * date : 2020-02-06 21:53 11 | * description :工具模块 12 | */ 13 | 14 | @Module 15 | class UtilModule { 16 | 17 | @Provides 18 | @Singleton 19 | fun provideRxBus() = RxBus.getInstance() 20 | } -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/reader/text/tag/ParagraphTag.cpp: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2020/3/1 8:23 PM 3 | // description : 4 | // 5 | 6 | #include "ParagraphTag.h" 7 | 8 | ParagraphTag::ParagraphTag(TextParagraph::Type type) : TextTag(TextTagType::PARAGRAPH) { 9 | this->type = type; 10 | } 11 | 12 | void ParagraphTag::writeToParcelInternal(Parcel &parcel) const { 13 | auto paragraphType = CommonUtil::to_underlying(type); 14 | parcel.writeInt8(paragraphType); 15 | } 16 | 17 | 18 | -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/ui/component/book/text/hyphenation/TextHyphenInfo.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.ui.component.book.text.hyphenation 2 | 3 | /** 4 | * author : newbiechen 5 | * date : 2019-11-03 15:37 6 | * description :断字信息类 7 | */ 8 | 9 | class TextHyphenInfo(length: Int) { 10 | var mask: BooleanArray = BooleanArray(length - 1) 11 | 12 | fun isHyphenationPossible(position: Int): Boolean { 13 | return position < mask.size && mask[position] 14 | } 15 | } -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/util/CommonUtil.h: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2020-02-16 14:38 3 | // description : 4 | // 5 | 6 | #ifndef NBREADER_COMMONUTIL_H 7 | #define NBREADER_COMMONUTIL_H 8 | 9 | #include 10 | 11 | namespace CommonUtil { 12 | template 13 | constexpr typename std::underlying_type::type to_underlying(E e) noexcept { 14 | return static_cast::type>(e); 15 | }; 16 | } 17 | 18 | #endif //NBREADER_COMMONUTIL_H 19 | -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/ui/component/widget/MineTabView.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.ui.component.widget 2 | 3 | import android.content.Context 4 | import com.newbiechen.nbreader.R 5 | 6 | class MineTabView(context: Context) : TabView(context) { 7 | override fun getImageRes(isChecked: Boolean): Int { 8 | return if (isChecked) R.drawable.icon_mine_selected else R.drawable.icon_mine_unselected 9 | } 10 | 11 | override fun onCheckedChange(isChecked: Boolean) { 12 | } 13 | 14 | } -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/util/Constants.h: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2019-11-17 14:56 3 | // description : 4 | // 5 | 6 | #ifndef NBREADER_CONSTANTS_H 7 | #define NBREADER_CONSTANTS_H 8 | 9 | #include 10 | namespace Constants{ 11 | // 段落基础信息文件尾缀 12 | static std::string SUFFIX_PGH_BASE = "pgb"; 13 | // 段落详细信息文件尾缀 14 | static std::string SUFFIX_PGH_DETAIL = "pgd"; 15 | // 书籍默认缓冲区的大小 16 | static size_t BOOK_DEFAULT_BUFFER = 131072; 17 | } 18 | 19 | 20 | #endif //NBREADER_CONSTANTS_H 21 | -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/ui/component/adapter/base/WrapViewHolder.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.ui.component.adapter.base 2 | 3 | import androidx.databinding.ViewDataBinding 4 | import androidx.recyclerview.widget.RecyclerView 5 | 6 | /** 7 | * author : newbiechen 8 | * date : 2019-08-19 17:12 9 | * description : 10 | */ 11 | 12 | // 用于封装的真正 ViewHolder 的 ViewHolder 13 | data class WrapViewHolder(val binding: ViewDataBinding, val holder: IViewHolder) : 14 | RecyclerView.ViewHolder(binding.root) -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/ui/component/binding/TextViewBinding.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.ui.component.binding 2 | 3 | import android.widget.TextView 4 | import androidx.databinding.BindingAdapter 5 | 6 | /** 7 | * author : newbiechen 8 | * date : 2020-02-13 00:27 9 | * description : 10 | */ 11 | 12 | object TextViewBinding { 13 | @BindingAdapter("app:selected") 14 | @JvmStatic 15 | fun TextView.setTextSelected(isSelected: Boolean) { 16 | setSelected(isSelected) 17 | } 18 | } -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/ui/component/widget/FindTabView.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.ui.component.widget 2 | 3 | import android.content.Context 4 | import com.newbiechen.nbreader.R 5 | 6 | class FindTabView(context: Context) : TabView(context) { 7 | 8 | override fun getImageRes(isChecked: Boolean): Int { 9 | return if (isChecked) R.drawable.icon_find_selected else R.drawable.icon_find_unselected 10 | } 11 | 12 | override fun onCheckedChange(isChecked: Boolean) { 13 | } 14 | 15 | } -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/ui/page/mine/MineFragment.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.ui.page.mine 2 | 3 | import com.newbiechen.nbreader.R 4 | import com.newbiechen.nbreader.databinding.FragmentMineBinding 5 | import com.newbiechen.nbreader.ui.page.base.BaseBindingFragment 6 | 7 | class MineFragment : BaseBindingFragment() { 8 | companion object { 9 | fun newInstance() = MineFragment() 10 | } 11 | 12 | override fun initContentView(): Int = R.layout.fragment_mine 13 | } 14 | -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/di/module/base/AppModule.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.di.module.base 2 | 3 | import android.app.Application 4 | import android.content.Context 5 | import com.newbiechen.nbreader.NBApplication 6 | import dagger.Binds 7 | import dagger.Module 8 | 9 | @Module 10 | abstract class AppModule { 11 | 12 | @Binds 13 | abstract fun bindApplicationContext(application: NBApplication): Context 14 | 15 | @Binds 16 | abstract fun bindApplication(application: NBApplication): Application 17 | } -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/ui/component/book/text/config/CSSStyleInterceptor.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.ui.component.book.text.config 2 | 3 | 4 | /** 5 | * author : newbiechen 6 | * date : 2020/3/11 2:50 PM 7 | * description :支持的 CSS 标签类型 8 | */ 9 | 10 | interface CSSStyleInterceptor { 11 | fun isEnableFontSize(): Boolean 12 | 13 | fun isEnableMargin(): Boolean 14 | 15 | fun isEnablePadding(): Boolean 16 | 17 | fun isEnableSpace(): Boolean 18 | 19 | fun isEnableAlignment(): Boolean 20 | } -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/reader/text/tag/ControlTag.cpp: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2020/3/1 8:23 PM 3 | // description : 4 | // 5 | 6 | #include "ControlTag.h" 7 | 8 | ControlTag::ControlTag(TextKind kind, bool isStartTag) : TextTag(TextTagType::CONTROL) { 9 | this->kind = kind; 10 | this->isStartTag = isStartTag; 11 | } 12 | 13 | void ControlTag::writeToParcelInternal(Parcel &parcel) const { 14 | auto value = CommonUtil::to_underlying(kind); 15 | parcel.writeInt8(value); 16 | parcel.writeBool(isStartTag); 17 | } -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/reader/text/type/TextAlignmentType.h: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2020-02-15 21:27 3 | // description : 4 | // 5 | 6 | #ifndef NBREADER_TEXTALIGNMENTTYPE_H 7 | #define NBREADER_TEXTALIGNMENTTYPE_H 8 | 9 | enum class TextAlignmentType : char { 10 | ALIGN_UNDEFINED = 0, 11 | ALIGN_LEFT = 1, 12 | ALIGN_RIGHT = 2, 13 | ALIGN_CENTER = 3, 14 | ALIGN_JUSTIFY = 4, 15 | ALIGN_LINESTART = 5 // left for LTR languages and right for RTL 16 | }; 17 | 18 | 19 | #endif //NBREADER_TEXTALIGNMENTTYPE_H 20 | -------------------------------------------------------------------------------- /app/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/reader/text/entity/TextChapter.cpp: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2019-12-09 15:50 3 | // description : 4 | // 5 | 6 | #include "TextChapter.h" 7 | 8 | TextChapter::TextChapter() : url(""), title("") { 9 | startIndex = 0; 10 | endIndex = 0; 11 | } 12 | 13 | TextChapter::TextChapter(const std::string &url, const std::string &title, int startIndex, 14 | int endIndex) : url(url), title(title), 15 | startIndex(startIndex), endIndex(endIndex) { 16 | 17 | } -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/tools/xml/SAXParser.cpp: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2020-02-15 16:15 3 | // description : 4 | // 5 | 6 | #include "SAXParser.h" 7 | 8 | void SAXParser::parse(const std::string &path, SAXHandler &handler) { 9 | File parseFile(path); 10 | 11 | if (!parseFile.exists()) { 12 | // todo:抛出异常 13 | } else { 14 | parse(parseFile, handler); 15 | } 16 | } 17 | 18 | void SAXParser::parse(const File &file, SAXHandler &handler) { 19 | auto is = file.getInputStream(); 20 | parse(is, handler); 21 | } -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/ui/component/binding/StatusViewBinding.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.ui.component.binding 2 | 3 | import androidx.databinding.BindingAdapter 4 | import com.newbiechen.nbreader.ui.component.widget.StatusView 5 | 6 | /** 7 | * author : newbiechen 8 | * date : 2019-08-10 17:40 9 | * description : 10 | */ 11 | 12 | object StatusViewBinding { 13 | 14 | @BindingAdapter("app:curStatus") 15 | @JvmStatic 16 | fun StatusView.setViewStatus(status: Int) { 17 | setStatus(status) 18 | } 19 | } -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/ui/component/widget/page/anim/TextPageAnimation.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.ui.component.widget.page.anim 2 | 3 | import android.view.View 4 | import com.newbiechen.nbreader.ui.component.widget.page.text.TextPageManager 5 | 6 | /** 7 | * author : newbiechen 8 | * date : 2020/3/7 10:02 AM 9 | * description : 10 | */ 11 | abstract class TextPageAnimation(view: View, pageManager: TextPageManager) : IPageAnimation { 12 | protected val mView = view 13 | protected val mPageManager = pageManager 14 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable/bg_seek_bar_progress.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/filesystem/FileStat.h: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2019-09-23 11:21 3 | // description : 4 | // 5 | 6 | #ifndef NBREADER_FILEINFO_H 7 | #define NBREADER_FILEINFO_H 8 | 9 | #include 10 | #include 11 | 12 | struct FileStat { 13 | bool isDirectory; 14 | bool exists; 15 | size_t size; 16 | size_t lastModifiedTime; 17 | 18 | FileStat(); 19 | }; 20 | 21 | inline FileStat::FileStat() : exists(false), isDirectory(false), size(0), lastModifiedTime(0) { 22 | } 23 | 24 | #endif //NBREADER_FILEINFO_H 25 | -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/reader/text/tag/FixedHSpaceTag.h: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2020/3/1 8:26 PM 3 | // description : 修复竖直区域标签 4 | // 5 | 6 | #ifndef NBREADER_FIXEDHSPACETAG_H 7 | #define NBREADER_FIXEDHSPACETAG_H 8 | 9 | 10 | #include "TextTag.h" 11 | 12 | class FixedHSpaceTag : public TextTag { 13 | public: 14 | FixedHSpaceTag(unsigned char length); 15 | 16 | protected: 17 | void writeToParcelInternal(Parcel &parcel) const override; 18 | 19 | private: 20 | unsigned char length; 21 | }; 22 | 23 | 24 | #endif //NBREADER_FIXEDHSPACETAG_H 25 | -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/ui/component/book/text/entity/textstyle/BaseTextStyle.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.ui.component.book.text.entity.textstyle 2 | 3 | import com.newbiechen.nbreader.ui.component.book.text.entity.TextMetrics 4 | 5 | /** 6 | * author : newbiechen 7 | * date : 2020/3/11 11:52 PM 8 | * description :基础样式类 9 | */ 10 | 11 | abstract class BaseTextStyle : TreeTextStyle(null) { 12 | abstract fun getFontSize(): Int 13 | override fun getFontSize(metrics: TextMetrics): Int { 14 | return getFontSize() 15 | } 16 | } -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/ui/component/widget/BookShelfTabView.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.ui.component.widget 2 | 3 | import android.content.Context 4 | import com.newbiechen.nbreader.R 5 | 6 | class BookShelfTabView(context: Context) : TabView(context) { 7 | 8 | override fun getImageRes(isChecked: Boolean): Int { 9 | return if (isChecked) R.drawable.icon_book_shelf_selected 10 | else R.drawable.icon_book_shelf_unselected 11 | } 12 | 13 | override fun onCheckedChange(isChecked: Boolean) { 14 | // 暂时不处理 15 | } 16 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable/layer_rating_bar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 7 | 9 | -------------------------------------------------------------------------------- /app/src/main/assets/hyphenationPatterns/LICENSES: -------------------------------------------------------------------------------- 1 | All the pattern files in this archive were created from TeX hyphenation patterns. Original file name is pointed in comments inside a pattern file. 2 | 3 | This file contains a list of licences for original files. 4 | 5 | GNU General Public License: 6 | cs, id, hu 7 | GNU Lesser General Public License: 8 | it 9 | LaTeX Project Public License: 10 | de, de-traditional, el, eo, es, pl, pt, ru, sv, uk, nl 11 | Public Domain (with some restrictions, see corresponding pattern file for details): 12 | en, fr, fi, no 13 | Unknown: 14 | lt, tr 15 | -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/NBBookMain.cpp: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2019-09-22 15:34 3 | // description : 4 | // 5 | #include 6 | #include "util/AndroidUtil.h" 7 | #include "android/application/AndroidFormatPluginApp.h" 8 | #include "util/Logger.h" 9 | 10 | 11 | /** 12 | * 初始化 JNI 13 | */ 14 | extern "C" 15 | JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *jvm, void *reserved) { 16 | // 创建 Android 类型的 Application 17 | AndroidFormatPluginApp::newInstance(); 18 | // 初始化 application 19 | NBBookApp::getInstance().initApp(jvm); 20 | return JNI_VERSION_1_6; 21 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable/layer_hd_rating_bar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 7 | 9 | -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/reader/text/tag/ControlTag.h: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2020/3/1 8:23 PM 3 | // description : 控制位标签 4 | // 5 | 6 | #ifndef NBREADER_CONTROLTAG_H 7 | #define NBREADER_CONTROLTAG_H 8 | 9 | 10 | #include "TextTag.h" 11 | #include "TextKind.h" 12 | 13 | class ControlTag : public TextTag { 14 | public: 15 | ControlTag(TextKind kind, bool isStartTag); 16 | 17 | protected: 18 | void writeToParcelInternal(Parcel &parcel) const override; 19 | 20 | private: 21 | TextKind kind; 22 | bool isStartTag; 23 | }; 24 | 25 | 26 | #endif //NBREADER_CONTROLTAG_H 27 | -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/data/local/room/dao/CatalogDao.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.data.local.room.dao 2 | 3 | import androidx.room.* 4 | import com.newbiechen.nbreader.data.entity.CatalogEntity 5 | import io.reactivex.Maybe 6 | 7 | @Dao 8 | interface CatalogDao { 9 | @Query("SELECT * FROM catalog_entity") 10 | fun getAllCatalogs(): Maybe> 11 | 12 | @Insert(onConflict = OnConflictStrategy.REPLACE) 13 | fun insertCatalogs(catalogs: List) 14 | 15 | @Delete 16 | fun deleteAllCatalogs(catalogs: List) 17 | } -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/reader/text/tag/ParagraphTag.h: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2020/3/1 8:23 PM 3 | // description : 段落标签 4 | // 5 | 6 | #ifndef NBREADER_PARAGRAPHTAG_H 7 | #define NBREADER_PARAGRAPHTAG_H 8 | 9 | 10 | #include "TextTag.h" 11 | #include "../entity/TextParagraph.h" 12 | 13 | class ParagraphTag : public TextTag { 14 | public: 15 | ParagraphTag(TextParagraph::Type type); 16 | 17 | protected: 18 | void writeToParcelInternal(Parcel &parcel) const override; 19 | 20 | private: 21 | TextParagraph::Type type; 22 | }; 23 | 24 | 25 | #endif //NBREADER_PARAGRAPHTAG_H 26 | -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/tools/xml/SAXParserFactory.h: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2020-02-15 16:15 3 | // description : 4 | // 5 | 6 | #ifndef NBREADER_SAXPARSERFACTORY_H 7 | #define NBREADER_SAXPARSERFACTORY_H 8 | 9 | 10 | #include 11 | #include "SAXParser.h" 12 | #include "SAXParserImpl.h" 13 | 14 | class SAXParserFactory { 15 | 16 | public: 17 | static std::shared_ptr getParser() { 18 | return std::make_shared(); 19 | } 20 | 21 | private: 22 | SAXParserFactory() { 23 | } 24 | }; 25 | 26 | 27 | #endif //NBREADER_SAXPARSERFACTORY_H 28 | -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/ui/component/book/text/entity/textstyle/TextAlignmentType.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.ui.component.book.text.entity.textstyle 2 | 3 | /** 4 | * author : newbiechen 5 | * date : 2019-10-27 14:41 6 | * description : 7 | */ 8 | 9 | object TextAlignmentType{ 10 | const val ALIGN_UNDEFINED: Byte = 0 11 | const val ALIGN_LEFT: Byte = 1 12 | const val ALIGN_RIGHT: Byte = 2 13 | const val ALIGN_CENTER: Byte = 3 14 | const val ALIGN_JUSTIFY: Byte = 4 15 | const val ALIGN_LINESTART: Byte = 5 // left for LTR languages and right for RTL 16 | } -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/filesystem/UnixFileDir.h: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2019-09-25 15:49 3 | // description : 4 | // 5 | 6 | #ifndef NBREADER_UNIXFILEDIR_H 7 | #define NBREADER_UNIXFILEDIR_H 8 | 9 | 10 | #include "FileDir.h" 11 | 12 | #include 13 | 14 | class UnixFileDir : public FileDir { 15 | public: 16 | 17 | UnixFileDir(const std::string &path) : FileDir(path) { 18 | } 19 | 20 | ~UnixFileDir() { 21 | } 22 | 23 | protected: 24 | virtual void readFilePaths(std::vector &paths, bool fullPath) const ; 25 | }; 26 | 27 | 28 | #endif //NBREADER_UNIXFILEDIR_H 29 | -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/ui/component/book/text/entity/TextChapter.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.ui.component.book.text.entity 2 | 3 | /** 4 | * author : newbiechen 5 | * date : 2019-12-25 18:18 6 | * description :章节信息数据 7 | */ 8 | 9 | data class TextChapter( 10 | val url: String, 11 | val title: String, // 章节标题 12 | val startIndex: Int, // 在源文件的起始偏移值 13 | val endIndex: Int // 在源文件的终止偏移值。 如果传入 -1 表示读取到文件的末尾。 14 | ) { 15 | override fun toString(): String { 16 | return "TextChapter(url='$url', title='$title', startIndex=$startIndex, endIndex=$endIndex)" 17 | } 18 | } -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/ui/component/widget/page/OnPageListener.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.ui.component.widget.page 2 | 3 | import com.newbiechen.nbreader.ui.component.book.text.engine.PagePosition 4 | import com.newbiechen.nbreader.ui.component.book.text.engine.PageProgress 5 | 6 | /** 7 | * author : newbiechen 8 | * date : 2020/3/7 8:01 PM 9 | * description : 10 | */ 11 | interface OnPageListener { 12 | // 通知页面准备 13 | fun onPreparePage(pagePosition: PagePosition, pageProgress: PageProgress) 14 | 15 | // 通知页面改变 16 | fun onPageChange(pagePosition: PagePosition, pageProgress: PageProgress) 17 | } -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/android/filesystem/AndroidFileSystem.h: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2019-09-24 10:54 3 | // description : Android 直接沿用 UnixFileSystem,这里只是用来占位 4 | // 5 | 6 | #ifndef NBREADER_ANDROIDFILESYSTEM_H 7 | #define NBREADER_ANDROIDFILESYSTEM_H 8 | 9 | 10 | #include "../../filesystem/UnixFileSystem.h" 11 | 12 | class AndroidFileSystem : UnixFileSystem { 13 | public: 14 | static void newInstance(); 15 | }; 16 | 17 | inline void AndroidFileSystem::newInstance() { 18 | if (sInstance == nullptr) { 19 | sInstance = new AndroidFileSystem(); 20 | } 21 | } 22 | 23 | #endif //NBREADER_ANDROIDFILESYSTEM_H 24 | -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/filesystem/zip/ZipFileDir.h: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2019-09-25 16:34 3 | // description : Zip 文件目录 4 | // 5 | 6 | #ifndef NBREADER_ZIPFILEDIR_H 7 | #define NBREADER_ZIPFILEDIR_H 8 | 9 | 10 | #include "../FileDir.h" 11 | 12 | class ZipFileDir : public FileDir { 13 | public: 14 | ZipFileDir(const std::string &path) : FileDir(path) { 15 | } 16 | 17 | ~ZipFileDir() { 18 | } 19 | 20 | protected: 21 | virtual void readFilePaths(std::vector &paths, bool fullPath) const; 22 | 23 | virtual std::string getSeparator() const; 24 | }; 25 | 26 | 27 | #endif //NBREADER_ZIPFILEDIR_H 28 | -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/ui/component/book/library/IBookLibrary.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.ui.component.book.library 2 | 3 | import com.newbiechen.nbreader.data.entity.BookEntity 4 | 5 | /** 6 | * author : newbiechen 7 | * date : 2019-09-16 17:08 8 | * description :用于调用 LibraryService 的接口 9 | */ 10 | 11 | interface IBookLibrary { 12 | // 查询操作 13 | fun getBookById(id: String): BookEntity 14 | 15 | fun getBookByPath(path: String): BookEntity 16 | fun getRecentBook(): BookEntity 17 | 18 | // 存储操作 19 | fun saveBook(book: BookEntity) 20 | 21 | // 移除操作 22 | fun removeBookById(id: String) 23 | } -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/data/local/room/converter/BookTypeConverter.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.data.local.room.converter 2 | 3 | import androidx.room.TypeConverter 4 | import com.newbiechen.nbreader.ui.component.book.type.BookType 5 | 6 | /** 7 | * author : newbiechen 8 | * date : 2019-09-21 15:38 9 | * description : 10 | */ 11 | 12 | class BookTypeConverter { 13 | 14 | @TypeConverter 15 | fun strToType(type: String): BookType { 16 | return BookType.valueOf(type) 17 | } 18 | 19 | @TypeConverter 20 | fun typeToStr(bookType: BookType): String { 21 | return bookType.name 22 | } 23 | } -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/ui/component/adapter/MainPagerAdapter.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.ui.component.adapter 2 | 3 | import androidx.fragment.app.Fragment 4 | import androidx.fragment.app.FragmentManager 5 | import androidx.fragment.app.FragmentPagerAdapter 6 | import com.newbiechen.nbreader.uilts.factory.MainFragFactory 7 | 8 | class MainPagerAdapter(fm: FragmentManager, var factory: MainFragFactory) : FragmentPagerAdapter(fm) { 9 | 10 | override fun getItem(position: Int): Fragment { 11 | return factory.createFragment(position) 12 | } 13 | 14 | override fun getCount(): Int = factory.getCount() 15 | } 16 | -------------------------------------------------------------------------------- /app/src/main/res/menu/meun_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 9 | 10 | 15 | -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/ui/component/book/text/entity/TextParagraph.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.ui.component.book.text.entity 2 | 3 | /** 4 | * author : newbiechen 5 | * date : 2020-01-12 16:39 6 | * description :文本段落 7 | */ 8 | 9 | /** 10 | * @param type:段落类型,具体类型详见 11 | * @see com.newbiechen.nbreader.ui.component.book.text.entity.tag.TextParagraphType 12 | * @param indexFromChapter:段落在章节中的位置 13 | * @param startOffset:段落在章节中的起始偏移 14 | * @param endOffset:段落在章节中的终止偏移 15 | */ 16 | data class TextParagraph( 17 | val type: Byte, 18 | val indexFromChapter: Int, 19 | val startOffset: Int, 20 | val endOffset: Int 21 | ) -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/data/local/room/NBDataBase.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.data.local.room 2 | 3 | import androidx.room.Database 4 | import androidx.room.RoomDatabase 5 | import com.newbiechen.nbreader.data.entity.CatalogEntity 6 | import com.newbiechen.nbreader.data.entity.BookEntity 7 | import com.newbiechen.nbreader.data.local.room.dao.BookDao 8 | import com.newbiechen.nbreader.data.local.room.dao.CatalogDao 9 | 10 | @Database(entities = [CatalogEntity::class, BookEntity::class], version = 1) 11 | abstract class NBDataBase : RoomDatabase() { 12 | abstract fun getCatalogDao(): CatalogDao 13 | abstract fun getBookDao(): BookDao 14 | } -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/data/repository/impl/IBookRepository.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.data.repository.impl 2 | 3 | import com.newbiechen.nbreader.data.entity.BookEntity 4 | import io.reactivex.Flowable 5 | 6 | /** 7 | * author : newbiechen 8 | * date : 2020-02-04 20:56 9 | * description :书籍仓库信息 10 | */ 11 | 12 | interface IBookRepository { 13 | /** 14 | * 根据参数获取书籍 15 | * @param isCache:是否是缓存书籍 16 | */ 17 | fun getBooks(isCache: Boolean): Flowable> 18 | 19 | /** 20 | * 存储书籍 21 | */ 22 | fun saveBook(bookEntity: BookEntity) 23 | 24 | fun saveBooks(books: List) 25 | } -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/ui/component/book/text/util/TextDimenUtil.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.ui.component.book.text.util 2 | 3 | import android.content.Context 4 | import android.util.DisplayMetrics 5 | 6 | /** 7 | * author : newbiechen 8 | * date : 2019-11-07 15:18 9 | * description :文本尺寸工具 10 | */ 11 | 12 | object TextDimenUtil { 13 | 14 | fun getDisplayDPI(context: Context): Int { 15 | val metrics = getMetrics(context) 16 | return (160 * metrics.density).toInt() 17 | } 18 | 19 | private fun getMetrics(context: Context): DisplayMetrics { 20 | return context.resources.displayMetrics 21 | } 22 | } -------------------------------------------------------------------------------- /app/src/main/res/layout/item_book_list_sort.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 16 | 17 | -------------------------------------------------------------------------------- /app/src/main/res/layout/layout_page_header.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 15 | -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/data/repository/impl/IBookListRepository.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.data.repository.impl 2 | 3 | import com.newbiechen.nbreader.data.entity.NetBookListWrapper 4 | import io.reactivex.Flowable 5 | 6 | /** 7 | * author : newbiechen 8 | * date : 2019-08-05 19:41 9 | * description :书籍列表信息仓库 (NetBookPage) 10 | */ 11 | 12 | interface IBookListRepository { 13 | fun getBookList( 14 | alias: String, 15 | sort: Int, 16 | start: Int, 17 | limit: Int, 18 | cat: String? = null, 19 | isserial: Boolean? = null, 20 | updated: Int? = null 21 | ): Flowable 22 | } -------------------------------------------------------------------------------- /app/src/main/assets/hyphenationPatterns/CHANGES: -------------------------------------------------------------------------------- 1 | All the files *.pattern were produced from the original TeX files. All changes 2 | are the notation changes: 3 | * we use XML notation (file format is obvious form any sample) 4 | * '.' in patterns is replaced by ' ' 5 | * all accented characters were written as &xxx; entities, instead of TeX 6 | notation 7 | * all exceptions (\hyphenation{xxx-xx-xx} in TeX notation) were replaced 8 | with the patterns with weights 7 and 8 9 | 10 | Czech hyphenation pattern is excluded for the closed-source version of FBReader, 11 | because the original TeX file is licensed under the GNU GPL. 12 | 13 | -- Nikolay Pultsin (geometer@fbreader.org) 14 | -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/reader/text/type/TextTagType.h: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2019-12-30 14:55 3 | // description : 文本标签类型 4 | // 5 | 6 | #ifndef NBREADER_TEXTTAGTYPE_H 7 | #define NBREADER_TEXTTAGTYPE_H 8 | 9 | 10 | enum class TextTagType : char { 11 | TEXT = 1, // 文本标签 12 | IMAGE = 2, // 图片标签 13 | CONTROL = 3, // 控制标签 14 | HYPERLINK_CONTROL = 4, // 超链接控制标签 15 | STYLE_CSS = 5, 16 | STYLE_OTHER = 6, 17 | STYLE_CLOSE = 7, 18 | FIXED_HSPACE = 8, 19 | RESET_BIDI = 9, 20 | AUDIO = 10, 21 | VIDEO = 11, // 视频标签 22 | EXTENSION = 12, // 扩展标签 23 | PARAGRAPH = 13, // 段落标签 24 | }; 25 | 26 | 27 | #endif //NBREADER_TEXTTAGTYPE_H 28 | -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/data/local/room/converter/StringListConverter.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.data.local.room.converter 2 | 3 | import androidx.room.TypeConverter 4 | import com.google.gson.Gson 5 | import com.google.gson.reflect.TypeToken 6 | 7 | /** 8 | * String 列表转换器 9 | */ 10 | class StringListConverter { 11 | 12 | @TypeConverter 13 | fun jsonToObject(json: String): List { 14 | val listType = object : TypeToken>() {}.type 15 | return Gson().fromJson(json, listType) 16 | } 17 | 18 | @TypeConverter 19 | fun objectToJson(list: List): String { 20 | return Gson().toJson(list) 21 | } 22 | } -------------------------------------------------------------------------------- /app/src/main/res/menu/menu_file_system.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 10 | 11 | 15 | -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/plugin/oeb/ContainerReader.h: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2020-02-20 23:49 3 | // description : 4 | // 5 | 6 | #ifndef NBREADER_CONTAINERREADER_H 7 | #define NBREADER_CONTAINERREADER_H 8 | 9 | #include "../../tools/xml/SAXHandler.h" 10 | 11 | class ContainerReader : public SAXHandler { 12 | 13 | public: 14 | const std::string &getOpfPath() const { 15 | return opfPath; 16 | } 17 | 18 | void readFile(const File &path); 19 | 20 | protected: 21 | void 22 | startElement(std::string &localName, std::string &fullName, Attributes &attributes) override; 23 | 24 | private: 25 | std::string opfPath; 26 | }; 27 | 28 | 29 | #endif //NBREADER_CONTAINERREADER_H 30 | -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/data/entity/LocalBookEntity.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.data.entity 2 | 3 | import com.newbiechen.nbreader.ui.component.book.type.BookType 4 | 5 | /** 6 | * author : newbiechen 7 | * date : 2020-02-04 20:42 8 | * description:本地书籍信息 9 | */ 10 | 11 | data class LocalBookEntity( 12 | val id: Long, 13 | val name: String, // 书籍名 14 | val type: BookType, // 书籍类型 15 | val size: Long, // 书籍大小 16 | val lastModified: Long, // 文件的添加时间,单位:ms 17 | val path: String // 文件路径 18 | ) { 19 | override fun toString(): String { 20 | return "BookInfo(id=$id, title='$name', type=$type, size=$size, lastModified=$lastModified, path='$path')" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/data/remote/BookDetailRemoteDataSource.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.data.remote 2 | 3 | import com.newbiechen.nbreader.data.entity.NetBookDetailWrapper 4 | import com.newbiechen.nbreader.data.remote.api.BookApi 5 | import com.newbiechen.nbreader.data.repository.impl.IBookDetailRepository 6 | import io.reactivex.Flowable 7 | import javax.inject.Inject 8 | 9 | /** 10 | * author : newbiechen 11 | * date : 2019-08-14 18:31 12 | * description : 13 | */ 14 | 15 | class BookDetailRemoteDataSource @Inject constructor(private val api: BookApi) : IBookDetailRepository { 16 | override fun getBookDetail(bookId: String): Flowable = api.getBookDetail(bookId) 17 | } -------------------------------------------------------------------------------- /app/src/main/res/layout/item_tag.xml: -------------------------------------------------------------------------------- 1 | 2 | 15 | -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/di/module/FileSystemModule.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.di.module 2 | 3 | import com.newbiechen.nbreader.ui.page.filecatalog.FileCatalogFragment 4 | import com.newbiechen.nbreader.ui.page.smartlookup.SmartLookupFragment 5 | import dagger.Module 6 | import dagger.android.ContributesAndroidInjector 7 | 8 | /** 9 | * author : newbiechen 10 | * date : 2019-08-17 14:44 11 | * description : 12 | */ 13 | 14 | @Module 15 | abstract class FileSystemModule { 16 | @ContributesAndroidInjector 17 | internal abstract fun bindFileCatalogFragment(): FileCatalogFragment 18 | 19 | @ContributesAndroidInjector 20 | internal abstract fun bindSmartLookupFragment(): SmartLookupFragment 21 | } -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/uilts/FileUtil.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.uilts 2 | 3 | import android.content.Context 4 | import android.os.Environment 5 | 6 | /** 7 | * author : newbiechen 8 | * date : 2019-09-18 17:30 9 | * description : 10 | */ 11 | 12 | object FileUtil { 13 | 14 | // 获取 Cache 文件夹 15 | fun getCachePath(context: Context): String { 16 | return if (isSdCardExist()) { 17 | context.externalCacheDir.absolutePath 18 | } else { 19 | context.cacheDir.absolutePath 20 | } 21 | } 22 | 23 | //判断是否挂载了SD卡 24 | fun isSdCardExist(): Boolean { 25 | return Environment.MEDIA_MOUNTED == Environment.getExternalStorageState() 26 | } 27 | } -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/plugin/oeb/OebReader.h: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2020-02-23 11:42 3 | // description : 4 | // 5 | 6 | #ifndef NBREADER_OEBREADER_H 7 | #define NBREADER_OEBREADER_H 8 | 9 | #include 10 | #include "../../reader/text/entity/TextChapter.h" 11 | #include "../../reader/book/BookEncoder.h" 12 | #include "../../tools/xhtml/XHTMLReader.h" 13 | 14 | class OebReader { 15 | public: 16 | OebReader(); 17 | 18 | ~OebReader() { 19 | } 20 | 21 | // 读取章节信息 22 | bool readContent(TextChapter &inChapter, TextContent &outContent); 23 | 24 | private: 25 | // 书籍编码器 26 | BookEncoder mBookEncoder; 27 | 28 | XHTMLReader mXhtmlReader; 29 | }; 30 | 31 | 32 | #endif //NBREADER_OEBREADER_H 33 | -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/ui/component/book/text/entity/resource/image/TextImage.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.ui.component.book.text.entity.resource.image 2 | 3 | import android.graphics.Bitmap 4 | import android.util.Size 5 | 6 | /** 7 | * author : newbiechen 8 | * date : 2020/2/29 4:37 PM 9 | * description :文本图片接口 10 | */ 11 | 12 | // TODO:图片来源 zip、file、network 13 | // TODO:如何做图片缓存的问题 14 | // TODO:支持设置占位图片 15 | interface TextImage { 16 | /** 17 | * 图片源路径 18 | */ 19 | fun getPath(): String 20 | 21 | /** 22 | * 图片的最大尺寸 23 | */ 24 | fun getImage(maxSize: Size?): Bitmap? 25 | 26 | /** 27 | * 请求图片的大小 28 | */ 29 | fun requestImageSize(maxSize: Size?): Size? 30 | } -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/util/Boolean.h: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2020-02-15 21:43 3 | // description : 4 | // 5 | 6 | #ifndef NBREADER_BOOLEAN_H 7 | #define NBREADER_BOOLEAN_H 8 | 9 | enum class Boolean : char { 10 | FALSE = 0, 11 | TRUE = 1, 12 | UNDEFINED = 2 13 | }; 14 | 15 | inline Boolean boolToBoolean(bool value) { 16 | return value ? Boolean::TRUE : Boolean::FALSE; 17 | } 18 | 19 | inline bool booleanToBool(Boolean value, bool defaultValue) { 20 | switch (value) { 21 | default: 22 | return defaultValue; 23 | case Boolean::TRUE: 24 | return true; 25 | case Boolean::FALSE: 26 | return false; 27 | } 28 | } 29 | 30 | #endif //NBREADER_BOOLEAN_H 31 | -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/reader/text/tag/ContentTag.h: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2020/3/1 9:49 PM 3 | // description : 文本内容标签 4 | // 5 | 6 | #ifndef NBREADER_CONTENTTAG_H 7 | #define NBREADER_CONTENTTAG_H 8 | 9 | 10 | #include "TextTag.h" 11 | 12 | class ContentTag : public TextTag { 13 | public: 14 | 15 | ContentTag(const std::string &text); 16 | 17 | ContentTag(const std::vector &texts); 18 | 19 | void append(const std::string &text); 20 | 21 | void append(const std::vector &texts); 22 | 23 | protected: 24 | void writeToParcelInternal(Parcel &parcel) const override; 25 | 26 | private: 27 | std::vector mContentList; 28 | }; 29 | 30 | 31 | #endif //NBREADER_CONTENTTAG_H 32 | -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/data/local/CatalogLocalDataSource.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.data.local 2 | 3 | import com.newbiechen.nbreader.data.entity.CatalogEntity 4 | import com.newbiechen.nbreader.data.local.room.dao.CatalogDao 5 | import com.newbiechen.nbreader.data.repository.impl.ICatalogRepository 6 | import io.reactivex.Flowable 7 | import javax.inject.Inject 8 | 9 | class CatalogLocalDataSource @Inject constructor(private val catalogDao: CatalogDao) : ICatalogRepository { 10 | 11 | override fun getCatalogItems(): Flowable> = catalogDao.getAllCatalogs().toFlowable() 12 | 13 | override fun saveCatalogItems(entities: List) { 14 | catalogDao.insertCatalogs(entities) 15 | } 16 | } -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/tools/font/FontManager.cpp: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2019-10-06 16:56 3 | // description : 4 | // TODO:暂未实现 5 | 6 | #include "FontManager.h" 7 | 8 | std::string FontManager::put(const std::string &family, std::shared_ptr entry) { 9 | return std::string(); 10 | } 11 | 12 | const std::map > &FontManager::entries() const { 13 | return std::map >(); 14 | } 15 | 16 | int FontManager::familyListIndex(const std::vector &familyList) { 17 | return 0; 18 | } 19 | 20 | /*const std::vector > &FontManager::familyLists() const { 21 | return std::vector>(); 22 | }*/ 23 | 24 | -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/ui/component/widget/page/anim/IPageAnimation.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.ui.component.widget.page.anim 2 | 3 | import android.graphics.Canvas 4 | import android.view.MotionEvent 5 | import com.newbiechen.nbreader.ui.component.widget.page.action.MotionAction 6 | 7 | /** 8 | * author : newbiechen 9 | * date : 2020/3/7 9:31 AM 10 | * description : 11 | */ 12 | interface IPageAnimation { 13 | /** 14 | * 设置视口 15 | */ 16 | fun setViewPort(w: Int, h: Int) 17 | 18 | /** 19 | * 传递点击行为 20 | */ 21 | fun onTouchEvent(action: MotionAction): Boolean 22 | 23 | fun draw(canvas: Canvas) 24 | 25 | fun startAnim() 26 | 27 | fun abortAnim() 28 | 29 | fun computeScroll() 30 | } -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/plugin/EncodingTextReader.h: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2019-09-24 14:51 3 | // description : 处理编码问题的 Reader 4 | // 5 | 6 | #ifndef NBREADER_ENCODINGTEXTREADER_H 7 | #define NBREADER_ENCODINGTEXTREADER_H 8 | 9 | #include 10 | #include "../filesystem/charset/CharsetConverter.h" 11 | 12 | class EncodingTextReader { 13 | 14 | public: 15 | // 进行转码操作 16 | void convert(std::string &dst, const char *srcStart, const char *srcEnd); 17 | 18 | protected: 19 | // 传入编码类型 20 | EncodingTextReader(const std::string &charset); 21 | 22 | virtual ~EncodingTextReader() { 23 | } 24 | 25 | private: 26 | // 编码转换器 27 | CharsetConverter mConverter; 28 | }; 29 | 30 | 31 | #endif //NBREADER_ENCODINGTEXTREADER_H 32 | -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/reader/text/entity/TextContent.h: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2020/2/28 10:18 PM 3 | // description : 文本内容 4 | // 5 | 6 | #ifndef NBREADER_TEXTCONTENT_H 7 | #define NBREADER_TEXTCONTENT_H 8 | 9 | 10 | #include 11 | 12 | class TextContent { 13 | 14 | public: 15 | char *resourcePtr; 16 | size_t resourceSize; 17 | char *contentPtr; 18 | size_t contentSize; 19 | 20 | TextContent(); 21 | 22 | TextContent(char *resourcePtr, size_t resourceSize,char *contentPtr, size_t contentSize); 23 | 24 | bool isInitialized() { 25 | return hasInitialized; 26 | } 27 | 28 | void release(); 29 | 30 | private: 31 | bool hasInitialized; 32 | }; 33 | 34 | 35 | #endif //NBREADER_TEXTCONTENT_H 36 | -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/android/application/AndroidFormatPluginApp.h: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2019-10-14 11:10 3 | // description : 4 | // 5 | 6 | #ifndef NBREADER_ANDROIDFORMATPLUGINAPP_H 7 | #define NBREADER_ANDROIDFORMATPLUGINAPP_H 8 | 9 | 10 | #include "../../NBBookApp.h" 11 | 12 | class AndroidFormatPluginApp : NBBookApp { 13 | public: 14 | // 创建 app 15 | static void newInstance(); 16 | 17 | private: 18 | void initApp(JavaVM *jvm) override; 19 | 20 | public: 21 | 22 | std::string language() override; 23 | 24 | std::string version() override; 25 | 26 | private: 27 | AndroidFormatPluginApp() { 28 | } 29 | 30 | ~AndroidFormatPluginApp() { 31 | } 32 | }; 33 | 34 | 35 | #endif //NBREADER_ANDROIDFORMATPLUGINAPP_H 36 | -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/data/entity/CatalogLabelEntity.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.data.entity 2 | 3 | import com.google.gson.annotations.SerializedName 4 | 5 | /** 6 | * author : newbiechen 7 | * date : 2019-08-02 20:14 8 | * description :目录标签 9 | */ 10 | 11 | data class CatalogLabelWrapper( 12 | @SerializedName("female") 13 | val female: List, 14 | @SerializedName("male") 15 | val male: List, 16 | val ok: Boolean 17 | ) 18 | 19 | data class CatalogLabelEntity( 20 | @SerializedName("gender") 21 | val gender: String, 22 | // 标签目录 23 | @SerializedName("major") 24 | val major: String, 25 | // 子标签 26 | @SerializedName("mins") 27 | val mins: List 28 | ) -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/ui/component/book/text/entity/resource/TextAttribute.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.ui.component.book.text.entity.resource 2 | 3 | import com.newbiechen.nbreader.ui.component.book.text.parcel.TextParcel 4 | 5 | /** 6 | * author : newbiechen 7 | * date : 2020/3/2 5:24 PM 8 | * description : 9 | */ 10 | 11 | // 资源属性标记 12 | interface TextAttribute 13 | 14 | // 图片资源属性 15 | data class TextImageAttr( 16 | val id: String, 17 | val path: String 18 | ) : TextAttribute { 19 | constructor(parcel: TextParcel) : this( 20 | parcel.readString16(), 21 | parcel.readString16() 22 | ) 23 | 24 | override fun toString(): String { 25 | return "TextImageAttr(id='$id', path='$path')" 26 | } 27 | 28 | } -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/ui/component/widget/page/anim/IPageAnimCallback.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.ui.component.widget.page.anim 2 | 3 | import android.graphics.Bitmap 4 | import com.newbiechen.nbreader.ui.component.widget.page.PageType 5 | 6 | /** 7 | * author : newbiechen 8 | * date : 2020-01-26 16:13 9 | * description :页面动画回调 10 | */ 11 | 12 | interface IPageAnimCallback { 13 | /** 14 | * 动画页面大小改变 15 | */ 16 | fun onPageSizeChanged(w: Int, h: Int) 17 | 18 | /** 19 | * 是否页面存在 20 | */ 21 | fun hasPage(type: PageType): Boolean 22 | 23 | /** 24 | * 获取页面 25 | */ 26 | fun getPage(type: PageType): Bitmap 27 | 28 | /** 29 | * 请求翻页 30 | */ 31 | fun turnPage(type: PageType) 32 | } -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/ui/page/base/BaseViewModel.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.ui.page.base 2 | 3 | import androidx.lifecycle.ViewModel 4 | import io.reactivex.disposables.CompositeDisposable 5 | import io.reactivex.disposables.Disposable 6 | 7 | abstract class BaseViewModel : ViewModel() { 8 | 9 | private var compositeDisposable = CompositeDisposable() 10 | 11 | protected fun addDisposable(disposable: Disposable) { 12 | compositeDisposable.add(disposable) 13 | } 14 | 15 | protected fun addAllDisposable(vararg disposable: Disposable) { 16 | compositeDisposable.addAll(*disposable) 17 | } 18 | 19 | override fun onCleared() { 20 | super.onCleared() 21 | compositeDisposable.clear() 22 | } 23 | } -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/tools/xml/SAXParser.h: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2020-02-15 16:15 3 | // description : 4 | // 5 | 6 | #ifndef NBREADER_SAXPARSER_H 7 | #define NBREADER_SAXPARSER_H 8 | 9 | 10 | #include 11 | #include "../../filesystem/io/InputStream.h" 12 | #include "../../filesystem/File.h" 13 | 14 | class SAXHandler; 15 | 16 | class SAXParser { 17 | public: 18 | SAXParser() { 19 | }; 20 | 21 | virtual ~SAXParser() { 22 | }; 23 | 24 | void parse(const std::string &path, SAXHandler &handler); 25 | 26 | void parse(const File &file, SAXHandler &handler); 27 | 28 | virtual void parse(std::shared_ptr &is, SAXHandler &handler) = 0; 29 | 30 | virtual void reset() = 0; 31 | }; 32 | 33 | #endif //NBREADER_SAXPARSER_H 34 | -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/ui/component/extension/ToolbarExt.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.ui.component.extension 2 | 3 | import androidx.appcompat.widget.Toolbar 4 | import com.newbiechen.nbreader.uilts.SystemBarUtil 5 | 6 | /** 7 | * author : newbiechen 8 | * date : 2019-08-30 11:20 9 | * description : 10 | */ 11 | 12 | /** 13 | * 解决 toolbar 顶到 statusBar 的问题 14 | */ 15 | fun Toolbar.overlayStatusBar() { 16 | // 获取当前 statusbar 的高度 17 | var statusBarHeight = SystemBarUtil.getStatusBarHeight(context) 18 | // 重新计算 toolbar 的高度 19 | var resultPaddingTop = statusBarHeight + paddingTop 20 | // 重置高度 21 | layoutParams.height += statusBarHeight 22 | // 重置 padding 23 | setPadding(paddingLeft, resultPaddingTop, paddingRight, paddingBottom) 24 | } -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/data/repository/BookDetailRepository.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.data.repository 2 | 3 | import com.newbiechen.nbreader.data.entity.NetBookDetailWrapper 4 | import com.newbiechen.nbreader.data.repository.impl.IBookDetailRepository 5 | import com.newbiechen.nbreader.di.annotation.qualifier.RemoteData 6 | import io.reactivex.Flowable 7 | import javax.inject.Inject 8 | 9 | /** 10 | * author : newbiechen 11 | * date : 2019-08-14 18:33 12 | * description : 13 | */ 14 | 15 | class BookDetailRepository @Inject constructor(@RemoteData private val remoteDataSource: IBookDetailRepository) : 16 | IBookDetailRepository { 17 | override fun getBookDetail(bookId: String): Flowable = remoteDataSource.getBookDetail(bookId) 18 | } -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/NBBookApp.h: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2019-10-06 19:18 3 | // description : 全局上下文抽象类 4 | // 5 | 6 | #ifndef NBREADER_NBBOOKAPP_H 7 | #define NBREADER_NBBOOKAPP_H 8 | 9 | #include 10 | #include 11 | 12 | class NBBookApp { 13 | public: 14 | static NBBookApp &getInstance() { 15 | return *sInstance; 16 | } 17 | 18 | static void deleteInstance(); 19 | 20 | // 初始应用 21 | virtual void initApp(JavaVM *jvm) = 0; 22 | 23 | // 获取平台对应的语言 24 | virtual std::string language() = 0; 25 | 26 | // 获取平台对应的版本 27 | virtual std::string version() = 0; 28 | 29 | protected: 30 | static NBBookApp *sInstance; 31 | 32 | NBBookApp() {} 33 | 34 | virtual ~NBBookApp() {} 35 | }; 36 | 37 | #endif //NBREADER_NBBOOKAPP_H 38 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/newbiechen/nbreader/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader 2 | 3 | import androidx.test.InstrumentationRegistry 4 | import androidx.test.runner.AndroidJUnit4 5 | 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | import org.junit.Assert.* 10 | 11 | /** 12 | * Instrumented test, which will execute on an Android device. 13 | * 14 | * See [testing documentation](http://d.android.com/tools/testing). 15 | */ 16 | @RunWith(AndroidJUnit4::class) 17 | class ExampleInstrumentedTest { 18 | @Test 19 | fun useAppContext() { 20 | // Context of the app under test. 21 | val appContext = InstrumentationRegistry.getTargetContext() 22 | assertEquals("com.newbiechen.nbreader", appContext.packageName) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/ui/component/binding/ImageViewBinding.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.ui.component.binding 2 | 3 | import android.text.TextUtils 4 | import android.widget.ImageView 5 | import androidx.databinding.BindingAdapter 6 | import com.bumptech.glide.Glide 7 | import com.newbiechen.nbreader.R 8 | 9 | object ImageViewBinding { 10 | 11 | @BindingAdapter("app:url") 12 | @JvmStatic 13 | fun ImageView.loadImage(url: String?) { 14 | if (TextUtils.isEmpty(url)) { 15 | return 16 | } 17 | 18 | Glide.with(context) 19 | .load(url) 20 | .placeholder(R.drawable.ic_image_loading) 21 | .error(R.drawable.ic_image_load_error) 22 | .override(200, 200) 23 | .into(this) 24 | } 25 | } -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/tools/language/StatisticsNativeReader.h: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2019-10-18 17:15 3 | // description : 将本地文字转换成 Statistics 标签数据 4 | // 5 | 6 | #ifndef NBREADER_STATISTICSNATIVEREADER_H 7 | #define NBREADER_STATISTICSNATIVEREADER_H 8 | 9 | #include 10 | #include "StatisticsTag.h" 11 | 12 | class StatisticsNativeReader { 13 | 14 | public: 15 | StatisticsNativeReader(const std::string &breakSymbols); 16 | 17 | ~StatisticsNativeReader(); 18 | 19 | void readNativeStatistics(const char *buffer, std::size_t length, 20 | std::size_t charSequenceSize, 21 | NativeStatisticsTag &statistics); 22 | 23 | private: 24 | char *mBreakSymbolsTable; 25 | }; 26 | 27 | 28 | #endif //NBREADER_STATISTICSNATIVEREADER_H 29 | -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/util/Logger.h: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2019-09-24 17:29 3 | // description : 4 | // 5 | 6 | #ifndef NBREADER_LOGGER_H 7 | #define NBREADER_LOGGER_H 8 | 9 | #include 10 | #include 11 | 12 | class Logger { 13 | public: 14 | static const std::string TAG; 15 | 16 | static void i(const std::string &subTag,const std::string &msg); 17 | static void w(const std::string &subTag,const std::string &msg); 18 | static void d(const std::string &subTag,const std::string &msg); 19 | static void e(const std::string &subTag,const std::string &msg); 20 | private: 21 | Logger(); 22 | 23 | static void printLogger(android_LogPriority logPriority, const std::string &subTag, const std::string &msg); 24 | }; 25 | 26 | 27 | #endif //NBREADER_LOGGER_H 28 | -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/ui/component/book/text/entity/resource/image/TextImageFactory.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.ui.component.book.text.entity.resource.image 2 | 3 | import com.newbiechen.nbreader.ui.component.book.text.util.TextConstants 4 | import java.io.File 5 | 6 | /** 7 | * author : newbiechen 8 | * date : 2020/2/29 8:22 PM 9 | * description :文本图片构建器 10 | */ 11 | 12 | object TextImageFactory { 13 | 14 | fun getTextImage(path: String): TextImage? { 15 | // 是否是 http 16 | // 检测是否是 ftp 17 | // 检测是否路径 18 | File.separator 19 | // 检测路径是否存在 :,表示 zip 20 | // TODO:现在暂时只有 zip 的情况 21 | return if (path.contains(TextConstants.zipSeparator)) { 22 | TextZipImage(path) 23 | } else { 24 | null 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/ui/component/book/text/entity/textstyle/TreeTextStyle.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.ui.component.book.text.entity.textstyle 2 | 3 | import com.newbiechen.nbreader.ui.component.book.text.entity.TextMetrics 4 | 5 | /** 6 | * author : newbiechen 7 | * date : 2019-10-26 15:57 8 | * description :文本样式接口类 9 | */ 10 | 11 | abstract class TreeTextStyle(parentStyle: TreeTextStyle?) : TextStyle { 12 | // abstract fun getFontEntries(): List 13 | open val parent: TreeTextStyle? = parentStyle 14 | 15 | fun getLeftIndent(metrics: TextMetrics): Int { 16 | return getLeftMargin(metrics) + getLeftPadding(metrics) 17 | } 18 | 19 | fun getRightIndent(metrics: TextMetrics): Int { 20 | return getRightMargin(metrics) + getRightPadding(metrics) 21 | } 22 | } -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/filesystem/zip/ZipDecompressor.h: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2019-09-26 20:06 3 | // description : zip 解析器 4 | // 5 | 6 | #ifndef NBREADER_ZIPDECOMPRESSOR_H 7 | #define NBREADER_ZIPDECOMPRESSOR_H 8 | 9 | #include 10 | #include "../io/InputStream.h" 11 | #include 12 | #include 13 | 14 | class ZipDecompressor { 15 | public: 16 | ZipDecompressor(size_t availableSize); 17 | 18 | ~ZipDecompressor(); 19 | 20 | size_t decompress(InputStream &stream, char *buffer, size_t maxSize); 21 | 22 | private: 23 | // zip 流 24 | z_stream *mZStream; 25 | // zip 可解析的数据大小 26 | size_t mAvailableSize; 27 | char *mInBuffer; 28 | char *mOutBuffer; 29 | std::string mBuffer; // 作者用 string 代替 char * 作为缓冲区 30 | }; 31 | 32 | 33 | #endif //NBREADER_ZIPDECOMPRESSOR_H 34 | -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/ui/component/adapter/SimpleTagAdapter.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.ui.component.adapter 2 | 3 | import android.view.LayoutInflater 4 | import android.view.View 5 | import android.widget.TextView 6 | import com.newbiechen.nbreader.R 7 | import com.zhy.view.flowlayout.FlowLayout 8 | import com.zhy.view.flowlayout.TagAdapter 9 | 10 | /** 11 | * author : newbiechen 12 | * date : 2019-08-16 16:44 13 | * description : 14 | */ 15 | 16 | class SimpleTagAdapter(datas: List?) : TagAdapter(datas) { 17 | override fun getView(parent: FlowLayout?, position: Int, t: String?): View { 18 | val tvTag = LayoutInflater.from(parent!!.context) 19 | .inflate(R.layout.item_tag, parent, false) as TextView 20 | tvTag.text = t 21 | return tvTag 22 | } 23 | } -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/filesystem/io/OutputStream.h: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2019-09-24 11:12 3 | // description : 输出流抽象类 4 | // 5 | 6 | #ifndef NBREADER_OUTPUTSTREAM_H 7 | #define NBREADER_OUTPUTSTREAM_H 8 | 9 | #include 10 | #include 11 | 12 | class OutputStream { 13 | public: 14 | virtual ~OutputStream(); 15 | virtual bool open() = 0; 16 | virtual void write(const char *data, size_t len) = 0; 17 | virtual void write(const std::string &str) = 0; 18 | virtual void close() = 0; 19 | protected: 20 | OutputStream(); 21 | 22 | /*private: 23 | OutputStream(const OutputStream&); 24 | const OutputStream &operator = (const OutputStream&);*/ 25 | }; 26 | 27 | inline OutputStream::OutputStream() {} 28 | inline OutputStream::~OutputStream() {} 29 | 30 | #endif //NBREADER_OUTPUTSTREAM_H 31 | -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/data/local/room/dao/BookDao.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.data.local.room.dao 2 | 3 | import androidx.room.* 4 | import com.newbiechen.nbreader.data.entity.BookEntity 5 | import io.reactivex.Maybe 6 | 7 | /** 8 | * author : newbiechen 9 | * date : 2019-09-16 17:22 10 | * description :阅读器书籍数据 11 | */ 12 | 13 | @Dao 14 | interface BookDao { 15 | 16 | @Insert(onConflict = OnConflictStrategy.REPLACE) 17 | fun insertBook(book: BookEntity) 18 | 19 | @Insert(onConflict = OnConflictStrategy.REPLACE) 20 | fun insertBooks(books: List) 21 | 22 | @Update 23 | fun updateBook(book: BookEntity) 24 | 25 | @Delete 26 | fun removeBook(book: BookEntity) 27 | 28 | @Query("SELECT * FROM book_entity") 29 | fun getAllBooks(): Maybe> 30 | } 31 | -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/ui/component/binding/TabLayoutBinding.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.ui.component.binding 2 | 3 | import androidx.databinding.BindingAdapter 4 | import com.newbiechen.nbreader.ui.component.widget.TabView 5 | import com.google.android.material.tabs.TabLayout 6 | 7 | object TabLayoutBinding { 8 | 9 | @BindingAdapter("app:currentPos") 10 | @JvmStatic 11 | fun TabLayout.setCurrentItem(index: Int) { 12 | var tabView: TabView? 13 | for (i in 0 until tabCount) { 14 | tabView = getTabAt(i)?.customView as TabView? 15 | if (i == selectedTabPosition) { 16 | getTabAt(i)!!.select() 17 | tabView?.setChecked(true) 18 | } else { 19 | tabView?.setChecked(false) 20 | } 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/ui/component/book/text/config/TextConfigure.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.ui.component.book.text.config 2 | 3 | import android.graphics.Bitmap 4 | import android.graphics.drawable.Drawable 5 | 6 | /** 7 | * author : newbiechen 8 | * date : 2020/3/11 3:01 PM 9 | * description : 10 | * TODO:感觉除了 margin 之外都可放在 DefaultStyle 中,先把框架搭建起来。 11 | */ 12 | 13 | interface TextConfigure { 14 | /** 15 | * 文本距离页面左边的间距 16 | */ 17 | fun getMarginLeft(): Int 18 | 19 | /** 20 | * 文本距离页面右边的间距 21 | */ 22 | fun getMarginRight(): Int 23 | 24 | fun getMarginTop(): Int 25 | 26 | fun getMarginBottom(): Int 27 | 28 | // todo:textColor 放这里合理吗 29 | fun getTextColor(): Int 30 | 31 | /** 32 | * 获取背景 33 | */ 34 | fun getBackground(): Drawable? 35 | } -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/tools/font/FontManager.h: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2019-10-06 16:56 3 | // description : 字体管理器 4 | // 5 | 6 | #ifndef NBREADER_FONTMANAGER_H 7 | #define NBREADER_FONTMANAGER_H 8 | 9 | #include 10 | #include 11 | #include "FontMap.h" 12 | 13 | class FontManager { 14 | 15 | public: 16 | std::string put(const std::string &family, std::shared_ptr entry); 17 | int familyListIndex(const std::vector &familyList); 18 | 19 | const std::map > &entries() const; 20 | // const std::vector > &familyLists() const; 21 | 22 | private: 23 | std::map > mEntries; 24 | std::vector > mFamilyLists; 25 | }; 26 | 27 | #endif //NBREADER_FONTMANAGER_H 28 | -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/filesystem/FileDir.cpp: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2019-09-25 15:19 3 | // description : 4 | // 5 | 6 | #include "FileDir.h" 7 | #include "FileSystem.h" 8 | 9 | 10 | FileDir::FileDir(const std::string &path) : mPath(path) { 11 | } 12 | 13 | void FileDir::readFileNames(std::vector &names) const { 14 | readFilePaths(names, false); 15 | } 16 | 17 | void FileDir::readFilePaths(std::vector &paths) const { 18 | readFilePaths(paths, true); 19 | } 20 | 21 | std::string FileDir::fileNameToPath(const std::string &name) const { 22 | // TODO:需要 ../xxx 的情况 23 | // TODO:需要考虑将 path 当做 name 传入的情况。 如 /xxx/text.xx/xx.aas 24 | // TODO:需要考虑传入的 .. 返回上一级的情况。 25 | return mPath + getSeparator() + name; 26 | } 27 | 28 | std::string FileDir::getSeparator() const { 29 | return FileSystem::separator; 30 | } -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/filesystem/zip/ZipFileDir.cpp: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2019-09-25 16:34 3 | // description : 4 | // 5 | 6 | #include "ZipFileDir.h" 7 | #include "ZipEntry.h" 8 | #include "ZipEntryManager.h" 9 | #include "../FileSystem.h" 10 | 11 | void ZipFileDir::readFilePaths(std::vector &paths, bool fullPath) const { 12 | // 从 Zip 管理器中获取 ZipEntry 信息 13 | std::shared_ptr entry = ZipEntryManager::getInstance().getZipEntry(getPath()); 14 | 15 | // 将 item 的名字存储到 path 中 16 | entry->readItemNames(paths); 17 | 18 | // 如果请求的是完整路径,需要添加前缀 19 | if (fullPath) { 20 | for (auto it = paths.begin(); it != paths.end(); ++it) { 21 | *it = fileNameToPath(*it); 22 | } 23 | } 24 | } 25 | 26 | std::string ZipFileDir::getSeparator() const { 27 | return FileSystem::archiveSeparator; 28 | } -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/ui/component/book/text/entity/TextMetrics.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.ui.component.book.text.entity 2 | 3 | /** 4 | * author : newbiechen 5 | * date : 2019-10-26 14:59 6 | * description :文本尺寸 7 | */ 8 | 9 | data class TextMetrics(val dpi: Int, val fullWidth: Int, val fullHeight: Int, val fontSize: Int) { 10 | 11 | override fun equals(o: Any?): Boolean { 12 | if (o === this) { 13 | return true 14 | } 15 | if (o !is TextMetrics) { 16 | return false 17 | } 18 | val oo = o as TextMetrics? 19 | return dpi == oo!!.dpi && 20 | fullWidth == oo.fullHeight && 21 | fontSize == oo.fontSize 22 | } 23 | 24 | override fun hashCode(): Int { 25 | return dpi + 13 * (fullHeight + 13 * fullWidth) 26 | } 27 | } -------------------------------------------------------------------------------- /app/src/main/res/layout/item_smart_lookup_head.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 11 | 12 | 19 | 20 | -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/filesystem/io/InputStreamReader.cpp: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2019-11-29 23:39 3 | // description : 4 | // 5 | 6 | #include "InputStreamReader.h" 7 | 8 | 9 | InputStreamReader::InputStreamReader(std::shared_ptr inputStream, 10 | const std::string &charset) 11 | : mStreamDecoder(inputStream, charset) { 12 | } 13 | 14 | InputStreamReader::~InputStreamReader() { 15 | close(); 16 | } 17 | 18 | bool InputStreamReader::open() { 19 | return mStreamDecoder.open(); 20 | } 21 | 22 | int InputStreamReader::read(char *buffer, size_t length) { 23 | return mStreamDecoder.read(buffer, length); 24 | } 25 | 26 | void InputStreamReader::close() { 27 | mStreamDecoder.close(); 28 | } 29 | 30 | bool InputStreamReader::isFinish() const { 31 | return mStreamDecoder.isFinish(); 32 | } 33 | -------------------------------------------------------------------------------- /app/src/main/res/layout/layout_page.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 11 | 12 | 17 | 18 | 23 | -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/reader/text/entity/TextParagraph.h: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2019-12-30 14:32 3 | // description :文本段落信息 4 | #ifndef NBREADER_TEXTPARAGRAPH_H 5 | #define NBREADER_TEXTPARAGRAPH_H 6 | 7 | // 默认段落 8 | struct TextParagraph { 9 | // 段落类型 10 | enum Type { 11 | TEXT_PARAGRAPH = 0, // 文本段落 12 | TREE_PARAGRAPH = 1, // 目录段落 13 | EMPTY_LINE_PARAGRAPH = 2, // 空行段落 14 | BEFORE_SKIP_PARAGRAPH = 3, 15 | AFTER_SKIP_PARAGRAPH = 4, 16 | END_OF_SECTION_PARAGRAPH = 5, 17 | PSEUDO_END_OF_SECTION_PARAGRAPH = 6, 18 | END_OF_TEXT_PARAGRAPH = 7, 19 | ENCRYPTED_SECTION_PARAGRAPH = 8, 20 | }; 21 | 22 | TextParagraph(Type paragraphType = TEXT_PARAGRAPH) : type(paragraphType) { 23 | } 24 | 25 | // 段落类型 26 | Type type; 27 | }; 28 | 29 | 30 | #endif //NBREADER_TEXTPARAGRAPH_H 31 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/res/layout/layout_book_shelf_empty.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/uilts/StringUtil.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.uilts 2 | 3 | import java.text.DecimalFormat 4 | import kotlin.math.log10 5 | import kotlin.math.pow 6 | 7 | /** 8 | * author : newbiechen 9 | * date : 2019-08-06 15:29 10 | * description : 11 | */ 12 | 13 | object StringUtil { 14 | 15 | /** 16 | * 存储大小转化成字符串 17 | */ 18 | fun size2Str(size: Long): String { 19 | if (size <= 0) return "0" 20 | val units = arrayOf("B", "KB", "M", "G", "T") 21 | //计算单位的,原理是利用lg,公式是 lg(1024^n) = nlg(1024),最后 nlg(1024)/lg(1024) = n。 22 | val digitGroups = (log10(size.toDouble()) / log10(1024.0)).toInt() 23 | //计算原理是,size/单位值。单位值指的是:比如说b = 1024,KB = 1024^2 24 | return DecimalFormat("#,##0.##").format( 25 | size / 1024.0.pow(digitGroups.toDouble()) 26 | ) + " " + units[digitGroups] 27 | } 28 | } -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/plugin/PluginManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by 陈广祥 on 2019-09-18. 3 | // 4 | 5 | #ifndef NBREADER_PLUGINMANAGER_H 6 | #define NBREADER_PLUGINMANAGER_H 7 | 8 | #include 9 | #include "FormatPlugin.h" 10 | 11 | class PluginManager { 12 | public: 13 | /** 14 | * 创建解析器 15 | * @param type:解析器类型 16 | * @return 17 | */ 18 | static std::shared_ptr createFormatPlugin(const std::string &type); 19 | 20 | /** 21 | * 获取支持的解析格式 22 | */ 23 | static void readSupportFormat(std::vector &formats); 24 | 25 | /** 26 | * 是否是支持的编码类型 27 | * @param format 编码类型 28 | * @return 29 | */ 30 | static bool isSupportFormat(const std::string &format); 31 | 32 | private: 33 | // 编码类型列表 34 | static std::vector sFormatTypeList; 35 | }; 36 | 37 | #endif //NBREADER_PLUGINMANAGER_H 38 | -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/tools/language/StatisticsXMLReader.h: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2019-10-17 18:36 3 | // description : 对资源文件中的 xml 文件进行解析 4 | // 5 | 6 | #ifndef NBREADER_STATISTICSXMLREADER_H 7 | #define NBREADER_STATISTICSXMLREADER_H 8 | 9 | 10 | #include "StatisticsTag.h" 11 | #include "../xml/XMLReader.h" 12 | 13 | class StatisticsXMLReader : public XMLReader { 14 | public: 15 | std::shared_ptr readStatisticsTag(const std::string &fileName); 16 | 17 | void startElementHandler(const char *tag, const char **attributes); 18 | 19 | private: 20 | std::shared_ptr mStatisticsPtr; 21 | 22 | private: 23 | static const std::string ITEM_TAG; 24 | static const std::string STATISTICS_TAG; 25 | static std::map > statisticsMap; 26 | }; 27 | 28 | 29 | #endif //NBREADER_STATISTICSXMLREADER_H 30 | -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/data/entity/NetBookDetailEntity.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.data.entity 2 | 3 | /** 4 | * author : newbiechen 5 | * date : 2019-08-14 14:27 6 | * description : 7 | */ 8 | 9 | data class NetBookDetailWrapper( 10 | val _id: String, 11 | val author: String, 12 | val chaptersCount: Int, 13 | val contentType: String, 14 | val cover: String, 15 | val latelyFollower: Int, 16 | val isSerial: Boolean, 17 | val lastChapter: String, 18 | val longIntro: String, 19 | val majorCate: String, 20 | val minorCate: String, 21 | val retentionRatio: String, 22 | val rating: BookRating, 23 | val tags: List, 24 | val title: String, 25 | val updated: String, 26 | val wordCount: Int 27 | ) 28 | 29 | data class BookRating( 30 | val count: Int, 31 | val score: Double, 32 | val tip: String 33 | ) -------------------------------------------------------------------------------- /doc/support_html_tag.md: -------------------------------------------------------------------------------- 1 | # HTML:支持的标签(3月9日) 2 | 3 | HTML 标签划分为两类: 4 | 5 | 1. 功能标签:有布局标签(如:body、div)、资源标签(如:img、video) 6 | 2. 控制标签:控制内容样式的标签,如 h1 ~ h6、strong、em、code 等。 7 | 8 | 下面描述的标签,并不是每个都支持,还需要处理 9 | 10 | ## 功能标签 11 | 12 | 主要有如下标签: 13 | 14 | 1. body 15 | 2. aside 16 | 3. style 17 | 4. ol: 18 | 5. ul: 19 | 6. li: 20 | 7. a: 21 | 8. img: 22 | 9. object: 23 | 10. image: 24 | 11. svg: 25 | 12. div: 26 | 13. dt: 27 | 14. link: 28 | 15. pre: 29 | 16. td: 30 | 17. th: 31 | 19. source: 32 | 33 | ## 控制标签 34 | 35 | 主要有如下标签: 36 | 37 | 1. p: 38 | 2. h1: 39 | 3. h2: 40 | 4. h3: 41 | 5. h4: 42 | 6. h5: 43 | 7. h6: 44 | 8. strong: 45 | 9. b: 46 | 10. em: 47 | 11. i: 48 | 12. code: 49 | 13. tt: 50 | 14. kbd: 51 | 15. var: 52 | 16. samp: 53 | 17. cite 54 | 18. sup: 55 | 19. sub: 56 | 20. dd: 57 | 21. dfn: 58 | 22. strike: 59 | 60 | 这些控制标签对应 NBReader 的 ControlTag ,每个标签样式对应 TextKind。 61 | 62 | 支持使用 control.css 配置 TextKind 的样式。 -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/plugin/oeb/ContainerReader.cpp: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2020-02-20 23:49 3 | // description : 4 | // 5 | 6 | #include "ContainerReader.h" 7 | #include "../../util/UnicodeUtil.h" 8 | #include "../../tools/xml/SAXParserFactory.h" 9 | 10 | void ContainerReader::readFile(const File &path) { 11 | auto parser = SAXParserFactory::getParser(); 12 | parser->parse(path, *this); 13 | } 14 | 15 | void ContainerReader::startElement(std::string &localName, std::string &fullName, 16 | Attributes &attributes) { 17 | const std::string tagString = UnicodeUtil::toLower(fullName); 18 | if (tagString == "rootfile") { 19 | // 这是指向 opf path 的路径 20 | std::string fullPath = attributes.getValue("full-path"); 21 | if (!fullPath.empty()) { 22 | opfPath = fullPath; 23 | interrupt(); 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/uilts/NumberUtil.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.uilts 2 | 3 | import android.content.Context 4 | import com.newbiechen.nbreader.R 5 | import java.text.DecimalFormat 6 | 7 | /** 8 | * author : newbiechen 9 | * date : 2019-08-16 15:50 10 | * description : 11 | */ 12 | 13 | object NumberUtil { 14 | 15 | private const val TEN_THOUSAND = 10000 16 | 17 | /** 18 | * @param count 将数值缩小 19 | */ 20 | fun convertNumber(context: Context, count: Long): String { 21 | val df = DecimalFormat("#") 22 | if (count < TEN_THOUSAND) { 23 | return count.toString() 24 | } else if (count >= TEN_THOUSAND) { 25 | val countNumber = count / TEN_THOUSAND 26 | return df.format(countNumber) + context.resources.getString(R.string.common_ten_thousand) 27 | } 28 | return count.toString() 29 | } 30 | } -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/data/remote/BookListRemoteDataSource.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.data.remote 2 | 3 | import com.newbiechen.nbreader.data.entity.NetBookListWrapper 4 | import com.newbiechen.nbreader.data.remote.api.BookApi 5 | import com.newbiechen.nbreader.data.repository.impl.IBookListRepository 6 | import io.reactivex.Flowable 7 | import javax.inject.Inject 8 | 9 | /** 10 | * author : newbiechen 11 | * date : 2019-08-05 19:47 12 | * description : 13 | */ 14 | 15 | class BookListRemoteDataSource @Inject constructor(private val api: BookApi) : IBookListRepository { 16 | override fun getBookList( 17 | alias: String, 18 | sort: Int, 19 | start: Int, 20 | limit: Int, 21 | cat: String?, 22 | isserial: Boolean?, 23 | updated: Int? 24 | ): Flowable = api.getBookList(alias, sort, cat, isserial, updated, start, limit) 25 | } -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/NBApplication.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader 2 | 3 | import android.content.Context 4 | import com.newbiechen.nbreader.di.component.DaggerAppComponent 5 | import com.facebook.stetho.Stetho 6 | import dagger.android.AndroidInjector 7 | import dagger.android.DaggerApplication 8 | 9 | class NBApplication : DaggerApplication() { 10 | 11 | private lateinit var androidInjector: AndroidInjector 12 | 13 | override fun onCreate() { 14 | super.onCreate() 15 | 16 | Stetho.initializeWithDefaults(this) 17 | } 18 | 19 | override fun attachBaseContext(base: Context?) { 20 | super.attachBaseContext(base) 21 | 22 | androidInjector = DaggerAppComponent.builder() 23 | .application(this).build() 24 | } 25 | 26 | public override fun applicationInjector(): AndroidInjector = androidInjector 27 | 28 | } -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/ui/component/widget/page/DefaultActionCallback.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.ui.component.widget.page 2 | 3 | import com.newbiechen.nbreader.ui.component.widget.page.action.PageAction 4 | import com.newbiechen.nbreader.ui.component.widget.page.action.TapMenuAction 5 | import com.newbiechen.nbreader.ui.component.widget.page.text.PageActionListener 6 | 7 | /** 8 | * author : newbiechen 9 | * date : 2020/3/7 8:59 PM 10 | * description :页面行为事件回调 11 | */ 12 | 13 | open class DefaultActionCallback : PageActionListener { 14 | override fun invoke(action: PageAction) { 15 | when (action) { 16 | is TapMenuAction -> onTapMenuAction(action) 17 | else -> onUnknownAction(action) 18 | } 19 | } 20 | 21 | open fun onTapMenuAction(action: TapMenuAction) { 22 | 23 | } 24 | 25 | open fun onUnknownAction(action: PageAction) { 26 | 27 | } 28 | } -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/ui/component/widget/page/PageEnum.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.ui.component.widget.page 2 | 3 | /** 4 | * author : newbiechen 5 | * date : 2019-08-30 14:58 6 | * description :Page 使用到的枚举类集合 7 | */ 8 | 9 | /** 10 | * 翻页动画类型 11 | */ 12 | enum class PageAnimType { 13 | SIMULATION, SCROLL, COVER, SLIDE, NONE 14 | } 15 | 16 | enum class TextAnimType { 17 | CONTROL, SCROLL 18 | } 19 | 20 | /** 21 | * 页面的类型 22 | */ 23 | enum class PageType { 24 | PREVIOUS, CURRENT, NEXT; 25 | 26 | fun getNext(): PageType? { 27 | return when (this) { 28 | PREVIOUS -> CURRENT 29 | CURRENT -> NEXT 30 | else -> null 31 | } 32 | } 33 | 34 | fun getPrevious(): PageType? { 35 | return when (this) { 36 | NEXT -> CURRENT 37 | CURRENT -> PREVIOUS 38 | else -> null 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | ## For more details on how to configure your build environment visit 2 | # http://www.gradle.org/docs/current/userguide/build_environment.html 3 | # 4 | # Specifies the JVM arguments used for the daemon process. 5 | # The setting is particularly useful for tweaking memory settings. 6 | # Default value: -Xmx1024m -XX:MaxPermSize=256m 7 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 8 | # 9 | # When configured, Gradle will run in incubating parallel mode. 10 | # This option should only be used with decoupled projects. More details, visit 11 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 12 | # org.gradle.parallel=true 13 | #Mon Nov 04 16:00:26 CST 2019 14 | kotlin.code.style=official 15 | android.enableJetifier=true 16 | org.gradle.jvmargs=-Xmx1536M -Dkotlin.daemon.jvm.options\="-Xmx2048M" 17 | android.useAndroidX=true 18 | -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/reader/text/resource/ImageResource.cpp: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2020/3/1 9:45 PM 3 | // description : 4 | // 5 | 6 | #include "ImageResource.h" 7 | #include "../../../util/Logger.h" 8 | 9 | ImageResource::ImageResource(const std::string &resId, const std::string &path, 10 | const std::string &encoding, short vOffset, 11 | size_t offset, size_t size, 12 | std::shared_ptr encryptionInfo) 13 | : TextResource(TextResType::IMAGE), resId(resId), 14 | path(path), encoding(encoding), encryptionInfo(encryptionInfo) { 15 | 16 | this->vOffset = vOffset; 17 | this->offset = offset; 18 | this->size = size; 19 | } 20 | 21 | void ImageResource::writeToParcelInternal(Parcel &parcel) const { 22 | // 写入 id 23 | parcel.writeString16(resId); 24 | // 写入路径 25 | parcel.writeString16(path); 26 | } -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/reader/text/tag/TextTag.h: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2019-12-30 14:31 3 | // description : 文本标签 4 | // 5 | 6 | #ifndef NBREADER_TEXTTAG_H 7 | #define NBREADER_TEXTTAG_H 8 | 9 | 10 | #include "../../../tools/parcel/Parcel.h" 11 | #include "../type/TextTagType.h" 12 | #include "../../../util/CommonUtil.h" 13 | 14 | class TextTag : public Parcelable { 15 | protected: 16 | virtual void writeToParcelInternal(Parcel &parcel) const = 0; 17 | 18 | public: 19 | TextTag(TextTagType type) { 20 | mType = type; 21 | } 22 | 23 | TextTagType getType() { 24 | return mType; 25 | } 26 | 27 | virtual ~TextTag() { 28 | } 29 | 30 | void writeToParcel(Parcel &parcel) const override { 31 | parcel.writeInt8(CommonUtil::to_underlying(mType)); 32 | writeToParcelInternal(parcel); 33 | } 34 | 35 | private: 36 | TextTagType mType; 37 | }; 38 | 39 | #endif //NBREADER_TEXTTAG_H 40 | -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/plugin/txt/TxtPlugin.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by 陈广祥 on 2019-09-19. 3 | // 4 | 5 | #ifndef NBREADER_TXTPLUGIN_H 6 | #define NBREADER_TXTPLUGIN_H 7 | 8 | 9 | #include "../FormatPlugin.h" 10 | #include "PlainTextFormat.h" 11 | #include "TxtReader.h" 12 | 13 | class TxtPlugin : public FormatPlugin { 14 | public: 15 | TxtPlugin(); 16 | 17 | ~TxtPlugin(); 18 | 19 | bool readEncodingInternal(std::string &outEncoding) override; 20 | 21 | bool readLanguageInternal(std::string &outLanguage) override; 22 | 23 | bool readChaptersInternal(std::string &chapterPattern, 24 | std::vector &chapterList) override; 25 | 26 | bool 27 | readChapterContentInternal(TextChapter &inChapter, TextContent &outContent) override; 28 | 29 | private: 30 | // 文本格式 31 | PlainTextFormat mFormat; 32 | // 文本阅读器 33 | TxtReader *mTxtReaderPtr; 34 | }; 35 | 36 | #endif //NBREADER_TXTPLUGIN_H 37 | -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/ui/component/book/text/entity/TextFixedPosition.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.ui.component.book.text.entity 2 | 3 | /** 4 | * author : newbiechen 5 | * date : 2019-10-28 20:25 6 | * description : 7 | */ 8 | 9 | open class TextFixedPosition( 10 | private val chapterIndex: Int, 11 | private val paragraphIndex: Int, 12 | private val elementIndex: Int, 13 | private val charIndex: Int 14 | ) : TextPosition() { 15 | 16 | constructor(position: TextPosition) : this( 17 | position.getChapterIndex(), 18 | position.getParagraphIndex(), 19 | position.getElementIndex(), 20 | position.getCharIndex() 21 | ) 22 | 23 | override fun getChapterIndex(): Int = chapterIndex 24 | 25 | override fun getParagraphIndex(): Int = paragraphIndex 26 | 27 | override fun getElementIndex(): Int = elementIndex 28 | 29 | override fun getCharIndex(): Int = charIndex 30 | } 31 | -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/ui/component/book/text/entity/TextRegion.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.ui.component.book.text.entity 2 | 3 | /** 4 | * author : newbiechen 5 | * date : 2019-10-29 19:13 6 | * description :将一个或多个 Element 捆绑成一组内容区域。 7 | * 举例:超链接是由一组 word 组成的,所以超链接就是一个 TextRegion 8 | * 9 | * TODO:这部分暂时没有用到,只有一个骨架 10 | */ 11 | 12 | /** 13 | * @param regionInterval:内容区域的区间对应 element 的区间 14 | * @param elementAreas:所有 element area 的列表 15 | * @param fromAreaIndex:内容区域对应 elementAreas 的起始位置 16 | */ 17 | class TextRegion( 18 | val regionInterval: TextRegionInterval, 19 | elementAreas: List, 20 | fromAreaIndex: Int 21 | ) { 22 | private var mElementAreaList = elementAreas 23 | private var mFromAreaIndex = fromAreaIndex 24 | private var mToAreaIndex = fromAreaIndex + 1 25 | 26 | /** 27 | * 扩大 Region 区域 28 | */ 29 | fun extend() { 30 | ++mToAreaIndex 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/reader/text/tag/ImageTag.h: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2020-02-20 21:38 3 | // description : 图片标签 4 | // 5 | 6 | #ifndef NBREADER_IMAGETAG_H 7 | #define NBREADER_IMAGETAG_H 8 | 9 | 10 | #include 11 | #include "TextTag.h" 12 | #include "../../../tools/drm/FileEncryptionInfo.h" 13 | #include "../resource/ImageResource.h" 14 | 15 | class ImageTag : public TextTag { 16 | public: 17 | ImageTag(const std::string &resourceId, 18 | const std::string &path, const std::string &encoding, 19 | bool isCover, short vOffset, 20 | size_t offset, size_t size, std::shared_ptr encryptionInfo); 21 | 22 | protected: 23 | void writeToParcelInternal(Parcel &parcel) const override; 24 | 25 | public: 26 | // 图片资源信息 27 | ImageResource imageResource; 28 | 29 | const std::string resId; 30 | // 是否是封面 31 | bool isCover; 32 | }; 33 | 34 | 35 | #endif //NBREADER_IMAGETAG_H 36 | -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/ui/component/book/text/entity/element/TextFixedHSpaceElement.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.ui.component.book.text.entity.element 2 | 3 | /** 4 | * author : newbiechen 5 | * date : 2019-11-07 13:58 6 | * description : 7 | */ 8 | 9 | class TextFixedHSpaceElement(val length: Int) : TextElement() { 10 | companion object { 11 | // 缓存对应长度的 HSpace 12 | private val sCacheHSpaceList = arrayOfNulls(20) 13 | 14 | fun getElement(len: Int): TextElement { 15 | return if (len < 20) { 16 | var cached: TextElement? = sCacheHSpaceList[len] 17 | if (cached == null) { 18 | cached = TextFixedHSpaceElement(len) 19 | sCacheHSpaceList[len] = cached 20 | } 21 | cached 22 | } else { 23 | TextFixedHSpaceElement(len) 24 | } 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/android/filesystem/AndroidAssetManager.h: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2019-10-17 18:09 3 | // description : 4 | // 5 | 6 | #ifndef NBREADER_ANDROIDASSETMANAGER_H 7 | #define NBREADER_ANDROIDASSETMANAGER_H 8 | 9 | 10 | #include "../../filesystem/asset/AssetManager.h" 11 | #include 12 | #include 13 | #include 14 | 15 | class AndroidAssetManager : public AssetManager { 16 | public: 17 | static void newInstance(); 18 | 19 | void registerAssetManager(jobject assetManager); 20 | 21 | virtual std::shared_ptr open(const std::string &path) const override; 22 | 23 | 24 | virtual std::shared_ptr> list(const std::string &path, bool fullPath) const override; 25 | 26 | private: 27 | AndroidAssetManager(); 28 | 29 | ~AndroidAssetManager(); 30 | 31 | jobject mAssetManager; 32 | 33 | }; 34 | 35 | 36 | #endif //NBREADER_ANDROIDASSETMANAGER_H 37 | -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/filesystem/io/Reader.h: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2019-11-29 23:36 3 | // description : 参考 java 的 Reader 写的读取器。(用于处理编码问题) 4 | // 5 | 6 | #ifndef NBREADER_READER_H 7 | #define NBREADER_READER_H 8 | 9 | #include 10 | 11 | class Reader { 12 | public: 13 | virtual ~Reader() { 14 | } 15 | 16 | /** 17 | * 启动读取 18 | * @return 19 | */ 20 | virtual bool open() = 0; 21 | 22 | /** 23 | * 将读取到的数据写入缓冲区 24 | * @param buffer 25 | * @param length 26 | * @return 读取数据的长度。 27 | * 28 | * TODO:与 InputStream 不同的是 returnSize != length 不表示 Reader 结束。判断是否真正结束需要 29 | * @see isFinish() 30 | * 31 | */ 32 | virtual int read(char *buffer, size_t length) = 0; 33 | 34 | /** 35 | * 停止读取 36 | */ 37 | virtual void close() = 0; 38 | 39 | /** 40 | * 是否读取完成 41 | */ 42 | virtual bool isFinish() const = 0; 43 | }; 44 | 45 | 46 | #endif //NBREADER_READER_H 47 | -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/filesystem/zip/ZipEntryManager.h: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2019-09-25 16:35 3 | // description : Zip 元素管理器 4 | // 5 | 6 | #ifndef NBREADER_ZIPFILEMANAGER_H 7 | #define NBREADER_ZIPFILEMANAGER_H 8 | 9 | #include 10 | #include "ZipEntry.h" 11 | 12 | class ZipEntryManager { 13 | public: 14 | static ZipEntryManager &getInstance(); 15 | 16 | static void deleteInstance(); 17 | 18 | ~ZipEntryManager() { 19 | } 20 | 21 | std::shared_ptr getZipEntry(const std::string &zipPath); 22 | 23 | private: 24 | static ZipEntryManager *sInstance; 25 | static const std::size_t MAX_CACHE_COUNT = 5; 26 | // zip 文件缓冲数组 27 | std::shared_ptr mZipEntryArr[MAX_CACHE_COUNT]; 28 | // 缓冲的索引 29 | int mCacheIndex; 30 | 31 | ZipEntryManager() { 32 | memset(mZipEntryArr, '\0', MAX_CACHE_COUNT); 33 | mCacheIndex = 0; 34 | } 35 | }; 36 | 37 | 38 | #endif //NBREADER_ZIPFILEMANAGER_H 39 | -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/ui/component/widget/page/anim/NonePageAnimation.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.ui.component.widget.page.anim 2 | 3 | import android.graphics.Canvas 4 | import android.view.View 5 | 6 | /** 7 | * author : newbiechen 8 | * date : 2019-09-02 11:13 9 | * description : 10 | */ 11 | 12 | class NonePageAnimation(view: View, pageManager: IPageAnimCallback) : 13 | PageAnimation(view, pageManager) { 14 | companion object { 15 | private const val TAG = "NonePageAnimation" 16 | } 17 | 18 | override fun drawStatic(canvas: Canvas) { 19 | // 绘制当前页 20 | canvas.drawBitmap(getFromPage(), 0f, 0f, null) 21 | } 22 | 23 | override fun drawMove(canvas: Canvas) { 24 | canvas.drawBitmap(getFromPage(), 0f, 0f, null) 25 | } 26 | 27 | override fun startAnim() { 28 | // TODO:预加载 toPage,更新翻到下一页的页面 (忘记这干啥用的了) 29 | // getToPage() 30 | 31 | // 直接结束动画 32 | finishAnim() 33 | } 34 | } -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/di/module/DatabaseModule.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.di.module 2 | 3 | import android.content.Context 4 | import androidx.room.Room 5 | import com.newbiechen.nbreader.data.local.room.NBDataBase 6 | import com.newbiechen.nbreader.data.local.room.dao.BookDao 7 | import com.newbiechen.nbreader.data.local.room.dao.CatalogDao 8 | import com.newbiechen.nbreader.uilts.Constants 9 | import dagger.Module 10 | import dagger.Provides 11 | import javax.inject.Singleton 12 | 13 | @Module 14 | class DatabaseModule { 15 | 16 | @Singleton 17 | @Provides 18 | fun provideDataBase(context: Context): NBDataBase = 19 | Room.databaseBuilder(context, NBDataBase::class.java, Constants.DB_NAME).build() 20 | 21 | @Singleton 22 | @Provides 23 | fun provideCatalogDao(dataBase: NBDataBase): CatalogDao = dataBase.getCatalogDao() 24 | 25 | @Singleton 26 | @Provides 27 | fun provideBookDao(dataBase: NBDataBase): BookDao = dataBase.getBookDao() 28 | } -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/reader/text/resource/TextResource.h: -------------------------------------------------------------------------------- 1 | 2 | // author : newbiechen 3 | // date : 2020/3/1 9:45 PM 4 | // description : 5 | // 6 | 7 | #ifndef NBREADER_TEXTRESOURCE_H 8 | #define NBREADER_TEXTRESOURCE_H 9 | 10 | 11 | #include "../../../tools/parcel/Parcel.h" 12 | #include "../type/TextResType.h" 13 | #include "../../../util/CommonUtil.h" 14 | 15 | class TextResource : public Parcelable { 16 | protected: 17 | virtual void writeToParcelInternal(Parcel &parcel) const = 0; 18 | 19 | public: 20 | TextResource(TextResType type) { 21 | mType = type; 22 | } 23 | 24 | virtual ~TextResource() { 25 | } 26 | 27 | 28 | TextResType getType() { 29 | return mType; 30 | } 31 | 32 | void writeToParcel(Parcel &parcel) const override { 33 | parcel.writeInt8(CommonUtil::to_underlying(mType)); 34 | writeToParcelInternal(parcel); 35 | } 36 | 37 | private: 38 | TextResType mType; 39 | }; 40 | 41 | 42 | #endif //NBREADER_TEXTRESOURCE_H 43 | -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/data/repository/BookListRepository.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.data.repository 2 | 3 | import com.newbiechen.nbreader.data.entity.NetBookListWrapper 4 | import com.newbiechen.nbreader.data.repository.impl.IBookListRepository 5 | import com.newbiechen.nbreader.di.annotation.qualifier.RemoteData 6 | import io.reactivex.Flowable 7 | import javax.inject.Inject 8 | 9 | /** 10 | * author : newbiechen 11 | * date : 2019-08-05 19:48 12 | * description :书籍列表仓库 13 | */ 14 | 15 | class BookListRepository @Inject constructor(@RemoteData private val remoteDataSource: IBookListRepository) : 16 | IBookListRepository { 17 | override fun getBookList( 18 | alias: String, 19 | sort: Int, 20 | start: Int, 21 | limit: Int, 22 | cat: String?, 23 | isserial: Boolean?, 24 | updated: Int? 25 | ): Flowable = remoteDataSource.getBookList(alias, sort, start, limit, cat, isserial, updated) 26 | } 27 | 28 | -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/filesystem/io/FileOutputStream.h: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2019-09-27 17:08 3 | // description : 4 | // 5 | 6 | #ifndef NBREADER_FILEOUTPUTSTREAM_H 7 | #define NBREADER_FILEOUTPUTSTREAM_H 8 | 9 | 10 | #include "OutputStream.h" 11 | #include 12 | 13 | class File; 14 | 15 | class FileOutputStream : public OutputStream { 16 | public: 17 | FileOutputStream(const std::string &filePath); 18 | 19 | FileOutputStream(const File &file); 20 | 21 | ~FileOutputStream(); 22 | 23 | bool open() override; 24 | 25 | /** 26 | * 是否允许 27 | * @param append 28 | * @return 29 | */ 30 | bool open(bool append); 31 | 32 | void write(const char *data, size_t len) override; 33 | 34 | void write(const std::string &str) override; 35 | 36 | void close() override; 37 | 38 | private: 39 | bool openFileInternal(bool append); 40 | 41 | std::string mPath; 42 | FILE *mFile; 43 | }; 44 | 45 | 46 | #endif //NBREADER_FILEOUTPUTSTREAM_H 47 | -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/reader/text/tag/ContentTag.cpp: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2020/3/1 9:49 PM 3 | // description : 4 | // 5 | 6 | #include "ContentTag.h" 7 | 8 | ContentTag::ContentTag(const std::string &text) : TextTag(TextTagType::TEXT) { 9 | append(text); 10 | } 11 | 12 | ContentTag::ContentTag(const std::vector &texts) : TextTag(TextTagType::TEXT) { 13 | append(texts); 14 | } 15 | 16 | void ContentTag::append(const std::string &text) { 17 | mContentList.push_back(text); 18 | } 19 | 20 | void ContentTag::append(const std::vector &texts) { 21 | mContentList.insert(mContentList.end(), texts.begin(), texts.end()); 22 | } 23 | 24 | void ContentTag::writeToParcelInternal(Parcel &parcel) const { 25 | std::string resultText; 26 | 27 | // 将数据中的数据,写入到统一文本中 28 | for (auto itr = mContentList.begin(); itr != mContentList.end(); ++itr) { 29 | resultText.append(*itr); 30 | } 31 | 32 | // 写入文本数据 33 | parcel.writeString32(resultText); 34 | } 35 | -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/filesystem/io/FileInputStream.h: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2019-09-24 13:29 3 | // description : 4 | // 5 | 6 | #ifndef NBREADER_FILEINPUTSTREAM_H 7 | #define NBREADER_FILEINPUTSTREAM_H 8 | 9 | 10 | #include "InputStream.h" 11 | #include 12 | #include "../File.h" 13 | 14 | class FileInputStream : public InputStream { 15 | public: 16 | FileInputStream(const std::string &filePath); 17 | 18 | FileInputStream(const File &file); 19 | 20 | ~FileInputStream(); 21 | 22 | // 打开输入流 23 | bool open() override; 24 | 25 | // 读取数据 26 | size_t read(char *buffer, size_t maxSize) override; 27 | 28 | // 跳到具体位置 29 | void seek(int offset, bool absoluteOffset) override; 30 | 31 | // 当前位置 32 | size_t offset() const override; 33 | 34 | size_t length() const override; 35 | 36 | // 关闭输入流 37 | void close() override; 38 | 39 | private: 40 | std::string mFilePath; 41 | FILE *mFilePtr; 42 | }; 43 | 44 | 45 | #endif //NBREADER_FILEINPUTSTREAM_H 46 | -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/util/Logger.cpp: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2019-09-24 17:29 3 | // description : 4 | // 5 | 6 | #include "Logger.h" 7 | 8 | const std::string Logger::TAG = "NBReader"; 9 | 10 | void Logger::printLogger(android_LogPriority logPriority, const std::string &subTag, const std::string &msg) { 11 | std::string printStr = "[" + subTag + "]" + msg; 12 | // printf("%s", printStr.c_str()); 13 | __android_log_print(logPriority, TAG.c_str(), "%s", printStr.c_str()); 14 | } 15 | 16 | void Logger::i(const std::string &subTag, const std::string &msg) { 17 | printLogger(ANDROID_LOG_INFO, subTag, msg); 18 | } 19 | 20 | void Logger::d(const std::string &subTag, const std::string &msg) { 21 | printLogger(ANDROID_LOG_DEBUG, subTag, msg); 22 | } 23 | 24 | void Logger::w(const std::string &subTag, const std::string &msg) { 25 | printLogger(ANDROID_LOG_WARN, subTag, msg); 26 | 27 | } 28 | 29 | void Logger::e(const std::string &subTag, const std::string &msg) { 30 | printLogger(ANDROID_LOG_ERROR, subTag, msg); 31 | } -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/reader/text/entity/TextChapter.h: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2019-12-09 15:50 3 | // description : 4 | // 5 | 6 | #ifndef NBREADER_TEXTCHAPTER_H 7 | #define NBREADER_TEXTCHAPTER_H 8 | 9 | 10 | #include 11 | 12 | class TextChapter { 13 | public: 14 | 15 | TextChapter(); 16 | 17 | TextChapter(const std::string &url, const std::string &title, 18 | int startIndex, int endIndex); 19 | 20 | // 路径信息 21 | std::string url; 22 | // 标题 23 | std::string title; 24 | // 对应源文件的起始位置 25 | int startIndex; 26 | // 对应源文件的终止位置(指向最后一个字符的下一个位置) 27 | // TODO:如果传入 -1 表示读取到 url 的最后一个字符(暂时这么设定,为解决 zip 拿不到解压文件的大小问题) 28 | int endIndex; 29 | 30 | std::string toString() { 31 | std::string str = "url:" + url + " chapter:" + title 32 | + " startIndex:" + std::to_string(startIndex) 33 | + " endIndex:" + std::to_string(endIndex); 34 | return str; 35 | } 36 | }; 37 | 38 | 39 | #endif //NBREADER_TEXTCHAPTER_H 40 | -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/filesystem/io/InputStream.h: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2019-09-24 10:57 3 | // description : 输入流抽象类 4 | // 5 | 6 | #ifndef NBREADER_INPUTSTREAM_H 7 | #define NBREADER_INPUTSTREAM_H 8 | 9 | #include 10 | 11 | class InputStream { 12 | 13 | public: 14 | InputStream(); 15 | 16 | virtual ~InputStream(); 17 | 18 | // 打开输入流 19 | virtual bool open() = 0; 20 | 21 | // 读取数据 22 | virtual size_t read(char *buffer, size_t maxSize) = 0; 23 | 24 | // 跳到具体位置 25 | virtual void seek(int offset, bool absoluteOffset) = 0; 26 | 27 | // 当前位置 28 | virtual size_t offset() const = 0; 29 | 30 | // 获取流数据的大小 31 | virtual size_t length() const = 0; 32 | 33 | // 关闭输入流 34 | virtual void close() = 0; 35 | 36 | /*private: 37 | InputStream(const InputStream & is); 38 | const InputStream &operator=(const InputStream &is);*/ 39 | }; 40 | 41 | inline InputStream::InputStream() { 42 | } 43 | 44 | inline InputStream::~InputStream() { 45 | } 46 | 47 | #endif //NBREADER_INPUTSTREAM_H 48 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_mine.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 13 | 14 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/reader/text/entity/TextContent.cpp: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2020/2/28 10:18 PM 3 | // description : 4 | // 5 | 6 | #include "TextContent.h" 7 | 8 | TextContent::TextContent() { 9 | contentPtr = nullptr; 10 | resourcePtr = nullptr; 11 | resourceSize = 0; 12 | contentSize = 0; 13 | 14 | hasInitialized = false; 15 | } 16 | 17 | TextContent::TextContent(char *resourcePtr, size_t resourceSize, char *contentPtr, 18 | size_t contentSize) { 19 | this->resourcePtr = resourcePtr; 20 | this->resourceSize = resourceSize; 21 | 22 | this->contentPtr = contentPtr; 23 | this->contentSize = contentSize; 24 | 25 | hasInitialized = true; 26 | } 27 | 28 | void TextContent::release() { 29 | if (contentPtr != nullptr) { 30 | delete contentPtr; 31 | contentPtr = nullptr; 32 | } 33 | 34 | if (resourcePtr != nullptr) { 35 | delete resourcePtr; 36 | } 37 | 38 | contentSize = 0; 39 | resourceSize = 0; 40 | 41 | hasInitialized = false; 42 | } -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/tools/xml/BaseHandler.cpp: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2020-02-18 23:27 3 | // description : 4 | // 5 | 6 | #include "BaseHandler.h" 7 | #include "../../util/StringUtil.h" 8 | 9 | void BaseHandler::startNamespace(std::string &prefix, std::string &uri) { 10 | mNamespaceMap[prefix] = uri; 11 | } 12 | 13 | void BaseHandler::endNamespace(std::string &prefix) { 14 | } 15 | 16 | 17 | bool BaseHandler::isRightTag(const std::string &ns, const std::string &expectTag, 18 | const std::string &actualTag) const { 19 | if (expectTag == actualTag) { 20 | return true; 21 | } 22 | 23 | const int nameLen = expectTag.size(); 24 | const int tagLen = actualTag.size(); 25 | if (tagLen < nameLen + 2) { 26 | return false; 27 | } 28 | if (StringUtil::endsWith(expectTag, actualTag) && actualTag[tagLen - nameLen - 1] == ':') { 29 | std::string ns = getNamespaceUrl(actualTag.substr(0, tagLen - nameLen - 1)); 30 | return !ns.empty(); 31 | } 32 | return false; 33 | } -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/filesystem/asset/AssetManager.h: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2019-10-17 15:25 3 | // description : 资源管理器 4 | // 5 | 6 | #ifndef NBREADER_ASSETMANAGER_H 7 | #define NBREADER_ASSETMANAGER_H 8 | 9 | #include 10 | #include "../io/InputStream.h" 11 | 12 | class AssetManager { 13 | public: 14 | static AssetManager &getInstance() { 15 | return *sInstance; 16 | } 17 | 18 | static void deleteInstance() { 19 | delete sInstance; 20 | } 21 | 22 | public: 23 | // 输入流 24 | virtual std::shared_ptr open(const std::string &path) const = 0; 25 | 26 | /** 27 | * 获取文件目录下的所有文件路径 28 | * @param path :资源文件路径 29 | * @param fullPath:返回全路径,还是返回文件名 30 | * @return 31 | */ 32 | virtual std::shared_ptr> list(const std::string &path, bool fullPath) const = 0; 33 | 34 | protected: 35 | static AssetManager *sInstance; 36 | 37 | AssetManager() { 38 | } 39 | 40 | ~AssetManager() { 41 | } 42 | }; 43 | 44 | 45 | #endif //NBREADER_ASSETMANAGER_H 46 | -------------------------------------------------------------------------------- /app/src/main/res/layout/layout_toolbar.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 12 | 13 | 21 | 22 | -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/data/local/BookLocalDataSource.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.data.local 2 | 3 | import com.newbiechen.nbreader.data.entity.BookEntity 4 | import com.newbiechen.nbreader.data.local.room.dao.BookDao 5 | import com.newbiechen.nbreader.data.repository.impl.IBookRepository 6 | import io.reactivex.Flowable 7 | import javax.inject.Inject 8 | 9 | /** 10 | * author : newbiechen 11 | * date : 2020-02-04 20:54 12 | * description :书籍本地缓存数据源 13 | */ 14 | 15 | class BookLocalDataSource @Inject constructor(private val bookDao: BookDao) : IBookRepository { 16 | 17 | override fun getBooks(isCache: Boolean): Flowable> { 18 | // 如果不是从缓存中读取的,则直接返回 19 | if (!isCache) { 20 | return Flowable.empty() 21 | } 22 | 23 | return bookDao.getAllBooks().toFlowable() 24 | } 25 | 26 | override fun saveBook(bookEntity: BookEntity) { 27 | bookDao.insertBook(bookEntity) 28 | } 29 | 30 | override fun saveBooks(books: List) { 31 | bookDao.insertBooks(books) 32 | } 33 | } -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/filesystem/UnixFileDir.cpp: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2019-09-25 15:49 3 | // description : 4 | // 5 | 6 | #include 7 | #include 8 | #include "UnixFileDir.h" 9 | #include "FileSystem.h" 10 | 11 | void UnixFileDir::readFilePaths(std::vector &paths, bool fullPath) const { 12 | DIR *dir = opendir(getPath().c_str()); 13 | 14 | if (dir != 0) { 15 | const std::string namePrefix = getPath() + FileSystem::separator; 16 | const dirent *file; 17 | struct stat fileInfo; 18 | std::string shortName; 19 | while ((file = readdir(dir)) != 0) { 20 | shortName = file->d_name; 21 | if ((shortName == ".") || (shortName == "..")) { 22 | continue; 23 | } 24 | const std::string path = namePrefix + shortName; 25 | lstat(path.c_str(), &fileInfo); 26 | if (S_ISREG(fileInfo.st_mode)) { 27 | paths.push_back(fullPath ? path : shortName); 28 | } 29 | } 30 | closedir(dir); 31 | } 32 | } -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/filesystem/UnixFileSystem.h: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2019-09-23 10:59 3 | // description : Unix 文件系统 4 | // 5 | 6 | #ifndef NBREADER_UNIXFILESYSTEM_H 7 | #define NBREADER_UNIXFILESYSTEM_H 8 | 9 | 10 | #include "FileSystem.h" 11 | 12 | class UnixFileSystem : public FileSystem { 13 | public: 14 | // 对其他 path 进行标准化 15 | virtual std::string normalizePath(const std::string &path) const override ; 16 | 17 | protected: 18 | virtual void normalizeInternal(std::string &path) const override; 19 | 20 | // 创建目录 21 | virtual bool createDirectory(const std::string &path) const override; 22 | 23 | // 创建并返回目录 24 | virtual std::shared_ptr getDirectory(const std::string &path) const override; 25 | 26 | // 创建文件 27 | virtual bool createFile(const std::string &path) const override; 28 | 29 | // 删除文件 30 | virtual bool deleteFile(const std::string &path) const override; 31 | 32 | // 获取文件状态信息 33 | virtual FileStat getFileStat(const std::string &path) const override; 34 | }; 35 | 36 | 37 | #endif //NBREADER_UNIXFILESYSTEM_H 38 | -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/reader/text/resource/ImageResource.h: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2020/3/1 9:45 PM 3 | // description : 图片资源 4 | // 5 | 6 | #ifndef NBREADER_IMAGERESOURCE_H 7 | #define NBREADER_IMAGERESOURCE_H 8 | 9 | #include "TextResource.h" 10 | #include "../../../tools/drm/FileEncryptionInfo.h" 11 | 12 | class ImageResource : public TextResource { 13 | 14 | public: 15 | ImageResource(const std::string &resId, const std::string &path, 16 | const std::string &encoding, short vOffset, 17 | size_t offset, size_t size, std::shared_ptr encryptionInfo); 18 | 19 | protected: 20 | void writeToParcelInternal(Parcel &parcel) const override; 21 | 22 | private: 23 | const std::string resId; 24 | // 图片地址 25 | const std::string path; 26 | // 图片的编码方式 27 | const std::string encoding; 28 | // 偏移(暂时不知道这个东西有什么作用) 29 | short vOffset; 30 | // 文件偏移 31 | size_t offset; 32 | // 图片大小 33 | size_t size; 34 | // 图片加密信息 35 | std::shared_ptr encryptionInfo; 36 | }; 37 | 38 | #endif //NBREADER_IMAGERESOURCE_H 39 | -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/ui/component/book/text/entity/element/TextElement.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.ui.component.book.text.entity.element 2 | 3 | import com.newbiechen.nbreader.ui.component.book.text.entity.resource.image.TextImage 4 | import com.newbiechen.nbreader.ui.component.book.text.entity.tag.TextStyleTag 5 | 6 | /** 7 | * author : newbiechen 8 | * date : 2019-10-21 17:27 9 | * description :文本元素 10 | */ 11 | 12 | open class TextElement { 13 | companion object { 14 | val HSpace = TextElement() 15 | // NON-BREAK-SPACE 表示该标志所在的字母组合(单词),不允许换行,即单词要连在一行显示 16 | // wiki:不可中断空白连同前面一个、后面一个字符都在同一行,不会换行。 17 | val NBSpace: TextElement = TextElement() 18 | val AfterParagraph: TextElement = TextElement() 19 | val Indent: TextElement = TextElement() 20 | val StyleClose: TextElement = TextElement() 21 | } 22 | } 23 | 24 | data class TextStyleElement(val styleTag: TextStyleTag) : TextElement() 25 | 26 | data class TextImageElement(val image: TextImage) : TextElement() 27 | 28 | // TODO:占位标签 29 | class TextHyperlinkControlElement() : TextElement() 30 | -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/ui/component/book/text/config/DefaultConfigure.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.ui.component.book.text.config 2 | 3 | import android.graphics.drawable.Drawable 4 | 5 | /** 6 | * author : newbiechen 7 | * date : 2020/3/11 6:38 PM 8 | * description : 9 | */ 10 | 11 | class DefaultConfigure private constructor() : TextConfigure { 12 | 13 | companion object { 14 | @Volatile 15 | private var instance: DefaultConfigure? = null 16 | 17 | fun getInstance() = instance ?: synchronized(this) { 18 | DefaultConfigure() 19 | } 20 | } 21 | 22 | override fun getMarginLeft(): Int { 23 | return 0 24 | } 25 | 26 | override fun getMarginRight(): Int { 27 | return 0 28 | } 29 | 30 | override fun getMarginTop(): Int { 31 | return 0 32 | } 33 | 34 | override fun getMarginBottom(): Int { 35 | return 0 36 | } 37 | 38 | override fun getTextColor(): Int { 39 | return 0xff000000.toInt() 40 | } 41 | 42 | override fun getBackground(): Drawable? { 43 | return null 44 | } 45 | } -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/ui/component/binding/RecyclerViewBinding.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.ui.component.binding 2 | 3 | import androidx.databinding.BindingAdapter 4 | import androidx.recyclerview.widget.RecyclerView 5 | import com.newbiechen.nbreader.data.entity.CatalogEntity 6 | import com.newbiechen.nbreader.ui.component.adapter.FindAdapter 7 | import com.newbiechen.nbreader.ui.component.adapter.LocalBookWrapper 8 | import com.newbiechen.nbreader.ui.component.adapter.SmartLookupAdapter 9 | 10 | object RecyclerViewBinding { 11 | 12 | @BindingAdapter("app:items") 13 | @JvmStatic 14 | fun RecyclerView.setCatalogs(catalogs: List?) { 15 | (adapter as FindAdapter?)?.apply { 16 | refreshItems(catalogs) 17 | } 18 | } 19 | 20 | @BindingAdapter("app:items") 21 | @JvmStatic 22 | fun RecyclerView.setBookInfoGroup(groups: List>>?) { 23 | if (groups == null) { 24 | return 25 | } 26 | 27 | (adapter as SmartLookupAdapter?)?.apply { 28 | refreshAllGroup(groups) 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/util/StringUtil.h: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2019-09-24 16:22 3 | // description : 4 | // 5 | 6 | #ifndef NBREADER_STRINGUTIL_H 7 | #define NBREADER_STRINGUTIL_H 8 | 9 | #include 10 | #include 11 | 12 | class StringUtil { 13 | private: 14 | StringUtil(); 15 | 16 | public: 17 | static bool startsWith(const std::string &str, const std::string &start); 18 | 19 | static bool endsWith(const std::string &str, const std::string &end); 20 | 21 | // 在 string 后添加 num 数字 22 | static void appendNumber(std::string &str, unsigned int num); 23 | 24 | static std::string numberToString(unsigned int n); 25 | 26 | static void asciiToLowerInline(std::string &asciiString); 27 | 28 | static void stripWhiteSpaces(std::string &str); 29 | 30 | static std::vector 31 | split(const std::string &str, const std::string &delimiter, bool skipEmpty); 32 | 33 | static int parseDecimal(const std::string &str, int defaultValue); 34 | 35 | static double stringToDouble(const std::string &value, double defaultValue); 36 | }; 37 | 38 | 39 | #endif //NBREADER_STRINGUTIL_H 40 | -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/uilts/factory/ViewModelFactory.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.uilts.factory 2 | 3 | import androidx.lifecycle.ViewModel 4 | import androidx.lifecycle.ViewModelProvider 5 | import javax.inject.Inject 6 | import javax.inject.Provider 7 | import javax.inject.Singleton 8 | 9 | /** 10 | * ViewModel 工厂,原理: 11 | * 1. ViewModelFactory 会获取到 Dagger2 中注册的所有 Provider> 对象 12 | * 2. 当用户需要指定 ViewModel 时,就会调用这个 Factory,获取 ViewModel 对应的 Provider> 13 | * 3. 通过 Provider> 获取被 Dagger2 注入过的 ViewModel。 14 | */ 15 | @Singleton 16 | class ViewModelFactory @Inject constructor( 17 | private val modelMap: Map, @JvmSuppressWildcards Provider> 18 | ) : ViewModelProvider.Factory { 19 | override fun create(modelClass: Class): T { 20 | val model = modelMap[modelClass] 21 | ?: modelMap.entries.firstOrNull { (key, _) -> 22 | modelClass.isAssignableFrom(key) 23 | }?.value 24 | ?: throw IllegalArgumentException("Unknown model class $modelClass") 25 | return model.get() as T 26 | } 27 | } -------------------------------------------------------------------------------- /app/src/main/res/layout/item_page_anim.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 11 | 14 | 15 | 16 | 19 | 20 | 30 | 31 | -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/ui/component/binding/ViewGroupBinding.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.ui.component.binding 2 | 3 | import android.view.ViewGroup 4 | import android.view.animation.Animation 5 | import androidx.databinding.BindingAdapter 6 | 7 | /** 8 | * author : newbiechen 9 | * date : 2019-08-29 15:59 10 | * description : 11 | */ 12 | 13 | object ViewGroupBinding { 14 | @BindingAdapter("app:enterAnim", "app:exitAnim", "app:visible") 15 | @JvmStatic 16 | fun ViewGroup.setTransitionAnim(enterAnim: Animation?, exitAnim: Animation?, isVisible: Boolean?) { 17 | if (isVisible == null) { 18 | return 19 | } 20 | 21 | // 退出动画 22 | if (visibility == ViewGroup.VISIBLE && !isVisible) { 23 | visibility = ViewGroup.GONE 24 | if (exitAnim != null) { 25 | startAnimation(exitAnim) 26 | } 27 | } else if (visibility != ViewGroup.VISIBLE && isVisible) { 28 | visibility = ViewGroup.VISIBLE 29 | if (enterAnim != null) { 30 | startAnimation(enterAnim) 31 | } 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/ui/component/book/text/entity/textstyle/TextStyle.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.ui.component.book.text.entity.textstyle 2 | 3 | import com.newbiechen.nbreader.ui.component.book.text.entity.TextMetrics 4 | 5 | /** 6 | * author : newbiechen 7 | * date : 2020/3/11 4:43 PM 8 | * description :返回值不为 null 的 9 | */ 10 | interface TextStyle { 11 | fun getFontSize(metrics: TextMetrics): Int 12 | fun isBold(): Boolean 13 | fun isItalic(): Boolean 14 | fun isUnderline(): Boolean 15 | fun isStrikeThrough(): Boolean 16 | fun getLeftMargin(metrics: TextMetrics): Int 17 | fun getRightMargin(metrics: TextMetrics): Int 18 | fun getLeftPadding(metrics: TextMetrics): Int 19 | fun getRightPadding(metrics: TextMetrics): Int 20 | fun getFirstLineIndent(metrics: TextMetrics): Int 21 | fun getLineSpacePercent(): Int 22 | fun getVerticalAlign(metrics: TextMetrics): Int 23 | fun isVerticallyAligned(): Boolean 24 | fun getSpaceBefore(metrics: TextMetrics): Int 25 | fun getSpaceAfter(metrics: TextMetrics): Int 26 | fun getAlignment(): Byte 27 | fun allowHyphenations(): Boolean 28 | } -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/uilts/DensityUtil.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.uilts 2 | 3 | import android.content.Context 4 | import android.util.TypedValue 5 | 6 | 7 | object DensityUtil { 8 | /** 9 | * dp转px 10 | */ 11 | fun dp2px(context: Context, dpVal: Float): Int { 12 | return TypedValue.applyDimension( 13 | TypedValue.COMPLEX_UNIT_DIP, 14 | dpVal, context.resources.displayMetrics 15 | ).toInt() 16 | } 17 | 18 | /** 19 | * sp转px 20 | */ 21 | fun sp2px(context: Context, spVal: Float): Int { 22 | return TypedValue.applyDimension( 23 | TypedValue.COMPLEX_UNIT_SP, 24 | spVal, context.resources.displayMetrics 25 | ).toInt() 26 | } 27 | 28 | /** 29 | * px转dp 30 | */ 31 | fun px2dp(context: Context, pxVal: Float): Float { 32 | val scale = context.resources.displayMetrics.density 33 | return pxVal / scale 34 | } 35 | 36 | /** 37 | * px转sp 38 | */ 39 | fun px2sp(context: Context, pxVal: Float): Float { 40 | return pxVal / context.resources.displayMetrics.scaledDensity 41 | } 42 | } -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/tools/xml/XMLFilter.h: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2020-02-18 23:22 3 | // description : 用于过滤 xml 标签信息 4 | // 5 | 6 | #ifndef NBREADER_XMLFILTER_H 7 | #define NBREADER_XMLFILTER_H 8 | 9 | #include 10 | #include "BaseHandler.h" 11 | 12 | // 过滤带有 namespace 的 xml 标签 13 | class NsXMLFilter { 14 | public: 15 | /** 16 | * @param url:命名空间对应的 url 地址 17 | * @param patternName:匹配的名字 18 | */ 19 | NsXMLFilter(const std::string &nsUrl, const std::string &attrName); 20 | 21 | virtual bool accept(const BaseHandler &handler, const char *patternName) const; 22 | 23 | /** 24 | * 25 | * @param handler :必须支持 NsSAXHandler 26 | * @param checkName:待检测的名字 27 | * @return 28 | */ 29 | virtual bool accept(const BaseHandler &handler, const std::string &patternName) const; 30 | 31 | std::string pattern(const BaseHandler &handler, const Attributes &attrs) const; 32 | 33 | 34 | const std::string &getAttributetName() { 35 | return mAttrName; 36 | } 37 | 38 | private: 39 | const std::string mNsUrl; 40 | const std::string mAttrName; 41 | }; 42 | 43 | 44 | #endif //NBREADER_XMLFILTER_H 45 | -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/android/application/AndroidFormatPluginApp.cpp: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2019-10-14 11:10 3 | // description : 4 | // 5 | 6 | #include 7 | #include "AndroidFormatPluginApp.h" 8 | #include "../../util/AndroidUtil.h" 9 | #include "../filesystem/AndroidFileSystem.h" 10 | #include "../filesystem/AndroidAssetManager.h" 11 | 12 | void AndroidFormatPluginApp::newInstance() { 13 | sInstance = new AndroidFormatPluginApp(); 14 | } 15 | 16 | std::string AndroidFormatPluginApp::language() { 17 | JNIEnv *env = AndroidUtil::getEnv(); 18 | jobject locale = AndroidUtil::StaticMethod_Locale_getDefault->call(); 19 | std::string lang = AndroidUtil::Method_Locale_getLanguage->callForCppString(locale); 20 | env->DeleteLocalRef(locale); 21 | return lang; 22 | } 23 | 24 | std::string AndroidFormatPluginApp::version() { 25 | // TODO:暂时未实现 26 | return std::string(); 27 | } 28 | 29 | void AndroidFormatPluginApp::initApp(JavaVM *jvm) { 30 | // 初始化 android 工具类 31 | AndroidUtil::init(jvm); 32 | // 初始化 android 文件系统 33 | AndroidFileSystem::newInstance(); 34 | // 初始化 android 资源文件系统 35 | AndroidAssetManager::newInstance(); 36 | } 37 | -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/plugin/oeb/OebReader.cpp: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2020-02-23 11:42 3 | // description : 4 | // 5 | 6 | #include "OebReader.h" 7 | #include "../../tools/xhtml/XHTMLReader.h" 8 | #include "../../filesystem/FileSystem.h" 9 | 10 | OebReader::OebReader() : mXhtmlReader(mBookEncoder, 0) { 11 | } 12 | 13 | bool OebReader::readContent(TextChapter &inChapter, TextContent &outContent) { 14 | // 准备文件信息 15 | File chapterFile(inChapter.url); 16 | 17 | std::string chapterPath = chapterFile.getPath(); 18 | int referenceIndex = chapterPath.rfind(FileSystem::archiveSeparator); 19 | 20 | // 参考名,就是文件在压缩包内的路径。(这部分是不是可能封装到什么地方) 21 | std::string referenceName(""); 22 | if (referenceIndex != -1) { 23 | referenceName.assign(chapterPath.substr(referenceIndex + 1)); 24 | } 25 | // 打开书籍编码器 26 | mBookEncoder.open(); 27 | // 添加初始段落样式 28 | mBookEncoder.pushTextKind(TextKind::REGULAR); 29 | // 进行文件解析 30 | mXhtmlReader.readFile(chapterFile, referenceName); 31 | // 设置文本结束段落标记 32 | mBookEncoder.insertEndOfSectionParagraph(); 33 | outContent = mBookEncoder.close(); 34 | // 将解析到的数据输出 35 | return outContent.isInitialized(); 36 | } -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/util/FilePathUtil.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010-2015 FBReader.ORG Limited 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 17 | * 02110-1301, USA. 18 | */ 19 | 20 | #ifndef __ZLFILEUTIL_H__ 21 | #define __ZLFILEUTIL_H__ 22 | 23 | #include 24 | 25 | class FilePathUtil { 26 | 27 | public: 28 | static std::string normalizeUnixPath(const std::string &path); 29 | 30 | private: 31 | FilePathUtil(); 32 | }; 33 | 34 | #endif /* __ZLFILEUTIL_H__ */ 35 | -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/tools/xml/BaseHandler.h: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2020-02-18 23:27 3 | // description : 对经常用到的 XML 解析功能的封装 4 | // 5 | 6 | #ifndef NBREADER_BASEHANDLER_H 7 | #define NBREADER_BASEHANDLER_H 8 | 9 | 10 | #include "SAXHandler.h" 11 | 12 | class BaseHandler : public SAXHandler { 13 | 14 | public: 15 | bool isNamespaceExist(const std::string &ns) const { 16 | return mNamespaceMap.find(ns) != mNamespaceMap.end(); 17 | } 18 | 19 | std::string getNamespaceUrl(const std::string &ns) const { 20 | auto it = mNamespaceMap.find(ns); 21 | if (it != mNamespaceMap.end()) { 22 | return it->second; 23 | } 24 | return std::string(); 25 | } 26 | 27 | void startNamespace(std::string &prefix, std::string &uri) override; 28 | 29 | void endNamespace(std::string &prefix) override; 30 | 31 | /** 32 | * 是否是正确的 tag 33 | * @return 34 | */ 35 | bool isRightTag(const std::string &ns, const std::string &expectTag, const std::string &actualTag) const; 36 | 37 | private: 38 | // 存储 namespace 的容器 39 | std::map mNamespaceMap; 40 | }; 41 | 42 | 43 | #endif //NBREADER_BASEHANDLER_H 44 | -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/filesystem/zip/ZipEntry.h: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2019-09-25 16:35 3 | // description : zip 元素 4 | // 5 | 6 | #ifndef NBREADER_ZIPENTRIY_H 7 | #define NBREADER_ZIPENTRIY_H 8 | 9 | #include 10 | #include 11 | 12 | // Zip 文件中的条目信息 13 | struct ZipItemInfo { 14 | int offset = -1; 15 | int compressionMethod; 16 | int compressedSize; 17 | int uncompressedSize; 18 | 19 | }; 20 | 21 | // zip 元素或 zip 文件 22 | class ZipEntry { 23 | public: 24 | ZipEntry(const std::string &path); 25 | 26 | ~ZipEntry() { 27 | } 28 | 29 | // 获取 zip 文件内的条目信息 30 | ZipItemInfo getItemInfo(const std::string &itemName) const; 31 | 32 | // 读取 zip 文件内的条目的名字 33 | void readItemNames(std::vector &names) const; 34 | 35 | // 当前 Entry 文件是否过期 36 | bool isValid() const; 37 | 38 | std::string getPath() const { 39 | return mPath; 40 | } 41 | 42 | size_t getLastModifiedTime() const { 43 | return mLastModifiedTime; 44 | } 45 | 46 | private: 47 | const std::string mPath; 48 | size_t mLastModifiedTime; 49 | std::map mItemMap; 50 | }; 51 | 52 | 53 | #endif //NBREADER_ZIPENTRIY_H 54 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_find.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/di/module/MainModule.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.di.module 2 | 3 | import com.newbiechen.nbreader.di.annotation.scope.ActivityScoped 4 | import com.newbiechen.nbreader.ui.page.bookshelf.BookShelfFragment 5 | import com.newbiechen.nbreader.ui.page.find.FindFragment 6 | import com.newbiechen.nbreader.ui.page.mine.MineFragment 7 | import com.newbiechen.nbreader.uilts.factory.MainFragFactory 8 | import com.newbiechen.nbreader.uilts.factory.NBMainFragFactory 9 | import com.newbiechen.nbreader.di.annotation.scope.FragmentScoped 10 | import dagger.Binds 11 | import dagger.Module 12 | import dagger.android.ContributesAndroidInjector 13 | 14 | @Module 15 | abstract class MainModule { 16 | @ActivityScoped 17 | @Binds 18 | abstract fun bindFragmentFactory(fragmentFactory: NBMainFragFactory): MainFragFactory 19 | 20 | @FragmentScoped 21 | @ContributesAndroidInjector 22 | abstract fun bindBookShelfFragment(): BookShelfFragment 23 | 24 | @FragmentScoped 25 | @ContributesAndroidInjector 26 | abstract fun bindFindFragment(): FindFragment 27 | 28 | @FragmentScoped 29 | @ContributesAndroidInjector 30 | abstract fun bindMineFragment(): MineFragment 31 | } -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/android/filesystem/AndroidAssetInputStream.h: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2019-10-17 18:11 3 | // description : 4 | // 5 | 6 | #ifndef NBREADER_ANDROIDASSETINPUTSTREAM_H 7 | #define NBREADER_ANDROIDASSETINPUTSTREAM_H 8 | 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include "../../filesystem/io/InputStream.h" 15 | 16 | class AndroidAssetInputStream : public InputStream { 17 | public: 18 | 19 | ~AndroidAssetInputStream(); 20 | 21 | virtual bool open() override; 22 | 23 | virtual size_t read(char *buffer, size_t maxSize) override; 24 | 25 | virtual void seek(int offset, bool absoluteOffset) override; 26 | 27 | virtual size_t offset() const override; 28 | 29 | size_t length() const override; 30 | 31 | virtual void close() override; 32 | 33 | private: 34 | AndroidAssetInputStream(AAssetManager *aAssetManager, const std::string &assetPath); 35 | 36 | 37 | AAssetManager *mAAssetManager; 38 | AAsset *mAssetFile; 39 | const std::string mAssetPath; 40 | 41 | friend class AndroidAssetManager; 42 | }; 43 | 44 | 45 | #endif //NBREADER_ANDROIDASSETINPUTSTREAM_H 46 | -------------------------------------------------------------------------------- /app/src/main/cpp/nbbook/filesystem/io/InputStreamReader.h: -------------------------------------------------------------------------------- 1 | // author : newbiechen 2 | // date : 2019-11-29 23:39 3 | // description : 4 | // 5 | 6 | #ifndef NBREADER_INPUTSTREAMREADER_H 7 | #define NBREADER_INPUTSTREAMREADER_H 8 | 9 | 10 | #include 11 | #include 12 | #include 13 | #include "Reader.h" 14 | #include "InputStream.h" 15 | #include "../charset/StreamDecoder.h" 16 | 17 | class InputStreamReader : public Reader { 18 | 19 | public: 20 | InputStreamReader(std::shared_ptr inputStream, const std::string &charset); 21 | 22 | ~InputStreamReader(); 23 | 24 | void close() override; 25 | 26 | /** 27 | * 28 | * @param buffer 29 | * @param offset 30 | * @param length 31 | * @return 返回读取到数据的长度 32 | * 33 | */ 34 | int read(char *buffer, size_t length) override; 35 | 36 | // 需要加一个方法判断是否 read 完成 37 | 38 | // 需要加一个方法 39 | 40 | bool open() override; 41 | 42 | bool isFinish() const override; 43 | 44 | size_t alreadyDecodeLength() const { 45 | return mStreamDecoder.alreadyDecodeLength(); 46 | } 47 | 48 | private: 49 | StreamDecoder mStreamDecoder; 50 | }; 51 | 52 | 53 | #endif //NBREADER_INPUTSTREAMREADER_H 54 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_book_shelf.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 10 | 11 | 12 | 15 | 16 | 21 | 22 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_read_catalogy.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 11 | 12 | 15 | 16 | 17 | 21 | 22 | 33 | 34 | -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/ui/component/widget/page/action/MotionAction.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.ui.component.widget.page.action 2 | 3 | import android.view.MotionEvent 4 | 5 | /** 6 | * author : newbiechen 7 | * date : 2020/3/5 4:04 PM 8 | * description :运动事件 9 | */ 10 | 11 | enum class MotionType { 12 | PRESS, // 按下事件 13 | LONG_PRESS, // 长按事件 14 | MOVE, // 移动事件 15 | RELEASE, // 释放事件 16 | CANCEL, // 取消事件 17 | SINGLE_TAP, // 单击事件 18 | DOUBLE_TAP, // 双击事件 19 | } 20 | 21 | data class MotionAction( 22 | val type: MotionType, 23 | val event: MotionEvent 24 | ) : PageAction { 25 | companion object { 26 | fun obtain(other: MotionAction): MotionAction { 27 | val newType = other.type 28 | val newEvent = MotionEvent.obtain(other.event) 29 | return MotionAction(newType, newEvent) 30 | } 31 | } 32 | 33 | /** 34 | * 对于 obtain() 复制的 action,需要调用该方法回收 35 | */ 36 | fun recycle() { 37 | // 需要回收 event 38 | event.recycle() 39 | } 40 | 41 | override fun toString(): String { 42 | return "MotionAction(type=$type, x=${event.x.toInt()}, y=${event.y.toInt()})" 43 | } 44 | } -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/ui/page/filesystem/ILocalBookSystem.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.ui.page.filesystem 2 | 3 | import com.newbiechen.nbreader.data.entity.LocalBookEntity 4 | 5 | 6 | /** 7 | * author : newbiechen 8 | * date : 2019-08-21 15:48 9 | * description :本地书籍系统 10 | */ 11 | 12 | interface ILocalBookSystem { 13 | /** 14 | * 设置全选 15 | * @param isChecked:是否全选 16 | */ 17 | fun setBookCheckedAll(isChecked: Boolean) 18 | 19 | /** 20 | * 获取选中书籍的数量 21 | */ 22 | fun getCheckedBookCount(): Int 23 | 24 | /** 25 | * 删除选中的书籍 26 | */ 27 | fun deleteCheckedBooks() 28 | 29 | /** 30 | * 获取选中的书籍 31 | */ 32 | fun getCheckedBooks(): List 33 | 34 | /** 35 | * 设置书籍回调 36 | */ 37 | fun setBookCallback(callback: ILocalBookCallback) 38 | 39 | /** 40 | * 获取书籍数 41 | */ 42 | fun getBookCount(): Int 43 | 44 | /** 45 | * 存储选中的书籍 46 | */ 47 | fun saveCheckedBooks() 48 | } 49 | 50 | interface ILocalBookCallback { 51 | fun onCheckedChange(isChecked: Boolean) 52 | fun onSaveCheckedBooks(localBooks: List) 53 | fun onDeleteCheckedBooks(localBooks: List) 54 | } -------------------------------------------------------------------------------- /app/src/main/java/com/newbiechen/nbreader/ui/component/book/library/BookLibrary.kt: -------------------------------------------------------------------------------- 1 | package com.newbiechen.nbreader.ui.component.book.library 2 | 3 | import com.newbiechen.nbreader.data.entity.BookEntity 4 | 5 | /** 6 | * author : newbiechen 7 | * date : 2019-09-16 17:09 8 | * description :书籍存取 9 | */ 10 | 11 | class BookLibrary : IBookLibrary { 12 | 13 | override fun getBookById(id: String): BookEntity { 14 | TODO("not implemented") //To change body of created functions use File | Settings | File Templates. 15 | } 16 | 17 | override fun getBookByPath(path: String): BookEntity { 18 | TODO("not implemented") //To change body of created functions use File | Settings | File Templates. 19 | } 20 | 21 | override fun getRecentBook(): BookEntity { 22 | TODO("not implemented") //To change body of created functions use File | Settings | File Templates. 23 | } 24 | 25 | override fun saveBook(book: BookEntity) { 26 | TODO("not implemented") //To change body of created functions use File | Settings | File Templates. 27 | } 28 | 29 | override fun removeBookById(id: String) { 30 | TODO("not implemented") //To change body of created functions use File | Settings | File Templates. 31 | } 32 | 33 | } --------------------------------------------------------------------------------