Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
S
swiftcleanerphonehelper
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
swiftcleanerphonehelper
Commits
0d090e6e
Commit
0d090e6e
authored
Dec 20, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...
parent
78fa725e
Pipeline
#1370
canceled with stages
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
171 additions
and
29 deletions
+171
-29
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+5
-1
AdmobHelper.kt
app/src/main/java/com/zxdemo/admob/AdmobHelper.kt
+16
-15
NotificationUtils.kt
app/src/main/java/com/zxdemo/notity/NotificationUtils.kt
+1
-1
PermanentNotifyService.kt
...rc/main/java/com/zxdemo/service/PermanentNotifyService.kt
+13
-12
notifi_stay_small.xml
app/src/main/res/layout/notifi_stay_small.xml
+136
-0
notify_stay_big.xml
app/src/main/res/layout/notify_stay_big.xml
+0
-0
No files found.
app/src/main/AndroidManifest.xml
View file @
0d090e6e
...
...
@@ -3,13 +3,13 @@
xmlns:tools=
"http://schemas.android.com/tools"
>
<uses-permission
android:name=
"android.permission.INTERNET"
/>
<uses-permission
android:name=
"android.permission.POST_NOTIFICATIONS"
/>
<uses-permission
android:name=
"android.permission.READ_EXTERNAL_STORAGE"
/>
<uses-permission
android:name=
"android.permission.WRITE_EXTERNAL_STORAGE"
/>
<uses-permission
android:name=
"android.permission.MANAGE_EXTERNAL_STORAGE"
/>
<uses-permission
android:name=
"android.permission.REQUEST_DELETE_PACKAGES"
/>
<uses-permission
android:name=
"android.permission.READ_NOTIFICATIONS"
/>
<uses-permission
android:name=
"android.permission.POST_NOTIFICATIONS"
/>
<uses-permission
android:name=
"android.permission.FOREGROUND_SERVICE_DATA_SYNC"
/>
<queries>
...
...
@@ -109,6 +109,10 @@
android:name=
"android.max_aspect"
android:value=
"2.4"
/>
<service
android:name=
"com.zxdemo.service.PermanentNotifyService"
android:foregroundServiceType=
"dataSync"
/>
<!-- 广告的appId每次打包正式需要改 -->
<meta-data
...
...
app/src/main/java/com/zxdemo/admob/AdmobHelper.kt
View file @
0d090e6e
package
com.zxdemo.admob
import
android.app.Activity
import
android.content.Context
import
android.os.Bundle
...
...
@@ -402,7 +403,7 @@ object AdmobHelper {
override
fun
onAdClicked
(
p0
:
MaxAd
)
{
Log
.
d
(
TAG
,
"app open Ad Max was clicked"
)
calculate
(
KEY_CLICK_NUMBER
)
//com.zxdemo.admob.
ReportAdUtils.clickAd(appOpenAd?.responseInfo, APP_OPEN_AD_UNIT)
ReportAdUtils
.
clickAd
(
appOpenAd
?.
responseInfo
,
APP_OPEN_AD_UNIT
)
}
override
fun
onAdLoadFailed
(
p0
:
String
,
p1
:
MaxError
)
{
...
...
@@ -600,20 +601,20 @@ object AdmobHelper {
failed
:
(()
->
Unit
?)?
=
null
)
{
// if (useAdmob) {
// Use the fragment width as the ad width when layout is finished.
adViewContainer
.
viewTreeObserver
.
addOnGlobalLayoutListener
(
object
:
ViewTreeObserver
.
OnGlobalLayoutListener
{
override
fun
onGlobalLayout
()
{
val
screenPixelDensity
=
context
.
resources
.
displayMetrics
.
density
val
adWidth
=
(
adViewContainer
.
width
/
screenPixelDensity
).
toInt
()
val
adSize
=
AdSize
.
getCurrentOrientationAnchoredAdaptiveBannerAdSize
(
context
,
adWidth
)
showBannerAd
(
context
,
adViewContainer
,
adSize
,
collapsible
,
completed
,
failed
)
adViewContainer
.
viewTreeObserver
.
removeOnGlobalLayoutListener
(
this
)
}
})
// Use the fragment width as the ad width when layout is finished.
adViewContainer
.
viewTreeObserver
.
addOnGlobalLayoutListener
(
object
:
ViewTreeObserver
.
OnGlobalLayoutListener
{
override
fun
onGlobalLayout
()
{
val
screenPixelDensity
=
context
.
resources
.
displayMetrics
.
density
val
adWidth
=
(
adViewContainer
.
width
/
screenPixelDensity
).
toInt
()
val
adSize
=
AdSize
.
getCurrentOrientationAnchoredAdaptiveBannerAdSize
(
context
,
adWidth
)
showBannerAd
(
context
,
adViewContainer
,
adSize
,
collapsible
,
completed
,
failed
)
adViewContainer
.
viewTreeObserver
.
removeOnGlobalLayoutListener
(
this
)
}
})
// } else {
// showBannerAd(context, adViewContainer, completed, failed)
// }
...
...
app/src/main/java/com/zxdemo/notity/NotificationUtils.kt
View file @
0d090e6e
...
...
@@ -132,7 +132,7 @@ object NotificationUtils {
fun
sendNotification
(
context
:
Context
,
action
:
String
,
value
:
String
)
{
var
actionId
=
nextNotificationId
val
bigRemoteViews
=
RemoteViews
(
context
.
packageName
,
R
.
layout
.
notice_expand
)
val
smallRemoteViews
=
RemoteViews
(
context
.
packageName
,
R
.
layout
.
noti
ce_fold
)
val
smallRemoteViews
=
RemoteViews
(
context
.
packageName
,
R
.
layout
.
noti
fy_stay_big
)
when
(
actionId
)
{
ID_CLEAN_JUNK
->
{
}
...
...
app/src/main/java/com/zxdemo/service/PermanentNotifyService.kt
View file @
0d090e6e
...
...
@@ -9,6 +9,7 @@ import android.app.Service
import
android.content.Context
import
android.content.Intent
import
android.content.pm.ServiceInfo
import
android.graphics.BitmapFactory
import
android.os.Build
import
android.os.IBinder
import
android.widget.RemoteViews
...
...
@@ -71,8 +72,8 @@ class PermanentNotifyService : Service() {
val
channelName
=
"Foreground Service Channel"
val
channelId
=
"Service_Id"
val
category
=
Notification
.
CATEGORY_SERVICE
val
contentView
=
RemoteViews
(
context
.
packageName
,
R
.
layout
.
noti
ce_fold
)
val
expendView
=
RemoteViews
(
context
.
packageName
,
R
.
layout
.
noti
ce_fold
)
val
contentView
=
RemoteViews
(
context
.
packageName
,
R
.
layout
.
noti
fi_stay_small
)
val
expendView
=
RemoteViews
(
context
.
packageName
,
R
.
layout
.
noti
fy_stay_big
)
val
cleanIntent
=
PendingIntent
.
getActivity
(
context
,
// context
...
...
@@ -80,8 +81,8 @@ class PermanentNotifyService : Service() {
Intent
(
"CleanJunkActivity"
,
null
,
context
,
MainActivity
::
class
.
java
),
// intent
PendingIntent
.
FLAG_UPDATE_CURRENT
or
PendingIntent
.
FLAG_IMMUTABLE
// flags
)
//
contentView.setOnClickPendingIntent(R.id.tv_clean, cleanIntent)
//
expendView.setOnClickPendingIntent(R.id.tv_clean, cleanIntent)
contentView
.
setOnClickPendingIntent
(
R
.
id
.
tv_clean
,
cleanIntent
)
expendView
.
setOnClickPendingIntent
(
R
.
id
.
tv_clean
,
cleanIntent
)
val
appIntent
=
PendingIntent
.
getActivity
(
context
,
// context
...
...
@@ -89,16 +90,16 @@ class PermanentNotifyService : Service() {
Intent
(
"AppManagerActivity"
,
null
,
context
,
MainActivity
::
class
.
java
),
// intent
PendingIntent
.
FLAG_UPDATE_CURRENT
or
PendingIntent
.
FLAG_IMMUTABLE
// flags
)
//
contentView.setOnClickPendingIntent(R.id.tv_app, appIntent)
//
expendView.setOnClickPendingIntent(R.id.tv_app, appIntent)
contentView
.
setOnClickPendingIntent
(
R
.
id
.
tv_app
,
appIntent
)
expendView
.
setOnClickPendingIntent
(
R
.
id
.
tv_app
,
appIntent
)
val
whatsIntent
=
PendingIntent
.
getActivity
(
context
,
// context
0
,
// request code
Intent
(
"CleanerActivity"
,
null
,
context
,
MainActivity
::
class
.
java
),
// intent
PendingIntent
.
FLAG_UPDATE_CURRENT
or
PendingIntent
.
FLAG_IMMUTABLE
// flags
)
//
contentView.setOnClickPendingIntent(R.id.tv_whatsapp, whatsIntent)
//
expendView.setOnClickPendingIntent(R.id.tv_whatsapp, whatsIntent)
contentView
.
setOnClickPendingIntent
(
R
.
id
.
tv_whatsapp
,
whatsIntent
)
expendView
.
setOnClickPendingIntent
(
R
.
id
.
tv_whatsapp
,
whatsIntent
)
val
largeIntent
=
PendingIntent
.
getActivity
(
context
,
// context
...
...
@@ -111,15 +112,15 @@ class PermanentNotifyService : Service() {
),
// intent
PendingIntent
.
FLAG_UPDATE_CURRENT
or
PendingIntent
.
FLAG_IMMUTABLE
// flags
)
//
contentView.setOnClickPendingIntent(R.id.tv_large, largeIntent)
//
expendView.setOnClickPendingIntent(R.id.tv_large, largeIntent)
contentView
.
setOnClickPendingIntent
(
R
.
id
.
tv_large
,
largeIntent
)
expendView
.
setOnClickPendingIntent
(
R
.
id
.
tv_large
,
largeIntent
)
val
nfIntent
=
Intent
(
context
,
MainActivity
::
class
.
java
)
val
pendingIntent
=
PendingIntent
.
getActivity
(
context
,
0
,
nfIntent
,
PendingIntent
.
FLAG_IMMUTABLE
)
val
builder
=
NotificationCompat
.
Builder
(
context
,
channelId
)
// builder.setSmallIcon(R.drawable.lig
) //设置状态栏内的小图标
//
builder.setLargeIcon(BitmapFactory.decodeResource(context.resources, R.drawable.icon_apk))
builder
.
setSmallIcon
(
R
.
mipmap
.
logo
)
//设置状态栏内的小图标
builder
.
setLargeIcon
(
BitmapFactory
.
decodeResource
(
context
.
resources
,
R
.
drawable
.
icon_apk
))
builder
.
setContentTitle
(
context
.
resources
.
getString
(
R
.
string
.
app_name
))
builder
.
setContentIntent
(
pendingIntent
)
//设置PendingIntent
builder
.
setVisibility
(
NotificationCompat
.
VISIBILITY_PRIVATE
)
//设置通知公开可见
...
...
app/src/main/res/layout/notifi_stay_small.xml
0 → 100644
View file @
0d090e6e
<?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=
"wrap_content"
android:background=
"@drawable/shape_radio_10dp_white"
tools:ignore=
"DisableBaselineAlignment"
>
<!--清理-->
<LinearLayout
android:id=
"@+id/id_ll_clean"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:gravity=
"center"
android:orientation=
"vertical"
android:paddingVertical=
"8dp"
tools:ignore=
"UseCompoundDrawables"
>
<FrameLayout
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
tools:ignore=
"UselessParent"
>
<ImageView
android:layout_width=
"40dp"
android:layout_height=
"40dp"
android:layout_margin=
"2dp"
android:src=
"@mipmap/c_clean"
tools:ignore=
"ContentDescription"
/>
<ImageView
android:layout_width=
"15dp"
android:layout_height=
"15dp"
android:layout_gravity=
"end"
tools:ignore=
"ContentDescription"
/>
</FrameLayout>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"2dp"
android:text=
"Clean"
android:textColor=
"#666666"
android:textSize=
"12sp"
android:visibility=
"gone"
tools:ignore=
"HardcodedText"
/>
</LinearLayout>
<!--恢复照片-->
<LinearLayout
android:id=
"@+id/id_recovery_photos"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:gravity=
"center"
android:orientation=
"vertical"
android:paddingVertical=
"8dp"
tools:ignore=
"UseCompoundDrawables"
>
<ImageView
android:layout_width=
"40dp"
android:layout_height=
"40dp"
android:layout_marginBottom=
"6dp"
android:src=
"@mipmap/c_app"
tools:ignore=
"ContentDescription"
/>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"App"
android:textColor=
"#666666"
android:textSize=
"12sp"
android:visibility=
"gone"
tools:ignore=
"HardcodedText"
/>
</LinearLayout>
<!--恢复视频-->
<LinearLayout
android:id=
"@+id/id_recovery_videos"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:gravity=
"center"
android:orientation=
"vertical"
android:paddingVertical=
"8dp"
tools:ignore=
"UseCompoundDrawables"
>
<ImageView
android:layout_width=
"40dp"
android:layout_height=
"40dp"
android:layout_marginBottom=
"6dp"
android:src=
"@mipmap/h_batteryinfo"
tools:ignore=
"ContentDescription"
/>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"Battery"
android:textColor=
"#666666"
android:textSize=
"12sp"
android:visibility=
"gone"
tools:ignore=
"HardcodedText"
/>
</LinearLayout>
<!--恢复文档-->
<LinearLayout
android:id=
"@+id/id_recovery_documents"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:gravity=
"center"
android:orientation=
"vertical"
android:paddingVertical=
"8dp"
android:visibility=
"visible"
tools:ignore=
"UseCompoundDrawables"
>
<ImageView
android:layout_width=
"40dp"
android:layout_height=
"40dp"
android:layout_marginBottom=
"6dp"
android:src=
"@mipmap/h_large"
tools:ignore=
"ContentDescription"
/>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"Large"
android:textColor=
"#666666"
android:textSize=
"12sp"
android:visibility=
"gone"
tools:ignore=
"HardcodedText"
/>
</LinearLayout>
</LinearLayout>
\ No newline at end of file
app/src/main/res/layout/noti
ce_fold
.xml
→
app/src/main/res/layout/noti
fy_stay_big
.xml
View file @
0d090e6e
File moved
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