Sfoglia il codice sorgente

PDFTool(Android) - 优化自定义图章列表

liuxiaolong 1 anno fa
parent
commit
f0479cffc0
14 ha cambiato i file con 352 aggiunte e 402 eliminazioni
  1. 74 108
      ComPDFKit_Tools/src/main/java/com/compdfkit/tools/annotation/pdfproperties/pdfstamp/CStampCustomFragment.java
  2. 108 0
      ComPDFKit_Tools/src/main/java/com/compdfkit/tools/annotation/pdfproperties/pdfstamp/adapter/CustomStampAdapter.java
  3. 80 0
      ComPDFKit_Tools/src/main/java/com/compdfkit/tools/annotation/pdfproperties/pdfstamp/bean/CCustomStampBean.java
  4. 0 86
      ComPDFKit_Tools/src/main/java/com/compdfkit/tools/common/views/pdfproperties/font/CExternFontSpinnerAdapter.java
  5. 38 14
      ComPDFKit_Tools/src/main/java/com/compdfkit/tools/common/views/pdfproperties/font/CFontSpinnerAdapter.java
  6. 0 97
      ComPDFKit_Tools/src/main/java/com/compdfkit/tools/common/views/pdfproperties/font/CFontSpinnerAdapter1.java
  7. 9 29
      ComPDFKit_Tools/src/main/java/com/compdfkit/tools/common/views/pdfproperties/font/CFontStyleSpinnerAdapter.java
  8. 2 2
      ComPDFKit_Tools/src/main/java/com/compdfkit/tools/common/views/pdfproperties/font/CPDFFontView.java
  9. 2 0
      ComPDFKit_Tools/src/main/java/com/compdfkit/tools/common/views/pdfproperties/pdfstyle/manager/provider/CSelectedAnnotStyleProvider.java
  10. 13 0
      ComPDFKit_Tools/src/main/res/layout/tools_annot_stamp_custom_stamp_title.xml
  11. 7 56
      ComPDFKit_Tools/src/main/res/layout/tools_properties_stamp_custom_list_fragment.xml
  12. 2 1
      ComPDFKit_Tools/src/main/res/layout/tools_properties_stamp_image_stamp_list_item.xml
  13. 15 8
      ComPDFKit_Tools/src/main/res/layout/tools_properties_stamp_standard_list_fragment.xml
  14. 2 1
      ComPDFKit_Tools/src/main/res/layout/tools_properties_stamp_text_stamp_list_item.xml

+ 74 - 108
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/annotation/pdfproperties/pdfstamp/CStampCustomFragment.java

@@ -20,14 +20,13 @@ import androidx.activity.result.ActivityResultLauncher;
 import androidx.activity.result.contract.ActivityResultContracts;
 import androidx.annotation.NonNull;
 import androidx.annotation.Nullable;
-import androidx.appcompat.widget.AppCompatTextView;
 import androidx.recyclerview.widget.GridLayoutManager;
 import androidx.recyclerview.widget.RecyclerView;
 
 import com.compdfkit.core.annotation.CPDFStampAnnotation;
 import com.compdfkit.tools.R;
-import com.compdfkit.tools.annotation.pdfproperties.pdfstamp.adapter.CImageStampListAdapter;
-import com.compdfkit.tools.annotation.pdfproperties.pdfstamp.adapter.CTextStampAdapter;
+import com.compdfkit.tools.annotation.pdfproperties.pdfstamp.adapter.CustomStampAdapter;
+import com.compdfkit.tools.annotation.pdfproperties.pdfstamp.bean.CCustomStampBean;
 import com.compdfkit.tools.annotation.pdfproperties.pdfstamp.bean.CTextStampBean;
 import com.compdfkit.tools.annotation.pdfproperties.pdfstamp.data.CStampDatas;
 import com.compdfkit.tools.common.utils.dialog.CAlertDialog;
@@ -36,22 +35,15 @@ import com.compdfkit.tools.common.utils.threadpools.CThreadPoolUtils;
 import com.compdfkit.tools.common.views.pdfproperties.basic.CBasicPropertiesFragment;
 import com.google.android.material.floatingactionbutton.FloatingActionButton;
 
