Forráskód Böngészése

ComPDFKit Demo(Android) - 替换正式秘钥

liuxiaolong 1 éve
szülő
commit
7c8f5baf75

+ 0 - 6
LICENSE

@@ -1,6 +0,0 @@
-Copyright © 2014-2023 PDF Technologies, Inc. All Rights Reserved.
-
-THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
-AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE ComPDFKit LICENSE AGREEMENT.
-UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
-This notice may not be removed from this file.

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 2 - 2
compdfkit-tools/src/main/AndroidManifest.xml


+ 33 - 0
compdfkit-tools/src/main/java/com/compdfkit/tools/CPDFOutlineDialogFragment.java

@@ -0,0 +1,33 @@
+/**
+ * Copyright © 2014-2023 PDF Technologies, Inc. All Rights Reserved.
+ *
+ * THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
+ * AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE ComPDFKit LICENSE AGREEMENT.
+ * UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
+ * This notice may not be removed from this file.
+ */
+
+package com.compdfkit.tools;
+
+
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
+import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
+
+public class CPDFOutlineDialogFragment extends BottomSheetDialogFragment {
+
+    @Nullable
+    @Override
+    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
+        return super.onCreateView(inflater, container, savedInstanceState);
+    }
+
+
+
+}

+ 9 - 0
compdfkit-tools/src/main/java/com/compdfkit/tools/pdfview/CPDFReaderView.java

@@ -1,3 +1,12 @@
+/**
+ * Copyright © 2014-2023 PDF Technologies, Inc. All Rights Reserved.
+ *
+ * THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
+ * AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE ComPDFKit LICENSE AGREEMENT.
+ * UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
+ * This notice may not be removed from this file.
+ */
+
 package com.compdfkit.tools.pdfview;
 
 import android.content.Context;

+ 65 - 2
compdfkit-tools/src/main/java/com/compdfkit/tools/pdfview/CPDFToolBar.java

@@ -1,15 +1,29 @@
+/**
+ * Copyright © 2014-2023 PDF Technologies, Inc. All Rights Reserved.
+ * <p>
+ * THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
+ * AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE ComPDFKit LICENSE AGREEMENT.
+ * UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
+ * This notice may not be removed from this file.
+ */
+
 package com.compdfkit.tools.pdfview;
 
 
 import android.content.Context;
 import android.content.res.TypedArray;
+import android.graphics.Color;
+import android.graphics.drawable.Drawable;
 import android.text.TextUtils;
 import android.util.AttributeSet;
 import android.view.LayoutInflater;
+import android.view.View;
 import android.widget.FrameLayout;
 
 import androidx.annotation.NonNull;
 import androidx.annotation.Nullable;
+import androidx.appcompat.content.res.AppCompatResources;
+import androidx.appcompat.widget.AppCompatImageView;
 import androidx.appcompat.widget.AppCompatTextView;
 
 import com.compdfkit.tools.R;
