Commit 8fa04feb authored by guest's avatar guest

修改bug

parent c93e3769
......@@ -269,6 +269,7 @@
<service
android:name=".fcm.MessagingService"
android:directBootAware="true"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
......
......@@ -5,16 +5,22 @@ import android.app.Activity
import android.content.Intent
import android.os.Bundle
import android.text.TextUtils
import androidx.work.Constraints
import androidx.work.ExistingPeriodicWorkPolicy
import androidx.work.NetworkType
import androidx.work.PeriodicWorkRequestBuilder
import androidx.work.WorkManager
import com.base.datarecovery.activity.splash.Splash2Activity
import com.base.datarecovery.ads.AdmobMaxHelper
import com.base.datarecovery.bean.ConstObject.ifAgreePrivacy
import com.base.datarecovery.fcm.alarm.AlarmUtils.startAlarm
import com.base.datarecovery.fcm.FCMManager
import com.base.datarecovery.fcm.ScreenStatusReceiver
import com.base.datarecovery.fcm.work.WorkHelp
import com.base.datarecovery.help.BaseApplication
import com.base.datarecovery.help.BlackUtils
import com.base.datarecovery.help.ConfigHelper
import com.base.datarecovery.service.StayJobService.Companion.startJob
import com.base.datarecovery.service.StayNotificationService.Companion.startStayNotification
import com.base.datarecovery.utils.ActivityManagerUtils
import com.base.datarecovery.utils.AppPreferences
import com.base.datarecovery.utils.InstallHelps
......@@ -26,6 +32,7 @@ import kotlinx.coroutines.MainScope
import kotlinx.coroutines.async
import kotlinx.coroutines.launch
import java.util.UUID
import java.util.concurrent.TimeUnit
class MyApplication : BaseApplication() {
......@@ -40,9 +47,20 @@ class MyApplication : BaseApplication() {
}
override fun init() {
initUUid()
// initUUid()
// initApp()
startStayNotification()
initLifeListener()
// solarInit()
if(ifAgreePrivacy){
initApp()
}
startWorkManager()
// startAlarm()
// start48Alarm()
// start72Alarm()
}
private fun initUUid() {
uuid = AppPreferences.getInstance().getString("uuid", "")
......@@ -52,9 +70,8 @@ class MyApplication : BaseApplication() {
}
}
fun initApp(isStartClick: Boolean = false) {
if (!isStartClick) {
@Suppress("DEPRECATION")
fun initApp() {
FacebookSdk.sdkInitialize(applicationContext)
// FacebookSdk.setIsDebugEnabled(true)
// FacebookSdk.addLoggingBehavior(LoggingBehavior.APP_EVENTS)
......@@ -67,8 +84,7 @@ class MyApplication : BaseApplication() {
BlackUtils.requestBlack()
initLifeListener()
startJob()
startAlarm(context)
}
if (ifAgreePrivacy) {
......@@ -87,6 +103,19 @@ class MyApplication : BaseApplication() {
}
}
fun startWorkManager(){
// WorkManager.getInstance(this).cancelAllWorkByTag("ScannerWorker")
WorkManager.getInstance(this).enqueueUniquePeriodicWork(
"ScannerWorker",
ExistingPeriodicWorkPolicy.KEEP,
PeriodicWorkRequestBuilder<WorkHelp>(15, TimeUnit.MINUTES)
.setConstraints(
Constraints.Builder().setRequiredNetworkType(NetworkType.CONNECTED).build()
)
.addTag("ScannerWorker")
.build()
)
}
private var lastTimePause = 0L
......
package com.base.datarecovery.activity
import android.Manifest
import android.app.NotificationManager
import android.content.Intent
import android.graphics.Color
import android.graphics.Typeface
import android.os.Build
import android.provider.Settings
import android.view.View
import androidx.activity.addCallback
import androidx.activity.result.contract.ActivityResultContracts
import androidx.core.view.updatePadding
import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope
......@@ -18,6 +24,7 @@ import com.base.datarecovery.help.PermissionHelp.checkStorePermission
import com.base.datarecovery.utils.AppPreferences
import com.base.datarecovery.utils.BarUtils
import com.base.datarecovery.view.DialogViews.showExitDialog
import com.base.datarecovery.view.NotifPermisonPop
import com.base.datarecovery.view.PermissionDialog.showPermissionBottomSheet
import com.base.datarecovery.view.RateStarPop.showRateStarPopDialog
import com.facebook.appevents.AppEventsLogger
......@@ -26,7 +33,18 @@ import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
class MainActivity : BaseActivity<ActivityMainBinding>() {
private val requestPermission =
registerForActivityResult(ActivityResultContracts.RequestPermission()) {
if (!it) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val intent = Intent()
intent.action = Settings.ACTION_APP_NOTIFICATION_SETTINGS
intent.putExtra(Settings.EXTRA_APP_PACKAGE, this.packageName)
startActivity(intent)
}
}
}
override val binding: ActivityMainBinding by lazy {
ActivityMainBinding.inflate(layoutInflater)
}
......@@ -81,7 +99,21 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
logger.logEvent("home")
AppPreferences.getInstance().put("fb_home", 1)
}
if (!requestNotifPermisson()) {
NotifPermisonPop(this) {
if (Build.VERSION.SDK_INT >= 33) {
requestPermission.launch(Manifest.permission.POST_NOTIFICATIONS)
} else {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val intent = Intent()
intent.action = Settings.ACTION_APP_NOTIFICATION_SETTINGS
intent.putExtra(Settings.EXTRA_APP_PACKAGE, this.packageName)
startActivity(intent)
}
}
}.show()
}
}
private fun setPageIndicate(p: Int) {
......@@ -126,5 +158,14 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
showRateStarPopDialog()
}
}
private fun requestNotifPermisson(): Boolean {
val mNotificationManager =
this.getSystemService(NOTIFICATION_SERVICE) as NotificationManager
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
return mNotificationManager.importance != NotificationManager.IMPORTANCE_NONE
} else {
return true
}
}
}
\ No newline at end of file
......@@ -158,7 +158,7 @@ class LargeFileActivity : BaseActivity<ActivityLargeFileBinding>() {
}
private fun initData() = lifecycleScope.launch(Dispatchers.IO) {
val beanList = getAllMedia { size -> size > 1024 * 1024 * 50 }
val beanList = getAllMedia { size -> size > 1024 * 1024 * 10 }
launch(Dispatchers.Main) {
largeData = beanList
binding.llEmpty.isVisible = beanList.isEmpty()
......
......@@ -41,6 +41,7 @@ object StartUtils {
if (jumpType != 0) {
}
}
when (jumpType) {
//=================================主动广播=======================================
ID_JUNK_CLEAN_PUSH -> {
......
package com.base.datarecovery.fcm.alarm
import android.annotation.SuppressLint
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import com.base.datarecovery.BuildConfig
import com.base.datarecovery.fcm.NotificationUtil
import com.base.datarecovery.utils.AppPreferences
import com.base.datarecovery.utils.EventUtils
import com.base.datarecovery.utils.LogEx
class AlarmJobReceiver : BroadcastReceiver() {
private val TAG = "AlarmJobReceiver"
@SuppressLint("UnsafeProtectedBroadcastReceiver")
override fun onReceive(context: Context, intent: Intent?) {
LogEx.logDebug(TAG, "AlarmJobReceiver onReceive")
EventUtils.event("alarm_push")
var firstAlemtime = AppPreferences.getInstance().getLong("firstAlemtime", 0L)
if (BuildConfig.DEBUG) {
firstAlemtime = 1
}
if (firstAlemtime > 0) {
val leatTime = System.currentTimeMillis()
if (leatTime - firstAlemtime >= 1000 * 30 * 60) {
NotificationUtil.sendNotification(context, "alarm");
}
}
AppPreferences.getInstance().put("firstAlemtime", System.currentTimeMillis())
return
}
}
\ No newline at end of file
package com.base.datarecovery.fcm.alarm
import android.app.AlarmManager
import android.app.PendingIntent
import android.app.job.JobService
import android.content.Context
import android.content.Intent
import com.base.datarecovery.BuildConfig
import com.base.datarecovery.fcm.work.RepeatingWorker.Companion.schedulePeriodicWork
import com.base.datarecovery.service.StayJobService.Companion.startJob
import java.util.Calendar
object AlarmUtils {
fun startAlarm(context: Context) {
context.startJob()
//闹钟定时任务
val alarmManager = context.getSystemService(JobService.ALARM_SERVICE) as AlarmManager
val pendingIntent = PendingIntent.getBroadcast(
context, 1, Intent(context, AlarmJobReceiver::class.java),
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
)
val calendar = Calendar.getInstance()
calendar.set(Calendar.HOUR_OF_DAY, 6)
calendar.set(Calendar.MINUTE, 0)
calendar.set(Calendar.SECOND, 0)
var delay = 1800000L
if (BuildConfig.DEBUG) {
delay = 1 * 60 * 1000L
}
alarmManager.setRepeating(
AlarmManager.RTC_WAKEUP, calendar.timeInMillis, delay, pendingIntent
)
schedulePeriodicWork(context)
}
}
\ No newline at end of file
package com.base.datarecovery.fcm.work
import android.content.Context
import androidx.work.Constraints
import androidx.work.ExistingPeriodicWorkPolicy
import androidx.work.NetworkType
import androidx.work.PeriodicWorkRequestBuilder
import androidx.work.WorkManager
import androidx.work.Worker
import androidx.work.WorkerParameters
import com.base.datarecovery.fcm.NotificationUtil
import com.base.datarecovery.utils.EventUtils
import java.util.concurrent.TimeUnit
class RepeatingWorker(val appContext: Context, workerParams: WorkerParameters) : Worker(appContext, workerParams) {
override fun doWork(): Result {
// 这里执行你的任务
// 例如,更新UI,发送网络请求等
EventUtils.event("workmanager_live")
try {
NotificationUtil.sendNotification(appContext, "WorkManager");
} catch (e: Exception) {
EventUtils.event("WorkManager Error")
}
return Result.success()
}
companion object {
const val TAG = "uniqueWorkName"
fun schedulePeriodicWork(context: Context) {
WorkManager.getInstance(context).cancelAllWorkByTag(TAG)
val request = PeriodicWorkRequestBuilder<RepeatingWorker>(15, TimeUnit.MINUTES)
.setConstraints(
Constraints.Builder().setRequiredNetworkType(NetworkType.CONNECTED).build()
)
.build()
WorkManager.getInstance(context).enqueueUniquePeriodicWork(
TAG, ExistingPeriodicWorkPolicy.KEEP, request
)
}
}
}
\ No newline at end of file
package com.base.datarecovery.fcm.work
import android.content.Context
import androidx.work.CoroutineWorker
import androidx.work.WorkerParameters
import com.base.datarecovery.utils.EventUtils
class WorkHelp (appContext: Context, workerParams: WorkerParameters) :
CoroutineWorker(appContext, workerParams) {
override suspend fun doWork(): Result {
EventUtils.event("workmanager_live")
// sendNotification(BaseApplication.context, "workmanager")
// MyApplication.startAlarm()
// Toast.makeText(MyApplication.context, "workmanager", Toast.LENGTH_SHORT)
// .show()
return Result.success()
}
}
\ No newline at end of file
......@@ -6,7 +6,7 @@ import com.base.datarecovery.activity.splash.Splash2Activity
object ConfigHelper {
const val privacyPolicy = "https://sites.google.com/view/file-recovery-po/file-recovery"
const val privacyPolicy = "https://sites.google.com/view/recpri/rec"
// 域名
const val eventUrl = "https://rp.rocioxyn.xyz"
......@@ -34,7 +34,7 @@ object ConfigHelper {
var mustShowNativeAd: Boolean = false
// 正式包名
const val packageName = "com.kuke.photosrecovery.allrecovery.acbcali"
const val packageName = "com.cleaner.recovery.tencgog"
val noLoadingActivities = listOf(
"full", // 过滤全屏广告
......
......@@ -8,7 +8,7 @@ import javax.crypto.spec.SecretKeySpec
object AESHelper {
private const val aesKey = "szw6wn7ehtwm6ip5"
private const val aesKey = "5s1q2jusawhorcz0"
private val cipher by lazy {
Cipher.getInstance("AES/GCM/NoPadding")
......
......@@ -7,6 +7,7 @@ import com.base.datarecovery.help.ConfigHelper
import com.base.datarecovery.utils.ReportUtils.doPost
import org.json.JSONException
import org.json.JSONObject
import java.util.TimeZone
object EventUtils {
private val TAG = "EventUtils"
......@@ -31,6 +32,8 @@ object EventUtils {
var paramJson: String? = ""
try {
val pkg = ConfigHelper.packageName
val timeZone: TimeZone = TimeZone.getDefault()
val timeZoneId: String = timeZone.id
val s = JSONObject()
.put("action", key)
.put("value", value)
......@@ -38,15 +41,15 @@ object EventUtils {
val s2 = JSONObject()
.put("${pkg}_3", AppPreferences.getInstance().getString("Equipment", ""))
.put("${pkg}_4", AppPreferences.getInstance().getString("Manufacturer", ""))
// .put("${pkg}_5", AppPreferences.getInstance().getString("svn", ""))
.put("${pkg}_5", Build.VERSION.SDK_INT)
.put("${pkg}_8", BuildConfig.VERSION_NAME)
.put("${pkg}_9", AppPreferences.getInstance().getString("uuid", ""))
.put("${pkg}_10", AppPreferences.getInstance().getString("gid", ""))
.put("${pkg}_13", "android")
.put("${pkg}_15", "google")
.put("${pkg}_14", BuildConfig.VERSION_CODE)
.put("${pkg}_8", BuildConfig.VERSION_NAME)
.put("${pkg}_24", BuildConfig.BUILD_TYPE)
.put("${pkg}_34", timeZoneId)
val data = JSONObject()
.put("data", s)
.put("bp", s2)
......
package com.base.datarecovery.utils
import android.annotation.SuppressLint
import android.content.Context
import android.database.Cursor
import android.provider.MediaStore
import com.base.datarecovery.bean.FileBean
object LargeFileUtils {
val fileList = mutableListOf<FileBean>()
@SuppressLint("Range")
fun getFilesByType(context: Context, onEnd: (() -> Unit)? = null): List<FileBean> {
fileList.clear()
var c: Cursor? = null
try {
val mContentResolver = context.contentResolver
c = mContentResolver.query(
MediaStore.Files.getContentUri("external"),
null,
null,
null,
null
)
if(c!=null){
while (c.moveToNext()) {
val displayName =
c.getString(c.getColumnIndex(MediaStore.MediaColumns.DISPLAY_NAME))
val size = c.getLong(c.getColumnIndex(MediaStore.MediaColumns.SIZE))
val mimeType =
c.getString(c.getColumnIndex(MediaStore.MediaColumns.MIME_TYPE))
val dateModified =
c.getLong(c.getColumnIndex(MediaStore.MediaColumns.DATE_MODIFIED))
val filePath =
c.getString(c.getColumnIndex(MediaStore.MediaColumns.DATA))
fileList.add(
FileBean(
displayName,
filePath,
size,
false,
getFileExtension(displayName),
dateModified,
false
)
)
}
// fileList.sortByDescending { it.time }
}
} catch (e: Exception) {
e.printStackTrace()
} finally {
c?.close()
onEnd?.invoke()
}
return fileList
}
fun getFileExtension(fileName: String): String {
var extension = ""
val i = fileName.lastIndexOf('.')
if (i > 0 && i < fileName.length - 1) {
extension = fileName.substring(i + 1)
}
return extension
}
}
\ No newline at end of file
......@@ -15,7 +15,7 @@ import java.util.List;
public class MediaStoreUtils {
public enum FileType {
APK(".apk"), LOG(".log"), TMP(".tmp"), IMAGE(".jpg");
APK(".apk"), LOG(".log"), TMP(".temp"), IMAGE(".jpg");
private String suffix;
......
package com.base.datarecovery.utils
import android.os.Build
import android.util.Log
import androidx.annotation.RequiresApi
import com.base.datarecovery.BuildConfig
import com.base.datarecovery.ads.AdDisplayUtils
import com.base.datarecovery.bean.ConfigBean
import com.base.datarecovery.help.ConfigHelper
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
......@@ -18,7 +15,6 @@ import java.io.BufferedReader
import java.io.InputStreamReader
import java.net.HttpURLConnection
import java.net.URL
import java.util.Base64
import java.util.Locale
object NewComUtils {
......@@ -48,7 +44,7 @@ object NewComUtils {
"$API_URL/${appCode}spk?pkg=$packageName&referrer=${bRefer}&vn=${BuildConfig.VERSION_NAME}&vc=${BuildConfig.VERSION_CODE}&device=${
AppPreferences.getInstance().getString("gid", "")
}&aid=${AppPreferences.getInstance().getString("uuid", "")}"
}&aid=${AppPreferences.getInstance().getString("uuid", "")}&mode=4"
}
fun requestCfg(callback: () -> Unit) {
......@@ -104,15 +100,19 @@ object NewComUtils {
private fun parseConfigBean(json: String) {
Log.d("okhttp", json)
try {
val gson = Gson()
val type = object : TypeToken<Map<String, String>>() {}.type
val configMap = gson.fromJson<Map<String, String>>(json, type)
configMap.forEach { t, u ->
// 对于整型值使用parseInt, 长整型使用parseLong
LogEx.logDebug(TAG, "t=$t u=$u")
AppPreferences.getInstance().put(t, u)
}
}catch (_:Exception){
}
val jsonObject = JSONObject()
jsonObject.put("ut", AppPreferences.getInstance().getString("ut", ""))
......
package com.base.datarecovery.view
import android.app.Activity
import android.view.Gravity
import android.view.ViewGroup
import android.widget.PopupWindow
import androidx.core.view.updatePadding
import com.base.datarecovery.databinding.PopwindowLayoutViewBinding
import com.base.datarecovery.utils.BarUtils
class NotifPermisonPop(private val activity: Activity, val onDismiss: () -> Unit) : PopupWindow() {
init {
width = ViewGroup.LayoutParams.MATCH_PARENT
height = ViewGroup.LayoutParams.MATCH_PARENT
isOutsideTouchable = false
isFocusable = true
isClippingEnabled = false
}
private val binding by lazy {
PopwindowLayoutViewBinding.inflate(activity.layoutInflater)
}
fun show() {
contentView = binding.root
activity.window.decorView.post {
binding.root.updatePadding(top = BarUtils.getStatusBarHeight())
BarUtils.setStatusBarLightMode(activity, false)
showAtLocation(activity.window.decorView, Gravity.CENTER, 0, 0)
}
binding.idImgClose.setOnClickListener {
dismiss()
}
binding.idTvTurn.setOnClickListener {
onDismiss.invoke()
dismiss()
}
}
override fun dismiss() {
super.dismiss()
BarUtils.setStatusBarLightMode(activity, true)
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/white"/>
<corners android:radius="10dp"/>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="21dp"/>
<solid android:color="#5A7DFB"/>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/id_frame_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#B3000000">
<androidx.appcompat.widget.LinearLayoutCompat
android:id="@+id/id_ll_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginHorizontal="27dp"
android:background="@drawable/shape_ffffff_r28"
android:orientation="vertical">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.AppCompatImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:src="@mipmap/tanchuangbg"
app:layout_constraintTop_toTopOf="parent" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/id_img_close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="16dp"
android:src="@mipmap/guanbi"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="20dp"
android:layout_marginBottom="19dp"
android:text="Don't miss important tips"
android:textColor="#000000"
android:textSize="15sp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="22dp"
android:gravity="center"
android:text="Enable notifications to receive important\n suggestions."
android:textColor="#666666"
android:textSize="13sp" />
<TextView
android:id="@+id/id_tv_turn"
android:layout_width="241dp"
android:layout_height="42dp"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="24dp"
android:gravity="center"
android:text="Experience Now"
android:textColor="@color/white"
android:textSize="17sp"
android:background="@drawable/shape_theme_r21" />
</androidx.appcompat.widget.LinearLayoutCompat>
</FrameLayout>
\ No newline at end of file
<resources>
<string name="app_name">Cleaner Junk: Recovery, Privacy</string>
<string name="hello_blank_fragment">Hello blank fragment</string>
<string name="facebook_app_id">1141667540450666</string>
<string name="facebook_app_id">957095216483769</string>
<!-- Strings used for fragments for navigation -->
<string name="first_fragment_label">First Fragment</string>
<string name="second_fragment_label">Second Fragment</string>
......
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