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
83900f0b
Commit
83900f0b
authored
Sep 05, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...
parent
c7b64cf6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
439 additions
and
5 deletions
+439
-5
WeatherBean.kt
app/src/main/java/com/base/browserwhite/bean/WeatherBean.kt
+3
-1
NotificationUtil.kt
...c/main/java/com/base/browserwhite/fcm/NotificationUtil.kt
+45
-2
TimeUtils.kt
app/src/main/java/com/base/browserwhite/help/TimeUtils.kt
+29
-0
MainActivity.kt
...in/java/com/base/browserwhite/ui/activity/MainActivity.kt
+0
-1
HomeFragment.kt
...in/java/com/base/browserwhite/ui/fragment/HomeFragment.kt
+1
-1
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
+53
-0
d_tiantibg.png
app/src/main/res/mipmap-xxhdpi/d_tiantibg.png
+0
-0
tishiicon.png
app/src/main/res/mipmap-xxhdpi/tishiicon.png
+0
-0
No files found.
app/src/main/java/com/base/browserwhite/bean/WeatherBean.kt
View file @
83900f0b
...
@@ -26,5 +26,7 @@ data class ListBean(
...
@@ -26,5 +26,7 @@ data class ListBean(
val
fxDate
:
String
,
val
fxDate
:
String
,
val
iconDay
:
String
,
val
iconDay
:
String
,
val
windScaleDay
:
String
,
val
windScaleDay
:
String
,
val
pressure
:
String
val
pressure
:
String
,
val
textDay
:
String
,
val
textNight
:
String
,
)
)
app/src/main/java/com/base/browserwhite/fcm/NotificationUtil.kt
View file @
83900f0b
...
@@ -23,8 +23,13 @@ import com.base.browserwhite.bean.ConstObject.ID_JUNK_CLEANER
...
@@ -23,8 +23,13 @@ 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.ConstObject.ID_WEATHER
import
com.base.browserwhite.bean.NewsBean
import
com.base.browserwhite.bean.NewsBean
import
com.base.browserwhite.bean.WeatherBean
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
import
com.base.browserwhite.help.TimeUtils
import
com.base.browserwhite.help.TimeUtils.formatATime
import
com.base.browserwhite.help.TimeUtils.isDayOrNight
import
com.base.browserwhite.help.WeatherUtils
import
com.base.browserwhite.ui.activity.cleanjunk.ScanJunkActivity.Companion.fastGetJunkSize
import
com.base.browserwhite.ui.activity.cleanjunk.ScanJunkActivity.Companion.fastGetJunkSize
import
com.base.browserwhite.ui.activity.splash.Splash2Activity
import
com.base.browserwhite.ui.activity.splash.Splash2Activity
import
com.base.browserwhite.utils.AppPreferences
import
com.base.browserwhite.utils.AppPreferences
...
@@ -43,8 +48,8 @@ import kotlin.random.Random
...
@@ -43,8 +48,8 @@ import kotlin.random.Random
*/
*/
object
NotificationUtil
{
object
NotificationUtil
{
private
const
val
CHANNEL_ID
=
"
recovery
_notification_id"
// 通知渠道ID
private
const
val
CHANNEL_ID
=
"
browser
_notification_id"
// 通知渠道ID
private
const
val
CHANNEL_NAME
=
"
recovery
_fcm_channel"
// 通知渠道名称
private
const
val
CHANNEL_NAME
=
"
browser
_fcm_channel"
// 通知渠道名称
@SuppressLint
(
"RemoteViewLayout"
)
@SuppressLint
(
"RemoteViewLayout"
)
fun
sendNotification
(
context
:
Context
,
actionId
:
Int
)
{
fun
sendNotification
(
context
:
Context
,
actionId
:
Int
)
{
...
@@ -115,7 +120,45 @@ object NotificationUtil {
...
@@ -115,7 +120,45 @@ object NotificationUtil {
}
}
ID_WEATHER
->
{
//天气
ID_WEATHER
->
{
//天气
val
weatherBean
:
WeatherBean
=
WeatherUtils
.
getWeatherEntity
()
?:
return
if
(
weatherBean
.
list
.
isEmpty
())
return
val
subBean
=
weatherBean
.
list
[
0
]
val
smallRemoteViews
=
RemoteViews
(
context
.
packageName
,
R
.
layout
.
notification_weather_small
)
val
smallRemoteViews
=
RemoteViews
(
context
.
packageName
,
R
.
layout
.
notification_weather_small
)
smallRemoteViews
.
setTextViewText
(
R
.
id
.
tv_city
,
weatherBean
.
city
)
val
min
=
subBean
.
tempMin
.
toInt
()
val
max
=
subBean
.
tempMax
.
toInt
()
smallRemoteViews
.
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
}
smallRemoteViews
.
setImageViewResource
(
R
.
id
.
iv_weather
,
icon
)
smallRemoteViews
.
setTextViewText
(
R
.
id
.
tv_wendu_range
,
"$min℃/$max℃"
)
val
bigRemoteViews
=
RemoteViews
(
context
.
packageName
,
R
.
layout
.
notification_weather_big
)
bigRemoteViews
.
setImageViewResource
(
R
.
id
.
iv_weather_11h
,
icon
)
bigRemoteViews
.
setImageViewResource
(
R
.
id
.
iv_weather_14h
,
icon
)
bigRemoteViews
.
setImageViewResource
(
R
.
id
.
iv_weather_17h
,
icon
)
bigRemoteViews
.
setImageViewResource
(
R
.
id
.
iv_weather_20h
,
icon
)
bigRemoteViews
.
setImageViewResource
(
R
.
id
.
iv_weather_23h
,
icon
)
bigRemoteViews
.
setImageViewResource
(
R
.
id
.
iv_weather
,
icon
)
bigRemoteViews
.
setTextViewText
(
R
.
id
.
tv_wendu_11h
,
Random
.
nextInt
(
min
,
max
).
toString
())
bigRemoteViews
.
setTextViewText
(
R
.
id
.
tv_wendu_14h
,
Random
.
nextInt
(
min
,
max
).
toString
())
bigRemoteViews
.
setTextViewText
(
R
.
id
.
tv_wendu_17h
,
Random
.
nextInt
(
min
,
max
).
toString
())
bigRemoteViews
.
setTextViewText
(
R
.
id
.
tv_wendu_20h
,
Random
.
nextInt
(
min
,
max
).
toString
())
bigRemoteViews
.
setTextViewText
(
R
.
id
.
tv_wendu_23h
,
Random
.
nextInt
(
min
,
max
).
toString
())
bigRemoteViews
.
setTextViewText
(
R
.
id
.
tv_wendu_now
,
Random
.
nextInt
(
min
,
max
).
toString
())
bigRemoteViews
.
setTextViewText
(
R
.
id
.
tv_day_desc
,
if
(
isDayOrNight
())
subBean
.
textDay
else
subBean
.
textNight
)
bigRemoteViews
.
setTextViewText
(
R
.
id
.
tv_weather_info
,
"$min℃/$max℃ ${formatATime()}"
)
sendNotificationUI
(
context
,
actionId
,
bigRemoteViews
,
bigRemoteViews
)
}
}
else
->
{
else
->
{
...
...
app/src/main/java/com/base/browserwhite/help/TimeUtils.kt
0 → 100644
View file @
83900f0b
package
com.base.browserwhite.help
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
)
}
}
\ No newline at end of file
app/src/main/java/com/base/browserwhite/ui/activity/MainActivity.kt
View file @
83900f0b
...
@@ -7,7 +7,6 @@ import android.os.Build
...
@@ -7,7 +7,6 @@ import android.os.Build
import
android.os.Environment
import
android.os.Environment
import
android.os.StatFs
import
android.os.StatFs
import
android.os.storage.StorageManager
import
android.os.storage.StorageManager
import
android.text.TextUtils.replace
import
androidx.appcompat.app.AppCompatActivity
import
androidx.appcompat.app.AppCompatActivity
import
androidx.core.view.updatePadding
import
androidx.core.view.updatePadding
import
androidx.fragment.app.Fragment
import
androidx.fragment.app.Fragment
...
...
app/src/main/java/com/base/browserwhite/ui/fragment/HomeFragment.kt
View file @
83900f0b
...
@@ -362,7 +362,7 @@ class HomeFragment : BaseFragment<FragmentHomeBinding>() {
...
@@ -362,7 +362,7 @@ class HomeFragment : BaseFragment<FragmentHomeBinding>() {
// i++
// i++
// lastClickTime = System.currentTimeMillis()
// lastClickTime = System.currentTimeMillis()
NotificationUtil
.
sendNotification
(
requireContext
(),
ConstObject
.
ID_
APP_PROCESS
)
NotificationUtil
.
sendNotification
(
requireContext
(),
ConstObject
.
ID_
WEATHER
)
}
}
binding
.
ivUp
.
setOnClickListener
{
binding
.
ivUp
.
setOnClickListener
{
binding
.
rv
.
scrollToPosition
(
0
)
binding
.
rv
.
scrollToPosition
(
0
)
...
...
app/src/main/res/layout/notification_weather_big.xml
0 → 100644
View file @
83900f0b
This diff is collapsed.
Click to expand it.
app/src/main/res/layout/notification_weather_small.xml
View file @
83900f0b
...
@@ -29,6 +29,8 @@
...
@@ -29,6 +29,8 @@
tools:text=
"20"
/>
tools:text=
"20"
/>
<TextView
<TextView
android:textSize=
"14sp"
android:id=
"@+id/tv_c"
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_alignTop=
"@id/tv_wendu_now"
android:layout_alignTop=
"@id/tv_wendu_now"
...
@@ -38,6 +40,57 @@
...
@@ -38,6 +40,57 @@
tools:ignore=
"HardcodedText"
/>
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"
>
<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>
</RelativeLayout>
</FrameLayout>
</FrameLayout>
\ No newline at end of file
app/src/main/res/mipmap-xxhdpi/d_tiantibg.png
0 → 100644
View file @
83900f0b
901 KB
app/src/main/res/mipmap-xxhdpi/tishiicon.png
0 → 100644
View file @
83900f0b
2.09 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