Compare commits
11 Commits
timestamp-
...
timestamp-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f49c8141a8 | ||
|
|
6f3ce092ca | ||
|
|
29785be88d | ||
|
|
3f809e4c7a | ||
|
|
9c3c485ecd | ||
|
|
336511931d | ||
|
|
d3da3304ee | ||
|
|
a5295a0744 | ||
|
|
9b761b35ce | ||
|
|
5206f8781e | ||
|
|
2c0a5bfe65 |
@@ -1,6 +1,8 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
buildscript {
|
||||
repositories {
|
||||
//本地 maven 库
|
||||
maven { url "file:///sdcard/.aide/maven/" }
|
||||
// Nexus Maven 库地址
|
||||
// "WinBoLL Release"
|
||||
maven { url "https://nexus.winboll.cc/repository/maven-public/" }
|
||||
@@ -26,6 +28,8 @@ buildscript {
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
//本地 maven 库
|
||||
maven { url "file:///sdcard/.aide/maven/" }
|
||||
// Nexus Maven 库地址
|
||||
// "WinBoLL Release"
|
||||
maven { url "https://nexus.winboll.cc/repository/maven-public/" }
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#Created by .winboll/winboll_app_build.gradle
|
||||
#Wed May 07 10:48:11 HKT 2025
|
||||
stageCount=9
|
||||
#Wed May 07 13:48:06 HKT 2025
|
||||
stageCount=13
|
||||
libraryProject=
|
||||
baseVersion=15.0
|
||||
publishVersion=15.0.8
|
||||
publishVersion=15.0.12
|
||||
buildCount=0
|
||||
baseBetaVersion=15.0.9
|
||||
baseBetaVersion=15.0.13
|
||||
|
||||
@@ -26,10 +26,7 @@ import cc.winboll.studio.timestamp.receivers.ButtonClickReceiver;
|
||||
import cc.winboll.studio.timestamp.utils.AppConfigsUtil;
|
||||
import cc.winboll.studio.timestamp.utils.NotificationHelper;
|
||||
import cc.winboll.studio.timestamp.utils.ServiceUtil;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import cc.winboll.studio.timestamp.utils.TimeStampUtil;
|
||||
|
||||
public class MainService extends Service {
|
||||
|
||||
@@ -211,15 +208,10 @@ public class MainService extends Service {
|
||||
switch (message.what) {
|
||||
case MSG_UPDATE_TIMESTAMP:
|
||||
{
|
||||
long currentMillis = System.currentTimeMillis();
|
||||
Instant instant = Instant.ofEpochMilli(currentMillis);
|
||||
LocalDateTime ldt = LocalDateTime.ofInstant(instant, ZoneId.systemDefault());
|
||||
String szTimeStampFormatString = AppConfigsUtil.getInstance(MainService.this).getAppConfigsModel().getTimeStampFormatString();
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(szTimeStampFormatString);
|
||||
String formattedDateTime = ldt.format(formatter);
|
||||
mNotificationHelper.sendForegroundNotification(MainService.this, "时间戳:\n" + formattedDateTime + "\n已拷贝到剪贴板。");
|
||||
String szTimeStampShowString = TimeStampUtil.getInstance(MainService.this).getTimeStampShowString();
|
||||
mNotificationHelper.sendForegroundNotification(MainService.this, "时间戳:\n" + szTimeStampShowString + "\n已拷贝到剪贴板。");
|
||||
|
||||
LogUtils.d(TAG, "Hello, World! " + formattedDateTime);
|
||||
LogUtils.d(TAG, "Hello, World! " + szTimeStampShowString);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
||||
@@ -25,8 +25,8 @@ public class AppConfigsModel extends BaseBean {
|
||||
|
||||
public AppConfigsModel() {
|
||||
this.isEnableService = false;
|
||||
this.timeStampFormatString = "yyyy-MM-dd HH:mm:ss";
|
||||
this.timeStampCopyFormatString = "yyyy_MM_dd-HH_mm_ss";
|
||||
this.timeStampFormatString = "yyyy-MM-dd HH:mm:ss SSS";
|
||||
this.timeStampCopyFormatString = "yyyy_MM_dd-HH_mm_ss-SSS";
|
||||
}
|
||||
|
||||
public void setTimeStampCopyFormatString(String timeStampCopyFormatString) {
|
||||
|
||||
@@ -10,36 +10,27 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.widget.Toast;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.timestamp.BuildConfig;
|
||||
import cc.winboll.studio.timestamp.MainService;
|
||||
import cc.winboll.studio.timestamp.utils.AppConfigsUtil;
|
||||
import cc.winboll.studio.timestamp.utils.ClipboardUtil;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import cc.winboll.studio.timestamp.utils.TimeStampUtil;
|
||||
|
||||
public class ButtonClickReceiver extends BroadcastReceiver {
|
||||
|
||||
public static final String TAG = "ButtonClickReceiver";
|
||||
|
||||
public static final String BUTTON_COPYTIMESTAMP_ACTION = "cc.winboll.studio.timestamp.receivers.ButtonClickReceiver.BUTTON_COPYTIMESTAMP_ACTION";
|
||||
public static final String BUTTON_COPYTIMESTAMP_ACTION = ButtonClickReceiver.class.getName() + (BuildConfig.DEBUG ?".DEBUG_": ".") + "BUTTON_COPYTIMESTAMP_ACTION";
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
LogUtils.d(TAG, "onReceive");
|
||||
if (intent.getAction().equals(BUTTON_COPYTIMESTAMP_ACTION)) {
|
||||
// 在这里编写按钮点击后要执行的代码
|
||||
long currentMillis = System.currentTimeMillis();
|
||||
Instant instant = Instant.ofEpochMilli(currentMillis);
|
||||
LocalDateTime ldt = LocalDateTime.ofInstant(instant, ZoneId.systemDefault());
|
||||
String szTimeStampFormatString = AppConfigsUtil.getInstance(context).getAppConfigsModel().getTimeStampCopyFormatString();
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(szTimeStampFormatString);
|
||||
String formattedDateTime = ldt.format(formatter);
|
||||
|
||||
ClipboardUtil.copyTextToClipboard(context, formattedDateTime);
|
||||
TimeStampUtil.getInstance(context).genTimeStamp();
|
||||
ClipboardUtil.copyTextToClipboard(context, TimeStampUtil.getInstance(context).getTimeStampCopyString());
|
||||
|
||||
// 比如显示一个Toast
|
||||
Toast.makeText(context, "时间戳:\n" + formattedDateTime + "\n已拷贝到剪贴板。", Toast.LENGTH_SHORT).show();
|
||||
Toast.makeText(context, "时间戳:\n" + TimeStampUtil.getInstance(context).getTimeStampCopyString() + "\n已拷贝到剪贴板。", Toast.LENGTH_SHORT).show();
|
||||
MainService.updateCopiedTimeStamp();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,12 +22,12 @@ public class AppConfigsUtil {
|
||||
|
||||
AppConfigsUtil(Context context) {
|
||||
this.mContext = context;
|
||||
loadAppConfigs();
|
||||
}
|
||||
|
||||
public synchronized static AppConfigsUtil getInstance(Context context){
|
||||
if(_AppConfigsUtil == null) {
|
||||
_AppConfigsUtil = new AppConfigsUtil(context);
|
||||
_AppConfigsUtil.loadAppConfigs();
|
||||
}
|
||||
return _AppConfigsUtil;
|
||||
}
|
||||
@@ -42,8 +42,8 @@ public class AppConfigsUtil {
|
||||
if (appConfigsModel != null) {
|
||||
mAppConfigsModel = appConfigsModel;
|
||||
} else {
|
||||
saveAppConfigs(new AppConfigsModel());
|
||||
_AppConfigsUtil = this;
|
||||
mAppConfigsModel = new AppConfigsModel();
|
||||
saveAppConfigs(mAppConfigsModel);
|
||||
}
|
||||
return mAppConfigsModel;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
package cc.winboll.studio.timestamp.utils;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen
|
||||
* @Date 2025/05/07 11:03
|
||||
* @Describe TimeStampUtil
|
||||
*/
|
||||
import android.content.Context;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
public class TimeStampUtil {
|
||||
|
||||
public static final String TAG = "TimeStampUtil";
|
||||
|
||||
volatile static TimeStampUtil _TimeStampUtil;
|
||||
|
||||
Context mContext;
|
||||
long mTimeStamp;
|
||||
|
||||
TimeStampUtil(Context context) {
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
public synchronized static TimeStampUtil getInstance(Context context) {
|
||||
if (_TimeStampUtil == null) {
|
||||
_TimeStampUtil = new TimeStampUtil(context);
|
||||
}
|
||||
return _TimeStampUtil;
|
||||
}
|
||||
|
||||
public void genTimeStamp() {
|
||||
mTimeStamp = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public String getTimeStampShowString() {
|
||||
long currentMillis = mTimeStamp;
|
||||
Instant instant = Instant.ofEpochMilli(currentMillis);
|
||||
LocalDateTime ldt = LocalDateTime.ofInstant(instant, ZoneId.systemDefault());
|
||||
String szTimeStampFormatString = AppConfigsUtil.getInstance(mContext).getAppConfigsModel().getTimeStampFormatString();
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(szTimeStampFormatString);
|
||||
String formattedDateTime = ldt.format(formatter);
|
||||
return formattedDateTime;
|
||||
}
|
||||
|
||||
public String getTimeStampCopyString() {
|
||||
long currentMillis = mTimeStamp;
|
||||
Instant instant = Instant.ofEpochMilli(currentMillis);
|
||||
LocalDateTime ldt = LocalDateTime.ofInstant(instant, ZoneId.systemDefault());
|
||||
String szTimeStampFormatString = AppConfigsUtil.getInstance(mContext).getAppConfigsModel().getTimeStampCopyFormatString();
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(szTimeStampFormatString);
|
||||
String formattedDateTime = ldt.format(formatter);
|
||||
return formattedDateTime;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user