Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
P
PhoneManager
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
Yang
PhoneManager
Commits
ebf80e73
Commit
ebf80e73
authored
Apr 07, 2025
by
CZ1004
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
充电壁纸
parent
27d2a238
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
482 additions
and
24 deletions
+482
-24
Info.plist
ChargeShow/Info.plist
+27
-0
IntentHandler.swift
ChargeShow/IntentHandler.swift
+124
-0
Intents.intentdefinition
Intents.intentdefinition
+79
-0
project.pbxproj
PhoneManager.xcodeproj/project.pbxproj
+160
-5
applicationLauncher.json
...source/Animation/LaunchAnimation/applicationLauncher.json
+1
-1
applicationLauncherOld.json
...rce/Animation/LaunchAnimation/applicationLauncherOld.json
+1
-0
ChargeInfoViewController.swift
.../Session/Charge/Controller/ChargeInfoViewController.swift
+5
-2
ChargeViewController.swift
...lass/Session/Charge/Controller/ChargeViewController.swift
+8
-2
ChargeDataModel.swift
...eManager/Class/Session/Charge/Model/ChargeDataModel.swift
+27
-3
ChargeViewCollectionModel.swift
...lass/Session/Charge/Model/ChargeViewCollectionModel.swift
+1
-2
ChargeInfoSettingView.swift
...ger/Class/Session/Charge/View/ChargeInfoSettingView.swift
+15
-0
ChargeVideoPlayingView.swift
...er/Class/Session/Charge/View/ChargeVideoPlayingView.swift
+1
-1
ChargeView.swift
PhoneManager/Class/Session/Charge/View/ChargeView.swift
+7
-2
ChargeViewCollectionCell.swift
.../Class/Session/Charge/View/ChargeViewCollectionCell.swift
+3
-1
HomeViewController.swift
PhoneManager/Class/Session/Home/HomeViewController.swift
+9
-2
BatteryMonitorManager.swift
...l/Class/BatteryMonitorManager/BatteryMonitorManager.swift
+13
-2
Info.plist
PhoneManager/Info.plist
+1
-1
No files found.
ChargeShow/Info.plist
0 → 100644
View file @
ebf80e73
<
?xml
v
e
rsion="
1
.
0
"
e
n
c
o
d
ing="UT
F
-
8
"?
>
<
!
D
O
C
TYP
E
plist
PU
B
LI
C
"-//
A
ppl
e
//
D
T
D
PLIST
1
.
0
//
E
N"
"http://www.
a
ppl
e
.
c
om/
D
T
D
s/Prop
e
rtyList-
1
.
0
.
d
t
d
"
>
<
plist
v
e
rsion="
1
.
0
"
>
<
d
i
c
t
>
<
k
e
y
>
NSExtension
<
/k
e
y
>
<
d
i
c
t
>
<
k
e
y
>
NSExtensionAttributes
<
/k
e
y
>
<
d
i
c
t
>
<
k
e
y
>
IntentsRestrictedWhileLocked
<
/k
e
y
>
<
a
rr
a
y/
>
<
k
e
y
>
IntentsRestrictedWhileProtectedDataUnavailable
<
/k
e
y
>
<
a
rr
a
y/
>
<
k
e
y
>
IntentsSupported
<
/k
e
y
>
<
a
rr
a
y
>
<
string
>
ChargeShowIntent
<
/string
>
<
string
>
INSearchForMessagesIntent
<
/string
>
<
string
>
INSendMessageIntent
<
/string
>
<
string
>
INSetMessageAttributeIntent
<
/string
>
<
/
a
rr
a
y
>
<
/
d
i
c
t
>
<
k
e
y
>
NSExtensionPointIdentifier
<
/k
e
y
>
<
string
>
com.apple.intents-service
<
/string
>
<
k
e
y
>
NSExtensionPrincipalClass
<
/k
e
y
>
<
string
>
$
(
PRODUCT_MODULE_NAME
)
.IntentHandler
<
/string
>
<
/
d
i
c
t
>
<
/
d
i
c
t
>
<
/plist
>
ChargeShow/IntentHandler.swift
0 → 100644
View file @
ebf80e73
//
// IntentHandler.swift
// ChargeShow
//
// Created by edy on 2025/4/7.
//
import
Intents
// As an example, this class is set up to handle Message intents.
// You will want to replace this or add other intents as appropriate.
// The intents you wish to handle must be declared in the extension's Info.plist.
// You can test your example integration by saying things to Siri like:
// "Send a message using <myApp>"
// "<myApp> John saying hello"
// "Search for messages in <myApp>"
class
IntentHandler
:
INExtension
,
INSendMessageIntentHandling
,
INSearchForMessagesIntentHandling
,
INSetMessageAttributeIntentHandling
{
override
func
handler
(
for
intent
:
INIntent
)
->
Any
{
// This is the default implementation. If you want different objects to handle different intents,
// you can override this and return the handler you want for that particular intent.
print
(
"有反应么"
)
return
self
}
// MARK: - INSendMessageIntentHandling
// Implement resolution methods to provide additional information about your intent (optional).
func
resolveRecipients
(
for
intent
:
INSendMessageIntent
,
with
completion
:
@escaping
([
INSendMessageRecipientResolutionResult
])
->
Void
)
{
if
let
recipients
=
intent
.
recipients
{
// If no recipients were provided we'll need to prompt for a value.
if
recipients
.
count
==
0
{
completion
([
INSendMessageRecipientResolutionResult
.
needsValue
()])
return
}
var
resolutionResults
=
[
INSendMessageRecipientResolutionResult
]()
for
recipient
in
recipients
{
let
matchingContacts
=
[
recipient
]
// Implement your contact matching logic here to create an array of matching contacts
switch
matchingContacts
.
count
{
case
2
...
Int
.
max
:
// We need Siri's help to ask user to pick one from the matches.
resolutionResults
+=
[
INSendMessageRecipientResolutionResult
.
disambiguation
(
with
:
matchingContacts
)]
case
1
:
// We have exactly one matching contact
resolutionResults
+=
[
INSendMessageRecipientResolutionResult
.
success
(
with
:
recipient
)]
case
0
:
// We have no contacts matching the description provided
resolutionResults
+=
[
INSendMessageRecipientResolutionResult
.
unsupported
()]
default
:
break
}
}
completion
(
resolutionResults
)
}
else
{
completion
([
INSendMessageRecipientResolutionResult
.
needsValue
()])
}
}
func
resolveContent
(
for
intent
:
INSendMessageIntent
,
with
completion
:
@escaping
(
INStringResolutionResult
)
->
Void
)
{
if
let
text
=
intent
.
content
,
!
text
.
isEmpty
{
completion
(
INStringResolutionResult
.
success
(
with
:
text
))
}
else
{
completion
(
INStringResolutionResult
.
needsValue
())
}
}
// Once resolution is completed, perform validation on the intent and provide confirmation (optional).
func
confirm
(
intent
:
INSendMessageIntent
,
completion
:
@escaping
(
INSendMessageIntentResponse
)
->
Void
)
{
// Verify user is authenticated and your app is ready to send a message.
let
userActivity
=
NSUserActivity
(
activityType
:
NSStringFromClass
(
INSendMessageIntent
.
self
))
let
response
=
INSendMessageIntentResponse
(
code
:
.
ready
,
userActivity
:
userActivity
)
completion
(
response
)
}
// Handle the completed intent (required).
func
handle
(
intent
:
INSendMessageIntent
,
completion
:
@escaping
(
INSendMessageIntentResponse
)
->
Void
)
{
// Implement your application logic to send a message here.
let
userActivity
=
NSUserActivity
(
activityType
:
NSStringFromClass
(
INSendMessageIntent
.
self
))
let
response
=
INSendMessageIntentResponse
(
code
:
.
success
,
userActivity
:
userActivity
)
completion
(
response
)
}
// Implement handlers for each intent you wish to handle. As an example for messages, you may wish to also handle searchForMessages and setMessageAttributes.
// MARK: - INSearchForMessagesIntentHandling
func
handle
(
intent
:
INSearchForMessagesIntent
,
completion
:
@escaping
(
INSearchForMessagesIntentResponse
)
->
Void
)
{
// Implement your application logic to find a message that matches the information in the intent.
let
userActivity
=
NSUserActivity
(
activityType
:
NSStringFromClass
(
INSearchForMessagesIntent
.
self
))
let
response
=
INSearchForMessagesIntentResponse
(
code
:
.
success
,
userActivity
:
userActivity
)
// Initialize with found message's attributes
response
.
messages
=
[
INMessage
(
identifier
:
"identifier"
,
content
:
"I am so excited about SiriKit!"
,
dateSent
:
Date
(),
sender
:
INPerson
(
personHandle
:
INPersonHandle
(
value
:
"sarah@example.com"
,
type
:
.
emailAddress
),
nameComponents
:
nil
,
displayName
:
"Sarah"
,
image
:
nil
,
contactIdentifier
:
nil
,
customIdentifier
:
nil
),
recipients
:
[
INPerson
(
personHandle
:
INPersonHandle
(
value
:
"+1-415-555-5555"
,
type
:
.
phoneNumber
),
nameComponents
:
nil
,
displayName
:
"John"
,
image
:
nil
,
contactIdentifier
:
nil
,
customIdentifier
:
nil
)]
)]
completion
(
response
)
}
// MARK: - INSetMessageAttributeIntentHandling
func
handle
(
intent
:
INSetMessageAttributeIntent
,
completion
:
@escaping
(
INSetMessageAttributeIntentResponse
)
->
Void
)
{
// Implement your application logic to set the message attribute here.
let
userActivity
=
NSUserActivity
(
activityType
:
NSStringFromClass
(
INSetMessageAttributeIntent
.
self
))
let
response
=
INSetMessageAttributeIntentResponse
(
code
:
.
success
,
userActivity
:
userActivity
)
completion
(
response
)
}
}
Intents.intentdefinition
0 → 100644
View file @
ebf80e73
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist
version=
"1.0"
>
<dict>
<key>
INEnums
</key>
<array/>
<key>
INIntentDefinitionModelVersion
</key>
<string>
1.2
</string>
<key>
INIntentDefinitionNamespace
</key>
<string>
hAB6zR
</string>
<key>
INIntentDefinitionSystemVersion
</key>
<string>
24D81
</string>
<key>
INIntentDefinitionToolsBuildVersion
</key>
<string>
16C5032a
</string>
<key>
INIntentDefinitionToolsVersion
</key>
<string>
16.2
</string>
<key>
INIntents
</key>
<array>
<dict>
<key>
INIntentCategory
</key>
<string>
generic
</string>
<key>
INIntentConfigurable
</key>
<true/>
<key>
INIntentDescription
</key>
<string>
充电
</string>
<key>
INIntentDescriptionID
</key>
<string>
wDHi0A
</string>
<key>
INIntentManagedParameterCombinations
</key>
<dict>
<key></key>
<dict>
<key>
INIntentParameterCombinationSupportsBackgroundExecution
</key>
<true/>
<key>
INIntentParameterCombinationUpdatesLinked
</key>
<true/>
</dict>
</dict>
<key>
INIntentName
</key>
<string>
ChargeShow
</string>
<key>
INIntentParameterCombinations
</key>
<dict>
<key></key>
<dict>
<key>
INIntentParameterCombinationIsPrimary
</key>
<true/>
<key>
INIntentParameterCombinationSupportsBackgroundExecution
</key>
<true/>
</dict>
</dict>
<key>
INIntentResponse
</key>
<dict>
<key>
INIntentResponseCodes
</key>
<array>
<dict>
<key>
INIntentResponseCodeName
</key>
<string>
success
</string>
<key>
INIntentResponseCodeSuccess
</key>
<true/>
</dict>
<dict>
<key>
INIntentResponseCodeName
</key>
<string>
failure
</string>
</dict>
</array>
</dict>
<key>
INIntentTitle
</key>
<string>
Charge Show
</string>
<key>
INIntentTitleID
</key>
<string>
wwbZJW
</string>
<key>
INIntentType
</key>
<string>
Custom
</string>
<key>
INIntentVerb
</key>
<string>
Do
</string>
</dict>
</array>
<key>
INTypes
</key>
<array/>
</dict>
</plist>
PhoneManager.xcodeproj/project.pbxproj
View file @
ebf80e73
This diff is collapsed.
Click to expand it.
PhoneManager/Class/Resource/Animation/LaunchAnimation/applicationLauncher.json
View file @
ebf80e73
This diff is collapsed.
Click to expand it.
PhoneManager/Class/Resource/Animation/LaunchAnimation/applicationLauncherOld.json
0 → 100644
View file @
ebf80e73
This diff is collapsed.
Click to expand it.
PhoneManager/Class/Session/Charge/Controller/ChargeInfoViewController.swift
View file @
ebf80e73
...
...
@@ -18,6 +18,8 @@ class ChargeInfoViewController:BaseViewController {
var
type
:
ChargeInfoType
?
var
flag
:
Int
?
var
isShowBack
:
Bool
?
{
didSet
{
...
...
@@ -43,7 +45,8 @@ class ChargeInfoViewController:BaseViewController {
lazy
var
settingView
:
ChargeInfoSettingView
=
{
let
sview
:
ChargeInfoSettingView
=
ChargeInfoSettingView
(
frame
:
CGRect
(
x
:
0
,
y
:
0
,
width
:
view
.
width
,
height
:
78
+
safeHeight
))
sview
.
model
=
self
.
model
sview
.
flag
=
self
.
flag
sview
.
isHidden
=
type
==
.
setting
?
false
:
true
return
sview
...
...
@@ -61,9 +64,9 @@ class ChargeInfoViewController:BaseViewController {
}
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
self
.
barHidden
=
true
titleView
.
model
.
title
=
""
...
...
PhoneManager/Class/Session/Charge/Controller/ChargeViewController.swift
View file @
ebf80e73
...
...
@@ -38,10 +38,16 @@ class ChargeViewController:BaseViewController {
guard
let
self
else
{
return
}
if
let
cModel
=
model
as?
ChargeDataModel
{
sview
.
callOrder
=
{[
weak
self
]
flag
in
guard
let
self
else
{
return
}
let
vc
:
ChargeInfoViewController
=
ChargeInfoViewController
(
model
:
cModel
,
type
:
ChargeInfoViewController
.
ChargeInfoType
.
setting
)
vc
.
flag
=
flag
as?
Int
self
.
navigationController
?
.
pushViewController
(
vc
,
animated
:
true
)
}
}
}
}
...
...
PhoneManager/Class/Session/Charge/Model/ChargeDataModel.swift
View file @
ebf80e73
...
...
@@ -10,11 +10,35 @@ import Foundation
struct
ChargeDataModel
{
var
isFree
:
Bool
var
CoverImage
:
UIImage
var
coverImage
:
UIImage
?
var
url
:
URL
init
(
isFree
:
Bool
,
C
overImage
:
UIImage
,
url
:
URL
)
{
init
(
isFree
:
Bool
,
c
overImage
:
UIImage
,
url
:
URL
)
{
self
.
isFree
=
isFree
self
.
CoverImage
=
C
overImage
self
.
coverImage
=
c
overImage
self
.
url
=
url
}
func
toDictionary
()
->
[
String
:
Any
]
{
if
let
imageData
=
coverImage
!.
pngData
()
{
print
(
"成功将图片转换为 PNG 格式的 Data,数据大小:
\(
imageData
.
count
)
字节"
)
return
[
"isFree"
:
isFree
,
"coverImage"
:
imageData
,
"url"
:
url
.
absoluteString
]
}
else
{
print
(
"转换失败"
)
}
return
[:]
}
init
?(
dictionary
:
[
String
:
Any
])
{
guard
let
isFree
=
dictionary
[
"isFree"
]
as?
Bool
,
let
coverImageData
=
dictionary
[
"coverImage"
]
as?
Data
,
let
url
=
dictionary
[
"url"
]
as?
String
else
{
return
nil
}
self
.
isFree
=
isFree
self
.
coverImage
=
UIImage
(
data
:
coverImageData
)
!
self
.
url
=
URL
(
string
:
url
)
!
}
}
PhoneManager/Class/Session/Charge/Model/ChargeViewCollectionModel.swift
View file @
ebf80e73
...
...
@@ -43,9 +43,8 @@ func loadVideoItems() -> [ChargeDataModel]{
do
{
let
cgImage
=
try
imageGenerator
.
copyCGImage
(
at
:
time
,
actualTime
:
nil
)
let
image
=
UIImage
(
cgImage
:
cgImage
)
let
model
=
ChargeDataModel
(
isFree
:
true
,
C
overImage
:
image
,
url
:
url
)
let
model
=
ChargeDataModel
(
isFree
:
true
,
c
overImage
:
image
,
url
:
url
)
dataArray
.
append
(
model
)
print
(
"获取视频成功"
)
}
catch
{
print
(
"获取视频图片出错:
\(
error
.
localizedDescription
)
"
)
}
...
...
PhoneManager/Class/Session/Charge/View/ChargeInfoSettingView.swift
View file @
ebf80e73
...
...
@@ -9,6 +9,10 @@ import UIKit
class
ChargeInfoSettingView
:
UIView
{
var
model
:
ChargeDataModel
?
var
flag
:
Int
?
lazy
var
settingBtn
:
UIButton
=
{
let
sview
:
UIButton
=
UIButton
()
...
...
@@ -48,8 +52,19 @@ class ChargeInfoSettingView:UIView {
}
@objc
func
settingBtnClick
()
{
// 存储到userDefaults
UserDefaults
.
standard
.
set
(
String
(
flag
!
),
forKey
:
"chargePicInfo"
)
let
alert
=
UIAlertController
(
title
:
nil
,
message
:
"完成!"
,
preferredStyle
:
.
alert
)
self
.
responderViewController
()?
.
present
(
alert
,
animated
:
true
,
completion
:
nil
)
// 2 秒后关闭弹窗
DispatchQueue
.
main
.
asyncAfter
(
deadline
:
.
now
()
+
1
)
{
alert
.
dismiss
(
animated
:
true
,
completion
:
nil
)
self
.
responderViewController
()?
.
navigationController
?
.
popViewController
(
animated
:
true
)
}
}
}
PhoneManager/Class/Session/Charge/View/ChargeVideoPlayingView.swift
View file @
ebf80e73
...
...
@@ -35,7 +35,7 @@ class ChargeVideoPlayingView: UIView {
return
}
// 将编码后的字符串转换为 URL 对象
guard
let
encodedURL
=
URL
(
string
:
encodedURLString
)
else
{
guard
URL
(
string
:
encodedURLString
)
!=
nil
else
{
print
(
"无法创建编码后的 URL"
)
return
}
...
...
PhoneManager/Class/Session/Charge/View/ChargeView.swift
View file @
ebf80e73
...
...
@@ -10,7 +10,9 @@ import AVFoundation
class
ChargeView
:
UIView
{
var
callBack
:
callBack
<
Any
>
=
{
model
in
}
var
callBack
:
callBack
<
Any
>
=
{
model
in
}
var
callOrder
:
callBack
<
Any
>
=
{
flag
in
}
let
footerID
:
String
=
"footerID"
...
...
@@ -89,7 +91,7 @@ extension ChargeView:WaterfallMutiSectionDelegate,UICollectionViewDataSource,UIC
func
collectionView
(
_
collectionView
:
UICollectionView
,
cellForItemAt
indexPath
:
IndexPath
)
->
UICollectionViewCell
{
let
cell
=
collectionView
.
dequeueReusableCell
(
withReuseIdentifier
:
ChargeViewCollectionCell
.
identifiers
,
for
:
indexPath
)
as!
ChargeViewCollectionCell
cell
.
flag
=
indexPath
.
row
cell
.
model
=
models
[
indexPath
.
row
]
return
cell
...
...
@@ -100,6 +102,9 @@ extension ChargeView:WaterfallMutiSectionDelegate,UICollectionViewDataSource,UIC
let
model
=
models
[
indexPath
.
row
]
self
.
callBack
(
model
)
self
.
callOrder
(
indexPath
.
row
)
}
func
collectionView
(
_
collectionView
:
UICollectionView
,
...
...
PhoneManager/Class/Session/Charge/View/ChargeViewCollectionCell.swift
View file @
ebf80e73
...
...
@@ -12,6 +12,8 @@ class ChargeViewCollectionCell:UICollectionViewCell {
static
let
identifiers
=
"ChargeViewCollectionCellID"
var
flag
:
Int
?
var
videoURL
:
URL
?
lazy
var
backImageView
:
UIImageView
=
{
...
...
@@ -66,7 +68,7 @@ class ChargeViewCollectionCell:UICollectionViewCell {
guard
let
self
else
{
return
}
self
.
backImageView
.
image
=
model
.
C
overImage
self
.
backImageView
.
image
=
model
.
c
overImage
self
.
isFreeBtn
.
isHidden
=
model
.
isFree
...
...
PhoneManager/Class/Session/Home/HomeViewController.swift
View file @
ebf80e73
...
...
@@ -122,8 +122,15 @@ class HomeViewController:BaseViewController {
isShowPay
=
true
if
BatteryMonitorManager
.
shared
.
getBatteryIsCharging
()
{
let
vc
:
ChargeInfoViewController
=
ChargeInfoViewController
(
model
:
loadVideoItems
()
.
first
,
type
:
ChargeInfoViewController
.
ChargeInfoType
.
charge
)
// 从字典里面取 如果有
var
tempModel
:
ChargeDataModel
?
if
UserDefaults
.
standard
.
object
(
forKey
:
"chargePicInfo"
)
==
nil
{
tempModel
=
loadVideoItems
()
.
first
}
else
{
let
flag
:
String
=
UserDefaults
.
standard
.
object
(
forKey
:
"chargePicInfo"
)
as!
String
tempModel
=
loadVideoItems
()[
Int
(
flag
)
!
]
}
let
vc
:
ChargeInfoViewController
=
ChargeInfoViewController
(
model
:
tempModel
,
type
:
ChargeInfoViewController
.
ChargeInfoType
.
charge
)
self
.
navigationController
?
.
pushViewController
(
vc
,
animated
:
false
)
...
...
PhoneManager/Class/Tool/Class/BatteryMonitorManager/BatteryMonitorManager.swift
View file @
ebf80e73
...
...
@@ -84,8 +84,19 @@ class BatteryMonitorManager {
func
getBatteryIsCharging
()
->
Bool
{
UIDevice
.
current
.
isBatteryMonitoringEnabled
=
true
return
UIDevice
.
current
.
batteryState
==
.
charging
switch
UIDevice
.
current
.
batteryState
{
case
.
unknown
:
print
(
"电池状态未知"
)
case
.
unplugged
:
print
(
"电池未充电"
)
case
.
charging
:
print
(
"电池正在充电"
)
case
.
full
:
print
(
"电池已充满"
)
@unknown
default
:
break
}
return
UIDevice
.
current
.
batteryState
==
.
charging
||
UIDevice
.
current
.
batteryState
==
.
full
}
// MARK: - Private Methods
...
...
PhoneManager/Info.plist
View file @
ebf80e73
...
...
@@ -11,8 +11,8 @@
<
/
d
i
c
t
>
<
k
e
y
>
NSUserActivityTypes
<
/k
e
y
>
<
a
rr
a
y
>
<
string
>
ChargeShowIntent
<
/string
>
<
string
>
LaunchAppIntent
<
/string
>
<
string
>
Charge
Intents
<
/string
>
<
/
a
rr
a
y
>
<
k
e
y
>
PHPhotoLibraryPreventAutomaticLimitedAccessAlert
<
/k
e
y
>
<
tru
e
/
>
...
...
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