Commit 1b533843 authored by wanglei's avatar wanglei

...

parent a8dabff6
...@@ -16,6 +16,7 @@ object ConstObject { ...@@ -16,6 +16,7 @@ object ConstObject {
const val ID_NEWS = 12002 const val ID_NEWS = 12002
const val ID_SCAN_CODE = 12003 const val ID_SCAN_CODE = 12003
const val ID_APP_PROCESS = 12004 const val ID_APP_PROCESS = 12004
const val ID_WEATHER = 12012
const val JUNK_CLEANER = "Junk Cleaner" const val JUNK_CLEANER = "Junk Cleaner"
const val NEWS = "News" const val NEWS = "News"
......
...@@ -17,9 +17,11 @@ import androidx.core.app.NotificationCompat ...@@ -17,9 +17,11 @@ import androidx.core.app.NotificationCompat
import androidx.core.graphics.drawable.IconCompat import androidx.core.graphics.drawable.IconCompat
import com.base.browserwhite.MyApplication import com.base.browserwhite.MyApplication
import com.base.browserwhite.R import com.base.browserwhite.R
import com.base.browserwhite.bean.ConstObject.ID_APP_PROCESS
import com.base.browserwhite.bean.ConstObject.ID_CLEAN_JUNK_MEMORY import com.base.browserwhite.bean.ConstObject.ID_CLEAN_JUNK_MEMORY
import com.base.browserwhite.bean.ConstObject.ID_JUNK_CLEANER import com.base.browserwhite.bean.ConstObject.ID_JUNK_CLEANER
import com.base.browserwhite.bean.ConstObject.ID_NEWS import com.base.browserwhite.bean.ConstObject.ID_NEWS
import com.base.browserwhite.bean.ConstObject.ID_WEATHER
import com.base.browserwhite.bean.NewsBean import com.base.browserwhite.bean.NewsBean
import com.base.browserwhite.help.EventUtils import com.base.browserwhite.help.EventUtils
import com.base.browserwhite.help.NewsUtils.getNews import com.base.browserwhite.help.NewsUtils.getNews
...@@ -28,6 +30,8 @@ import com.base.browserwhite.ui.activity.splash.Splash2Activity ...@@ -28,6 +30,8 @@ import com.base.browserwhite.ui.activity.splash.Splash2Activity
import com.base.browserwhite.utils.AppPreferences import com.base.browserwhite.utils.AppPreferences
import com.base.browserwhite.utils.ImageUtils.getBitmapFromURL 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.RamUtils
import com.base.browserwhite.utils.RamUtils.ramPair
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import java.util.Calendar import java.util.Calendar
import java.util.Locale import java.util.Locale
...@@ -47,7 +51,7 @@ object NotificationUtil { ...@@ -47,7 +51,7 @@ object NotificationUtil {
fun sendNotification(context: Context, actionId: Int) { fun sendNotification(context: Context, actionId: Int) {
when (actionId) { when (actionId) {
ID_JUNK_CLEANER -> { ID_JUNK_CLEANER -> {//清理
var size = fastGetJunkSize(context) var size = fastGetJunkSize(context)
if (size == 0L) { if (size == 0L) {
size = Random.nextLong(1024 * 5, 1024 * 10) size = Random.nextLong(1024 * 5, 1024 * 10)
...@@ -60,7 +64,7 @@ object NotificationUtil { ...@@ -60,7 +64,7 @@ object NotificationUtil {
sendNotificationUI(context, actionId, bigRemoteViews, smallRemoteViews) sendNotificationUI(context, actionId, bigRemoteViews, smallRemoteViews)
} }
ID_CLEAN_JUNK_MEMORY -> { ID_CLEAN_JUNK_MEMORY -> {//清理和内存
var size = fastGetJunkSize(context) var size = fastGetJunkSize(context)
if (size == 0L) { if (size == 0L) {
size = Random.nextLong(1024 * 5, 1024 * 10) size = Random.nextLong(1024 * 5, 1024 * 10)
...@@ -74,7 +78,7 @@ object NotificationUtil { ...@@ -74,7 +78,7 @@ object NotificationUtil {
sendNotificationUI(context, actionId, bigRemoteViews, smallRemoteViews) sendNotificationUI(context, actionId, bigRemoteViews, smallRemoteViews)
} }
ID_NEWS -> { ID_NEWS -> {//新闻
val mainHandler = Handler(Looper.getMainLooper()) val mainHandler = Handler(Looper.getMainLooper())
Thread { Thread {
...@@ -95,6 +99,26 @@ object NotificationUtil { ...@@ -95,6 +99,26 @@ object NotificationUtil {
}.start() }.start()
} }
ID_APP_PROCESS -> {//内存
val pair = MyApplication.context.ramPair()
val percent = (pair.first * 100 / pair.second).toInt()
val desc = "Memory is $percent% used"
val smallRemoteViews = RemoteViews(context.packageName, R.layout.notification_memory_small)
smallRemoteViews.setProgressBar(R.id.progress_bar, percent, 100, false)
smallRemoteViews.setTextViewText(R.id.tv_desc, desc)
val bigRemoteViews = RemoteViews(context.packageName, R.layout.notification_memory_small)
bigRemoteViews.setProgressBar(R.id.progress_bar, percent, 100, false)
bigRemoteViews.setTextViewText(R.id.tv_desc, desc)
sendNotificationUI(context, actionId, bigRemoteViews, smallRemoteViews)
}
ID_WEATHER -> {
}
else -> { else -> {
} }
} }
...@@ -286,6 +310,11 @@ object NotificationUtil { ...@@ -286,6 +310,11 @@ object NotificationUtil {
} }
private val NOTIFICATION_IDS = intArrayOf( private val NOTIFICATION_IDS = intArrayOf(
0 ID_JUNK_CLEANER,
ID_CLEAN_JUNK_MEMORY,
ID_NEWS,
ID_APP_PROCESS,
ID_WEATHER
) )
} }
\ No newline at end of file
...@@ -100,7 +100,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() { ...@@ -100,7 +100,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data) super.onActivityResult(requestCode, resultCode, data)
homeFragment?.onActivityResult(resultCode, resultCode, data) homeFragment.onActivityResult(resultCode, resultCode, data)
} }
override fun initListener() { override fun initListener() {
......
...@@ -14,6 +14,7 @@ import androidx.recyclerview.widget.LinearLayoutManager ...@@ -14,6 +14,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
import com.base.browserwhite.R import com.base.browserwhite.R
import com.base.browserwhite.ads.admob.AdmobNativeUtils import com.base.browserwhite.ads.admob.AdmobNativeUtils
import com.base.browserwhite.bean.BookmarkBean import com.base.browserwhite.bean.BookmarkBean
import com.base.browserwhite.bean.ConstObject
import com.base.browserwhite.bean.ConstObject.APP_PROCESS import com.base.browserwhite.bean.ConstObject.APP_PROCESS
import com.base.browserwhite.bean.ConstObject.BAIDU import com.base.browserwhite.bean.ConstObject.BAIDU
import com.base.browserwhite.bean.ConstObject.BING import com.base.browserwhite.bean.ConstObject.BING
...@@ -30,6 +31,7 @@ import com.base.browserwhite.bean.WebSiteBean ...@@ -30,6 +31,7 @@ import com.base.browserwhite.bean.WebSiteBean
import com.base.browserwhite.bean.defaultValue import com.base.browserwhite.bean.defaultValue
import com.base.browserwhite.bean.webSiteGroupBeanList import com.base.browserwhite.bean.webSiteGroupBeanList
import com.base.browserwhite.databinding.FragmentHomeBinding import com.base.browserwhite.databinding.FragmentHomeBinding
import com.base.browserwhite.fcm.NotificationUtil
import com.base.browserwhite.help.Constants import com.base.browserwhite.help.Constants
import com.base.browserwhite.help.NewsUtils.requestNews import com.base.browserwhite.help.NewsUtils.requestNews
import com.base.browserwhite.help.RxBus import com.base.browserwhite.help.RxBus
...@@ -360,7 +362,7 @@ class HomeFragment : BaseFragment<FragmentHomeBinding>() { ...@@ -360,7 +362,7 @@ class HomeFragment : BaseFragment<FragmentHomeBinding>() {
// i++ // i++
// lastClickTime = System.currentTimeMillis() // lastClickTime = System.currentTimeMillis()
// NotificationUtil.sendNotification(requireContext(), ConstObject.ID_NEWS) NotificationUtil.sendNotification(requireContext(), ConstObject.ID_APP_PROCESS)
} }
binding.ivUp.setOnClickListener { binding.ivUp.setOnClickListener {
binding.rv.scrollToPosition(0) binding.rv.scrollToPosition(0)
......
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 设置背景色 -->
<item android:id="@android:id/background">
<shape>
<solid android:color="#E5E8ED" />
<corners android:radius="2.5dp" />
</shape>
</item>
<!-- 设置进度条颜色 -->
<item android:id="@android:id/progress">
<scale android:scaleWidth="100%">
<shape>
<corners android:radius="2.5dp" />
<solid android:color="#FD4242" />
</shape>
</scale>
</item>
</layer-list>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="@drawable/bg_ffffff_15">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="15dp"
android:src="@mipmap/process_notification"
tools:ignore="ContentDescription" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="7dp"
android:layout_marginEnd="40dp"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="@+id/tv_desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/black"
android:textSize="14sp"
tools:text="Memory is 73% used" />
<ProgressBar
android:id="@+id/progress_bar"
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
android:layout_width="match_parent"
android:layout_height="5dp"
android:layout_marginTop="6dp"
android:max="100"
android:progressDrawable="@drawable/progress_bar_appprocess_notifi"
tools:progress="75" />
</LinearLayout>
<TextView
android:id="@+id/tv_btn"
android:layout_width="69dp"
android:layout_height="34dp"
android:layout_gravity="center_vertical"
android:layout_marginEnd="13dp"
android:background="@drawable/bg_0571ed_18"
android:gravity="center"
android:text="Scan"
android:textColor="@color/white"
android:textSize="15sp"
tools:ignore="HardcodedText" />
</LinearLayout>
\ No newline at end of file
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