Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/#9 setting tab UI #21

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions .idea/deploymentTargetDropDown.xml

This file was deleted.

15 changes: 8 additions & 7 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" >
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
Expand All @@ -18,11 +18,12 @@
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/Theme.PINPLE_AOS"
tools:targetApi="31" >
tools:targetApi="31">

<activity
android:name=".SettingTabActivity"
android:label="설정"
android:parentActivityName=".MainActivity" />
android:name=".PreferenceActivity"
android:exported="true" />

<activity
android:name=".ProfileActivity"
android:exported="false" />
Expand All @@ -34,7 +35,7 @@
android:exported="false" />
<activity
android:name=".SplashActivity"
android:exported="true" >
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand All @@ -52,7 +53,7 @@
android:exported="true" />
<activity
android:name="com.kakao.sdk.auth.AuthCodeHandlerActivity"
android:exported="true" >
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import android.app.Application
import com.kakao.sdk.common.KakaoSdk

class GlobalApplication : Application() {
var kakaolgoin: Int? = null
var googlelogin: Int? = null
override fun onCreate() {
super.onCreate()

KakaoSdk.init(this, "a85a328d0b6714f24de2203795161478")
}
}
3 changes: 0 additions & 3 deletions app/src/main/java/com/example/pinple_aos/LandingActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@ package com.example.pinple_aos

import android.content.Intent
import android.os.Bundle
import android.util.Log
import android.widget.ImageButton
import androidx.appcompat.app.AppCompatActivity
import androidx.viewpager2.widget.ViewPager2
import com.example.pinple_aos.databinding.ActivityLandingBinding
import com.kakao.sdk.common.util.Utility


class LandingActivity: AppCompatActivity() {
Expand Down
32 changes: 14 additions & 18 deletions app/src/main/java/com/example/pinple_aos/LoginActivity.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package com.example.pinple_aos

import android.app.Activity
import android.app.Application
import android.content.Context
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
Expand All @@ -13,18 +11,14 @@ import com.google.android.gms.auth.api.signin.GoogleSignIn
import com.google.android.gms.auth.api.signin.GoogleSignInOptions
import com.google.android.gms.common.api.ApiException
import com.kakao.sdk.auth.model.OAuthToken
import com.kakao.sdk.common.KakaoSdk

import com.kakao.sdk.user.UserApiClient

class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
KakaoSdk.init(this, "a85a328d0b6714f24de2203795161478")
}
}

class LoginActivity : AppCompatActivity() {



private fun moveToAnotherPage() {
val intent = Intent(this, SettingNameActivity::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION)
Expand All @@ -37,21 +31,26 @@ class LoginActivity : AppCompatActivity() {
UserApiClient.instance.loginWithKakaoAccount(this, callback = kakaoAccountLoginCallback)
} else if (token != null) {
// 카카오톡 로그인 성공
// 추가 작업 수행
val app = application as GlobalApplication
app.kakaolgoin = 1
moveToAnotherPage()

}
}

private val kakaoAccountLoginCallback: (OAuthToken?, Throwable?) -> Unit = { token, error ->
if (error != null) {
// 카카오 계정 로그인 실패
Toast.makeText(this, "로그인 실패: ${error.message}", Toast.LENGTH_SHORT).show()
} else if (token != null) {
// 카카오 계정 로그인 성공
// 추가 작업 수행
val app = application as GlobalApplication
app.kakaolgoin = 1
moveToAnotherPage()
}
}


private val googleSignInLauncher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
if (result.resultCode == Activity.RESULT_OK) {
val data: Intent? = result.data
Expand All @@ -75,7 +74,6 @@ class LoginActivity : AppCompatActivity() {
googleLoginButton.setOnClickListener {
signInWithGoogle()
}

}

private fun signInWithGoogle() {
Expand All @@ -93,15 +91,13 @@ class LoginActivity : AppCompatActivity() {
try {
val account = task.getResult(ApiException::class.java)
// 구글 로그인 성공
// 추가 작업 수행
val app = application as GlobalApplication
app.googlelogin = 1
moveToAnotherPage()

} catch (e: ApiException) {
// 구글 로그인 실패
Toast.makeText(this, "구글 로그인 실패", Toast.LENGTH_SHORT).show()
}




}
}
}
4 changes: 2 additions & 2 deletions app/src/main/java/com/example/pinple_aos/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.example.pinple_aos

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.navigation.Navigation
Expand All @@ -14,6 +15,7 @@ import androidx.fragment.app.Fragment
import android.util.Log
import androidx.core.content.ContextCompat
import android.graphics.drawable.Drawable
import android.widget.ImageButton

class MainActivity : AppCompatActivity() {

Expand All @@ -28,8 +30,6 @@ class MainActivity : AppCompatActivity() {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)



bottomNavigationView = findViewById(R.id.bottomNavigationView)

// MainFragment로 시작
Expand Down
126 changes: 126 additions & 0 deletions app/src/main/java/com/example/pinple_aos/PreferenceActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
package com.example.pinple_aos

import android.annotation.SuppressLint
import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.util.Log
import androidx.appcompat.app.AppCompatActivity
import android.widget.Button
import android.widget.TextView
import android.widget.Toast
import com.kakao.sdk.user.UserApiClient
import com.google.android.gms.auth.api.signin.GoogleSignIn
import com.google.android.gms.auth.api.signin.GoogleSignInOptions
import com.google.android.gms.auth.api.signin.GoogleSignInClient
import kotlin.math.log

class PreferenceActivity : AppCompatActivity() {

private lateinit var googleSignInClient: GoogleSignInClient



@SuppressLint("SetTextI18n")
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_preference)

// 구글 로그인 설정 초기화
val gso = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestEmail()
.build()
googleSignInClient = GoogleSignIn.getClient(this, gso)

// application에서 값 가져오기
val app = application as GlobalApplication
val kakaologinKey = app.kakaolgoin
val googleloginKey = app.googlelogin

// 로그인 api에 따라서 텍스트 변경
val loginTxt = findViewById<TextView>(R.id.google_kakao_login_inf)

if (kakaologinKey == 1) loginTxt.text = "(카카오로 로그인)"
else if (googleloginKey == 1) loginTxt.text = "(구글로 로그인)"


//api에서 계정 이메일 가져오기(구현중)
val emailTxt = findViewById<TextView>(R.id.email_inf)

if (kakaologinKey == 1) emailTxt.text = "[email protected]"
else if (googleloginKey == 1) emailTxt.text = "[email protected]"



//로그아웃 부분
val logoutButton = findViewById<Button>(R.id.logout_btn)
logoutButton.setOnClickListener {
if (kakaologinKey == 1) {
// 카카오 로그아웃 실행
UserApiClient.instance.logout { error ->
if (error != null) {
}
else {
val app = application as GlobalApplication
app.kakaolgoin = 0
moveToMainActivity()
}
}
}
if (googleloginKey == 1) {
// 구글 로그아웃 실행
googleSignInClient.signOut().addOnCompleteListener { task ->
if (task.isSuccessful) {
// 구글 로그아웃 성공 처리
val app = application as GlobalApplication
app.googlelogin = 0
moveToMainActivity()
} else {
// 구글 로그아웃 실패 처리
}
}
}
}

//회원탈퇴 부분
val withdrawlButton = findViewById<Button>(R.id.Withdrawal_btn)

withdrawlButton.setOnClickListener {
if (kakaologinKey == 1) {
// 카카오 회원탈퇴 실행
UserApiClient.instance.unlink { error ->
if (error != null) {
}
else {
val app = application as GlobalApplication
app.kakaolgoin = 0
moveToMainActivity()
}
}
}
if (googleloginKey == 1) {
// 구글 회원탈퇴 실행
googleSignInClient.revokeAccess().addOnCompleteListener { task ->
if (task.isSuccessful) {
// 구글 회원탈퇴 성공 처리
val app = application as GlobalApplication
app.googlelogin = 0
moveToMainActivity()
} else {
// 구글 회원탈퇴 실패 처리
}
}
}

}


}

private fun moveToMainActivity() {
val intent = Intent(this, LoginActivity::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION)
startActivity(intent)
finish()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class ProfileActivity : AppCompatActivity() {
}

activeButton.setOnClickListener {
val intent = Intent(this, MainActivity::class.java)
val intent = Intent(this, PreferenceActivity::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION)
startActivity(intent)
}
Expand Down
Loading