From 162e9a3aa4053f8cf2e257dbd8e3cf152e460464 Mon Sep 17 00:00:00 2001
From: mac <user@users-MacBook-Pro.local>
Date: 星期三, 30 十月 2024 18:12:43 +0800
Subject: [PATCH] (增加分享日志功能)2024年10月30日18:12:41

---
 app/src/main/java/com/hdl/photovoltaic/ui/test/TestLogActivity.java |   25 ++++++++++++++++++++++++-
 app/src/main/res/layout/activity_test_log.xml                       |    6 +++---
 2 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/app/src/main/java/com/hdl/photovoltaic/ui/test/TestLogActivity.java b/app/src/main/java/com/hdl/photovoltaic/ui/test/TestLogActivity.java
index bbe5ee5..a5313bc 100644
--- a/app/src/main/java/com/hdl/photovoltaic/ui/test/TestLogActivity.java
+++ b/app/src/main/java/com/hdl/photovoltaic/ui/test/TestLogActivity.java
@@ -1,12 +1,16 @@
 package com.hdl.photovoltaic.ui.test;
 
 
+import android.content.Intent;
+import android.net.Uri;
 import android.os.Bundle;
 import android.text.Spannable;
 import android.text.SpannableStringBuilder;
 import android.text.TextUtils;
 import android.text.style.ForegroundColorSpan;
 import android.view.View;
+
+import androidx.core.content.FileProvider;
 
 import com.hdl.photovoltaic.R;
 import com.hdl.photovoltaic.base.CustomBaseActivity;
@@ -18,6 +22,7 @@
 import com.hdl.photovoltaic.widget.ConfirmationCancelDialog;
 import com.hdl.photovoltaic.widget.ListStaticDialog;
 
+import java.io.File;
 import java.util.IdentityHashMap;
 import java.util.Map;
 
@@ -94,7 +99,25 @@
             @Override
             public void onClick(View v) {
                 //todo 闇�瑕佽皟浜戠鐨勬帴鍙�
-                HdlThreadLogic.toast(_mActivity, "杩樻病鏈夋敮鎸佷笂浼犳棩蹇�.");
+//                HdlThreadLogic.toast(_mActivity, "杩樻病鏈夋敮鎸佷笂浼犳棩蹇�.");
+
+//                Intent sendIntent = new Intent();
+//                sendIntent.setAction(Intent.ACTION_SEND);
+//                sendIntent.putExtra(Intent.EXTRA_TEXT, "This is my text to send.");
+//                sendIntent.setType("text/plain");
+//                startActivity(Intent.createChooser(sendIntent, "Share via"));
+                try {
+                    // 鍦ˋctivity涓垱寤哄垎浜獻ntent
+                    Intent shareIntent = new Intent(Intent.ACTION_SEND);
+                    shareIntent.setType("application/pdf"); // 鏍规嵁瑕佸垎浜殑鏂囦欢绫诲瀷璁剧疆MIME绫诲瀷
+                    File file = new File(HdlFileLogic.getInstance().getLogFileNamePath()); // 鎸囧畾鏂囦欢璺緞
+                    Uri fileUri = FileProvider.getUriForFile(_mActivity, "com.hdl.photovoltaic.dc.fileprovider", file);
+                    shareIntent.putExtra(Intent.EXTRA_STREAM, fileUri);
+                    shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
+                    startActivity(Intent.createChooser(shareIntent, "Share file using"));
+                } catch (Exception ignored) {
+                    HdlThreadLogic.toast(_mActivity, "鍒嗕韩澶辫触");
+                }
             }
         });
 
diff --git a/app/src/main/res/layout/activity_test_log.xml b/app/src/main/res/layout/activity_test_log.xml
index 84a7c50..8fad593 100644
--- a/app/src/main/res/layout/activity_test_log.xml
+++ b/app/src/main/res/layout/activity_test_log.xml
@@ -129,7 +129,7 @@
         android:id="@+id/sv"
         android:layout_width="0dp"
         android:layout_height="0dp"
-        app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintBottom_toTopOf="@+id/uploading_log_ll"
         app:layout_constraintEnd_toEndOf="parent"
         app:layout_constraintStart_toStartOf="parent"
         app:layout_constraintTop_toBottomOf="@+id/title_cl">
@@ -153,10 +153,10 @@
     </ScrollView>
     <!--涓婁紶鏃ュ織鍐呭-->
     <LinearLayout
+        android:id="@+id/uploading_log_ll"
         android:layout_width="match_parent"
         android:layout_height="@dimen/dp_50"
         android:background="@color/text_FFFFFFFF"
-        android:visibility="gone"
         app:layout_constraintBottom_toBottomOf="parent"
         app:layout_constraintEnd_toEndOf="parent"
         app:layout_constraintStart_toStartOf="parent"
@@ -168,7 +168,7 @@
             android:layout_height="@dimen/dp_50"
             android:layout_weight="1"
             android:gravity="center"
-            android:text="涓婁紶鏃ュ織鍒颁簯绔�"
+            android:text="鏃ュ織鍒嗕韩"
             android:textColor="@color/text_030D1C"
             android:textSize="@dimen/text_15" />
     </LinearLayout>

--
Gitblit v1.8.0