Commit 9fd2497f authored by leichao.gao's avatar leichao.gao

Merge branch 'master' of gitlab.huolea.com:koko/browser-white

parents d9262a71 514b2cc0
...@@ -2,6 +2,7 @@ package com.base.browserwhite.fcm ...@@ -2,6 +2,7 @@ package com.base.browserwhite.fcm
import android.util.Log import android.util.Log
import com.base.browserwhite.bean.ConstObject import com.base.browserwhite.bean.ConstObject
import com.base.browserwhite.bean.ConstObject.ID_APP_PROCESS_2
import com.base.browserwhite.utils.AppPreferences import com.base.browserwhite.utils.AppPreferences
import com.base.browserwhite.utils.LogEx import com.base.browserwhite.utils.LogEx
import com.base.browserwhite.utils.TimeUtils import com.base.browserwhite.utils.TimeUtils
...@@ -48,14 +49,22 @@ object NotificationHelp { ...@@ -48,14 +49,22 @@ object NotificationHelp {
LogEx.logDebug(TAG, "ID_WEATHER canPush=$canPush") LogEx.logDebug(TAG, "ID_WEATHER canPush=$canPush")
} }
ConstObject.ID_APP_PROCESS_1 -> { ConstObject.ID_APP_PROCESS_1, ID_APP_PROCESS_2 -> {
canPush = canPushAppProcess() canPush = canPushAppProcess()
} }
ConstObject.ID_CONSTELLATION -> {
// canPush = canPushConstellation()
}
} }
return canPush return canPush
} }
// private fun canPushConstellation(): Boolean {
//
// }
//天气 //天气
private fun canPushWeather(): Boolean { private fun canPushWeather(): Boolean {
...@@ -118,6 +127,8 @@ object NotificationHelp { ...@@ -118,6 +127,8 @@ object NotificationHelp {
ConstObject.ID_JUNK_CLEANER, ConstObject.ID_JUNK_CLEANER,
ConstObject.ID_NEWS, ConstObject.ID_NEWS,
ConstObject.ID_APP_PROCESS_1, ConstObject.ID_APP_PROCESS_1,
ConstObject.ID_WEATHER ConstObject.ID_APP_PROCESS_2,
ConstObject.ID_WEATHER,
ConstObject.ID_CONSTELLATION
) )
} }
...@@ -7,6 +7,7 @@ import android.app.NotificationManager ...@@ -7,6 +7,7 @@ import android.app.NotificationManager
import android.app.PendingIntent import android.app.PendingIntent
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.graphics.Bitmap
import android.graphics.drawable.Icon import android.graphics.drawable.Icon
import android.os.Build import android.os.Build
import android.os.Handler import android.os.Handler
...@@ -29,9 +30,8 @@ import com.base.browserwhite.bean.ConstObject.ID_WEATHER ...@@ -29,9 +30,8 @@ import com.base.browserwhite.bean.ConstObject.ID_WEATHER
import com.base.browserwhite.bean.NewsBean import com.base.browserwhite.bean.NewsBean
import com.base.browserwhite.bean.WeatherBean import com.base.browserwhite.bean.WeatherBean
import com.base.browserwhite.help.NewsUtils.getNewSp import com.base.browserwhite.help.NewsUtils.getNewSp
import com.base.browserwhite.utils.TimeUtils.formatATime
import com.base.browserwhite.utils.TimeUtils.isDayOrNight
import com.base.browserwhite.help.WeatherUtils import com.base.browserwhite.help.WeatherUtils
import com.base.browserwhite.ui.activity.appprocess.AppProcessActivity
import com.base.browserwhite.ui.activity.cleanjunk.ScanJunkActivity.Companion.fastGetJunkSize import com.base.browserwhite.ui.activity.cleanjunk.ScanJunkActivity.Companion.fastGetJunkSize
import com.base.browserwhite.ui.activity.splash.Splash2Activity import com.base.browserwhite.ui.activity.splash.Splash2Activity
import com.base.browserwhite.utils.AppPreferences import com.base.browserwhite.utils.AppPreferences
...@@ -39,6 +39,8 @@ import com.base.browserwhite.utils.ImageUtils.getBitmapFromURL ...@@ -39,6 +39,8 @@ import com.base.browserwhite.utils.ImageUtils.getBitmapFromURL
import com.base.browserwhite.utils.KotlinExt.toFormatSize import com.base.browserwhite.utils.KotlinExt.toFormatSize
import com.base.browserwhite.utils.LogEx import com.base.browserwhite.utils.LogEx
import com.base.browserwhite.utils.RamUtils.ramPair import com.base.browserwhite.utils.RamUtils.ramPair
import com.base.browserwhite.utils.TimeUtils.formatATime
import com.base.browserwhite.utils.TimeUtils.isDayOrNight
import kotlin.random.Random import kotlin.random.Random
...@@ -198,8 +200,17 @@ object NotificationUiUtil { ...@@ -198,8 +200,17 @@ object NotificationUiUtil {
ID_USAGE_REPORT -> {//使用报告 ID_USAGE_REPORT -> {//使用报告
val smallRemoteViews = RemoteViews(context.packageName, R.layout.notification_usage_report_small) val smallRemoteViews = RemoteViews(context.packageName, R.layout.notification_usage_report_small)
val bigRemoteViews = RemoteViews(context.packageName, R.layout.notification_usage_report_small) val bigRemoteViews = RemoteViews(context.packageName, R.layout.notification_usage_report_big)
val pm = context.packageManager
val apps = AppProcessActivity.fastGetAppIcon(context)
LogEx.logDebug("ID_USAGE_REPORT", "${apps.size}")
runCatching {
val app1 = apps[0]
val drawable1 = app1.applicationInfo.loadIcon(pm)
val bitmap = Bitmap.createBitmap(50, 50, Bitmap.Config.ARGB_8888)
LogEx.logDebug("ID_USAGE_REPORT", "${bitmap.height} ${bitmap.width}")
bigRemoteViews.setImageViewBitmap(R.id.iv_app_1, bitmap)
}
sendNotificationUI(context, actionId, bigRemoteViews, smallRemoteViews) sendNotificationUI(context, actionId, bigRemoteViews, smallRemoteViews)
} }
......
...@@ -85,6 +85,23 @@ class AppProcessActivity : BaseActivity<ActivityAppProcessBinding>() { ...@@ -85,6 +85,23 @@ class AppProcessActivity : BaseActivity<ActivityAppProcessBinding>() {
} }
} }
companion object {
fun isLaunchApp(context: Context, app: PackageInfo, filterSystem: Boolean = true): Boolean {
val flagSystem = (app.applicationInfo.flags and ApplicationInfo.FLAG_SYSTEM) < 1
val flag = if (filterSystem) flagSystem else true
return flag && app.applicationInfo.packageName != context.packageName
}
@SuppressLint("QueryPermissionsNeeded")
fun fastGetAppIcon(context: Context): List<PackageInfo> {
val pm = context.packageManager
val packages = pm.getInstalledPackages(0).filter { isLaunchApp(context, it) }
return packages
}
}
@SuppressLint("QueryPermissionsNeeded") @SuppressLint("QueryPermissionsNeeded")
private fun initData() = lifecycleScope.launch(Dispatchers.IO) { private fun initData() = lifecycleScope.launch(Dispatchers.IO) {
...@@ -125,13 +142,6 @@ class AppProcessActivity : BaseActivity<ActivityAppProcessBinding>() { ...@@ -125,13 +142,6 @@ class AppProcessActivity : BaseActivity<ActivityAppProcessBinding>() {
} }
} }
private fun isLaunchApp(context: Context, app: PackageInfo, filterSystem: Boolean = true): Boolean {
val flagSystem = (app.applicationInfo.flags and ApplicationInfo.FLAG_SYSTEM) < 1
val flag = if (filterSystem) flagSystem else true
return flag && app.applicationInfo.packageName != context.packageName
}
// fun test() { // fun test() {
// val am = getSystemService(ACTIVITY_SERVICE) as ActivityManager // val am = getSystemService(ACTIVITY_SERVICE) as ActivityManager
......
package com.base.browserwhite.ui.views
import android.animation.Animator
import android.animation.ValueAnimator
import android.content.Context
import android.graphics.Canvas
import android.graphics.Color
import android.graphics.Paint
import android.graphics.RectF
import android.util.AttributeSet
import android.view.animation.LinearInterpolator
import android.widget.ProgressBar
import com.base.browserwhite.R
class ColorProgressBar : ProgressBar {
private lateinit var ringPaint: Paint//圆环笔
private var centerX = 0f
private var centerY = 0f
private var radius = 0f
private var strokeWidth = 0f // 圆环的宽度
private var margin = 10f
private lateinit var ringRectF: RectF
private lateinit var progressRectF: RectF
private lateinit var progressPaint: Paint
private var listProgressBean: List<ProgressBean> = listOf()
private var currentAngle = 0f
var finishAnimation: (() -> Unit)? = null
constructor(context: Context) : super(context){
initPaint(context)
}
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs){
initPaint(context)
}
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr){
initPaint(context)
}
private fun initPaint(context: Context) {
strokeWidth = context.resources.getDimension(R.dimen.dp_9)
ringPaint = Paint()
ringPaint.isAntiAlias = true
ringPaint.style = Paint.Style.STROKE
ringPaint.setColor(Color.parseColor("#E6E7EC"))
ringPaint.strokeWidth = strokeWidth
progressPaint = Paint()
progressPaint.isAntiAlias = true
progressPaint.style = Paint.Style.STROKE
progressPaint.strokeWidth = strokeWidth
progressPaint.strokeCap = Paint.Cap.ROUND
// 初始化圆的中心点和半径
centerX = width / 2.0f
centerY = height / 2.0f
radius = (centerX.coerceAtMost(centerY) - strokeWidth / 2) - margin
}
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
super.onSizeChanged(w, h, oldw, oldh)
centerX = w / 2.0f
centerY = h / 2.0f
radius = (centerX.coerceAtMost(centerY) - strokeWidth / 2) - margin
ringRectF = RectF(centerX - radius, centerY - radius, centerX + radius, centerY + radius)
progressRectF = RectF(centerX - radius, centerY - radius, centerX + radius, centerY + radius)
}
override fun onDraw(canvas: Canvas) {
super.onDraw(canvas)
// // 绘制圆环
// canvas.drawOval(ringRectF, ringPaint)
//
//
// listProgressBean.forEachIndexed { index, progressBean ->
// progressPaint.setColor(Color.parseColor(progressBean.color))
//
// if (index != 0) {
// val lastProgressBean: ProgressBean = listProgressBean[index - 1]
//
// if (currentAngle <= progressBean.sweepAngle) {
// canvas.drawArc(progressRectF, -90f, currentAngle, false, progressPaint)
// progressBean.draw = true
// } else if (lastProgressBean.draw) {
// canvas.drawArc(progressRectF, -90f, progressBean.sweepAngle, false, progressPaint)
// progressBean.draw = true
// }
// } else {
// if (currentAngle >= progressBean.startAngle) {
// canvas.drawArc(progressRectF, -90f, currentAngle, false, progressPaint)
// progressBean.draw = true
// }
// }
// }
}
private fun setProgress(angle: Float) {
currentAngle = angle
invalidate()
}
fun animateProgress(list: List<ProgressBean>) {
listProgressBean = list
val totalAngle = list.maxOf { it.sweepAngle }
val progressAnimator = ValueAnimator.ofFloat(0f, totalAngle)
progressAnimator.interpolator = LinearInterpolator() // 平滑插值器
progressAnimator.setDuration(1500) // 动画持续时间1000毫秒
progressAnimator.addUpdateListener { animation ->
val animatedValue = animation.getAnimatedValue() as Float
setProgress(animatedValue)
}
progressAnimator.addListener(object : Animator.AnimatorListener {
override fun onAnimationStart(animation: Animator) {
}
override fun onAnimationEnd(animation: Animator) {
finishAnimation?.invoke()
}
override fun onAnimationCancel(animation: Animator) {
}
override fun onAnimationRepeat(animation: Animator) {
}
})
progressAnimator.start()
}
}
\ 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="2dp"/>
<solid android:color="#00BF79"/>
</shape>
\ 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="#8338FF"/>
<corners android:radius="2dp"/>
</shape>
\ 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="#FF4343"/>
<corners android:radius="2dp"/>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<com.base.browserwhite.ui.views.ColorProgress xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="50dp"
android:layout_height="50dp" />
<?xml version="1.0" encoding="utf-8"?>
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
</ImageView>
\ No newline at end of file
This diff is collapsed.
...@@ -5,15 +5,15 @@ ...@@ -5,15 +5,15 @@
android:layout_height="60dp" android:layout_height="60dp"
android:background="@drawable/bg_ffffff_15"> android:background="@drawable/bg_ffffff_15">
<com.base.browserwhite.ui.views.ColorProgressBar <ImageView
android:layout_width="34dp" android:id="@+id/iv"
android:layout_height="34dp" android:layout_width="45dp"
android:layout_height="45dp"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_marginStart="15dp" android:layout_marginStart="15dp"
android:src="@mipmap/clean" android:src="@mipmap/x_yuan"
tools:ignore="ContentDescription" /> tools:ignore="ContentDescription" />
<LinearLayout <LinearLayout
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
......
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