Skip to content

Commit

Permalink
[feat] #139 Modify Project & Modify View My Info API
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-j0y committed May 1, 2022
1 parent 50b12fe commit 47e39bb
Show file tree
Hide file tree
Showing 43 changed files with 640 additions and 404 deletions.
6 changes: 3 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@

<application
android:name=".util.InfraApplication"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:icon="@mipmap/ic_app_icon"
android:label="인프라"
android:roundIcon="@mipmap/ic_app_icon_round"
android:supportsRtl="true"
android:theme="@style/Theme.InfraAndroid"
android:usesCleartextTraffic="true"
Expand Down
Binary file added app/src/main/ic_app_icon-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/ic_launcher-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.example.infraandroid.home.view.fragment

import android.widget.Toast
import androidx.navigation.findNavController
import com.bumptech.glide.Glide
import com.example.infraandroid.util.InfraApplication
import com.example.infraandroid.R
import com.example.infraandroid.databinding.FragmentHomeBinding
Expand All @@ -28,6 +29,11 @@ class HomeFragment : BaseFragment<FragmentHomeBinding>(R.layout.fragment_home) {

override fun FragmentHomeBinding.onCreateView(){
binding.homeUserHiTv.text = getString(R.string.home_user_hi).format(InfraApplication.prefs.getString("userNickName", "null"))
Glide.with(requireActivity())
.load(InfraApplication.prefs.getString("userProfileImg", "null"))
.circleCrop()
.error(R.drawable.user_photo)
.into(binding.homeUserPhotoIv)
}

override fun FragmentHomeBinding.onViewCreated() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ data class ResponseLoginData(
@SerializedName("user_nickname")
val userNickName : String,
@SerializedName("jwtRefreshIdx")
val refreshToken : Int
val refreshToken : Int,
@SerializedName("user_prPhoto")
val userProfileImg : String
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class LoginFragment : BaseFragment<FragmentLoginBinding>(R.layout.fragment_login
InfraApplication.prefs.setString("refreshToken", response.body()?.result?.refreshToken.toString())
InfraApplication.prefs.setString("userId", response.body()?.result?.userId.toString())
InfraApplication.prefs.setString("userNickName", response.body()?.result?.userNickName.toString())
InfraApplication.prefs.setString("userProfileImg", response.body()?.result?.userProfileImg.toString())
InfraApplication.prefs.setUserId(response.body()?.result?.userId.toString())
InfraApplication.prefs.setUserPW(inputPw)
Toast.makeText(requireActivity(),"요청에 성공하셨습니다.", Toast.LENGTH_SHORT).show()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package com.example.infraandroid.myinfo

import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.fragment.app.Fragment
import androidx.navigation.findNavController
import androidx.navigation.fragment.findNavController
import com.bumptech.glide.Glide
import com.example.infraandroid.util.InfraApplication
import com.example.infraandroid.R
import com.example.infraandroid.databinding.FragmentMyInfoBinding
Expand All @@ -34,6 +37,15 @@ class MyInfoFragment : Fragment() {

mBinding = binding
mBinding?.myInfoUserNameTv?.text = getString(R.string.my_info_name).format(InfraApplication.prefs.getString("userNickName","null"))

mBinding?.myInfoUserProfileIv?.let {
Glide.with(requireActivity())
.load(InfraApplication.prefs.getString("userProfileImg", "null"))
.circleCrop()
.error(R.drawable.user_photo)
.into(it)
}

return mBinding?.root
}

Expand Down Expand Up @@ -75,6 +87,17 @@ class MyInfoFragment : Fragment() {
val intent = Intent(this.context, OssLicensesMenuActivity::class.java)
startActivity(intent)
}

mBinding!!.csLinearLayout.setOnClickListener {
Toast.makeText(requireActivity(), "인프라 고객센터 이메일\n" +
"[email protected]", Toast.LENGTH_LONG).show()
}

mBinding!!.serviceLinearLayout.setOnClickListener {
val intent = Intent(Intent.ACTION_VIEW, Uri.parse("https://chrome-fortnight-803.notion.site/41f70ebd4eed4b40928815e7e1796466"))
startActivity(intent)
}

}

override fun onDestroyView() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@ class MyProjectViewModel : ViewModel() {
private val _currentDay = MutableLiveData<String?>()
val currentDay: LiveData<String?> = _currentDay

private val _currentProjectPhotoStatus = MutableLiveData<String?>(null)
val currentProjectPhotoStatus: LiveData<String?> = _currentProjectPhotoStatus

fun deleteProjectPhoto(){
_currentProjectPhotoStatus.value = "삭제"
}

fun updateProjectPhoto(){
_currentProjectPhotoStatus.value = "등록"
}

fun updateObservingProjectNum(projectNum: Int?){
_currentObservingProjectNum.value = projectNum!!
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ class MyIdeaModifyPageFragment : BaseFragment<FragmentMyInfoProjectModifyBinding
binding.deletePhotoImageView.isGone = true
mediaPath = null
fileToUpload = null
viewModel.deleteProjectPhoto()
}

// 완료 버튼 눌렀을 때 프로젝트 수정 완료
Expand All @@ -309,6 +310,9 @@ class MyIdeaModifyPageFragment : BaseFragment<FragmentMyInfoProjectModifyBinding
val requestBody = file.asRequestBody("image/jpeg".toMediaTypeOrNull())
fileToUpload = MultipartBody.Part.createFormData("images", file.name, requestBody)
}
else{
fileToUpload = null
}

Log.d(TAG, "onViewCreated: 수정완료버튼${viewModel.currentMyProjectSubCategory.value}" )

Expand All @@ -323,7 +327,8 @@ class MyIdeaModifyPageFragment : BaseFragment<FragmentMyInfoProjectModifyBinding
"\"pj_endTerm\" : "+ endTermString +"," +
"\"pj_deadline\" : "+ deadlineString +"," +
"\"pj_totalPerson\" : "+ binding.numberOfTeamEditText.text.toString() +"," +
"\"hashtag\" : ["+ hashTagString +"]}"
"\"hashtag\" : ["+ hashTagString +"]," +
"\"pjPhoto\" : \"" + viewModel.currentProjectPhotoStatus.value.toString() + "\"}"

val jsonList = jsonString.toRequestBody("text/plain".toMediaTypeOrNull())
val call : Call<ResponseModifyProjectData> = ServiceCreator.myProjectService
Expand Down Expand Up @@ -401,6 +406,7 @@ class MyIdeaModifyPageFragment : BaseFragment<FragmentMyInfoProjectModifyBinding
)!!
cursor.moveToFirst()
mediaPath = cursor.getString(cursor.getColumnIndex(MediaStore.MediaColumns.DATA))
viewModel.updateProjectPhoto()
}
else{
Toast.makeText(requireActivity(), "이미지 업로드 실패", Toast.LENGTH_SHORT).show()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
package com.example.infraandroid.myinfo.myinfomodify.model

import okhttp3.MultipartBody
import okhttp3.RequestBody
import retrofit2.Call
import retrofit2.http.Header
import retrofit2.http.PATCH
import retrofit2.http.Path
import retrofit2.http.*

interface MyInfoService {
@PATCH("/user/profile/info/{id}")
@GET("/user/profile/info/{id}")
fun viewMyInfo(
@Header("X-ACCESS-TOKEN") jwt: String,
@Path("id") userId : String
): Call<ResponseViewMyInfoData>

@Multipart
@PATCH("/user/profile/info/{id}")
fun ModifyMyInfo(
fun modifyMyInfo(
@Header("X-ACCESS-TOKEN") jwt: String,
@Path("id") userId : String
): Call<RequestModifyMyInfoData>

@Path("id") userId : String,
@Part("user_nickname") userNickName : RequestBody,
@Part("user_prPhoto") userProfileStatus : RequestBody,
@Part images: MultipartBody.Part?
): Call<ResponseModifyMyInfoData>

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.example.infraandroid.myinfo.myinfomodify.model

data class RequestModifyMyInfoData(
data class ResponseModifyMyInfoData(
val isSuccess: Boolean,
val code: Int,
val message: String,
Expand Down
Loading

0 comments on commit 47e39bb

Please sign in to comment.