4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.github.barteksc.pdfviewer.listener;
17 |
18 | public interface OnErrorListener {
19 |
20 | /**
21 | * Called if error occurred while opening PDF
22 | * @param t Throwable with error
23 | */
24 | void onError(Throwable t);
25 | }
26 |
--------------------------------------------------------------------------------
/android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/listener/OnRenderListener.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2017 Bartosz Schiller
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.github.barteksc.pdfviewer.listener;
17 |
18 | public interface OnRenderListener {
19 |
20 | /**
21 | * Called only once, when document is rendered
22 | * @param nbPages number of pages
23 | */
24 | void onInitiallyRendered(int nbPages);
25 | }
26 |
--------------------------------------------------------------------------------
/android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/listener/OnPageErrorListener.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2017 Bartosz Schiller
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.github.barteksc.pdfviewer.listener;
17 |
18 | public interface OnPageErrorListener {
19 |
20 | /**
21 | * Called if error occurred while loading PDF page
22 | * @param t Throwable with error
23 | */
24 | void onPageError(int page, Throwable t);
25 | }
26 |
--------------------------------------------------------------------------------
/app/src/main/java/com/aaron/yespdf/common/DaoConverter.java:
--------------------------------------------------------------------------------
1 | package com.aaron.yespdf.common;
2 |
3 | import org.greenrobot.greendao.converter.PropertyConverter;
4 |
5 | import java.util.Arrays;
6 | import java.util.List;
7 |
8 | /**
9 | * @author Aaron aaronzzxup@gmail.com
10 | */
11 | public final class DaoConverter implements PropertyConverter, String> {
12 |
13 | @Override
14 | public List convertToEntityProperty(String databaseValue) {
15 | if (databaseValue == null) {
16 | return null;
17 | }
18 | return Arrays.asList(databaseValue.split(","));
19 | }
20 |
21 | @Override
22 | public String convertToDatabaseValue(List entityProperty) {
23 | if (entityProperty == null) {
24 | return null;
25 | }
26 | StringBuilder sb = new StringBuilder();
27 | for (String json : entityProperty) {
28 | sb.append(json).append(",");
29 | }
30 | return sb.substring(0, sb.length() - 1);
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/app_ic_action_settings_white.xml:
--------------------------------------------------------------------------------
1 |
8 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/app_ic_action_settings_black.xml:
--------------------------------------------------------------------------------
1 |
8 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/app_fragment_auto_scan.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
13 |
14 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/link/LinkHandler.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2017 Bartosz Schiller
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.github.barteksc.pdfviewer.link;
17 |
18 | import com.github.barteksc.pdfviewer.model.LinkTapEvent;
19 |
20 | public interface LinkHandler {
21 |
22 | /**
23 | * Called when link was tapped by user
24 | *
25 | * @param event current event
26 | */
27 | void handleLinkEvent(LinkTapEvent event);
28 | }
29 |
--------------------------------------------------------------------------------
/app/src/main/java/com/aaron/yespdf/filepicker/SelectFragmentAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.aaron.yespdf.filepicker
2 |
3 | import androidx.fragment.app.Fragment
4 | import androidx.fragment.app.FragmentManager
5 | import androidx.fragment.app.FragmentPagerAdapter
6 | import com.aaron.yespdf.R
7 | import com.aaron.yespdf.common.App
8 |
9 | /**
10 | * @author Aaron aaronzzxup@gmail.com
11 | */
12 | internal class SelectFragmentAdapter(fm: FragmentManager) : FragmentPagerAdapter(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) {
13 |
14 | override fun getItem(position: Int): Fragment {
15 | return if (position == 0) {
16 | AutoScanFragment.newInstance()
17 | } else ViewAllFragment.newInstance()
18 | }
19 |
20 | override fun getCount(): Int {
21 | return 2
22 | }
23 |
24 | override fun getPageTitle(position: Int): CharSequence? {
25 | return TITLES[position]
26 | }
27 |
28 | companion object {
29 | private val TITLES = arrayOf(App.getContext().getString(R.string.app_auto_scan), App.getContext().getString(R.string.app_view_all))
30 | }
31 | }
--------------------------------------------------------------------------------
/android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/source/DocumentSource.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Bartosz Schiller.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.github.barteksc.pdfviewer.source;
17 |
18 | import android.content.Context;
19 |
20 | import com.shockwave.pdfium.PdfDocument;
21 | import com.shockwave.pdfium.PdfiumCore;
22 |
23 | import java.io.IOException;
24 |
25 | public interface DocumentSource {
26 | PdfDocument createDocument(Context context, PdfiumCore core, String password) throws IOException;
27 | }
28 |
--------------------------------------------------------------------------------
/android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/listener/OnLoadCompleteListener.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 Bartosz Schiller
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.github.barteksc.pdfviewer.listener;
17 |
18 | /**
19 | * Implement this interface to receive events from PDFView
20 | * when loading is complete.
21 | */
22 | public interface OnLoadCompleteListener {
23 |
24 | /**
25 | * Called when the PDF is loaded
26 | * @param nbPages the number of pages in this PDF file
27 | */
28 | void loadComplete(int nbPages);
29 | }
30 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app's APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Automatically convert third-party libraries to use AndroidX
19 | android.enableJetifier=true
20 |
21 |
--------------------------------------------------------------------------------
/.idea/dictionaries/Aaron.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | aaronzzx
5 | animatable
6 | appid
7 | autofill
8 | autoscroll
9 | blurlayout
10 | bottombar
11 | bugly
12 | coolapk
13 | disp
14 | doubletap
15 | emptyview
16 | filepicker
17 | fileprovider
18 | hmmss
19 | ibtn
20 | importeds
21 | infos
22 | numpicker
23 | operationbar
24 | pageinfo
25 | pdfs
26 | pdfview
27 | qrcode
28 | quickbar
29 | scaner
30 | searchview
31 | seekbar
32 | selectall
33 | selecteds
34 | tencent
35 | thum
36 | traversable
37 | unbinder
38 | undoredobar
39 | wechat
40 | xxxhlarge
41 | yespdf
42 |
43 |
44 |
--------------------------------------------------------------------------------
/android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/exception/FileNotFoundException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 Bartosz Schiller
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.github.barteksc.pdfviewer.exception;
17 |
18 | @Deprecated
19 | public class FileNotFoundException extends RuntimeException {
20 |
21 | public FileNotFoundException(String detailMessage) {
22 | super(detailMessage);
23 | }
24 |
25 | public FileNotFoundException(String detailMessage, Throwable throwable) {
26 | super(detailMessage, throwable);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/app_bottomdialog_grouping.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
16 |
17 |
27 |
28 |
--------------------------------------------------------------------------------
/android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/link/link.plantuml:
--------------------------------------------------------------------------------
1 | @startuml
2 |
3 | title __LINK's Class Diagram__\n
4 |
5 | namespace com.github.barteksc.pdfviewer {
6 | namespace link {
7 | class com.github.barteksc.pdfviewer.link.DefaultLinkHandler {
8 | {static} - TAG : String
9 | + DefaultLinkHandler()
10 | + handleLinkEvent()
11 | - handlePage()
12 | - handleUri()
13 | }
14 | }
15 | }
16 |
17 |
18 | namespace com.github.barteksc.pdfviewer {
19 | namespace link {
20 | interface com.github.barteksc.pdfviewer.link.LinkHandler {
21 | {abstract} + handleLinkEvent()
22 | }
23 | }
24 | }
25 |
26 |
27 | com.github.barteksc.pdfviewer.link.DefaultLinkHandler .up.|> com.github.barteksc.pdfviewer.link.LinkHandler
28 | com.github.barteksc.pdfviewer.link.DefaultLinkHandler o-- com.github.barteksc.pdfviewer.PDFView : pdfView
29 |
30 |
31 | right footer
32 |
33 |
34 | PlantUML diagram generated by SketchIt! (https://bitbucket.org/pmesmeur/sketch.it)
35 | For more information about this tool, please contact philippe.mesmeur@gmail.com
36 | endfooter
37 |
38 | @enduml
39 |
--------------------------------------------------------------------------------
/app/src/main/java/com/aaron/yespdf/common/utils/utils.plantuml:
--------------------------------------------------------------------------------
1 | @startuml
2 |
3 | title __UTILS's Class Diagram__\n
4 |
5 | namespace com.aaron.yespdf {
6 | namespace common {
7 | namespace utils {
8 | class com.aaron.yespdf.common.utils.DialogUtils {
9 | {static} + createBottomSheetDialog()
10 | {static} + createBottomSheetDialog()
11 | {static} + createDialog()
12 | {static} + createDialog()
13 | - DialogUtils()
14 | }
15 | }
16 | }
17 | }
18 |
19 |
20 | namespace com.aaron.yespdf {
21 | namespace common {
22 | namespace utils {
23 | class com.aaron.yespdf.common.utils.PdfUtils {
24 | {static} + getPdfHeight()
25 | {static} + getPdfTotalPage()
26 | {static} + getPdfWidth()
27 | {static} + pdfToBitmap()
28 | {static} + saveBitmap()
29 | - PdfUtils()
30 | }
31 | }
32 | }
33 | }
34 |
35 |
36 |
37 |
38 | right footer
39 |
40 |
41 | PlantUML diagram generated by SketchIt! (https://bitbucket.org/pmesmeur/sketch.it)
42 | For more information about this tool, please contact philippe.mesmeur@gmail.com
43 | endfooter
44 |
45 | @enduml
46 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/app_loading_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/app_dialog_loading.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
20 |
21 |
30 |
31 |
--------------------------------------------------------------------------------
/android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/listener/OnPageChangeListener.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 Bartosz Schiller
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.github.barteksc.pdfviewer.listener;
17 |
18 | /**
19 | * Implements this interface to receive events from PDFView
20 | * when a page has changed through swipe
21 | */
22 | public interface OnPageChangeListener {
23 |
24 | /**
25 | * Called when the user use swipe to change page
26 | *
27 | * @param page the new page displayed, starting from 0
28 | * @param pageCount the total page count
29 | */
30 | void onPageChanged(int page, int pageCount);
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/app/src/main/java/com/aaron/yespdf/common/YGridDecoration.java:
--------------------------------------------------------------------------------
1 | package com.aaron.yespdf.common;
2 |
3 | import android.graphics.Rect;
4 | import android.view.View;
5 |
6 | import androidx.annotation.NonNull;
7 | import androidx.recyclerview.widget.RecyclerView;
8 |
9 | import com.blankj.utilcode.util.ConvertUtils;
10 |
11 | /**
12 | * @author Aaron aaronzzxup@gmail.com
13 | */
14 | public class YGridDecoration extends RecyclerView.ItemDecoration {
15 |
16 | @Override
17 | public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
18 | if (Settings.INSTANCE.getLinearLayout()) {
19 | outRect.top = ConvertUtils.dp2px(6f);
20 | outRect.bottom = ConvertUtils.dp2px(6f);
21 | return;
22 | }
23 | int count = state.getItemCount();
24 | int pos = parent.getChildAdapterPosition(view);
25 | if (pos < 3) {
26 | outRect.top = ConvertUtils.dp2px(8);
27 | } else if (pos >= count - 3) {
28 | outRect.top = ConvertUtils.dp2px(24);
29 | outRect.bottom = ConvertUtils.dp2px(8);
30 | } else {
31 | outRect.top = ConvertUtils.dp2px(24);
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/listener/OnLongPressListener.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2017 Bartosz Schiller
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.github.barteksc.pdfviewer.listener;
17 |
18 | import android.view.MotionEvent;
19 |
20 | /**
21 | * Implement this interface to receive events from PDFView
22 | * when view has been long pressed
23 | */
24 | public interface OnLongPressListener {
25 |
26 | /**
27 | * Called when the user has a long tap gesture, before processing scroll handle toggling
28 | *
29 | * @param e MotionEvent that registered as a confirmed long press
30 | */
31 | void onLongPress(MotionEvent e);
32 | }
33 |
--------------------------------------------------------------------------------
/android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/listener/OnPageScrollListener.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 Bartosz Schiller
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.github.barteksc.pdfviewer.listener;
17 |
18 | /**
19 | * Implements this interface to receive events from PDFView
20 | * when a page has been scrolled
21 | */
22 | public interface OnPageScrollListener {
23 |
24 | /**
25 | * Called on every move while scrolling
26 | *
27 | * @param page current page index
28 | * @param positionOffset see {@link com.github.barteksc.pdfviewer.PDFView#getPositionOffset()}
29 | */
30 | void onPageScrolled(int page, float positionOffset);
31 | }
32 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/app_dialog_qrcode.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
14 |
15 |
20 |
21 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 | *.apk
3 | *.ap_
4 |
5 | # Files for the ART/Dalvik VM
6 | *.dex
7 |
8 | # Java class files
9 | *.class
10 |
11 | # Generated files
12 | bin/
13 | gen/
14 | out/
15 |
16 | # Gradle files
17 | .gradle/
18 | build/
19 |
20 | # Local configuration file (sdk path, etc)
21 | local.properties
22 |
23 | # Proguard folder generated by Eclipse
24 | proguard/
25 |
26 | # Log Files
27 | *.log
28 |
29 | # Android Studio Navigation editor temp files
30 | .navigation/
31 |
32 | # Android Studio captures folder
33 | captures/
34 |
35 | # IntelliJ
36 | *.iml
37 | .idea/workspace.xml
38 | .idea/tasks.xml
39 | .idea/gradle.xml
40 | .idea/assetWizardSettings.xml
41 | .idea/dictionaries
42 | .idea/libraries
43 | .idea/caches
44 |
45 | # Keystore files
46 | # Uncomment the following line if you do not want to check your keystore files in.
47 | *.jks
48 |
49 | # External native build folder generated in Android Studio 2.2 and later
50 | .externalNativeBuild
51 |
52 | # Google Services (e.g. APIs or Firebase)
53 | google-services.json
54 |
55 | # Freeline
56 | freeline.py
57 | freeline/
58 | freeline_project_description.json
59 |
60 | # fastlane
61 | fastlane/report.xml
62 | fastlane/Preview.html
63 | fastlane/screenshots
64 | fastlane/test_output
65 | fastlane/readme.md
66 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/app_recycler_item_settings_seekbar.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
17 |
18 |
30 |
31 |
--------------------------------------------------------------------------------
/android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/listener/OnTapListener.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2017 Bartosz Schiller
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.github.barteksc.pdfviewer.listener;
17 |
18 | import android.view.MotionEvent;
19 |
20 | /**
21 | * Implement this interface to receive events from PDFView
22 | * when view has been touched
23 | */
24 | public interface OnTapListener {
25 |
26 | /**
27 | * Called when the user has a tap gesture, before processing scroll handle toggling
28 | *
29 | * @param e MotionEvent that registered as a confirmed single tap
30 | * @return true if the single tap was handled, false to toggle scroll handle
31 | */
32 | boolean onTap(MotionEvent e);
33 | }
34 |
--------------------------------------------------------------------------------
/app/src/main/java/com/aaron/yespdf/common/CollectionHolder.kt:
--------------------------------------------------------------------------------
1 | package com.aaron.yespdf.common
2 |
3 | import android.view.View
4 | import android.widget.CheckBox
5 | import android.widget.TextView
6 | import com.aaron.yespdf.R
7 | import com.aaron.yespdf.common.widgets.BorderImageView
8 |
9 | /**
10 | * @author Aaron aaronzzxup@gmail.com
11 | */
12 | class CollectionHolder(itemView: View) : BaseHolder(itemView) {
13 | val ivCover1: BorderImageView
14 | val ivCover2: BorderImageView
15 | val ivCover3: BorderImageView
16 | val ivCover4: BorderImageView
17 | val tvTitle: TextView
18 | val tvCount: TextView
19 | override val checkBox: CheckBox
20 |
21 | companion object {
22 | const val DEFAULT_LAYOUT = R.layout.app_recycler_item_collection
23 | const val DEFAULT_LAYOUT_HORIZONTAL = R.layout.app_recycler_item_collection_horizontal
24 | }
25 |
26 | init {
27 | ivCover1 = itemView.findViewById(R.id.app_iv_1)
28 | ivCover2 = itemView.findViewById(R.id.app_iv_2)
29 | ivCover3 = itemView.findViewById(R.id.app_iv_3)
30 | ivCover4 = itemView.findViewById(R.id.app_iv_4)
31 | tvTitle = itemView.findViewById(R.id.app_tv_title)
32 | tvCount = itemView.findViewById(R.id.app_tv_count)
33 | checkBox = itemView.findViewById(R.id.app_cb)
34 | }
35 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/aaron/yespdf/main/MainPresenter.kt:
--------------------------------------------------------------------------------
1 | package com.aaron.yespdf.main
2 |
3 | import com.aaron.yespdf.common.DBHelper
4 | import com.aaron.yespdf.common.DataManager
5 | import com.aaron.yespdf.filepicker.SelectActivity
6 | import kotlinx.coroutines.CoroutineScope
7 | import kotlinx.coroutines.Dispatchers
8 | import kotlinx.coroutines.launch
9 | import kotlinx.coroutines.withContext
10 |
11 | /**
12 | * @author Aaron aaronzzxup@gmail.com
13 | */
14 | internal class MainPresenter(view: IMainView) : IMainPresenter(view) {
15 |
16 | override fun insertPDF(paths: List?, type: Int?, groupName: String?) {
17 | if (paths == null || type == null) {
18 | return
19 | }
20 | (view as CoroutineScope).launch {
21 | view.onShowLoading()
22 | withContext(Dispatchers.IO) {
23 | val paths = paths.reversed()
24 | if (type == SelectActivity.TYPE_BASE_FOLDER) {
25 | DBHelper.insert(paths)
26 | } else { // SelectActivity.TYPE_TO_EXIST, SelectActivity.TYPE_CUSTOM
27 | DBHelper.insert(paths, groupName ?: "BASE_FOLDER")
28 | }
29 | }
30 | DataManager.updateAll()
31 | view.onUpdate()
32 | view.onHideLoading()
33 | }
34 | }
35 | }
--------------------------------------------------------------------------------
/android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/source/ByteArraySource.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Bartosz Schiller.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.github.barteksc.pdfviewer.source;
17 |
18 | import android.content.Context;
19 |
20 | import com.shockwave.pdfium.PdfDocument;
21 | import com.shockwave.pdfium.PdfiumCore;
22 |
23 | import java.io.IOException;
24 |
25 | public class ByteArraySource implements DocumentSource {
26 |
27 | private byte[] data;
28 |
29 | public ByteArraySource(byte[] data) {
30 | this.data = data;
31 | }
32 |
33 | @Override
34 | public PdfDocument createDocument(Context context, PdfiumCore core, String password) throws IOException {
35 | return core.newDocument(data, password);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/app_activity_search.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
14 |
15 |
22 |
23 |
24 |
25 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FFFFFF
4 | #FFFFFF
5 | #E54F4F
6 | #E28B8B
7 | #E54F4F
8 | @color/base_black
9 | #787878
10 | @color/base_black
11 | #FFCB6B
12 |
13 | #08000000
14 | #1FE54F4F
15 |
16 | #E57373
17 | #9575CD
18 | #4FC3F7
19 | #81C784
20 | #FFB74D
21 |
22 | @color/base_black
23 | @color/app_color_accent
24 | @color/base_white
25 | @color/base_white_shallow
26 |
27 |
--------------------------------------------------------------------------------
/app/src/main/res/values/attr.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/source/UriSource.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Bartosz Schiller.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.github.barteksc.pdfviewer.source;
17 |
18 | import android.content.Context;
19 | import android.net.Uri;
20 | import android.os.ParcelFileDescriptor;
21 |
22 | import com.shockwave.pdfium.PdfDocument;
23 | import com.shockwave.pdfium.PdfiumCore;
24 |
25 | import java.io.IOException;
26 |
27 | public class UriSource implements DocumentSource {
28 |
29 | private Uri uri;
30 |
31 | public UriSource(Uri uri) {
32 | this.uri = uri;
33 | }
34 |
35 | @Override
36 | public PdfDocument createDocument(Context context, PdfiumCore core, String password) throws IOException {
37 | ParcelFileDescriptor pfd = context.getContentResolver().openFileDescriptor(uri, "r");
38 | return core.newDocument(pfd, password);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/app/src/main/java/com/aaron/yespdf/common/widgets/NewViewPager.java:
--------------------------------------------------------------------------------
1 | package com.aaron.yespdf.common.widgets;
2 |
3 | import android.annotation.SuppressLint;
4 | import android.content.Context;
5 | import android.util.AttributeSet;
6 | import android.view.MotionEvent;
7 |
8 | import androidx.annotation.NonNull;
9 | import androidx.annotation.Nullable;
10 | import androidx.viewpager.widget.ViewPager;
11 |
12 | /**
13 | * @author Aaron aaronzzxup@gmail.com
14 | */
15 | public class NewViewPager extends ViewPager {
16 |
17 | private boolean mScrollable = true;
18 |
19 | public NewViewPager(@NonNull Context context) {
20 | super(context);
21 | }
22 |
23 | public NewViewPager(@NonNull Context context, @Nullable AttributeSet attrs) {
24 | super(context, attrs);
25 | }
26 |
27 | @SuppressLint("ClickableViewAccessibility")
28 | @Override
29 | public boolean onTouchEvent(MotionEvent ev) {
30 | if (mScrollable) {
31 | return super.onTouchEvent(ev);
32 | }
33 | return false; // 必须返回 false ,否则子 View 无法处理触摸事件
34 | }
35 |
36 | @Override
37 | public boolean onInterceptTouchEvent(MotionEvent ev) {
38 | if (mScrollable) {
39 | return super.onInterceptTouchEvent(ev);
40 | }
41 | return false; // 必须返回 false ,否则子 View 无法处理触摸事件
42 | }
43 |
44 | /**
45 | * 是否允许左右滑动
46 | */
47 | public void setScrollable(boolean enable) {
48 | mScrollable = enable;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/source/InputStreamSource.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Bartosz Schiller.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.github.barteksc.pdfviewer.source;
17 |
18 | import android.content.Context;
19 |
20 | import com.github.barteksc.pdfviewer.util.Util;
21 | import com.shockwave.pdfium.PdfDocument;
22 | import com.shockwave.pdfium.PdfiumCore;
23 |
24 | import java.io.IOException;
25 | import java.io.InputStream;
26 |
27 | public class InputStreamSource implements DocumentSource {
28 |
29 | private InputStream inputStream;
30 |
31 | public InputStreamSource(InputStream inputStream) {
32 | this.inputStream = inputStream;
33 | }
34 |
35 | @Override
36 | public PdfDocument createDocument(Context context, PdfiumCore core, String password) throws IOException {
37 | return core.newDocument(Util.toByteArray(inputStream), password);
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/source/FileSource.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Bartosz Schiller.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.github.barteksc.pdfviewer.source;
17 |
18 | import android.content.Context;
19 | import android.os.ParcelFileDescriptor;
20 |
21 | import com.shockwave.pdfium.PdfDocument;
22 | import com.shockwave.pdfium.PdfiumCore;
23 |
24 | import java.io.File;
25 | import java.io.IOException;
26 |
27 | public class FileSource implements DocumentSource {
28 |
29 | private File file;
30 |
31 | public FileSource(File file) {
32 | this.file = file;
33 | }
34 |
35 | @Override
36 | public PdfDocument createDocument(Context context, PdfiumCore core, String password) throws IOException {
37 | ParcelFileDescriptor pfd = ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY);
38 | return core.newDocument(pfd, password);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/app/src/main/java/com/aaron/yespdf/about/Info.kt:
--------------------------------------------------------------------------------
1 | package com.aaron.yespdf.about
2 |
3 | import android.annotation.SuppressLint
4 | import android.os.Build
5 | import com.aaron.yespdf.BuildConfig
6 | import com.aaron.yespdf.R
7 | import com.aaron.yespdf.common.App
8 | import com.blankj.utilcode.util.ScreenUtils
9 | import java.util.*
10 |
11 | /**
12 | * @author Aaron aaronzzxup@gmail.com
13 | */
14 | @SuppressLint("ConstantLocale")
15 | interface Info {
16 | companion object {
17 | const val MY_BLOG = "https://juejin.im/user/5c3f3b2b5188252580051f8c"
18 | const val MY_EMAIL = "mailto:aaronzzxup@gmail.com"
19 | const val SOURCE_CODE = "https://github.com/Aaronzzx/YESPDF"
20 | const val MY_GITHUB = "https://github.com/Aaronzzx"
21 | val FEEDBACK_SUBJECT = ("YES PDF! for Android " + "view" + BuildConfig.VERSION_NAME + "\n"
22 | + "Feedback(" + Build.BRAND + "-" + Build.MODEL + ")")
23 | val FEEDBACK_TEXT = (App.getContext().getString(R.string.app_feedback_title) + "\n"
24 | + "Device: " + Build.BRAND + "-" + Build.MODEL + "\n"
25 | + "Android Version: " + Build.VERSION.RELEASE + "(SDK=" + Build.VERSION.SDK_INT + ")" + "\n"
26 | + "Resolution: " + ScreenUtils.getScreenWidth() + "*" + ScreenUtils.getScreenHeight() + "\n"
27 | + "System Language: " + Locale.getDefault().language + "(" + Locale.getDefault().country + ")" + "\n"
28 | + "App Version: " + BuildConfig.VERSION_NAME)
29 | }
30 | }
--------------------------------------------------------------------------------
/android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/listener/OnDrawListener.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 Bartosz Schiller
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.github.barteksc.pdfviewer.listener;
17 |
18 | import android.graphics.Canvas;
19 |
20 | /**
21 | * This interface allows an extern class to draw
22 | * something on the PDFView canvas, above all images.
23 | */
24 | public interface OnDrawListener {
25 |
26 | /**
27 | * This method is called when the PDFView is
28 | * drawing its view.
29 | *
30 | * The page is starting at (0,0)
31 | *
32 | * @param canvas The canvas on which to draw things.
33 | * @param pageWidth The width of the current page.
34 | * @param pageHeight The height of the current page.
35 | * @param displayedPage The current page index
36 | */
37 | void onLayerDrawn(Canvas canvas, float pageWidth, float pageHeight, int displayedPage);
38 | }
39 |
--------------------------------------------------------------------------------
/android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/scroll/ScrollHandle.java:
--------------------------------------------------------------------------------
1 | package com.github.barteksc.pdfviewer.scroll;
2 |
3 | import com.github.barteksc.pdfviewer.PDFView;
4 |
5 | public interface ScrollHandle {
6 |
7 | /**
8 | * Used to move the handle, called internally by PDFView
9 | *
10 | * @param position current scroll ratio between 0 and 1
11 | */
12 | void setScroll(float position);
13 |
14 | /**
15 | * Method called by PDFView after setting scroll handle.
16 | * Do not call this method manually.
17 | * For usage sample see {@link DefaultScrollHandle}
18 | *
19 | * @param pdfView PDFView instance
20 | */
21 | void setupLayout(PDFView pdfView);
22 |
23 | /**
24 | * Method called by PDFView when handle should be removed from layout
25 | * Do not call this method manually.
26 | */
27 | void destroyLayout();
28 |
29 | /**
30 | * Set page number displayed on handle
31 | *
32 | * @param pageNum page number
33 | */
34 | void setPageNum(int pageNum);
35 |
36 | /**
37 | * Get handle visibility
38 | *
39 | * @return true if handle is visible, false otherwise
40 | */
41 | boolean shown();
42 |
43 | /**
44 | * Show handle
45 | */
46 | void show();
47 |
48 | /**
49 | * Hide handle immediately
50 | */
51 | void hide();
52 |
53 | /**
54 | * Hide handle after some time (defined by implementation)
55 | */
56 | void hideDelayed();
57 | }
58 |
--------------------------------------------------------------------------------
/app/src/main/java/com/aaron/yespdf/filepicker/IViewAllContract.kt:
--------------------------------------------------------------------------------
1 | package com.aaron.yespdf.filepicker
2 |
3 | import androidx.annotation.StringRes
4 | import com.aaron.yespdf.common.IModel
5 | import com.aaron.yespdf.common.IPresenter
6 | import com.aaron.yespdf.common.IView
7 | import com.blankj.utilcode.util.SDCardUtils.SDCardInfo
8 | import java.io.File
9 | import java.util.*
10 | import kotlin.collections.ArrayList
11 |
12 | /**
13 | * @author Aaron aaronzzxup@gmail.com
14 | */
15 | interface IViewAllModel : IModel {
16 | fun listStorage(callback: (List?) -> Unit)
17 | fun listFile(path: String?, callback: (List?) -> Unit)
18 | fun saveLastPath(path: String?)
19 | fun queryLastPath(): String?
20 |
21 | companion object {
22 | const val SP_LAST_PATH = "SP_LAST_PATH" // 使用首选项存放退出之前的路径
23 | }
24 | }
25 |
26 | interface IViewAllView : IView {
27 | fun onShowMessage(@StringRes stringId: Int)
28 | fun onShowFileList(fileList: List?)
29 | fun onShowPath(pathList: List)
30 | }
31 |
32 | abstract class IViewAllPresenter(view: IViewAllView) : IPresenter(view) {
33 | protected abstract val model: IViewAllModel
34 | protected var fileList: MutableList = ArrayList()
35 |
36 | abstract fun canFinish(): Boolean
37 | abstract fun goBack()
38 | abstract fun listStorage()
39 | abstract fun listFile(path: String?)
40 | abstract fun detach()
41 |
42 | companion object {
43 | const val ROOT_PATH = "/storage/emulated"
44 | }
45 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/aaron/yespdf/main/OperationBarHelper.kt:
--------------------------------------------------------------------------------
1 | package com.aaron.yespdf.main
2 |
3 | import android.animation.Animator
4 | import android.animation.AnimatorListenerAdapter
5 | import android.view.View
6 | import android.view.animation.AccelerateDecelerateInterpolator
7 | import android.view.animation.BounceInterpolator
8 |
9 | /**
10 | * @author Aaron aaronzzxup@gmail.com
11 | */
12 | object OperationBarHelper {
13 | fun show(view: View) {
14 | view.animate()
15 | .scaleX(1.0F)
16 | .scaleY(1.0F)
17 | .alpha(1.0F)
18 | .setDuration(100L)
19 | .setInterpolator(AccelerateDecelerateInterpolator())
20 | .setListener(object : AnimatorListenerAdapter() {
21 | override fun onAnimationStart(animation: Animator?) {
22 | view.visibility = View.VISIBLE
23 | }
24 | })
25 | .start()
26 | }
27 |
28 | fun hide(view: View) {
29 | view.animate()
30 | .scaleX(1.1F)
31 | .scaleY(1.1F)
32 | .alpha(0F)
33 | .setDuration(100L)
34 | .setInterpolator(AccelerateDecelerateInterpolator())
35 | .setListener(object : AnimatorListenerAdapter() {
36 | override fun onAnimationEnd(animation: Animator?) {
37 | view.visibility = View.GONE
38 | }
39 | })
40 | .start()
41 | }
42 | }
--------------------------------------------------------------------------------
/android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/model/model.plantuml:
--------------------------------------------------------------------------------
1 | @startuml
2 |
3 | title __MODEL's Class Diagram__\n
4 |
5 | namespace com.github.barteksc.pdfviewer {
6 | namespace model {
7 | class com.github.barteksc.pdfviewer.model.LinkTapEvent {
8 | - documentX : float
9 | - documentY : float
10 | - link : Link
11 | - mappedLinkRect : RectF
12 | - originalX : float
13 | - originalY : float
14 | + LinkTapEvent()
15 | + getDocumentX()
16 | + getDocumentY()
17 | + getLink()
18 | + getMappedLinkRect()
19 | + getOriginalX()
20 | + getOriginalY()
21 | }
22 | }
23 | }
24 |
25 |
26 | namespace com.github.barteksc.pdfviewer {
27 | namespace model {
28 | class com.github.barteksc.pdfviewer.model.PagePart {
29 | - cacheOrder : int
30 | - page : int
31 | - pageRelativeBounds : RectF
32 | - renderedBitmap : Bitmap
33 | - thumbnail : boolean
34 | + PagePart()
35 | + equals()
36 | + getCacheOrder()
37 | + getPage()
38 | + getPageRelativeBounds()
39 | + getRenderedBitmap()
40 | + isThumbnail()
41 | + setCacheOrder()
42 | }
43 | }
44 | }
45 |
46 |
47 |
48 |
49 | right footer
50 |
51 |
52 | PlantUML diagram generated by SketchIt! (https://bitbucket.org/pmesmeur/sketch.it)
53 | For more information about this tool, please contact philippe.mesmeur@gmail.com
54 | endfooter
55 |
56 | @enduml
57 |
--------------------------------------------------------------------------------
/android-pdf-viewer/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'kotlin-android-extensions'
3 | apply plugin: 'kotlin-android'
4 |
5 | ext {
6 | bintrayRepo = 'maven'
7 | bintrayName = 'android-pdf-viewer'
8 |
9 | publishedGroupId = 'com.github.barteksc'
10 | libraryName = 'AndroidPdfViewer'
11 | artifact = 'android-pdf-viewer'
12 |
13 | libraryDescription = 'Android view for displaying PDFs rendered with PdfiumAndroid'
14 |
15 | siteUrl = 'https://github.com/barteksc/AndroidPdfViewer'
16 | gitUrl = 'https://github.com/barteksc/AndroidPdfViewer.git'
17 |
18 | libraryVersion = '3.2.0-beta.1'
19 |
20 | developerId = 'barteksc'
21 | developerName = 'Bartosz Schiller'
22 | developerEmail = 'barteksch@boo.pl'
23 |
24 | licenseName = 'The Apache Software License, Version 2.0'
25 | licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
26 | allLicenses = ["Apache-2.0"]
27 | }
28 |
29 | android {
30 | compileSdkVersion 29
31 |
32 | defaultConfig {
33 | minSdkVersion 16
34 | targetSdkVersion 29
35 | versionCode 1
36 | versionName "3.2.0-beta.1"
37 | }
38 |
39 | }
40 |
41 | dependencies {
42 | implementation 'com.android.support:support-compat:28.0.0'
43 | api 'com.github.barteksc:pdfium-android:1.9.0'
44 | implementation 'com.aaron:base:1.1.5-beta9'
45 | implementation "androidx.core:core-ktx:+"
46 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
47 | }
48 |
49 | apply from: 'bintray.gradle'
50 | repositories {
51 | mavenCentral()
52 | }
--------------------------------------------------------------------------------
/app/src/main/res/layout/app_recycler_item_settings_recent_count.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
20 |
21 |
30 |
31 |
40 |
41 |
--------------------------------------------------------------------------------
/app/src/main/java/com/aaron/yespdf/main/CollectionAdapter2.kt:
--------------------------------------------------------------------------------
1 | package com.aaron.yespdf.main
2 |
3 | import android.widget.ImageView
4 | import com.aaron.base.image.DefaultOption
5 | import com.aaron.base.image.ImageLoader
6 | import com.aaron.yespdf.R
7 | import com.aaron.yespdf.common.App
8 | import com.aaron.yespdf.common.BaseAdapter
9 | import com.aaron.yespdf.common.CoverHolder
10 | import com.aaron.yespdf.common.Settings
11 | import com.aaron.yespdf.common.bean.PDF
12 | import com.blankj.utilcode.util.StringUtils
13 |
14 | /**
15 | * @author Aaron aaronzzxup@gmail.com
16 | */
17 | class CollectionAdapter2(
18 | data: MutableList
19 | ) : BaseAdapter(
20 | if (Settings.linearLayout) CoverHolder.DEFAULT_LAYOUT_HORIZONTAL
21 | else CoverHolder.DEFAULT_LAYOUT,
22 | data
23 | ) {
24 |
25 | override val checkBoxId: Int = R.id.app_cb
26 | override val emptyText: CharSequence = App.getContext().getString(R.string.app_have_no_all)
27 | override val emptyIcon: Int = R.drawable.app_img_all
28 |
29 | override fun convert(helper: CoverHolder, item: PDF) {
30 | item.run {
31 | helper.tvTitle.text = name
32 | helper.tvProgress.text = mContext.getString(R.string.app_already_read, progress)
33 | if (!StringUtils.isEmpty(cover)) {
34 | ImageLoader.load(mContext, DefaultOption.Builder(cover).into(helper.ivCover))
35 | } else {
36 | helper.ivCover.scaleType = ImageView.ScaleType.FIT_XY
37 | helper.ivCover.setImageResource(R.drawable.app_img_none_cover)
38 | }
39 | }
40 | }
41 | }
--------------------------------------------------------------------------------
/android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/util/Util.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Bartosz Schiller.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.github.barteksc.pdfviewer.util;
17 |
18 | import android.content.Context;
19 | import android.util.TypedValue;
20 |
21 | import java.io.ByteArrayOutputStream;
22 | import java.io.IOException;
23 | import java.io.InputStream;
24 |
25 | public class Util {
26 | private static final int DEFAULT_BUFFER_SIZE = 1024 * 4;
27 |
28 | public static int getDP(Context context, int dp) {
29 | return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, context.getResources().getDisplayMetrics());
30 | }
31 |
32 | public static byte[] toByteArray(InputStream inputStream) throws IOException {
33 | ByteArrayOutputStream os = new ByteArrayOutputStream();
34 | byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
35 | int n;
36 | while (-1 != (n = inputStream.read(buffer))) {
37 | os.write(buffer, 0, n);
38 | }
39 | return os.toByteArray();
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/source/AssetSource.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Bartosz Schiller.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.github.barteksc.pdfviewer.source;
17 |
18 |
19 | import android.content.Context;
20 | import android.os.ParcelFileDescriptor;
21 |
22 | import com.github.barteksc.pdfviewer.util.FileUtils;
23 | import com.shockwave.pdfium.PdfDocument;
24 | import com.shockwave.pdfium.PdfiumCore;
25 |
26 | import java.io.File;
27 | import java.io.IOException;
28 |
29 | public class AssetSource implements DocumentSource {
30 |
31 | private final String assetName;
32 |
33 | public AssetSource(String assetName) {
34 | this.assetName = assetName;
35 | }
36 |
37 | @Override
38 | public PdfDocument createDocument(Context context, PdfiumCore core, String password) throws IOException {
39 | File f = FileUtils.fileFromAsset(context, assetName);
40 | ParcelFileDescriptor pfd = ParcelFileDescriptor.open(f, ParcelFileDescriptor.MODE_READ_ONLY);
41 | return core.newDocument(pfd, password);
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/app/src/main/java/com/aaron/yespdf/common/greendao/UpdateOpenHelper.java:
--------------------------------------------------------------------------------
1 | package com.aaron.yespdf.common.greendao;
2 |
3 | import android.content.Context;
4 | import android.database.sqlite.SQLiteDatabase;
5 | import android.os.SystemClock;
6 | import android.util.Log;
7 |
8 | import com.aaron.yespdf.common.App;
9 | import com.aaron.yespdf.common.AppConfig;
10 | import com.aaron.yespdf.common.DBHelper;
11 |
12 | import org.greenrobot.greendao.database.Database;
13 |
14 | /**
15 | * @author Aaron aaronzzxup@gmail.com
16 | */
17 | public class UpdateOpenHelper extends DaoMaster.OpenHelper {
18 |
19 | public UpdateOpenHelper(Context context, String name) {
20 | super(context, name);
21 | }
22 |
23 | public UpdateOpenHelper(Context context, String name, SQLiteDatabase.CursorFactory factory) {
24 | super(context, name, factory);
25 | }
26 |
27 |
28 | @Override
29 | public void onUpgrade(Database db, int oldVersion, int newVersion) {
30 | super.onUpgrade(db, oldVersion, newVersion);
31 | Log.i("version", oldVersion + "---先前和更新之后的版本---" + newVersion);
32 | if (oldVersion < newVersion) {
33 | MigrationHelper.migrate(db, new MigrationHelper.ReCreateAllTableListener() {
34 | @Override
35 | public void onCreateAllTables(Database db, boolean ifNotExists) {
36 | DaoMaster.createAllTables(db, ifNotExists);
37 | }
38 |
39 | @Override
40 | public void onDropAllTables(Database db, boolean ifExists) {
41 | DaoMaster.dropAllTables(db, ifExists);
42 | }
43 | }, PDFDao.class, CollectionDao.class);
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/app/src/main/java/com/aaron/yespdf/common/event/event.plantuml:
--------------------------------------------------------------------------------
1 | @startuml
2 |
3 | title __EVENT's Class Diagram__\n
4 |
5 | namespace com.aaron.yespdf {
6 | namespace common {
7 | namespace event {
8 | class com.aaron.yespdf.common.event.AllEvent {
9 | }
10 | }
11 | }
12 | }
13 |
14 |
15 | namespace com.aaron.yespdf {
16 | namespace common {
17 | namespace event {
18 | class com.aaron.yespdf.common.event.ContentEvent {
19 | - bookmarkList : List
20 | + ContentEvent()
21 | + getBookmarkList()
22 | }
23 | }
24 | }
25 | }
26 |
27 |
28 | namespace com.aaron.yespdf {
29 | namespace common {
30 | namespace event {
31 | class com.aaron.yespdf.common.event.HotfixEvent {
32 | }
33 | }
34 | }
35 | }
36 |
37 |
38 | namespace com.aaron.yespdf {
39 | namespace common {
40 | namespace event {
41 | class com.aaron.yespdf.common.event.MaxRecentEvent {
42 | }
43 | }
44 | }
45 | }
46 |
47 |
48 | namespace com.aaron.yespdf {
49 | namespace common {
50 | namespace event {
51 | class com.aaron.yespdf.common.event.RecentPDFEvent {
52 | - fromPreviewActivity : boolean
53 | + RecentPDFEvent()
54 | + RecentPDFEvent()
55 | + isFromPreviewActivity()
56 | + setFromPreviewActivity()
57 | }
58 | }
59 | }
60 | }
61 |
62 |
63 |
64 |
65 | right footer
66 |
67 |
68 | PlantUML diagram generated by SketchIt! (https://bitbucket.org/pmesmeur/sketch.it)
69 | For more information about this tool, please contact philippe.mesmeur@gmail.com
70 | endfooter
71 |
72 | @enduml
73 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/app_bottomdialog_scan.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
19 |
20 |
29 |
30 |
40 |
41 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/app_recycler_item_backup.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
15 |
16 |
21 |
22 |
30 |
31 |
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/app_fragment_view_all.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
12 |
13 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
34 |
35 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/app/src/main/java/com/aaron/yespdf/filepicker/ViewAllModel.kt:
--------------------------------------------------------------------------------
1 | package com.aaron.yespdf.filepicker
2 |
3 | import com.aaron.yespdf.filepicker.IViewAllModel.Companion.SP_LAST_PATH
4 | import com.blankj.utilcode.util.SDCardUtils
5 | import com.blankj.utilcode.util.SDCardUtils.SDCardInfo
6 | import com.blankj.utilcode.util.SPStaticUtils
7 | import com.blankj.utilcode.util.ThreadUtils
8 | import com.blankj.utilcode.util.ThreadUtils.SimpleTask
9 | import java.io.File
10 |
11 | /**
12 | * @author Aaron aaronzzxup@gmail.com
13 | */
14 | class ViewAllModel : IViewAllModel {
15 |
16 | private val mListable: IListable
17 |
18 | override fun listStorage(callback: (List?) -> Unit) {
19 | ThreadUtils.executeByIo>(object : SimpleTask>() {
20 | override fun doInBackground(): List {
21 | return SDCardUtils.getSDCardInfo()
22 | }
23 |
24 | override fun onSuccess(result: List?) {
25 | callback(result)
26 | }
27 | })
28 | }
29 |
30 | override fun listFile(path: String?, callback: (List?) -> Unit) {
31 | ThreadUtils.executeByIo>(object : SimpleTask?>() {
32 | override fun doInBackground(): List? {
33 | return mListable.listFile(path)
34 | }
35 |
36 | override fun onSuccess(result: List?) {
37 | callback(result)
38 | }
39 | })
40 | }
41 |
42 | override fun saveLastPath(path: String?) {
43 | SPStaticUtils.put(SP_LAST_PATH, path)
44 | }
45 |
46 | override fun queryLastPath(): String? {
47 | return SPStaticUtils.getString(SP_LAST_PATH, "")
48 | }
49 |
50 | init {
51 | mListable = ByNameListable()
52 | }
53 | }
--------------------------------------------------------------------------------
/app/src/main/res/layout/app_activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
14 |
15 |
21 |
22 |
26 |
27 |
31 |
32 |
33 |
34 |
35 |
36 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/util/Constants.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 Bartosz Schiller
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.github.barteksc.pdfviewer.util;
17 |
18 | public class Constants {
19 |
20 | public static boolean DEBUG_MODE = false;
21 |
22 | /** Between 0 and 1, the thumbnails quality (default 0.3). Increasing this value may cause performance decrease */
23 | public static float THUMBNAIL_RATIO = 0.3f;
24 |
25 | /**
26 | * The size of the rendered parts (default 256)
27 | * Tinier : a little bit slower to have the whole page rendered but more reactive.
28 | * Bigger : user will have to wait longer to have the first visual results
29 | */
30 | public static float PART_SIZE = 256;
31 |
32 | /** Part of document above and below screen that should be preloaded, in dp */
33 | public static int PRELOAD_OFFSET = 20;
34 |
35 | public static class Cache {
36 |
37 | /** The size of the cache (number of bitmaps kept) */
38 | public static int CACHE_SIZE = 120;
39 |
40 | public static int THUMBNAILS_CACHE_SIZE = 8;
41 | }
42 |
43 | public static class Pinch {
44 |
45 | public static float MAXIMUM_ZOOM = 10;
46 |
47 | public static float MINIMUM_ZOOM = 1;
48 |
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------