Skip to content

Commit

Permalink
🤝 merge : pull request #30 from eunjjungg/feat/setting
Browse files Browse the repository at this point in the history
Feat/setting
  • Loading branch information
eunjjungg authored Jan 21, 2023
2 parents 9845df0 + aa53bfb commit b8fe068
Show file tree
Hide file tree
Showing 16 changed files with 775 additions and 36 deletions.
11 changes: 9 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@
android:theme="@style/Theme.Greme"
android:usesCleartextTraffic="true"
tools:targetApi="31">
<activity
android:name=".ui.view.SettingUserInfoActivity"
android:exported="false">
<meta-data
android:name="android.app.lib_name"
android:value="" />
</activity>
<activity
android:name=".ui.view.OtherUserDiaryActivity"
android:exported="false">
Expand Down Expand Up @@ -69,7 +76,7 @@
android:value="" />
</activity>
<activity
android:name=".ui.view.MainActivity"
android:name=".ui.view.LoginActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand All @@ -89,7 +96,7 @@
android:value="" />
</activity>
<activity
android:name=".ui.view.LoginActivity"
android:name=".ui.view.MainActivity"
android:exported="true">
<meta-data
android:name="android.app.lib_name"
Expand Down
32 changes: 32 additions & 0 deletions app/src/main/java/com/shootit/greme/model/SettingServerModel.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.shootit.greme.model

import com.google.gson.annotations.SerializedName

data class UserCurrentInfo(
@SerializedName("username")
val username: String,
@SerializedName("imageUrl")
val imageUrl: String,
@SerializedName("interestType")
val interestType: List<Int>,
@SerializedName("genderType")
val genderType: Int,
@SerializedName("area")
val area: String,
@SerializedName("purpose")
val purpose: String,
)

data class UserInterestAndGenderInfo(
@SerializedName("interestType")
val interestType: List<Int>,
@SerializedName("genderType")
val genderType: Int
)

data class UserAreaAndPurposeInfo(
@SerializedName("area")
val area: String,
@SerializedName("purpose")
val purpose: String
)
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,7 @@ object ConnectionObject {
val getSignOutRetrofitService: SignOutInterface by lazy {
getRetrofit.create(SignOutInterface::class.java)
}
val getSettingRetrofitService: SettingInterface by lazy {
getRetrofit.create(SettingInterface::class.java)
}
}
24 changes: 24 additions & 0 deletions app/src/main/java/com/shootit/greme/network/SettingInterface.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.shootit.greme.network

import com.shootit.greme.model.UserAreaAndPurposeInfo
import com.shootit.greme.model.UserCurrentInfo
import com.shootit.greme.model.UserInterestAndGenderInfo
import retrofit2.Response
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.PATCH

interface SettingInterface {

// get current profile
@GET("/user/profile")
suspend fun getCurrentProfile() : Response<UserCurrentInfo>

// set interest, gender
@PATCH("/user/profile1")
suspend fun setUserInterestAndGender(@Body data: UserInterestAndGenderInfo) : Response<Void>

// set area, purpose
@PATCH("/user/profile2")
suspend fun setUserAreaAndPurpose(@Body data: UserAreaAndPurposeInfo) : Response<Void>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.shootit.greme.repository

import android.util.Log
import com.shootit.greme.model.ChallengeActivityModel
import com.shootit.greme.model.UserAreaAndPurposeInfo
import com.shootit.greme.model.UserCurrentInfo
import com.shootit.greme.model.UserInterestAndGenderInfo
import com.shootit.greme.network.ConnectionObject

class SettingRepository {

companion object {
private var instance: SettingRepository? = null

fun getInstance(): SettingRepository? {
if(instance == null) instance = SettingRepository()
return instance
}
}

suspend fun getCurrentProfile(): UserCurrentInfo? {
val response = ConnectionObject
.getSettingRetrofitService.getCurrentProfile()
return if (response.isSuccessful) {
response.body() as UserCurrentInfo
} else {
Log.d("challenge server err", response.errorBody()?.string().toString())
null
}
}

suspend fun setUserInterestAndGender(userInterestAndGenderInfo: UserInterestAndGenderInfo): Boolean {
val response = ConnectionObject
.getSettingRetrofitService.setUserInterestAndGender(userInterestAndGenderInfo)
return response.isSuccessful
}

suspend fun setUserAreaAndPurpose(userAreaAndPurposeInfo: UserAreaAndPurposeInfo): Boolean {
val response = ConnectionObject
.getSettingRetrofitService.setUserAreaAndPurpose(userAreaAndPurposeInfo)
return response.isSuccessful
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ class InterestButton : ConstraintLayout {
true -> binding.iconBg.background.setTint(ContextCompat.getColor(context, R.color.icon_bg_selected))
else -> binding.iconBg.background.setTint(ContextCompat.getColor(context, R.color.icon_bg_unSelected))
}
listener?.interestButtonOnClick(binding.description.text.toString(), interestIsSelected)
if (this::listener.isInitialized) {
listener.interestButtonOnClick(binding.description.text.toString(), interestIsSelected)
}
}
}

Expand Down
24 changes: 19 additions & 5 deletions app/src/main/java/com/shootit/greme/ui/fragment/SettingFragment.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.shootit.greme.ui.fragment

import android.app.Activity
import android.app.AlertDialog
import android.content.Context
import android.content.DialogInterface
import android.content.Intent
import android.graphics.Color
import android.os.Bundle
import android.util.Log
Expand All @@ -11,13 +13,15 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.core.app.ActivityOptionsCompat
import androidx.core.content.ContextCompat
import com.shootit.greme.R
import com.shootit.greme.databinding.FragmentSettingBinding
import com.shootit.greme.model.ChallengeData
import com.shootit.greme.model.ResponseDateDiaryData
import com.shootit.greme.network.ConnectionObject
import com.shootit.greme.ui.adapter.ParticipatedChallengeAdapter
import com.shootit.greme.ui.view.SettingUserInfoActivity
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response
Expand Down Expand Up @@ -47,11 +51,21 @@ class SettingFragment : Fragment(R.layout.fragment_setting) {
val root: View = binding.root
initRecycler()
binding.btnProfileModify.setOnClickListener {
val profileeditFragment = ProfileEditFragment()
requireActivity().supportFragmentManager
.beginTransaction()
.replace(R.id.nav_fl, profileeditFragment)
.commitNow()

// profile setting 화면 이동
// TODO transition animation 고민중...
Intent(binding.root.context, SettingUserInfoActivity::class.java).also {
//val pair: androidx.core.util.Pair<View, String> = androidx.core.util.Pair(binding.btnProfileModify, "pageName")
//val optionPair = ActivityOptionsCompat.makeSceneTransitionAnimation(this@SettingFragment.activity as Activity, pair)
//startActivity(it, optionPair.toBundle())
startActivity(it)
}

// val profileeditFragment = ProfileEditFragment()
// requireActivity().supportFragmentManager
// .beginTransaction()
// .replace(R.id.nav_fl, profileeditFragment)
// .commitNow()
}
binding.btnLogout.setOnClickListener {
val builder = AlertDialog.Builder(requireContext())
Expand Down
Loading

0 comments on commit b8fe068

Please sign in to comment.