clone https://gitea.winboll.cc/Studio/WinBoLL_Bck20251205_175044_440.git and fix build.gradle file maven key settings.
This commit is contained in:
1
timestamp/.gitignore
vendored
Normal file
1
timestamp/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/build
|
||||
8
timestamp/README.md
Normal file
8
timestamp/README.md
Normal file
@@ -0,0 +1,8 @@
|
||||
## TimpStamp
|
||||
|
||||
#### 介绍
|
||||
时间戳工具集。常驻工具栏快捷拷贝一份时间戳到剪贴板的工具。
|
||||
|
||||
## 使用要点:
|
||||
1。常驻通知栏按钮的正常使用,
|
||||
需要设置允许应用[写入剪贴板]的[始终允许]权限。
|
||||
1
timestamp/app_update_description.txt
Normal file
1
timestamp/app_update_description.txt
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
72
timestamp/build.gradle
Normal file
72
timestamp/build.gradle
Normal file
@@ -0,0 +1,72 @@
|
||||
apply plugin: 'com.android.application'
|
||||
apply from: '../.winboll/winboll_app_build.gradle'
|
||||
apply from: '../.winboll/winboll_lint_build.gradle'
|
||||
|
||||
def genVersionName(def versionName){
|
||||
// 检查编译标志位配置
|
||||
assert (winbollBuildProps['stageCount'] != null)
|
||||
assert (winbollBuildProps['baseVersion'] != null)
|
||||
// 保存基础版本号
|
||||
winbollBuildProps.setProperty("baseVersion", "${versionName}");
|
||||
//保存编译标志配置
|
||||
FileOutputStream fos = new FileOutputStream(winbollBuildPropsFile)
|
||||
winbollBuildProps.store(fos, "${winbollBuildPropsDesc}");
|
||||
fos.close();
|
||||
|
||||
// 返回编译版本号
|
||||
return "${versionName}." + winbollBuildProps['stageCount']
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion 32
|
||||
buildToolsVersion "32.0.0"
|
||||
|
||||
defaultConfig {
|
||||
applicationId "cc.winboll.studio.timestamp"
|
||||
minSdkVersion 24
|
||||
targetSdkVersion 29
|
||||
versionCode 1
|
||||
// versionName 更新后需要手动设置
|
||||
// .winboll/winbollBuildProps.properties 文件的 stageCount=0
|
||||
// Gradle编译环境下合起来的 versionName 就是 "${versionName}.0"
|
||||
versionName "15.1"
|
||||
if(true) {
|
||||
versionName = genVersionName("${versionName}")
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api fileTree(dir: 'libs', include: ['*.jar'])
|
||||
api 'cc.winboll.studio:libaes:15.6.0'
|
||||
api 'cc.winboll.studio:libapputils:15.3.4'
|
||||
api 'cc.winboll.studio:libappbase:15.7.6'
|
||||
|
||||
// SSH
|
||||
api 'com.jcraft:jsch:0.1.55'
|
||||
// Html 解析
|
||||
api 'org.jsoup:jsoup:1.13.1'
|
||||
// 二维码类库
|
||||
api 'com.google.zxing:core:3.4.1'
|
||||
api 'com.journeyapps:zxing-android-embedded:3.6.0'
|
||||
// 应用介绍页类库
|
||||
api 'io.github.medyo:android-about-page:2.0.0'
|
||||
// 吐司类库
|
||||
api 'com.github.getActivity:ToastUtils:10.5'
|
||||
// 网络连接类库
|
||||
api 'com.squareup.okhttp3:okhttp:4.4.1'
|
||||
// AndroidX 类库
|
||||
api 'androidx.appcompat:appcompat:1.1.0'
|
||||
api 'com.google.android.material:material:1.4.0'
|
||||
//api 'androidx.viewpager:viewpager:1.0.0'
|
||||
//api 'androidx.vectordrawable:vectordrawable:1.1.0'
|
||||
//api 'androidx.vectordrawable:vectordrawable-animated:1.1.0'
|
||||
//api 'androidx.fragment:fragment:1.1.0'
|
||||
}
|
||||
8
timestamp/build.properties
Normal file
8
timestamp/build.properties
Normal file
@@ -0,0 +1,8 @@
|
||||
#Created by .winboll/winboll_app_build.gradle
|
||||
#Sun Sep 28 13:16:52 HKT 2025
|
||||
stageCount=5
|
||||
libraryProject=
|
||||
baseVersion=15.1
|
||||
publishVersion=15.1.4
|
||||
buildCount=0
|
||||
baseBetaVersion=15.1.5
|
||||
21
timestamp/proguard-rules.pro
vendored
Normal file
21
timestamp/proguard-rules.pro
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
15
timestamp/src/beta/AndroidManifest.xml
Normal file
15
timestamp/src/beta/AndroidManifest.xml
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools" >
|
||||
|
||||
<application
|
||||
tools:replace="android:icon,android:roundIcon"
|
||||
android:icon="@drawable/ic_launcher_beta"
|
||||
android:roundIcon="@drawable/ic_launcher_beta">
|
||||
|
||||
<!-- Put flavor specific code here -->
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
|
||||
6
timestamp/src/beta/res/values/strings.xml
Normal file
6
timestamp/src/beta/res/values/strings.xml
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<string name="app_name">TimeStamp +</string>
|
||||
|
||||
</resources>
|
||||
67
timestamp/src/main/AndroidManifest.xml
Normal file
67
timestamp/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1,67 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<manifest
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="cc.winboll.studio.timestamp">
|
||||
|
||||
<!-- 开机启动 -->
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
|
||||
|
||||
<!-- 运行前台服务 -->
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
|
||||
|
||||
<!-- READ_CLIPBOARD -->
|
||||
<uses-permission android:name="android.permission.READ_CLIPBOARD"/>
|
||||
|
||||
<!-- WRITE_CLIPBOARD -->
|
||||
<uses-permission android:name="android.permission.WRITE_CLIPBOARD"/>
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@drawable/ic_launcher_stage"
|
||||
android:roundIcon="@drawable/ic_launcher_stage"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/MyAppTheme"
|
||||
android:resizeableActivity="true"
|
||||
android:name=".App">
|
||||
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:label="@string/app_name">
|
||||
|
||||
<intent-filter>
|
||||
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
|
||||
</intent-filter>
|
||||
|
||||
</activity>
|
||||
|
||||
<meta-data
|
||||
android:name="android.max_aspect"
|
||||
android:value="4.0"/>
|
||||
|
||||
<activity android:name=".GlobalApplication$CrashActivity"/>
|
||||
|
||||
<service android:name=".MainService"/>
|
||||
|
||||
<service android:name=".AssistantService"/>
|
||||
|
||||
<receiver
|
||||
android:name=".receivers.MainReceiver"
|
||||
android:enabled="true"
|
||||
android:exported="false"
|
||||
android:directBootAware="true">
|
||||
|
||||
<intent-filter>
|
||||
|
||||
<action android:name="android.intent.action.BOOT_COMPLETED"/>
|
||||
|
||||
</intent-filter>
|
||||
|
||||
</receiver>
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
349
timestamp/src/main/java/cc/winboll/studio/timestamp/App.java
Normal file
349
timestamp/src/main/java/cc/winboll/studio/timestamp/App.java
Normal file
@@ -0,0 +1,349 @@
|
||||
package cc.winboll.studio.timestamp;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.HorizontalScrollView;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import cc.winboll.studio.timestamp.R;
|
||||
import cc.winboll.studio.libappbase.GlobalApplication;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.Closeable;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.lang.Thread.UncaughtExceptionHandler;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
public class App extends GlobalApplication {
|
||||
|
||||
private static Handler MAIN_HANDLER = new Handler(Looper.getMainLooper());
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
|
||||
// 初始化 Toast 框架
|
||||
ToastUtils.init(this);
|
||||
// 设置 Toast 布局样式
|
||||
//ToastUtils.setView(R.layout.view_toast);
|
||||
//ToastUtils.setStyle(new WhiteToastStyle());
|
||||
ToastUtils.setGravity(Gravity.BOTTOM, 0, 200);
|
||||
|
||||
//CrashHandler.getInstance().registerGlobal(this);
|
||||
//CrashHandler.getInstance().registerPart(this);
|
||||
}
|
||||
|
||||
public static int getAPPIcon() {
|
||||
return BuildConfig.DEBUG?R.drawable.ic_launcher_beta:R.drawable.ic_launcher_stage;
|
||||
}
|
||||
|
||||
public static void write(InputStream input, OutputStream output) throws IOException {
|
||||
byte[] buf = new byte[1024 * 8];
|
||||
int len;
|
||||
while ((len = input.read(buf)) != -1) {
|
||||
output.write(buf, 0, len);
|
||||
}
|
||||
}
|
||||
|
||||
public static void write(File file, byte[] data) throws IOException {
|
||||
File parent = file.getParentFile();
|
||||
if (parent != null && !parent.exists()) parent.mkdirs();
|
||||
|
||||
ByteArrayInputStream input = new ByteArrayInputStream(data);
|
||||
FileOutputStream output = new FileOutputStream(file);
|
||||
try {
|
||||
write(input, output);
|
||||
} finally {
|
||||
closeIO(input, output);
|
||||
}
|
||||
}
|
||||
|
||||
public static String toString(InputStream input) throws IOException {
|
||||
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
||||
write(input, output);
|
||||
try {
|
||||
return output.toString("UTF-8");
|
||||
} finally {
|
||||
closeIO(input, output);
|
||||
}
|
||||
}
|
||||
|
||||
public static void closeIO(Closeable... closeables) {
|
||||
for (Closeable closeable : closeables) {
|
||||
try {
|
||||
if (closeable != null) closeable.close();
|
||||
} catch (IOException ignored) {}
|
||||
}
|
||||
}
|
||||
|
||||
public static class CrashHandler {
|
||||
|
||||
public static final UncaughtExceptionHandler DEFAULT_UNCAUGHT_EXCEPTION_HANDLER = Thread.getDefaultUncaughtExceptionHandler();
|
||||
|
||||
private static CrashHandler sInstance;
|
||||
|
||||
private PartCrashHandler mPartCrashHandler;
|
||||
|
||||
public static CrashHandler getInstance() {
|
||||
if (sInstance == null) {
|
||||
sInstance = new CrashHandler();
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public void registerGlobal(Context context) {
|
||||
registerGlobal(context, null);
|
||||
}
|
||||
|
||||
public void registerGlobal(Context context, String crashDir) {
|
||||
Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandlerImpl(context.getApplicationContext(), crashDir));
|
||||
}
|
||||
|
||||
public void unregister() {
|
||||
Thread.setDefaultUncaughtExceptionHandler(DEFAULT_UNCAUGHT_EXCEPTION_HANDLER);
|
||||
}
|
||||
|
||||
public void registerPart(Context context) {
|
||||
unregisterPart(context);
|
||||
mPartCrashHandler = new PartCrashHandler(context.getApplicationContext());
|
||||
MAIN_HANDLER.postAtFrontOfQueue(mPartCrashHandler);
|
||||
}
|
||||
|
||||
public void unregisterPart(Context context) {
|
||||
if (mPartCrashHandler != null) {
|
||||
mPartCrashHandler.isRunning.set(false);
|
||||
mPartCrashHandler = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static class PartCrashHandler implements Runnable {
|
||||
|
||||
private final Context mContext;
|
||||
|
||||
public AtomicBoolean isRunning = new AtomicBoolean(true);
|
||||
|
||||
public PartCrashHandler(Context context) {
|
||||
this.mContext = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
while (isRunning.get()) {
|
||||
try {
|
||||
Looper.loop();
|
||||
} catch (final Throwable e) {
|
||||
e.printStackTrace();
|
||||
if (isRunning.get()) {
|
||||
MAIN_HANDLER.post(new Runnable(){
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Toast.makeText(mContext, e.toString(), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (e instanceof RuntimeException) {
|
||||
throw (RuntimeException)e;
|
||||
} else {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class UncaughtExceptionHandlerImpl implements UncaughtExceptionHandler {
|
||||
|
||||
private static DateFormat DATE_FORMAT = new SimpleDateFormat("yyyy_MM_dd-HH_mm_ss");
|
||||
|
||||
private final Context mContext;
|
||||
|
||||
private final File mCrashDir;
|
||||
|
||||
public UncaughtExceptionHandlerImpl(Context context, String crashDir) {
|
||||
this.mContext = context;
|
||||
this.mCrashDir = TextUtils.isEmpty(crashDir) ? new File(mContext.getExternalCacheDir(), "crash") : new File(crashDir);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uncaughtException(Thread thread, Throwable throwable) {
|
||||
try {
|
||||
|
||||
String log = buildLog(throwable);
|
||||
writeLog(log);
|
||||
|
||||
try {
|
||||
Intent intent = new Intent(mContext, CrashActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
intent.putExtra(Intent.EXTRA_TEXT, log);
|
||||
mContext.startActivity(intent);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
writeLog(e.toString());
|
||||
}
|
||||
|
||||
throwable.printStackTrace();
|
||||
android.os.Process.killProcess(android.os.Process.myPid());
|
||||
System.exit(0);
|
||||
|
||||
} catch (Throwable e) {
|
||||
if (DEFAULT_UNCAUGHT_EXCEPTION_HANDLER != null) DEFAULT_UNCAUGHT_EXCEPTION_HANDLER.uncaughtException(thread, throwable);
|
||||
}
|
||||
}
|
||||
|
||||
private String buildLog(Throwable throwable) {
|
||||
String time = DATE_FORMAT.format(new Date());
|
||||
|
||||
String versionName = "unknown";
|
||||
long versionCode = 0;
|
||||
try {
|
||||
PackageInfo packageInfo = mContext.getPackageManager().getPackageInfo(mContext.getPackageName(), 0);
|
||||
versionName = packageInfo.versionName;
|
||||
versionCode = Build.VERSION.SDK_INT >= 28 ? packageInfo.getLongVersionCode() : packageInfo.versionCode;
|
||||
} catch (Throwable ignored) {}
|
||||
|
||||
LinkedHashMap<String, String> head = new LinkedHashMap<String, String>();
|
||||
head.put("Time Of Crash", time);
|
||||
head.put("Device", String.format("%s, %s", Build.MANUFACTURER, Build.MODEL));
|
||||
head.put("Android Version", String.format("%s (%d)", Build.VERSION.RELEASE, Build.VERSION.SDK_INT));
|
||||
head.put("App Version", String.format("%s (%d)", versionName, versionCode));
|
||||
head.put("Kernel", getKernel());
|
||||
head.put("Support Abis", Build.VERSION.SDK_INT >= 21 && Build.SUPPORTED_ABIS != null ? Arrays.toString(Build.SUPPORTED_ABIS): "unknown");
|
||||
head.put("Fingerprint", Build.FINGERPRINT);
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
for (String key : head.keySet()) {
|
||||
if (builder.length() != 0) builder.append("\n");
|
||||
builder.append(key);
|
||||
builder.append(" : ");
|
||||
builder.append(head.get(key));
|
||||
}
|
||||
|
||||
builder.append("\n\n");
|
||||
builder.append(Log.getStackTraceString(throwable));
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
private void writeLog(String log) {
|
||||
String time = DATE_FORMAT.format(new Date());
|
||||
File file = new File(mCrashDir, "crash_" + time + ".txt");
|
||||
try {
|
||||
write(file, log.getBytes("UTF-8"));
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static String getKernel() {
|
||||
try {
|
||||
return App.toString(new FileInputStream("/proc/version")).trim();
|
||||
} catch (Throwable e) {
|
||||
return e.getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static final class CrashActivity extends Activity {
|
||||
|
||||
private String mLog;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setTheme(android.R.style.Theme_DeviceDefault);
|
||||
setTitle("App Crash");
|
||||
|
||||
mLog = getIntent().getStringExtra(Intent.EXTRA_TEXT);
|
||||
|
||||
ScrollView contentView = new ScrollView(this);
|
||||
contentView.setFillViewport(true);
|
||||
|
||||
HorizontalScrollView horizontalScrollView = new HorizontalScrollView(this);
|
||||
|
||||
TextView textView = new TextView(this);
|
||||
int padding = dp2px(16);
|
||||
textView.setPadding(padding, padding, padding, padding);
|
||||
textView.setText(mLog);
|
||||
textView.setTextIsSelectable(true);
|
||||
textView.setTypeface(Typeface.DEFAULT);
|
||||
textView.setLinksClickable(true);
|
||||
|
||||
horizontalScrollView.addView(textView);
|
||||
contentView.addView(horizontalScrollView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
|
||||
setContentView(contentView);
|
||||
}
|
||||
|
||||
private void restart() {
|
||||
Intent intent = getPackageManager().getLaunchIntentForPackage(getPackageName());
|
||||
if (intent != null) {
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(intent);
|
||||
}
|
||||
finish();
|
||||
android.os.Process.killProcess(android.os.Process.myPid());
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
private static int dp2px(float dpValue) {
|
||||
final float scale = Resources.getSystem().getDisplayMetrics().density;
|
||||
return (int) (dpValue * scale + 0.5f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
menu.add(0, android.R.id.copy, 0, android.R.string.copy)
|
||||
.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.copy:
|
||||
ClipboardManager cm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
cm.setPrimaryClip(ClipData.newPlainText(getPackageName(), mLog));
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
restart();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package cc.winboll.studio.timestamp;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen
|
||||
* @Date 2025/05/05 09:49
|
||||
* @Describe MainService 守护进程服务
|
||||
*/
|
||||
import android.app.Service;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
import android.os.IBinder;
|
||||
import cc.winboll.studio.timestamp.AssistantService;
|
||||
import cc.winboll.studio.timestamp.MainService;
|
||||
import cc.winboll.studio.timestamp.models.AppConfigsModel;
|
||||
import cc.winboll.studio.timestamp.utils.AppConfigsUtil;
|
||||
import cc.winboll.studio.timestamp.utils.ServiceUtil;
|
||||
|
||||
public class AssistantService extends Service {
|
||||
|
||||
public static final String TAG = "AssistantService";
|
||||
|
||||
//MyBinder mMyBinder;
|
||||
MyServiceConnection mMyServiceConnection;
|
||||
volatile boolean mIsThreadAlive;
|
||||
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
//return mMyBinder;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
//LogUtils.d(TAG, "call onCreate()");
|
||||
super.onCreate();
|
||||
|
||||
//mMyBinder = new MyBinder();
|
||||
if (mMyServiceConnection == null) {
|
||||
mMyServiceConnection = new MyServiceConnection();
|
||||
}
|
||||
// 设置运行参数
|
||||
mIsThreadAlive = false;
|
||||
run();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
//LogUtils.d(TAG, "call onStartCommand(...)");
|
||||
run();
|
||||
AppConfigsModel appConfigs = AppConfigsUtil.getInstance(AssistantService.this).loadAppConfigs();
|
||||
return appConfigs.isEnableService() ? Service.START_STICKY: super.onStartCommand(intent, flags, startId);
|
||||
}
|
||||
|
||||
/*class MyBinder extends IMyAidlInterface.Stub {
|
||||
@Override
|
||||
public String getServiceName() {
|
||||
return AssistantService.class.getSimpleName();
|
||||
}
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
//LogUtils.d(TAG, "call onDestroy()");
|
||||
mIsThreadAlive = false;
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
// 运行服务内容
|
||||
//
|
||||
void run() {
|
||||
//LogUtils.d(TAG, "call run()");
|
||||
AppConfigsModel appConfigs = AppConfigsUtil.getInstance(AssistantService.this).loadAppConfigs();
|
||||
if (appConfigs.isEnableService()) {
|
||||
if (mIsThreadAlive == false) {
|
||||
// 设置运行状态
|
||||
mIsThreadAlive = true;
|
||||
// 唤醒和绑定主进程
|
||||
wakeupAndBindMain();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 唤醒和绑定主进程
|
||||
//
|
||||
void wakeupAndBindMain() {
|
||||
if (ServiceUtil.isServiceAlive(getApplicationContext(), MainService.class.getName()) == false) {
|
||||
//LogUtils.d(TAG, "wakeupAndBindMain() Wakeup... ControlCenterService");
|
||||
startForegroundService(new Intent(AssistantService.this, MainService.class));
|
||||
}
|
||||
//LogUtils.d(TAG, "wakeupAndBindMain() Bind... ControlCenterService");
|
||||
bindService(new Intent(AssistantService.this, MainService.class), mMyServiceConnection, Context.BIND_IMPORTANT);
|
||||
}
|
||||
|
||||
// 主进程与守护进程连接时需要用到此类
|
||||
//
|
||||
class MyServiceConnection implements ServiceConnection {
|
||||
@Override
|
||||
public void onServiceConnected(ComponentName name, IBinder service) {
|
||||
//LogUtils.d(TAG, "call onServiceConnected(...)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onServiceDisconnected(ComponentName name) {
|
||||
//LogUtils.d(TAG, "call onServiceDisconnected(...)");
|
||||
AppConfigsModel appConfigs = AppConfigsUtil.getInstance(AssistantService.this).loadAppConfigs();
|
||||
if (appConfigs.isEnableService()) {
|
||||
wakeupAndBindMain();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
package cc.winboll.studio.timestamp;
|
||||
|
||||
import android.os.Bundle;
|
||||
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;
|
||||
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;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
public static final String TAG = "MainActivity";
|
||||
|
||||
EditText metTimeStampFormatString;
|
||||
TextView mtvTimeStampFormatString;
|
||||
EditText metTimeStampCopyFormatString;
|
||||
TextView mtvTimeStampCopyFormatString;
|
||||
|
||||
LogView mLogView;
|
||||
Switch mswEnableMainService;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
Toolbar toolbar=(Toolbar)findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
metTimeStampFormatString = findViewById(R.id.et_timestampformatstring);
|
||||
mtvTimeStampFormatString = findViewById(R.id.tv_timestampformatstring);
|
||||
metTimeStampCopyFormatString = findViewById(R.id.et_timestampcopyformatstring);
|
||||
mtvTimeStampCopyFormatString = findViewById(R.id.tv_timestampcopyformatstring);
|
||||
|
||||
metTimeStampFormatString.setText(AppConfigsUtil.getInstance(this).getAppConfigsModel().getTimeStampFormatString());
|
||||
showPreViewResult(metTimeStampFormatString, mtvTimeStampFormatString);
|
||||
metTimeStampCopyFormatString.setText(AppConfigsUtil.getInstance(this).getAppConfigsModel().getTimeStampCopyFormatString());
|
||||
showPreViewResult(metTimeStampCopyFormatString, mtvTimeStampCopyFormatString);
|
||||
|
||||
mswEnableMainService = findViewById(R.id.activitymainSwitch1);
|
||||
mswEnableMainService.setChecked(AppConfigsUtil.getInstance(this).loadAppConfigs().isEnableService());
|
||||
|
||||
mLogView = findViewById(R.id.logview);
|
||||
|
||||
ToastUtils.show("onCreate");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
mLogView.start();
|
||||
}
|
||||
|
||||
public void onSetMainServiceStatus(View view) {
|
||||
MainService.setMainServiceStatus(this, mswEnableMainService.isChecked());
|
||||
}
|
||||
|
||||
public void onSaveFormatString(View view) {
|
||||
if(showPreViewResult(metTimeStampFormatString, mtvTimeStampFormatString)) {
|
||||
AppConfigsUtil.getInstance(this).getAppConfigsModel().setTimeStampFormatString(metTimeStampFormatString.getText().toString());
|
||||
AppConfigsUtil.getInstance(this).saveAppConfigs();
|
||||
}
|
||||
}
|
||||
|
||||
public void onSaveCopyFormatString(View view) {
|
||||
if(showPreViewResult(metTimeStampCopyFormatString, mtvTimeStampCopyFormatString)) {
|
||||
AppConfigsUtil.getInstance(this).getAppConfigsModel().setTimeStampCopyFormatString(metTimeStampCopyFormatString.getText().toString());
|
||||
AppConfigsUtil.getInstance(this).saveAppConfigs();
|
||||
}
|
||||
}
|
||||
|
||||
boolean showPreViewResult(EditText etFormat, TextView tvShow) {
|
||||
try {
|
||||
long currentMillis = System.currentTimeMillis();
|
||||
Instant instant = Instant.ofEpochMilli(currentMillis);
|
||||
LocalDateTime ldt = LocalDateTime.ofInstant(instant, ZoneId.systemDefault());
|
||||
String szTimeStampFormatString = etFormat.getText().toString();
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(szTimeStampFormatString);
|
||||
String formattedDateTime = ldt.format(formatter);
|
||||
tvShow.setText(formattedDateTime);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,229 @@
|
||||
package cc.winboll.studio.timestamp;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen
|
||||
* @Date 2025/05/05 09:47
|
||||
* @Describe 主要服务
|
||||
*/
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.Service;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.ServiceConnection;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
import android.os.Message;
|
||||
import android.widget.RemoteViews;
|
||||
import android.widget.TextView;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.timestamp.AssistantService;
|
||||
import cc.winboll.studio.timestamp.MainService;
|
||||
import cc.winboll.studio.timestamp.models.AppConfigsModel;
|
||||
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 cc.winboll.studio.timestamp.utils.TimeStampUtil;
|
||||
|
||||
public class MainService extends Service {
|
||||
|
||||
public static String TAG = "MainService";
|
||||
|
||||
public static final int MSG_UPDATE_TIMESTAMP = 0;
|
||||
|
||||
ButtonClickReceiver mButtonClickReceiver;
|
||||
NotificationHelper mNotificationHelper;
|
||||
Notification mNotification;
|
||||
RemoteViews mRemoteViews;
|
||||
TextView mtvTimeStamp;
|
||||
//Timer mTimer;
|
||||
private static boolean _mIsServiceAlive;
|
||||
public static final String EXTRA_APKFILEPATH = "EXTRA_APKFILEPATH";
|
||||
final static int MSG_INSTALL_APK = 0;
|
||||
static MyHandler _MyHandler;
|
||||
MyServiceConnection mMyServiceConnection;
|
||||
MainActivity mInstallCompletedFollowUpActivity;
|
||||
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
mNotificationHelper = new NotificationHelper();
|
||||
mNotificationHelper.createServiceNotificationChannel(this);
|
||||
|
||||
// 创建广播接收器实例
|
||||
mButtonClickReceiver = new ButtonClickReceiver();
|
||||
|
||||
// 创建 IntentFilter 并设置要接收的广播动作
|
||||
IntentFilter filter = new IntentFilter(ButtonClickReceiver.BUTTON_COPYTIMESTAMP_ACTION);
|
||||
|
||||
// 注册广播接收器
|
||||
registerReceiver(mButtonClickReceiver, filter);
|
||||
|
||||
LogUtils.d(TAG, "onCreate()");
|
||||
_mIsServiceAlive = false;
|
||||
|
||||
_MyHandler = new MyHandler();
|
||||
if (mMyServiceConnection == null) {
|
||||
mMyServiceConnection = new MyServiceConnection();
|
||||
}
|
||||
|
||||
run();
|
||||
}
|
||||
|
||||
private void run() {
|
||||
AppConfigsModel appConfigs = AppConfigsUtil.getInstance(MainService.this).loadAppConfigs();
|
||||
if (appConfigs.isEnableService()) {
|
||||
if (_mIsServiceAlive == false) {
|
||||
// 设置运行状态
|
||||
_mIsServiceAlive = true;
|
||||
|
||||
// 显示前台通知栏
|
||||
// mNotificationHelper = new NotificationHelper(this);
|
||||
// //notification = helper.showForegroundNotification(intent, getString(R.string.app_name), getString(R.string.text_aboutservernotification));
|
||||
// mNotification = mNotificationHelper.showCustomForegroundNotification(new Intent(this, MainActivity.class), mRemoteViews, mRemoteViews);
|
||||
// startForeground(NotificationHelper.FOREGROUND_NOTIFICATION_ID, mNotification);
|
||||
|
||||
// 唤醒守护进程
|
||||
wakeupAndBindAssistant();
|
||||
|
||||
LogUtils.d(TAG, "running...");
|
||||
_MyHandler.sendEmptyMessage(MSG_UPDATE_TIMESTAMP);
|
||||
|
||||
// mTimer = new Timer();
|
||||
// TimerTask task = new TimerTask() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// //System.out.println("定时任务执行了");
|
||||
// mMyHandler.sendEmptyMessage(MSG_UPDATE_TIMESTAMP);
|
||||
// }
|
||||
// };
|
||||
// // 延迟1秒后开始执行,之后每隔100毫秒执行一次
|
||||
// mTimer.schedule(task, 1000, 100);
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
LogUtils.d(TAG, "_mIsServiceAlive is " + Boolean.toString(_mIsServiceAlive));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
|
||||
// if (mTimer != null) {
|
||||
// mTimer.cancel();
|
||||
// }
|
||||
|
||||
NotificationManager notificationManager = getSystemService(NotificationManager.class);
|
||||
notificationManager.cancelAll();
|
||||
|
||||
_mIsServiceAlive = false;
|
||||
_MyHandler = null;
|
||||
LogUtils.d(TAG, "onDestroy()");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
LogUtils.d(TAG, "onStartCommand");
|
||||
|
||||
run();
|
||||
AppConfigsModel appConfigs = AppConfigsUtil.getInstance(MainService.this).loadAppConfigs();
|
||||
|
||||
return appConfigs.isEnableService() ? Service.START_STICKY: super.onStartCommand(intent, flags, startId);
|
||||
}
|
||||
|
||||
public static void setMainServiceStatus(Context context, boolean isEnable) {
|
||||
AppConfigsModel appConfigs = AppConfigsUtil.getInstance(context).loadAppConfigs();
|
||||
appConfigs.setIsEnableService(isEnable);
|
||||
AppConfigsUtil.getInstance(context).saveAppConfigs();
|
||||
|
||||
Intent intent = new Intent(context, MainService.class);
|
||||
if (isEnable) {
|
||||
context.startService(intent);
|
||||
} else {
|
||||
context.stopService(intent);
|
||||
}
|
||||
}
|
||||
|
||||
// 主进程与守护进程连接时需要用到此类
|
||||
//
|
||||
private class MyServiceConnection implements ServiceConnection {
|
||||
@Override
|
||||
public void onServiceConnected(ComponentName name, IBinder service) {
|
||||
//LogUtils.d(TAG, "call onServiceConnected(...)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onServiceDisconnected(ComponentName name) {
|
||||
//LogUtils.d(TAG, "call onServiceConnected(...)");
|
||||
AppConfigsModel appConfigs = AppConfigsUtil.getInstance(MainService.this).loadAppConfigs();
|
||||
if (appConfigs.isEnableService()) {
|
||||
// 唤醒守护进程
|
||||
wakeupAndBindAssistant();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 唤醒和绑定守护进程
|
||||
//
|
||||
void wakeupAndBindAssistant() {
|
||||
if (ServiceUtil.isServiceAlive(getApplicationContext(), AssistantService.class.getName()) == false) {
|
||||
startService(new Intent(MainService.this, AssistantService.class));
|
||||
//LogUtils.d(TAG, "call wakeupAndBindAssistant() : Binding... AssistantService");
|
||||
bindService(new Intent(MainService.this, AssistantService.class), mMyServiceConnection, Context.BIND_IMPORTANT);
|
||||
}
|
||||
}
|
||||
|
||||
// void updateTimeStamp() {
|
||||
// long currentMillis = System.currentTimeMillis();
|
||||
// Instant instant = Instant.ofEpochMilli(currentMillis);
|
||||
// LocalDateTime ldt = LocalDateTime.ofInstant(instant, ZoneId.systemDefault());
|
||||
// String szTimeStampFormatString = AppConfigs.getInstance(this).getTimeStampFormatString();
|
||||
// DateTimeFormatter formatter = DateTimeFormatter.ofPattern(szTimeStampFormatString);
|
||||
// String formattedDateTime = ldt.format(formatter);
|
||||
// //System.out.println(formattedDateTime);
|
||||
// mRemoteViews.setTextViewText(R.id.tv_timestamp, formattedDateTime);
|
||||
// notification = mNotificationHelper.showCustomForegroundNotification(intentMainService, mRemoteViews, mRemoteViews);
|
||||
// //startForeground(NotificationHelper.FOREGROUND_NOTIFICATION_ID, notification);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// 服务事务处理类
|
||||
//
|
||||
class MyHandler extends Handler {
|
||||
|
||||
public void handleMessage(Message message) {
|
||||
switch (message.what) {
|
||||
case MSG_UPDATE_TIMESTAMP:
|
||||
{
|
||||
String szTimeStampShowString = TimeStampUtil.getInstance(MainService.this).getTimeStampShowString();
|
||||
mNotificationHelper.sendForegroundNotification(MainService.this, "时间戳:\n" + szTimeStampShowString + "\n已截取。");
|
||||
|
||||
LogUtils.d(TAG, "Hello, World! " + szTimeStampShowString);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
super.handleMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
public static void updateCopiedTimeStamp() {
|
||||
if (_MyHandler != null) {
|
||||
_MyHandler.sendEmptyMessage(MSG_UPDATE_TIMESTAMP);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package cc.winboll.studio.timestamp.models;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen
|
||||
* @Date 2025/05/05 09:51
|
||||
* @Describe 应用配置数据模型
|
||||
*/
|
||||
import android.content.Context;
|
||||
import android.util.JsonReader;
|
||||
import android.util.JsonWriter;
|
||||
import cc.winboll.studio.libappbase.BaseBean;
|
||||
import cc.winboll.studio.timestamp.models.AppConfigsModel;
|
||||
import java.io.IOException;
|
||||
|
||||
public class AppConfigsModel extends BaseBean {
|
||||
|
||||
public static final String TAG = "AppConfigs";
|
||||
|
||||
// 是否启动服务
|
||||
boolean isEnableService;
|
||||
// 时间戳显示格式
|
||||
String timeStampFormatString;
|
||||
// 时间戳拷贝格式
|
||||
String timeStampCopyFormatString;
|
||||
|
||||
public AppConfigsModel() {
|
||||
this.isEnableService = false;
|
||||
this.timeStampFormatString = "yyyy-MM-dd HH:mm:ss SSS";
|
||||
this.timeStampCopyFormatString = "yyyy_MM_dd-HH_mm_ss-SSS";
|
||||
}
|
||||
|
||||
public void setTimeStampCopyFormatString(String timeStampCopyFormatString) {
|
||||
this.timeStampCopyFormatString = timeStampCopyFormatString;
|
||||
}
|
||||
|
||||
public String getTimeStampCopyFormatString() {
|
||||
return timeStampCopyFormatString;
|
||||
}
|
||||
|
||||
public void setTimeStampFormatString(String timeStampFormatString) {
|
||||
this.timeStampFormatString = timeStampFormatString;
|
||||
}
|
||||
|
||||
public String getTimeStampFormatString() {
|
||||
return timeStampFormatString;
|
||||
}
|
||||
|
||||
public void setIsEnableService(boolean isEnableService) {
|
||||
this.isEnableService = isEnableService;
|
||||
}
|
||||
|
||||
public boolean isEnableService() {
|
||||
return isEnableService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return AppConfigsModel.class.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeThisToJsonWriter(JsonWriter jsonWriter) throws IOException {
|
||||
super.writeThisToJsonWriter(jsonWriter);
|
||||
jsonWriter.name("isEnableService").value(isEnableService());
|
||||
jsonWriter.name("timeStampFormatString").value(getTimeStampFormatString());
|
||||
jsonWriter.name("timeStampCopyFormatString").value(getTimeStampCopyFormatString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean initObjectsFromJsonReader(JsonReader jsonReader, String name) throws IOException {
|
||||
if (super.initObjectsFromJsonReader(jsonReader, name)) { return true; } else {
|
||||
if (name.equals("isEnableService")) {
|
||||
setIsEnableService(jsonReader.nextBoolean());
|
||||
} else if (name.equals("timeStampFormatString")) {
|
||||
setTimeStampFormatString(jsonReader.nextString());
|
||||
} else if (name.equals("timeStampCopyFormatString")) {
|
||||
setTimeStampCopyFormatString(jsonReader.nextString());
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBean readBeanFromJsonReader(JsonReader jsonReader) throws IOException {
|
||||
jsonReader.beginObject();
|
||||
while (jsonReader.hasNext()) {
|
||||
String name = jsonReader.nextName();
|
||||
if (!initObjectsFromJsonReader(jsonReader, name)) {
|
||||
jsonReader.skipValue();
|
||||
}
|
||||
}
|
||||
// 结束 JSON 对象
|
||||
jsonReader.endObject();
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
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;
|
||||
import cc.winboll.studio.timestamp.BuildConfig;
|
||||
import cc.winboll.studio.timestamp.MainService;
|
||||
import cc.winboll.studio.timestamp.utils.ClipboardUtil;
|
||||
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 = 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)) {
|
||||
// 在这里编写按钮点击后要执行的代码
|
||||
TimeStampUtil.getInstance(context).genTimeStamp();
|
||||
ClipboardUtil.copyTextToClipboard(context, TimeStampUtil.getInstance(context).getTimeStampCopyString());
|
||||
|
||||
// 比如显示一个Toast
|
||||
Toast.makeText(context, "时间戳:\n" + TimeStampUtil.getInstance(context).getTimeStampCopyString() + "\n已拷贝到剪贴板。", Toast.LENGTH_SHORT).show();
|
||||
MainService.updateCopiedTimeStamp();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package cc.winboll.studio.timestamp.receivers;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.timestamp.MainService;
|
||||
import cc.winboll.studio.timestamp.models.AppConfigsModel;
|
||||
import cc.winboll.studio.timestamp.utils.AppConfigsUtil;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen&豆包大模型<zhangsken@qq.com>
|
||||
* @Date 2025/07/28 11:15
|
||||
* @Describe MainReceiver
|
||||
*/
|
||||
public class MainReceiver extends BroadcastReceiver {
|
||||
|
||||
public static final String TAG = "MainReceiver";
|
||||
|
||||
static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
|
||||
|
||||
AppConfigsUtil mAppConfigsUtil;
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String szAction = intent.getAction();
|
||||
if (szAction.equals(ACTION_BOOT_COMPLETED)) {
|
||||
AppConfigsModel appConfigs = AppConfigsUtil.getInstance(context).loadAppConfigs();
|
||||
boolean isEnable = appConfigs.isEnableService();
|
||||
AppConfigsUtil.getInstance(context).saveAppConfigs();
|
||||
|
||||
Intent intentMainService = new Intent(context, MainService.class);
|
||||
if (isEnable) {
|
||||
context.startService(intentMainService);
|
||||
}
|
||||
LogUtils.i(TAG, "System Boot And Start ManagerService Completed!");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package cc.winboll.studio.timestamp.utils;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen
|
||||
* @Date 2025/05/05 14:00
|
||||
* @Describe AppConfigsUtil
|
||||
*/
|
||||
import android.content.Context;
|
||||
import android.util.JsonReader;
|
||||
import android.util.JsonWriter;
|
||||
import cc.winboll.studio.libappbase.BaseBean;
|
||||
import cc.winboll.studio.timestamp.models.AppConfigsModel;
|
||||
import java.io.IOException;
|
||||
|
||||
public class AppConfigsUtil {
|
||||
|
||||
public static final String TAG = "AppConfigsUtil";
|
||||
|
||||
volatile static AppConfigsUtil _AppConfigsUtil;
|
||||
Context mContext;
|
||||
AppConfigsModel mAppConfigsModel;
|
||||
|
||||
AppConfigsUtil(Context context) {
|
||||
this.mContext = context;
|
||||
loadAppConfigs();
|
||||
}
|
||||
|
||||
public synchronized static AppConfigsUtil getInstance(Context context){
|
||||
if(_AppConfigsUtil == null) {
|
||||
_AppConfigsUtil = new AppConfigsUtil(context);
|
||||
}
|
||||
return _AppConfigsUtil;
|
||||
}
|
||||
|
||||
public AppConfigsModel getAppConfigsModel() {
|
||||
return mAppConfigsModel;
|
||||
}
|
||||
|
||||
public AppConfigsModel loadAppConfigs() {
|
||||
AppConfigsModel appConfigsModel = null;
|
||||
appConfigsModel = AppConfigsModel.loadBean(mContext, AppConfigsModel.class);
|
||||
if (appConfigsModel != null) {
|
||||
mAppConfigsModel = appConfigsModel;
|
||||
} else {
|
||||
mAppConfigsModel = new AppConfigsModel();
|
||||
saveAppConfigs(mAppConfigsModel);
|
||||
}
|
||||
return mAppConfigsModel;
|
||||
}
|
||||
|
||||
public void saveAppConfigs(AppConfigsModel appConfigsModel) {
|
||||
AppConfigsModel.saveBean(mContext, appConfigsModel);
|
||||
}
|
||||
|
||||
public void saveAppConfigs() {
|
||||
AppConfigsModel.saveBean(mContext, mAppConfigsModel);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package cc.winboll.studio.timestamp.utils;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen
|
||||
* @Date 2025/05/07 02:38
|
||||
* @Describe AudioPlayer
|
||||
*/
|
||||
import android.content.Context;
|
||||
import android.media.MediaPlayer;
|
||||
import android.net.Uri;
|
||||
import android.util.Log;
|
||||
|
||||
public class AudioPlayerMP3Util {
|
||||
|
||||
public static final String TAG = "AudioPlayer";
|
||||
|
||||
private static MediaPlayer mediaPlayer;
|
||||
|
||||
/**
|
||||
* 播放指定的 MP3 文件
|
||||
*
|
||||
* @param context 上下文
|
||||
* @param mp3FilePath MP3 文件的路径,例如:"/storage/emulated/0/Music/song.mp3"
|
||||
*/
|
||||
public static void playMp3(Context context, String mp3FilePath) {
|
||||
if (mediaPlayer != null && mediaPlayer.isPlaying()) {
|
||||
mediaPlayer.stop();
|
||||
mediaPlayer.release();
|
||||
mediaPlayer = null;
|
||||
}
|
||||
|
||||
try {
|
||||
mediaPlayer = new MediaPlayer();
|
||||
Uri uri = Uri.parse(mp3FilePath);
|
||||
mediaPlayer.setDataSource(context, uri);
|
||||
mediaPlayer.prepare();
|
||||
mediaPlayer.start();
|
||||
|
||||
mediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
|
||||
@Override
|
||||
public void onCompletion(MediaPlayer mp) {
|
||||
releaseMediaPlayer();
|
||||
}
|
||||
});
|
||||
|
||||
mediaPlayer.setOnErrorListener(new MediaPlayer.OnErrorListener() {
|
||||
@Override
|
||||
public boolean onError(MediaPlayer mp, int what, int extra) {
|
||||
Log.e("AudioPlayer", "播放音频时出错: what=" + what + ", extra=" + extra);
|
||||
releaseMediaPlayer();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
releaseMediaPlayer();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 释放 MediaPlayer 资源
|
||||
*/
|
||||
private static void releaseMediaPlayer() {
|
||||
if (mediaPlayer != null) {
|
||||
mediaPlayer.stop();
|
||||
mediaPlayer.release();
|
||||
mediaPlayer = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
package cc.winboll.studio.timestamp.utils;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen
|
||||
* @Date 2025/05/07 02:31
|
||||
* @Describe AudioPlayerUtil
|
||||
*/
|
||||
import android.content.Context;
|
||||
import android.media.MediaPlayer;
|
||||
import android.net.Uri;
|
||||
import android.util.Log;
|
||||
|
||||
public class AudioPlayerUriUtil {
|
||||
|
||||
public static final String TAG = "AudioPlayerUtil";
|
||||
|
||||
private static MediaPlayer mediaPlayer;
|
||||
|
||||
/**
|
||||
* 播放指定Uri的音频
|
||||
* @param context 上下文
|
||||
* @param audioUri 音频的Uri
|
||||
*/
|
||||
public static void playAudio(Context context, Uri audioUri) {
|
||||
if (mediaPlayer != null && mediaPlayer.isPlaying()) {
|
||||
mediaPlayer.stop();
|
||||
mediaPlayer.release();
|
||||
mediaPlayer = null;
|
||||
}
|
||||
|
||||
try {
|
||||
mediaPlayer = new MediaPlayer();
|
||||
mediaPlayer.setDataSource(context, audioUri);
|
||||
mediaPlayer.prepare();
|
||||
mediaPlayer.start();
|
||||
|
||||
mediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
|
||||
@Override
|
||||
public void onCompletion(MediaPlayer mp) {
|
||||
releaseMediaPlayer();
|
||||
}
|
||||
});
|
||||
|
||||
mediaPlayer.setOnErrorListener(new MediaPlayer.OnErrorListener() {
|
||||
@Override
|
||||
public boolean onError(MediaPlayer mp, int what, int extra) {
|
||||
Log.e("AudioPlayer", "播放音频时出错: what=" + what + ", extra=" + extra);
|
||||
releaseMediaPlayer();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
releaseMediaPlayer();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 释放MediaPlayer资源
|
||||
*/
|
||||
private static void releaseMediaPlayer() {
|
||||
if (mediaPlayer != null) {
|
||||
mediaPlayer.stop();
|
||||
mediaPlayer.release();
|
||||
mediaPlayer = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package cc.winboll.studio.timestamp.utils;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen
|
||||
* @Date 2025/05/06 10:53
|
||||
* @Describe 剪贴板工具集
|
||||
*/
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
|
||||
public class ClipboardUtil {
|
||||
public static final String TAG = "ClipboardUtil";
|
||||
|
||||
private static final long COPY_DELAY = 500; // 延迟 500 毫秒
|
||||
private static Handler handler = new Handler();
|
||||
|
||||
/**
|
||||
* 拷贝文本到剪贴板
|
||||
* @param context 上下文
|
||||
* @param text 要拷贝的文本
|
||||
*/
|
||||
public static void copyTextToClipboard(final Context context, final String text) {
|
||||
handler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ClipboardManager clipboardManager = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
if (clipboardManager != null) {
|
||||
ClipData clipData = ClipData.newPlainText("label", text);
|
||||
clipboardManager.setPrimaryClip(clipData);
|
||||
}
|
||||
}
|
||||
}, COPY_DELAY);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package cc.winboll.studio.timestamp.utils;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen
|
||||
* @Date 2025/05/05 09:52
|
||||
* @Describe 文件管理工具类
|
||||
*/
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
public class FileUtil {
|
||||
|
||||
public static final String TAG = "FileUtil";
|
||||
|
||||
//
|
||||
// 把字符串写入文件,指定 UTF-8 编码
|
||||
//
|
||||
public static void writeFile(String filePath, String content) throws IOException {
|
||||
File file = new File(filePath);
|
||||
FileOutputStream outputStream = new FileOutputStream(file);
|
||||
OutputStreamWriter writer = new OutputStreamWriter(outputStream, StandardCharsets.UTF_8);
|
||||
writer.write(content);
|
||||
writer.close();
|
||||
}
|
||||
|
||||
//
|
||||
// 读取文件到字符串,指定 UTF-8 编码
|
||||
//
|
||||
public static String readFile(String filePath) throws IOException {
|
||||
File file = new File(filePath);
|
||||
FileInputStream inputStream = new FileInputStream(file);
|
||||
InputStreamReader reader = new InputStreamReader(inputStream, StandardCharsets.UTF_8);
|
||||
StringBuilder content = new StringBuilder();
|
||||
int character;
|
||||
while ((character = reader.read()) != -1) {
|
||||
content.append((char) character);
|
||||
}
|
||||
reader.close();
|
||||
return content.toString();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,200 @@
|
||||
package cc.winboll.studio.timestamp.utils;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen
|
||||
* @Date 2025/05/05 10:36
|
||||
* @Describe 应用通知工具类
|
||||
*/
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Color;
|
||||
import android.media.RingtoneManager;
|
||||
import android.net.Uri;
|
||||
import android.widget.RemoteViews;
|
||||
import cc.winboll.studio.timestamp.App;
|
||||
import cc.winboll.studio.timestamp.MainActivity;
|
||||
import cc.winboll.studio.timestamp.MainService;
|
||||
import cc.winboll.studio.timestamp.R;
|
||||
import cc.winboll.studio.timestamp.receivers.ButtonClickReceiver;
|
||||
|
||||
public class NotificationHelper {
|
||||
|
||||
public static final String TAG = "NotificationUtil";
|
||||
public static final int ID_MSG_SERVICE = 10000;
|
||||
|
||||
static final String szSMSChannelID = "1";
|
||||
|
||||
static final String szServiceChannelID = "0";
|
||||
|
||||
|
||||
//static int mNumSendForegroundNotification = 10000;
|
||||
//static int mNumSendSMSNotification = 20000;
|
||||
Context mContext;
|
||||
|
||||
|
||||
public NotificationManager createServiceNotificationChannel(Context context) {
|
||||
mContext = context;
|
||||
//创建通知渠道ID
|
||||
String channelId = szServiceChannelID;
|
||||
//创建通知渠道名称
|
||||
String channelName = "Service Message";
|
||||
//创建通知渠道重要性
|
||||
int importance = NotificationManager.IMPORTANCE_MIN;
|
||||
NotificationChannel channel = new NotificationChannel(channelId, channelName, importance);
|
||||
channel.setSound(null, null);
|
||||
NotificationManager notificationManager = (NotificationManager) context.getSystemService(
|
||||
Context.NOTIFICATION_SERVICE);
|
||||
notificationManager.createNotificationChannel(channel);
|
||||
return notificationManager;
|
||||
}
|
||||
|
||||
public NotificationManager createSMSNotificationChannel(Context context) {
|
||||
//创建通知渠道ID
|
||||
String channelId = szSMSChannelID;
|
||||
//创建通知渠道名称
|
||||
String channelName = "SMS Message";
|
||||
//创建通知渠道重要性
|
||||
int importance = NotificationManager.IMPORTANCE_HIGH;
|
||||
NotificationChannel channel = new NotificationChannel(channelId, channelName, importance);
|
||||
channel.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE), Notification.AUDIO_ATTRIBUTES_DEFAULT);
|
||||
NotificationManager notificationManager = (NotificationManager) context.getSystemService(
|
||||
Context.NOTIFICATION_SERVICE);
|
||||
notificationManager.createNotificationChannel(channel);
|
||||
return notificationManager;
|
||||
}
|
||||
|
||||
// 创建通知
|
||||
//
|
||||
public void sendForegroundNotification(MainService service, String message) {
|
||||
//创建Notification,传入Context和channelId
|
||||
Intent intent = new Intent();//这个intent会传给目标,可以使用getIntent来获取
|
||||
intent.setClass(mContext, MainActivity.class);
|
||||
|
||||
//这里放一个count用来区分每一个通知
|
||||
//intent.putExtra("intent", "intent--->" + count);//这里设置一个数据,带过去
|
||||
|
||||
//参数1:context 上下文对象
|
||||
//参数2:发送者私有的请求码(Private request code for the sender)
|
||||
//参数3:intent 意图对象
|
||||
//参数4:必须为FLAG_ONE_SHOT,FLAG_NO_CREATE,FLAG_CANCEL_CURRENT,FLAG_UPDATE_CURRENT,中的一个
|
||||
PendingIntent mForegroundPendingIntent = PendingIntent.getActivity(service, ID_MSG_SERVICE, intent, PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_CANCEL_CURRENT);
|
||||
|
||||
Notification mForegroundNotification = new Notification.Builder(service, szServiceChannelID)
|
||||
.setAutoCancel(true)
|
||||
//.setContentTitle(nessageNotificationBean.getTitle())
|
||||
//.setContentText(nessageNotificationBean.getContent())
|
||||
//.setContent(remoteviews)
|
||||
.setWhen(System.currentTimeMillis())
|
||||
.setSmallIcon(App.getAPPIcon())
|
||||
//设置红色
|
||||
.setColor(Color.parseColor("#F00606"))
|
||||
.setLargeIcon(BitmapFactory.decodeResource(service.getResources(), App.getAPPIcon()))
|
||||
.setContentIntent(mForegroundPendingIntent)
|
||||
.build();
|
||||
|
||||
// 创建 RemoteViews 对象,加载布局
|
||||
RemoteViews remoteViews = new RemoteViews(mContext.getPackageName(), R.layout.custom_notification_layout);
|
||||
|
||||
// 自定义 TextView 的文本
|
||||
remoteViews.setTextViewText(R.id.tv_timestamp, message);
|
||||
// 自定义 TextView 的文本颜色
|
||||
remoteViews.setTextColor(R.id.tv_timestamp, mContext.getResources().getColor(R.color.colorAccent, null));
|
||||
// 这里虽然不能直接设置字体大小,但可以通过反射等方式尝试(不推荐,且有兼容性问题)
|
||||
|
||||
// 设置按钮图片
|
||||
remoteViews.setImageViewResource(R.id.iv_copytimestamp, App.getAPPIcon());
|
||||
// 创建点击通知后的意图
|
||||
Intent intentMain = new Intent(mContext, MainActivity.class);
|
||||
PendingIntent pendingMainIntent = PendingIntent.getActivity(mContext, 0, intentMain, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
// 设置通知的点击事件
|
||||
remoteViews.setOnClickPendingIntent(R.id.tv_timestamp, pendingMainIntent);
|
||||
|
||||
// 创建点击按钮后要发送的广播 Intent
|
||||
Intent broadcastIntent = new Intent(ButtonClickReceiver.BUTTON_COPYTIMESTAMP_ACTION);
|
||||
android.app.PendingIntent pendingIntent = android.app.PendingIntent.getBroadcast(
|
||||
mContext,
|
||||
0,
|
||||
broadcastIntent,
|
||||
android.app.PendingIntent.FLAG_UPDATE_CURRENT
|
||||
);
|
||||
|
||||
// 为按钮设置点击事件
|
||||
remoteViews.setOnClickPendingIntent(R.id.iv_copytimestamp, pendingIntent);
|
||||
|
||||
mForegroundNotification.contentView = remoteViews;
|
||||
mForegroundNotification.bigContentView = remoteViews;
|
||||
|
||||
service.startForeground(ID_MSG_SERVICE, mForegroundNotification);
|
||||
|
||||
TimeStampUtil.getInstance(service).playNotifyMusic(service);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// public void sendSMSNotification(Context context, MessageNotificationBean messageNotificationBean) {
|
||||
// NotificationManager notificationManager = (NotificationManager) context.getSystemService(
|
||||
// Context.NOTIFICATION_SERVICE);
|
||||
// /*NotificationManager notificationManager = createSMSNotificationChannel(context);
|
||||
// if (notificationManager == null) {
|
||||
// LogUtils.d(TAG, "createSMSNotificationChannel failed.");
|
||||
// return;
|
||||
// }*/
|
||||
//
|
||||
// //创建Notification,传入Context和channelId
|
||||
// Intent intent = new Intent(context, SMSActivity.class);
|
||||
// intent.putExtra(SMSActivity.EXTRA_PHONE, messageNotificationBean.getPhone());
|
||||
// LogUtils.d(TAG, "sendSMSNotification(...) message.getPhone() is : " + messageNotificationBean.getPhone());
|
||||
// //Intent intent = new Intent();//这个intent会传给目标,可以使用getIntent来获取
|
||||
// //intent.setClass(context, MainActivity.class);
|
||||
// //这里放一个count用来区分每一个通知
|
||||
// //intent.putExtra("intent", "intent--->" + count);//这里设置一个数据,带过去
|
||||
//
|
||||
// //参数1:context 上下文对象
|
||||
// //参数2:发送者私有的请求码(Private request code for the sender)
|
||||
// //参数3:intent 意图对象
|
||||
// //参数4:必须为FLAG_ONE_SHOT,FLAG_NO_CREATE,FLAG_CANCEL_CURRENT,FLAG_UPDATE_CURRENT,中的一个
|
||||
// PendingIntent mRemindPendingIntent = PendingIntent.getActivity(context, messageNotificationBean.getMessageId(), intent, PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_CANCEL_CURRENT);
|
||||
// Notification mSMSNotification = new Notification.Builder(context, szSMSChannelID)
|
||||
// .setAutoCancel(true)
|
||||
// .setContentTitle(messageNotificationBean.getTitle())
|
||||
// .setContentText(messageNotificationBean.getContent())
|
||||
// .setWhen(System.currentTimeMillis())
|
||||
// .setSmallIcon(R.drawable.ic_launcher)
|
||||
// //设置红色
|
||||
// .setColor(Color.parseColor("#F00606"))
|
||||
// .setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_launcher))
|
||||
// .setContentIntent(mRemindPendingIntent)
|
||||
// .build();
|
||||
//
|
||||
// RemoteViews mrvSMSNotificationView = new RemoteViews(context.getPackageName(), R.layout.remoteview);
|
||||
// mrvSMSNotificationView.setTextViewText(R.id.remoteviewTextView1, messageNotificationBean.getTitle());
|
||||
// mrvSMSNotificationView.setTextViewText(R.id.remoteviewTextView2, messageNotificationBean.getContent());
|
||||
// mrvSMSNotificationView.setImageViewResource(R.id.remoteviewImageView1, R.drawable.ic_launcher);
|
||||
// mSMSNotification.contentView = mrvSMSNotificationView;
|
||||
// mSMSNotification.bigContentView = mrvSMSNotificationView;
|
||||
// notificationManager.notify(messageNotificationBean.getMessageId(), mSMSNotification);
|
||||
// LogUtils.d(TAG, "getMessageId is : " + Integer.toString(messageNotificationBean.getMessageId()));
|
||||
//
|
||||
// }
|
||||
|
||||
// public void sendSMSReceivedMessage(Context context, int nMessageId, String szPhone, String szBody) {
|
||||
// String szTitle = context.getString(R.string.text_smsfrom) + "<" + szPhone + ">";
|
||||
// String szContent = "[ " + szBody + " ]";
|
||||
// sendSMSNotification(context, new MessageNotificationBean(nMessageId, szPhone, szTitle, szContent));
|
||||
// }
|
||||
|
||||
// public static void cancelNotification(Context context, int notificationId) {
|
||||
// // 获取 NotificationManager 实例
|
||||
// NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
// // 撤回指定 ID 的通知栏消息
|
||||
// notificationManager.cancel(notificationId);
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package cc.winboll.studio.timestamp.utils;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen
|
||||
* @Date 2025/05/05 09:58
|
||||
* @Describe 应用服务管理类
|
||||
*/
|
||||
import android.app.ActivityManager;
|
||||
import android.content.Context;
|
||||
import java.util.List;
|
||||
|
||||
public class ServiceUtil {
|
||||
|
||||
public final static String TAG = "ServiceUtil";
|
||||
|
||||
public static boolean isServiceAlive(Context context, String szServiceName) {
|
||||
// 获取Activity管理者对象
|
||||
ActivityManager manager = (ActivityManager) context
|
||||
.getSystemService(Context.ACTIVITY_SERVICE);
|
||||
// 获取正在运行的服务(此处设置最多取1000个)
|
||||
List<ActivityManager.RunningServiceInfo> runningServices = manager
|
||||
.getRunningServices(1000);
|
||||
if (runningServices.size() <= 0) {
|
||||
return false;
|
||||
}
|
||||
// 遍历,若存在名字和传入的serviceName的一致则说明存在
|
||||
for (ActivityManager.RunningServiceInfo runningServiceInfo : runningServices) {
|
||||
if (runningServiceInfo.service.getClassName().equals(szServiceName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package cc.winboll.studio.timestamp.utils;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen
|
||||
* @Date 2025/05/07 11:03
|
||||
* @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;
|
||||
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;
|
||||
mTimeStamp = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// 播放时间戳确定时的提示音乐
|
||||
//
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package cc.winboll.studio.timestamp.views;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen
|
||||
* @Date 2025/05/05 12:53
|
||||
* @Describe TimeStampView
|
||||
*/
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
|
||||
public class TimeStampView extends View {
|
||||
|
||||
public static final String TAG = "TimeStampView";
|
||||
|
||||
public static final int MSG_UPDATE_TIMESTAMP = 0;
|
||||
|
||||
//private Paint circlePaint;
|
||||
//private Paint textPaint;
|
||||
|
||||
// Context mContext;
|
||||
// Timer mTimer;
|
||||
// TextView mtvTimeStamp;
|
||||
// MyHandler mMyHandler;
|
||||
public TimeStampView(Context context) {
|
||||
super(context);
|
||||
//initView(context);
|
||||
init();
|
||||
}
|
||||
|
||||
public TimeStampView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
//initView(context);
|
||||
init();
|
||||
}
|
||||
|
||||
public TimeStampView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
//initView(context);
|
||||
init();
|
||||
}
|
||||
|
||||
public TimeStampView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
//initView(context);
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
// circlePaint = new Paint();
|
||||
// circlePaint.setColor(Color.BLUE);
|
||||
// circlePaint.setStyle(Paint.Style.FILL);
|
||||
//
|
||||
// textPaint = new Paint();
|
||||
// textPaint.setColor(Color.WHITE);
|
||||
// textPaint.setTextSize(40);
|
||||
// textPaint.setTextAlign(Paint.Align.CENTER);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
super.onDraw(canvas);
|
||||
//int width = getWidth();
|
||||
//int height = getHeight();
|
||||
// int width = 50;
|
||||
// int height = 50;
|
||||
// float radius = Math.min(width, height) / 2;
|
||||
// canvas.drawCircle(width / 2, height / 2, radius, circlePaint);
|
||||
// String text = "自定义";
|
||||
// RectF rect = new RectF(0, 0, width, height);
|
||||
// Paint.FontMetricsInt fontMetrics = textPaint.getFontMetricsInt();
|
||||
// int baseline =(int)((rect.bottom + rect.top - fontMetrics.bottom - fontMetrics.top) / 2);
|
||||
// canvas.drawText(text, width / 2, baseline, textPaint);
|
||||
}
|
||||
|
||||
// void initView(Context context) {
|
||||
// View viewMain = inflate(context, R.layout.view_timestamp, null);
|
||||
// this.mContext = context;
|
||||
// mtvTimeStamp = viewMain.findViewById(R.id.tv_timestamp);
|
||||
// addView(viewMain);
|
||||
//
|
||||
// mMyHandler = new MyHandler();
|
||||
//
|
||||
|
||||
// }
|
||||
|
||||
// public void updateTimeStamp() {
|
||||
// try {
|
||||
//
|
||||
// } catch (Exception e) {
|
||||
// LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
|
||||
// ToastUtils.show(e);
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
}
|
||||
170
timestamp/src/main/res/drawable/ic_launcher_background.xml
Normal file
170
timestamp/src/main/res/drawable/ic_launcher_background.xml
Normal file
@@ -0,0 +1,170 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportHeight="108"
|
||||
android:viewportWidth="108">
|
||||
<path
|
||||
android:fillColor="#26A69A"
|
||||
android:pathData="M0,0h108v108h-108z" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M9,0L9,108"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,0L19,108"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,0L29,108"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,0L39,108"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,0L49,108"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,0L59,108"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,0L69,108"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,0L79,108"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M89,0L89,108"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M99,0L99,108"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,9L108,9"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,19L108,19"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,29L108,29"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,39L108,39"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,49L108,49"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,59L108,59"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,69L108,69"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,79L108,79"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,89L108,89"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,99L108,99"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,29L89,29"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,39L89,39"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,49L89,49"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,59L89,59"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,69L89,69"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,79L89,79"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,19L29,89"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,19L39,89"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,19L49,89"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,19L59,89"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,19L69,89"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,19L79,89"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
</vector>
|
||||
15
timestamp/src/main/res/drawable/ic_launcher_beta.xml
Normal file
15
timestamp/src/main/res/drawable/ic_launcher_beta.xml
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item
|
||||
android:left="1dp"
|
||||
android:top="1dp"
|
||||
android:right="1dp"
|
||||
android:bottom="1dp"
|
||||
android:drawable="@drawable/ic_launcher_background"/>
|
||||
<item
|
||||
android:left="1dp"
|
||||
android:top="1dp"
|
||||
android:right="1dp"
|
||||
android:bottom="1dp"
|
||||
android:drawable="@drawable/ic_timestamp"/>
|
||||
</layer-list>
|
||||
10
timestamp/src/main/res/drawable/ic_launcher_stage.xml
Normal file
10
timestamp/src/main/res/drawable/ic_launcher_stage.xml
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<!--<item android:drawable="@drawable/ic_launcher_background"/>-->
|
||||
<item
|
||||
android:left="1dp"
|
||||
android:top="1dp"
|
||||
android:right="1dp"
|
||||
android:bottom="1dp"
|
||||
android:drawable="@drawable/ic_timestamp"/>
|
||||
</layer-list>
|
||||
BIN
timestamp/src/main/res/drawable/ic_timestamp.png
Normal file
BIN
timestamp/src/main/res/drawable/ic_timestamp.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 10 KiB |
180
timestamp/src/main/res/layout/activity_main.xml
Normal file
180
timestamp/src/main/res/layout/activity_main.xml
Normal file
@@ -0,0 +1,180 @@
|
||||
<?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"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="10dp">
|
||||
|
||||
<Switch
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="启用时间戳常驻通知栏"
|
||||
android:id="@+id/activitymainSwitch1"
|
||||
android:onClick="onSetMainServiceStatus"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Show Format Preview:"
|
||||
android:paddingRight="10dp"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Text"
|
||||
android:id="@+id/tv_timestampformatstring"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="10dp">
|
||||
|
||||
<EditText
|
||||
android:layout_width="0dp"
|
||||
android:ems="10"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/et_timestampformatstring"
|
||||
android:layout_weight="1.0"/>
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="ApplyShow"
|
||||
android:id="@+id/btn_saveformatstring"
|
||||
android:textAllCaps="false"
|
||||
android:onClick="onSaveFormatString"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Copy Format Preview:"
|
||||
android:paddingRight="10dp"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Text"
|
||||
android:id="@+id/tv_timestampcopyformatstring"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="10dp">
|
||||
|
||||
<EditText
|
||||
android:layout_width="0dp"
|
||||
android:ems="10"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/et_timestampcopyformatstring"
|
||||
android:layout_weight="1.0"/>
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="ApplyCopy"
|
||||
android:id="@+id/btn_savecopyformatstring"
|
||||
android:textAllCaps="false"
|
||||
android:onClick="onSaveCopyFormatString"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
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="wrap_content"
|
||||
android:gravity="center_vertical|center_horizontal">
|
||||
|
||||
<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>
|
||||
|
||||
25
timestamp/src/main/res/layout/custom_notification_layout.xml
Normal file
25
timestamp/src/main/res/layout/custom_notification_layout.xml
Normal file
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal"
|
||||
android:padding="16dp"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_timestamp"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Text"
|
||||
android:textColor="#000000"
|
||||
android:textSize="14sp"
|
||||
android:layout_weight="1.0"/>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:id="@+id/iv_copytimestamp"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
BIN
timestamp/src/main/res/raw/diweiyi.mp3
Normal file
BIN
timestamp/src/main/res/raw/diweiyi.mp3
Normal file
Binary file not shown.
6
timestamp/src/main/res/values/colors.xml
Normal file
6
timestamp/src/main/res/values/colors.xml
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="colorPrimary">#009688</color>
|
||||
<color name="colorPrimaryDark">#00796B</color>
|
||||
<color name="colorAccent">#FF9800</color>
|
||||
</resources>
|
||||
5
timestamp/src/main/res/values/strings.xml
Normal file
5
timestamp/src/main/res/values/strings.xml
Normal file
@@ -0,0 +1,5 @@
|
||||
<resources>
|
||||
<string name="app_name">TimeStamp</string>
|
||||
<string name="text_aboutservernotification">This is the prompt window when the SMS service runs, which you can set to hide this class notification in the notification message settings.</string>
|
||||
<string name="accessibility_service_description">Accessibility service description.</string>
|
||||
</resources>
|
||||
11
timestamp/src/main/res/values/styles.xml
Normal file
11
timestamp/src/main/res/values/styles.xml
Normal file
@@ -0,0 +1,11 @@
|
||||
<resources>
|
||||
|
||||
<!-- Base application theme. -->
|
||||
<style name="MyAppTheme" parent="Theme.AppCompat.Light.NoActionBar">
|
||||
<!-- Customize your theme here. -->
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
15
timestamp/src/stage/AndroidManifest.xml
Normal file
15
timestamp/src/stage/AndroidManifest.xml
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools" >
|
||||
|
||||
<application
|
||||
tools:replace="android:icon,android:roundIcon"
|
||||
android:icon="@drawable/ic_launcher_stage"
|
||||
android:roundIcon="@drawable/ic_launcher_stage">
|
||||
|
||||
<!-- Put flavor specific code here -->
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
|
||||
6
timestamp/src/stage/res/values/strings.xml
Normal file
6
timestamp/src/stage/res/values/strings.xml
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<!-- Put flavor specific strings here -->
|
||||
|
||||
</resources>
|
||||
Reference in New Issue
Block a user