Skip to content

Commit

Permalink
Merge pull request #55 from tukcomCD2024/Android_front-end
Browse files Browse the repository at this point in the history
Android front end
  • Loading branch information
kmseongmin authored May 15, 2024
2 parents 53e59ef + a9164b9 commit 2a79a55
Show file tree
Hide file tree
Showing 95 changed files with 4,274 additions and 278 deletions.
Binary file modified .DS_Store
Binary file not shown.
Binary file added .github/.DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ out/

### SECRET KEY INFO ###
BackEnd/src/main/resources/firebase/webrtc.json
BackEnd/src/main/resources/ssl/keystore.p12
BackEnd/src/main/resources/ssl/keystore.p12
1 change: 1 addition & 0 deletions .idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified Android/.gradle/8.2/checksums/checksums.lock
Binary file not shown.
Binary file added Android/.gradle/8.2/checksums/md5-checksums.bin
Binary file not shown.
Binary file added Android/.gradle/8.2/checksums/sha1-checksums.bin
Binary file not shown.
Binary file not shown.
Binary file modified Android/.gradle/8.2/executionHistory/executionHistory.lock
Binary file not shown.
Binary file modified Android/.gradle/8.2/fileHashes/fileHashes.bin
Binary file not shown.
Binary file modified Android/.gradle/8.2/fileHashes/fileHashes.lock
Binary file not shown.
Binary file not shown.
Binary file modified Android/.gradle/buildOutputCleanup/buildOutputCleanup.lock
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
���ˌ��M��UV�
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
���ˌ��M��UV�
Binary file not shown.
Binary file not shown.
Empty file.
Binary file added Android/.gradle/file-system.probe
Binary file not shown.
51 changes: 51 additions & 0 deletions Android/.idea/assetWizardSettings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions Android/.idea/deploymentTargetDropDown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Android/.idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Android/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Android/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ dependencies {
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
implementation ("com.squareup.retrofit2:retrofit:2.9.0")
implementation ("com.squareup.retrofit2:converter-gson:2.9.0")
implementation ("com.squareup.retrofit2:converter-scalars:2.9.0")
implementation ("com.android.volley:volley:1.2.1")
// https://mvnrepository.com/artifact/org.webrtc/google-webrtc
//implementation("org.webrtc:google-webrtc:1.0.32006")
Expand Down
16 changes: 12 additions & 4 deletions Android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<uses-permission android:name="android.permission.READ_PHONE_STATE" />

<application
android:name=".MyApplication"
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
Expand All @@ -21,6 +22,12 @@
android:theme="@style/Base.Theme.Frontend_android"
android:usesCleartextTraffic="true"
tools:targetApi="31">
<activity
android:name=".Friend_Request"
android:exported="false" />
<activity
android:name=".FindPassword"
android:exported="true" />
<activity
android:name=".TestActivity"
android:exported="true" />
Expand All @@ -29,13 +36,14 @@
android:exported="true" />
<activity
android:name=".AddFriend"
android:exported="true" />
android:exported="true"
android:windowSoftInputMode="adjustResize" />
<activity
android:name=".Login"
android:name=".NaviActivity"
android:exported="true" />
<activity
android:name=".SignUp"
android:exported="false" />
android:exported="true" />
<!--
<meta-data
android:name="com.google.android.actions"
Expand All @@ -45,7 +53,7 @@
android:name=".MainActivity"
android:exported="true" />
<activity
android:name=".NaviActivity"
android:name=".Login"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,24 @@ package com.example.front_end_android
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import android.widget.Toast
import com.example.front_end_android.databinding.ActivityAddFriendBinding
import com.example.front_end_android.dataclass.AddFriendRequest
import com.example.front_end_android.dataclass.AddFriendResponse
import com.example.front_end_android.dataclass.ErrorResponse
import com.example.front_end_android.dataclass.LoginErrorResponse
import com.example.front_end_android.dataclass.LoginResponse
import com.example.front_end_android.util.AuthInterceptor
import com.google.gson.Gson
import com.google.gson.GsonBuilder
import okhttp3.OkHttpClient
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import retrofit2.converter.scalars.ScalarsConverterFactory

class AddFriend : AppCompatActivity() {

Expand All @@ -16,13 +32,75 @@ class AddFriend : AppCompatActivity() {
setContentView(binding.root)

binding.backFriendsImg.setOnClickListener {

finish()

}
binding.backFriendsTxt.setOnClickListener {

finish()
}

binding.friendRequestTxt.setOnClickListener {
val intent = Intent(this, Friend_Request::class.java)
startActivity(intent)
}

binding.sendFriendRequestBtn.setOnClickListener {

val accessToken = MyApplication.preferences.getString("AccessToken",".")
val senderEmail = MyApplication.preferences.getString("email",".")
val receiverEmail = binding.receiverEmailEdt.text.toString()

val client = OkHttpClient.Builder()
.addInterceptor(AuthInterceptor(accessToken))
.build()

val gson = GsonBuilder().setLenient().create()
val retrofit = Retrofit.Builder()
.baseUrl("https://4kringo.shop:8080/")
.client(client)
.addConverterFactory(ScalarsConverterFactory.create())
.addConverterFactory(GsonConverterFactory.create(gson))
.build()
val service = retrofit.create(RetrofitService::class.java)

val addFriendRequest = AddFriendRequest(senderEmail, receiverEmail)
val call = service.sendFriendRequestRetrofit(addFriendRequest)
Log.d("YMC", "accessToken: $accessToken")

call.enqueue(object : Callback<AddFriendResponse> {
override fun onResponse(call: Call<AddFriendResponse>, response: Response<AddFriendResponse>) {
val jsonResponse = response.body()
val message = jsonResponse?.message

if (response.isSuccessful) {
Log.d("YMC", "onResponse 성공: $jsonResponse $response")
Log.d("YMC", "message: $message")

} else {
Log.d("YMC", "onResponse 실패")//*
Log.d("YMC", "onResponse 실패: $jsonResponse $response")
Log.d("YMC", "message: $message")
val errorBody = response.errorBody()
if (errorBody != null) {
val errorJson = errorBody.string()
Log.d("YMC", "onResponse 실패 errorJson: $errorJson")

val errorResponse = Gson().fromJson(errorJson, ErrorResponse::class.java)

val status = errorResponse.status
val message = errorResponse.message
val data = errorResponse.data
val code = errorResponse.code
Log.d("YMC", "onResponse 실패 : $status $message $data $code")
} else {
Log.d("YMC", "onResponse 실패 : errorBody is null")
}
}

}
override fun onFailure(call: Call<AddFriendResponse>, t: Throwable) {
Log.d("YMC", "onFailure 에러: ${t.message}")//*
}
})

}

Expand Down
38 changes: 32 additions & 6 deletions Android/app/src/main/java/com/example/front_end_android/Calling.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ import android.speech.SpeechRecognizer
import android.speech.tts.TextToSpeech
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import com.google.gson.JsonObject
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import org.json.JSONObject
import java.util.Locale

class Calling : AppCompatActivity(), NewMessageInterface {
Expand Down Expand Up @@ -117,12 +119,14 @@ class Calling : AppCompatActivity(), NewMessageInterface {
}

private fun init(){
userName = intent.getStringExtra("username")//실제로는 intent로 유저 이름을 받아야함
userName = MyApplication.preferences.getString("email",".")
targetName = MyApplication.preferences.getString("targetName",".")
/*userName = intent.getStringExtra("username")//실제로는 intent로 유저 이름을 받아야함
if(userName == "asdf@naver.com"){
targetName = "asdfg@naver.com"
}else{
targetName = "asdf@naver.com"//실제로는 intent로 전화를 거는 상대방을 이름을 받아야함
}
}*/
socketRepository = SocketRepository(this)
userName?.let { socketRepository?.initSocket(it) }
rtcClient = RTCClient(application, userName!!, socketRepository!!, object : PeerConnectionObserver(){
Expand Down Expand Up @@ -229,9 +233,19 @@ class Calling : AppCompatActivity(), NewMessageInterface {
}
"answer_received" ->{
Log.d("YMC", "answer_received: $message")//*

val data11 = message.data
Log.d("YMC", "data: $data11")//*

val sdpStartIndex = message.data.toString().indexOf("sdp=")
val sdpEndIndex = message.data.toString().indexOf("}", startIndex = sdpStartIndex)
val sdpValueAnswer = message.data.toString().substring(sdpStartIndex + 4, sdpEndIndex) // "+ 4" to skip "sdp="

Log.d("YMC", "sdpValueAnswer: $sdpValueAnswer")
val session = SessionDescription(
SessionDescription.Type.ANSWER,
message.data.toString()
sdpValueAnswer.toString()
//message.data.toString()
)
rtcClient?.onRemoteSessionReceived(session)
runOnUiThread {
Expand All @@ -242,6 +256,15 @@ class Calling : AppCompatActivity(), NewMessageInterface {
"offer_received" -> {
runOnUiThread {
Log.d("YMC", "offer_received: $message")//*

val data11 = message.data
Log.d("YMC", "data: $data11")//*

val sdpStartIndex = message.data.toString().indexOf("sdp=")
val sdpEndIndex = message.data.toString().indexOf("}", startIndex = sdpStartIndex)
val sdpValueOffer = message.data.toString().substring(sdpStartIndex + 4, sdpEndIndex) // "+ 4" to skip "sdp="

Log.d("YMC", "sdpValueOffer: $sdpValueOffer")
setIncomingCallLayoutVisible()
binding.incomingNameTV.text = "${message.name.toString()} is calling you"
binding.acceptButton.setOnClickListener {
Expand All @@ -255,10 +278,13 @@ class Calling : AppCompatActivity(), NewMessageInterface {
}
val session = SessionDescription(
SessionDescription.Type.OFFER,
message.data.toString()
sdpValueOffer.toString()
//message.data.toString()
)
rtcClient?.onRemoteSessionReceived(session)
Log.d("YMC", "@@@@@@@@@@@@@@@")
rtcClient?.answer(message.name!!)
Log.d("YMC", "###############")
targetName = message.name!!
binding.remoteViewLoading.visibility = View.GONE
}
Expand Down Expand Up @@ -339,7 +365,7 @@ class Calling : AppCompatActivity(), NewMessageInterface {
private val recognitionListener: RecognitionListener = object : RecognitionListener {
// 말하기 시작할 준비가되면 호출
override fun onReadyForSpeech(params: Bundle) {
Toast.makeText(applicationContext, "음성인식 시작", Toast.LENGTH_SHORT).show()
//Toast.makeText(applicationContext, "음성인식 시작", Toast.LENGTH_SHORT).show()
//binding.tvState.text = "이제 말씀하세요!"
}
// 말하기 시작했을 때 호출
Expand Down Expand Up @@ -375,7 +401,7 @@ class Calling : AppCompatActivity(), NewMessageInterface {
SpeechRecognizer.ERROR_SPEECH_TIMEOUT -> "말하는 시간초과"
else -> "알 수 없는 오류임"
}
Toast.makeText(applicationContext, "에러 발생: $message", Toast.LENGTH_SHORT).show()
//Toast.makeText(applicationContext, "에러 발생: $message", Toast.LENGTH_SHORT).show()
//binding.tvState.text = "에러 발생: $message"
// 에러 발생 시 듣기 재시작
if(isTranslateMode == true){
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.example.front_end_android

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.example.front_end_android.databinding.ActivityFindPasswordBinding

class FindPassword : AppCompatActivity() {

private lateinit var binding:ActivityFindPasswordBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityFindPasswordBinding.inflate(layoutInflater)
setContentView(binding.root)



}
}
Loading

0 comments on commit 2a79a55

Please sign in to comment.