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() { ...@@ -95,7 +95,7 @@ class ActionBroadcast : BroadcastReceiver() {
val isPushCfg = PushManager.isPush(ID_LOW_BATTERY_PUSH) val isPushCfg = PushManager.isPush(ID_LOW_BATTERY_PUSH)
if (flag2 && isPushCfg) { 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() { ...@@ -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 { ...@@ -150,9 +150,10 @@ object NotificationHelper {
/** /**
* 发送通知对于 * 发送通知对于
* @param extra 额外参数
*/ */
@SuppressLint("RemoteViewLayout") @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) val remoteViews = RemoteViews(packageName, R.layout.notification_common)
...@@ -247,13 +248,13 @@ object NotificationHelper { ...@@ -247,13 +248,13 @@ object NotificationHelper {
ID_LOW_BATTERY_PUSH -> { ID_LOW_BATTERY_PUSH -> {
remoteViews.setImageViewResource(R.id.iv_icon, R.mipmap.dianliangdi) 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") remoteViews.setTextViewText(R.id.tv_btn, "View")
} }
ID_LOW_RAM_PUSH -> { ID_LOW_RAM_PUSH -> {
remoteViews.setImageViewResource(R.id.iv_icon, R.mipmap.neicundi) 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") remoteViews.setTextViewText(R.id.tv_btn, "Optimize")
} }
......
package com.zxhyis.toolss.common.notification package com.zxhyis.toolss.common.notification
import android.content.Context
import com.zxhyis.toolss.FileApp import com.zxhyis.toolss.FileApp
import com.zxhyis.toolss.ad.EventHelper import com.zxhyis.toolss.ad.EventHelper
import com.zxhyis.toolss.ad.PushManager import com.zxhyis.toolss.ad.PushManager
...@@ -12,7 +11,6 @@ import com.zxhyis.toolss.ad.queryDataStoreBlock ...@@ -12,7 +11,6 @@ import com.zxhyis.toolss.ad.queryDataStoreBlock
import com.zxhyis.toolss.common.notification.NotificationHelper.postActionNotification import com.zxhyis.toolss.common.notification.NotificationHelper.postActionNotification
import com.zxhyis.toolss.logic.LogEx import com.zxhyis.toolss.logic.LogEx
import com.zxhyis.toolss.logic.RamMemoryEx import com.zxhyis.toolss.logic.RamMemoryEx
import com.zxhyis.toolss.logic.toast
import java.util.TimerTask import java.util.TimerTask
import kotlin.time.Duration.Companion.minutes import kotlin.time.Duration.Companion.minutes
import kotlin.time.DurationUnit import kotlin.time.DurationUnit
...@@ -31,12 +29,13 @@ class NotificationTimerTask(val eventParams: EventParams?) : TimerTask() { ...@@ -31,12 +29,13 @@ class NotificationTimerTask(val eventParams: EventParams?) : TimerTask() {
fun oneShotNotification(noLimit: Boolean = false) { fun oneShotNotification(noLimit: Boolean = false) {
//内存低于阀值推送 //内存低于阀值推送
val flag = postRamLower60() val flag = postRamLower60()
if (flag) { if (flag) {
val log = "postRamLower60 isPush=$flag" val log = "postRamLower60 isPush=$flag"
EventHelper.event("pushCircleOrder_isPush", log, eventParams = eventParams) EventHelper.event("pushCircleOrder_isPush", log, eventParams = eventParams)
val extra = RamMemoryEx.getMemoryUsage(FileApp.fContext).toInt()
FileApp.fContext.postActionNotification(ID_LOW_RAM_PUSH, eventParams, extra)
return return
} }
......
...@@ -10,6 +10,7 @@ import android.os.Bundle ...@@ -10,6 +10,7 @@ import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.view.ViewManager
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import com.zxhyis.toolss.R import com.zxhyis.toolss.R
...@@ -53,7 +54,7 @@ class LaunchesFragment : Fragment(), ReportInterface { ...@@ -53,7 +54,7 @@ class LaunchesFragment : Fragment(), ReportInterface {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
setTextFont() setTextFont()
adapter = RecentAppAdapter(requireActivity(),RecentAppAdapter.UI_LAUNCHES_MODE) adapter = RecentAppAdapter(requireActivity(), RecentAppAdapter.UI_LAUNCHES_MODE)
binding.rv.adapter = adapter binding.rv.adapter = adapter
binding.clLaunches.setOnClick(javaClass.simpleName) { binding.clLaunches.setOnClick(javaClass.simpleName) {
...@@ -92,13 +93,19 @@ class LaunchesFragment : Fragment(), ReportInterface { ...@@ -92,13 +93,19 @@ class LaunchesFragment : Fragment(), ReportInterface {
todayUI(false) todayUI(false)
pageReport() pageReport()
LogEx.logDebug(TAG, "onViewCreated")
}
override fun onResume() {
super.onResume()
LogEx.logDebug(TAG, "onResume")
} }
@SuppressLint("SetTextI18n") @SuppressLint("SetTextI18n")
fun todayUI(isReFresh: Boolean = true) { fun todayUI(isReFresh: Boolean = true) {
binding.tvDate.text = "Today" + simpleDateFormat2.format(System.currentTimeMillis()) binding.tvDate.text = "Today" + simpleDateFormat2.format(System.currentTimeMillis())
if (isReFresh) { 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 { ...@@ -106,7 +113,7 @@ class LaunchesFragment : Fragment(), ReportInterface {
fun recent60UI(isReFresh: Boolean = true) { fun recent60UI(isReFresh: Boolean = true) {
binding.tvDate.text = "Recent 60 minus" binding.tvDate.text = "Recent 60 minus"
if (isReFresh) { 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 { ...@@ -115,7 +122,7 @@ class LaunchesFragment : Fragment(), ReportInterface {
binding.tvDate.text = binding.tvDate.text =
"Yesterday" + simpleDateFormat2.format(System.currentTimeMillis() - 24.hours.toLong(DurationUnit.MILLISECONDS)) "Yesterday" + simpleDateFormat2.format(System.currentTimeMillis() - 24.hours.toLong(DurationUnit.MILLISECONDS))
if (isReFresh) { 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 { ...@@ -123,7 +130,7 @@ class LaunchesFragment : Fragment(), ReportInterface {
fun sevenDaysUI(isReFresh: Boolean = true) { fun sevenDaysUI(isReFresh: Boolean = true) {
binding.tvDate.text = "Last 7 days" binding.tvDate.text = "Last 7 days"
if (isReFresh) { 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 { ...@@ -287,7 +294,11 @@ class LaunchesFragment : Fragment(), ReportInterface {
binding.tvDate.setTypeface(fontMediumTypeface) binding.tvDate.setTypeface(fontMediumTypeface)
} }
/**
* 更新数据
*/
fun setAppUseData(dataList: List<AppBean>) { fun setAppUseData(dataList: List<AppBean>) {
LogEx.logDebug(TAG, "setAppUseData")
this.dataList.clear() this.dataList.clear()
this.dataList.addAll(dataList) this.dataList.addAll(dataList)
//setLaunchNumber() //setLaunchNumber()
......
...@@ -142,7 +142,7 @@ class RecentAppActivity : AppCompatActivity(), ReportInterface { ...@@ -142,7 +142,7 @@ class RecentAppActivity : AppCompatActivity(), ReportInterface {
//更新UI数据 //更新UI数据
launch(Dispatchers.Main) { launch(Dispatchers.Main) {
updateFragmentData() updateFragmentData(0, 1)
} }
} }
} }
...@@ -171,12 +171,17 @@ class RecentAppActivity : AppCompatActivity(), ReportInterface { ...@@ -171,12 +171,17 @@ class RecentAppActivity : AppCompatActivity(), ReportInterface {
} }
private fun updateFragmentData() { private fun updateFragmentData(vararg position: Int) {
val launchesFragment = pages[0] as LaunchesFragment if (position.contains(0)) {
val screenTimeFragment = pages[1] as ScreenTimeFragment 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) { private fun setScreenTimeData(queryTime: Int = TODAY_QUERY) {
...@@ -209,16 +214,16 @@ class RecentAppActivity : AppCompatActivity(), ReportInterface { ...@@ -209,16 +214,16 @@ class RecentAppActivity : AppCompatActivity(), ReportInterface {
if (hashMap.keys.contains(app.pkg)) { if (hashMap.keys.contains(app.pkg)) {
val value = hashMap[app.pkg] val value = hashMap[app.pkg]
if (value != null) { if (value != null) {
val tempList = arrayListOf<UsageEvents.Event>() val tempList2 = arrayListOf<UsageEvents.Event>()
tempList.addAll(value) tempList2.addAll(value)
app.usageEvents?.also { evens -> tempList.addAll(evens) } app.usageEvents?.also { evens -> tempList2.addAll(evens) }
app.usageEvents = tempList app.usageEvents = tempList2
} }
} }
} }
} }
fun changeTimeRefresh(queryTime: Int) { fun changeTimeRefresh(queryTime: Int, fragmentPosition: Int) {
lifecycleScope.launch(Dispatchers.IO) { lifecycleScope.launch(Dispatchers.IO) {
initAppData() initAppData()
...@@ -229,7 +234,7 @@ class RecentAppActivity : AppCompatActivity(), ReportInterface { ...@@ -229,7 +234,7 @@ class RecentAppActivity : AppCompatActivity(), ReportInterface {
setScreenTimeData(queryTime) setScreenTimeData(queryTime)
//更新UI数据 //更新UI数据
launch(Dispatchers.Main) { updateFragmentData() } launch(Dispatchers.Main) { updateFragmentData(fragmentPosition) }
} }
} }
......
...@@ -86,7 +86,6 @@ class ScreenTimeFragment : Fragment(), ReportInterface { ...@@ -86,7 +86,6 @@ class ScreenTimeFragment : Fragment(), ReportInterface {
todayUI(false) todayUI(false)
// initChart() // initChart()
pageReport() pageReport()
adapter.setData(this.dataList)
} }
private fun initChart() { private fun initChart() {
...@@ -158,7 +157,7 @@ class ScreenTimeFragment : Fragment(), ReportInterface { ...@@ -158,7 +157,7 @@ class ScreenTimeFragment : Fragment(), ReportInterface {
fun todayUI(isReFresh: Boolean = true) { fun todayUI(isReFresh: Boolean = true) {
binding.tvDate.text = "Today" + simpleDateFormat2.format(System.currentTimeMillis()) binding.tvDate.text = "Today" + simpleDateFormat2.format(System.currentTimeMillis())
if (isReFresh) { 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 { ...@@ -166,7 +165,7 @@ class ScreenTimeFragment : Fragment(), ReportInterface {
fun recent60UI(isReFresh: Boolean = true) { fun recent60UI(isReFresh: Boolean = true) {
binding.tvDate.text = "Recent 60 minus" binding.tvDate.text = "Recent 60 minus"
if (isReFresh) { 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 { ...@@ -179,7 +178,7 @@ class ScreenTimeFragment : Fragment(), ReportInterface {
) )
) )
if (isReFresh) { 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 { ...@@ -187,7 +186,7 @@ class ScreenTimeFragment : Fragment(), ReportInterface {
fun sevenDaysUI(isReFresh: Boolean = true) { fun sevenDaysUI(isReFresh: Boolean = true) {
binding.tvDate.text = "Last 7 days" binding.tvDate.text = "Last 7 days"
if (isReFresh) { 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