Commit f4d8fe36 authored by shigemi miura's avatar shigemi miura

音声入力追加

parent a2e1336e
......@@ -42,8 +42,9 @@ struct Imagepicker : UIViewControllerRepresentable {
//Use Photo
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
let image = info[.originalImage] as! UIImage
let data = image.pngData()
self.parent.image = data!
if let data = image.jpegData(compressionQuality: 1.0) {
self.parent.image = data
}
self.parent.show.toggle()
}
}
......
......@@ -34,6 +34,8 @@ struct ChatInputView: View {
Divider()
HStack(spacing: 10) {
Spacer(minLength: 10)
// MARK: - カメラボタン
Button {
sceneDelegate.tabWindow?.isHidden = true
......@@ -73,24 +75,24 @@ struct ChatInputView: View {
}
//MARK: - 音声入力ボタン
// Button {
// isRecording.toggle()
// if isRecording {
// speechRecognizer.transcribedText = ""
// speechRecognizer.startRecording()
// } else {
// speechRecognizer.stopRecording()
// inputText = speechRecognizer.transcribedText
// }
// } label: {
// Image(systemName: isRecording ? "mic.fill" : "mic")
// .resizable()
// .frame(width: 20, height: 20)
// .padding(5)
// }
Button {
isRecording.toggle()
if isRecording {
speechRecognizer.transcribedText = ""
speechRecognizer.startRecording()
} else {
speechRecognizer.stopRecording()
inputText = speechRecognizer.transcribedText
}
} label: {
Image(systemName: isRecording ? "mic.fill" : "mic")
.resizable()
.frame(width: 20, height: 20)
.padding(5)
}
//MARK: - テキスト入力
TextField("", text: $inputText, onEditingChanged: { isEditing in
TextField("Enter your message", text: $inputText, onEditingChanged: { isEditing in
sceneDelegate.tabWindow?.isHidden = isEditing
isFocus = true
})
......
......@@ -909,7 +909,7 @@ class LocationCalculation{
}
if let dist = distance {
print(debug: "checkPolyline \(dist)")
// print(debug: "checkPolyline \(dist)")
}
return distance
}
......@@ -950,14 +950,14 @@ class LocationCalculation{
}
}
print(debug: "crossLineDistance \(rtn)/(isOutside)/(distance)")
// print(debug: "crossLineDistance \(rtn)/(isOutside)/(distance)")
}
}
if isOutside {
distance *= -1
}
print(debug: "crossLineDistance \(distance)")
// print(debug: "crossLineDistance \(distance)")
return (isCross, distance)
}
......@@ -988,7 +988,7 @@ class LocationCalculation{
for cnt in 0...(loopCntMax - 1) {
let newDistance = distance2(lastPos: objPos[cnt], nextPos: shipPos, type: Mrdc.E_NV_MRDC_NORMAL)
if newDistance.retCode {
print(debug: "pointsDistance \(newDistance) (cnt)")
// print(debug: "pointsDistance \(newDistance) (cnt)")
if distance > newDistance.dist {
distance = newDistance.dist
nearbyPoint = cnt
......@@ -1024,7 +1024,7 @@ class LocationCalculation{
var distance1 = 0.0
let rtn1 = eNvXteRL(lastPos: objPos[beforePoint], nextPos: objPos[nearbyPoint], shipPos: shipPos)
if rtn1.retCode {
print(debug: "pointsDistance \(rtn1)/(beforePoint)/(nearbyPoint)/(distance)")
// print(debug: "pointsDistance \(rtn1)/(beforePoint)/(nearbyPoint)/(distance)")
if rtn1.xte < 0 {
outside1 = true
}
......@@ -1035,7 +1035,7 @@ class LocationCalculation{
var distance2 = 0.0
let rtn2 = eNvXteRL(lastPos: objPos[nearbyPoint], nextPos: objPos[nextPoint], shipPos: shipPos)
if rtn2.retCode {
print(debug: "pointsDistance \(rtn2)/(beforePoint)/(nearbyPoint)/(distance)")
// print(debug: "pointsDistance \(rtn2)/(beforePoint)/(nearbyPoint)/(distance)")
if rtn2.xte < 0 {
outside2 = true
}
......@@ -1060,7 +1060,7 @@ class LocationCalculation{
if outside {
distance *= -1
}
print(debug: "pointsDistance \(distance)")
// print(debug: "pointsDistance \(distance)")
return (lineOut, distance)
}
......@@ -1077,13 +1077,13 @@ class LocationCalculation{
-> (retCode: Bool, xte: Double) //正常終了:true 異常:false 距離[NM]
{
let rtn1 = eNvMrdc(lastPos: lastPos, nextPos: nextPos, type: Mrdc.E_NV_MRDC_NORMAL)
print(debug: "eNvXteRL1 \(rtn1)")
// print(debug: "eNvXteRL1 \(rtn1)")
if (!rtn1.retCode) {
return (false, 0.0)
}
let rRegCo = LocationCalculation.deg2rad(deg: rtn1.co1)
let rtn2 = eNvMrdc(lastPos: lastPos, nextPos: shipPos, type: Mrdc.E_NV_MRDC_NORMAL)
print(debug: "eNvXteRL2 \(rtn2)")
// print(debug: "eNvXteRL2 \(rtn2)")
if (!rtn2.retCode) {
return (false, 0.0)
}
......@@ -1318,7 +1318,7 @@ class LocationCalculation{
dist = LocationCalculation.rad2deg(rad: dist) * deg2NM
}
dist = abs(dist)
print( debug: "dist:\(dist)" )
// print( debug: "dist:\(dist)" )
return DistanceInf(retCode: true, dist: dist)
}
......
......@@ -117,7 +117,7 @@ class AppDelegate: NSObject, UIApplicationDelegate ,MSNotificationHubDelegate, M
.withAutoReconnect()
// .withLogging(minLogLevel: .error)
.withLogging(minLogLevel: .debug)
.withHubConnectionOptions(configureHubConnectionOptions: {options in options.keepAliveInterval = 20 })
.withHubConnectionOptions(configureHubConnectionOptions: {options in options.keepAliveInterval = 30})
.build()
if let r_connection = connection {
......@@ -315,22 +315,27 @@ class ChatHubConnectionDelegate: HubConnectionDelegate {
}
func connectionDidOpen(hubConnection: HubConnection) {
print(debug: "connectionDidStart")
app?.connectionDidStart()
}
func connectionDidFailToOpen(error: Error) {
print(debug: "connectionDidFailToOpen:\(error)")
app?.connectionDidFailToOpen(error: error)
}
func connectionDidClose(error: Error?) {
print(debug: "connectionDidClose:\(String(describing: error))")
app?.connectionDidClose(error: error)
}
func connectionWillReconnect(error: Error) {
print(debug: "connectionWillReconnect:\(error)")
app?.connectionWillReconnect(error: error)
}
func connectionDidReconnect() {
print(debug: "connectionDidReconnect")
app?.connectionDidReconnect()
}
}
......
......@@ -231,41 +231,4 @@ class ServerSession{
}
return false
}
func httpBody(boundary: String, _ uploadImage : ReqUploadImage) -> Data! {
var httpBody1 = "--\(boundary)\r\n"
httpBody1 += "Content-Disposition: form-data; name=\"ShipId\"\r\n"
httpBody1 += "\r\n"
httpBody1 += "\(uploadImage.shipId)\r\n"
httpBody1 += "--\(boundary)\r\n"
httpBody1 += "Content-Disposition: form-data; name=\"MessageId\"\r\n"
httpBody1 += "\r\n"
httpBody1 += "\(uploadImage.messageId)\r\n"
httpBody1 += "--\(boundary)\r\n"
httpBody1 += "Content-Disposition: form-data; name=\"Location\"\r\n"
httpBody1 += "\r\n"
httpBody1 += "\(uploadImage.location)\r\n"
httpBody1 += "--\(boundary)\r\n"
httpBody1 += "Content-Disposition: form-data; name=\"From\"\r\n"
httpBody1 += "\r\n"
httpBody1 += "\(uploadImage.from)\r\n"
httpBody1 += "--\(boundary)\r\n"
httpBody1 += "Content-Disposition: form-data; name=\"FromId\"\r\n"
httpBody1 += "\r\n"
httpBody1 += "\(uploadImage.fromId)\r\n"
httpBody1 += "--\(boundary)\r\n"
httpBody1 += "Content-Type: image/jpeg\r\n"
httpBody1 += "\r\n"
var httpBody = Data()
httpBody.append(httpBody1.data(using: .utf8)!)
httpBody.append(uploadImage.files)
var httpBody2 = "\r\n"
httpBody2 += "--\(boundary)--\r\n"
httpBody.append(httpBody2.data(using: .utf8)!)
return httpBody
}
}
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