Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
D
Data Recovery 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
Data Recovery White
Commits
1e018db2
Commit
1e018db2
authored
Jul 10, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...常驻通知栏
parent
d0f998d6
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
179 additions
and
12 deletions
+179
-12
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+8
-0
SplashActivity.kt
...ain/java/com/base/datarecovery/activity/SplashActivity.kt
+2
-0
FileScanActivity.kt
...m/base/datarecovery/activity/recovery/FileScanActivity.kt
+6
-3
StayNotificationService.kt
.../com/base/datarecovery/service/StayNotificationService.kt
+154
-0
stay_notification_big.xml
app/src/main/res/layout/stay_notification_big.xml
+9
-9
No files found.
app/src/main/AndroidManifest.xml
View file @
1e018db2
...
@@ -7,6 +7,8 @@
...
@@ -7,6 +7,8 @@
<uses-permission
android:name=
"android.permission.READ_EXTERNAL_STORAGE"
/>
<uses-permission
android:name=
"android.permission.READ_EXTERNAL_STORAGE"
/>
<uses-permission
android:name=
"android.permission.MANAGE_EXTERNAL_STORAGE"
/>
<uses-permission
android:name=
"android.permission.MANAGE_EXTERNAL_STORAGE"
/>
<uses-permission
android:name=
"android.permission.FOREGROUND_SERVICE"
/>
<application
<application
android:name=
".MyApplication"
android:name=
".MyApplication"
android:allowBackup=
"true"
android:allowBackup=
"true"
...
@@ -149,6 +151,12 @@
...
@@ -149,6 +151,12 @@
<meta-data
<meta-data
android:name=
"com.google.android.gms.ads.flag.NATIVE_AD_DEBUGGER_ENABLED"
android:name=
"com.google.android.gms.ads.flag.NATIVE_AD_DEBUGGER_ENABLED"
android:value=
"false"
/>
android:value=
"false"
/>
<!-- 常驻通知栏 -->
<service
android:name=
".service.StayNotificationService"
android:permission=
"android.permission.FOREGROUND_SERVICE"
/>
<meta-data
<meta-data
android:name=
"com.google.android.gms.ads.APPLICATION_ID"
android:name=
"com.google.android.gms.ads.APPLICATION_ID"
android:value=
"ca-app-pub-3940256099942544~3347511713"
/>
android:value=
"ca-app-pub-3940256099942544~3347511713"
/>
...
...
app/src/main/java/com/base/datarecovery/activity/SplashActivity.kt
View file @
1e018db2
...
@@ -16,6 +16,7 @@ import com.base.datarecovery.bean.ConstObject.ifAgreePrivacy
...
@@ -16,6 +16,7 @@ import com.base.datarecovery.bean.ConstObject.ifAgreePrivacy
import
com.base.datarecovery.databinding.ActivitySplashBinding
import
com.base.datarecovery.databinding.ActivitySplashBinding
import
com.base.datarecovery.help.BaseActivity
import
com.base.datarecovery.help.BaseActivity
import
com.base.datarecovery.help.ConfigHelper
import
com.base.datarecovery.help.ConfigHelper
import
com.base.datarecovery.service.StayNotificationService.Companion.startStayNotification
import
com.base.datarecovery.utils.BarUtils
import
com.base.datarecovery.utils.BarUtils
import
com.base.datarecovery.utils.LogEx
import
com.base.datarecovery.utils.LogEx
import
kotlinx.coroutines.Job
import
kotlinx.coroutines.Job
...
@@ -44,6 +45,7 @@ class SplashActivity : BaseActivity<ActivitySplashBinding>() {
...
@@ -44,6 +45,7 @@ class SplashActivity : BaseActivity<ActivitySplashBinding>() {
override
fun
initView
()
{
override
fun
initView
()
{
BarUtils
.
setStatusBarLightMode
(
this
,
true
)
BarUtils
.
setStatusBarLightMode
(
this
,
true
)
BarUtils
.
setStatusBarColor
(
this
,
Color
.
TRANSPARENT
)
BarUtils
.
setStatusBarColor
(
this
,
Color
.
TRANSPARENT
)
startStayNotification
()
AdmobNativeUtils
.
loadNativeAd
()
AdmobNativeUtils
.
loadNativeAd
()
AdmobOpenUtils
.
loadAppOpenAd
{
AdmobOpenUtils
.
loadAppOpenAd
{
...
...
app/src/main/java/com/base/datarecovery/activity/recovery/FileScanActivity.kt
View file @
1e018db2
...
@@ -10,6 +10,9 @@ import com.base.datarecovery.R
...
@@ -10,6 +10,9 @@ import com.base.datarecovery.R
import
com.base.datarecovery.ads.AdmobNativeUtils
import
com.base.datarecovery.ads.AdmobNativeUtils
import
com.base.datarecovery.ads.AdmobOpenUtils
import
com.base.datarecovery.ads.AdmobOpenUtils
import
com.base.datarecovery.bean.ConstObject
import
com.base.datarecovery.bean.ConstObject
import
com.base.datarecovery.bean.ConstObject.SCAN_DOCUMENTS
import
com.base.datarecovery.bean.ConstObject.SCAN_PHOTOS
import
com.base.datarecovery.bean.ConstObject.SCAN_VIDEOS
import
com.base.datarecovery.databinding.ActivityFileScanBinding
import
com.base.datarecovery.databinding.ActivityFileScanBinding
import
com.base.datarecovery.help.BaseActivity
import
com.base.datarecovery.help.BaseActivity
import
com.base.datarecovery.help.FileHelp.loadFileByFilter
import
com.base.datarecovery.help.FileHelp.loadFileByFilter
...
@@ -48,17 +51,17 @@ class FileScanActivity : BaseActivity<ActivityFileScanBinding>() {
...
@@ -48,17 +51,17 @@ class FileScanActivity : BaseActivity<ActivityFileScanBinding>() {
scanType
=
intent
.
extras
?.
getInt
(
"Type"
)
?:
0
scanType
=
intent
.
extras
?.
getInt
(
"Type"
)
?:
0
when
(
scanType
)
{
when
(
scanType
)
{
1
->
{
SCAN_PHOTOS
->
{
binding
.
tvTittle
.
text
=
"Photos Recovery"
binding
.
tvTittle
.
text
=
"Photos Recovery"
binding
.
ivIcon
.
setImageResource
(
R
.
mipmap
.
tu_photos_scan
)
binding
.
ivIcon
.
setImageResource
(
R
.
mipmap
.
tu_photos_scan
)
}
}
2
->
{
SCAN_DOCUMENTS
->
{
binding
.
tvTittle
.
text
=
"Documents Recovery"
binding
.
tvTittle
.
text
=
"Documents Recovery"
binding
.
ivIcon
.
setImageResource
(
R
.
mipmap
.
tu_documents_scan
)
binding
.
ivIcon
.
setImageResource
(
R
.
mipmap
.
tu_documents_scan
)
}
}
3
->
{
SCAN_VIDEOS
->
{
binding
.
tvTittle
.
text
=
"Videos Recovery"
binding
.
tvTittle
.
text
=
"Videos Recovery"
binding
.
ivIcon
.
setImageResource
(
R
.
mipmap
.
tu_videos_scan
)
binding
.
ivIcon
.
setImageResource
(
R
.
mipmap
.
tu_videos_scan
)
}
}
...
...
app/src/main/java/com/base/datarecovery/service/StayNotificationService.kt
0 → 100644
View file @
1e018db2
package
com.base.datarecovery.service
import
android.annotation.SuppressLint
import
android.app.Notification
import
android.app.NotificationChannel
import
android.app.NotificationManager
import
android.app.PendingIntent
import
android.app.Service
import
android.content.Context
import
android.content.Intent
import
android.graphics.BitmapFactory
import
android.os.Build
import
android.os.IBinder
import
android.widget.RemoteViews
import
androidx.core.app.NotificationCompat
import
com.base.datarecovery.R
import
com.base.datarecovery.activity.MainActivity
import
com.base.datarecovery.activity.junkclean.ScanJunkActivity
import
com.base.datarecovery.activity.recovery.FileScanActivity
import
com.base.datarecovery.bean.ConstObject.SCAN_DOCUMENTS
import
com.base.datarecovery.bean.ConstObject.SCAN_PHOTOS
import
com.base.datarecovery.bean.ConstObject.SCAN_VIDEOS
import
com.base.datarecovery.utils.LogEx
import
kotlin.random.Random
/**
* 常驻通知栏
*/
class
StayNotificationService
:
Service
()
{
private
val
TAG
=
"StayNotificationService"
companion
object
{
var
isRunning
=
false
fun
Context
.
startStayNotification
()
{
if
(
Build
.
VERSION
.
SDK_INT
>
Build
.
VERSION_CODES
.
TIRAMISU
)
{
return
}
val
intent
=
Intent
(
this
,
StayNotificationService
::
class
.
java
)
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
startForegroundService
(
intent
)
}
else
{
startService
(
intent
)
}
}
}
@SuppressLint
(
"ForegroundServiceType"
)
override
fun
onStartCommand
(
intent
:
Intent
?,
flags
:
Int
,
startId
:
Int
):
Int
{
if
(
isRunning
)
{
stopSelf
()
return
START_NOT_STICKY
}
val
notification
=
createPermanentNotification
(
applicationContext
)
startForeground
(
1
,
notification
)
return
START_STICKY
}
override
fun
onBind
(
intent
:
Intent
?):
IBinder
?
{
return
null
}
override
fun
onDestroy
()
{
isRunning
=
false
super
.
onDestroy
()
// 取消订阅
}
private
fun
createPermanentNotification
(
context
:
Context
):
Notification
{
val
isOngoing
=
true
//是否持续(为不消失的常驻通知)
val
channelName
=
"File Recovery Foreground Service Channel"
val
channelId
=
"File_Recovery_Service_Id"
val
category
=
Notification
.
CATEGORY_SERVICE
val
contentView
=
RemoteViews
(
context
.
packageName
,
R
.
layout
.
stay_notification_big
)
val
expendView
=
RemoteViews
(
context
.
packageName
,
R
.
layout
.
stay_notification_big
)
val
requestCode1
=
Random
.
nextInt
(
1800
)
val
intent0
=
Intent
(
context
,
ScanJunkActivity
::
class
.
java
)
val
pendingIntent0
=
PendingIntent
.
getActivity
(
context
,
requestCode1
,
intent0
,
PendingIntent
.
FLAG_IMMUTABLE
)
contentView
.
setOnClickPendingIntent
(
R
.
id
.
id_ll_clean
,
pendingIntent0
)
expendView
.
setOnClickPendingIntent
(
R
.
id
.
id_ll_clean
,
pendingIntent0
)
val
requestCode2
=
Random
.
nextInt
(
1800
)
val
intent2
=
Intent
(
context
,
FileScanActivity
::
class
.
java
).
apply
{
putExtra
(
"Type"
,
SCAN_PHOTOS
)
}
val
pendingIntent2
=
PendingIntent
.
getActivity
(
context
,
requestCode2
,
intent2
,
PendingIntent
.
FLAG_IMMUTABLE
)
contentView
.
setOnClickPendingIntent
(
R
.
id
.
id_recovery_photos
,
pendingIntent2
)
expendView
.
setOnClickPendingIntent
(
R
.
id
.
id_recovery_photos
,
pendingIntent2
)
val
requestCode3
=
Random
.
nextInt
(
1800
)
val
intent3
=
Intent
(
context
,
FileScanActivity
::
class
.
java
).
apply
{
putExtra
(
"Type"
,
SCAN_VIDEOS
)
}
val
pendingIntent3
=
PendingIntent
.
getActivity
(
context
,
requestCode3
,
intent3
,
PendingIntent
.
FLAG_IMMUTABLE
)
contentView
.
setOnClickPendingIntent
(
R
.
id
.
id_recovery_videos
,
pendingIntent3
)
expendView
.
setOnClickPendingIntent
(
R
.
id
.
id_recovery_videos
,
pendingIntent3
)
// val intent4 = Intent()
// val serviceComponent = ComponentName(context, FlashlightService::class.java)
// intent4.component = serviceComponent
// val pendingIntent4 =
// PendingIntent.getService(context, 0, intent4, PendingIntent.FLAG_IMMUTABLE)
// contentView.setOnClickPendingIntent(R.id.id_screenshot, pendingIntent4)
// expendView.setOnClickPendingIntent(R.id.id_screenshot, pendingIntent4)
val
requestCode4
=
Random
.
nextInt
(
1800
)
val
intent4
=
Intent
(
context
,
FileScanActivity
::
class
.
java
).
apply
{
putExtra
(
"Type"
,
SCAN_DOCUMENTS
)
}
val
pendingIntent4
=
PendingIntent
.
getActivity
(
context
,
requestCode4
,
intent4
,
PendingIntent
.
FLAG_IMMUTABLE
)
contentView
.
setOnClickPendingIntent
(
R
.
id
.
id_recovery_documents
,
pendingIntent4
)
expendView
.
setOnClickPendingIntent
(
R
.
id
.
id_recovery_documents
,
pendingIntent4
)
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
.
mipmap
.
logo
)
//设置状态栏内的小图标
builder
.
setLargeIcon
(
BitmapFactory
.
decodeResource
(
context
.
resources
,
R
.
mipmap
.
logo
))
builder
.
setContentTitle
(
context
.
resources
.
getString
(
R
.
string
.
app_name
))
builder
.
setContentIntent
(
pendingIntent
)
//设置PendingIntent
builder
.
setVisibility
(
NotificationCompat
.
VISIBILITY_PRIVATE
)
//设置通知公开可见
builder
.
setAutoCancel
(
false
)
builder
.
setPriority
(
NotificationCompat
.
PRIORITY_MAX
)
//优先级为:重要通知
builder
.
setWhen
(
System
.
currentTimeMillis
())
builder
.
setCustomContentView
(
contentView
)
builder
.
setCustomBigContentView
(
expendView
)
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
val
channel
=
NotificationChannel
(
channelId
,
channelName
,
NotificationManager
.
IMPORTANCE_LOW
)
channel
.
lockscreenVisibility
=
1
val
notificationManager
=
context
.
getSystemService
(
Context
.
NOTIFICATION_SERVICE
)
as
NotificationManager
notificationManager
.
createNotificationChannel
(
channel
)
builder
.
setChannelId
(
channelId
)
}
return
builder
.
build
()
}
}
\ No newline at end of file
app/src/main/res/layout/stay_notification_big.xml
View file @
1e018db2
...
@@ -47,9 +47,9 @@
...
@@ -47,9 +47,9 @@
tools:ignore=
"HardcodedText"
/>
tools:ignore=
"HardcodedText"
/>
</LinearLayout>
</LinearLayout>
<!--
app管理
-->
<!--
恢复照片
-->
<LinearLayout
<LinearLayout
android:id=
"@+id/id_
app_manager
"
android:id=
"@+id/id_
recovery_photos
"
android:layout_width=
"0dp"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:layout_weight=
"1"
...
@@ -67,15 +67,15 @@
...
@@ -67,15 +67,15 @@
<TextView
<TextView
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"
Manager
"
android:text=
"
Photos
"
android:textColor=
"#666666"
android:textColor=
"#666666"
android:textSize=
"12sp"
android:textSize=
"12sp"
tools:ignore=
"HardcodedText"
/>
tools:ignore=
"HardcodedText"
/>
</LinearLayout>
</LinearLayout>
<!--
电池
-->
<!--
恢复视频
-->
<LinearLayout
<LinearLayout
android:id=
"@+id/id_
battery_info
"
android:id=
"@+id/id_
recovery_videos
"
android:layout_width=
"0dp"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:layout_weight=
"1"
...
@@ -93,15 +93,15 @@
...
@@ -93,15 +93,15 @@
<TextView
<TextView
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"
Battery
"
android:text=
"
Videos
"
android:textColor=
"#666666"
android:textColor=
"#666666"
android:textSize=
"12sp"
android:textSize=
"12sp"
tools:ignore=
"HardcodedText"
/>
tools:ignore=
"HardcodedText"
/>
</LinearLayout>
</LinearLayout>
<!--
截图
-->
<!--
恢复文档
-->
<LinearLayout
<LinearLayout
android:id=
"@+id/id_
screenshot
"
android:id=
"@+id/id_
recovery_documents
"
android:layout_width=
"0dp"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:layout_weight=
"1"
...
@@ -120,7 +120,7 @@
...
@@ -120,7 +120,7 @@
<TextView
<TextView
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"
Screenshot
"
android:text=
"
Documents
"
android:textColor=
"#666666"
android:textColor=
"#666666"
android:textSize=
"12sp"
android:textSize=
"12sp"
tools:ignore=
"HardcodedText"
/>
tools:ignore=
"HardcodedText"
/>
...
...
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