Skip to content

Commit

Permalink
Merge pull request #11 from aquamarine5/1.3-dev
Browse files Browse the repository at this point in the history
UDCA included to collect UsageData, +Bugly to trace
  • Loading branch information
aquamarine5 authored May 2, 2024
2 parents 740ffdc + 84923e8 commit 28b7ab1
Show file tree
Hide file tree
Showing 37 changed files with 698 additions and 163 deletions.
2 changes: 2 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
# OnceShot
# OnceShot
## OnceShot 是什么?
- OnceShot 是作者高二的创意,因为自己的截图太多(达到了2000张),很多截图分享给别人用一次也就用不上了,但是有些截图想保留着,就打算做个分类App,把一次性的截图分享给别人之后就删除,这样自己的截图文件夹就只有想要一直留存的图片了
- OnceShot 的最新版本是v1.3.0.0(2024/05/02),更多内容可以看[Releases](https://github.com/aquamarine5/OnceShot/releases)的Changelog
### Examples
- 听到了一首好好听的歌,截图分享给别人,这时候点击**分享后删除**,不占用手机空间
- 打游戏的时候碰到了有意思的事,截图分享给别人,这时候点击**关闭**,永远留存下来 ![Screenshot_20240501_162000.jpg](https://s2.loli.net/2024/05/01/yDLkRTlMxgw6HC9.jpg)
- 买东西的时候商家邀请截图发给客服,但是没办法直接通过分享渠道发过去,这时候点击**等等我...**,确定发送成功之后再删除
- 截图的时候发现截错了,这时候点击**直接删除**,就不用担心一会发送截图的时候会发错啦
## 如何使用?
- 先下载([点我跳转到最新版本的Release](https://github.com/aquamarine5/OnceShot/releases/latest)),在Assets里面找到`app-release.apk`(或者是`app-debug.apk`)下载安装
- 第一次打开 OnceShot 时,服务并不会启动,把权限全部授予给 OnceShot 后,服务即可正常启动
- 完成了上面两步,现在截个图,如果出现了 OnceShot 的操作面板悬浮窗,说明设置成功🎉
1 change: 1 addition & 0 deletions announcement/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
44 changes: 44 additions & 0 deletions announcement/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
plugins {
id 'com.android.library'
id 'org.jetbrains.kotlin.android'
}

android {
namespace 'org.aquarngd.announcement'
compileSdk 34

defaultConfig {
minSdk 24

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures{
buildConfig=true
}
}

dependencies {

implementation 'androidx.core:core-ktx:1.13.0'
implementation platform('org.jetbrains.kotlin:kotlin-bom:1.8.0')
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.11.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}
Empty file added announcement/consumer-rules.pro
Empty file.
21 changes: 21 additions & 0 deletions announcement/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions announcement/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package org.aquarngd.announcement

class AnnouncementService {
}
19 changes: 11 additions & 8 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ android {
applicationId "org.aquarngd.onceshot"
minSdk 24
targetSdk 34
versionCode 1010000
versionName "1.1.0.0"
versionCode 1030000
versionName "1.3.0.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand All @@ -35,6 +35,7 @@ android {
}
buildFeatures {
compose true
buildConfig true
}
composeOptions {
kotlinCompilerExtensionVersion '1.3.2'
Expand All @@ -47,28 +48,30 @@ android {
}

dependencies {
implementation 'com.tencent.bugly:crashreport:latest.release'
implementation "com.squareup.okhttp3:okhttp:4.11.0"
implementation 'com.squareup.okio:okio:3.2.0'
implementation 'androidx.core:core-ktx:1.12.0'
implementation 'androidx.core:core-ktx:1.13.0'
implementation platform('org.jetbrains.kotlin:kotlin-bom:1.8.0')
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.7.0'
implementation 'androidx.activity:activity-compose:1.8.2'
implementation 'androidx.activity:activity-compose:1.9.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation platform('androidx.compose:compose-bom:2023.08.00')
implementation 'androidx.compose.ui:ui:1.6.1'
implementation 'androidx.compose.ui:ui:1.6.6'
implementation 'androidx.compose.ui:ui-graphics'
implementation 'androidx.compose.ui:ui-tooling-preview'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.compose.material3:material3:1.2.0'
implementation 'androidx.core:core-ktx:1.12.0'
implementation 'androidx.compose.material3:material3:1.2.1'
implementation 'androidx.core:core-ktx:1.13.0'
implementation 'com.google.android.material:material:1.11.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation project(path: ':stackbricks')
implementation project(path: ':udca')
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
androidTestImplementation platform('androidx.compose:compose-bom:2023.08.00')
androidTestImplementation 'androidx.compose.ui:ui-test-junit4'
debugImplementation 'androidx.compose.ui:ui-tooling'
debugImplementation 'androidx.compose.ui:ui-test-manifest:1.6.1'
debugImplementation 'androidx.compose.ui:ui-test-manifest:1.6.6'
}
5 changes: 4 additions & 1 deletion app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,7 @@

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
#-renamesourcefileattribute SourceFile

-dontwarn com.tencent.bugly.**
-keep public class com.tencent.bugly.**{*;}
20 changes: 20 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission
android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
tools:ignore="ScopedStorage" />
Expand Down Expand Up @@ -55,11 +56,30 @@
android:exported="false"
android:label="ForegroundService"
android:launchMode="singleTop" />
<!-- Required: set your sentry.io project identifier (DSN) -->
<meta-data android:name="io.sentry.dsn" android:value="https://ab6dc78fdf7748d540a0ccf4815de194@o4505418205364224.ingest.us.sentry.io/4506881518338048" />

<!-- enable automatic breadcrumbs for user interactions (clicks, swipes, scrolls) -->
<meta-data android:name="io.sentry.traces.user-interaction.enable" android:value="true" />
<!-- enable screenshot for crashes -->
<meta-data android:name="io.sentry.attach-screenshot" android:value="true" />
<!-- enable view hierarchy for crashes -->
<meta-data android:name="io.sentry.attach-view-hierarchy" android:value="true" />

<!-- enable the performance API by setting a sample-rate, adjust in production env -->
<meta-data android:name="io.sentry.traces.sample-rate" android:value="1.0" />
<!-- enable profiling when starting transactions, adjust in production env -->
<meta-data android:name="io.sentry.traces.profiling.sample-rate" android:value="1.0" />
<!-- 配置APP ID -->
<meta-data
android:name="BUGLY_APPID"
android:value="2d98a3477d" />
</application>
<queries>
<intent>
<action android:name="android.intent.action.SEND" />
<data android:mimeType="image/*" />
</intent>
</queries>

</manifest>
9 changes: 9 additions & 0 deletions app/src/main/java/org/aquarngd/onceshot/AnalysisDataClass.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.aquarngd.onceshot

import org.aquarngd.udca.UsageDataKey

data class AnalysisDataClass(
var key: UsageDataKey,
var str:String,
var value:Int
)
17 changes: 17 additions & 0 deletions app/src/main/java/org/aquarngd/onceshot/AnalysisDataKey.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.aquarngd.onceshot

import org.aquarngd.udca.UsageDataKey

class AnalysisDataKey {
companion object{
val SCREENSHOT_COUNT=UsageDataKey("sc")
val CLICK_DELETE_DIRECTLY=UsageDataKey("cd", listOf(SCREENSHOT_COUNT))
val CLICK_CLOSE=UsageDataKey("cc", listOf(SCREENSHOT_COUNT))
val TIMEOUT_CLOSE=UsageDataKey("tc", listOf(SCREENSHOT_COUNT))
val CLICK_WAITING=UsageDataKey("cw", listOf(SCREENSHOT_COUNT))
val CLICK_WAITING_DELETE=UsageDataKey("cwd", listOf(CLICK_WAITING))
val CLICK_WAITING_IGNORE=UsageDataKey("cwi", listOf(CLICK_WAITING))
val CLICK_DELETE_AFTER_SHARE=UsageDataKey("ca", listOf(SCREENSHOT_COUNT))
val SETTING_DURATION="d"
}
}
60 changes: 60 additions & 0 deletions app/src/main/java/org/aquarngd/onceshot/AnalysisService.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package org.aquarngd.onceshot

import android.content.Context
import android.content.SharedPreferences
import com.tencent.bugly.crashreport.CrashReport
import org.aquarngd.udca.BuglyUsageDataAnalyser
import java.time.Instant
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter

class AnalysisService {
companion object{
const val SETTING_DURATION="sd"
const val LAST_UPLOAD_TIME="last_upload_time"
const val UPLOAD_INTERVAL=86400000L
val UPLOAD_USAGE_VALUES= listOf(
AnalysisDataKey.SCREENSHOT_COUNT,
AnalysisDataKey.TIMEOUT_CLOSE,
AnalysisDataKey.CLICK_CLOSE,
AnalysisDataKey.CLICK_DELETE_DIRECTLY,
AnalysisDataKey.CLICK_DELETE_AFTER_SHARE,
AnalysisDataKey.CLICK_WAITING,
AnalysisDataKey.CLICK_WAITING_DELETE,
AnalysisDataKey.CLICK_WAITING_IGNORE
)
val USAGE_VALUES_STRING= mapOf(
AnalysisDataKey.SCREENSHOT_COUNT to "截图次数",
AnalysisDataKey.TIMEOUT_CLOSE to "悬浮窗自动关闭",
AnalysisDataKey.CLICK_CLOSE to "点击悬浮窗关闭",
AnalysisDataKey.CLICK_DELETE_DIRECTLY to "点击直接删除",
AnalysisDataKey.CLICK_DELETE_AFTER_SHARE to "点击分享后删除",
AnalysisDataKey.CLICK_WAITING to "点击等等我",
AnalysisDataKey.CLICK_WAITING_DELETE to "等等我后删除",
AnalysisDataKey.CLICK_WAITING_IGNORE to "等等我后保留"
)
}

fun tryUpload(context: Context){
if(checkNeedUpload(context)){
upload(context)
}
}
fun upload(context: Context){
val sb=StringBuilder()
val sp=getSharedPreferences(context)
UPLOAD_USAGE_VALUES.forEach {
sb.append("${it.key}:${sp.getInt(it.key,0)}; ")
}
sb.append("d: ${sp.getInt(AnalysisDataKey.SETTING_DURATION,30)}")
BuglyUsageDataAnalyser().upload(sb.toString())
sp.edit().putLong(LAST_UPLOAD_TIME,System.currentTimeMillis()).apply()
}
fun checkNeedUpload(context: Context): Boolean {
val time=getSharedPreferences(context).getLong(LAST_UPLOAD_TIME,0)
return System.currentTimeMillis()-time> UPLOAD_INTERVAL
}
private fun getSharedPreferences(context: Context):SharedPreferences{
return context.getSharedPreferences("UDCA_SP",Context.MODE_PRIVATE)
}
}
Loading

0 comments on commit 28b7ab1

Please sign in to comment.