@@ -17,6 +31,9 @@ import com.compdfkit.tools.R;
 public class CPDFToolBar extends FrameLayout {
 
     private AppCompatTextView tvToolBarTitle;
+    private AppCompatImageView ivToolBarSearchBtn;
+    private AppCompatImageView ivToolBarOutlineBtn;
+    private AppCompatImageView ivToolBarMoreBtn;
 
     public CPDFToolBar(@NonNull Context context) {
         super(context);
@@ -32,20 +49,66 @@ public class CPDFToolBar extends FrameLayout {
         super(context, attrs, defStyleAttr);
     }
 
-    private void initToolBar(Context context, @Nullable AttributeSet attrs){
+    private void initToolBar(Context context, @Nullable AttributeSet attrs) {
         LayoutInflater.from(getContext()).inflate(R.layout.tools_cpdf_tool_bar, this);
+        setBackgroundColor(Color.WHITE);
+        setElevation(8);
         tvToolBarTitle = findViewById(R.id.tv_tool_bar_title);
+        ivToolBarMoreBtn = findViewById(R.id.iv_tool_bar_more);
+        ivToolBarSearchBtn = findViewById(R.id.iv_tool_bar_search);
+        ivToolBarOutlineBtn = findViewById(R.id.iv_tool_bar_outline);
         initAttributes(context, attrs);
     }
 
-    private void initAttributes(Context context, @Nullable AttributeSet attrs){
+    private void initAttributes(Context context, @Nullable AttributeSet attrs) {
         TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.Tools_CPDFToolBar);
         if (typedArray != null) {
             String toolBarTitle = typedArray.getString(R.styleable.Tools_CPDFToolBar_tools_toolbar_title);
+            typedArray.getResourceId(R.styleable.Tools_CPDFToolBar_tools_toolbar_search_icon, -1);
             if (!TextUtils.isEmpty(toolBarTitle)) {
                 tvToolBarTitle.setText(toolBarTitle);
             }
+            Drawable searchIconDrawable = loadImageFromAttributes(typedArray, R.styleable.Tools_CPDFToolBar_tools_toolbar_search_icon, R.drawable.tools_ic_search);
+            if (searchIconDrawable != null) {
+                ivToolBarSearchBtn.setImageDrawable(searchIconDrawable);
+            }
+            Drawable outlineIconDrawable = loadImageFromAttributes(typedArray, R.styleable.Tools_CPDFToolBar_tools_toolbar_outline_icon, R.drawable.tools_ic_outline);
+            if (outlineIconDrawable != null) {
+                ivToolBarOutlineBtn.setImageDrawable(outlineIconDrawable);
+            }
+            Drawable moreIconDrawable = loadImageFromAttributes(typedArray, R.styleable.Tools_CPDFToolBar_tools_toolbar_more_icon, R.drawable.tools_ic_more);
+            if (moreIconDrawable != null) {
+                ivToolBarMoreBtn.setImageDrawable(moreIconDrawable);
+            }
+            typedArray.recycle();
+        }
+    }
+
+    private Drawable loadImageFromAttributes(TypedArray typedArray, int index, int defValue){
+        Drawable drawable = null;
+        try {
+            int resId = typedArray.getResourceId(index, defValue);
+            if (resId != -1){
+                drawable = AppCompatResources.getDrawable(getContext(), resId);
+            }
+            return drawable;
+        }catch (Exception e){
+            return null;
         }
     }
 
+
+    public void setSearchBtnClickListener(View.OnClickListener clickListener){
+        ivToolBarSearchBtn.setOnClickListener(clickListener);
+    }
+
+    public void setOutlineBtnClickListener(View.OnClickListener clickListener){
+        ivToolBarOutlineBtn.setOnClickListener(clickListener);
+    }
+
+    public void setMoreBtnClickListener(View.OnClickListener clickListener){
+        ivToolBarMoreBtn.setOnClickListener(clickListener);
+    }
+
+
 }

+ 9 - 0
compdfkit-tools/src/main/res/drawable/tools_ic_back.xml

@@ -0,0 +1,9 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="24dp"
+    android:height="24dp"
+    android:viewportWidth="32"
+    android:viewportHeight="32">
+  <path
+      android:pathData="M9.476,16.257c-0.103,-0.435 0.015,-0.912 0.355,-1.251l10.685,-10.685c0.521,-0.521 1.365,-0.521 1.886,0s0.521,1.365 0,1.886l-9.745,9.745 9.746,9.746c0.521,0.521 0.521,1.365 0,1.886s-1.365,0.521 -1.886,0l-10.685,-10.685c-0.171,-0.171 -0.296,-0.388 -0.354,-0.632l-0.002,-0.009z"
+      android:fillColor="#000000"/>
+</vector>

+ 45 - 0
compdfkit-tools/src/main/res/layout/tools_cpdf_outline_dialog_fragment.xml

@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools">
+
+
+    <androidx.constraintlayout.widget.ConstraintLayout
+        android:layout_width="match_parent"
+        android:layout_height="?android:attr/actionBarSize"
+        app:layout_constraintTop_toTopOf="parent"
+        >
+
+        <androidx.appcompat.widget.AppCompatImageView
+            android:id="@+id/iv_tool_bar_search"
+            android:layout_width="0dp"
+            android:layout_height="match_parent"
+            android:layout_margin="10dp"
+            android:padding="4dp"
+            app:layout_constraintBottom_toBottomOf="parent"
+            app:layout_constraintDimensionRatio="1:1"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintTop_toTopOf="parent"
+            app:srcCompat="@drawable/tools_ic_back" />
+
+        <androidx.appcompat.widget.AppCompatTextView
+            android:id="@+id/tv_tool_bar_title"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:textColor="@android:color/black"
+            app:layout_constraintBottom_toBottomOf="parent"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintTop_toTopOf="parent"
+            android:textSize="16sp"
+            android:text="Outline" />
+
+
+    </androidx.constraintlayout.widget.ConstraintLayout>
+
+
+
+
+</androidx.constraintlayout.widget.ConstraintLayout>

+ 1 - 0
compdfkit-tools/src/main/res/layout/tools_cpdf_tool_bar.xml

@@ -16,6 +16,7 @@
         app:layout_constraintEnd_toEndOf="parent"
         app:layout_constraintStart_toStartOf="parent"
         app:layout_constraintTop_toTopOf="parent"
+        android:textSize="16sp"
         tools:text="PDF View" />
 
     <androidx.appcompat.widget.AppCompatImageView

+ 3 - 0
compdfkit-tools/src/main/res/values/tools_attrs.xml

@@ -4,6 +4,9 @@
 
     <declare-styleable name="Tools_CPDFToolBar">
         <attr name="tools_toolbar_title" format="string"/>
+        <attr name="tools_toolbar_search_icon" format="reference"/>
+        <attr name="tools_toolbar_outline_icon" format="reference"/>
+        <attr name="tools_toolbar_more_icon" format="reference"/>
     </declare-styleable>
 
 </resources>

+ 1 - 1
viewer-ctrl-demo/build.gradle

@@ -8,7 +8,7 @@ android {
     resourcePrefix 'viewer_'
 
     defaultConfig {
-        applicationId "com.compdfkit.pdfviewer"
+        applicationId "com.compdfkit.demo.viewer"
         minSdk rootProject.ext.android.MINSDK
         targetSdk rootProject.ext.android.TARGETSDK
         versionCode rootProject.ext.android.VERSIONCODE

+ 19 - 1
viewer-ctrl-demo/src/main/java/com/compdfkit/demo/viewer/MainActivity.java

@@ -3,6 +3,7 @@ package com.compdfkit.demo.viewer;
 import androidx.appcompat.app.AppCompatActivity;
 
 import android.os.Bundle;
+import android.widget.Toast;
 
 import com.compdfkit.demo.viewer.databinding.ViewerActivityMainBinding;
 import com.compdfkit.tools.task.CExtractAssetFileTask;
@@ -21,10 +22,27 @@ public class MainActivity extends AppCompatActivity {
         super.onCreate(savedInstanceState);
         binding = ViewerActivityMainBinding.inflate(getLayoutInflater());
         setContentView(binding.getRoot());
-
+        initToolbarListener();
         CExtractAssetFileTask.extract(this, QUICK_START_GUIDE, QUICK_START_GUIDE, (pdfFile) ->
                 runOnUiThread(() -> binding.pdfReaderView.openPdfFile(pdfFile.getAbsolutePath())));
 
+
+    }
+
+
+    private void initToolbarListener(){
+        binding.pdfToolBar.setSearchBtnClickListener(v -> {
+            Toast.makeText(this, "search", Toast.LENGTH_SHORT).show();
+        });
+        binding.pdfToolBar.setOutlineBtnClickListener(v -> {
+            //open outline
+            Toast.makeText(this, "outline", Toast.LENGTH_SHORT).show();
+
+        });
+        binding.pdfToolBar.setMoreBtnClickListener(v -> {
+
+        });
+
     }
 
 }

+ 4 - 3
viewer-ctrl-demo/src/main/res/layout/viewer_activity_main.xml

@@ -4,23 +4,24 @@
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
+    android:elevation="4dp"
     tools:context=".MainActivity">
 
     <com.compdfkit.tools.pdfview.CPDFToolBar
-        android:id="@+id/cpdf_tool_bar"
+        android:id="@+id/pdf_tool_bar"
         android:layout_width="match_parent"
         android:layout_height="?android:attr/actionBarSize"
         app:layout_constraintTop_toTopOf="parent"
         app:layout_constraintStart_toStartOf="parent"
         app:layout_constraintEnd_toEndOf="parent"
-
+        app:tools_toolbar_title="@string/viewer_toolbar_title"
         />
 
     <com.compdfkit.tools.pdfview.CPDFReaderView
         android:id="@+id/pdf_reader_view"
         android:layout_width="match_parent"
         android:layout_height="0dp"
-        app:layout_constraintTop_toBottomOf="@id/cpdf_tool_bar"
+        app:layout_constraintTop_toBottomOf="@id/pdf_tool_bar"
         app:layout_constraintBottom_toBottomOf="parent"/>
 
 

+ 2 - 0
viewer-ctrl-demo/src/main/res/values/strings.xml

@@ -1,3 +1,5 @@
 <resources>
     <string name="viewer_app_name">viewer-ctrl-demo</string>
+
+    <string name="viewer_toolbar_title">PDFView</string>
 </resources>