Commit 203bd232 authored by lmj_521aiau@163.com's avatar lmj_521aiau@163.com

no message

parent 582e0a94
...@@ -15,4 +15,5 @@ target 'ShorthandMaster' do ...@@ -15,4 +15,5 @@ target 'ShorthandMaster' do
pod 'PDFGenerator', '~> 3.1' pod 'PDFGenerator', '~> 3.1'
pod 'Masonry' pod 'Masonry'
pod 'UMCCommon'
end end
...@@ -19,6 +19,8 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -19,6 +19,8 @@ NS_ASSUME_NONNULL_BEGIN
- (void)pause; - (void)pause;
- (void)stop; - (void)stop;
- (void)write:(NSData *)data path:path;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END
...@@ -154,4 +154,9 @@ static SHMp3RecordManager * manager; ...@@ -154,4 +154,9 @@ static SHMp3RecordManager * manager;
} }
} }
- (void)write:(NSData *)data path:path{
self.dataWriter = [[XBDataWriter alloc] init];
[self.dataWriter writeData:data toPath:path];
}
@end @end
...@@ -29,6 +29,7 @@ class SHRecordListViewController: SHBaseViewController { ...@@ -29,6 +29,7 @@ class SHRecordListViewController: SHBaseViewController {
self.navigationItem.leftBarButtonItem = UIBarButtonItem.init(image: leftImage, style: .plain, target: self, action: #selector(userCilck)) self.navigationItem.leftBarButtonItem = UIBarButtonItem.init(image: leftImage, style: .plain, target: self, action: #selector(userCilck))
setupUI() setupUI()
/*
SHCloudManager.shared.cheakAccountStatus { (result) in SHCloudManager.shared.cheakAccountStatus { (result) in
if result == false{ if result == false{
...@@ -47,11 +48,24 @@ class SHRecordListViewController: SHBaseViewController { ...@@ -47,11 +48,24 @@ class SHRecordListViewController: SHBaseViewController {
}, finish: nil) }, finish: nil)
} }
} }
*/
} }
func prepareDateSource(){ func prepareDateSource(){
dataSources = [] dataSources = []
if let list = CRUserDefaults.recordList { // if let list = CRUserDefaults.recordList {
// for dic in list.reversed(){
// let model = SHRecordModel()
// model.setValuesForKeys(dic)
// if model.delete == false{
// dataSources.append(model)
// }
// }
// }
let keyValueStore = NSUbiquitousKeyValueStore.default
let list = keyValueStore.object(forKey: "list") as? [Dictionary<String, Any>]
if let list = list {
for dic in list.reversed(){ for dic in list.reversed(){
let model = SHRecordModel() let model = SHRecordModel()
model.setValuesForKeys(dic) model.setValuesForKeys(dic)
...@@ -59,6 +73,7 @@ class SHRecordListViewController: SHBaseViewController { ...@@ -59,6 +73,7 @@ class SHRecordListViewController: SHBaseViewController {
dataSources.append(model) dataSources.append(model)
} }
} }
tableView?.reloadData()
} }
if dataSources.count == 0 { if dataSources.count == 0 {
...@@ -71,19 +86,38 @@ class SHRecordListViewController: SHBaseViewController { ...@@ -71,19 +86,38 @@ class SHRecordListViewController: SHBaseViewController {
func removeModel(_ indexPath: IndexPath){ func removeModel(_ indexPath: IndexPath){
var list = CRUserDefaults.recordList // var list = CRUserDefaults.recordList
//
// let deleteModel = dataSources[indexPath.row]
//
// for (index, dic) in list!.enumerated(){
// if dic["pathFile"] as! String == deleteModel.pathFile{
// var subDic = dic
// subDic["delete"] = true
// subDic["deleteDate"] = Date.init()
// list![index] = subDic
// }
// }
// CRUserDefaults.recordList = list
let deleteModel = dataSources[indexPath.row] let deleteModel = dataSources[indexPath.row]
for (index, dic) in list!.enumerated(){ let keyValueStore = NSUbiquitousKeyValueStore.default
if dic["pathFile"] as! String == deleteModel.pathFile{ let list = keyValueStore.object(forKey: "list") as? [Dictionary<String, Any>]
var subDic = dic
subDic["delete"] = true if var list = list {
subDic["deleteDate"] = Date.init() for (index, dic) in list.enumerated(){
list![index] = subDic if dic["pathFile"] as! String == deleteModel.pathFile{
// var subDic = dic
// subDic["delete"] = true
// subDic["deleteDate"] = Date.init()
// list[index] = subDic
list.remove(at: index)
}
} }
keyValueStore.set(list, forKey: "list")
keyValueStore.synchronize()
} }
CRUserDefaults.recordList = list
self.prepareDateSource() self.prepareDateSource()
self.tableView?.beginUpdates() self.tableView?.beginUpdates()
...@@ -112,13 +146,17 @@ class SHRecordListViewController: SHBaseViewController { ...@@ -112,13 +146,17 @@ class SHRecordListViewController: SHBaseViewController {
@objc func userCilck(){ @objc func userCilck(){
let mine = UIStoryboard.init(name: "Mine", bundle: nil).instantiateViewController(withIdentifier: "SHMineViewController") as! SHMineViewController if SHUserAccountManager.shared.isMember == false {
self.navigationController?.pushViewController(mine, animated: true) self.goRecord()
}
} }
@IBAction func goRecord(){ @IBAction func goRecord(){
if let list = CRUserDefaults.recordList, list.count > 1{ if dataSources.count > 1{
if SHUserAccountManager.shared.isMember == false{ if SHUserAccountManager.shared.isMember == false{
self.goGoods() self.goGoods()
return return
......
...@@ -203,11 +203,17 @@ class SHRecordShowViewController: SHBaseViewController { ...@@ -203,11 +203,17 @@ class SHRecordShowViewController: SHBaseViewController {
} }
} }
do { do {
let documentsFile = (NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first)!.appending(model!.pathFile)
// documentsFile = (NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first)!.appending(model!.pcmPathFile) // documentsFile = (NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first)!.appending(model!.pcmPathFile)
// player = try AVAudioPlayer.init(data: model!.fileData) let documentsFile = (NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first)!.appending(model!.pathFile)
player = try AVAudioPlayer(contentsOf: URL(fileURLWithPath: documentsFile))
if FileManager.default.fileExists(atPath: documentsFile) == false {
player = try AVAudioPlayer.init(data: model!.fileData)
}else{
player = try AVAudioPlayer(contentsOf: URL(fileURLWithPath: documentsFile))
}
print("歌曲长度:\(player!.duration)") print("歌曲长度:\(player!.duration)")
player!.play() player!.play()
...@@ -303,11 +309,23 @@ class SHRecordShowViewController: SHBaseViewController { ...@@ -303,11 +309,23 @@ class SHRecordShowViewController: SHBaseViewController {
@objc fileprivate func generateWav() { @objc fileprivate func generateWav() {
do{ do{
// let manager = FileManager.default
// manager.copyItem(atPath: <#T##String#>, toPath: <#T##String#>) let documentsFile_mp3 = (NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first)!.appending(model!.pathFile)
let documentsFile_wav = (NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first)!.appending(model!.pathFile)
let fileURL_wav = URL.init(fileURLWithPath: documentsFile_wav) 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 = (NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first)!+subStr
try! FileManager.default.createDirectory(atPath: documentsFile_sub, withIntermediateDirectories: true, attributes: nil)
let fileURL_wav = URL.init(fileURLWithPath: documentsFile_mp3)
SHMp3RecordManager.shared().write(model!.fileData, path: documentsFile_mp3)
let data_wav = try Data.init(contentsOf: fileURL_wav) let data_wav = try Data.init(contentsOf: fileURL_wav)
if FileManager.default.fileExists(atPath: documentsFile_mp3) == false {}
let activityVC = UIActivityViewController(activityItems: [data_wav, fileURL_wav], applicationActivities: nil) let activityVC = UIActivityViewController(activityItems: [data_wav, fileURL_wav], applicationActivities: nil)
activityVC.completionWithItemsHandler = { activityVC.completionWithItemsHandler = {
......
...@@ -132,6 +132,7 @@ class SHRecordViewController: SHBaseViewController{ ...@@ -132,6 +132,7 @@ class SHRecordViewController: SHBaseViewController{
UIApplication.shared.keyWindow!.addSubview(export) UIApplication.shared.keyWindow!.addSubview(export)
export.selectedIndexCallBack = { index in export.selectedIndexCallBack = { index in
if index == 0 { if index == 0 {
MBProgressHUD.showMessage("已复制文本内容", to: export)
self.copyBtn() self.copyBtn()
} else if index == 1{ } else if index == 1{
self.generatePDF() self.generatePDF()
...@@ -449,59 +450,61 @@ class SHRecordViewController: SHBaseViewController{ ...@@ -449,59 +450,61 @@ class SHRecordViewController: SHBaseViewController{
model.pcmPathFile = pcm_file_path! model.pcmPathFile = pcm_file_path!
model.during = seconds model.during = seconds
let dic = ["time":model.time, "address":model.address, "txt":model.txt, "pathFile":model.pathFile, "during":model.during, "delete":model.delete, "rename":model.rename] as [String : Any] // let dic = ["time":model.time, "address":model.address, "txt":model.txt, "pathFile":model.pathFile, "during":model.during, "delete":model.delete, "rename":model.rename] as [String : Any]
var list = CRUserDefaults.recordList // var list = CRUserDefaults.recordList
if list == nil { // if list == nil {
list = [dic] // list = [dic]
}else{ // }else{
var contains = false // var contains = false
for (index, subDic) in list!.enumerated(){ // for (index, subDic) in list!.enumerated(){
if (subDic["pathFile"] as! String) == model.pathFile { // if (subDic["pathFile"] as! String) == model.pathFile {
contains = true // contains = true
list![index] = dic // list![index] = dic
break // break
}
}
if contains == false {
list?.append(dic)
}
}
CRUserDefaults.recordList = list
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)
//
// let dic = ["time":model.time, "address":model.address, "txt":model.txt, "pathFile":model.pathFile, "during":model.during, "delete":model.delete, "fileData":recorder_ss_data] as [String : Any]
//
// let keyValueStore = NSUbiquitousKeyValueStore.default
// var list = keyValueStore.object(forKey: "list") as? [Dictionary<String, Any>]
// if list == nil {
// list = [dic]
// }else{
// var contains = false
// for (index, subDic) in list!.enumerated(){
// if (subDic["pathFile"] as! String) == model.pathFile {
// contains = true
// list![index] = dic
// break
// }
// }
// if contains == false {
// list!.append(dic)
// } // }
// } // }
// keyValueStore.set(list, forKey: "list") // if contains == false {
// keyValueStore.synchronize() // list?.append(dic)
// // }
// } catch {
//
// } // }
// CRUserDefaults.recordList = list
//
// 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
let dic = ["time":model.time, "address":model.address, "txt":model.txt, "pathFile":model.pathFile, "during":model.during, "delete":model.delete, "fileData":model.fileData, "rename":model.rename] as [String : Any]
let keyValueStore = NSUbiquitousKeyValueStore.default
var list = keyValueStore.object(forKey: "list") as? [Dictionary<String, Any>]
if list == nil {
list = [dic]
}else{
var contains = false
for (index, subDic) in list!.enumerated(){
if (subDic["pathFile"] as! String) == model.pathFile {
contains = true
list![index] = dic
break
}
}
if contains == false {
list!.append(dic)
}
}
keyValueStore.set(list, forKey: "list")
keyValueStore.synchronize()
currentModel = model
} catch {
}
} }
func removeCurrentRecored(_ model:SHRecordModel){ func removeCurrentRecored(_ model:SHRecordModel){
...@@ -626,11 +629,11 @@ extension SHRecordViewController{ ...@@ -626,11 +629,11 @@ extension SHRecordViewController{
private func generatePDF() { private func generatePDF() {
do { do {
let range: Range = currentModel!.pathFile.range(of: "/record.map")! let range: Range = currentModel!.pathFile.range(of: "/record.mp3")!
let location: Int = currentModel!.pathFile.distance(from: currentModel!.pathFile.startIndex, to: range.lowerBound) let location: Int = currentModel!.pathFile.distance(from: currentModel!.pathFile.startIndex, to: range.lowerBound)
let subStr = currentModel!.pathFile.prefix(location) let subStr = currentModel!.pathFile.prefix(location)
let documentsFile = (NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first)!+subStr+"/\(subStr).pdf" let documentsFile = (NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first)!+subStr+"/\(currentModel!.rename).pdf"
try PDFGenerator.generate(self.recordTextView!, to: documentsFile) try PDFGenerator.generate(self.recordTextView!, to: documentsFile)
//此三方会把传入控件约束移除 需重新添加 //此三方会把传入控件约束移除 需重新添加
......
...@@ -20,7 +20,7 @@ class SHStoreManager: NSObject { ...@@ -20,7 +20,7 @@ class SHStoreManager: NSObject {
case .success(let product): case .success(let product):
log("Purchase Success: \(product.productId)") log("Purchase Success: \(product.productId)")
let appleValidator = AppleReceiptValidator(service: .production, sharedSecret: "a2495c6d266e43fea58fda6c49f12264") let appleValidator = AppleReceiptValidator(service: .production, sharedSecret: "0b55ed291ec647e7867e20681fb88a41")
let hud1 = MBProgressHUD.showAdded(to: inView, animated: true) let hud1 = MBProgressHUD.showAdded(to: inView, animated: true)
SwiftyStoreKit.verifyReceipt(using: appleValidator) { result in SwiftyStoreKit.verifyReceipt(using: appleValidator) { result in
hud1.hide(animated: true) hud1.hide(animated: true)
...@@ -200,7 +200,7 @@ class SHStoreManager: NSObject { ...@@ -200,7 +200,7 @@ class SHStoreManager: NSObject {
} }
print("Restore sortedResults: \(sortedResults)") print("Restore sortedResults: \(sortedResults)")
if let purchase = sortedResults.last { if let purchase = sortedResults.last {
let appleValidator = AppleReceiptValidator(service: .production, sharedSecret: "a2495c6d266e43fea58fda6c49f12264") let appleValidator = AppleReceiptValidator(service: .production, sharedSecret: "0b55ed291ec647e7867e20681fb88a41")
let hud1 = MBProgressHUD.show(with: toView) let hud1 = MBProgressHUD.show(with: toView)
SwiftyStoreKit.verifyReceipt(using: appleValidator) { result in SwiftyStoreKit.verifyReceipt(using: appleValidator) { result in
hud1?.hide(animated: true) hud1?.hide(animated: true)
......
...@@ -5,6 +5,11 @@ ...@@ -5,6 +5,11 @@
#import "MBProgressHUD+MJ.h" #import "MBProgressHUD+MJ.h"
#import "AESCipher.h" #import "AESCipher.h"
#import "UIView+CornerRadii.h" #import "UIView+CornerRadii.h"
#import "SHMp3RecordManager.h" #import "SHMp3RecordManager.h"
#import "SHMemberUpgradeAlertView.h" #import "SHMemberUpgradeAlertView.h"
#import "AlertControllerTool.h" #import "AlertControllerTool.h"
#import <UMCommon/UMCommon.h>
#import <UMCommon/MobClick.h>
...@@ -5,18 +5,9 @@ ...@@ -5,18 +5,9 @@
<key>aps-environment</key> <key>aps-environment</key>
<string>development</string> <string>development</string>
<key>com.apple.developer.icloud-container-identifiers</key> <key>com.apple.developer.icloud-container-identifiers</key>
<array> <array/>
<string>iCloud.com.ShorthandMaster.www</string>
</array>
<key>com.apple.developer.icloud-services</key> <key>com.apple.developer.icloud-services</key>
<array> <array/>
<string>CloudKit</string>
<string>CloudDocuments</string>
</array>
<key>com.apple.developer.ubiquity-container-identifiers</key>
<array>
<string>iCloud.com.ShorthandMaster.www</string>
</array>
<key>com.apple.developer.ubiquity-kvstore-identifier</key> <key>com.apple.developer.ubiquity-kvstore-identifier</key>
<string>$(TeamIdentifierPrefix)$(CFBundleIdentifier)</string> <string>$(TeamIdentifierPrefix)$(CFBundleIdentifier)</string>
</dict> </dict>
......
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