Commit 446c75f7 authored by lmj_521aiau@163.com's avatar lmj_521aiau@163.com

icloud 优化

parent 1a7e95d5
......@@ -73,7 +73,7 @@ class SHMineViewController: SHBaseViewController {
}
func sortType(){
UIAlertController.showActionSheet(withTitle: "", message: "", cancelBtnTitle: "取消", otherBtnTitles: sortTypes) { (index) in
UIAlertController.showActionSheet(withTitle: nil, message: nil, cancelBtnTitle: "取消", otherBtnTitles: sortTypes) { (index) in
if index == 0{
return
}
......@@ -153,6 +153,7 @@ extension SHMineViewController:UITableViewDelegate, UITableViewDataSource{
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)
switch indexPath.section {
case 0:
sortType()
......@@ -178,7 +179,18 @@ extension SHMineViewController:UITableViewDelegate, UITableViewDataSource{
self.navigationController?.pushViewController(webView, animated: true)
break
case 3:
SHStoreManager.restorePurchases(success: {
SHUserAccountManager.shared.getUserInfo({ (model) in
if model.isMember{
self.getUserInfo()
MBProgressHUD.showSuccess("恢复成功")
}else{
MBProgressHUD.showError("恢复失败,请稍后再试")
}
}, failure: {
MBProgressHUD.showError("恢复失败,请稍后再试")
})
}, toView: self.view)
break
default:
break
......@@ -188,13 +200,5 @@ extension SHMineViewController:UITableViewDelegate, UITableViewDataSource{
default:
break
}
// let webView = SHWebViewController()
// webView.url = SHUserAccountManager.shared.h5_urlDic["user"] as? String
// webView.title = "付费用户协议"
// self.navigationController?.pushViewController(webView, animated: true)
// let delete = UIStoryboard.init(name: "Mine", bundle: nil).instantiateViewController(withIdentifier: "SHDeleteDetailsViewController") as! SHDeleteDetailsViewController
// self.navigationController?.pushViewController(delete, animated: true)
}
}
......@@ -32,6 +32,7 @@ class SHRecordModel: NSObject{
@objc var selected: Bool = false
@objc var icloud: Bool = false
@objc var processing: Bool = false
override func setValue(_ value: Any?, forUndefinedKey key: String) {
......
......@@ -193,13 +193,13 @@
<rect key="frame" x="0.0" y="100" width="414" height="678"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="点击右上角添加笔记" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="JlT-EC-bWg">
<rect key="frame" x="115.5" y="395" width="183.5" height="24"/>
<fontDescription key="fontDescription" type="system" pointSize="20"/>
<rect key="frame" x="124.5" y="396" width="165.5" height="21.5"/>
<fontDescription key="fontDescription" type="system" pointSize="18"/>
<color key="textColor" red="0.40000000000000002" green="0.40000000000000002" blue="0.40000000000000002" alpha="0.84705882349999995" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="recordlist_no_data" translatesAutoresizingMaskIntoConstraints="NO" id="1ji-L1-Qj7">
<rect key="frame" x="123.5" y="272" width="167" height="103"/>
<rect key="frame" x="123.5" y="273" width="167" height="103"/>
</imageView>
</subviews>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
......@@ -334,13 +334,13 @@
<rect key="frame" x="0.0" y="44" width="414" height="758"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="这个笔记本里还没有笔记" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="QYS-Yf-f9g">
<rect key="frame" x="95" y="367" width="224.5" height="24"/>
<fontDescription key="fontDescription" type="system" pointSize="20"/>
<rect key="frame" x="106" y="368.5" width="202" height="21.5"/>
<fontDescription key="fontDescription" type="system" pointSize="18"/>
<color key="textColor" red="0.40000000000000002" green="0.40000000000000002" blue="0.40000000000000002" alpha="0.84705882349999995" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="recordlist_no_data" translatesAutoresizingMaskIntoConstraints="NO" id="QrU-uf-U0R">
<rect key="frame" x="123.5" y="244" width="167" height="103"/>
<rect key="frame" x="123.5" y="245.5" width="167" height="103"/>
</imageView>
</subviews>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
......
......@@ -128,11 +128,12 @@ class SHRecordDetailsVC: SHBaseViewController {
@objc func editClick(_ restore:Bool){
self.markAlertViewShow(false)
self.bottomView?.cancel = true
if restore == false{
if currentModel.dataSources.count == 0 {
return
}
edit = !edit
}else {
edit = false
......@@ -210,7 +211,9 @@ extension SHRecordDetailsVC {
//MARK:icloud上传Models
func icloundUpload(_ index:NSInteger){
let model = currentModel.dataSources[index]
if model.processing == true {
return
}
var contains = false
for folderModel in SHCloudManager.shared.icloudFolderModels {
if currentModel.id == folderModel.id {
......@@ -219,10 +222,12 @@ extension SHRecordDetailsVC {
}
}
model.processing = true
if contains {
SHCloudManager.shared.addNewRecord(model) { (result, models) in
if result {
model.icloud = true
model.processing = false
SHCloudManager.shared.modifyFolder(self.currentModel) { (result, models) in
if result {
self.updateocloudUI()
......@@ -234,6 +239,7 @@ extension SHRecordDetailsVC {
SHCloudManager.shared.addNewRecord(model) { (result, models) in
if result {
model.icloud = true
model.processing = false
SHCloudManager.shared.addNewFolder(self.currentModel) { (result, models) in
if result {
self.updateocloudUI()
......@@ -310,11 +316,8 @@ extension SHRecordDetailsVC {
if self.currentModel.dataSources.count == 0 {
self.editClick(true)
self.markAlertViewShow(false)
self.bottomView?.cancel = true
}
self.selectRecordModels = []
// edit = false
DispatchQueue.main.async {
self.tableView?.reloadData()
}
......
......@@ -158,93 +158,23 @@ class SHRecordListViewController: SHBaseViewController {
}
}
var list = keyValueStore.object(forKey: "Folderlist") as? [Dictionary<String, Any>]
if list == nil {
list = keyValueStore.object(forKey: "list") as? [Dictionary<String, Any>]
}
list = nil
if let list = list {
var folderModel = SHRecordFolderModel()
if let sub = list.first{
folderModel = getDataDictWith(dict: sub)
if folderModel.id.length == 0 {
folderModel.createDate = nowDate
folderModel.modifyDate = nowDate
folderModel.name = "未知";
folderModel.id = nowDate.milliStamp
for dic in list.reversed(){
var model = SHRecordModel()
model = getDataDictWith(dict: dic)
folderModel.dataSources.append(model)
}
let modifyDateSortDataSources = folderModel.dataSources.sorted { (model0, model1) -> Bool in
return model0.modifyDate.compare(model1.modifyDate) == ComparisonResult.orderedDescending
}
folderModel.modifyDate = modifyDateSortDataSources.first?.modifyDate ?? nowDate
let modelDict = getDictWith(obj: folderModel)
keyValueStore.set([modelDict], forKey: "Folderlist")
keyValueStore.synchronize()
print("synchronize === \(keyValueStore.synchronize())")
}
switch CRUserDefaults.sortType {
case 0:
dataSources.sort { (model0, model1) -> Bool in
return model0.createDate.compare(model1.createDate) == ComparisonResult.orderedDescending
}
// let modityList = keyValueStore.object(forKey: "Folderlist") as? [Dictionary<String, Any>]
// if let list = modityList {
// for dict in list.reversed(){
// var model = SHRecordFolderModel()
// model = getDataDictWith(dict: dict)
// if model.top == true {
// topDataSources.append(model)
// }else{
// dataSources.append(model)
// }
// }
// }
dataSources = dataSources.filterDuplicates({$0.id})
topDataSources = topDataSources.filterDuplicates({$0.id})
switch CRUserDefaults.sortType {
case 0:
dataSources.sort { (model0, model1) -> Bool in
return model0.createDate.compare(model1.createDate) == ComparisonResult.orderedDescending
}
topDataSources.sort { (model0, model1) -> Bool in
return model0.createDate.compare(model1.createDate) == ComparisonResult.orderedDescending
}
break
default:
dataSources.sort { (model0, model1) -> Bool in
return model0.modifyDate.compare(model1.modifyDate) == ComparisonResult.orderedDescending
}
topDataSources.sort { (model0, model1) -> Bool in
return model0.modifyDate.compare(model1.modifyDate) == ComparisonResult.orderedDescending
}
break
topDataSources.sort { (model0, model1) -> Bool in
return model0.createDate.compare(model1.createDate) == ComparisonResult.orderedDescending
}
}else{
switch CRUserDefaults.sortType {
case 0:
dataSources.sort { (model0, model1) -> Bool in
return model0.createDate.compare(model1.createDate) == ComparisonResult.orderedDescending
}
topDataSources.sort { (model0, model1) -> Bool in
return model0.createDate.compare(model1.createDate) == ComparisonResult.orderedDescending
}
break
default:
dataSources.sort { (model0, model1) -> Bool in
return model0.modifyDate.compare(model1.modifyDate) == ComparisonResult.orderedDescending
}
topDataSources.sort { (model0, model1) -> Bool in
return model0.modifyDate.compare(model1.modifyDate) == ComparisonResult.orderedDescending
}
break
break
default:
dataSources.sort { (model0, model1) -> Bool in
return model0.modifyDate.compare(model1.modifyDate) == ComparisonResult.orderedDescending
}
topDataSources.sort { (model0, model1) -> Bool in
return model0.modifyDate.compare(model1.modifyDate) == ComparisonResult.orderedDescending
}
break
}
dataSources = topDataSources+dataSources
......@@ -260,7 +190,6 @@ class SHRecordListViewController: SHBaseViewController {
self.view.sendSubviewToBack(maskView)
}
markCountLab?.text = "笔记本总数:\(dataSources.count)"
}
@objc func mineCilck(){
......@@ -541,7 +470,7 @@ extension SHRecordListViewController: UITableViewDelegate, UITableViewDataSource
self.removeModel(indexPath)
completionHandler(true)
completionHandler(false)
}
deleteAction.image = UIImage.init(named: "recordlist_delete")
deleteAction.backgroundColor = UIColor.init(hexStr: "E93425")
......@@ -550,7 +479,7 @@ extension SHRecordListViewController: UITableViewDelegate, UITableViewDataSource
self.renameModel(indexPath)
completionHandler(true)
completionHandler(false)
}
renameAction.image = UIImage.init(named: "recordlist_rename")
renameAction.backgroundColor = UIColor.init(hexStr: "BCBCBC")
......
......@@ -151,7 +151,7 @@ class SHRecordMoveFileVC: SHBaseViewController {
}
}
}
MBProgressHUD.show("正在处理中,请稍后...", view: nil)
MBProgressHUD.show("正在转移中,请稍后...", view: nil)
let list = CRUserDefaults.recordList
if var recordList = list{
//增
......@@ -183,32 +183,43 @@ class SHRecordMoveFileVC: SHBaseViewController {
}
SHCloudManager.shared.modifyFolder(self.currentModel) { (result, models) in
if result {
var contains = false
for folderModel in SHCloudManager.shared.icloudFolderModels {
if targetModel.id == folderModel.id {
contains = true
break
var contains = false
let folderRecord = SHCloudManager.shared.icloudFolderModels.filter({ $0.id == targetModel.id
}).first
if folderRecord != nil {
contains = true
}
if contains {
SHCloudManager.shared.modifyFolder(targetModel) { (result, models) in
if result {
self.saveSuccessCallBack?(self.currentModel)
DispatchQueue.main.async {
MBProgressHUD.hide()
self.navigationController?.dismiss(animated: true, completion: nil)
}
}
}
if contains {
SHCloudManager.shared.modifyFolder(targetModel) { (result, models) in
if result {
self.saveSuccessCallBack?(self.currentModel)
DispatchQueue.main.async {
MBProgressHUD.hide()
self.navigationController?.dismiss(animated: true, completion: nil)
}
}
} else {
let folderRecord = targetModel.dataSources.filter({ $0.icloud == true
}).first
if folderRecord == nil {
self.saveSuccessCallBack?(self.currentModel)
DispatchQueue.main.async {
MBProgressHUD.hide()
self.navigationController?.dismiss(animated: true, completion: nil)
}
} else {
SHCloudManager.shared.addNewFolder(targetModel) { (result, models) in
if result {
self.saveSuccessCallBack?(self.currentModel)
DispatchQueue.main.async {
MBProgressHUD.hide()
self.navigationController?.dismiss(animated: true, completion: nil)
}
return
}
SHCloudManager.shared.addNewFolder(targetModel) { (result, models) in
if result {
self.saveSuccessCallBack?(self.currentModel)
DispatchQueue.main.async {
MBProgressHUD.hide()
self.navigationController?.dismiss(animated: true, completion: nil)
}
}
}
......
......@@ -263,10 +263,6 @@ class SHRecordViewController: SHBaseViewController{
func saveContent(){
// if currentTxt?.length == 0 {
// return
// }
let nowDate = Date()
let model = SHRecordModel()
model.recordingType = 0
......@@ -279,17 +275,17 @@ class SHRecordViewController: SHBaseViewController{
model.pcmPathFile = pcm_file_path
model.during = seconds
image_file_paths = []
image_indexs = []
let images = ["recordlist_no_data_search", "recordlist_no_data"]
for (index, imageStr) in images.enumerated(){
let image = UIImage.init(named: imageStr)
let filePath = DocumentPath+image_file_path+"\(index).jpeg"
let imageData = image!.jpegData(compressionQuality: 1)
try? imageData?.write(to: URL(fileURLWithPath: filePath))
image_file_paths.append(image_file_path+"\(index).jpeg")
image_indexs.append(index)
}
// image_file_paths = []
// image_indexs = []
// let images = ["recordlist_no_data_search", "recordlist_no_data"]
// for (index, imageStr) in images.enumerated(){
// let image = UIImage.init(named: imageStr)
// let filePath = DocumentPath+image_file_path+"\(index).jpeg"
// let imageData = image!.jpegData(compressionQuality: 1)
// try? imageData?.write(to: URL(fileURLWithPath: filePath))
// image_file_paths.append(image_file_path+"\(index).jpeg")
// image_indexs.append(index)
// }
model.imagesPath = []
model.imagesIndex = []
......
......@@ -177,6 +177,7 @@ class SHAVAudioManager: NSObject {
let lowPassResults = pow(10, (0.05 * (self.monitor?.peakPower(forChannel: 0))!));
decibelsCallBack?(lowPassResults)
// print("lowPassResults == \(lowPassResults)")
// print("decibels == \(decibels)")
if decibels > -44 {
if recognitionTask?.isCancelled == true && self.state == SHRecordState.start{
......@@ -260,7 +261,7 @@ class SHAVAudioManager: NSObject {
return $0 + " " + $1
}}
)
if recorderResult.hasSuffix("\n") {
if recorderResult.hasSuffix("\n") || recorderResult.length == 0 {
recorderResult = recorderResult + processStr
}else{
recorderResult = recorderResult + " " + processStr
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment