Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
P
PDF Viewer Scanner White ago
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
kuxulei
PDF Viewer Scanner White ago
Commits
727cd032
Commit
727cd032
authored
Oct 11, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...
parent
0fd22711
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
172 additions
and
44 deletions
+172
-44
MyApplication.kt
...va/com/base/pdfviewerscannerwhite/helper/MyApplication.kt
+1
-2
StayNotificationService.kt
.../pdfviewerscannerwhite/service/StayNotificationService.kt
+43
-17
MainActivity.kt
...va/com/base/pdfviewerscannerwhite/ui/main/MainActivity.kt
+25
-16
notification_message.xml
app/src/main/res/layout/notification_message.xml
+27
-0
stay_notification_big.xml
app/src/main/res/layout/stay_notification_big.xml
+11
-9
stay_notification_small.xml
app/src/main/res/layout/stay_notification_small.xml
+65
-0
No files found.
app/src/main/java/com/base/pdfviewerscannerwhite/helper/MyApplication.kt
View file @
727cd032
...
...
@@ -5,7 +5,6 @@ import android.app.Application
import
android.content.Intent
import
android.os.Bundle
import
android.text.TextUtils
import
com.base.pdfviewerscannerwhite.bean.ConstObject
import
com.base.pdfviewerscannerwhite.fcm.FCMManager
import
com.base.pdfviewerscannerwhite.ui.splash.SplashActivity
import
com.base.pdfviewerscannerwhite.utils.ActivityManagerUtils
...
...
@@ -76,7 +75,7 @@ class MyApplication : Application() {
private
var
lastTimePause
=
0L
private
var
lastTimeResume
=
0L
private
fun
isHotLaunch
():
Boolean
{
if
((
lastTimeResume
-
lastTimePause
)
>
2
000
)
{
if
((
lastTimeResume
-
lastTimePause
)
>
5
000
)
{
return
true
}
return
false
...
...
app/src/main/java/com/base/pdfviewerscannerwhite/service/StayNotificationService.kt
View file @
727cd032
...
...
@@ -9,10 +9,12 @@ import android.content.Context
import
android.content.Intent
import
android.content.pm.ServiceInfo
import
android.graphics.BitmapFactory
import
android.graphics.drawable.Icon
import
android.os.Build
import
android.os.IBinder
import
android.widget.RemoteViews
import
androidx.core.app.NotificationCompat
import
androidx.core.graphics.drawable.IconCompat
import
com.base.pdfviewerscannerwhite.R
import
com.base.pdfviewerscannerwhite.bean.ConstObject
import
com.base.pdfviewerscannerwhite.helper.EventUtils
...
...
@@ -59,11 +61,9 @@ class StayNotificationService : Service() {
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
channelName
=
"PDF Reader Foreground Service Channel"
val
channelId
=
"PDF_Reader_Service_Id"
val
contentView
=
RemoteViews
(
context
.
packageName
,
R
.
layout
.
stay_notification_small
)
val
expendView
=
RemoteViews
(
context
.
packageName
,
R
.
layout
.
stay_notification_big
)
val
requestCode1
=
Random
.
nextInt
(
1800
)
...
...
@@ -77,20 +77,46 @@ class StayNotificationService : Service() {
intent1
,
PendingIntent
.
FLAG_IMMUTABLE
)
contentView
.
setOnClickPendingIntent
(
R
.
id
.
ll_2
,
pendingIntent1
)
expendView
.
setOnClickPendingIntent
(
R
.
id
.
ll_2
,
pendingIntent1
)
contentView
.
setOnClickPendingIntent
(
R
.
id
.
fl_1
,
pendingIntent1
)
expendView
.
setOnClickPendingIntent
(
R
.
id
.
fl_1
,
pendingIntent1
)
val
requestCode2
=
Random
.
nextInt
(
1800
)
val
intent2
=
Intent
(
context
,
SplashActivity
::
class
.
java
).
apply
{
putExtra
(
"actionId"
,
ConstObject
.
NOTIFICATION_ACTION_DOCUMENT
)
}
val
pendingIntent2
=
PendingIntent
.
getActivity
(
context
,
requestCode2
,
intent2
,
PendingIntent
.
FLAG_IMMUTABLE
)
contentView
.
setOnClickPendingIntent
(
R
.
id
.
ll_2
,
pendingIntent2
)
expendView
.
setOnClickPendingIntent
(
R
.
id
.
ll_2
,
pendingIntent2
)
val
requestCode3
=
Random
.
nextInt
(
1800
)
val
intent3
=
Intent
(
context
,
SplashActivity
::
class
.
java
).
apply
{
putExtra
(
"actionId"
,
ConstObject
.
NOTIFICATION_ACTION_BOOKMARK
)
}
val
pendingIntent3
=
PendingIntent
.
getActivity
(
context
,
requestCode3
,
intent3
,
PendingIntent
.
FLAG_IMMUTABLE
)
contentView
.
setOnClickPendingIntent
(
R
.
id
.
ll_3
,
pendingIntent3
)
expendView
.
setOnClickPendingIntent
(
R
.
id
.
ll_3
,
pendingIntent3
)
//
val
builder
=
NotificationCompat
.
Builder
(
context
,
channelId
)
//
// val smallIcon = IconCompat.createFromIcon(
// context, Icon.createWithResource(
// MyApplication.context, R.mipmap.logo_notification_small
// )
// )
// smallIcon?.let {
// builder.setSmallIcon(smallIcon) //设置状态栏内的小图标
// }
val
smallIcon
=
IconCompat
.
createFromIcon
(
context
,
Icon
.
createWithResource
(
MyApplication
.
context
,
R
.
mipmap
.
logo
)
)
smallIcon
?.
let
{
builder
.
setSmallIcon
(
smallIcon
)
//设置状态栏内的小图标
}
val
nfIntent
=
Intent
(
context
,
MainActivity
::
class
.
java
)
val
pendingIntent
=
...
...
app/src/main/java/com/base/pdfviewerscannerwhite/ui/main/MainActivity.kt
View file @
727cd032
...
...
@@ -14,6 +14,8 @@ import com.base.pdfviewerscannerwhite.ads.admob.AdmobBannerUtils
import
com.base.pdfviewerscannerwhite.bean.ConstObject
import
com.base.pdfviewerscannerwhite.bean.ConstObject.BOOKMARK_DATA_TYPE
import
com.base.pdfviewerscannerwhite.bean.ConstObject.DOCUMENT_DATA_TYPE
import
com.base.pdfviewerscannerwhite.bean.ConstObject.NOTIFICATION_ACTION_BOOKMARK
import
com.base.pdfviewerscannerwhite.bean.ConstObject.NOTIFICATION_ACTION_DOCUMENT
import
com.base.pdfviewerscannerwhite.bean.ConstObject.RECENT_DATA_TYPE
import
com.base.pdfviewerscannerwhite.bean.ConstObject.SHORTCUT_MERGE_PDF
import
com.base.pdfviewerscannerwhite.bean.ConstObject.SHORTCUT_SCAN_PDF
...
...
@@ -80,6 +82,28 @@ class MainActivity : BaseActivity<ActivityMain2Binding>(), MainView {
actionIdOperation
()
}
private
fun
actionIdOperation
()
{
if
(
actionId
==
SHORTCUT_SCAN_PDF
)
{
mainPresenter
.
starAdGmsScan
(
this
)
}
if
(
actionId
==
SHORTCUT_SPLIT_PDF
)
{
startActivity
(
Intent
(
this
,
PdfSelectActivity
::
class
.
java
).
apply
{
putExtra
(
"doWhat"
,
ConstObject
.
DO_SPLIT_PDF
)
})
}
if
(
actionId
==
SHORTCUT_MERGE_PDF
)
{
startActivity
(
Intent
(
this
,
PdfSelectActivity
::
class
.
java
).
apply
{
putExtra
(
"doWhat"
,
ConstObject
.
DO_MERGE_PDF
)
})
}
if
(
actionId
==
NOTIFICATION_ACTION_DOCUMENT
)
{
binding
.
llDocument
.
callOnClick
()
}
if
(
actionId
==
NOTIFICATION_ACTION_BOOKMARK
)
{
binding
.
llBookmark
.
callOnClick
()
}
}
private
fun
closeScanGuide
()
{
binding
.
flScanGuide
.
visibility
=
View
.
GONE
showPermissionThenBanner
()
...
...
@@ -115,6 +139,7 @@ class MainActivity : BaseActivity<ActivityMain2Binding>(), MainView {
//permission
if
(
checkStorePermission
()
&&
needRefresh
)
{
mainPresenter
.
initAllDocumentData
()
showMainBanner
()
}
else
{
showPermissionThenBanner
()
}
...
...
@@ -282,22 +307,6 @@ class MainActivity : BaseActivity<ActivityMain2Binding>(), MainView {
}
private
fun
actionIdOperation
()
{
if
(
actionId
==
SHORTCUT_SCAN_PDF
)
{
mainPresenter
.
starAdGmsScan
(
this
)
}
if
(
actionId
==
SHORTCUT_SPLIT_PDF
)
{
startActivity
(
Intent
(
this
,
PdfSelectActivity
::
class
.
java
).
apply
{
putExtra
(
"doWhat"
,
ConstObject
.
DO_SPLIT_PDF
)
})
}
if
(
actionId
==
SHORTCUT_MERGE_PDF
)
{
startActivity
(
Intent
(
this
,
PdfSelectActivity
::
class
.
java
).
apply
{
putExtra
(
"doWhat"
,
ConstObject
.
DO_MERGE_PDF
)
})
}
}
private
fun
shareDocument
()
{
if
(
currentFragment
is
DocumentPageFragment
)
{
val
documentFragment
=
(
currentFragment
as
DocumentPageFragment
)
...
...
app/src/main/res/layout/notification_message.xml
0 → 100644
View file @
727cd032
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
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"
>
<TextView
android:id=
"@+id/tv_tittle"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"15dp"
android:layout_marginTop=
"16dp"
android:textColor=
"#010101"
android:textSize=
"16sp"
android:textStyle=
"bold"
tools:text=
"New file available for view"
/>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_below=
"@id/tv_tittle"
android:layout_marginStart=
"15dp"
android:layout_marginTop=
"10dp"
android:layout_marginBottom=
"15dp"
android:textColor=
"#898989"
tools:text=
"Did you miss this PDF file?"
/>
</RelativeLayout>
\ No newline at end of file
app/src/main/res/layout/stay_notification_big.xml
View file @
727cd032
...
...
@@ -4,19 +4,20 @@
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"horizontal"
android:paddingVertical=
"8dp"
tools:ignore=
"DisableBaselineAlignment"
>
<FrameLayout
android:id=
"@+id/fl_1"
android:layout_width=
"0dp"
android:layout_height=
"
wrap_cont
ent"
android:layout_height=
"
match_par
ent"
android:layout_gravity=
"center_vertical"
android:layout_weight=
"1"
>
<ImageView
android:layout_width=
"
5
5dp"
android:layout_height=
"
5
5dp"
android:layout_width=
"
3
5dp"
android:layout_height=
"
3
5dp"
android:layout_gravity=
"center"
android:src=
"@mipmap/logo"
tools:ignore=
"ContentDescription"
/>
...
...
@@ -26,13 +27,14 @@
android:id=
"@+id/ll_2"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical"
android:layout_weight=
"1"
android:orientation=
"vertical"
tools:ignore=
"UseCompoundDrawables"
>
<ImageView
android:layout_width=
"
wrap_content
"
android:layout_height=
"
wrap_content
"
android:layout_width=
"
30dp
"
android:layout_height=
"
30dp
"
android:layout_gravity=
"center_horizontal"
android:src=
"@mipmap/doc_notification"
tools:ignore=
"ContentDescription"
/>
...
...
@@ -44,7 +46,7 @@
android:layout_marginTop=
"2dp"
android:text=
"Document"
android:textColor=
"@color/black"
android:textSize=
"1
6
sp"
android:textSize=
"1
4
sp"
tools:ignore=
"HardcodedText"
/>
</LinearLayout>
...
...
@@ -58,8 +60,8 @@
tools:ignore=
"UseCompoundDrawables"
>
<ImageView
android:layout_width=
"
wrap_content
"
android:layout_height=
"
wrap_content
"
android:layout_width=
"
30dp
"
android:layout_height=
"
30dp
"
android:layout_gravity=
"center_horizontal"
android:src=
"@mipmap/bookmark_notification"
tools:ignore=
"ContentDescription"
/>
...
...
@@ -71,7 +73,7 @@
android:layout_marginTop=
"2dp"
android:text=
"Bookmark"
android:textColor=
"@color/black"
android:textSize=
"1
6
sp"
android:textSize=
"1
4
sp"
tools:ignore=
"HardcodedText"
/>
</LinearLayout>
...
...
app/src/main/res/layout/stay_notification_small.xml
0 → 100644
View file @
727cd032
<?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:orientation=
"horizontal"
android:paddingVertical=
"8dp"
tools:ignore=
"DisableBaselineAlignment"
>
<FrameLayout
android:id=
"@+id/fl_1"
android:layout_width=
"0dp"
android:layout_height=
"match_parent"
android:layout_gravity=
"center_vertical"
android:layout_weight=
"1"
>
<ImageView
android:layout_width=
"35dp"
android:layout_height=
"35dp"
android:layout_gravity=
"center"
android:src=
"@mipmap/logo"
tools:ignore=
"ContentDescription"
/>
</FrameLayout>
<LinearLayout
android:id=
"@+id/ll_2"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical"
android:layout_weight=
"1"
android:orientation=
"vertical"
tools:ignore=
"UseCompoundDrawables"
>
<ImageView
android:layout_width=
"30dp"
android:layout_height=
"30dp"
android:layout_gravity=
"center_horizontal"
android:layout_marginVertical=
"10dp"
android:src=
"@mipmap/doc_notification"
tools:ignore=
"ContentDescription"
/>
</LinearLayout>
<LinearLayout
android:id=
"@+id/ll_3"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:orientation=
"vertical"
tools:ignore=
"UseCompoundDrawables"
>
<ImageView
android:layout_width=
"30dp"
android:layout_height=
"30dp"
android:layout_gravity=
"center_horizontal"
android:layout_marginVertical=
"10dp"
android:src=
"@mipmap/bookmark_notification"
tools:ignore=
"ContentDescription"
/>
</LinearLayout>
</LinearLayout>
\ No newline at end of file
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