Commit f299164f authored by wanglei's avatar wanglei

1.垃圾清理

2.截图清理
3.照片压缩
4.重复照片清理
5.大文件清理
parent 47b8bf8a
......@@ -10,9 +10,7 @@ import android.util.Log
import com.google.android.gms.ads.MobileAds
import com.google.firebase.FirebaseApp
import com.test.easy.easycleanerjunk.activity.splash.NewSplashActivity
import com.test.easy.easycleanerjunk.display.fcm.FcmHelper
import com.test.easy.easycleanerjunk.helps.BaseApplication
import com.test.easy.easycleanerjunk.helps.ComUtils.requestCfg
import com.test.easy.easycleanerjunk.helps.ConfigHelper
import com.test.easy.easycleanerjunk.helps.InstallHelps
import com.test.easy.easycleanerjunk.helps.ads.AdmobUtils
......@@ -47,7 +45,6 @@ class MyApplication : BaseApplication() {
if (ConfigHelper.ifAgreePrivacy) {
initNotificationWork()
MainScope().launch {
requestCfg()
InstallHelps.init()
}
MobileAds.initialize(this) { initializationStatus ->
......@@ -69,8 +66,6 @@ class MyApplication : BaseApplication() {
private fun initNotificationWork() {
FirebaseApp.initializeApp(this)
FcmHelper.getToken()
FcmHelper.subscribeToTopic()
Log.d("MyService", "startService:" + Process.myPid());
}
......
package com.test.easy.easycleanerjunk.activity
import android.animation.Animator
import android.annotation.SuppressLint
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.hardware.camera2.CameraAccessException
import android.hardware.camera2.CameraManager
import android.location.LocationManager
import android.os.BatteryManager
import android.os.Build
import android.os.SystemClock
import android.provider.Settings
import android.view.View
import android.widget.Toast
import androidx.activity.addCallback
import androidx.activity.result.contract.ActivityResultContracts
import androidx.core.view.isVisible
import com.test.easy.easycleanerjunk.R
import com.test.easy.easycleanerjunk.databinding.ActivityBatteryInfoBinding
import com.test.easy.easycleanerjunk.helps.BaseActivity
import com.test.easy.easycleanerjunk.helps.ads.AdmobUtils
import com.test.easy.easycleanerjunk.view.AFunOb
import java.util.Calendar
import java.util.Date
import kotlin.math.roundToInt
@SuppressLint("SetTextI18n")
class BatteryInfoActivity : BaseActivity<ActivityBatteryInfoBinding>() {
override val isLightMode = true
private lateinit var receiver: BatteryReceiver
private lateinit var cm: CameraManager
private lateinit var cameraId: String
private var isTorchOn = false
override val binding: ActivityBatteryInfoBinding by lazy {
ActivityBatteryInfoBinding.inflate(layoutInflater)
}
override fun initView() {
receiver = BatteryReceiver()
val filter = IntentFilter(Intent.ACTION_BATTERY_CHANGED)
registerReceiver(receiver, filter)
cm = getSystemService(Context.CAMERA_SERVICE) as CameraManager
try {
cameraId = cm.cameraIdList[0]
} catch (e: CameraAccessException) {
e.printStackTrace()
}
setFilter()
binding.idBatteryLottie.imageAssetsFolder = "easy_battery_scan/images/"
binding.idBatteryLottie.setAnimation("easy_battery_scan/data.json")
binding.idBatteryLottie.playAnimation()
binding.root.postDelayed({
playFinish()
}, 5000)
binding.switchTwo.setOnClickListener {
turnOnBluetooth()
}
binding.switchThree.setOnCheckedChangeListener { _, isChecked ->
if (isChecked) {
turnOnFlashLight()
} else {
turnOffFlashLight()
}
}
binding.switchFour.setOnClickListener {
jumpLocationSettings()
}
binding.btOk.setOnClickListener {
AdmobUtils.showInterstitialAd(this) {
binding.btOk.setBackgroundResource(R.drawable.bg_shape_set_click)
startActivity(Intent(this, ResultActivity::class.java).apply {
putExtra("from", AFunOb.BATTERY_INFO)
})
finish()
}
}
binding.ivBack.setOnClickListener {
AdmobUtils.showInterstitialAd(this@BatteryInfoActivity) {
finishToMain()
}
}
onBackPressedDispatcher.addCallback {
AdmobUtils.showInterstitialAd(this@BatteryInfoActivity) {
finishToMain()
}
}
}
private val result1 =
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {
}
private val settingResult =
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {
}
private inner class BatteryReceiver : BroadcastReceiver() {
override fun onReceive(context: Context?, intent: Intent?) {
val current = intent?.extras?.getInt("level") ?: 0
val total = intent?.extras?.getInt("scale") ?: 0
val percent = current * 100 / total
if (percent >= 30) {
binding.imagePower.setImageResource(R.drawable.batteryl)
} else {
binding.imagePower.setImageResource(R.drawable.batteryh)
}
val voltage = intent?.getIntExtra("voltage", 0)?.toFloat()?.roundToInt() ?: 0
binding.tvVo.text = "${voltage / 1000f}V"
val temperature = intent?.getIntExtra("temperature", 0)?.toFloat()?.roundToInt() ?: 0
binding.tvTemp.text = "${temperature / 10f}°C"
binding.tvLevel.text = "$percent%"
}
}
private fun playFinish() {
binding.idConsOne.isVisible = false
binding.idConsBatteryFinish.isVisible = true
binding.idBatteryFinish.addAnimatorListener(object : Animator.AnimatorListener {
override fun onAnimationStart(p0: Animator) {
}
override fun onAnimationEnd(p0: Animator) {
AdmobUtils.showInterstitialAd(this@BatteryInfoActivity) {
updateUI()
}
}
override fun onAnimationCancel(p0: Animator) {
}
override fun onAnimationRepeat(p0: Animator) {
}
})
}
private fun checkFlashLight() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
cm.registerTorchCallback(object : CameraManager.TorchCallback() {
override fun onTorchModeChanged(cameraId: String, enabled: Boolean) {
super.onTorchModeChanged(cameraId, enabled)
if (cameraId == this@BatteryInfoActivity.cameraId) {
if (enabled && !isTorchOn) {
isTorchOn = true
binding.switchThree.isChecked = true
} else if (!enabled && isTorchOn) {
isTorchOn = false
binding.switchThree.isChecked = false
}
}
}
}, null)
} else {
Toast.makeText(this, "don't support you phone", Toast.LENGTH_SHORT).show()
}
}
private fun turnOnFlashLight() {
try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
cm.setTorchMode(cameraId, true)
} // 打开手电筒
} catch (e: CameraAccessException) {
e.printStackTrace()
}
}
private fun turnOffFlashLight() {
try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
cm.setTorchMode(cameraId, false)
} // 打开手电筒
} catch (e: CameraAccessException) {
e.printStackTrace()
}
}
private fun jumpLocationSettings() {
val intent = Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS)
settingResult.launch(intent)
}
private fun checkLocation() {
binding.switchFour.isChecked = isLocationEnabled(this)
}
private fun isLocationEnabled(context: Context): Boolean {
val locationManager = context.getSystemService(Context.LOCATION_SERVICE) as LocationManager
return locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER) ||
locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)
}
private fun setFilter() {
val uptime = SystemClock.elapsedRealtime()
val currantTime = Calendar.getInstance().time
val batteryUseTime = currantTime.time - uptime
val batteryDate = Date(batteryUseTime)
binding.tvTime.text = "${batteryDate.hours} H ${batteryDate.minutes} M"
val bm = getSystemService(Context.BATTERY_SERVICE) as BatteryManager
val chargeCounter = bm.getIntProperty(BatteryManager.BATTERY_PROPERTY_CHARGE_COUNTER)
val pCapacity = bm.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY)
if (chargeCounter != Int.MIN_VALUE && pCapacity != Int.MIN_VALUE) {
binding.tvMa.text = "${
String.format("%.1f", (chargeCounter / (pCapacity.toFloat() / 100f)) / 1000f)
} mAh"
}
}
private fun updateUI() {
binding.idBatteryLottie.visibility = View.GONE
binding.idConsBatteryFinish.isVisible = false
binding.llContent.isVisible = true
}
override fun onResume() {
super.onResume()
binding.btOk.setBackgroundResource(R.drawable.bg_shape_set)
checkFlashLight()
checkLocation()
}
fun turnOnBluetooth() {
val intent2 = Intent(Settings.ACTION_BLUETOOTH_SETTINGS)
result1.launch(intent2)
}
override fun onDestroy() {
super.onDestroy()
unregisterReceiver(receiver)
binding?.idBatteryLottie?.clearAnimation()
}
}
\ No newline at end of file
package com.test.easy.easycleanerjunk.activity
import android.annotation.SuppressLint
import android.content.Context
import android.content.Intent
import android.net.ConnectivityManager
import android.net.wifi.WifiManager
import android.os.Build
import android.os.Environment
import android.os.StatFs
import androidx.activity.addCallback
import com.test.easy.easycleanerjunk.databinding.ActivityDeviceScanInfoBinding
import com.test.easy.easycleanerjunk.helps.BaseActivity
import com.test.easy.easycleanerjunk.helps.KotlinExt.toFormatSize
import com.test.easy.easycleanerjunk.helps.LogEx
import com.test.easy.easycleanerjunk.helps.ads.AdmobUtils
import com.test.easy.easycleanerjunk.utils.DeviceUtils
import com.test.easy.easycleanerjunk.view.AFunOb
import java.io.BufferedReader
import java.io.File
import java.io.FileReader
import java.io.IOException
import java.nio.file.Files
import java.nio.file.Paths
import java.util.Locale
class DeviceScanInfoActivity : BaseActivity<ActivityDeviceScanInfoBinding>() {
private val TAG = "DeviceScanActivity"
override val binding: ActivityDeviceScanInfoBinding by lazy {
ActivityDeviceScanInfoBinding.inflate(layoutInflater)
}
@SuppressLint("SetTextI18n")
override fun initView() {
binding.tvDeviceName.text = getDeviceName()
binding.tvAndroidVersion.text = "System Version: Android ${Build.VERSION.RELEASE}"
binding.tvAbis.text = DeviceUtils.getABIs().toStringEx()
val cupInfo = cpuInfo()
cupInfo.forEach {
LogEx.logDebug(TAG, "cupInfo $it")
}
binding.tvCpuCores.text = cupInfo.find { it.contains("CPU architecture") }?.split(":")?.get(1)
binding.tvIpAddress.text = if (isWifiConnected(this)) getWifiIpAddress(this) else ""
binding.tvSsid.text = getWifiSSID(this)
binding.tvLinkSpeed.text = "${getWifiLinkSpeed(this)} Mbps"
binding.tvCpuFrequency.text = "${getCpuFreq("cpuinfo_min_freq") / 1000}MHZ - ${getCpuFreq("cpuinfo_max_freq") / 1000}MHZ"
binding.tvCpuHardware.text = getCpuHardware()
}
override fun initListener() {
binding.tvOk.setOnClickListener {
startActivity(Intent(this, ResultActivity::class.java).apply {
putExtra("from", AFunOb.DEVICE_SCAN)
})
}
binding.flBack.setOnClickListener {
onBackPressedDispatcher.onBackPressed()
}
onBackPressedDispatcher.addCallback {
AdmobUtils.showInterstitialAd(this@DeviceScanInfoActivity){
finishToMain()
}
}
}
private fun capitalize(str: String?): String? {
return if (str.isNullOrEmpty()) {
str
} else str.substring(0, 1).uppercase(Locale.getDefault()) + str.substring(1).lowercase(Locale.getDefault())
}
fun getDeviceName(): String? {
val manufacturer = Build.MANUFACTURER
val model = Build.MODEL
return if (model.lowercase(Locale.getDefault()).startsWith(manufacturer.lowercase(Locale.getDefault()))) {
capitalize(model)
} else capitalize(manufacturer) + " " + model
}
private fun cpuInfo(): ArrayList<String> {
val cpuList: ArrayList<String> = arrayListOf()
try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val cpuInfo = String(Files.readAllBytes(Paths.get("/proc/cpuinfo")))
LogEx.logDebug(TAG, "$cpuInfo")
val arrays = cpuInfo.split("\n")
cpuList.addAll(arrays)
}
} catch (e: IOException) {
e.printStackTrace()
}
return cpuList
}
fun isWifiConnected(context: Context): Boolean {
val connectivityManager = context.getSystemService(CONNECTIVITY_SERVICE) as ConnectivityManager
val networkInfo = connectivityManager.activeNetworkInfo
// 检查networkInfo是否为null以及是否连接到Wi-Fi
return networkInfo != null && networkInfo.type == ConnectivityManager.TYPE_WIFI
}
fun getWifiIpAddress(context: Context): String {
val wifiManager = context.getSystemService(WIFI_SERVICE) as WifiManager
val wifiInfo = wifiManager.connectionInfo
val ip = wifiInfo.ipAddress
return if (ip == 0) {
"No network connection"
} else (ip and 0xff).toString() + "." + (ip shr 8 and 0xff) + "." + (ip shr 16 and 0xff) + "." + (ip shr 24 and 0xff)
}
fun getMobileIpAddress(context: Context): String {
val connectivityManager = context.getSystemService(CONNECTIVITY_SERVICE) as ConnectivityManager
val activeNetwork = connectivityManager.activeNetworkInfo
return if (activeNetwork != null && activeNetwork.isConnected) {
activeNetwork.extraInfo.toString().split(" ".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()[1].trim { it <= ' ' }
} else "No network connection"
}
fun getWifiSSID(context: Context): String? {
val wifiManager = context.getSystemService(WIFI_SERVICE) as WifiManager
val wifiInfo = wifiManager.connectionInfo
if (wifiInfo != null) {
val ssid = wifiInfo.ssid
// 移除SSID周围的双引号
return if (ssid != null && ssid.isNotEmpty()) ssid.replace("\"".toRegex(), "") else null
}
return "<unknown ssid>"
}
/**
* 获取当前Wi-Fi连接的链路速度。
*
* @param context Android上下文对象。
* @return 链路速度,单位为Mbps。如果没有连接到Wi-Fi或无法获取,则返回-1。
*/
fun getWifiLinkSpeed(context: Context): Int {
val wifiManager = context.getSystemService(WIFI_SERVICE) as WifiManager
val wifiInfo = wifiManager.connectionInfo
// 获取Wi-Fi链路速度,单位为Mbps
return wifiInfo?.linkSpeed ?: -1
}
/**
* @param filePath
* cpuinfo_cur_freq
* cpuinfo_min_freq
* cpuinfo_max_freq
* scaling_available_frequencies
*
* @return 返回数据 546000KHZ=546MHZ
*/
fun getCpuFreq(filePath: String): Int {
val scalingPath = "/sys/devices/system/cpu/cpu0/cpufreq/"
val path = File(scalingPath + filePath)
var frequency = 0
try {
if (path.exists()) {
val reader = BufferedReader(FileReader(path))
val line = reader.readLine()
reader.close()
if (line != null) {
// 处理读取到的频率值
LogEx.logDebug("CPU Frequency", "$filePath: $line kHz")
frequency = line.toInt()
}
}
} catch (e: IOException) {
e.printStackTrace()
}
return frequency
}
@SuppressLint("PrivateApi")
fun getCpuHardware(): String {
val classType = Class.forName("android.os.SystemProperties")
val method = classType.getDeclaredMethod("get", String::class.java)
val result = method.invoke(classType, "ro.board.platform") as String
return result
}
private fun <T> Array<T>.toStringEx(): String {
val sb = StringBuffer()
sb.append("[")
forEachIndexed { index, t ->
if (index == size - 1) {
sb.append("$t")
} else {
sb.append("$t").append(",")
}
}
sb.append("]")
return sb.toString()
}
}
\ No newline at end of file
......@@ -10,20 +10,11 @@ import com.test.easy.easycleanerjunk.adapter.AppFunctionAdapter
import com.test.easy.easycleanerjunk.databinding.ActivityLayoutResultBinding
import com.test.easy.easycleanerjunk.helps.BaseActivity
import com.test.easy.easycleanerjunk.helps.KotlinExt.toFormatSize
import com.test.easy.easycleanerjunk.notificationclean.NotificationGuestActivity
import com.test.easy.easycleanerjunk.utils.BarUtils
import com.test.easy.easycleanerjunk.utils.SPUtils
import com.test.easy.easycleanerjunk.view.AFunOb.APP_MANAGER
import com.test.easy.easycleanerjunk.view.AFunOb.APP_SPEED
import com.test.easy.easycleanerjunk.view.AFunOb.BATTERY_INFO
import com.test.easy.easycleanerjunk.view.AFunOb.BATTERY_OPTIMIZER
import com.test.easy.easycleanerjunk.view.AFunOb.EMPTY_FILE_CLEANER
import com.test.easy.easycleanerjunk.view.AFunOb.JUNK_CLEANER
import com.test.easy.easycleanerjunk.view.AFunOb.LARGE_FILE_CLEANER
import com.test.easy.easycleanerjunk.view.AFunOb.NETWORK_TRAFFIC
import com.test.easy.easycleanerjunk.view.AFunOb.NOTIFICATION_CLEANER
import com.test.easy.easycleanerjunk.view.AFunOb.PHOTO_COMPRESS
import com.test.easy.easycleanerjunk.view.AFunOb.RECENT_APP_USAGE
import com.test.easy.easycleanerjunk.view.AFunOb.SIMILAR_PHOTOS
class ResultActivity : BaseActivity<ActivityLayoutResultBinding>() {
......@@ -41,31 +32,9 @@ class ResultActivity : BaseActivity<ActivityLayoutResultBinding>() {
JUNK_CLEANER -> {
startActivity(Intent(this, ScanJunkActivity::class.java))
}
RECENT_APP_USAGE -> {
startActivity(Intent(this, RecentAppActivity::class.java))
}
LARGE_FILE_CLEANER -> {
startActivity(Intent(this, LargeFileCleanActivity::class.java))
}
NOTIFICATION_CLEANER -> {
startActivity(Intent(this, NotificationGuestActivity::class.java))
}
NETWORK_TRAFFIC -> {
startActivity(Intent(this, NetWorkActivity::class.java))
}
APP_MANAGER -> {
startActivity(Intent(this, AppManagerActivity::class.java))
}
BATTERY_INFO -> {
startActivity(Intent(this, BatteryInfoActivity::class.java))
}
SIMILAR_PHOTOS -> {
startActivity(Intent(this, RepeatPhotoActivity::class.java))
}
......@@ -96,49 +65,15 @@ class ResultActivity : BaseActivity<ActivityLayoutResultBinding>() {
}
RECENT_APP_USAGE -> {
binding.tvInfo.text = ""
}
LARGE_FILE_CLEANER -> {
binding.tvInfo.text = ""
}
NOTIFICATION_CLEANER -> {
binding.tvInfo.text = ""
}
NETWORK_TRAFFIC -> {
binding.tvInfo.text = ""
}
APP_MANAGER -> {
binding.tvInfo.text = ""
}
BATTERY_INFO -> {
binding.tvInfo.text = "Battery scan completed."
SPUtils.getInstance().put("last_use_battery_info", System.currentTimeMillis())
}
EMPTY_FILE_CLEANER -> {
binding.tvInfo.text = ""
}
PHOTO_COMPRESS -> {
val size = intent.getLongExtra("size", 0L).toFormatSize(1)
binding.tvInfo.text = "Compress ${intent.getIntExtra("num", 0)} photo, $size space freed"
}
BATTERY_OPTIMIZER -> {
binding.tvInfo.text = "Completed"
}
APP_SPEED -> {
binding.tvInfo.text = "Completed"
}
else -> {}
}
from?.let {
......
......@@ -5,7 +5,6 @@ import android.net.Uri
import android.os.Build
import com.test.easy.easycleanerjunk.databinding.ActivitySettingBinding
import com.test.easy.easycleanerjunk.display.NotificationService
import com.test.easy.easycleanerjunk.display.fcm.FcmHelper
import com.test.easy.easycleanerjunk.helps.BaseActivity
import com.test.easy.easycleanerjunk.helps.ConfigHelper
import com.test.easy.easycleanerjunk.helps.ConfigHelper.allNotification
......@@ -20,7 +19,6 @@ class SettingActivity : BaseActivity<ActivitySettingBinding>() {
override fun initView() {
binding.switchRemainNotification.isChecked = remainNotification
binding.switchAllNotification.isChecked = allNotification
}
override fun initListener() {
......@@ -38,10 +36,7 @@ class SettingActivity : BaseActivity<ActivitySettingBinding>() {
stopService(serviceIntent)
}
}
binding.switchAllNotification.setOnCheckedChangeListener { buttonView, isChecked ->
allNotification = isChecked
switchFcm(isChecked)
}
binding.cardPrivacy.setOnClickListener {
val intent = Intent(
Intent.ACTION_VIEW,
......@@ -58,11 +53,4 @@ class SettingActivity : BaseActivity<ActivitySettingBinding>() {
startService(intent)
}
}
private fun switchFcm(checked: Boolean) {
if (checked) {
FcmHelper.subscribeToTopic()
} else {
FcmHelper.unSubscribeToTopic()
}
}
}
\ No newline at end of file
......@@ -2,24 +2,17 @@ package com.test.easy.easycleanerjunk.activity.splash
import android.app.Activity
import android.content.Intent
import com.test.easy.easycleanerjunk.activity.AppManagerActivity
import com.test.easy.easycleanerjunk.activity.CleanGuestActivity
import com.test.easy.easycleanerjunk.activity.DeviceScanActivity
import com.test.easy.easycleanerjunk.activity.LargeFileCleanActivity
import com.test.easy.easycleanerjunk.activity.NetWorkActivity
import com.test.easy.easycleanerjunk.activity.RecentAppActivity
import com.test.easy.easycleanerjunk.activity.RepeatPhotoActivity
import com.test.easy.easycleanerjunk.activity.ScanJunkActivity
import com.test.easy.easycleanerjunk.activity.ScreenShotActivity
import com.test.easy.easycleanerjunk.activity.home.NewMainActivity
import com.test.easy.easycleanerjunk.activity.photocompress.photo.StartCompressionPhotoActivity
import com.test.easy.easycleanerjunk.bean.ConfigBean.Companion.ID_APP_MANAGER
import com.test.easy.easycleanerjunk.bean.ConfigBean.Companion.ID_CLEAN_NOTIFICATION
import com.test.easy.easycleanerjunk.bean.ConfigBean.Companion.ID_JUNK_CLEAN_PUSH
import com.test.easy.easycleanerjunk.bean.ConfigBean.Companion.ID_LARGE_FILE_PUSH
import com.test.easy.easycleanerjunk.bean.ConfigBean.Companion.ID_NETWORK_TRAFFIC
import com.test.easy.easycleanerjunk.bean.ConfigBean.Companion.ID_PHOTO_COMPRESS
import com.test.easy.easycleanerjunk.bean.ConfigBean.Companion.ID_RECENT_USE_APP
import com.test.easy.easycleanerjunk.bean.ConfigBean.Companion.ID_SCREENSHOT_CLEAN
import com.test.easy.easycleanerjunk.bean.ConfigBean.Companion.ID_SIMILAR_IMAGE
import com.test.easy.easycleanerjunk.helps.ConfigHelper
......@@ -44,28 +37,12 @@ object SplashJumpUtils {
context.startActivity(Intent(context, ScanJunkActivity::class.java))
}
ID_LARGE_FILE_PUSH -> {
context.startActivity(Intent(context, LargeFileCleanActivity::class.java))
}
ID_PHOTO_COMPRESS -> {
context.startActivity(Intent(context, StartCompressionPhotoActivity::class.java))
}
ID_APP_MANAGER -> {
context.startActivity(Intent(context, AppManagerActivity::class.java))
}
ID_NETWORK_TRAFFIC -> {
context.startActivity(Intent(context, NetWorkActivity::class.java))
}
ID_CLEAN_NOTIFICATION -> {
context.startActivity(Intent(context, NotificationGuestActivity::class.java))
}
ID_RECENT_USE_APP -> {
context.startActivity(Intent(context, RecentAppActivity::class.java))
ID_LARGE_FILE_PUSH -> {
context.startActivity(Intent(context, LargeFileCleanActivity::class.java))
}
ID_SIMILAR_IMAGE -> {
......
......@@ -9,14 +9,9 @@ import androidx.recyclerview.widget.RecyclerView.ViewHolder
import com.test.easy.easycleanerjunk.R
import com.test.easy.easycleanerjunk.databinding.ItemResultFunBinding
import com.test.easy.easycleanerjunk.utils.SPUtils
import com.test.easy.easycleanerjunk.view.AFunOb.APP_MANAGER
import com.test.easy.easycleanerjunk.view.AFunOb.BATTERY_INFO
import com.test.easy.easycleanerjunk.view.AFunOb.JUNK_CLEANER
import com.test.easy.easycleanerjunk.view.AFunOb.LARGE_FILE_CLEANER
import com.test.easy.easycleanerjunk.view.AFunOb.NETWORK_TRAFFIC
import com.test.easy.easycleanerjunk.view.AFunOb.NOTIFICATION_CLEANER
import com.test.easy.easycleanerjunk.view.AFunOb.PHOTO_COMPRESS
import com.test.easy.easycleanerjunk.view.AFunOb.RECENT_APP_USAGE
import com.test.easy.easycleanerjunk.view.AFunOb.SIMILAR_PHOTOS
import com.test.easy.easycleanerjunk.view.XmlEx.inflate
import java.util.Collections
......@@ -28,31 +23,12 @@ class AppFunctionAdapter(val click: (name: String) -> Unit) :
Fun(JUNK_CLEANER, R.mipmap.t_cleanjunk, "Clean junk regularly to free up space", "Clean Up"),
Fun(PHOTO_COMPRESS, R.mipmap.t_photo, "Compress photos to save space", "Compress"),
Fun(LARGE_FILE_CLEANER, R.mipmap.t_large, "Clean large files to free up storage space", "Clean Up"),
Fun(
APP_MANAGER,
R.mipmap.t_appmanager,
"Check apps size and uninstall some apps to release storage space",
"Check Now"
),
Fun(
SIMILAR_PHOTOS,
R.mipmap.t_similar,
"Check similar photos to release more space",
"Clean Up"
),
Fun(
NOTIFICATION_CLEANER,
R.mipmap.t_notification,
"Too many annoying notifications? Block and clean",
"Check Now"
),
Fun(RECENT_APP_USAGE, R.mipmap.t_recent, "Check and manage recently active apps", "View Now"),
Fun(
NETWORK_TRAFFIC,
R.mipmap.t_network,
"View network traffic usage and stop traffic-consuming apps",
"View Now"
),
)
//修改顺序
......
......@@ -10,14 +10,9 @@ import com.test.easy.easycleanerjunk.databinding.ItemAdBinding
import com.test.easy.easycleanerjunk.databinding.ItemToolGrid1Binding
import com.test.easy.easycleanerjunk.databinding.ItemToolsGrid1Binding
import com.test.easy.easycleanerjunk.helps.ads.AdmobUtils
import com.test.easy.easycleanerjunk.view.AFunOb.APP_MANAGER
import com.test.easy.easycleanerjunk.view.AFunOb.DEVICE_SCAN
import com.test.easy.easycleanerjunk.view.AFunOb.JUNK_CLEANER
import com.test.easy.easycleanerjunk.view.AFunOb.LARGE_FILE_CLEANER
import com.test.easy.easycleanerjunk.view.AFunOb.NETWORK_TRAFFIC
import com.test.easy.easycleanerjunk.view.AFunOb.NOTIFICATION_CLEANER
import com.test.easy.easycleanerjunk.view.AFunOb.PHOTO_COMPRESS
import com.test.easy.easycleanerjunk.view.AFunOb.RECENT_APP_USAGE
import com.test.easy.easycleanerjunk.view.AFunOb.SCREENSHOT_CLEANER
import com.test.easy.easycleanerjunk.view.AFunOb.SIMILAR_PHOTOS
import com.test.easy.easycleanerjunk.view.XmlEx.inflate
......@@ -34,21 +29,10 @@ class ToolsAdapter(
ToolUI(LARGE_FILE_CLEANER, context.getString(R.string.large_file_cleaner), R.mipmap.t_large),
ToolUI(PHOTO_COMPRESS, context.getString(R.string.photo_compress), R.mipmap.t_photo),
ToolUI(SIMILAR_PHOTOS, context.getString(R.string.similar_photos), R.mipmap.t_similar),
ToolUI(APP_MANAGER, context.getString(R.string.app_manager), R.mipmap.t_appmanager),
)
),
ToolsUI(isAd = true),
ToolsUI(
tittle = "More",
tools = listOf(
ToolUI(NOTIFICATION_CLEANER, context.getString(R.string.notification_cleaner), R.mipmap.t_notification),
ToolUI(NETWORK_TRAFFIC, context.getString(R.string.network_traffic), R.mipmap.t_network),
ToolUI(RECENT_APP_USAGE, context.getString(R.string.recent_app_usage), R.mipmap.t_recent),
ToolUI(DEVICE_SCAN, context.getString(R.string.device_scan), R.mipmap.devicescan),
ToolUI(SCREENSHOT_CLEANER, context.getString(R.string.screenshot_cleaner), R.mipmap.screenshot)
)
),
ToolsUI(isAd = true),
)
override fun getItemViewType(position: Int): Int {
......
......@@ -39,15 +39,9 @@ data class ConfigBean(
companion object {
//功能触发push actionId 主动发送
const val ID_JUNK_CLEAN_PUSH = 11001 //清理垃圾
const val ID_BATTERY_PUSH = 11004// 电量信息
const val ID_LARGE_FILE_PUSH = 11006// 大文件清理
const val ID_DUPLICATE_FILE_PUSH = 11007//文件备份,重复文件,相似文件
const val ID_PHOTO_CLEAN_PUSH = 11009//清理相册
const val ID_PHOTO_COMPRESS = 11010//照片压缩
const val ID_APP_MANAGER = 11011//应用管理
const val ID_NETWORK_TRAFFIC = 11012//网络流量
const val ID_CLEAN_NOTIFICATION = 11013//清理通知栏
const val ID_RECENT_USE_APP = 11014//最近使用APP
const val ID_SIMILAR_IMAGE = 11015//清理相似图片
const val ID_SCREENSHOT_CLEAN = 12000//截图清理
......@@ -55,17 +49,9 @@ data class ConfigBean(
fun ConfigBean.getActionPushInterval(actionId: Int): Int {
val interval = when (actionId) {
ID_JUNK_CLEAN_PUSH -> push_interval_11001
ID_BATTERY_PUSH -> push_interval_11004
ID_LARGE_FILE_PUSH -> push_interval_11006
ID_DUPLICATE_FILE_PUSH -> push_interval_11007
ID_PHOTO_CLEAN_PUSH -> push_interval_11009
ID_PHOTO_COMPRESS -> push_interval_11010
ID_APP_MANAGER -> push_interval_11011
ID_NETWORK_TRAFFIC -> push_interval_11012
ID_CLEAN_NOTIFICATION -> push_interval_11013
ID_RECENT_USE_APP -> push_interval_11014
ID_SIMILAR_IMAGE -> push_interval_11015
ID_SCREENSHOT_CLEAN -> push_interval_12000
else -> 0
}
return interval
......
......@@ -15,13 +15,10 @@ import android.widget.RemoteViews
import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat
import com.test.easy.easycleanerjunk.R
import com.test.easy.easycleanerjunk.activity.AppManagerActivity
import com.test.easy.easycleanerjunk.activity.BatteryInfoActivity
import com.test.easy.easycleanerjunk.activity.ScanJunkActivity
import com.test.easy.easycleanerjunk.activity.home.NewMainActivity
import com.test.easy.easycleanerjunk.display.NotificationHelper.postActionNotification
import com.test.easy.easycleanerjunk.helps.BaseApplication
import com.test.easy.easycleanerjunk.helps.KotlinExt.string
import com.test.easy.easycleanerjunk.service.FlashlightService
......@@ -111,7 +108,7 @@ object NotificationUtils {
"Start foreground service."
)
val isOngoing = true //是否持续(为不消失的常驻通知)
val channelName = R.string.foreground_service_channel.string()
val channelName = context.resources.getString(R.string.foreground_service_channel)
val channelId = "Service_Id"
val category = Notification.CATEGORY_SERVICE
val contentView = RemoteViews(context.packageName, R.layout.reminder_layout_notification_notify)
......@@ -124,11 +121,11 @@ object NotificationUtils {
expendView.setOnClickPendingIntent(R.id.id_ll_clean, pendingIntent0)
val intent2 = Intent(context, BatteryInfoActivity::class.java)
val pendingIntent2 =
PendingIntent.getActivity(context, 0, intent2, PendingIntent.FLAG_IMMUTABLE)
contentView.setOnClickPendingIntent(R.id.id_battery, pendingIntent2)
expendView.setOnClickPendingIntent(R.id.id_battery, pendingIntent2)
// val intent2 = Intent(context, ::class.java)
// val pendingIntent2 =
// PendingIntent.getActivity(context, 0, intent2, PendingIntent.FLAG_IMMUTABLE)
// contentView.setOnClickPendingIntent(R.id.id_battery, pendingIntent2)
// expendView.setOnClickPendingIntent(R.id.id_battery, pendingIntent2)
val intent3 = Intent()
val serviceComponent = ComponentName(context, FlashlightService::class.java)
......@@ -138,11 +135,11 @@ object NotificationUtils {
contentView.setOnClickPendingIntent(R.id.id_lighit, pendingIntent3)
expendView.setOnClickPendingIntent(R.id.id_lighit, pendingIntent3)
val intent4 = Intent(context, AppManagerActivity::class.java)
val pendingIntent4 =
PendingIntent.getActivity(context, 0, intent4, PendingIntent.FLAG_IMMUTABLE)
contentView.setOnClickPendingIntent(R.id.id_app_manager, pendingIntent4)
expendView.setOnClickPendingIntent(R.id.id_app_manager, pendingIntent4)
// val intent4 = Intent(context, ::class.java)
// val pendingIntent4 =
// PendingIntent.getActivity(context, 0, intent4, PendingIntent.FLAG_IMMUTABLE)
// contentView.setOnClickPendingIntent(R.id.id_app_manager, pendingIntent4)
// expendView.setOnClickPendingIntent(R.id.id_app_manager, pendingIntent4)
val nfIntent = Intent(context, NewMainActivity::class.java)
val pendingIntent =
......@@ -184,10 +181,6 @@ object NotificationUtils {
val log = "isPush=$isPush " + "id=${id} "
Log.d(TAG, log)
if (isPush) {
// var extra: Int? = null
// if (id == ID_PHONE_ACCELERATE) {
// extra = RamMemoryEx.getMemoryUsage(BaseApplication.context).toInt()
// }
BaseApplication.context.postActionNotification(id, null, s)
}
}
......
package com.test.easy.easycleanerjunk.fragment
import android.annotation.SuppressLint
import android.app.AppOpsManager
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.provider.Settings
import android.view.View
import com.test.easy.easycleanerjunk.activity.AppManagerActivity
import com.test.easy.easycleanerjunk.adapter.AppListAdapter
import com.test.easy.easycleanerjunk.bean.AppBean
import com.test.easy.easycleanerjunk.databinding.FragmentAppListBinding
import com.test.easy.easycleanerjunk.helps.ActivityLauncher
import com.test.easy.easycleanerjunk.helps.BaseFragment
import com.test.easy.easycleanerjunk.helps.LogEx
import com.test.easy.easycleanerjunk.view.AppDetailDialog.showAppDetailDialog
import net.sourceforge.pinyin4j.PinyinHelper
import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType
import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat
import net.sourceforge.pinyin4j.format.HanyuPinyinToneType
import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination
/**
*/
class AppListFragment : BaseFragment<FragmentAppListBinding>() {
private val TAG = "AppListFragment"
private var adapter: AppListAdapter? = null
private var list = arrayListOf<AppBean>()
private var isRefreshData = false//是否需要更新数据
private lateinit var launcher: ActivityLauncher
private var type: Int = 0
var isAsc: Boolean = true
private var needPermission: Boolean = false
override val binding: FragmentAppListBinding by lazy {
FragmentAppListBinding.inflate(layoutInflater)
}
fun setInitData(
launcher: ActivityLauncher,
type: Int = 0,
isAsc: Boolean = true,
needPermission: Boolean = false
) {
this.launcher = launcher
this.type = type
this.isAsc = isAsc
this.needPermission = needPermission
}
@SuppressLint("SetTextI18n")
override fun setView() {
if (needPermission && !checkUsageAccessSettings(requireContext())) {
binding.flContent.visibility = View.GONE
binding.flPermission.visibility = View.VISIBLE
} else {
if (isRefreshData) {
binding.progressbar.visibility = View.GONE
}
initRv()
initData()
}
}
override fun setListener() {
binding.tvAuthorization.setOnClickListener {
val intent = Intent(Settings.ACTION_USAGE_ACCESS_SETTINGS)
intent.addCategory("android.intent.category.DEFAULT")
intent.data = Uri.parse("package:${requireActivity().packageName}")
launcher.launch(intent) {
LogEx.logDebug(TAG, "launcher callback")
(requireActivity() as AppManagerActivity).refreshUsageAccessData()
}
}
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
}
override fun onResume() {
super.onResume()
if (checkUsageAccessSettings(requireContext())) {
binding.flPermission.visibility = View.GONE
binding.flContent.visibility = View.VISIBLE
}
}
private fun initData() {
orderList()
adapter?.setData(list)
}
/**
* 更新数据不刷洗
*/
fun setData(dataList: List<AppBean>) {
list.clear()
list.addAll(dataList)
orderList()
}
/**
* 更新数据刷新
*/
@SuppressLint("NotifyDataSetChanged")
fun setDataRefresh(dataList: List<AppBean>) {
list.clear()
list.addAll(dataList)
orderList()
if (isVisible) {
if (adapter == null) {
initRv()
}
if (isRefreshData) {
binding.progressbar.visibility = View.GONE
}
adapter?.setData(list)
}
}
/**
* 刷洗fragment数据
*/
@SuppressLint("NotifyDataSetChanged")
fun refreshFragmentData(dataList: List<AppBean>, isRefresh: Boolean = false, index: Int = 0) {
isRefreshData = true
LogEx.logDebug(TAG, "isRefresh=$isRefresh isVisible=$isVisible index=$index")
if (isRefresh && isVisible) {
binding.flPermission.visibility = View.GONE
binding.progressbar.visibility = View.GONE
setDataRefresh(dataList)
} else {
setData(dataList)
}
}
fun showContent(isRefresh: Boolean = false) {
if (isRefresh) {
binding.flContent.visibility = View.VISIBLE
}
}
private fun initRv() {
adapter = AppListAdapter(itemClick = {
if (!(requireActivity() as AppManagerActivity).animationFinish) {
return@AppListAdapter
}
requireActivity().showAppDetailDialog(it, launcher) { unInstalled ->
if (unInstalled) {
adapter?.removeData(it)
otherAppRemove(it)
}
}
}, itemSelect = { selectList ->
showUnInstall(selectList)
})
binding.rv.adapter = adapter
}
private fun showUnInstall(selectList: List<AppBean>) {
(requireActivity() as AppManagerActivity).showUnInstall(selectList)
}
private fun orderList() {
when (type) {
APP_LIST_TYPE_NAME -> {
list.forEach {
it.pinYin = getPinyin(it.appName)
}
if (isAsc) {
list.sortBy { it.pinYin }
} else {
list.sortByDescending { it.pinYin }
}
}
APP_LIST_TYPE_INSTALL -> {
if (isAsc) {
list.sortBy { it.installTime }
} else {
list.sortByDescending { it.installTime }
}
}
APP_LIST_TYPE_SIZE -> {
if (isAsc) {
list.sortBy { it.appSize }
} else {
list.sortByDescending { it.appSize }
}
}
APP_LIST_TYPE_LAST_USE -> {
if (isAsc) {
list.sortBy { it.lastUsedTime }
} else {
list.sortByDescending { it.lastUsedTime }
}
}
}
}
/**
* 翻转顺序
*/
fun reverseOrder() {
isAsc = !isAsc
orderList()
adapter?.setData(list)
}
private fun otherAppRemove(appBean: AppBean) {
(requireActivity() as AppManagerActivity).otherPageRemove(appBean, this)
}
companion object {
const val APP_LIST_TYPE_NAME = 12
const val APP_LIST_TYPE_INSTALL = 15
const val APP_LIST_TYPE_SIZE = 19
const val APP_LIST_TYPE_LAST_USE = 123
}
/**
* 汉字转为拼音
* https://cloud.tencent.com/developer/article/1731852
* @return
*/
fun getPinyin(str: String): String {
val format = HanyuPinyinOutputFormat()
format.caseType = HanyuPinyinCaseType.UPPERCASE
format.toneType = HanyuPinyinToneType.WITHOUT_TONE
val sb = StringBuilder()
val strNoSpace = str.replace("\\s".toRegex(), "").trim()
// LogEx.logDebug(TAG, "strNoSpace=$strNoSpace")
val charArray = strNoSpace.toCharArray()
for (i in charArray.indices) {
val c = charArray[i]
// 如果是空格, 跳过
if (Character.isWhitespace(c)) {
continue
}
// LogEx.logDebug(TAG, "c.code=${c.code}")
if (c.code == -127 || c.code < 128) {
// 肯定不是汉字
sb.append(c)
} else {
var s: String? = ""
try {
// LogEx.logDebug(TAG, "c=$c")
// 通过char得到拼音集合. 单 - dan, shan
val array = PinyinHelper.toHanyuPinyinStringArray(c, format)
if (array.isNotEmpty()) {
s = array.first()
sb.append(s)
}
} catch (e: BadHanyuPinyinOutputFormatCombination) {
e.printStackTrace()
sb.append(s)
}
}
}
// LogEx.logDebug(TAG, "ping str=$sb")
return sb.toString()
}
private fun checkUsageAccessSettings(context: Context): Boolean {
val appOpsManager = context.getSystemService(Context.APP_OPS_SERVICE) as AppOpsManager
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
appOpsManager.unsafeCheckOpNoThrow(
AppOpsManager.OPSTR_GET_USAGE_STATS,
android.os.Process.myUid(),
context.packageName
) == AppOpsManager.MODE_ALLOWED
} else {
appOpsManager.checkOpNoThrow(
AppOpsManager.OPSTR_GET_USAGE_STATS,
android.os.Process.myUid(),
context.packageName
) == AppOpsManager.MODE_ALLOWED
}
}
}
\ No newline at end of file
......@@ -6,11 +6,7 @@ import android.content.Intent
import android.view.animation.LinearInterpolator
import android.widget.ScrollView
import androidx.core.view.updatePadding
import com.test.easy.easycleanerjunk.activity.AppManagerActivity
import com.test.easy.easycleanerjunk.activity.BatteryInfoActivity
import com.test.easy.easycleanerjunk.activity.LargeFileCleanActivity
import com.test.easy.easycleanerjunk.activity.NetWorkActivity
import com.test.easy.easycleanerjunk.activity.RecentAppActivity
import com.test.easy.easycleanerjunk.activity.RepeatPhotoActivity
import com.test.easy.easycleanerjunk.activity.ScanJunkActivity
import com.test.easy.easycleanerjunk.activity.SettingActivity
......@@ -18,7 +14,6 @@ import com.test.easy.easycleanerjunk.activity.photocompress.photo.StartCompressi
import com.test.easy.easycleanerjunk.databinding.FragmentLayoutHomeBinding
import com.test.easy.easycleanerjunk.helps.BaseFragment
import com.test.easy.easycleanerjunk.helps.KotlinExt.setOnClickListener
import com.test.easy.easycleanerjunk.helps.KotlinExt.toFormatSize
import com.test.easy.easycleanerjunk.notificationclean.NotificationGuestActivity
import com.test.easy.easycleanerjunk.utils.BarUtils
......@@ -83,25 +78,10 @@ class HomeFragment : BaseFragment<FragmentLayoutHomeBinding>() {
binding.idLargeFile.setOnClickListener {
startActivity(Intent(requireContext(), LargeFileCleanActivity::class.java))
}
binding.idAppManager.setOnClickListener {
startActivity(Intent(requireContext(), AppManagerActivity::class.java))
}
binding.idBatteryInfo.setOnClickListener {
startActivity(Intent(requireContext(), BatteryInfoActivity::class.java))
}
binding.idSimilarPhotos.setOnClickListener {
startActivity(Intent(requireContext(), RepeatPhotoActivity::class.java))
}
binding.idHomeNetwork.setOnClickListener {
startActivity(Intent(requireContext(), NetWorkActivity::class.java))
}
binding.idNotificationCleaner.setOnClickListener {
startActivity(Intent(requireActivity(), NotificationGuestActivity::class.java))
}
binding.idHomeRecent.setOnClickListener {
startActivity(Intent(requireContext(), RecentAppActivity::class.java))
}
binding.ivSetting.setOnClickListener {
startActivity(Intent(requireContext(), SettingActivity::class.java))
}
......
package com.test.easy.easycleanerjunk.fragment
import android.annotation.SuppressLint
import android.graphics.Typeface
import android.os.Bundle
import com.test.easy.easycleanerjunk.activity.RecentAppActivity
import com.test.easy.easycleanerjunk.adapter.RecentAppAdapter
import com.test.easy.easycleanerjunk.adapter.RecentAppAdapter.Companion.UI_SCREEN_TIME_MODE
import com.test.easy.easycleanerjunk.bean.AppBean
import com.test.easy.easycleanerjunk.databinding.FragmentScreenTimeBinding
import com.test.easy.easycleanerjunk.helps.BaseFragment
import com.test.easy.easycleanerjunk.helps.TimeUtils.PAST_60_MINUS_QUERY
import com.test.easy.easycleanerjunk.helps.TimeUtils.SEVEN_DAYS_QUERY
import com.test.easy.easycleanerjunk.helps.TimeUtils.TODAY_QUERY
import com.test.easy.easycleanerjunk.helps.TimeUtils.YESTERDAY_QUERY
import com.test.easy.easycleanerjunk.view.TimeSelectDialog.showTimeSelectDialog
import java.text.SimpleDateFormat
import kotlin.time.Duration.Companion.hours
import kotlin.time.DurationUnit
/**
*/
class ScreenTimeFragment : BaseFragment<FragmentScreenTimeBinding>() {
private var simpleDateFormat2 = SimpleDateFormat("(yyyy/MM/dd)")
private lateinit var adapter: RecentAppAdapter
private val dataList = arrayListOf<AppBean>()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
}
override val binding: FragmentScreenTimeBinding by lazy {
FragmentScreenTimeBinding.inflate(layoutInflater)
}
override fun setView() {
setTextFont()
binding.llDate.setOnClickListener {
requireContext().showTimeSelectDialog {
when (it) {
PAST_60_MINUS_QUERY -> {
recent60UI()
}
TODAY_QUERY -> {
todayUI()
}
YESTERDAY_QUERY -> {
yesterdayUI()
}
SEVEN_DAYS_QUERY -> {
sevenDaysUI()
}
}
}
}
adapter = RecentAppAdapter(requireActivity(), UI_SCREEN_TIME_MODE)
binding.rv.adapter = adapter
adapter.setData(dataList)
todayUI(false)
}
private fun setTextFont() {
val fontMedium = "sans-serif-medium"
val fontMediumTypeface = Typeface.create(fontMedium, Typeface.NORMAL)
binding.tvDate.setTypeface(fontMediumTypeface)
}
@SuppressLint("SetTextI18n")
fun todayUI(isReFresh: Boolean = true) {
binding.tvDate.text = "Today" + simpleDateFormat2.format(System.currentTimeMillis())
if (isReFresh) {
(requireActivity() as RecentAppActivity).changeTimeRefresh(TODAY_QUERY, 1)
}
}
@SuppressLint("SetTextI18n")
fun recent60UI(isReFresh: Boolean = true) {
binding.tvDate.text = "Recent 60 minus"
if (isReFresh) {
(requireActivity() as RecentAppActivity).changeTimeRefresh(PAST_60_MINUS_QUERY, 1)
}
}
@SuppressLint("SetTextI18n")
fun yesterdayUI(isReFresh: Boolean = true) {
binding.tvDate.text =
"Yesterday" + simpleDateFormat2.format(
System.currentTimeMillis() - 24.hours.toLong(
DurationUnit.MILLISECONDS
)
)
if (isReFresh) {
(requireActivity() as RecentAppActivity).changeTimeRefresh(YESTERDAY_QUERY, 1)
}
}
@SuppressLint("SetTextI18n")
fun sevenDaysUI(isReFresh: Boolean = true) {
binding.tvDate.text = "Last 7 days"
if (isReFresh) {
(requireActivity() as RecentAppActivity).changeTimeRefresh(SEVEN_DAYS_QUERY, 1)
}
}
fun setScreenData(dataList: ArrayList<AppBean>) {
this.dataList.clear()
this.dataList.addAll(dataList.filter { it.screenTime > 0 })
if (isVisible) {
adapter.setData(this.dataList)
}
}
override fun onResume() {
super.onResume()
}
}
\ No newline at end of file
package com.test.easy.easycleanerjunk.fragment
import android.content.Intent
import com.test.easy.easycleanerjunk.activity.AppManagerActivity
import com.test.easy.easycleanerjunk.activity.BatteryInfoActivity
import com.test.easy.easycleanerjunk.activity.DeviceScanInfoActivity
import com.test.easy.easycleanerjunk.activity.LargeFileCleanActivity
import com.test.easy.easycleanerjunk.activity.NetWorkActivity
import com.test.easy.easycleanerjunk.activity.RecentAppActivity
import com.test.easy.easycleanerjunk.activity.RepeatPhotoActivity
import com.test.easy.easycleanerjunk.activity.ScanJunkActivity
import com.test.easy.easycleanerjunk.activity.ScreenShotActivity
import com.test.easy.easycleanerjunk.activity.photocompress.photo.StartCompressionPhotoActivity
import com.test.easy.easycleanerjunk.adapter.ToolsAdapter
import com.test.easy.easycleanerjunk.databinding.FragmentLayoutTools1Binding
import com.test.easy.easycleanerjunk.helps.BaseFragment
import com.test.easy.easycleanerjunk.notificationclean.NotificationGuestActivity
import com.test.easy.easycleanerjunk.view.AFunOb
import com.test.easy.easycleanerjunk.view.AFunOb.APP_MANAGER
import com.test.easy.easycleanerjunk.view.AFunOb.BATTERY_INFO
import com.test.easy.easycleanerjunk.view.AFunOb.DEVICE_SCAN
import com.test.easy.easycleanerjunk.view.AFunOb.LARGE_FILE_CLEANER
import com.test.easy.easycleanerjunk.view.AFunOb.NETWORK_TRAFFIC
import com.test.easy.easycleanerjunk.view.AFunOb.NOTIFICATION_CLEANER
import com.test.easy.easycleanerjunk.view.AFunOb.PHOTO_COMPRESS
import com.test.easy.easycleanerjunk.view.AFunOb.RECENT_APP_USAGE
import com.test.easy.easycleanerjunk.view.AFunOb.SCREENSHOT_CLEANER
import com.test.easy.easycleanerjunk.view.AFunOb.SIMILAR_PHOTOS
class ToolsFragment : BaseFragment<FragmentLayoutTools1Binding>() {
......@@ -41,25 +27,13 @@ class ToolsFragment : BaseFragment<FragmentLayoutTools1Binding>() {
startActivity(Intent(requireContext(), ScanJunkActivity::class.java))
}
RECENT_APP_USAGE -> {
startActivity(Intent(requireActivity(), RecentAppActivity::class.java))
}
LARGE_FILE_CLEANER -> {
startActivity(Intent(requireContext(), LargeFileCleanActivity::class.java))
}
NOTIFICATION_CLEANER -> {
startActivity(Intent(requireActivity(), NotificationGuestActivity::class.java))
}
NETWORK_TRAFFIC -> {
startActivity(Intent(requireContext(), NetWorkActivity::class.java))
}
APP_MANAGER -> {
startActivity(Intent(requireContext(), AppManagerActivity::class.java))
}
SIMILAR_PHOTOS -> {
startActivity(Intent(requireContext(), RepeatPhotoActivity::class.java))
......@@ -68,19 +42,6 @@ class ToolsFragment : BaseFragment<FragmentLayoutTools1Binding>() {
PHOTO_COMPRESS -> {
startActivity(Intent(requireActivity(), StartCompressionPhotoActivity::class.java))
}
BATTERY_INFO -> {
startActivity(Intent(requireActivity(), BatteryInfoActivity::class.java))
}
DEVICE_SCAN -> {
startActivity(Intent(requireActivity(), DeviceScanInfoActivity::class.java))
}
SCREENSHOT_CLEANER -> {
startActivity(Intent(requireActivity(), ScreenShotActivity::class.java))
}
}
}
binding.rvTools.adapter = adapter
......
......@@ -2,20 +2,9 @@ package com.test.easy.easycleanerjunk.view
object AFunOb {
const val JUNK_CLEANER = "Junk Cleaner"//垃圾清理
const val RECENT_APP_USAGE = "Recent App Usage"//最近使用
const val LARGE_FILE_CLEANER = "Large File Cleaner"//大文件
const val NOTIFICATION_CLEANER = "Notification Cleaner"
const val NETWORK_TRAFFIC = "Network Traffic"
const val APP_MANAGER = "App Manager"
const val BATTERY_INFO = "Battery Info"
const val EMPTY_FILE_CLEANER = "Empty File Cleaner"
const val SIMILAR_PHOTOS = "Similar Photos"
const val SPEAK_CLEANER = "Speaker Cleaner"
const val PHOTO_COMPRESS = "Photo Compress"
const val APP_LOCK = "App Lock"
const val APP_SPEED = "App Speed"
const val BATTERY_OPTIMIZER = "Battery Optimizer"
const val DEVICE_SCAN = "Device Scan"
const val SCREENSHOT_CLEANER = "Screenshot Cleaner"
}
\ No newline at end of file
......@@ -14,7 +14,6 @@ import android.view.View
import android.view.ViewGroup
import com.google.android.material.bottomsheet.BottomSheetDialog
import com.test.easy.easycleanerjunk.R
import com.test.easy.easycleanerjunk.activity.PermissionManagerActivity
import com.test.easy.easycleanerjunk.bean.AppBean
import com.test.easy.easycleanerjunk.bean.AppBean.Companion.appBeanGson
import com.test.easy.easycleanerjunk.databinding.DialogAppDetailBinding
......@@ -106,15 +105,6 @@ object AppDetailDialog {
startActivity(intent)
}
}
binding.tvPermissionCheck.setOnClickListener {
dialog.dismiss()
val newIntent = Intent(this, PermissionManagerActivity::class.java)
val json = appBeanGson.toJson(appBean)
newIntent.putExtra("AppBean", json)
startActivity(newIntent)
}
binding.tvUninstall.setOnClickListener {
dialog.dismiss()
......
......@@ -65,37 +65,6 @@
app:trackTint="@color/color_switch_track_selector" />
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_marginHorizontal="16dp"
android:layout_marginTop="20dp"
app:cardBackgroundColor="@color/white"
app:cardCornerRadius="15dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="12dp"
android:text="All Notification Messages"
android:textColor="@color/black"
android:textSize="16sp"
tools:ignore="HardcodedText" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/switch_all_notification"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|end"
android:layout_marginEnd="15dp"
android:layout_marginBottom="5dp"
android:thumb="@drawable/bg_switch_thumb_ffffff"
app:thumbTint="@color/white"
app:track="@drawable/bg_switch_track"
app:trackTint="@color/color_switch_track_selector" />
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
......
......@@ -195,20 +195,6 @@
android:textSize="14sp" />
<TextView
android:id="@+id/tv_permission_check"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"
android:clickable="true"
android:focusable="true"
android:paddingHorizontal="20dp"
android:paddingVertical="10dp"
android:text="@string/permission_check"
android:textColor="#000000"
android:textSize="14sp" />
<TextView
android:id="@+id/tv_uninstall"
android:layout_width="match_parent"
......
......@@ -309,6 +309,7 @@
<com.noober.background.view.BLLinearLayout
android:id="@+id/id_app_manager"
android:layout_width="0dp"
android:visibility="invisible"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_horizontal"
......@@ -355,6 +356,7 @@
<com.noober.background.view.BLLinearLayout
android:id="@+id/id_battery_info"
android:layout_width="0dp"
android:visibility="invisible"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_horizontal"
......@@ -402,153 +404,6 @@
</androidx.appcompat.widget.LinearLayoutCompat>
</com.noober.background.view.BLLinearLayout>
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="17dp"
android:layout_marginTop="17dp"
android:layout_marginBottom="17dp"
android:gravity="center_vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="More Tools"
android:textColor="#000000"
android:textSize="19sp"
android:textStyle="bold"
tools:ignore="HardcodedText" />
</androidx.appcompat.widget.LinearLayoutCompat>
<com.noober.background.view.BLLinearLayout
android:id="@+id/id_home_network"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="12dp"
android:layout_marginBottom="12dp"
android:elevation="0dp"
android:gravity="center_vertical"
android:paddingHorizontal="12dp"
android:paddingVertical="16dp"
android:visibility="visible"
app:bl_corners_radius="10dp"
app:bl_solid_color="#F8F8F8">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxHeight="27dp"
android:minHeight="27dp"
android:src="@mipmap/h_network"
tools:ignore="ContentDescription" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_weight="1"
android:text="Network Traffic"
android:textColor="#000000"
android:textSize="13sp"
android:textStyle="bold"
tools:ignore="HardcodedText" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:src="@mipmap/h_jiantou"
tools:ignore="ContentDescription" />
</com.noober.background.view.BLLinearLayout>
<com.noober.background.view.BLLinearLayout
android:id="@+id/id_home_recent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="12dp"
android:layout_marginBottom="12dp"
android:elevation="0dp"
android:gravity="center_vertical"
android:paddingHorizontal="12dp"
android:paddingVertical="16dp"
android:visibility="visible"
app:bl_corners_radius="10dp"
app:bl_solid_color="#F8F8F8">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minWidth="27dp"
android:minHeight="27dp"
android:src="@mipmap/h_recentapp"
tools:ignore="ContentDescription" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_weight="1"
android:text="Recent App Usage"
android:textColor="#000000"
android:textSize="13sp"
android:textStyle="bold"
tools:ignore="HardcodedText" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:src="@mipmap/h_jiantou"
tools:ignore="ContentDescription" />
</com.noober.background.view.BLLinearLayout>
<com.noober.background.view.BLLinearLayout
android:id="@+id/id_notification_cleaner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="12dp"
android:layout_marginBottom="12dp"
android:elevation="0dp"
android:gravity="center_vertical"
android:paddingHorizontal="12dp"
android:paddingVertical="16dp"
android:visibility="visible"
app:bl_corners_radius="10dp"
app:bl_solid_color="#F8F8F8">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minWidth="27dp"
android:minHeight="27dp"
android:src="@mipmap/h_notification"
tools:ignore="ContentDescription" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_weight="1"
android:text="Notification Cleaner"
android:textColor="#000000"
android:textSize="13sp"
android:textStyle="bold"
tools:ignore="HardcodedText" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:src="@mipmap/h_jiantou"
tools:ignore="ContentDescription" />
</com.noober.background.view.BLLinearLayout>
</androidx.appcompat.widget.LinearLayoutCompat>
</androidx.core.widget.NestedScrollView>
......
......@@ -33,85 +33,6 @@
tools:ignore="HardcodedText" />
</LinearLayout>
<!--病毒-->
<LinearLayout
android:id="@+id/id_ll_virus"
android:layout_width="0dp"
android:visibility="gone"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical"
tools:ignore="UseCompoundDrawables">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:src="@drawable/saomiao"
tools:ignore="ContentDescription" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Virus"
android:textColor="#666666"
android:textSize="12sp"
tools:ignore="HardcodedText" />
</LinearLayout>
<!--app管理-->
<LinearLayout
android:id="@+id/id_app_manager"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical"
tools:ignore="UseCompoundDrawables">
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginBottom="8dp"
android:src="@drawable/guanli"
tools:ignore="ContentDescription" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Manager"
android:textColor="#666666"
android:textSize="12sp"
tools:ignore="HardcodedText" />
</LinearLayout>
<!--电池-->
<LinearLayout
android:id="@+id/id_battery"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical"
tools:ignore="UseCompoundDrawables">
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginBottom="8dp"
android:src="@drawable/dianchi"
tools:ignore="ContentDescription" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Battery"
android:textColor="#666666"
android:textSize="12sp"
tools:ignore="HardcodedText" />
</LinearLayout>
<!--手电-->
<LinearLayout
android:id="@+id/id_lighit"
......
......@@ -24,58 +24,6 @@
tools:ignore="ContentDescription" />
</LinearLayout>
<!--病毒-->
<LinearLayout
android:id="@+id/id_ll_virus"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:visibility="gone"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
android:src="@drawable/saomiao" />
</LinearLayout>
<!--app管理-->
<LinearLayout
android:id="@+id/id_app_manager"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginBottom="4dp"
android:src="@drawable/guanli"
tools:ignore="ContentDescription" />
</LinearLayout>
<!--电池-->
<LinearLayout
android:id="@+id/id_battery"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginBottom="4dp"
android:src="@drawable/dianchi"
tools:ignore="ContentDescription" />
</LinearLayout>
<!--手电-->
<LinearLayout
android:id="@+id/id_lighit"
......
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