在主界面添加时间戳截取按钮
This commit is contained in:
		| @@ -1,8 +1,8 @@ | ||||
| #Created by .winboll/winboll_app_build.gradle | ||||
| #Wed May 07 15:07:02 HKT 2025 | ||||
| #Thu Jul 24 07:21:00 GMT 2025 | ||||
| stageCount=2 | ||||
| libraryProject= | ||||
| baseVersion=15.1 | ||||
| publishVersion=15.1.1 | ||||
| buildCount=0 | ||||
| buildCount=12 | ||||
| baseBetaVersion=15.1.2 | ||||
|   | ||||
| @@ -5,6 +5,7 @@ import android.view.View; | ||||
| import android.widget.EditText; | ||||
| import android.widget.Switch; | ||||
| import android.widget.TextView; | ||||
| import android.widget.Toast; | ||||
| import androidx.appcompat.app.AppCompatActivity; | ||||
| import androidx.appcompat.widget.Toolbar; | ||||
| import cc.winboll.studio.libappbase.LogUtils; | ||||
| @@ -12,6 +13,8 @@ import cc.winboll.studio.libappbase.LogView; | ||||
| import cc.winboll.studio.timestamp.MainService; | ||||
| import cc.winboll.studio.timestamp.R; | ||||
| import cc.winboll.studio.timestamp.utils.AppConfigsUtil; | ||||
| import cc.winboll.studio.timestamp.utils.ClipboardUtil; | ||||
| import cc.winboll.studio.timestamp.utils.TimeStampUtil; | ||||
| import com.hjq.toast.ToastUtils; | ||||
| import java.time.Instant; | ||||
| import java.time.LocalDateTime; | ||||
| @@ -97,4 +100,22 @@ public class MainActivity extends AppCompatActivity { | ||||
|         } | ||||
|         return false; | ||||
|     } | ||||
| 	 | ||||
| 	public void onTimeStamp(View view) { | ||||
| 		// 在这里编写按钮点击后要执行的代码 | ||||
| 		TimeStampUtil.getInstance(this).genTimeStamp(); | ||||
| 		String formattedDateTime = TimeStampUtil.getInstance(this).getTimeStampCopyString(); | ||||
| 		ClipboardUtil.copyTextToClipboard(this, formattedDateTime); | ||||
| 		 | ||||
| 		// 更新时间戳文本框显示内容 | ||||
| 		EditText etTimeStamp = findViewById(R.id.et_timestamp); | ||||
| 		etTimeStamp.setText(formattedDateTime); | ||||
|  | ||||
| 		// 输出一个提示音 | ||||
| 		TimeStampUtil.getInstance(this).playNotifyMusic(this); | ||||
| 		 | ||||
| 		// 比如显示一个 Toast | ||||
| 		Toast.makeText(this, "时间戳:\n" + TimeStampUtil.getInstance(this).getTimeStampCopyString() + "\n已拷贝到剪贴板。", Toast.LENGTH_SHORT).show(); | ||||
| 		MainService.updateCopiedTimeStamp(); | ||||
| 	} | ||||
| } | ||||
|   | ||||
| @@ -131,18 +131,12 @@ public class NotificationHelper { | ||||
|  | ||||
|         service.startForeground(ID_MSG_SERVICE, mForegroundNotification); | ||||
| 		 | ||||
|         // 播放默认短信铃声 | ||||
|         Uri defaultSmsRingtoneUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); | ||||
|         AudioPlayerUriUtil.playAudio(service, defaultSmsRingtoneUri); | ||||
|  | ||||
|         // 播放应用铃声 | ||||
|         // 获取MP3文件的Uri | ||||
|         Uri soundUri = Uri.parse("android.resource://" + service.getPackageName() + "/" + R.raw.diweiyi); | ||||
|         AudioPlayerUriUtil.playAudio(service, soundUri); | ||||
| 		TimeStampUtil.getInstance(service).playNotifyMusic(service); | ||||
|     } | ||||
| 	 | ||||
|      | ||||
|      | ||||
|  | ||||
| //    public void sendSMSNotification(Context context, MessageNotificationBean messageNotificationBean) { | ||||
| //        NotificationManager notificationManager = (NotificationManager) context.getSystemService( | ||||
| //            Context.NOTIFICATION_SERVICE); | ||||
|   | ||||
| @@ -6,6 +6,8 @@ package cc.winboll.studio.timestamp.utils; | ||||
|  * @Describe TimeStampUtil | ||||
|  */ | ||||
| import android.content.Context; | ||||
| import android.net.Uri; | ||||
| import cc.winboll.studio.timestamp.R; | ||||
| import java.time.Instant; | ||||
| import java.time.LocalDateTime; | ||||
| import java.time.ZoneId; | ||||
| @@ -55,4 +57,19 @@ public class TimeStampUtil { | ||||
|         String formattedDateTime = ldt.format(formatter); | ||||
|         return formattedDateTime; | ||||
|     } | ||||
| 	 | ||||
|  | ||||
| 	// | ||||
| 	// 播放时间戳确定时的提示音乐 | ||||
| 	// | ||||
| 	public static void playNotifyMusic(Context context) { | ||||
|         // 播放默认短信铃声 | ||||
|         //Uri defaultSmsRingtoneUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); | ||||
|         //AudioPlayerUriUtil.playAudio(context, defaultSmsRingtoneUri); | ||||
|  | ||||
|         // 播放应用铃声 | ||||
|         // 获取MP3文件的Uri | ||||
|         Uri soundUri = Uri.parse("android.resource://" + context.getPackageName() + "/" + R.raw.diweiyi); | ||||
|         AudioPlayerUriUtil.playAudio(context, soundUri); | ||||
| 	} | ||||
| } | ||||
|   | ||||
| @@ -1,6 +1,16 @@ | ||||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <LinearLayout | ||||
| 	xmlns:android="http://schemas.android.com/apk/res/android" | ||||
| 	android:orientation="vertical" | ||||
| 	android:layout_width="wrap_content" | ||||
| 	android:layout_height="wrap_content"> | ||||
|  | ||||
| 	<ScrollView | ||||
| 		android:layout_width="match_parent" | ||||
| 		android:layout_height="0dp" | ||||
| 		android:layout_weight="1.0"> | ||||
|  | ||||
| 		<LinearLayout | ||||
| 			xmlns:app="http://schemas.android.com/apk/res-auto" | ||||
| 			android:layout_width="match_parent" | ||||
| 			android:layout_height="match_parent" | ||||
| @@ -119,26 +129,52 @@ | ||||
| 			</LinearLayout> | ||||
|  | ||||
| 			<LinearLayout | ||||
| 		android:orientation="vertical" | ||||
| 				android:orientation="horizontal" | ||||
| 				android:layout_width="match_parent" | ||||
| 		android:layout_height="0dp" | ||||
| 		android:layout_weight="1.0" | ||||
| 		android:gravity="center_vertical|center_horizontal"> | ||||
| 				android:layout_height="wrap_content"> | ||||
|  | ||||
| 				<TextView | ||||
| 					android:layout_width="wrap_content" | ||||
| 					android:layout_height="wrap_content" | ||||
| 					android:text="当前截取的时间戳为:"/> | ||||
|  | ||||
| 			</LinearLayout> | ||||
|  | ||||
| 			<LinearLayout | ||||
| 				android:orientation="vertical" | ||||
| 				android:layout_width="match_parent" | ||||
| 		android:layout_height="0dp" | ||||
| 		android:layout_weight="1.0"> | ||||
| 				android:layout_height="wrap_content" | ||||
| 				android:gravity="center_vertical|center_horizontal"> | ||||
|  | ||||
| 		<cc.winboll.studio.libappbase.LogView | ||||
| 			android:layout_width="match_parent" | ||||
| 			android:layout_height="match_parent" | ||||
| 			android:id="@+id/logview"/> | ||||
| 				<ImageButton | ||||
| 					android:layout_width="100dp" | ||||
| 					android:layout_height="100dp" | ||||
| 					android:onClick="onTimeStamp" | ||||
| 					android:background="@drawable/ic_timestamp"/> | ||||
|  | ||||
| 			</LinearLayout> | ||||
|  | ||||
| 			<LinearLayout | ||||
| 				android:orientation="horizontal" | ||||
| 				android:layout_width="match_parent" | ||||
| 				android:layout_height="wrap_content"> | ||||
|  | ||||
| 				<EditText | ||||
| 					android:layout_width="match_parent" | ||||
| 					android:ems="10" | ||||
| 					android:layout_height="wrap_content" | ||||
| 					android:id="@+id/et_timestamp"/> | ||||
|  | ||||
| 			</LinearLayout> | ||||
|  | ||||
| 		</LinearLayout> | ||||
|  | ||||
| 	</ScrollView> | ||||
|  | ||||
| 	<cc.winboll.studio.libappbase.LogView | ||||
| 		android:layout_width="match_parent" | ||||
| 		android:layout_height="200dp" | ||||
| 		android:id="@+id/logview"/> | ||||
|  | ||||
| </LinearLayout> | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 ZhanGSKen
					ZhanGSKen