+import java.util.ArrayList;
 import java.util.List;
 
 
 public class CStampCustomFragment extends CBasicPropertiesFragment {
 
-    private RecyclerView rvTextStamp;
+    private RecyclerView rvCustomStamp;
 
-    private AppCompatTextView tvTextStampTitle;
-
-    private RecyclerView rvImageStamp;
-
-    private AppCompatTextView tvImageStampTitle;
-
-    private CTextStampAdapter textStampAdapter;
-
-    private CImageStampListAdapter imageStampListAdapter;
+    private CustomStampAdapter customStampAdapter;
 
     private ActivityResultLauncher<Intent> addStampLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
         if (result.getData() != null && result.getData().getStringExtra("file_path") != null) {
@@ -71,10 +63,7 @@ public class CStampCustomFragment extends CBasicPropertiesFragment {
     public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
         View rootView = inflater.inflate(R.layout.tools_properties_stamp_custom_list_fragment, container, false);
         FloatingActionButton fabAdd = rootView.findViewById(R.id.fab_add_custom_stamp);
-        rvTextStamp = rootView.findViewById(R.id.rv_custom_text_stamp);
-        tvTextStampTitle = rootView.findViewById(R.id.tv_custom_text_stamp_title);
-        rvImageStamp = rootView.findViewById(R.id.rv_custom_image_stamp);
-        tvImageStampTitle = rootView.findViewById(R.id.tv_custom_image_stamp_title);
+        rvCustomStamp = rootView.findViewById(R.id.rv_custom_stamp);
         fabAdd.setOnClickListener(v -> {
             CAddStampSwichDialogFragment addStampDialog = CAddStampSwichDialogFragment.newInstance();
             addStampDialog.setAddTextStampClickListener(v1 -> {
@@ -86,6 +75,7 @@ public class CStampCustomFragment extends CBasicPropertiesFragment {
                 importImageDialogFragment.setImportImageListener(imageUri -> {
                     if (imageUri != null) {
                         CStampDatas.saveStampImage(getContext(), imageUri);
+
                         refreshStampList();
                     }
                     importImageDialogFragment.dismiss();
@@ -102,7 +92,6 @@ public class CStampCustomFragment extends CBasicPropertiesFragment {
     public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
         super.onViewCreated(view, savedInstanceState);
         initTextStampList();
-        initImageStampList();
         refreshStampList();
     }
 
@@ -111,119 +100,96 @@ public class CStampCustomFragment extends CBasicPropertiesFragment {
         gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
             @Override
             public int getSpanSize(int position) {
-                boolean isPortrait = getContext().getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT;
-                return isPortrait ? 2 : 1;
-            }
-        });
-        rvTextStamp.setLayoutManager(gridLayoutManager);
-        rvTextStamp.setNestedScrollingEnabled(false);
-        textStampAdapter = new CTextStampAdapter();
-        textStampAdapter.setOnItemClickListener((adapter, view, position) -> {
-            if (viewModel != null) {
-                CTextStampBean bean = adapter.list.get(position);
-                CPDFStampAnnotation.TextStamp textStamp = new CPDFStampAnnotation.TextStamp(
-                        bean.getTextContent(),
-                        bean.getDateStr(),
-                        bean.getTextStampShapeId(),
-                        bean.getTextStampColorId());
-                viewModel.getStyle().setTextStamp(textStamp);
-                dismissStyleDialog();
-            }
-        });
-        textStampAdapter.addOnItemChildClickListener(R.id.iv_delete, (adapter, view, position) -> {
-            CAlertDialog alertDialog = CAlertDialog.newInstance(getString(R.string.tools_warning), getString(R.string.tools_are_you_sure_to_delete));
-            alertDialog.setCancelClickListener(v -> alertDialog.dismiss());
-            alertDialog.setConfirmClickListener(v -> {
-                CTextStampBean bean = adapter.list.get(position);
-                CStampDatas.removeStamp(bean.getFilePath());
-                textStampAdapter.remove(position);
-                if (textStampAdapter.list.size() == 0){
-                    tvTextStampTitle.setVisibility(View.GONE);
+                int itemType = customStampAdapter.getItemViewType(position);
+                switch (itemType){
+                    case CCustomStampBean.ITEM_TEXT_STAMP_TITLE:
+                    case CCustomStampBean.ITEM_IMAGE_STAMP_TITLE:
+                        return 2;
+                    default:
+                        boolean isPortrait = getContext().getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT;
+                        return isPortrait ? 2 : 1;
                 }
-                alertDialog.dismiss();
-            });
-            alertDialog.show(getChildFragmentManager(), "alertDialog");
-        });
-        rvTextStamp.setAdapter(textStampAdapter);
-    }
-
-    private void initImageStampList() {
-        GridLayoutManager gridLayoutManager = new GridLayoutManager(getContext(), 2);
-        gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
-            @Override
-            public int getSpanSize(int position) {
-                boolean isPortrait = getContext().getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT;
-                return isPortrait ? 2 : 1;
             }
         });
-        rvImageStamp.setLayoutManager(gridLayoutManager);
-        rvImageStamp.setNestedScrollingEnabled(false);
-        imageStampListAdapter = new CImageStampListAdapter();
-        imageStampListAdapter.setOnItemClickListener((adapter, view, position) -> {
+        rvCustomStamp.setLayoutManager(gridLayoutManager);
+        customStampAdapter = new CustomStampAdapter();
+        customStampAdapter.setOnItemClickListener((adapter, view, position) -> {
             if (viewModel != null) {
-                String imagePath = adapter.list.get(position);
-                viewModel.getStyle().setImagePath(imagePath);
-                dismissStyleDialog();
+                CCustomStampBean bean = adapter.list.get(position);
+                switch (bean.getItemType()) {
+                    case CCustomStampBean.ITEM_TEXT_STAMP:
+                        CTextStampBean textStampBean = bean.getTextStampBean();
+                        CPDFStampAnnotation.TextStamp textStamp = new CPDFStampAnnotation.TextStamp(
+                                textStampBean.getTextContent(),
+                                textStampBean.getDateStr(),
+                                textStampBean.getTextStampShapeId(),
+                                textStampBean.getTextStampColorId());
+                        viewModel.getStyle().setTextStamp(textStamp);
+                        dismissStyleDialog();
+                        break;
+                    case CCustomStampBean.ITEM_IMAGE_STAMP:
+                        String imagePath = adapter.list.get(position).getImageStampPath();
+                        viewModel.getStyle().setImagePath(imagePath);
+                        dismissStyleDialog();
+                        break;
+                    default:
+                        break;
+                }
             }
         });
-        imageStampListAdapter.addOnItemChildClickListener(R.id.iv_delete, (adapter, view, position) -> {
+        customStampAdapter.addOnItemChildClickListener(R.id.iv_delete, (adapter, view, position) -> {
             CAlertDialog alertDialog = CAlertDialog.newInstance(getString(R.string.tools_warning), getString(R.string.tools_are_you_sure_to_delete));
             alertDialog.setCancelClickListener(v -> alertDialog.dismiss());
             alertDialog.setConfirmClickListener(v -> {
-                String imagePath = adapter.list.get(position);
-                CStampDatas.removeStamp(imagePath);
-                imageStampListAdapter.remove(position);
-                if (imageStampListAdapter.list.size() == 0){
-                    tvImageStampTitle.setVisibility(View.GONE);
+                CCustomStampBean bean = adapter.list.get(position);
+                switch (bean.getItemType()) {
+                    case CCustomStampBean.ITEM_TEXT_STAMP:
+                        CStampDatas.removeStamp(bean.getTextStampBean().getFilePath());
+                        customStampAdapter.remove(position);
+                        customStampAdapter.checkRemoveTextStampTitle();
+                        alertDialog.dismiss();
+                        break;
+                    case CCustomStampBean.ITEM_IMAGE_STAMP:
+                        String imagePath = adapter.list.get(position).getImageStampPath();
+                        CStampDatas.removeStamp(imagePath);
+                        customStampAdapter.remove(position);
+                        customStampAdapter.checkRemoveImageStampTitle();
+                        alertDialog.dismiss();
+                        break;
+                    default:
+                        break;
                 }
-                alertDialog.dismiss();
             });
             alertDialog.show(getChildFragmentManager(), "alertDialog");
         });
-        rvImageStamp.setAdapter(imageStampListAdapter);
+        rvCustomStamp.setAdapter(customStampAdapter);
     }
 
     private void refreshStampList() {
         CThreadPoolUtils.getInstance().executeIO(() -> {
             try {
                 if (getContext() != null) {
-                    List<CTextStampBean> list = CStampDatas.getTextStampList(getContext());
-                    if (textStampAdapter != null) {
-                        textStampAdapter.setList(list);
+                    List<CCustomStampBean> lists = new ArrayList<>();
+                    List<CTextStampBean> textStampList = CStampDatas.getTextStampList(getContext());
+                    for (int i = 0; i < textStampList.size(); i++) {
+                        if (i == 0){
+                            lists.add(CCustomStampBean.headItem(getString(R.string.tools_text_stamp), CCustomStampBean.ITEM_TEXT_STAMP_TITLE));
+                        }
+                        lists.add(new CCustomStampBean(textStampList.get(i)));
                     }
-                    checkShowStampTitle();
-                }
-            }catch (Exception e){
-
-            }
-        });
-        CThreadPoolUtils.getInstance().executeIO(() -> {
-            try {
-                if (getContext() != null) {
-                    List<String> list = CStampDatas.getImageStampList(getContext());
-                    if (imageStampListAdapter != null) {
-                        imageStampListAdapter.setList(list);
+                    List<String> imageStampList = CStampDatas.getImageStampList(getContext());
+                    for (int i = 0; i < imageStampList.size(); i++) {
+                        if (i == 0){
+                            lists.add(CCustomStampBean.headItem(getString(R.string.tools_image_stamp), CCustomStampBean.ITEM_IMAGE_STAMP_TITLE));
+                        }
+                        lists.add(new CCustomStampBean(imageStampList.get(i)));
                     }
-                    checkShowStampTitle();
+                    CThreadPoolUtils.getInstance().executeMain(()->{
+                        customStampAdapter.setList(lists);
+                    });
                 }
-            }catch (Exception e){
-
+            } catch (Exception e) {
             }
         });
     }
-
-    private void checkShowStampTitle() {
-        if (getActivity() != null) {
-            getActivity().runOnUiThread(()->{
-                if (tvTextStampTitle != null) {
-                    boolean show = textStampAdapter != null && textStampAdapter.list.size() > 0;
-                    tvTextStampTitle.setVisibility(show ? View.VISIBLE : View.GONE);
-                }
-                if (tvImageStampTitle != null) {
-                    boolean show = imageStampListAdapter != null && imageStampListAdapter.list.size() > 0;
-                    tvImageStampTitle.setVisibility(show ? View.VISIBLE : View.GONE);
-                }
-            });
-        }
-    }
 }

+ 108 - 0
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/annotation/pdfproperties/pdfstamp/adapter/CustomStampAdapter.java

@@ -0,0 +1,108 @@
+/**
+ * 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.annotation.pdfproperties.pdfstamp.adapter;
+
+
+import android.content.Context;
+import android.view.ViewGroup;
+
+import androidx.appcompat.widget.AppCompatImageView;
+
+import com.bumptech.glide.Glide;
+import com.compdfkit.core.annotation.CPDFStampAnnotation;
+import com.compdfkit.tools.R;
+import com.compdfkit.tools.annotation.pdfproperties.pdfstamp.bean.CCustomStampBean;
+import com.compdfkit.tools.annotation.pdfproperties.pdfstamp.bean.CTextStampBean;
+import com.compdfkit.tools.common.utils.adapter.CBaseQuickAdapter;
+import com.compdfkit.tools.common.utils.adapter.CBaseQuickViewHolder;
+import com.compdfkit.tools.common.views.pdfproperties.stamp.CPDFStampTextView;
+
+public class CustomStampAdapter extends CBaseQuickAdapter<CCustomStampBean, CBaseQuickViewHolder> {
+    public CustomStampAdapter() {
+    }
+
+    @Override
+    protected CBaseQuickViewHolder onCreateViewHolder(Context context, ViewGroup parent, int viewType) {
+        if (viewType == CCustomStampBean.ITEM_TEXT_STAMP_TITLE || viewType == CCustomStampBean.ITEM_IMAGE_STAMP_TITLE) {
+            return new CBaseQuickViewHolder(R.layout.tools_annot_stamp_custom_stamp_title, parent);
+        } else if (viewType == CCustomStampBean.ITEM_TEXT_STAMP) {
+            return new CBaseQuickViewHolder(R.layout.tools_properties_stamp_text_stamp_list_item, parent);
+        } else {
+            return new CBaseQuickViewHolder(R.layout.tools_properties_stamp_image_stamp_list_item, parent);
+        }
+    }
+
+    @Override
+    protected void onBindViewHolder(CBaseQuickViewHolder holder, int position, CCustomStampBean item) {
+        switch (item.getItemType()) {
+            case CCustomStampBean.ITEM_TEXT_STAMP_TITLE:
+            case CCustomStampBean.ITEM_IMAGE_STAMP_TITLE:
+                holder.setText(R.id.tv_custom_text_stamp_title, item.getTitle());
+                break;
+            case CCustomStampBean.ITEM_TEXT_STAMP:
+                CPDFStampTextView stampTextView = holder.getView(R.id.stamp_text_view);
+                CTextStampBean textStampBean = item.getTextStampBean();
+                stampTextView.setShape(CPDFStampAnnotation.TextStampShape.valueOf(textStampBean.getTextStampShapeId()));
+                stampTextView.setColor(textStampBean.getBgColor());
+                stampTextView.setContent(textStampBean.getTextContent());
+                stampTextView.setDateSwitch(textStampBean.isShowDate());
+                stampTextView.setTimeSwitch(textStampBean.isShowTime());
+                break;
+            case CCustomStampBean.ITEM_IMAGE_STAMP:
+                AppCompatImageView imageView = holder.getView(R.id.iv_stamp_image);
+                Glide.with(holder.itemView.getContext())
+                        .load(item.getImageStampPath())
+                        .into(imageView);
+                break;
+            default:
+                break;
+        }
+    }
+
+    @Override
+    public int getItemViewType(int position) {
+        return list.get(position).getItemType();
+    }
+
+    public void checkRemoveTextStampTitle() {
+        boolean hasTextStamp = false;
+        int textStampTitleIndex = -1;
+        for (int i = 0; i < list.size(); i++) {
+            CCustomStampBean bean = list.get(i);
+            if (bean.getItemType() == CCustomStampBean.ITEM_TEXT_STAMP_TITLE) {
+                textStampTitleIndex = i;
+            }
+            if (bean.getItemType() == CCustomStampBean.ITEM_TEXT_STAMP) {
+                hasTextStamp = true;
+                break;
+            }
+        }
+        if (!hasTextStamp && textStampTitleIndex >= 0) {
+            remove(textStampTitleIndex);
+        }
+    }
+
+    public void checkRemoveImageStampTitle() {
+        boolean hasImageStamp = false;
+        int imageStampTitleIndex = -1;
+        for (int i = 0; i < list.size(); i++) {
+            CCustomStampBean bean = list.get(i);
+            if (bean.getItemType() == CCustomStampBean.ITEM_IMAGE_STAMP_TITLE) {
+                imageStampTitleIndex = i;
+            }
+            if (bean.getItemType() == CCustomStampBean.ITEM_IMAGE_STAMP) {
+                hasImageStamp = true;
+                break;
+            }
+        }
+        if (!hasImageStamp && imageStampTitleIndex >= 0) {
+            remove(imageStampTitleIndex);
+        }
+    }
+}

+ 80 - 0
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/annotation/pdfproperties/pdfstamp/bean/CCustomStampBean.java

@@ -0,0 +1,80 @@
+/**
+ * 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.annotation.pdfproperties.pdfstamp.bean;
+
+
+public class CCustomStampBean {
+
+    public static final int ITEM_TEXT_STAMP_TITLE = 0;
+    public static final int ITEM_IMAGE_STAMP_TITLE = 1;
+
+    public static final int ITEM_TEXT_STAMP = 2;
+
+    public static final int ITEM_IMAGE_STAMP = 3;
+
+    private int itemType = ITEM_TEXT_STAMP_TITLE;
+
+    private String title;
+
+    private CTextStampBean textStampBean;
+
+    private String imageStampPath;
+
+    public static CCustomStampBean headItem(String title, int itemType){
+        CCustomStampBean bean = new CCustomStampBean();
+        bean.setItemType(itemType);
+        bean.setTitle(title);
+        return bean;
+    }
+    public CCustomStampBean(){
+
+    }
+    public CCustomStampBean(CTextStampBean textStampBean){
+        this.itemType = ITEM_TEXT_STAMP;
+        this.textStampBean = textStampBean;
+    }
+
+    public CCustomStampBean(String imageStampPath){
+        this.itemType = ITEM_IMAGE_STAMP;
+        this.imageStampPath = imageStampPath;
+    }
+
+    public int getItemType() {
+        return itemType;
+    }
+
+    public void setItemType(int itemType) {
+        this.itemType = itemType;
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    public void setTitle(String title) {
+        this.title = title;
+    }
+
+    public CTextStampBean getTextStampBean() {
+        return textStampBean;
+    }
+
+    public void setTextStampBean(CTextStampBean textStampBean) {
+        this.textStampBean = textStampBean;
+    }
+
+    public String getImageStampPath() {
+        return imageStampPath;
+    }
+
+    public void setImageStampPath(String imageStampPath) {
+        this.imageStampPath = imageStampPath;
+    }
+}

+ 0 - 86
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/common/views/pdfproperties/font/CExternFontSpinnerAdapter.java

@@ -1,86 +0,0 @@
-/**
- * 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.common.views.pdfproperties.font;
-
-import android.content.Context;
-import android.graphics.Typeface;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.BaseAdapter;
-
-import androidx.annotation.NonNull;
-import androidx.appcompat.widget.AppCompatTextView;
-
-import com.compdfkit.core.annotation.CPDFTextAttribute;
-import com.compdfkit.tools.R;
-
-import java.util.List;
-
-
-public class CExternFontSpinnerAdapter extends BaseAdapter {
-
-    private List<CPDFTextAttribute.FontNameHelper.FontType> list;
-    List<String> externFontList = null;
-    private Context mContext;
-
-    public CExternFontSpinnerAdapter(@NonNull Context context, List<CPDFTextAttribute.FontNameHelper.FontType> fontTypes) {
-        this.list = fontTypes;
-        mContext = context;
-    }
-
-    public CExternFontSpinnerAdapter(@NonNull Context context, List<CPDFTextAttribute.FontNameHelper.FontType> fontTypes, List<String> fontList) {
-        this.list = fontTypes;
-        mContext = context;
-        externFontList = fontList;
-    }
-
-    public int getStandardFontCount() {
-        return list.size();
-    }
-
-    @Override
-    public int getCount() {
-        return list.size() + (externFontList == null ? 0 : externFontList.size());
-    }
-
-    @Override
-    public Object getItem(int position) {
-        if (position < list.size()) {
-            return list.get(position);
-        } else {
-            return externFontList.get(position - list.size());
-        }
-    }
-
-    @Override
-    public long getItemId(int position) {
-        return position;
-    }
-
-    @Override
-    public View getView(int position, View convertView, ViewGroup parent) {
-        LayoutInflater inflater = LayoutInflater.from(mContext);
-        convertView = inflater.inflate(R.layout.tools_spinner_list_item, null);
-        if (convertView != null){
-            AppCompatTextView textView = convertView.findViewById(R.id.tv_menu_title);
-            if (position < list.size()) {
-                CPDFTextAttribute.FontNameHelper.FontType fontType = (CPDFTextAttribute.FontNameHelper.FontType) getItem(position);
-                String fontName = CPDFTextAttribute.FontNameHelper.obtainFontName(fontType, false, false);
-                Typeface typeface = CPDFTextAttribute.FontNameHelper.getTypeface(textView.getContext(), fontName);
-                textView.setTypeface(typeface);
-                textView.setText(fontType == CPDFTextAttribute.FontNameHelper.FontType.Unknown ? "Unknown" : fontName);
-            } else {
-                textView.setText(externFontList.get(position - list.size()));
-            }
-        }
-        return convertView;
-    }
-}

+ 38 - 14
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/common/views/pdfproperties/font/CFontSpinnerAdapter.java

@@ -20,19 +20,23 @@ import androidx.annotation.NonNull;
 import androidx.appcompat.widget.AppCompatTextView;
 
 import com.compdfkit.core.annotation.CPDFTextAttribute;
+import com.compdfkit.core.font.CPDFFont;
+import com.compdfkit.core.font.CPDFFontName;
 import com.compdfkit.tools.R;
+import com.compdfkit.tools.common.views.pdfproperties.font.bean.CFontStyleItemBean;
 
+import java.util.ArrayList;
 import java.util.List;
 
 
 public class CFontSpinnerAdapter extends BaseAdapter {
 
-    private List<CPDFTextAttribute.FontNameHelper.FontType> list;
+    private List<CPDFFontName> list;
 
     private Context mContext;
 
-    public CFontSpinnerAdapter(@NonNull Context context, List<CPDFTextAttribute.FontNameHelper.FontType> fontTypes) {
-        this.list = fontTypes;
+    public CFontSpinnerAdapter(@NonNull Context context) {
+        list = CPDFFont.getOutFontName();
         mContext = context;
     }
 
@@ -42,7 +46,7 @@ public class CFontSpinnerAdapter extends BaseAdapter {
     }
 
     @Override
-    public Object getItem(int position) {
+    public CPDFFontName getItem(int position) {
         return list.get(position);
     }
 
@@ -55,19 +59,39 @@ public class CFontSpinnerAdapter extends BaseAdapter {
     public View getView(int position, View convertView, ViewGroup parent) {
         LayoutInflater inflater = LayoutInflater.from(mContext);
         convertView = inflater.inflate(R.layout.tools_spinner_list_item, null);
-        if (convertView != null){
+        if (convertView != null) {
             AppCompatTextView textView = convertView.findViewById(R.id.tv_menu_title);
-            CPDFTextAttribute.FontNameHelper.FontType fontType = (CPDFTextAttribute.FontNameHelper.FontType) getItem(position);
-            String fontName = CPDFTextAttribute.FontNameHelper.obtainFontName(fontType, false, false);
-            Typeface typeface = CPDFTextAttribute.FontNameHelper.getTypeface(textView.getContext(), fontName);
-            if (fontType == CPDFTextAttribute.FontNameHelper.FontType.Unknown){
-                textView.setTypeface(Typeface.DEFAULT);
-                textView.setText(CPDFTextAttribute.FontNameHelper.FontType.Unknown.name());
+            CPDFFontName cpdfFontName = list.get(position);
+            String familyName = cpdfFontName.getFamilyName();
+            String outFont = CPDFTextAttribute.FontNameHelper.obtainFontName(familyName, false, false);
+            Typeface typeface = CPDFTextAttribute.FontNameHelper.getTypeface(mContext, outFont);
+            textView.setTypeface(typeface);
+            textView.setText(familyName);
+
+        }
+        return convertView;
+    }
+
+    public int getPosition(String familyName) {
+        for (int i = 0; i < list.size(); i++) {
+            CPDFFontName fontName = list.get(i);
+            if (fontName.getFamilyName().equals(familyName)) {
+                return i;
+            }
+        }
+        return 0;
+    }
+
+    public List<CFontStyleItemBean> getFontStyleList(CPDFFontName cpdfFontName) {
+        List<CFontStyleItemBean> styleItemBeans = new ArrayList<>();
+        for (String styleName : cpdfFontName.getStyleName()) {
+            String psName = CPDFTextAttribute.FontNameHelper.obtainFontName(cpdfFontName.getFamilyName(), styleName);
+            if (styleName.equals("Regular")) {
+                styleItemBeans.add(0, new CFontStyleItemBean(styleName, psName));
             } else {
-                textView.setTypeface(typeface);
-                textView.setText(fontName);
+                styleItemBeans.add(new CFontStyleItemBean(styleName, psName));
             }
         }
-        return convertView;
+        return styleItemBeans;
     }
 }

+ 0 - 97
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/common/views/pdfproperties/font/CFontSpinnerAdapter1.java

@@ -1,97 +0,0 @@
-/**
- * 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.common.views.pdfproperties.font;
-
-import android.content.Context;
-import android.graphics.Typeface;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.BaseAdapter;
-
-import androidx.annotation.NonNull;
-import androidx.appcompat.widget.AppCompatTextView;
-
-import com.compdfkit.core.annotation.CPDFTextAttribute;
-import com.compdfkit.core.font.CPDFFont;
-import com.compdfkit.core.font.CPDFFontName;
-import com.compdfkit.tools.R;
-import com.compdfkit.tools.common.views.pdfproperties.font.bean.CFontStyleItemBean;
-
-import java.util.ArrayList;
-import java.util.List;
-
-
-public class CFontSpinnerAdapter1 extends BaseAdapter {
-
-    private List<CPDFFontName> list;
-
-    private Context mContext;
-
-    public CFontSpinnerAdapter1(@NonNull Context context) {
-        list = CPDFFont.getOutFontName();
-        mContext = context;
-    }
-
-    @Override
-    public int getCount() {
-        return list.size();
-    }
-
-    @Override
-    public CPDFFontName getItem(int position) {
-        return list.get(position);
-    }
-
-    @Override
-    public long getItemId(int position) {
-        return position;
-    }
-
-    @Override
-    public View getView(int position, View convertView, ViewGroup parent) {
-        LayoutInflater inflater = LayoutInflater.from(mContext);
-        convertView = inflater.inflate(R.layout.tools_spinner_list_item, null);
-        if (convertView != null) {
-            AppCompatTextView textView = convertView.findViewById(R.id.tv_menu_title);
-            CPDFFontName cpdfFontName = list.get(position);
-            String familyName = cpdfFontName.getFamilyName();
-            String outFont = CPDFTextAttribute.FontNameHelper.obtainFontName(familyName, false, false);
-            Typeface typeface = CPDFTextAttribute.FontNameHelper.getTypeface(mContext, outFont);
-            textView.setTypeface(typeface);
-            textView.setText(familyName);
-
-        }
-        return convertView;
-    }
-
-    public int getPosition(String familyName) {
-        for (int i = 0; i < list.size(); i++) {
-            CPDFFontName fontName = list.get(i);
-            if (fontName.getFamilyName().equals(familyName)) {
-                return i;
-            }
-        }
-        return 0;
-    }
-
-    public List<CFontStyleItemBean> getFontStyleList(CPDFFontName cpdfFontName) {
-        List<CFontStyleItemBean> styleItemBeans = new ArrayList<>();
-        for (String styleName : cpdfFontName.getStyleName()) {
-            String psName = CPDFTextAttribute.FontNameHelper.obtainFontName(cpdfFontName.getFamilyName(), styleName);
-            if (styleName.equals("Regular")) {
-                styleItemBeans.add(0, new CFontStyleItemBean(styleName, psName));
-            } else {
-                styleItemBeans.add(new CFontStyleItemBean(styleName, psName));
-            }
-        }
-        return styleItemBeans;
-    }
-}

+ 9 - 29
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/common/views/pdfproperties/font/CFontStyleSpinnerAdapter.java

@@ -1,3 +1,11 @@
+/**
+ * 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.common.views.pdfproperties.font;
 
 import android.content.Context;
@@ -15,12 +23,7 @@ import com.compdfkit.tools.common.views.pdfproperties.font.bean.CFontStyleItemBe
 import java.util.ArrayList;
 import java.util.List;
 
-/**
- * @classname:
- * @author: LiuXiaoLong
- * @date: 2024/2/26
- * description:
- */
+
 public class CFontStyleSpinnerAdapter extends BaseAdapter {
 
     private List<CFontStyleItemBean> list;
@@ -63,27 +66,4 @@ public class CFontStyleSpinnerAdapter extends BaseAdapter {
         this.list.addAll(list);
         notifyDataSetChanged();
     }
-
-    public int getIndex(boolean isBold, boolean isItalic){
-//        if (isBold){
-//            style = FontStyle.Bold;
-//        }
-//        if (isItalic){
-//            if (isBold){
-//                style = FontStyle.Bold_Italic;
-//            }else {
-//                style = FontStyle.Italic;
-//            }
-//        }
-//
-//        for (int i = 0; i < list.size(); i++) {
-//            FontStyle item = list.get(i);
-//            if (item == style){
-//                return i;
-//            }
-//        }
-        return 0;
-    }
-
-
 }

+ 2 - 2
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/common/views/pdfproperties/font/CPDFFontView.java

@@ -35,7 +35,7 @@ public class CPDFFontView extends LinearLayout {
 
     private Spinner fontStyleSpinner;
 
-    private CFontSpinnerAdapter1 fontAdapter;
+    private CFontSpinnerAdapter fontAdapter;
 
     private CFontStyleSpinnerAdapter fontStyleSpinnerAdapter;
 
@@ -61,7 +61,7 @@ public class CPDFFontView extends LinearLayout {
         fontSpinner = view.findViewById(R.id.spinner_font);
         fontStyleSpinner = view.findViewById(R.id.spinner_font_style);
         if (!isInEditMode()) {
-            fontAdapter = new CFontSpinnerAdapter1(context);
+            fontAdapter = new CFontSpinnerAdapter(context);
             fontSpinner.setAdapter(fontAdapter);
             fontStyleSpinnerAdapter = new CFontStyleSpinnerAdapter(context);
             fontStyleSpinner.setAdapter(fontStyleSpinnerAdapter);

+ 2 - 0
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/common/views/pdfproperties/pdfstyle/manager/provider/CSelectedAnnotStyleProvider.java

@@ -17,6 +17,7 @@ import com.compdfkit.core.annotation.CPDFLineAnnotation;
 import com.compdfkit.core.annotation.CPDFMarkupAnnotation;
 import com.compdfkit.core.annotation.CPDFSquareAnnotation;
 import com.compdfkit.core.annotation.CPDFTextAttribute;
+import com.compdfkit.tools.common.utils.CLog;
 import com.compdfkit.tools.common.views.pdfproperties.CTypeUtil;
 import com.compdfkit.tools.common.views.pdfproperties.pdfstyle.CAnnotStyle;
 import com.compdfkit.tools.common.views.pdfproperties.pdfstyle.CStyleType;
@@ -64,6 +65,7 @@ public class CSelectedAnnotStyleProvider implements CStyleProvider {
             } else if (annotImpl instanceof CPDFInkAnnotImpl) {
                 CPDFInkAnnotImpl inkAnnot = (CPDFInkAnnotImpl) annotImpl;
                 CPDFInkAnnotation inkAnnotation = (CPDFInkAnnotation) inkAnnot.onGetAnnotation();
+                CLog.e("注释Ink", "color: " + style.getColor() +  " alpha: " + style.getOpacity());
                 inkAnnotation.setColor(style.getColor());
                 inkAnnotation.setAlpha(style.getOpacity());
                 inkAnnotation.setBorderWidth(style.getBorderWidth());

+ 13 - 0
ComPDFKit_Tools/src/main/res/layout/tools_annot_stamp_custom_stamp_title.xml

@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.appcompat.widget.AppCompatTextView xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/tv_custom_text_stamp_title"
+    android:layout_width="match_parent"
+    android:layout_height="32dp"
+    android:background="@color/tools_reader_setting_head_bg_color"
+    android:gravity="center_vertical"
+    android:paddingStart="16dp"
+    android:paddingEnd="16dp"
+    android:text="@string/tools_text_stamp"
+    android:textColor="@color/tools_text_color_primary" />
+
+            

+ 7 - 56
ComPDFKit_Tools/src/main/res/layout/tools_properties_stamp_custom_list_fragment.xml

@@ -5,66 +5,17 @@
     android:layout_width="match_parent"
     android:layout_height="match_parent">
 
-
-    <androidx.core.widget.NestedScrollView
+    <com.compdfkit.tools.common.utils.view.CNestedScrollableHost
         android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:fillViewport="true">
+        android:layout_height="match_parent">
 
-        <RelativeLayout
-            android:id="@+id/id_stamp_activity_custom_rl"
+        <androidx.recyclerview.widget.RecyclerView
+            android:id="@+id/rv_custom_stamp"
             android:layout_width="match_parent"
-            android:layout_height="wrap_content">
-
-            <androidx.appcompat.widget.AppCompatTextView
-                android:id="@+id/tv_custom_text_stamp_title"
-                android:layout_width="match_parent"
-                android:layout_height="32dp"
-                android:background="@color/tools_reader_setting_head_bg_color"
-                android:gravity="center_vertical"
-                android:paddingStart="16dp"
-                android:paddingEnd="16dp"
-                android:text="@string/tools_text_stamp"
-                android:textColor="@color/tools_text_color_primary" />
-
-            <androidx.recyclerview.widget.RecyclerView
-                android:id="@+id/rv_custom_text_stamp"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:layout_below="@+id/tv_custom_text_stamp_title"
-                android:overScrollMode="never"
-                android:scrollbars="none"
-                app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
-                tools:itemCount="2"
-                tools:listitem="@layout/tools_properties_stamp_text_stamp_list_item" />
-
-            <androidx.appcompat.widget.AppCompatTextView
-                android:id="@+id/tv_custom_image_stamp_title"
-                android:layout_width="match_parent"
-                android:layout_height="32dp"
-                android:layout_below="@id/rv_custom_text_stamp"
-                android:layout_marginTop="16dp"
-                android:background="@color/tools_reader_setting_head_bg_color"
-                android:gravity="center_vertical"
-                android:paddingStart="16dp"
-                android:paddingEnd="16dp"
-                android:text="@string/tools_image_stamp"
-                android:textColor="@color/tools_text_color_primary" />
-
-            <androidx.recyclerview.widget.RecyclerView
-                android:id="@+id/rv_custom_image_stamp"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:layout_below="@+id/tv_custom_image_stamp_title"
-                android:overScrollMode="never"
-                android:scrollbars="none"
-                app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
-                app:spanCount="1"
-                tools:itemCount="2"
-                tools:listitem="@layout/tools_properties_stamp_image_stamp_list_item" />
-        </RelativeLayout>
-    </androidx.core.widget.NestedScrollView>
+            android:layout_height="match_parent"
+            tools:listitem="@layout/tools_properties_stamp_text_stamp_list_item" />
 
+    </com.compdfkit.tools.common.utils.view.CNestedScrollableHost>
 
     <com.google.android.material.floatingactionbutton.FloatingActionButton
         android:id="@+id/fab_add_custom_stamp"

+ 2 - 1
ComPDFKit_Tools/src/main/res/layout/tools_properties_stamp_image_stamp_list_item.xml

@@ -5,7 +5,8 @@
     android:layout_width="match_parent"
     android:layout_height="80dp"
     android:layout_marginHorizontal="16dp"
-    android:layout_marginTop="16dp"
+    android:layout_marginTop="8dp"
+    android:layout_marginBottom="8dp"
     android:background="@drawable/tools_style_signature_list_item_bg"
     android:foreground="@drawable/tools_common_btn_rectangle_ripple">
 

+ 15 - 8
ComPDFKit_Tools/src/main/res/layout/tools_properties_stamp_standard_list_fragment.xml

@@ -6,15 +6,22 @@
     android:background="@drawable/tools_common_btn_rectangle_ripple"
     android:layout_height="match_parent">
 
-    <androidx.recyclerview.widget.RecyclerView
-        android:id="@+id/rv_standard_stamp"
+    <com.compdfkit.tools.common.utils.view.CNestedScrollableHost
         android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
-        app:spanCount="2"
-        tools:itemCount="20"
-        android:paddingHorizontal="8dp"
-        tools:listitem="@layout/tools_properties_stamp_standard_list_item" />
+        android:layout_height="match_parent">
+
+        <androidx.recyclerview.widget.RecyclerView
+            android:id="@+id/rv_standard_stamp"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
+            app:spanCount="2"
+            tools:itemCount="20"
+            android:paddingHorizontal="8dp"
+            tools:listitem="@layout/tools_properties_stamp_standard_list_item" />
+
+    </com.compdfkit.tools.common.utils.view.CNestedScrollableHost>
+
 
 
 </androidx.constraintlayout.widget.ConstraintLayout>

+ 2 - 1
ComPDFKit_Tools/src/main/res/layout/tools_properties_stamp_text_stamp_list_item.xml

@@ -4,7 +4,8 @@
     android:layout_width="match_parent"
     android:layout_height="80dp"
     android:layout_marginHorizontal="16dp"
-    android:layout_marginTop="16dp"
+    android:layout_marginTop="8dp"
+    android:layout_marginBottom="8dp"
     android:background="@drawable/tools_style_signature_list_item_bg"
     android:foreground="@drawable/tools_common_btn_rectangle_ripple">