Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
B
Browser White
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wanglei
Browser White
Commits
1b533843
Commit
1b533843
authored
Sep 04, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...
parent
a8dabff6
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
117 additions
and
6 deletions
+117
-6
ConstObject.kt
app/src/main/java/com/base/browserwhite/bean/ConstObject.kt
+1
-0
NotificationUtil.kt
...c/main/java/com/base/browserwhite/fcm/NotificationUtil.kt
+33
-4
MainActivity.kt
...in/java/com/base/browserwhite/ui/activity/MainActivity.kt
+1
-1
HomeFragment.kt
...in/java/com/base/browserwhite/ui/fragment/HomeFragment.kt
+3
-1
progress_bar_appprocess_notifi.xml
app/src/main/res/drawable/progress_bar_appprocess_notifi.xml
+21
-0
notification_memory_small.xml
app/src/main/res/layout/notification_memory_small.xml
+58
-0
process_notification.png
app/src/main/res/mipmap-xxhdpi/process_notification.png
+0
-0
No files found.
app/src/main/java/com/base/browserwhite/bean/ConstObject.kt
View file @
1b533843
...
@@ -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"
...
...
app/src/main/java/com/base/browserwhite/fcm/NotificationUtil.kt
View file @
1b533843
...
@@ -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
app/src/main/java/com/base/browserwhite/ui/activity/MainActivity.kt
View file @
1b533843
...
@@ -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
()
{
...
...
app/src/main/java/com/base/browserwhite/ui/fragment/HomeFragment.kt
View file @
1b533843
...
@@ -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_NEW
S)
NotificationUtil
.
sendNotification
(
requireContext
(),
ConstObject
.
ID_APP_PROCES
S
)
}
}
binding
.
ivUp
.
setOnClickListener
{
binding
.
ivUp
.
setOnClickListener
{
binding
.
rv
.
scrollToPosition
(
0
)
binding
.
rv
.
scrollToPosition
(
0
)
...
...
app/src/main/res/drawable/progress_bar_appprocess_notifi.xml
0 → 100644
View file @
1b533843
<?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
app/src/main/res/layout/notification_memory_small.xml
0 → 100644
View file @
1b533843
<?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
app/src/main/res/mipmap-xxhdpi/process_notification.png
0 → 100644
View file @
1b533843
9.28 KB
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment