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
0d4d241e
Commit
0d4d241e
authored
Apr 29, 2025
by
CZ1004
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【修复】
1、跳转问题 2、缓存问题 3、首页UI问题 4、磁盘占用空间更改
parent
ea238559
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
142 additions
and
146 deletions
+142
-146
CompressSelectCell.swift
...ager/Class/Session/Compress/Cell/CompressSelectCell.swift
+5
-5
CompressQualityController.swift
...ssion/Compress/Controller/CompressQualityController.swift
+5
-5
CompressCustomHeaderView.swift
...lass/Session/Compress/View/CompressCustomHeaderView.swift
+9
-9
CompressViewModel.swift
.../Class/Session/Compress/ViewModel/CompressViewModel.swift
+1
-1
HomeInfoViewController.swift
...lass/Session/Home/Controller/HomeInfoViewController.swift
+0
-6
HomePhotosDetailViewController.swift
...sion/Home/Controller/HomePhotosDetailViewController.swift
+1
-3
HomeVideoDetailController.swift
...s/Session/Home/Controller/HomeVideoDetailController.swift
+1
-3
HomeCollectionViewHeader.swift
...er/Class/Session/Home/View/HomeCollectionViewHeader.swift
+51
-40
HomeNavView.swift
PhoneManager/Class/Session/Home/View/HomeNavView.swift
+1
-1
HomePhotosModel .swift
...ager/Class/Session/Home/View/Model/HomePhotosModel .swift
+5
-1
HomeOtherCollectionCell.swift
...lass/Session/Home/View/cell/HomeOtherCollectionCell.swift
+5
-5
HomeVideoDetailCell.swift
...er/Class/Session/Home/View/cell/HomeVideoDetailCell.swift
+5
-5
PMShowVideoCell.swift
PhoneManager/Class/Session/Secret/Cell/PMShowVideoCell.swift
+6
-4
PMShowImgVideoController.swift
...nager/Class/Session/Secret/PMShowImgVideoController.swift
+13
-3
SecretVideoPlayer.swift
...Manager/Class/Session/Secret/View/SecretVideoPlayer.swift
+5
-2
WidgetPublicModel.swift
...anager/Class/Session/Widget/Model/WidgetPublicModel.swift
+15
-3
PhotoAndVideoMananger.swift
...l/Class/PhotoAndVideoMananger/PhotoAndVideoMananger.swift
+12
-48
CommonFunc.swift
PhoneManager/Class/Tool/Common/CommonFunc.swift
+2
-2
No files found.
PhoneManager/Class/Session/Compress/Cell/CompressSelectCell.swift
View file @
0d4d241e
...
@@ -41,14 +41,14 @@ class CompressSelectCell : UICollectionViewCell {
...
@@ -41,14 +41,14 @@ class CompressSelectCell : UICollectionViewCell {
let
compressCompletedSize
=
Double
(
compressedData
.
count
)
let
compressCompletedSize
=
Double
(
compressedData
.
count
)
let
saveSize
=
model
.
orgSize
-
compressCompletedSize
let
saveSize
=
model
.
orgSize
-
compressCompletedSize
let
sizeKB
:
Double
=
saveSize
/
10
24
let
sizeKB
:
Double
=
saveSize
/
10
00
DispatchQueue
.
main
.
async
{
DispatchQueue
.
main
.
async
{
if
sizeKB
<
10
24
{
if
sizeKB
<
10
00
{
self
.
saveSizeLabel
.
text
=
String
(
format
:
"Save %.2f KB"
,
sizeKB
)
self
.
saveSizeLabel
.
text
=
String
(
format
:
"Save %.2f KB"
,
sizeKB
)
}
else
if
sizeKB
<
(
10
24
*
1024
)
&&
sizeKB
>
1024
{
}
else
if
sizeKB
<
(
10
00
*
1000
)
&&
sizeKB
>
1000
{
self
.
saveSizeLabel
.
text
=
String
(
format
:
"Save %.2f MB"
,
sizeKB
/
10
24
)
self
.
saveSizeLabel
.
text
=
String
(
format
:
"Save %.2f MB"
,
sizeKB
/
10
00
)
}
else
{
}
else
{
self
.
saveSizeLabel
.
text
=
String
(
format
:
"Save %.2f GB"
,
sizeKB
/
(
10
24
*
1024
))
self
.
saveSizeLabel
.
text
=
String
(
format
:
"Save %.2f GB"
,
sizeKB
/
(
10
00
*
1000
))
}
}
}
}
}
}
...
...
PhoneManager/Class/Session/Compress/Controller/CompressQualityController.swift
View file @
0d4d241e
...
@@ -199,15 +199,15 @@ class CompressQualityController : BaseViewController{
...
@@ -199,15 +199,15 @@ class CompressQualityController : BaseViewController{
orgAllSize
=
orgAllSize
+
modelData
.
orgSize
orgAllSize
=
orgAllSize
+
modelData
.
orgSize
}
}
sum
=
orgAllSize
-
compressAllSize
sum
=
orgAllSize
-
compressAllSize
sum
=
sum
/
10
24
sum
=
sum
/
10
00
if
sum
<
10
24
{
if
sum
<
10
00
{
vc
.
sizeToplabel
.
text
=
String
(
format
:
"%.2lfKB"
,
sum
)
vc
.
sizeToplabel
.
text
=
String
(
format
:
"%.2lfKB"
,
sum
)
}
else
if
sum
<
(
10
24
*
1024
)
&&
sum
>
1024
{
}
else
if
sum
<
(
10
00
*
1000
)
&&
sum
>
1000
{
sum
=
sum
/
10
24
sum
=
sum
/
10
00
vc
.
sizeToplabel
.
text
=
String
(
format
:
"%.2lfMB"
,
sum
)
vc
.
sizeToplabel
.
text
=
String
(
format
:
"%.2lfMB"
,
sum
)
}
else
{
}
else
{
sum
=
sum
/
(
10
24
*
1024
)
sum
=
sum
/
(
10
00
*
1000
)
vc
.
sizeToplabel
.
text
=
String
(
format
:
"%.2lfGB"
,
sum
)
vc
.
sizeToplabel
.
text
=
String
(
format
:
"%.2lfGB"
,
sum
)
}
}
let
str
=
String
(
format
:
"%.2lf"
,(
orgAllSize
-
compressAllSize
)
/
orgAllSize
)
let
str
=
String
(
format
:
"%.2lf"
,(
orgAllSize
-
compressAllSize
)
/
orgAllSize
)
...
...
PhoneManager/Class/Session/Compress/View/CompressCustomHeaderView.swift
View file @
0d4d241e
...
@@ -22,21 +22,21 @@ class CompressCustomHeaderView: UICollectionReusableView{
...
@@ -22,21 +22,21 @@ class CompressCustomHeaderView: UICollectionReusableView{
saveSum
=
saveSum
+
model
.
orgSize
*
0.8
saveSum
=
saveSum
+
model
.
orgSize
*
0.8
}
}
sum
=
sum
/
1000
sum
=
sum
/
1000
saveSum
=
saveSum
/
10
24
saveSum
=
saveSum
/
10
00
if
sum
<
10
24
{
if
sum
<
10
00
{
self
.
siezLabel
.
text
=
String
(
format
:
"%.2f KB"
,(
sum
))
self
.
siezLabel
.
text
=
String
(
format
:
"%.2f KB"
,(
sum
))
}
else
if
sum
<
(
10
24
*
1024
)
&&
sum
>
1024
{
}
else
if
sum
<
(
10
00
*
1000
)
&&
sum
>
1024
{
self
.
siezLabel
.
text
=
String
(
format
:
"%.2f MB"
,(
sum
/
10
24
))
self
.
siezLabel
.
text
=
String
(
format
:
"%.2f MB"
,(
sum
/
10
00
))
}
else
{
}
else
{
self
.
siezLabel
.
text
=
String
(
format
:
"%.2f GB"
,
sum
/
(
10
24*
1024
))
self
.
siezLabel
.
text
=
String
(
format
:
"%.2f GB"
,
sum
/
(
10
00*
1000
))
}
}
if
saveSum
<
10
24
{
if
saveSum
<
10
00
{
self
.
saveSizeLabel
.
text
=
String
(
format
:
"%.2f KB"
,(
saveSum
))
self
.
saveSizeLabel
.
text
=
String
(
format
:
"%.2f KB"
,(
saveSum
))
}
else
if
saveSum
<
(
10
24
*
1024
)
&&
saveSum
>
1024
{
}
else
if
saveSum
<
(
10
00
*
1000
)
&&
saveSum
>
1024
{
self
.
saveSizeLabel
.
text
=
String
(
format
:
"%.2f MB"
,(
saveSum
/
10
24
))
self
.
saveSizeLabel
.
text
=
String
(
format
:
"%.2f MB"
,(
saveSum
/
10
00
))
}
else
{
}
else
{
self
.
saveSizeLabel
.
text
=
String
(
format
:
"%.2f GB"
,
saveSum
/
(
10
24*
1024
))
self
.
saveSizeLabel
.
text
=
String
(
format
:
"%.2f GB"
,
saveSum
/
(
10
00*
1000
))
}
}
}
}
...
...
PhoneManager/Class/Session/Compress/ViewModel/CompressViewModel.swift
View file @
0d4d241e
...
@@ -401,7 +401,7 @@ class CompressViewModel{
...
@@ -401,7 +401,7 @@ class CompressViewModel{
let
imageManager
=
PHCachingImageManager
()
let
imageManager
=
PHCachingImageManager
()
let
options
=
PHImageRequestOptions
()
let
options
=
PHImageRequestOptions
()
options
.
isSynchronous
=
false
options
.
isSynchronous
=
false
options
.
deliveryMode
=
.
highQualityFormat
options
.
deliveryMode
=
.
opportunistic
options
.
isNetworkAccessAllowed
=
true
options
.
isNetworkAccessAllowed
=
true
imageManager
.
requestImage
(
for
:
asset
,
targetSize
:
CGSize
(
width
:
400
,
height
:
400
),
contentMode
:
.
aspectFill
,
options
:
options
)
{
(
image
,
_
)
in
imageManager
.
requestImage
(
for
:
asset
,
targetSize
:
CGSize
(
width
:
400
,
height
:
400
),
contentMode
:
.
aspectFill
,
options
:
options
)
{
(
image
,
_
)
in
...
...
PhoneManager/Class/Session/Home/Controller/HomeInfoViewController.swift
View file @
0d4d241e
...
@@ -104,12 +104,6 @@ class HomeInfoViewController:BaseViewController {
...
@@ -104,12 +104,6 @@ class HomeInfoViewController:BaseViewController {
})
})
}
}
// 更新下首页数据以及缓存数据
let
dataUpdated
=
Notification
.
Name
(
"DataUpdatedNotification"
)
NotificationCenter
.
default
.
post
(
name
:
dataUpdated
,
object
:
nil
,
userInfo
:
nil
)
func
updateFreeTimes
(){
func
updateFreeTimes
(){
// 删除成功后更新次数
// 删除成功后更新次数
var
times
=
UserDefaults
.
standard
.
object
(
forKey
:
"saveAdvTimes"
)
as!
Int
var
times
=
UserDefaults
.
standard
.
object
(
forKey
:
"saveAdvTimes"
)
as!
Int
...
...
PhoneManager/Class/Session/Home/Controller/HomePhotosDetailViewController.swift
View file @
0d4d241e
...
@@ -622,9 +622,7 @@ extension HomePhotosDetailViewController:WaterfallMutiSectionDelegate,UICollecti
...
@@ -622,9 +622,7 @@ extension HomePhotosDetailViewController:WaterfallMutiSectionDelegate,UICollecti
// 清理下缓存数据
// 清理下缓存数据
PhotoDataManager
.
manager
.
removeDataWhenDeleteInPage
(
data
:
self
.
selectedModel
)
PhotoDataManager
.
manager
.
removeDataWhenDeleteInPage
(
data
:
self
.
selectedModel
)
// 给首页发通知,数据删除
let
dataUpdated
=
Notification
.
Name
(
"DataUpdatedNotification"
)
NotificationCenter
.
default
.
post
(
name
:
dataUpdated
,
object
:
nil
,
userInfo
:
nil
)
// 更新页面
// 更新页面
...
...
PhoneManager/Class/Session/Home/Controller/HomeVideoDetailController.swift
View file @
0d4d241e
...
@@ -540,9 +540,7 @@ extension HomeVideoDetailController:WaterfallMutiSectionDelegate,UICollectionVie
...
@@ -540,9 +540,7 @@ extension HomeVideoDetailController:WaterfallMutiSectionDelegate,UICollectionVie
// 清理下缓存数据
// 清理下缓存数据
PhotoDataManager
.
manager
.
removeDataWhenDeleteInPage
(
data
:
self
.
selectedModel
)
PhotoDataManager
.
manager
.
removeDataWhenDeleteInPage
(
data
:
self
.
selectedModel
)
// 给首页发通知,数据删除
let
dataUpdated
=
Notification
.
Name
(
"DataUpdatedNotification"
)
NotificationCenter
.
default
.
post
(
name
:
dataUpdated
,
object
:
nil
,
userInfo
:
nil
)
// 更新页面
// 更新页面
...
...
PhoneManager/Class/Session/Home/View/HomeCollectionViewHeader.swift
View file @
0d4d241e
...
@@ -74,16 +74,16 @@ class HomeCollectionViewHeader : UICollectionReusableView {
...
@@ -74,16 +74,16 @@ class HomeCollectionViewHeader : UICollectionReusableView {
// 文本
// 文本
self
.
addSubview
(
self
.
tipLabel
)
self
.
addSubview
(
self
.
tipLabel
)
self
.
tipLabel
.
snp
.
makeConstraints
{
make
in
self
.
tipLabel
.
snp
.
makeConstraints
{
make
in
make
.
left
.
equalToSuperview
()
make
.
left
.
equalToSuperview
()
.
offset
(
8
)
make
.
top
.
equalToSuperview
()
.
offset
(
4
)
make
.
top
.
equalToSuperview
()
.
offset
(
4
)
make
.
height
.
equalTo
(
17
)
make
.
height
.
equalTo
(
17
)
}
}
self
.
addSubview
(
self
.
progressBar
)
self
.
addSubview
(
self
.
progressBar
)
self
.
progressBar
.
snp
.
makeConstraints
{
make
in
self
.
progressBar
.
snp
.
makeConstraints
{
make
in
make
.
top
.
equalTo
(
self
.
tipLabel
.
snp
.
bottom
)
.
offset
(
12
)
make
.
top
.
equalTo
(
self
.
tipLabel
.
snp
.
bottom
)
.
offset
(
12
)
make
.
width
.
equalToSuperview
()
make
.
width
.
equalToSuperview
()
.
offset
(
-
16
)
make
.
height
.
equalTo
(
31
)
make
.
height
.
equalTo
(
31
)
make
.
left
.
equalToSuperview
()
make
.
left
.
equalToSuperview
()
.
offset
(
8
)
}
}
// self.addSubview(self.subTiplabel)
// self.addSubview(self.subTiplabel)
...
@@ -163,12 +163,30 @@ class CustomProgressBar: UIView {
...
@@ -163,12 +163,30 @@ class CustomProgressBar: UIView {
private
let
dotSize
:
CGFloat
=
8
private
let
dotSize
:
CGFloat
=
8
private
let
labelSpacing
:
CGFloat
=
18
private
let
labelSpacing
:
CGFloat
=
18
var
usedProgress
:
CGFloat
=
0
var
usedProgress
:
CGFloat
=
0
{
var
chaoticProgress
:
CGFloat
=
0
didSet
{
self
.
updateProgress
()
}
}
var
totalProgress
:
CGFloat
=
0
var
chaoticProgress
:
CGFloat
=
0
{
didSet
{
self
.
updateProgress
()
}
}
override
init
(
frame
:
CGRect
)
{
override
init
(
frame
:
CGRect
)
{
super
.
init
(
frame
:
frame
)
super
.
init
(
frame
:
frame
)
setupUI
()
setupUI
()
let
disk
=
WidgetPublicModel
.
getDiskSpace
()
self
.
totalProgress
=
Double
(
disk
.
0
)
self
.
usedProgress
=
Double
(
disk
.
0
)
-
Double
(
disk
.
1
)
Task
{
let
photoData
=
await
Double
(
StorageManager
.
manager
.
getPhotoResourceMemory
())
self
.
chaoticProgress
=
photoData
}
}
}
required
init
?(
coder
:
NSCoder
)
{
required
init
?(
coder
:
NSCoder
)
{
...
@@ -177,22 +195,23 @@ class CustomProgressBar: UIView {
...
@@ -177,22 +195,23 @@ class CustomProgressBar: UIView {
}
}
private
func
setupUI
()
{
private
func
setupUI
()
{
layer
.
addSublayer
(
progressLayer
)
layer
.
addSublayer
(
progressLayer
)
usedLabel
.
text
=
"Used"
usedLabel
.
text
=
"Used"
usedLabel
.
font
=
UIFont
.
systemFont
(
ofSize
:
12
)
usedLabel
.
font
=
UIFont
.
systemFont
(
ofSize
:
12
)
usedLabel
.
textColor
=
.
black
usedLabel
.
textColor
=
UIColor
.
colorWithHex
(
hexStr
:
black6Color
)
addSubview
(
usedLabel
)
addSubview
(
usedLabel
)
chaoticLabel
.
text
=
"Chaotic content"
chaoticLabel
.
text
=
"Chaotic content"
chaoticLabel
.
font
=
UIFont
.
systemFont
(
ofSize
:
12
)
chaoticLabel
.
font
=
UIFont
.
systemFont
(
ofSize
:
12
)
chaoticLabel
.
textColor
=
.
black
chaoticLabel
.
textColor
=
UIColor
.
colorWithHex
(
hexStr
:
black6Color
)
addSubview
(
chaoticLabel
)
addSubview
(
chaoticLabel
)
idleLabel
.
text
=
"Idle"
idleLabel
.
text
=
"Idle"
idleLabel
.
font
=
UIFont
.
systemFont
(
ofSize
:
12
)
idleLabel
.
font
=
UIFont
.
systemFont
(
ofSize
:
12
)
idleLabel
.
textColor
=
.
black
idleLabel
.
textColor
=
UIColor
.
colorWithHex
(
hexStr
:
black6Color
)
addSubview
(
idleLabel
)
addSubview
(
idleLabel
)
}
}
...
@@ -222,38 +241,30 @@ class CustomProgressBar: UIView {
...
@@ -222,38 +241,30 @@ class CustomProgressBar: UIView {
}
}
private
func
updateProgress
()
{
private
func
updateProgress
()
{
DispatchQueue
.
global
(
qos
:
.
userInitiated
)
.
async
{
// 回到主线程更新 UI
let
disk
=
WidgetPublicModel
.
getDiskSpace
()
DispatchQueue
.
main
.
async
{
let
usedData
=
Double
(
disk
.
1
)
let
usedProgress
=
CGFloat
(
self
.
usedProgress
/
self
.
totalProgress
)
let
tolData
=
Double
(
disk
.
0
)
let
chaoticProgress
=
CGFloat
(
self
.
chaoticProgress
/
self
.
totalProgress
)
Task
{
let
photoData
=
await
Double
(
StorageManager
.
manager
.
getPhotoResourceMemory
())
let
totalProgress
=
usedProgress
+
chaoticProgress
// 回到主线程更新 UI
let
remainingProgress
=
1
-
totalProgress
DispatchQueue
.
main
.
async
{
let
usedProgress
=
CGFloat
(
usedData
/
tolData
)
let
usedWidth
=
self
.
bounds
.
width
*
usedProgress
let
chaoticProgress
=
CGFloat
(
photoData
/
tolData
)
let
chaoticWidth
=
self
.
bounds
.
width
*
chaoticProgress
let
idleWidth
=
self
.
bounds
.
width
*
remainingProgress
let
totalProgress
=
usedProgress
+
chaoticProgress
let
remainingProgress
=
1
-
totalProgress
let
usedLayer
=
CALayer
()
usedLayer
.
frame
=
CGRect
(
x
:
0
,
y
:
0
,
width
:
usedWidth
,
height
:
self
.
progressLayer
.
bounds
.
height
)
let
usedWidth
=
self
.
bounds
.
width
*
usedProgress
usedLayer
.
backgroundColor
=
self
.
usedColor
.
cgColor
let
chaoticWidth
=
self
.
bounds
.
width
*
chaoticProgress
let
idleWidth
=
self
.
bounds
.
width
*
remainingProgress
let
chaoticLayer
=
CALayer
()
chaoticLayer
.
frame
=
CGRect
(
x
:
usedWidth
,
y
:
0
,
width
:
chaoticWidth
,
height
:
self
.
progressLayer
.
bounds
.
height
)
let
usedLayer
=
CALayer
()
chaoticLayer
.
backgroundColor
=
self
.
chaoticColor
.
cgColor
usedLayer
.
frame
=
CGRect
(
x
:
0
,
y
:
0
,
width
:
usedWidth
,
height
:
self
.
progressLayer
.
bounds
.
height
)
usedLayer
.
backgroundColor
=
self
.
usedColor
.
cgColor
let
idleLayer
=
CALayer
()
idleLayer
.
frame
=
CGRect
(
x
:
usedWidth
+
chaoticWidth
,
y
:
0
,
width
:
idleWidth
,
height
:
self
.
progressLayer
.
bounds
.
height
)
let
chaoticLayer
=
CALayer
()
idleLayer
.
backgroundColor
=
self
.
idleColor
.
cgColor
chaoticLayer
.
frame
=
CGRect
(
x
:
usedWidth
,
y
:
0
,
width
:
chaoticWidth
,
height
:
self
.
progressLayer
.
bounds
.
height
)
self
.
progressLayer
.
sublayers
=
[
usedLayer
,
chaoticLayer
,
idleLayer
]
chaoticLayer
.
backgroundColor
=
self
.
chaoticColor
.
cgColor
let
idleLayer
=
CALayer
()
idleLayer
.
frame
=
CGRect
(
x
:
usedWidth
+
chaoticWidth
,
y
:
0
,
width
:
idleWidth
,
height
:
self
.
progressLayer
.
bounds
.
height
)
idleLayer
.
backgroundColor
=
self
.
idleColor
.
cgColor
self
.
progressLayer
.
sublayers
=
[
usedLayer
,
chaoticLayer
,
idleLayer
]
}
}
}
}
}
}
...
...
PhoneManager/Class/Session/Home/View/HomeNavView.swift
View file @
0d4d241e
...
@@ -37,7 +37,7 @@ class HomeNavView:UIView {
...
@@ -37,7 +37,7 @@ class HomeNavView:UIView {
// 标题
// 标题
self
.
addSubview
(
self
.
homeTitle
)
self
.
addSubview
(
self
.
homeTitle
)
self
.
homeTitle
.
snp
.
makeConstraints
{
make
in
self
.
homeTitle
.
snp
.
makeConstraints
{
make
in
make
.
left
.
equalTo
(
15
)
make
.
left
.
equalTo
(
15
+
8
)
make
.
top
.
equalTo
(
8
+
statusBarHeight
)
make
.
top
.
equalTo
(
8
+
statusBarHeight
)
make
.
height
.
equalTo
(
28
)
make
.
height
.
equalTo
(
28
)
make
.
width
.
equalTo
(
149
)
make
.
width
.
equalTo
(
149
)
...
...
PhoneManager/Class/Session/Home/View/Model/HomePhotosModel .swift
View file @
0d4d241e
...
@@ -84,7 +84,7 @@ class PhotoDataManager {
...
@@ -84,7 +84,7 @@ class PhotoDataManager {
}
}
for
index
in
0
..<
model
.
titleModelArray
.
count
{
for
index
in
0
..<
model
.
titleModelArray
.
count
{
// 删除相似截图和相似视频的缓存
// 删除相似截图和相似视频的缓存
var
size
:
Double
=
0.0
var
size
:
Double
=
0.0
var
finalyVideoData
:
[[
AssetModel
]]
=
[]
var
finalyVideoData
:
[[
AssetModel
]]
=
[]
let
array
=
model
.
titleModelArray
[
index
]
.
assets
let
array
=
model
.
titleModelArray
[
index
]
.
assets
...
@@ -106,6 +106,10 @@ class PhotoDataManager {
...
@@ -106,6 +106,10 @@ class PhotoDataManager {
}
}
// 处理完成保存下当前数据
// 处理完成保存下当前数据
self
.
saveToFileSystem
(
model
:
model
)
self
.
saveToFileSystem
(
model
:
model
)
// 更新下首页数据以及缓存数据
let
dataUpdated
=
Notification
.
Name
(
"DataUpdatedNotification"
)
NotificationCenter
.
default
.
post
(
name
:
dataUpdated
,
object
:
nil
,
userInfo
:
nil
)
})
})
// 将单利中的数据也删除
// 将单利中的数据也删除
for
item
in
data
{
for
item
in
data
{
...
...
PhoneManager/Class/Session/Home/View/cell/HomeOtherCollectionCell.swift
View file @
0d4d241e
...
@@ -117,13 +117,13 @@ class HomeOtherCollectionCell: UICollectionViewCell {
...
@@ -117,13 +117,13 @@ class HomeOtherCollectionCell: UICollectionViewCell {
self
.
countLabel
.
text
=
"
\(
count
)
Videos"
self
.
countLabel
.
text
=
"
\(
count
)
Videos"
}
}
// 设置文件大小文字
// 设置文件大小文字
let
sizeKB
:
Double
=
model
.
allFileSize
/
10
24
let
sizeKB
:
Double
=
model
.
allFileSize
/
10
00
if
sizeKB
<
10
24
{
if
sizeKB
<
10
00
{
self
.
sizeLabel
.
text
=
String
(
format
:
"(%.2lf) KB"
,
sizeKB
)
self
.
sizeLabel
.
text
=
String
(
format
:
"(%.2lf) KB"
,
sizeKB
)
}
else
if
sizeKB
<
(
10
24
*
1024
)
&&
sizeKB
>
1024
{
}
else
if
sizeKB
<
(
10
00
*
1000
)
&&
sizeKB
>
1000
{
self
.
sizeLabel
.
text
=
String
(
format
:
"(%.2lf) MB"
,
sizeKB
/
10
24
)
self
.
sizeLabel
.
text
=
String
(
format
:
"(%.2lf) MB"
,
sizeKB
/
10
00
)
}
else
{
}
else
{
self
.
sizeLabel
.
text
=
String
(
format
:
"(%.2lf) GB"
,
sizeKB
/
(
10
24
*
1024
))
self
.
sizeLabel
.
text
=
String
(
format
:
"(%.2lf) GB"
,
sizeKB
/
(
10
00
*
1000
))
}
}
}
}
...
...
PhoneManager/Class/Session/Home/View/cell/HomeVideoDetailCell.swift
View file @
0d4d241e
...
@@ -46,13 +46,13 @@ class HomeVideoDetailCell : UICollectionViewCell {
...
@@ -46,13 +46,13 @@ class HomeVideoDetailCell : UICollectionViewCell {
DispatchQueue
.
main
.
async
{
DispatchQueue
.
main
.
async
{
// 确保在主线程更新UI
// 确保在主线程更新UI
self
.
backImageView
.
image
=
thumbnailImage
self
.
backImageView
.
image
=
thumbnailImage
let
sizeKB
:
Double
=
Double
(
assetSize
/
10
24
)
let
sizeKB
:
Double
=
Double
(
assetSize
/
10
00
)
if
sizeKB
<
10
24
{
if
sizeKB
<
10
00
{
self
.
saveSizeLabel
.
text
=
String
(
format
:
"%.2f KB"
,
sizeKB
)
self
.
saveSizeLabel
.
text
=
String
(
format
:
"%.2f KB"
,
sizeKB
)
}
else
if
sizeKB
<
(
10
24
*
1024
)
&&
sizeKB
>
1024
{
}
else
if
sizeKB
<
(
10
00
*
1000
)
&&
sizeKB
>
1000
{
self
.
saveSizeLabel
.
text
=
String
(
format
:
"%.2f MB"
,
sizeKB
/
10
24
)
self
.
saveSizeLabel
.
text
=
String
(
format
:
"%.2f MB"
,
sizeKB
/
10
00
)
}
else
{
}
else
{
self
.
saveSizeLabel
.
text
=
String
(
format
:
"%.2f GB"
,
sizeKB
/
(
10
24
*
1024
))
self
.
saveSizeLabel
.
text
=
String
(
format
:
"%.2f GB"
,
sizeKB
/
(
10
00
*
1000
))
}
}
}
}
}
else
{
}
else
{
...
...
PhoneManager/Class/Session/Secret/Cell/PMShowVideoCell.swift
View file @
0d4d241e
...
@@ -18,14 +18,16 @@ class PMShowVideoCell: UICollectionViewCell {
...
@@ -18,14 +18,16 @@ class PMShowVideoCell: UICollectionViewCell {
var
type
:
Int
=
0
var
type
:
Int
=
0
func
reload
()
->
Void
{
func
reload
()
->
Void
{
var
url
:
URL
var
url
:
URL
?
if
type
==
0
{
if
type
==
0
{
url
=
"SecretIm"
.
document
()
.
appendingPathComponent
(
playURL
)
url
=
"SecretIm"
.
document
()
.
appendingPathComponent
(
playURL
)
}
else
{
}
else
{
url
=
homeResouceUrl
!
url
=
homeResouceUrl
}
if
let
url
=
url
{
player
.
playVideo
(
from
:
url
)
player
.
pause
()
}
}
player
.
playVideo
(
from
:
url
)
player
.
pause
()
}
}
override
init
(
frame
:
CGRect
)
{
override
init
(
frame
:
CGRect
)
{
...
...
PhoneManager/Class/Session/Secret/PMShowImgVideoController.swift
View file @
0d4d241e
...
@@ -185,14 +185,24 @@ extension PMShowImgVideoController : UICollectionViewDelegate,UICollectionViewDa
...
@@ -185,14 +185,24 @@ extension PMShowImgVideoController : UICollectionViewDelegate,UICollectionViewDa
// 相似视频
// 相似视频
if
collectionView
==
MaxCollection
{
if
collectionView
==
MaxCollection
{
let
cell
=
collectionView
.
dequeueReusableCell
(
withReuseIdentifier
:
PMShowVideoCellID
,
for
:
indexPath
)
as!
PMShowVideoCell
let
cell
=
collectionView
.
dequeueReusableCell
(
withReuseIdentifier
:
PMShowVideoCellID
,
for
:
indexPath
)
as!
PMShowVideoCell
cell
.
homeResouceUrl
=
self
.
url
// 这里主动获取下视频的链接
let
ident
=
self
.
homeDataSource
?[
indexPath
.
row
]
.
id
?
.
localIdentifier
if
let
ident
=
ident
{
self
.
getVideoURLFromLocalIdentifier
(
localIdentifier
:
ident
)
{
videoUrl
,
error
in
if
let
videoUrl
=
videoUrl
{
cell
.
homeResouceUrl
=
videoUrl
DispatchQueue
.
main
.
async
{
cell
.
reload
()
}
}
}
}
// 表示这个是视频
// 表示这个是视频
cell
.
type
=
1
cell
.
type
=
1
cell
.
reload
()
return
cell
return
cell
}
else
{
}
else
{
let
cell
=
collectionView
.
dequeueReusableCell
(
withReuseIdentifier
:
PMShowItemCellID
,
for
:
indexPath
)
as!
PMShowItemCell
let
cell
=
collectionView
.
dequeueReusableCell
(
withReuseIdentifier
:
PMShowItemCellID
,
for
:
indexPath
)
as!
PMShowItemCell
cell
.
icon
=
self
.
homeDataSource
!
[
indexPath
.
row
]
.
image
!
cell
.
icon
=
self
.
homeDataSource
!
[
indexPath
.
row
]
.
image
??
UIImage
()
cell
.
isCurrent
=
(
self
.
currentIdx
==
indexPath
.
row
)
cell
.
isCurrent
=
(
self
.
currentIdx
==
indexPath
.
row
)
return
cell
return
cell
}
}
...
...
PhoneManager/Class/Session/Secret/View/SecretVideoPlayer.swift
View file @
0d4d241e
...
@@ -63,9 +63,12 @@ class SecretVideoPlayer: UIView {
...
@@ -63,9 +63,12 @@ class SecretVideoPlayer: UIView {
}
}
}
}
func
playVideo
(
from
url
:
URL
)
{
func
playVideo
(
from
url
:
URL
?)
{
if
url
==
nil
{
return
}
removeObservers
()
removeObservers
()
player
=
AVPlayer
(
url
:
url
)
player
=
AVPlayer
(
url
:
url
!
)
if
let
playerLayer
=
layer
.
sublayers
?
.
first
as?
AVPlayerLayer
{
if
let
playerLayer
=
layer
.
sublayers
?
.
first
as?
AVPlayerLayer
{
playerLayer
.
player
=
player
playerLayer
.
player
=
player
}
}
...
...
PhoneManager/Class/Session/Widget/Model/WidgetPublicModel.swift
View file @
0d4d241e
...
@@ -20,6 +20,9 @@ class WidgetPublicModel: NSObject {
...
@@ -20,6 +20,9 @@ class WidgetPublicModel: NSObject {
return
batt
return
batt
}
}
/// 已使用
/// - Returns: 已使用空间
public
class
func
UseDiskSpace
()
->
CGFloat
{
public
class
func
UseDiskSpace
()
->
CGFloat
{
let
disk
=
getDiskSpace
()
let
disk
=
getDiskSpace
()
let
use
=
disk
.
0
-
disk
.
1
let
use
=
disk
.
0
-
disk
.
1
...
@@ -27,6 +30,9 @@ class WidgetPublicModel: NSObject {
...
@@ -27,6 +30,9 @@ class WidgetPublicModel: NSObject {
return
useP
return
useP
}
}
/// 获取总共和可用空间
/// - Returns: 总共和可用空间
public
class
func
getDiskSpace
()
->
(
Int64
,
Int64
)
{
public
class
func
getDiskSpace
()
->
(
Int64
,
Int64
)
{
let
total
=
TotalDiskSize
()
let
total
=
TotalDiskSize
()
let
available
=
AvailableDiskSize
()
let
available
=
AvailableDiskSize
()
...
@@ -43,9 +49,15 @@ class WidgetPublicModel: NSObject {
...
@@ -43,9 +49,15 @@ class WidgetPublicModel: NSObject {
}
}
// 硬盘剩余大小
// 硬盘剩余大小
class
func
AvailableDiskSize
()
->
Int64
{
class
func
AvailableDiskSize
()
->
Int64
{
var
fs
=
blankof
(
type
:
statfs
.
self
)
do
{
if
statfs
(
"/var"
,
&
fs
)
>=
0
{
let
fileURL
=
URL
(
fileURLWithPath
:
NSHomeDirectory
())
return
Int64
(
UInt64
(
fs
.
f_bsize
)
*
fs
.
f_bavail
)
let
values
=
try
fileURL
.
resourceValues
(
forKeys
:
[
.
volumeAvailableCapacityForImportantUsageKey
])
if
let
availableSpace
=
values
.
volumeAvailableCapacityForImportantUsage
{
return
Int64
(
availableSpace
)
}
}
catch
{
print
(
"获取磁盘空间信息时出错:
\(
error
)
"
)
return
-
1
}
}
return
-
1
return
-
1
}
}
...
...
PhoneManager/Class/Tool/Class/PhotoAndVideoMananger/PhotoAndVideoMananger.swift
View file @
0d4d241e
...
@@ -135,51 +135,6 @@ class PhotoAndVideoMananger {
...
@@ -135,51 +135,6 @@ class PhotoAndVideoMananger {
}
}
func
fetchAllFile
(
propress
:
@escaping
(
Int
,
Double
)
->
Void
,
completion
:
@escaping
(
Double
,
Int
)
->
Void
)
{
func
fetchAllFile
(
propress
:
@escaping
(
Int
,
Double
)
->
Void
,
completion
:
@escaping
(
Double
,
Int
)
->
Void
)
{
// if (self.allAssets.count == 0 ) {
//
// let fetchOptions = PHFetchOptions()
//
// let photoAllAssets = PHAsset.fetchAssets(with: .image, options: fetchOptions)
//
// let videoAllAssets = PHAsset.fetchAssets(with: .video, options: fetchOptions)
//
// let photoAssetsArray = photoAllAssets.objects(at: IndexSet(0..<photoAllAssets.count))
//
// let videoAssetsArray = videoAllAssets.objects(at: IndexSet(0..<videoAllAssets.count))
//
// let combinedArray = photoAssetsArray + videoAssetsArray
//
// DispatchQueue.global().async {[weak self] in
//
// guard let self = self else { return }
// // 计算总大小
// self.calculateTotalSize(of: combinedArray,progress: { fileSiez, index in
// propress(index,Double(fileSiez))
// }, completion: { fileSize,index in
// completion(Double(fileSize),index)
// })
//
// }
//
// }else {
//
//
// let combinedArray = self.allAssets
//
// DispatchQueue.global().async {[weak self] in
//
// guard let self = self else { return }
// // 计算总大小
// self.calculateTotalSize(of: combinedArray,progress: { fileSiez, index in
//
// propress(index,Double(fileSiez))
// }, completion: { fileSize,index in
// completion(Double(fileSize),index)
// })
//
// }
// }
let
fetchOptions
=
PHFetchOptions
()
let
fetchOptions
=
PHFetchOptions
()
let
photoAllAssets
=
PHAsset
.
fetchAssets
(
with
:
.
image
,
options
:
fetchOptions
)
let
photoAllAssets
=
PHAsset
.
fetchAssets
(
with
:
.
image
,
options
:
fetchOptions
)
...
@@ -517,18 +472,24 @@ class PhotoAndVideoMananger {
...
@@ -517,18 +472,24 @@ class PhotoAndVideoMananger {
func
getPhotoAssetSize
(
_
asset
:
PHAsset
,
completion
:
@escaping
(
Int64
)
->
Void
)
{
func
getPhotoAssetSize
(
_
asset
:
PHAsset
,
completion
:
@escaping
(
Int64
)
->
Void
)
{
let
options
=
PHImageRequestOptions
()
let
options
=
PHImageRequestOptions
()
options
.
isSynchronous
=
false
options
.
isSynchronous
=
false
options
.
version
=
.
original
// 获取原始数据
// 获取原始数据
options
.
version
=
.
original
// 不去计算iclound资源
options
.
isNetworkAccessAllowed
=
false
PHImageManager
.
default
()
.
requestImageDataAndOrientation
(
for
:
asset
,
options
:
options
)
{
(
data
,
_
,
_
,
_
)
in
PHImageManager
.
default
()
.
requestImageDataAndOrientation
(
for
:
asset
,
options
:
options
)
{
(
data
,
_
,
_
,
_
)
in
let
size
=
Int64
(
data
?
.
count
??
0
)
let
size
=
Int64
(
data
?
.
count
??
0
)
completion
(
size
)
completion
(
size
)
}
}
}
}
func
getVideoAssetSize
(
_
asset
:
PHAsset
,
completion
:
@escaping
(
Int64
)
->
Void
)
{
func
getVideoAssetSize
(
_
asset
:
PHAsset
,
completion
:
@escaping
(
Int64
)
->
Void
)
{
let
options
=
PHVideoRequestOptions
()
let
options
=
PHVideoRequestOptions
()
// 获取原始数据
options
.
version
=
.
original
options
.
version
=
.
original
// 不去计算iclound资源
options
.
isNetworkAccessAllowed
=
false
PHImageManager
.
default
()
.
requestAVAsset
(
forVideo
:
asset
,
options
:
options
)
{
(
avAsset
,
_
,
_
)
in
PHImageManager
.
default
()
.
requestAVAsset
(
forVideo
:
asset
,
options
:
options
)
{
(
avAsset
,
_
,
_
)
in
if
let
urlAsset
=
avAsset
as?
AVURLAsset
{
if
let
urlAsset
=
avAsset
as?
AVURLAsset
{
let
size
=
try
?
urlAsset
.
url
.
resourceValues
(
forKeys
:
[
.
fileSizeKey
])
.
fileSize
??
0
let
size
=
try
?
urlAsset
.
url
.
resourceValues
(
forKeys
:
[
.
fileSizeKey
])
.
fileSize
??
0
...
@@ -934,7 +895,7 @@ class PhotoAndVideoMananger {
...
@@ -934,7 +895,7 @@ class PhotoAndVideoMananger {
// 获取当前版本的照片或视频
// 获取当前版本的照片或视频
options
.
version
=
.
current
options
.
version
=
.
current
// 尽可能快地提供结果
// 尽可能快地提供结果
options
.
deliveryMode
=
.
highQuality
Format
options
.
deliveryMode
=
.
fast
Format
// 允许从iCloud请求
// 允许从iCloud请求
options
.
isNetworkAccessAllowed
=
true
options
.
isNetworkAccessAllowed
=
true
// 异步请求
// 异步请求
...
@@ -1188,6 +1149,9 @@ class SecretPhotoManager: NSObject, PhotoPickerControllerDelegate , CameraContro
...
@@ -1188,6 +1149,9 @@ class SecretPhotoManager: NSObject, PhotoPickerControllerDelegate , CameraContro
PMLoadingHUD
.
share
.
disMiss
()
PMLoadingHUD
.
share
.
disMiss
()
}
}
}
else
if
let
error
=
error
{
}
else
if
let
error
=
error
{
DispatchQueue
.
main
.
async
{
PMLoadingHUD
.
share
.
disMiss
()
}
print
(
"删除失败:
\(
error
.
localizedDescription
)
"
)
print
(
"删除失败:
\(
error
.
localizedDescription
)
"
)
}
}
...
...
PhoneManager/Class/Tool/Common/CommonFunc.swift
View file @
0d4d241e
...
@@ -30,8 +30,8 @@ func formatFileSize(_ bytes: Double) -> String {
...
@@ -30,8 +30,8 @@ func formatFileSize(_ bytes: Double) -> String {
var
unitIndex
=
0
var
unitIndex
=
0
// 循环计算合适的单位
// 循环计算合适的单位
while
size
>=
10
24
&&
unitIndex
<
units
.
count
-
1
{
while
size
>=
10
00
&&
unitIndex
<
units
.
count
-
1
{
size
/=
10
24
size
/=
10
00
unitIndex
+=
1
unitIndex
+=
1
}
}
...
...
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