Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
S
ShorthandMaster
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
lmj
ShorthandMaster
Commits
fd240c61
Commit
fd240c61
authored
Sep 27, 2020
by
lmj_521aiau@163.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
no message
parent
2bf0510d
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
146 additions
and
147 deletions
+146
-147
CRConstants.swift
ShorthandMaster/Contstants/CRConstants.swift
+1
-0
SHInputController.swift
ShorthandMaster/Input/Controller/SHInputController.swift
+8
-8
SHDeleteDetailsViewController.swift
ShorthandMaster/Mine/SHDeleteDetailsViewController.swift
+6
-6
SHRecordModel.swift
ShorthandMaster/Record/Model/SHRecordModel.swift
+7
-2
SHRecordDetailsVC.swift
ShorthandMaster/Record/SHRecordDetailsVC.swift
+3
-7
SHRecordListViewController.swift
ShorthandMaster/Record/SHRecordListViewController.swift
+28
-15
SHRecordShowViewController.swift
ShorthandMaster/Record/SHRecordShowViewController.swift
+56
-41
SHRecordViewController.swift
ShorthandMaster/Record/SHRecordViewController.swift
+17
-60
SHCloudManager.swift
ShorthandMaster/Share/Managers/SHCloudManager.swift
+20
-8
No files found.
ShorthandMaster/Contstants/CRConstants.swift
View file @
fd240c61
...
...
@@ -28,3 +28,4 @@ let SCREEN_HEIGHT: CGFloat = UIScreen.main.bounds.height
let
kAutoWidth
=
SCREEN_WIDTH
/
375
let
kAutoHeight
=
SCREEN_HEIGHT
/
667
let
DocumentPath
=
(
NSSearchPathForDirectoriesInDomains
(
.
documentDirectory
,
.
userDomainMask
,
true
)
.
first
)
!
ShorthandMaster/Input/Controller/SHInputController.swift
View file @
fd240c61
...
...
@@ -572,8 +572,8 @@ extension SHInputController
self
.
shInputView
.
bottomView
.
goOnAudioButton
.
isHidden
=
true
self
.
shInputView
.
bottomView
.
stopAudioButton
.
isHidden
=
false
let
mp3Path
:
String
=
(
NSSearchPathForDirectoriesInDomains
(
.
documentDirectory
,
.
userDomainMask
,
true
)
.
first
)
!
+
"/recorder.mp3"
let
pcmPath
:
String
=
(
NSSearchPathForDirectoriesInDomains
(
.
documentDirectory
,
.
userDomainMask
,
true
)
.
first
)
!
+
"/xbMixData.caf"
let
mp3Path
:
String
=
DocumentPath
+
"/recorder.mp3"
let
pcmPath
:
String
=
DocumentPath
+
"/xbMixData.caf"
recorder_mp3
.
configMp3Path
(
mp3Path
,
pcmPath
:
pcmPath
)
...
...
@@ -594,8 +594,8 @@ extension SHInputController
recorder_mp3
.
pause
()
let
mp3Path
:
String
=
(
NSSearchPathForDirectoriesInDomains
(
.
documentDirectory
,
.
userDomainMask
,
true
)
.
first
)
!
+
"/recorder.mp3"
let
pcmPath
:
String
=
(
NSSearchPathForDirectoriesInDomains
(
.
documentDirectory
,
.
userDomainMask
,
true
)
.
first
)
!
+
"/xbMixData.caf"
let
mp3Path
:
String
=
DocumentPath
+
"/recorder.mp3"
let
pcmPath
:
String
=
DocumentPath
+
"/xbMixData.caf"
print
(
"mp3Path"
+
mp3Path
)
print
(
"pcmPath"
+
pcmPath
)
...
...
@@ -611,8 +611,8 @@ extension SHInputController
recorder_mp3
.
start
()
let
mp3Path
:
String
=
(
NSSearchPathForDirectoriesInDomains
(
.
documentDirectory
,
.
userDomainMask
,
true
)
.
first
)
!
+
"/recorder.mp3"
let
pcmPath
:
String
=
(
NSSearchPathForDirectoriesInDomains
(
.
documentDirectory
,
.
userDomainMask
,
true
)
.
first
)
!
+
"/xbMixData.caf"
let
mp3Path
:
String
=
DocumentPath
+
"/recorder.mp3"
let
pcmPath
:
String
=
DocumentPath
+
"/xbMixData.caf"
print
(
"mp3Path"
+
mp3Path
)
print
(
"pcmPath"
+
pcmPath
)
...
...
@@ -628,8 +628,8 @@ extension SHInputController
recorder_mp3
.
stop
()
let
mp3Path
:
String
=
(
NSSearchPathForDirectoriesInDomains
(
.
documentDirectory
,
.
userDomainMask
,
true
)
.
first
)
!
+
"/recorder.mp3"
let
pcmPath
:
String
=
(
NSSearchPathForDirectoriesInDomains
(
.
documentDirectory
,
.
userDomainMask
,
true
)
.
first
)
!
+
"/xbMixData.caf"
let
mp3Path
:
String
=
DocumentPath
+
"/recorder.mp3"
let
pcmPath
:
String
=
DocumentPath
+
"/xbMixData.caf"
print
(
"mp3Path"
+
mp3Path
)
print
(
"pcmPath"
+
pcmPath
)
...
...
ShorthandMaster/Mine/SHDeleteDetailsViewController.swift
View file @
fd240c61
...
...
@@ -25,10 +25,10 @@ class SHDeleteDetailsViewController: SHBaseViewController {
func
prepareDateSource
(){
dataSource
=
[]
var
list
=
CRUserDefaults
.
recordList
for
(
index
,
dic
)
in
(
list
??
[])
.
enumerated
(){
let
model
=
SHRecordModel
()
model
.
setValuesForKeys
(
dic
)
//
var list = CRUserDefaults.recordList
//
for (index, dic) in (list ?? []).enumerated(){
//
let model = SHRecordModel()
//
model.setValuesForKeys(dic)
// if model.delete == true{
// if model.deleteDate.daysBetweenDate(toDate: Date.init()) > 30 {
// list?.remove(at: index)
...
...
@@ -36,8 +36,8 @@ class SHDeleteDetailsViewController: SHBaseViewController {
// dataSource.append(model)
// }
// }
}
CRUserDefaults
.
recordList
=
list
//
}
//
CRUserDefaults.recordList = list
}
func
removeModel
(
_
indexPath
:
IndexPath
){
...
...
ShorthandMaster/Record/Model/SHRecordModel.swift
View file @
fd240c61
...
...
@@ -19,15 +19,20 @@ class SHRecordModel: NSObject{
@objc
var
rename
:
String
=
""
@objc
var
txt
:
String
=
""
//录音资源
@objc
var
pathFile
:
String
=
""
@objc
var
pcmPathFile
:
String
=
""
@objc
var
assetFileUrlPath
:
String
=
""
//录音时间 估算
@objc
var
during
:
NSInteger
=
0
//照片资源
@objc
var
images
:
[
String
]
=
[]
@objc
var
imagesPath
:
[
String
]
=
[]
@objc
var
imagesIndex
:
[
String
]
=
[]
@objc
var
selected
:
Bool
=
false
@objc
var
icloud
:
Bool
=
false
@objc
var
fileData
:
Data
=
Data
()
override
func
setValue
(
_
value
:
Any
?,
forUndefinedKey
key
:
String
)
{
}
...
...
ShorthandMaster/Record/SHRecordDetailsVC.swift
View file @
fd240c61
...
...
@@ -388,12 +388,8 @@ extension SHRecordDetailsVC: UITableViewDelegate, UITableViewDataSource{
func
tableView
(
_
tableView
:
UITableView
,
didSelectRowAt
indexPath
:
IndexPath
)
{
// let show = UIStoryboard.init(name: "Record", bundle: nil).instantiateViewController(withIdentifier: "SHRecordShowViewController") as! SHRecordShowViewController
// if self.searchBarVC.isActive {
// show.model = searchDataSource[indexPath.row]
// }else{
// show.model = dataSources[indexPath.row]
// }
// self.navigationController?.pushViewController(show, animated: true)
let
show
=
UIStoryboard
.
init
(
name
:
"Record"
,
bundle
:
nil
)
.
instantiateViewController
(
withIdentifier
:
"SHRecordShowViewController"
)
as!
SHRecordShowViewController
show
.
model
=
currentModel
.
dataSources
[
indexPath
.
row
]
self
.
navigationController
?
.
pushViewController
(
show
,
animated
:
true
)
}
}
ShorthandMaster/Record/SHRecordListViewController.swift
View file @
fd240c61
...
...
@@ -42,12 +42,6 @@ class SHRecordListViewController: SHBaseViewController {
return
searchBarVC
}()
override
func
viewWillAppear
(
_
animated
:
Bool
)
{
super
.
viewWillAppear
(
animated
)
// prepareDateSource()
// self.tableView?.reloadData()
}
override
func
viewDidAppear
(
_
animated
:
Bool
)
{
super
.
viewDidAppear
(
animated
)
prepareDateSource
()
...
...
@@ -59,20 +53,40 @@ class SHRecordListViewController: SHBaseViewController {
self
.
searchBarVC
.
isActive
=
false
}
@objc
func
hehe
(
_
d
:
NSUbiquitousKeyValueStore
){
print
(
"
\(
d
)
"
)
}
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
NotificationCenter
.
default
.
addObserver
(
self
,
selector
:
#selector(
hehe
)
,
name
:
NSUbiquitousKeyValueStore
.
didChangeExternallyNotification
,
object
:
keyValueStore
)
let
url
=
FileManager
.
default
.
url
(
forUbiquityContainerIdentifier
:
nil
)
print
(
url
as
Any
)
SHCloudManager
.
shared
.
getAllFolderDataSource
{
(
result
,
sss
)
in
SHCloudManager
.
shared
.
getAllFolderDataSource
{
(
result
,
models
)
in
if
result
{
var
localFolder
:[
SHRecordFolderModel
]
=
[]
if
var
list
=
CRUserDefaults
.
recordList
{
for
dict
in
list
{
var
folderModel
=
SHRecordFolderModel
()
folderModel
=
getDataDictWith
(
dict
:
dict
)
localFolder
.
append
(
folderModel
)
}
for
model
in
models
{
let
containModel
=
localFolder
.
filter
{
$0
.
id
==
model
.
id
}
.
first
if
containModel
==
nil
{
list
.
append
(
getDictWith
(
obj
:
model
))
}
}
CRUserDefaults
.
recordList
=
list
}
else
{
var
list
:[
Dictionary
<
String
,
Any
>
]
=
[]
for
model
in
models
{
list
.
append
(
getDictWith
(
obj
:
model
))
}
CRUserDefaults
.
recordList
=
list
}
DispatchQueue
.
main
.
async
{
self
.
prepareDateSource
()
}
}
}
setupUI
()
...
...
@@ -89,7 +103,6 @@ class SHRecordListViewController: SHBaseViewController {
let
leftImage
=
UIImage
.
init
(
named
:
"record_nav_setting"
)?
.
withRenderingMode
(
.
alwaysOriginal
)
self
.
navigationItem
.
leftBarButtonItem
=
UIBarButtonItem
.
init
(
image
:
leftImage
,
style
:
.
plain
,
target
:
self
,
action
:
#selector(
mineCilck
)
)
searchView
=
searchBarVC
.
searchBar
searchView
.
frame
=
CGRect
(
x
:
8
,
y
:
0
,
width
:
SCREEN_WIDTH
-
16
,
height
:
56
)
self
.
tableHeaderView
?
.
addSubview
(
searchView
)
...
...
ShorthandMaster/Record/SHRecordShowViewController.swift
View file @
fd240c61
...
...
@@ -88,7 +88,7 @@ class SHRecordShowViewController: SHBaseViewController {
/*
func prepareRecognition(){
let documentsFile =
(NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first)!
.appending(model!.pathFile)
let documentsFile =
DocumentPath
.appending(model!.pathFile)
// let s = FileManager.default.fileExists(atPath: documentsFile)
...
...
@@ -157,38 +157,38 @@ class SHRecordShowViewController: SHBaseViewController {
AlertControllerTool
.
alertController
(
withTitle
:
"文件重命名"
,
message
:
""
,
textField
:
"请输入新文件名"
,
cancelTitle
:
"取消"
,
cancel
:
{
},
confirm
:
"确认"
,
confirmBlock
:
{
message
in
if
let
rename
:
String
=
message
as?
String
{
self
.
model
!.
rename
=
rename
self
.
setNavTitle
(
self
.
model
!.
rename
)
if
var
list
=
CRUserDefaults
.
recordList
{
for
(
index
,
dic
)
in
list
.
enumerated
(){
if
dic
[
"pathFile"
]
as!
String
==
self
.
model
!.
pathFile
{
var
subDic
=
dic
subDic
[
"rename"
]
=
rename
list
[
index
]
=
subDic
break
}
}
CRUserDefaults
.
recordList
=
list
}
let
keyValueStore
=
NSUbiquitousKeyValueStore
.
default
let
list
=
keyValueStore
.
object
(
forKey
:
"list"
)
as?
[
Dictionary
<
String
,
Any
>
]
if
var
list
=
list
{
for
(
index
,
dic
)
in
list
.
enumerated
(){
if
dic
[
"pathFile"
]
as!
String
==
self
.
model
!.
pathFile
{
var
subDic
=
dic
subDic
[
"rename"
]
=
rename
list
[
index
]
=
subDic
break
}
}
keyValueStore
.
set
(
list
,
forKey
:
"list"
)
keyValueStore
.
synchronize
()
}
}
//
if let rename:String = message as? String {
//
self.model!.rename = rename
//
self.setNavTitle(self.model!.rename)
//
//
if var list = CRUserDefaults.recordList {
//
for (index, dic) in list.enumerated(){
//
if dic["pathFile"] as! String == self.model!.pathFile{
//
var subDic = dic
//
subDic["rename"] = rename
//
list[index] = subDic
//
break
//
}
//
}
//
CRUserDefaults.recordList = list
//
}
//
//
let keyValueStore = NSUbiquitousKeyValueStore.default
//
let list = keyValueStore.object(forKey: "list") as? [Dictionary<String, Any>]
//
//
if var list = list {
//
for (index, dic) in list.enumerated(){
//
if dic["pathFile"] as! String == self.model!.pathFile{
//
var subDic = dic
//
subDic["rename"] = rename
//
list[index] = subDic
//
break
//
}
//
}
//
keyValueStore.set(list, forKey: "list")
//
keyValueStore.synchronize()
//
}
//
}
},
finish
:
nil
)
}
...
...
@@ -223,12 +223,25 @@ class SHRecordShowViewController: SHBaseViewController {
}
do
{
// documentsFile =
(NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first)!
.appending(model!.pcmPathFile)
// documentsFile =
DocumentPath
.appending(model!.pcmPathFile)
let
documentsFile
=
(
NSSearchPathForDirectoriesInDomains
(
.
documentDirectory
,
.
userDomainMask
,
true
)
.
first
)
!
.
appending
(
model
!.
pathFile
)
let
documentsFile
=
DocumentPath
.
appending
(
model
!.
pathFile
)
if
FileManager
.
default
.
fileExists
(
atPath
:
documentsFile
)
==
false
{
player
=
try
AVAudioPlayer
.
init
(
data
:
model
!.
fileData
)
player
=
try
AVAudioPlayer
(
contentsOf
:
URL
(
fileURLWithPath
:
model
!.
assetFileUrlPath
))
//写入
if
let
videoData
=
try
?
Data
(
contentsOf
:
URL
(
fileURLWithPath
:
model
!.
assetFileUrlPath
)){
let
range
:
Range
=
model
!.
pathFile
.
range
(
of
:
"/record.mp3"
)
!
let
location
:
Int
=
model
!.
pathFile
.
distance
(
from
:
model
!.
pathFile
.
startIndex
,
to
:
range
.
lowerBound
)
let
subStr
=
model
!.
pathFile
.
prefix
(
location
)
let
documentsFile_sub
=
DocumentPath
+
subStr
try!
FileManager
.
default
.
createDirectory
(
atPath
:
documentsFile_sub
,
withIntermediateDirectories
:
true
,
attributes
:
nil
)
SHMp3RecordManager
.
shared
()
.
write
(
videoData
,
path
:
documentsFile
)
}
}
else
{
player
=
try
AVAudioPlayer
(
contentsOf
:
URL
(
fileURLWithPath
:
documentsFile
))
}
...
...
@@ -303,7 +316,7 @@ class SHRecordShowViewController: SHBaseViewController {
let
location
:
Int
=
model
!.
pathFile
.
distance
(
from
:
model
!.
pathFile
.
startIndex
,
to
:
range
.
lowerBound
)
let
subStr
=
model
!.
pathFile
.
prefix
(
location
)
let
documentsFile
=
(
NSSearchPathForDirectoriesInDomains
(
.
documentDirectory
,
.
userDomainMask
,
true
)
.
first
)
!
+
subStr
+
"/
\(
model
!.
rename
)
.pdf"
let
documentsFile
=
DocumentPath
+
subStr
+
"/
\(
model
!.
rename
)
.pdf"
try
PDFGenerator
.
generate
(
self
.
recordTextView
!
,
to
:
documentsFile
)
//此三方会把传入控件约束移除 需重新添加
...
...
@@ -335,7 +348,7 @@ class SHRecordShowViewController: SHBaseViewController {
do
{
let
documentsFile_mp3
=
(
NSSearchPathForDirectoriesInDomains
(
.
documentDirectory
,
.
userDomainMask
,
true
)
.
first
)
!
.
appending
(
model
!.
pathFile
)
let
documentsFile_mp3
=
DocumentPath
.
appending
(
model
!.
pathFile
)
let
fileURL_wav
=
URL
.
init
(
fileURLWithPath
:
documentsFile_mp3
)
//没有 先创建 有 直接拿
...
...
@@ -344,11 +357,13 @@ class SHRecordShowViewController: SHBaseViewController {
let
location
:
Int
=
model
!.
pathFile
.
distance
(
from
:
model
!.
pathFile
.
startIndex
,
to
:
range
.
lowerBound
)
let
subStr
=
model
!.
pathFile
.
prefix
(
location
)
let
documentsFile_sub
=
(
NSSearchPathForDirectoriesInDomains
(
.
documentDirectory
,
.
userDomainMask
,
true
)
.
first
)
!
+
subStr
let
documentsFile_sub
=
DocumentPath
+
subStr
try!
FileManager
.
default
.
createDirectory
(
atPath
:
documentsFile_sub
,
withIntermediateDirectories
:
true
,
attributes
:
nil
)
SHMp3RecordManager
.
shared
()
.
write
(
model
!.
fileData
,
path
:
documentsFile_mp3
)
if
let
videoData
=
try
?
Data
(
contentsOf
:
URL
(
fileURLWithPath
:
model
!.
assetFileUrlPath
)){
SHMp3RecordManager
.
shared
()
.
write
(
videoData
,
path
:
documentsFile_mp3
)
}
}
// let data_wav = try Data.init(contentsOf: fileURL_wav)
...
...
@@ -357,7 +372,7 @@ class SHRecordShowViewController: SHBaseViewController {
let
location
:
Int
=
model
!.
pathFile
.
distance
(
from
:
model
!.
pathFile
.
startIndex
,
to
:
range
.
lowerBound
)
let
subStr
=
model
!.
pathFile
.
prefix
(
location
)
let
documentsFile_rename
=
(
NSSearchPathForDirectoriesInDomains
(
.
documentDirectory
,
.
userDomainMask
,
true
)
.
first
)
!
+
subStr
+
"/
\(
model
!.
rename
)
.mp3"
let
documentsFile_rename
=
DocumentPath
+
subStr
+
"/
\(
model
!.
rename
)
.mp3"
let
fileURL_rename
=
URL
.
init
(
fileURLWithPath
:
documentsFile_rename
)
if
FileManager
.
default
.
fileExists
(
atPath
:
documentsFile_rename
)
==
false
{
...
...
ShorthandMaster/Record/SHRecordViewController.swift
View file @
fd240c61
...
...
@@ -45,9 +45,10 @@ class SHRecordViewController: SHBaseViewController{
private
var
recordTime
=
0.00
// url : 录音文件的路径
var
wav_file_path
=
NSSearchPathForDirectoriesInDomains
(
.
documentDirectory
,
.
userDomainMask
,
true
)
.
first
?
.
appending
(
"/record.wav"
)
var
mp3_file_path
=
NSSearchPathForDirectoriesInDomains
(
.
documentDirectory
,
.
userDomainMask
,
true
)
.
first
?
.
appending
(
"/record.mp3"
)
var
pcm_file_path
=
NSSearchPathForDirectoriesInDomains
(
.
documentDirectory
,
.
userDomainMask
,
true
)
.
first
?
.
appending
(
"/xbMixData.caf"
)
var
wav_file_path
=
DocumentPath
.
appending
(
"/record.wav"
)
var
mp3_file_path
=
DocumentPath
.
appending
(
"/record.mp3"
)
var
pcm_file_path
=
DocumentPath
.
appending
(
"/xbMixData.caf"
)
var
images_file_path
:[
String
]
=
[]
var
session
:
AVAudioSession
{
let
session
:
AVAudioSession
=
AVAudioSession
.
sharedInstance
()
...
...
@@ -314,7 +315,7 @@ class SHRecordViewController: SHBaseViewController{
AVEncoderAudioQualityKey
:
NSNumber
(
value
:
Int32
(
AVAudioQuality
.
min
.
rawValue
))
]
do
{
let
recorder
=
try
AVAudioRecorder
(
url
:
URL
(
fileURLWithPath
:
wav_file_path
!
),
settings
:
configDic
)
let
recorder
=
try
AVAudioRecorder
(
url
:
URL
(
fileURLWithPath
:
wav_file_path
),
settings
:
configDic
)
recorder
.
isMeteringEnabled
=
true
// 准备录音(系统会给我们分配一些资源)
recorder
.
prepareToRecord
()
...
...
@@ -328,13 +329,13 @@ class SHRecordViewController: SHBaseViewController{
private
func
configPathFile
(){
let
fileManager
=
FileManager
.
default
let
fileArr
=
SHRecordViewController
.
getAllFilePath
(
(
NSSearchPathForDirectoriesInDomains
(
.
documentDirectory
,
.
userDomainMask
,
true
)
.
first
)
!
)
let
fileArr
=
SHRecordViewController
.
getAllFilePath
(
DocumentPath
)
let
subFile
=
Date
()
.
format
(
"yyyyMMdd"
)
var
exist
=
false
let
time
=
Date
.
init
()
.
timeStamp
for
(
_
,
documentsFile
)
in
fileArr
!.
enumerated
()
{
if
documentsFile
==
NSSearchPathForDirectoriesInDomains
(
.
documentDirectory
,
.
userDomainMask
,
true
)
.
first
?
.
appending
(
"/
\(
subFile
)
"
)
{
if
documentsFile
==
DocumentPath
.
appending
(
"/
\(
subFile
)
"
)
{
let
path
=
documentsFile
.
appending
(
time
)
mp3_file_path
=
"/"
+
subFile
+
time
+
"/record.mp3"
...
...
@@ -342,21 +343,21 @@ class SHRecordViewController: SHBaseViewController{
try!
fileManager
.
createDirectory
(
atPath
:
path
,
withIntermediateDirectories
:
true
,
attributes
:
nil
)
recorder_mp3
.
configMp3Path
(
(
NSSearchPathForDirectoriesInDomains
(
.
documentDirectory
,
.
userDomainMask
,
true
)
.
first
)
!+
mp3_file_path
!
,
pcmPath
:
(
NSSearchPathForDirectoriesInDomains
(
.
documentDirectory
,
.
userDomainMask
,
true
)
.
first
)
!+
pcm_file_path
!
)
recorder_mp3
.
configMp3Path
(
DocumentPath
+
mp3_file_path
,
pcmPath
:
DocumentPath
+
pcm_file_path
)
exist
=
true
break
}
}
if
exist
==
false
{
let
path
=
(
NSSearchPathForDirectoriesInDomains
(
.
documentDirectory
,
.
userDomainMask
,
true
)
.
first
?
.
appending
(
"/
\(
subFile
)
"
)
.
appending
(
time
))
!
let
path
=
(
DocumentPath
.
appending
(
"/
\(
subFile
)
"
)
.
appending
(
time
))
mp3_file_path
=
"/"
+
subFile
+
time
+
"/record.mp3"
pcm_file_path
=
"/"
+
subFile
+
time
+
"/xbMixData.caf"
try!
fileManager
.
createDirectory
(
atPath
:
path
,
withIntermediateDirectories
:
true
,
attributes
:
nil
)
recorder_mp3
.
configMp3Path
(
(
NSSearchPathForDirectoriesInDomains
(
.
documentDirectory
,
.
userDomainMask
,
true
)
.
first
)
!+
mp3_file_path
!
,
pcmPath
:
(
NSSearchPathForDirectoriesInDomains
(
.
documentDirectory
,
.
userDomainMask
,
true
)
.
first
)
!+
pcm_file_path
!
)
recorder_mp3
.
configMp3Path
(
DocumentPath
+
mp3_file_path
,
pcmPath
:
DocumentPath
+
pcm_file_path
)
}
NSLog
(
"mp3_file_path=======
\(
String
(
describing
:
mp3_file_path
)
)
pcm_file_path=======
\(
String
(
describing
:
pcm_file_path
)
)
"
)
...
...
@@ -457,7 +458,7 @@ class SHRecordViewController: SHBaseViewController{
recorder_mp3
.
stop
()
if
let
recorder
=
self
.
recorder
{
if
recorder
.
isRecording
{
print
(
"正在录音,马上结束它,文件保存到了:
\(
wav_file_path
!
)
"
)
print
(
"正在录音,马上结束它,文件保存到了:
\(
wav_file_path
)
"
)
}
else
{
print
(
"没有录音,但是依然结束它"
)
}
...
...
@@ -484,8 +485,8 @@ class SHRecordViewController: SHBaseViewController{
model
.
address
=
currentAddress
??
""
model
.
rename
=
currentAddress
??
""
model
.
txt
=
recognitionTaskText
.
first
??
(
self
.
currentTxt
??
""
)
model
.
pathFile
=
mp3_file_path
!
model
.
pcmPathFile
=
pcm_file_path
!
model
.
pathFile
=
mp3_file_path
model
.
pcmPathFile
=
pcm_file_path
model
.
during
=
seconds
var
contains
=
false
...
...
@@ -522,51 +523,7 @@ class SHRecordViewController: SHBaseViewController{
CRUserDefaults
.
recordList
=
recordList
}
}
currentModel
=
model
do
{
let
documentsFile
=
(
NSSearchPathForDirectoriesInDomains
(
.
documentDirectory
,
.
userDomainMask
,
true
)
.
first
)
!.
appending
(
model
.
pathFile
)
let
url
=
URL
.
init
(
fileURLWithPath
:
documentsFile
)
let
data
=
try
Data
.
init
(
contentsOf
:
url
)
model
.
fileData
=
data
if
folderModel
.
dataSources
.
count
!=
0
{
for
(
index
,
subModel
)
in
folderModel
.
dataSources
.
enumerated
()
{
if
subModel
.
pathFile
==
model
.
pathFile
{
folderModel
.
dataSources
[
index
]
=
model
break
}
}
}
else
{
folderModel
.
dataSources
.
append
(
model
)
}
// let keyValueStore = NSUbiquitousKeyValueStore.default
// let list = keyValueStore.object(forKey: "Folderlist") as? [Dictionary<String, Any>]
//
// if var recordList = list{
// for (index, subDict) in recordList.enumerated(){
// let subFolderModel:SHRecordFolderModel = getDataDictWith(dict: subDict)
// if subFolderModel.id == folderModel.id {
// contains = true
// subFolderModel.modifyDate = nowDate
// subFolderModel.dataSources = folderModel.dataSources
// let dic = getDictWith(obj: subFolderModel)
// recordList[index] = dic
// break
// }
// }
// if contains == true {
// keyValueStore.set(recordList, forKey: "Folderlist")
// keyValueStore.synchronize()
// }
// }
currentModel
=
model
}
catch
{
}
}
func
removeCurrentRecored
(
_
model
:
SHRecordModel
){
...
...
@@ -701,7 +658,7 @@ extension SHRecordViewController{
let
location
:
Int
=
currentModel
!.
pathFile
.
distance
(
from
:
currentModel
!.
pathFile
.
startIndex
,
to
:
range
.
lowerBound
)
let
subStr
=
currentModel
!.
pathFile
.
prefix
(
location
)
let
documentsFile
=
(
NSSearchPathForDirectoriesInDomains
(
.
documentDirectory
,
.
userDomainMask
,
true
)
.
first
)
!
+
subStr
+
"/
\(
currentModel
!.
rename
)
.pdf"
let
documentsFile
=
DocumentPath
+
subStr
+
"/
\(
currentModel
!.
rename
)
.pdf"
try
PDFGenerator
.
generate
(
self
.
recordTextView
!
,
to
:
documentsFile
)
//此三方会把传入控件约束移除 需重新添加
...
...
@@ -732,7 +689,7 @@ extension SHRecordViewController{
private
func
generateWav
()
{
do
{
let
documentsFile_wav
=
(
NSSearchPathForDirectoriesInDomains
(
.
documentDirectory
,
.
userDomainMask
,
true
)
.
first
)
!
.
appending
(
currentModel
!.
pathFile
)
let
documentsFile_wav
=
DocumentPath
.
appending
(
currentModel
!.
pathFile
)
let
fileURL_wav
=
URL
.
init
(
fileURLWithPath
:
documentsFile_wav
)
// let data_wav = try Data.init(contentsOf: fileURL_wav)
...
...
@@ -740,7 +697,7 @@ extension SHRecordViewController{
let
location
:
Int
=
currentModel
!.
pathFile
.
distance
(
from
:
currentModel
!.
pathFile
.
startIndex
,
to
:
range
.
lowerBound
)
let
subStr
=
currentModel
!.
pathFile
.
prefix
(
location
)
let
documentsFile_rename
=
(
NSSearchPathForDirectoriesInDomains
(
.
documentDirectory
,
.
userDomainMask
,
true
)
.
first
)
!
+
subStr
+
"/
\(
currentModel
!.
rename
)
.mp3"
let
documentsFile_rename
=
DocumentPath
+
subStr
+
"/
\(
currentModel
!.
rename
)
.mp3"
let
fileURL_rename
=
URL
.
init
(
fileURLWithPath
:
documentsFile_rename
)
if
FileManager
.
default
.
fileExists
(
atPath
:
documentsFile_rename
)
==
false
{
...
...
ShorthandMaster/Share/Managers/SHCloudManager.swift
View file @
fd240c61
...
...
@@ -135,11 +135,13 @@ class SHCloudManager: NSObject {
recordModel
.
pathFile
=
record
[
"pathFile"
]
as?
String
??
""
recordModel
.
rename
=
record
[
"title"
]
as?
String
??
""
recordModel
.
txt
=
record
[
"content"
]
as?
String
??
""
recordModel
.
during
=
record
[
"during"
]
as?
NSInteger
??
0
recordModel
.
createDate
=
record
[
"createDate"
]
as?
Date
??
Date
(
timeIntervalSince1970
:
0
)
recordModel
.
modifyDate
=
record
[
"modifyDate"
]
as?
Date
??
Date
(
timeIntervalSince1970
:
0
)
recordModel
.
icloud
=
true
// let asset = record["recordAsset"] as! CKAsset
// print(asset.fileURL?.path)
let
asset
=
record
[
"recordAsset"
]
as!
CKAsset
recordModel
.
assetFileUrlPath
=
asset
.
fileURL
?
.
path
??
""
folderModel
.
dataSources
.
append
(
recordModel
)
}
}
...
...
@@ -192,9 +194,10 @@ class SHCloudManager: NSObject {
})
.
first
if
recording
==
nil
{
let
documentsFile
=
(
NSSearchPathForDirectoriesInDomains
(
.
documentDirectory
,
.
userDomainMask
,
true
)
.
first
)
!
.
appending
(
recordModel
.
pathFile
)
let
documentsFile
=
DocumentPath
.
appending
(
recordModel
.
pathFile
)
let
url
=
URL
.
init
(
fileURLWithPath
:
documentsFile
)
let
asset
=
CKAsset
.
init
(
fileURL
:
url
)
let
nowDate
=
Date
()
let
record
=
CKRecord
.
init
(
recordType
:
recordName
)
record
.
setValue
(
recordModel
.
recordingType
,
forKey
:
"recordingType"
)
...
...
@@ -202,10 +205,15 @@ class SHCloudManager: NSObject {
record
.
setValue
(
recordModel
.
pathFile
,
forKey
:
"pathFile"
)
record
.
setValue
(
recordModel
.
address
,
forKey
:
"address"
)
record
.
setValue
(
recordModel
.
txt
,
forKey
:
"content"
)
record
.
setValue
(
recordModel
.
createDate
,
forKey
:
"createTime"
)
record
.
setValue
(
recordModel
.
modifyDate
,
forKey
:
"modifyDate"
)
record
.
setValue
(
recordModel
.
during
,
forKey
:
"during"
)
record
.
setValue
(
nowDate
,
forKey
:
"createTime"
)
record
.
setValue
(
nowDate
,
forKey
:
"modifyDate"
)
record
.
setValue
(
asset
,
forKey
:
"recordAsset"
)
for
image
in
recordModel
.
images
{
}
dateBase
.
save
(
record
)
{
(
subscription
,
saveError
)
in
if
let
error
=
saveError
{
print
(
"
\(
error
.
localizedDescription
)
"
)
...
...
@@ -243,8 +251,9 @@ class SHCloudManager: NSObject {
print
(
"
\(
error
.
localizedDescription
)
"
)
self
.
completionHandler
?(
false
,
[])
}
else
{
let
nowDate
=
Date
()
record
?[
"recordPaths"
]
=
recordPaths
record
?[
"modifyDate"
]
=
folderModel
.
modify
Date
record
?[
"modifyDate"
]
=
now
Date
self
.
dateBase
.
save
(
record
!
)
{
(
saveRecord
,
saveError
)
in
if
let
error
=
saveError
{
...
...
@@ -278,7 +287,11 @@ class SHCloudManager: NSObject {
print
(
"
\(
error
.
localizedDescription
)
"
)
self
.
completionHandler
?(
false
,
[])
}
else
{
record
?
.
setValue
(
recordModel
.
modifyDate
,
forKey
:
"modifyDate"
)
let
nowDate
=
Date
()
record
?
.
setValue
(
nowDate
,
forKey
:
"modifyDate"
)
self
.
dateBase
.
save
(
record
!
)
{
(
saveRecord
,
saveError
)
in
if
let
error
=
saveError
{
...
...
@@ -378,5 +391,4 @@ class SHCloudManager: NSObject {
}
}
}
}
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