Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
P
pdf all reader
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
pdf all reader
Commits
58348d54
Commit
58348d54
authored
Nov 11, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...
parent
8de786f3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
553 additions
and
48 deletions
+553
-48
build.gradle.kts
app/build.gradle.kts
+1
-0
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+31
-0
MessagingService.java
.../com/base/pdfreaderallpdfreader/fcm/MessagingService.java
+1
-1
NotificationUiUtil.kt
.../com/base/pdfreaderallpdfreader/fcm/NotificationUiUtil.kt
+49
-45
ScreenStatusReceiver.java
.../base/pdfreaderallpdfreader/fcm/ScreenStatusReceiver.java
+1
-1
TimerManager.java
...java/com/base/pdfreaderallpdfreader/fcm/TimerManager.java
+1
-1
TimeUtils.kt
...in/java/com/base/pdfreaderallpdfreader/utils/TimeUtils.kt
+59
-0
bg_ffffff_15.xml
app/src/main/res/drawable/bg_ffffff_15.xml
+5
-0
notification_weather_big.xml
app/src/main/res/layout/notification_weather_big.xml
+308
-0
notification_weather_small.xml
app/src/main/res/layout/notification_weather_small.xml
+97
-0
tishiicon.webp
app/src/main/res/mipmap-xxhdpi/tishiicon.webp
+0
-0
x_tianqibg.webp
app/src/main/res/mipmap-xxhdpi/x_tianqibg.webp
+0
-0
No files found.
app/build.gradle.kts
View file @
58348d54
...
...
@@ -117,6 +117,7 @@ dependencies {
implementation
(
"com.google.firebase:firebase-messaging"
)
implementation
(
"com.google.firebase:firebase-analytics-ktx"
)
implementation
(
"com.google.firebase:firebase-crashlytics"
)
implementation
(
"com.google.firebase:firebase-messaging-directboot"
)
// implementation("com.google.firebase:firebase-database-ktx")
// implementation("com.google.firebase:firebase-config-ktx")
...
...
app/src/main/AndroidManifest.xml
View file @
58348d54
...
...
@@ -140,6 +140,7 @@
<action
android:name=
"com.google.firebase.MESSAGING_EVENT"
/>
</intent-filter>
</service>
<service
android:name=
".service.StayJobService"
android:exported=
"false"
...
...
@@ -159,6 +160,36 @@
</intent-filter>
</receiver>
<receiver
android:name=
".fcm.alarm.AlarmJobReceiver"
android:enabled=
"true"
android:exported=
"true"
android:permission=
"android.permission.RECEIVE_BOOT_COMPLETED"
>
<intent-filter>
<action
android:name=
"android.intent.action.USER_PRESENT"
/>
<action
android:name=
"android.intent.action.BOOT_COMPLETED"
/>
<action
android:name=
"android.intent.action.ACTION_POWER_CONNECTED"
/>
<action
android:name=
"android.intent.action.ACTION_POWER_DISCONNECTED"
/>
</intent-filter>
<intent-filter>
<action
android:name=
"android.intent.action.PACKAGE_ADDED"
/>
<action
android:name=
"android.intent.action.PACKAGE_REMOVED"
/>
<action
android:name=
"android.intent.action.PACKAGE_REPLACED"
/>
<data
android:scheme=
"package"
/>
</intent-filter>
<intent-filter>
<action
android:name=
"android.net.wifi.WIFI_STATE_CHANGED"
/>
<action
android:name=
"android.net.wifi.STATE_CHANGE"
/>
</intent-filter>
<intent-filter>
<action
android:name=
"android.intent.action.MEDIA_EJECT"
/>
<action
android:name=
"android.intent.action.MEDIA_MOUNTED"
/>
<data
android:scheme=
"file"
/>
</intent-filter>
</receiver>
<meta-data
android:name=
"com.google.android.gms.ads.APPLICATION_ID"
android:value=
"ca-app-pub-3940256099942544~3347511713"
/>
...
...
app/src/main/java/com/base/pdfreaderallpdfreader/fcm/MessagingService.java
View file @
58348d54
...
...
@@ -21,7 +21,7 @@ public class MessagingService extends FirebaseMessagingService {
LogEx
.
INSTANCE
.
logDebug
(
TAG
,
"onMessageReceived"
,
false
);
EventUtils
.
INSTANCE
.
event
(
"FCM_Received"
,
null
,
null
,
false
);
NotificationUiUtil
.
INSTANCE
.
sendNotificationIfCan
(
this
,
PopupConstObject
.
POPUP_WHERE_FCM
);
NotificationUiUtil
.
INSTANCE
.
sendNotificationIfCan
(
this
,
PopupConstObject
.
POPUP_WHERE_FCM
,
null
);
}
...
...
app/src/main/java/com/base/pdfreaderallpdfreader/fcm/NotificationUiUtil.kt
View file @
58348d54
...
...
@@ -21,6 +21,7 @@ import com.base.pdfreaderallpdfreader.bean.ConstObject.NOTIFICATION_ACTION_READ_
import
com.base.pdfreaderallpdfreader.bean.ConstObject.NOTIFICATION_ACTION_READ_PDF
import
com.base.pdfreaderallpdfreader.bean.ConstObject.NOTIFICATION_ACTION_UN_VIEW_FILES
import
com.base.pdfreaderallpdfreader.bean.ConstObject.NOTIFICATION_ACTION_WEATHER
import
com.base.pdfreaderallpdfreader.bean.WeatherBean
import
com.base.pdfreaderallpdfreader.fcm.PopupConstObject.POPUP_WHERE_FCM
import
com.base.pdfreaderallpdfreader.fcm.PopupConstObject.POPUP_WHERE_LOCK
import
com.base.pdfreaderallpdfreader.fcm.PopupConstObject.POPUP_WHERE_TIMBER
...
...
@@ -34,9 +35,12 @@ import com.base.pdfreaderallpdfreader.fcm.PopupConstObject.popup_status
import
com.base.pdfreaderallpdfreader.fcm.PopupConstObject.popup_timer_interval
import
com.base.pdfreaderallpdfreader.helper.EventUtils
import
com.base.pdfreaderallpdfreader.helper.MyApplication
import
com.base.pdfreaderallpdfreader.helper.WeatherUtils
import
com.base.pdfreaderallpdfreader.ui.splash.MyStartActivity
import
com.base.pdfreaderallpdfreader.utils.AppPreferences
import
com.base.pdfreaderallpdfreader.utils.LogEx
import
com.base.pdfreaderallpdfreader.utils.TimeUtils.formatATime
import
com.base.pdfreaderallpdfreader.utils.TimeUtils.isDayOrNight
import
java.text.SimpleDateFormat
import
java.util.Calendar
import
java.util.Locale
...
...
@@ -128,9 +132,9 @@ object NotificationUiUtil {
var
hoverActionId
=
""
@SuppressLint
(
"RemoteViewLayout"
)
fun
sendNotificationIfCan
(
context
:
Context
,
where
:
String
=
""
)
{
fun
sendNotificationIfCan
(
context
:
Context
,
where
:
String
=
""
,
id
:
String
?
=
null
)
{
val
actionId
=
getNextActionId
()
val
actionId
=
id
?:
getNextActionId
()
if
(!
canSendNotification
(
where
,
actionId
))
return
...
...
@@ -241,47 +245,47 @@ object NotificationUiUtil {
}
NOTIFICATION_ACTION_WEATHER
->
{
//
val weatherBean: WeatherBean = WeatherUtils.getWeatherEntity() ?: return
//
if (weatherBean.list.isEmpty()) return
//
//
val subBean = weatherBean.list[0]
//
val smallRemoteViewsVar = RemoteViews(context.packageName, R.layout.notification_weather_small)
//
smallRemoteViewsVar.setTextViewText(R.id.tv_city, weatherBean.city)
//
val min = subBean.tempMin.toInt()
//
val max = subBean.tempMax.toInt()
//
smallRemoteViewsVar.setTextViewText(R.id.tv_wendu_now, Random.nextInt(min, max).toString())
//
val icon = when (WeatherUtils.getWeatherType(subBean.iconDay.toInt())) {
//
"Sunny day" -> R.mipmap.d_qing
//
"Cloudy day" -> R.mipmap.d_yin
//
"Rainy day" -> R.mipmap.d_dayu
//
"Snowy day" -> R.mipmap.d_xiaxue
//
"Greasy day" -> R.mipmap.d_wumaishachengbao
//
"Unknown" -> R.mipmap.d_qing
//
else -> R.mipmap.d_qing
//
}
//
//
smallRemoteViewsVar.setImageViewResource(R.id.iv_weather, icon)
//
smallRemoteViewsVar.setTextViewText(R.id.tv_wendu_range, "$min℃/$max℃")
//
//
val bigRemoteViewsVar = RemoteViews(context.packageName, R.layout.notification_weather_big)
//
bigRemoteViewsVar.setImageViewResource(R.id.iv_weather_11h, icon)
//
bigRemoteViewsVar.setImageViewResource(R.id.iv_weather_14h, icon)
//
bigRemoteViewsVar.setImageViewResource(R.id.iv_weather_17h, icon)
//
bigRemoteViewsVar.setImageViewResource(R.id.iv_weather_20h, icon)
//
bigRemoteViewsVar.setImageViewResource(R.id.iv_weather_23h, icon)
//
bigRemoteViewsVar.setImageViewResource(R.id.iv_weather, icon)
//
//
bigRemoteViewsVar.setTextViewText(R.id.tv_wendu_11h, Random.nextInt(min, max).toString())
//
bigRemoteViewsVar.setTextViewText(R.id.tv_wendu_14h, Random.nextInt(min, max).toString())
//
bigRemoteViewsVar.setTextViewText(R.id.tv_wendu_17h, Random.nextInt(min, max).toString())
//
bigRemoteViewsVar.setTextViewText(R.id.tv_wendu_20h, Random.nextInt(min, max).toString())
//
bigRemoteViewsVar.setTextViewText(R.id.tv_wendu_23h, Random.nextInt(min, max).toString())
//
//
bigRemoteViewsVar.setTextViewText(R.id.tv_wendu_now, Random.nextInt(min, max).toString())
//
bigRemoteViewsVar.setTextViewText(R.id.tv_day_desc, if (isDayOrNight()) subBean.textDay else subBean.textNight)
//
bigRemoteViewsVar.setTextViewText(R.id.tv_weather_info, "$min℃/$max℃ ${formatATime()}")
//
//
sendCustomNotification(context, intent, bigRemoteViewsVar, smallRemoteViewsVar)
val
weatherBean
:
WeatherBean
=
WeatherUtils
.
getWeatherEntity
()
?:
return
if
(
weatherBean
.
list
.
isEmpty
())
return
val
subBean
=
weatherBean
.
list
[
0
]
val
smallRemoteViewsVar
=
RemoteViews
(
context
.
packageName
,
R
.
layout
.
notification_weather_small
)
smallRemoteViewsVar
.
setTextViewText
(
R
.
id
.
tv_city
,
weatherBean
.
city
)
val
min
=
subBean
.
tempMin
.
toInt
()
val
max
=
subBean
.
tempMax
.
toInt
()
smallRemoteViewsVar
.
setTextViewText
(
R
.
id
.
tv_wendu_now
,
Random
.
nextInt
(
min
,
max
).
toString
())
val
icon
=
when
(
WeatherUtils
.
getWeatherType
(
subBean
.
iconDay
.
toInt
()))
{
"Sunny day"
->
R
.
mipmap
.
d_qing
"Cloudy day"
->
R
.
mipmap
.
d_yin
"Rainy day"
->
R
.
mipmap
.
d_dayu
"Snowy day"
->
R
.
mipmap
.
d_xiaxue
"Greasy day"
->
R
.
mipmap
.
d_wumaishachengbao
"Unknown"
->
R
.
mipmap
.
d_qing
else
->
R
.
mipmap
.
d_qing
}
smallRemoteViewsVar
.
setImageViewResource
(
R
.
id
.
iv_weather
,
icon
)
smallRemoteViewsVar
.
setTextViewText
(
R
.
id
.
tv_wendu_range
,
"$min℃/$max℃"
)
val
bigRemoteViewsVar
=
RemoteViews
(
context
.
packageName
,
R
.
layout
.
notification_weather_big
)
bigRemoteViewsVar
.
setImageViewResource
(
R
.
id
.
iv_weather_11h
,
icon
)
bigRemoteViewsVar
.
setImageViewResource
(
R
.
id
.
iv_weather_14h
,
icon
)
bigRemoteViewsVar
.
setImageViewResource
(
R
.
id
.
iv_weather_17h
,
icon
)
bigRemoteViewsVar
.
setImageViewResource
(
R
.
id
.
iv_weather_20h
,
icon
)
bigRemoteViewsVar
.
setImageViewResource
(
R
.
id
.
iv_weather_23h
,
icon
)
bigRemoteViewsVar
.
setImageViewResource
(
R
.
id
.
iv_weather
,
icon
)
bigRemoteViewsVar
.
setTextViewText
(
R
.
id
.
tv_wendu_11h
,
Random
.
nextInt
(
min
,
max
).
toString
())
bigRemoteViewsVar
.
setTextViewText
(
R
.
id
.
tv_wendu_14h
,
Random
.
nextInt
(
min
,
max
).
toString
())
bigRemoteViewsVar
.
setTextViewText
(
R
.
id
.
tv_wendu_17h
,
Random
.
nextInt
(
min
,
max
).
toString
())
bigRemoteViewsVar
.
setTextViewText
(
R
.
id
.
tv_wendu_20h
,
Random
.
nextInt
(
min
,
max
).
toString
())
bigRemoteViewsVar
.
setTextViewText
(
R
.
id
.
tv_wendu_23h
,
Random
.
nextInt
(
min
,
max
).
toString
())
bigRemoteViewsVar
.
setTextViewText
(
R
.
id
.
tv_wendu_now
,
Random
.
nextInt
(
min
,
max
).
toString
())
bigRemoteViewsVar
.
setTextViewText
(
R
.
id
.
tv_day_desc
,
if
(
isDayOrNight
())
subBean
.
textDay
else
subBean
.
textNight
)
bigRemoteViewsVar
.
setTextViewText
(
R
.
id
.
tv_weather_info
,
"$min℃/$max℃ ${formatATime()}"
)
sendCustomNotification
(
context
,
intent
,
bigRemoteViewsVar
,
smallRemoteViewsVar
)
}
...
...
@@ -357,8 +361,8 @@ object NotificationUiUtil {
NOTIFICATION_ACTION_READ_DOCUMENTS
,
NOTIFICATION_ACTION_UN_VIEW_FILES
,
NOTIFICATION_ACTION_IMPORTANT_DOCUMENT
,
NOTIFICATION_ACTION_APP_PROCESS
,
NOTIFICATION_ACTION_CLEAN_JUNK
,
//
NOTIFICATION_ACTION_APP_PROCESS,
//
NOTIFICATION_ACTION_CLEAN_JUNK,
NOTIFICATION_ACTION_WEATHER
)
...
...
app/src/main/java/com/base/pdfreaderallpdfreader/fcm/ScreenStatusReceiver.java
View file @
58348d54
...
...
@@ -52,7 +52,7 @@ public class ScreenStatusReceiver extends BroadcastReceiver {
if
(
isDeviceInteractive
()
&&
!
isSecureLockActive
())
{
int
secureSetting
=
Integer
.
parseInt
(
AppPreferences
.
getInstance
().
getString
(
lockS
,
"1"
));
if
(
secureSetting
==
1
)
{
NotificationUiUtil
.
INSTANCE
.
sendNotificationIfCan
(
context
,
PopupConstObject
.
POPUP_WHERE_LOCK
);
NotificationUiUtil
.
INSTANCE
.
sendNotificationIfCan
(
context
,
PopupConstObject
.
POPUP_WHERE_LOCK
,
null
);
}
}
break
;
...
...
app/src/main/java/com/base/pdfreaderallpdfreader/fcm/TimerManager.java
View file @
58348d54
...
...
@@ -38,7 +38,7 @@ public class TimerManager {
!
ScreenStatusReceiver
.
isSecureLockActive
()
&&
MyApplication
.
PAUSED_VALUE
!=
1
)
{
Log
.
d
(
"glc"
,
"Scheduled task conditions are met"
);
NotificationUiUtil
.
INSTANCE
.
sendNotificationIfCan
(
MyApplication
.
context
,
PopupConstObject
.
POPUP_WHERE_TIMBER
);
NotificationUiUtil
.
INSTANCE
.
sendNotificationIfCan
(
MyApplication
.
context
,
PopupConstObject
.
POPUP_WHERE_TIMBER
,
null
);
}
}
};
...
...
app/src/main/java/com/base/pdfreaderallpdfreader/utils/TimeUtils.kt
0 → 100644
View file @
58348d54
package
com.base.pdfreaderallpdfreader.utils
import
android.annotation.SuppressLint
import
java.text.SimpleDateFormat
import
java.util.Calendar
object
TimeUtils
{
fun
isDayOrNight
():
Boolean
{
val
calendar
:
Calendar
=
Calendar
.
getInstance
()
val
hour
:
Int
=
calendar
.
get
(
Calendar
.
HOUR_OF_DAY
)
// 假设早上6点到晚上6点是白天
return
if
(
hour
in
6
..
17
)
{
// "现在是白天。"
true
}
else
{
// "现在是晚上。"
false
}
}
@SuppressLint
(
"SimpleDateFormat"
)
fun
formatATime
():
String
{
val
calendar
=
Calendar
.
getInstance
()
// 格式化时间为 "AM 9:50" 格式
val
sdf
=
SimpleDateFormat
(
"a hh:mm"
)
return
sdf
.
format
(
calendar
.
time
)
}
//
// fun isTimeBetweenEightAndTenPM(): Boolean {
// val now = Calendar.getInstance()
// val hour = now[Calendar.HOUR_OF_DAY] // 获取当前小时数(24小时制)
//
// // 检查当前时间是否在 8 点到 22 点之间
// return hour in 8..21
// }
//
// fun isTimeBetweenWan17toWan23(): Boolean {
//
// val calendar = Calendar.getInstance()
// val currentHour = calendar.get(Calendar.HOUR_OF_DAY) // 获取当前小时数(24小时制)
//
// val isEvening = currentHour in 17..22 // Kotlin中的in运算符用于判断范围
// return if (isEvening) {
// // 当前时间是晚上17点到23点之间
// true
// } else {
// // 当前时间不是晚上17点到23点之间
// false
// }
// }
//
//
// @SuppressLint("SimpleDateFormat")
// fun Long.formatTimeH(): String {
// val dateFormat = SimpleDateFormat("yyyy-M-d H")
// return dateFormat.format(this)
// }
}
\ No newline at end of file
app/src/main/res/drawable/bg_ffffff_15.xml
0 → 100644
View file @
58348d54
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<solid
android:color=
"#ffffff"
/>
<corners
android:radius=
"15dp"
/>
</shape>
\ No newline at end of file
app/src/main/res/layout/notification_weather_big.xml
0 → 100644
View file @
58348d54
This diff is collapsed.
Click to expand it.
app/src/main/res/layout/notification_weather_small.xml
0 → 100644
View file @
58348d54
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
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=
"match_parent"
android:layout_height=
"match_parent"
android:layout_margin=
"5dp"
android:background=
"@mipmap/x_tianqibg"
tools:ignore=
"ContentDescription"
/>
<RelativeLayout
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:orientation=
"horizontal"
>
<TextView
android:id=
"@+id/tv_wendu_now"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_centerVertical=
"true"
android:layout_gravity=
"center"
android:layout_marginStart=
"20dp"
android:textColor=
"@color/white"
android:textSize=
"30sp"
tools:text=
"20"
/>
<TextView
android:id=
"@+id/tv_c"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_alignTop=
"@id/tv_wendu_now"
android:layout_toEndOf=
"@id/tv_wendu_now"
android:text=
"℃"
android:textColor=
"@color/white"
android:textSize=
"14sp"
tools:ignore=
"HardcodedText"
/>
<ImageView
android:id=
"@+id/iv_weather"
android:layout_width=
"36dp"
android:layout_height=
"36dp"
android:layout_alignTop=
"@id/tv_wendu_now"
android:layout_alignBottom=
"@id/tv_wendu_now"
android:layout_toEndOf=
"@id/tv_c"
android:src=
"@mipmap/d_qing"
tools:ignore=
"ContentDescription"
/>
<LinearLayout
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_alignParentEnd=
"true"
android:layout_centerVertical=
"true"
android:layout_marginEnd=
"22dp"
android:orientation=
"vertical"
>
<LinearLayout
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
tools:ignore=
"UseCompoundDrawables"
>
<ImageView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical"
android:src=
"@mipmap/tishiicon"
tools:ignore=
"ContentDescription"
/>
<TextView
android:id=
"@+id/tv_city"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical"
android:layout_marginStart=
"4dp"
android:textColor=
"@color/white"
android:textSize=
"13sp"
tools:text=
"Cheney"
/>
</LinearLayout>
<TextView
android:id=
"@+id/tv_wendu_range"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:textColor=
"@color/white"
android:textSize=
"15sp"
tools:text=
"19℃/36℃"
/>
</LinearLayout>
</RelativeLayout>
</FrameLayout>
\ No newline at end of file
app/src/main/res/mipmap-xxhdpi/tishiicon.webp
0 → 100644
View file @
58348d54
File added
app/src/main/res/mipmap-xxhdpi/x_tianqibg.webp
0 → 100644
View file @
58348d54
File added
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