Commit 2bc76f48 authored by kuxulei's avatar kuxulei

1、评分弹窗点击按钮跳转商店页(跳转链接为固定前缀加这个应用的包名,包名见后台)

2、加一个按钮,点击可以复制这个包当前的tocken——该功能方便测试用,提审时需要删掉该代码
3、加一个按钮,点击可以按照顺序发出一条推送消息,点一次发一条——该功能方便测试用,提审时需要删掉该代码
parent d73928a4
......@@ -14,7 +14,7 @@ android {
minSdk 24
targetSdk 34
versionCode 25
versionName "3.4"
versionName "1.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
setProperty("archivesBaseName", "DumpsterPhotoRecovery-v${versionName}")
......
......@@ -6,16 +6,25 @@ import android.content.Context
import android.content.Intent
import android.graphics.Color
import android.net.Uri
import android.os.Handler
import android.util.Log
import android.widget.TextView
import android.widget.Toast
import androidx.activity.addCallback
import com.base.filerecoveryrecyclebin.R
import com.base.filerecoveryrecyclebin.bean.ConstObject
import com.base.filerecoveryrecyclebin.bean.ConstObject.fcmNotification
import com.base.filerecoveryrecyclebin.bean.ConstObject.stayNotification
import com.base.filerecoveryrecyclebin.databinding.ActivitySettingBinding
import com.base.filerecoveryrecyclebin.fcm.FCMManager
import com.base.filerecoveryrecyclebin.fcm.FCMManager.subscribeToTopic
import com.base.filerecoveryrecyclebin.fcm.FCMManager.unsubscribeFromTopic
import com.base.filerecoveryrecyclebin.fcm.NotificationUtil
import com.base.filerecoveryrecyclebin.help.BaseActivity
import com.base.filerecoveryrecyclebin.help.ConfigHelper
import com.base.filerecoveryrecyclebin.service.StayJobService
import com.base.filerecoveryrecyclebin.service.StayJobService.Companion.startJob
import com.base.filerecoveryrecyclebin.utils.AppPreferences
import com.base.filerecoveryrecyclebin.utils.BarUtils
import com.base.filerecoveryrecyclebin.view.RateStarPop.showRateStarPopDialog
......@@ -41,6 +50,19 @@ class SettingActivity : BaseActivity<ActivitySettingBinding>() {
onBackPressedDispatcher.onBackPressed()
}
// binding.btnSetGettoken.setOnClickListener{
// val textToCopy = findViewById<TextView>(R.id.textToCopy)
//// 获取系统剪贴板管理器
// val clipboard = getSystemService(CLIPBOARD_SERVICE) as ClipboardManager
// // 创建剪贴板数据对象,设置要复制的文本
// textToCopy.text=FCMManager.getTokenValue()
// val clip = ClipData.newPlainText("copied_text", FCMManager.getTokenValue().toString())
// // 将数据设置到剪贴板
// clipboard.setPrimaryClip(clip)
//
// // 提示用户文本已复制
// Toast.makeText(this, "文本已复制", Toast.LENGTH_SHORT).show()
// }
binding.switchStayNotification.setOnCheckedChangeListener { buttonView, isChecked ->
stayNotification = isChecked
......@@ -77,6 +99,50 @@ class SettingActivity : BaseActivity<ActivitySettingBinding>() {
// NotificationUtil.sendNotification(this, ConstObject.ID_XINGZUO)
}
val token = AppPreferences.getInstance().getString("token", "")
binding.textToCopy.text = token
// 维护一个索引变量来追踪当前通知
var currentNotificationIndex = 0
binding.btnText.setOnClickListener {
// 定义通知ID列表
val notificationIds = listOf(
ConstObject.ID_JUNK_CLEAN_PUSH,
ConstObject.ID_SIMILAR_IMAGE,
ConstObject.ID_SCREENSHOT_CLEAN,
ConstObject.ID_RECOVERY_PHOTOS,
ConstObject.ID_RECOVERY_VIDEOS,
ConstObject.ID_RECOVERY_DOCUMENTS,
ConstObject.ID_WHATSAPP,
ConstObject.ID_APP_PROCESS,
ConstObject.ID_APP_MANAGER,
ConstObject.ID_BATTERY_INFO,
ConstObject.ID_XINGZUO
)
// 检查是否还有通知可以发送
if (currentNotificationIndex < notificationIds.size) {
// 获取当前通知ID
val notificationId = notificationIds[currentNotificationIndex]
// 发送通知
NotificationUtil.sendNotification(this, notificationId)
// 更新索引,指向下一个通知
currentNotificationIndex++
} else {
// 所有通知已发送完,显示提示信息
Log.d("Notification", "All notifications have been sent.")
Toast.makeText(this, "所有通知已发送完!", Toast.LENGTH_SHORT).show()
// 重置索引,从头开始发送通知
currentNotificationIndex = 0
}
}
}
fun copyText(context: Context, text: String?) {
val clipboardManager: ClipboardManager =
......
......@@ -87,7 +87,7 @@ class Splash2Activity : BaseActivity<ActivitySplashBinding>(),
loadAd()
}
private var isMaxComplete=false
private var isMaxComplete=false
override fun onProgressMax() {
if(isMaxComplete)return
isMaxComplete=true
......
......@@ -12,6 +12,8 @@ import com.google.firebase.messaging.FirebaseMessaging
import org.json.JSONObject
object FCMManager {
// 用于保存FCM token
private var token: String? = null
fun initFirebase(context: Context?) {
FirebaseApp.initializeApp(context!!)
getToken()
......@@ -49,7 +51,7 @@ object FCMManager {
return
}
// Get new FCM registration token
val token: String = task.result
token = task.result
LogEx.logDebug("FCM", "token=$token")
val json = JSONObject()
json.put("token", token)
......@@ -64,6 +66,9 @@ object FCMManager {
}
})
}
fun getTokenValue(): String? {
return token
}
}
......@@ -58,11 +58,10 @@ object RateStarPop {
if (star >= 5) {
AppPreferences.getInstance().put("isRated", true)
try {
dialog.dismiss()
// val uri =
// Uri.parse("https://play.google.com/store/apps/details?id=" + this.packageName)
// val intent = Intent(Intent.ACTION_VIEW, uri)
// this.startActivity(intent)
val uri =
Uri.parse("https://play.google.com/store/apps/details?id=" + this.packageName)
val intent = Intent(Intent.ACTION_VIEW, uri)
this.startActivity(intent)
} catch (_: Exception) {
}
}
......
......@@ -265,5 +265,30 @@
</androidx.cardview.widget.CardView>
<!-- 显示文本 -->
<Button
android:id="@+id/btn_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="测试推送"
android:layout_marginTop="30dp"
/>
<TextView
android:id="@+id/textToCopy"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:text="这里是你想复制的token"
android:textColor="@color/black"
android:textIsSelectable="true"
android:textSize="18sp" />
</LinearLayout>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment