Commit ca631f9d authored by wanglei's avatar wanglei

直接复制拆包大法

parent 8eb149d9
Pipeline #1082 canceled with stages
*.iml
/local.properties
/.gradle
/.idea
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
/gradle/wrapper.gradle-wrapper.jar
......@@ -95,7 +95,7 @@ class ActionBroadcast : BroadcastReceiver() {
val isPushCfg = PushManager.isPush(ID_LOW_BATTERY_PUSH)
if (flag2 && isPushCfg) {
FileApp.fContext.postActionNotification(ID_LOW_BATTERY_PUSH)
FileApp.fContext.postActionNotification(ID_LOW_BATTERY_PUSH, extra = level)
}
}
}
......@@ -103,34 +103,4 @@ class ActionBroadcast : BroadcastReceiver() {
}
}
fun lowJunkPush(context: Context) {
val activityManager = context.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
val memoryInfo = ActivityManager.MemoryInfo()
activityManager.getMemoryInfo(memoryInfo)
val availableMemory = memoryInfo.availMem
val totalMemory = memoryInfo.totalMem
val num = totalMemory - availableMemory
val entity = ComUtils.getPushTypeData("22005")
if (num >= (entity?.feature_ex1 ?: 0)) {
// 展示性能变差推送
val flag = PushManager.isPush(PushCfg.ID_LOW_RAM_PUSH)
if (flag) {
FileApp.fContext.postActionNotification(ID_LOW_RAM_PUSH)
}
}
}
fun charging(intent: Intent?) {
//电量发生变化
val level = intent?.getIntExtra(BatteryManager.EXTRA_LEVEL, -1) ?: -1
val scale: Int? = intent?.getIntExtra(BatteryManager.EXTRA_SCALE, -1)
//低电量阀值推送
val config = ComUtils.getPushTypeData(ID_LOW_BATTERY_PUSH.toString())
val flag = PushManager.isPush(ID_LOW_BATTERY_PUSH)
val lowValue = config?.feature_ex1 ?: 0
if (flag && (level < lowValue)) {
FileApp.fContext.postActionNotification(ID_LOW_BATTERY_PUSH)
}
}
}
\ No newline at end of file
......@@ -150,9 +150,10 @@ object NotificationHelper {
/**
* 发送通知对于
* @param extra 额外参数
*/
@SuppressLint("RemoteViewLayout")
fun Context.postActionNotification(actionId: Int, eventParams: EventParams? = null) {
fun Context.postActionNotification(actionId: Int, eventParams: EventParams? = null, extra: Int? = null) {
val remoteViews = RemoteViews(packageName, R.layout.notification_common)
......@@ -247,13 +248,13 @@ object NotificationHelper {
ID_LOW_BATTERY_PUSH -> {
remoteViews.setImageViewResource(R.id.iv_icon, R.mipmap.dianliangdi)
remoteViews.setTextViewText(R.id.tv_desc, "The battery is less than 50%, view the battery information")
remoteViews.setTextViewText(R.id.tv_desc, "The battery is $extra%, view the battery information")
remoteViews.setTextViewText(R.id.tv_btn, "View")
}
ID_LOW_RAM_PUSH -> {
remoteViews.setImageViewResource(R.id.iv_icon, R.mipmap.neicundi)
remoteViews.setTextViewText(R.id.tv_desc, "Ram usage reached 60%, optimize now!")
remoteViews.setTextViewText(R.id.tv_desc, "Ram usage reached $extra%, optimize now!")
remoteViews.setTextViewText(R.id.tv_btn, "Optimize")
}
......
package com.zxhyis.toolss.common.notification
import android.content.Context
import com.zxhyis.toolss.FileApp
import com.zxhyis.toolss.ad.EventHelper
import com.zxhyis.toolss.ad.PushManager
......@@ -12,7 +11,6 @@ import com.zxhyis.toolss.ad.queryDataStoreBlock
import com.zxhyis.toolss.common.notification.NotificationHelper.postActionNotification
import com.zxhyis.toolss.logic.LogEx
import com.zxhyis.toolss.logic.RamMemoryEx
import com.zxhyis.toolss.logic.toast
import java.util.TimerTask
import kotlin.time.Duration.Companion.minutes
import kotlin.time.DurationUnit
......@@ -31,12 +29,13 @@ class NotificationTimerTask(val eventParams: EventParams?) : TimerTask() {
fun oneShotNotification(noLimit: Boolean = false) {
//内存低于阀值推送
val flag = postRamLower60()
if (flag) {
val log = "postRamLower60 isPush=$flag"
EventHelper.event("pushCircleOrder_isPush", log, eventParams = eventParams)
val extra = RamMemoryEx.getMemoryUsage(FileApp.fContext).toInt()
FileApp.fContext.postActionNotification(ID_LOW_RAM_PUSH, eventParams, extra)
return
}
......
......@@ -10,6 +10,7 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.ViewManager
import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment
import com.zxhyis.toolss.R
......@@ -53,7 +54,7 @@ class LaunchesFragment : Fragment(), ReportInterface {
super.onViewCreated(view, savedInstanceState)
setTextFont()
adapter = RecentAppAdapter(requireActivity(),RecentAppAdapter.UI_LAUNCHES_MODE)
adapter = RecentAppAdapter(requireActivity(), RecentAppAdapter.UI_LAUNCHES_MODE)
binding.rv.adapter = adapter
binding.clLaunches.setOnClick(javaClass.simpleName) {
......@@ -92,13 +93,19 @@ class LaunchesFragment : Fragment(), ReportInterface {
todayUI(false)
pageReport()
LogEx.logDebug(TAG, "onViewCreated")
}
override fun onResume() {
super.onResume()
LogEx.logDebug(TAG, "onResume")
}
@SuppressLint("SetTextI18n")
fun todayUI(isReFresh: Boolean = true) {
binding.tvDate.text = "Today" + simpleDateFormat2.format(System.currentTimeMillis())
if (isReFresh) {
(requireActivity() as RecentAppActivity).changeTimeRefresh(AppViewModel.TODAY_QUERY)
(requireActivity() as RecentAppActivity).changeTimeRefresh(AppViewModel.TODAY_QUERY, 0)
}
}
......@@ -106,7 +113,7 @@ class LaunchesFragment : Fragment(), ReportInterface {
fun recent60UI(isReFresh: Boolean = true) {
binding.tvDate.text = "Recent 60 minus"
if (isReFresh) {
(requireActivity() as RecentAppActivity).changeTimeRefresh(AppViewModel.PAST_60_MINUS_QUERY)
(requireActivity() as RecentAppActivity).changeTimeRefresh(AppViewModel.PAST_60_MINUS_QUERY, 0)
}
}
......@@ -115,7 +122,7 @@ class LaunchesFragment : Fragment(), ReportInterface {
binding.tvDate.text =
"Yesterday" + simpleDateFormat2.format(System.currentTimeMillis() - 24.hours.toLong(DurationUnit.MILLISECONDS))
if (isReFresh) {
(requireActivity() as RecentAppActivity).changeTimeRefresh(AppViewModel.YESTERDAY_QUERY)
(requireActivity() as RecentAppActivity).changeTimeRefresh(AppViewModel.YESTERDAY_QUERY,0)
}
}
......@@ -123,7 +130,7 @@ class LaunchesFragment : Fragment(), ReportInterface {
fun sevenDaysUI(isReFresh: Boolean = true) {
binding.tvDate.text = "Last 7 days"
if (isReFresh) {
(requireActivity() as RecentAppActivity).changeTimeRefresh(AppViewModel.SEVEN_DAYS_QUERY)
(requireActivity() as RecentAppActivity).changeTimeRefresh(AppViewModel.SEVEN_DAYS_QUERY,0)
}
}
......@@ -287,7 +294,11 @@ class LaunchesFragment : Fragment(), ReportInterface {
binding.tvDate.setTypeface(fontMediumTypeface)
}
/**
* 更新数据
*/
fun setAppUseData(dataList: List<AppBean>) {
LogEx.logDebug(TAG, "setAppUseData")
this.dataList.clear()
this.dataList.addAll(dataList)
//setLaunchNumber()
......
......@@ -142,7 +142,7 @@ class RecentAppActivity : AppCompatActivity(), ReportInterface {
//更新UI数据
launch(Dispatchers.Main) {
updateFragmentData()
updateFragmentData(0, 1)
}
}
}
......@@ -171,12 +171,17 @@ class RecentAppActivity : AppCompatActivity(), ReportInterface {
}
private fun updateFragmentData() {
val launchesFragment = pages[0] as LaunchesFragment
val screenTimeFragment = pages[1] as ScreenTimeFragment
private fun updateFragmentData(vararg position: Int) {
if (position.contains(0)) {
val launchesFragment = pages[0] as LaunchesFragment
launchesFragment.setAppUseData(dataList)
}
if (position.contains(1)) {
val screenTimeFragment = pages[1] as ScreenTimeFragment
screenTimeFragment.setScreenData(dataList)
}
launchesFragment.setAppUseData(dataList)
screenTimeFragment.setScreenData(dataList)
}
private fun setScreenTimeData(queryTime: Int = TODAY_QUERY) {
......@@ -209,16 +214,16 @@ class RecentAppActivity : AppCompatActivity(), ReportInterface {
if (hashMap.keys.contains(app.pkg)) {
val value = hashMap[app.pkg]
if (value != null) {
val tempList = arrayListOf<UsageEvents.Event>()
tempList.addAll(value)
app.usageEvents?.also { evens -> tempList.addAll(evens) }
app.usageEvents = tempList
val tempList2 = arrayListOf<UsageEvents.Event>()
tempList2.addAll(value)
app.usageEvents?.also { evens -> tempList2.addAll(evens) }
app.usageEvents = tempList2
}
}
}
}
fun changeTimeRefresh(queryTime: Int) {
fun changeTimeRefresh(queryTime: Int, fragmentPosition: Int) {
lifecycleScope.launch(Dispatchers.IO) {
initAppData()
......@@ -229,7 +234,7 @@ class RecentAppActivity : AppCompatActivity(), ReportInterface {
setScreenTimeData(queryTime)
//更新UI数据
launch(Dispatchers.Main) { updateFragmentData() }
launch(Dispatchers.Main) { updateFragmentData(fragmentPosition) }
}
}
......
......@@ -86,7 +86,6 @@ class ScreenTimeFragment : Fragment(), ReportInterface {
todayUI(false)
// initChart()
pageReport()
adapter.setData(this.dataList)
}
private fun initChart() {
......@@ -158,7 +157,7 @@ class ScreenTimeFragment : Fragment(), ReportInterface {
fun todayUI(isReFresh: Boolean = true) {
binding.tvDate.text = "Today" + simpleDateFormat2.format(System.currentTimeMillis())
if (isReFresh) {
(requireActivity() as RecentAppActivity).changeTimeRefresh(AppViewModel.TODAY_QUERY)
(requireActivity() as RecentAppActivity).changeTimeRefresh(AppViewModel.TODAY_QUERY, 1)
}
}
......@@ -166,7 +165,7 @@ class ScreenTimeFragment : Fragment(), ReportInterface {
fun recent60UI(isReFresh: Boolean = true) {
binding.tvDate.text = "Recent 60 minus"
if (isReFresh) {
(requireActivity() as RecentAppActivity).changeTimeRefresh(AppViewModel.PAST_60_MINUS_QUERY)
(requireActivity() as RecentAppActivity).changeTimeRefresh(AppViewModel.PAST_60_MINUS_QUERY, 1)
}
}
......@@ -179,7 +178,7 @@ class ScreenTimeFragment : Fragment(), ReportInterface {
)
)
if (isReFresh) {
(requireActivity() as RecentAppActivity).changeTimeRefresh(AppViewModel.YESTERDAY_QUERY)
(requireActivity() as RecentAppActivity).changeTimeRefresh(AppViewModel.YESTERDAY_QUERY, 1)
}
}
......@@ -187,7 +186,7 @@ class ScreenTimeFragment : Fragment(), ReportInterface {
fun sevenDaysUI(isReFresh: Boolean = true) {
binding.tvDate.text = "Last 7 days"
if (isReFresh) {
(requireActivity() as RecentAppActivity).changeTimeRefresh(AppViewModel.SEVEN_DAYS_QUERY)
(requireActivity() as RecentAppActivity).changeTimeRefresh(AppViewModel.SEVEN_DAYS_QUERY, 1)
}
}
......
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