diff --git a/timestamp/build.properties b/timestamp/build.properties
index 16318df..62e827f 100644
--- a/timestamp/build.properties
+++ b/timestamp/build.properties
@@ -1,8 +1,8 @@
#Created by .winboll/winboll_app_build.gradle
-#Mon May 05 03:29:39 GMT 2025
+#Mon May 05 03:50:53 GMT 2025
stageCount=0
libraryProject=
baseVersion=15.0
publishVersion=15.0.0
-buildCount=15
+buildCount=24
baseBetaVersion=15.0.1
diff --git a/timestamp/src/main/AndroidManifest.xml b/timestamp/src/main/AndroidManifest.xml
index bff1a04..86517cb 100644
--- a/timestamp/src/main/AndroidManifest.xml
+++ b/timestamp/src/main/AndroidManifest.xml
@@ -39,6 +39,12 @@
+
+
+
+
+
+
diff --git a/timestamp/src/main/java/cc/winboll/studio/timestamp/MainService.java b/timestamp/src/main/java/cc/winboll/studio/timestamp/MainService.java
index 06cc4bf..4a00e01 100644
--- a/timestamp/src/main/java/cc/winboll/studio/timestamp/MainService.java
+++ b/timestamp/src/main/java/cc/winboll/studio/timestamp/MainService.java
@@ -6,6 +6,7 @@ package cc.winboll.studio.timestamp;
* @Describe 主要服务
*/
import android.app.Notification;
+import android.app.PendingIntent;
import android.app.Service;
import android.content.ComponentName;
import android.content.Context;
@@ -20,6 +21,7 @@ import cc.winboll.studio.libappbase.LogUtils;
import cc.winboll.studio.timestamp.AssistantService;
import cc.winboll.studio.timestamp.MainService;
import cc.winboll.studio.timestamp.models.AppConfigs;
+import cc.winboll.studio.timestamp.receivers.ButtonClickReceiver;
import cc.winboll.studio.timestamp.utils.NotificationHelper;
import cc.winboll.studio.timestamp.utils.ServiceUtil;
import java.lang.ref.WeakReference;
@@ -37,6 +39,8 @@ public class MainService extends Service {
public static final int MSG_UPDATE_TIMESTAMP = 0;
Intent intentMainService;
+ Intent mButtonBroadcastIntent;
+ PendingIntent mButtonPendingIntent;
NotificationHelper mNotificationHelper;
Notification notification;
RemoteViews mRemoteViews;
@@ -60,6 +64,15 @@ public class MainService extends Service {
mRemoteViews = new RemoteViews(getPackageName(), R.layout.remoteviews_timestamp);
intentMainService = new Intent(this, MainActivity.class);
+
+ // 创建点击按钮后要发送的广播 Intent
+ mButtonBroadcastIntent = new Intent(ButtonClickReceiver.BUTTON_COPYTIMESTAMP_ACTION);
+ mButtonPendingIntent = PendingIntent.getBroadcast(
+ this, // 上下文
+ 0, // 请求码,用于区分不同的 PendingIntent
+ mButtonBroadcastIntent, // Intent
+ PendingIntent.FLAG_UPDATE_CURRENT // 标志位,用于更新已存在的 PendingIntent
+ );
LogUtils.d(TAG, "onCreate()");
_mIsServiceAlive = false;
@@ -83,7 +96,7 @@ public class MainService extends Service {
//notification = helper.showForegroundNotification(intent, getString(R.string.app_name), getString(R.string.text_aboutservernotification));
notification = mNotificationHelper.showCustomForegroundNotification(intentMainService, mRemoteViews, mRemoteViews);
startForeground(NotificationHelper.FOREGROUND_NOTIFICATION_ID, notification);
-
+
// 唤醒守护进程
wakeupAndBindAssistant();
@@ -176,6 +189,8 @@ public class MainService extends Service {
String formattedDateTime = ldt.format(formatter);
//System.out.println(formattedDateTime);
mRemoteViews.setTextViewText(R.id.tv_timestamp, formattedDateTime);
+ // 为按钮设置点击事件
+ mRemoteViews.setOnClickPendingIntent(R.id.btn_copytimestamp, mButtonPendingIntent);
notification = mNotificationHelper.showCustomForegroundNotification(intentMainService, mRemoteViews, mRemoteViews);
//startForeground(NotificationHelper.FOREGROUND_NOTIFICATION_ID, notification);
}
diff --git a/timestamp/src/main/java/cc/winboll/studio/timestamp/receivers/ButtonClickReceiver.java b/timestamp/src/main/java/cc/winboll/studio/timestamp/receivers/ButtonClickReceiver.java
new file mode 100644
index 0000000..3a673db
--- /dev/null
+++ b/timestamp/src/main/java/cc/winboll/studio/timestamp/receivers/ButtonClickReceiver.java
@@ -0,0 +1,30 @@
+package cc.winboll.studio.timestamp.receivers;
+
+/**
+ * @Author ZhanGSKen
+ * @Date 2025/05/05 11:35
+ * @Describe ButtonClickReceiver
+ */
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.widget.Toast;
+import cc.winboll.studio.libappbase.LogUtils;
+
+public class ButtonClickReceiver extends BroadcastReceiver {
+
+ public static final String TAG = "ButtonClickReceiver";
+
+ public static final String BUTTON_COPYTIMESTAMP_ACTION = "com.example.BUTTON_CLICK_ACTION";
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ LogUtils.d(TAG, "onReceive");
+ //if (intent.getAction().equals(BUTTON_COPYTIMESTAMP_ACTION)) {
+ // 在这里编写按钮点击后要执行的代码
+ // 比如显示一个Toast
+ Toast.makeText(context, "按钮被点击了", Toast.LENGTH_SHORT).show();
+ //}
+ }
+
+}
diff --git a/timestamp/src/main/res/layout/remoteviews_timestamp.xml b/timestamp/src/main/res/layout/remoteviews_timestamp.xml
index a8bb1a9..6979cb9 100644
--- a/timestamp/src/main/res/layout/remoteviews_timestamp.xml
+++ b/timestamp/src/main/res/layout/remoteviews_timestamp.xml
@@ -2,15 +2,23 @@
+ android:layout_height="match_parent"
+ android:gravity="center_vertical">
+ android:id="@+id/tv_timestamp"
+ android:layout_weight="1.0"/>
+
+